lkml.org 
[lkml]   [2019]   [Nov]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] xtensa: improve stack dumping
On Wed, Nov 6, 2019 at 12:51 PM Dmitry Safonov <dima@arista.com> wrote:
> On 11/6/19 6:16 PM, Max Filippov wrote:
> > @@ -512,10 +510,12 @@ void show_stack(struct task_struct *task, unsigned long *sp)
> > for (i = 0; i < kstack_depth_to_print; i++) {
> > if (kstack_end(sp))
> > break;
> > - pr_cont(" %08lx", *sp++);
> > + sprintf(buf + (i % 8) * 9, " %08lx", *sp++);
>
> buf is on the stack, does sprintf() put null-terminator for hex?

It should put null-terminator regardless of the format string.

> > if (i % 8 == 7)
> > - pr_cont("\n");
> > + pr_info("%s\n", buf);
> > }
> > + if (i % 8)
> > + pr_info("%s\n", buf);
>
> If the stack trace ends with (i % 8 == 7), you'll double-print the last
> line?

No, I don't think so. 'For' loop condition is checked after i++, so if
loop ends with i % 8 == 7 then its last iteration was done with
i % 8 == 6 and thus the buf haven't been printed.

--
Thanks.
-- Max

\
 
 \ /
  Last update: 2019-11-06 23:01    [W:0.079 / U:0.424 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site