[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMo8BfLDk_ztsG0eSFgd2+hW9-MqrOKmPn0kSvCeq3uBGXapHg@mail.gmail.com>
Date: Wed, 6 Nov 2019 14:00:14 -0800
From: Max Filippov <jcmvbkbc@...il.com>
To: Dmitry Safonov <dima@...sta.com>
Cc: "open list:TENSILICA XTENSA PORT (xtensa)"
<linux-xtensa@...ux-xtensa.org>, Chris Zankel <chris@...kel.net>,
LKML <linux-kernel@...r.kernel.org>,
Petr Mladek <pmladek@...e.com>
Subject: Re: [PATCH] xtensa: improve stack dumping
On Wed, Nov 6, 2019 at 12:51 PM Dmitry Safonov <dima@...sta.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
Powered by blists - more mailing lists