[DTrace-devel] [PATCH v2] Add support for array/struct/union to trace()

Eugene Loh eugene.loh at oracle.com
Sat Jan 29 04:01:58 UTC 2022


For the moment, just two questions:

Does this look correct?

# dtrace -n '
struct {
   int8_t x;
} A;

BEGIN {
   A.x = 0x34;
   trace(A);
   exit(0);
}'
dtrace: description '
struct ' matched 1 probe
CPU     ID                    FUNCTION:NAME
   2      1                           :BEGIN

No output?

And...

On 1/28/22 2:25 PM, Kris Van Hees via DTrace-devel wrote:
> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> @@ -905,6 +905,25 @@ static const uint_t	ldstw[] = {
> +/*
> + * When loading bit-fields, we want to convert a byte count in the range
> + * 1-8 to the closest power of 2 (e.g. 3->4, 5->8, etc).  The clp2() function
> + * is a clever implementation from "Hacker's Delight" by Henry Warren, Jr.
> + */

What is "the range 1-8"?  Can't the input be any 32-bit integer? (Well, 
any 64-bit integer that fits into the lowest 32 bits.)  I know this is a 
pre-existing comment, but if it's wrong and the code is being touched, 
we can fix it.

> +static size_t
> +clp2(size_t x)
> +{
> +	x--;
> +
> +	x |= (x >> 1);
> +	x |= (x >> 2);
> +	x |= (x >> 4);
> +	x |= (x >> 8);
> +	x |= (x >> 16);
> +
> +	return x + 1;
> +}



More information about the DTrace-devel mailing list