[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <78ff494e-2fe2-b881-29ca-84992e26d415@arista.com>
Date: Wed, 6 Nov 2019 22:18:45 +0000
From: Dmitry Safonov <dima@...sta.com>
To: Max Filippov <jcmvbkbc@...il.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 11/6/19 10:00 PM, Max Filippov wrote:
> 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.
Always unsure what to expect from printf() :)
>
>>> 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.
Ah, right - me being stupid.
Thanks,
Dmitry
Powered by blists - more mailing lists