2006-01-05 06:22:11

by Dave Jones

[permalink] [raw]
Subject: dual line backtraces for i386.

Another 'get better debug info from users' patch.
x86-64 has had this since day one, and I don't know why
no-one ever ported it to i386.

Instead of using one line per function call in the backtrace,
we can fit two per line.

Signed-off-by: Dave Jones <[email protected]>

--- linux-2.6.15/arch/i386/kernel/traps.c~ 2005-12-01 04:25:36.000000000 -0500
+++ linux-2.6.15/arch/i386/kernel/traps.c 2005-12-01 04:36:19.000000000 -0500
@@ -116,6 +116,7 @@ static inline unsigned long print_contex
unsigned long *stack, unsigned long ebp)
{
unsigned long addr;
+ char space=0;

#ifdef CONFIG_FRAME_POINTER
while (valid_stack_ptr(tinfo, (void *)ebp)) {
@@ -131,9 +132,17 @@ static inline unsigned long print_contex
if (__kernel_text_address(addr)) {
printk(" [<%08lx>]", addr);
print_symbol(" %s", addr);
- printk("\n");
+ if (space == 0) {
+ printk(" ");
+ space = 1;
+ } else {
+ printk("\n");
+ space = 0;
+ }
}
}
+ if (space==1)
+ printk("\n");
#endif
return ebp;
}


2006-01-05 18:21:51

by Chuck Ebbert

[permalink] [raw]
Subject: Re: dual line backtraces for i386.

In-Reply-To: <[email protected]>

On Thu, 5 Jan 2006 at 01:22:08 -0500, Dave Jones wrote:

> --- linux-2.6.15/arch/i386/kernel/traps.c~ 2005-12-01 04:25:36.000000000 -0500
> +++ linux-2.6.15/arch/i386/kernel/traps.c 2005-12-01 04:36:19.000000000 -0500
> @@ -116,6 +116,7 @@ static inline unsigned long print_contex
> unsigned long *stack, unsigned long ebp)
> {
> unsigned long addr;
> + char space=0;

char space = 0;


> - printk("\n");
> + if (space == 0) {
> + printk(" ");
> + space = 1;
> + } else {
> + printk("\n");
> + space = 0;
> + }

Why not:

printk(space == 0 ? " " : "\n");
space = !space;


> + if (space==1)
> + printk("\n");

if (space == 1)

--
Chuck
Currently reading: _Thud!_ by Terry Pratchett

2006-01-06 02:11:39

by Dave Jones

[permalink] [raw]
Subject: Re: dual line backtraces for i386.

On Thu, Jan 05, 2006 at 01:18:32PM -0500, Chuck Ebbert wrote:

> > - printk("\n");
> > + if (space == 0) {
> > + printk(" ");
> > + space = 1;
> > + } else {
> > + printk("\n");
> > + space = 0;
> > + }
>
> Why not:
>
> printk(space == 0 ? " " : "\n");
> space = !space;

readability ?
Personally, I despise the ternary operator, because it makes me
stop to try to parse it every time I see it. With the code I wrote
it's blindlingly obvious what is going on.

Dave

2006-01-06 18:40:42

by Chuck Ebbert

[permalink] [raw]
Subject: Re: dual line backtraces for i386.

In-Reply-To: <[email protected]>

On Thu, 5 Jan 2006 at 16:28:02 -0500, Dave Jones wrote:

> > Why not:
> >
> > printk(space == 0 ? " " : "\n");
> > space = !space;
>
> readability ?

Well, if I were going for _un_readability I'd have suggested:

printk(space = !space ? " " : "\n");

:)

> Personally, I despise the ternary operator, because it makes me
> stop to try to parse it every time I see it.

I think it's a psychological thing because it makes you spend as
much time parsing a single line as it would to parse a whole
if-then-else and it just feels wrong somehow.

> With the code I wrote
> it's blindlingly obvious what is going on.

For simple espressions I think it's about the same, but like you said
it's a personal thing. A soon as you start nesting cases the 'if'
becomes much clearer. (People who nest ternary expressions should
be taken out and shot.)
--
Chuck
Currently reading: _Thud!_ by Terry Pratchett

2006-01-06 19:18:13

by Jan Engelhardt

[permalink] [raw]
Subject: Re: dual line backtraces for i386.

>> > printk(space == 0 ? " " : "\n");
>> > space = !space;
>>
>> readability ?
>
>Well, if I were going for _un_readability I'd have suggested:
>
> printk(space = !space ? " " : "\n");

Anyone voting for "\t" instead of " "?


Jan Engelhardt
--

2006-01-06 19:33:38

by Bob Copeland

[permalink] [raw]
Subject: Re: dual line backtraces for i386.

On 1/6/06, Jan Engelhardt <[email protected]> wrote:
> >> > printk(space == 0 ? " " : "\n");
> >> > space = !space;
> >>
> >> readability ?
> >
> >Well, if I were going for _un_readability I'd have suggested:
> >
> > printk(space = !space ? " " : "\n");
>
> Anyone voting for "\t" instead of " "?

Sure: if you use '\t' then you can do:

printk("%c", 9+space++);
space &= 1;

No branches ;)

2006-01-07 00:02:41

by Mitchell Blank Jr

[permalink] [raw]
Subject: Re: dual line backtraces for i386.

Bob Copeland wrote:
> Sure: if you use '\t' then you can do:
>
> printk("%c", 9+space++);
> space &= 1;

Please...

char space = '\t';
[...]
printk("%c", space);
space = ('\t' + '\n') - space;

Even fewer instructions and actually somewhat understandable.

-Mitch

2006-01-07 11:18:08

by Jan Engelhardt

[permalink] [raw]
Subject: Re: dual line backtraces for i386.

>Please...
>
> char space = '\t';
> [...]
> printk("%c", space);
> space = ('\t' + '\n') - space;
>
>Even fewer instructions and actually somewhat understandable.

I see the days of kernelgolf coming...



Jan Engelhardt
--