diff options
| author | Mark Johnston <markj@FreeBSD.org> | 2025-09-10 14:33:58 +0000 |
|---|---|---|
| committer | Mark Johnston <markj@FreeBSD.org> | 2025-09-10 16:00:13 +0000 |
| commit | 3877025f52ee205fe99ad4ff68229933d57e4bcb (patch) | |
| tree | f38c8c0eff536ba64e8c56a7f84beaac0f8887a5 | |
| parent | 0b68e3ce6e0e437fa480b25a0ef706ee08562257 (diff) | |
dtrace: Use a size_t to represent a buffer size in the printm action
printm is specific to the FreeBSD dtrace port. I believe it's
effectively the same as tracemem(), though printm apparently predates
it. It stores the size of the buffer of traced data inline. Currently
it represents that size using a uintptr_t, which isn't really right and
poses challenges when porting to CHERI because
`DTRACE_STORE(uintptr_t, ...` requires the destination to be suitably
aligned, but this isn't necessary since we're just storing a size.
Convert to using a size_t. This should be a no-op since
sizeof(uintptr_t) == sizeof(size_t) on non-CHERI platforms (and besides
that I don't see a reason to use printm() when tracemem() is available
and is simpler to use.)
Reviewed by: Domagoj Stolfa, avg
MFC after: 2 weeks
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D52055
| -rw-r--r-- | cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c | 9 | ||||
| -rw-r--r-- | sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c | 11 |
2 files changed, 10 insertions, 10 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c index 385c9d78bdfc..b311b5425587 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c @@ -2242,11 +2242,10 @@ dt_format_bytes_get(dtrace_hdl_t *dtp, caddr_t addr, size_t nbytes) static int dt_format_memory(dtrace_hdl_t *dtp, caddr_t addr) { - - size_t nbytes = *((uintptr_t *) addr); + size_t nbytes = *((size_t *) addr); char *s; - s = dt_format_bytes_get(dtp, addr + sizeof(uintptr_t), nbytes); + s = dt_format_bytes_get(dtp, addr + sizeof(size_t), nbytes); if (s == NULL) return (-1); @@ -2260,9 +2259,9 @@ static int dt_print_memory(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr) { int quiet = (dtp->dt_options[DTRACEOPT_QUIET] != DTRACEOPT_UNSET); - size_t nbytes = *((uintptr_t *) addr); + size_t nbytes = *((size_t *) addr); - return (dt_print_bytes(dtp, fp, addr + sizeof(uintptr_t), + return (dt_print_bytes(dtp, fp, addr + sizeof(size_t), nbytes, 50, quiet, 1)); } diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c index 7192df200ae2..8078f3f6d4b1 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c +++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c @@ -7761,7 +7761,8 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1, uintptr_t *memref = (uintptr_t *)(uintptr_t) val; if (!DTRACE_INSCRATCHPTR(&mstate, - (uintptr_t)memref, 2 * sizeof(uintptr_t))) { + (uintptr_t) memref, + sizeof (uintptr_t) + sizeof (size_t))) { *flags |= CPU_DTRACE_BADADDR; continue; } @@ -7773,21 +7774,21 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1, * Check if the size exceeds the allocated * buffer size. */ - if (size + sizeof(uintptr_t) > dp->dtdo_rtype.dtdt_size) { + if (size + sizeof (size_t) > + dp->dtdo_rtype.dtdt_size) { /* Flag a drop! */ *flags |= CPU_DTRACE_DROP; continue; } /* Store the size in the buffer first. */ - DTRACE_STORE(uintptr_t, tomax, - valoffs, size); + DTRACE_STORE(size_t, tomax, valoffs, size); /* * Offset the buffer address to the start * of the data. */ - valoffs += sizeof(uintptr_t); + valoffs += sizeof(size_t); /* * Reset to the memory address rather than |
