Re: [PATCH 1/2] Unify the handling of stack traces in the consumer

Eugene Loh <[email protected]>
Newsgroups dev.linux.lists.dtrace
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.