[DTrace-devel] [PATCH 1/2] Unify the handling of stack traces in the consumer

Eugene Loh eugene.loh at oracle.com
Sun Sep 28 23:52:52 UTC 2025


On 9/28/25 19:26, Kris Van Hees wrote:

> On Sun, Sep 28, 2025 at 01:50:02AM -0400, Eugene Loh wrote:
>
>> For kernel stacks, I guess size is always 8.  Could mention that? Also not a
>> big deal.
> I am not sure what you mean by this?  The size of the data that is set aide to
> store the stack trace depends on the number of frames that is requested.

Right.  I mean the size of a PC.

The code used to have a function

int
dt_print_stack(dtp, fp, format, addr, depth, size)
{
         for (i = 0; i < depth; i++) {
                 switch (size) {
                 case sizeof(uint32_t):
                         /* LINTED - alignment */
                         pc = *((uint32_t *)addr);
                         break;
                 case sizeof(uint64_t):
                         /* LINTED - alignment */
                         pc = *((uint64_t *)addr);
                         break;
                 default:
                         return dt_set_errno(dtp, EDT_BADSTACKPC);
                 }
                 addr += size;
                 [...]
         }
}

(Lots of code redacted.)  Anyhow, we feed in a "size" argument.  The 
ported function is

int
dt_print_stack_kernel(dtp, fp, format, addr, indent, depth)
{
         for (i = 0; i < depth; i++) {
                 pc = *((uint64_t *)addr);
                 if (pc == 0)
                 addr += sizeof(pc);
                 [...]
         }
}

which assumes 8-byte values.  Again, no big deal.



More information about the DTrace-devel mailing list