Skip to contentSkip to conversation

x86-64: improve the format of stack dumps

PATCH In review Luben Tuikov 2 participants 4 messages Feb 7, 2006 1 message not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 x86-64: improve the format of stack dumps

In reply to a message not in the archive

Improve the format of stack dumps for x86-64.
* Single column of stack entries. (similar to other arches)
* Print the offset in hexadecimal instead of decimal! (similar to other arches)
* Print the size of the routines as well. (similar to other arches)
* No white line after RIP.
* No duplicate register dump on RIP line.
* No white line after register dump.
* Formatted/lined up dump of the stacks.

For example:

SysRq : Show Regs
CPU 0:

Modules linked in: i2c_dev i2c_core
Pid: 0, comm: swapper Not tainted 2.6.16-rc2-git #34
RIP: 0010:[<ffffffff801096b1>] mwait_idle+0x3c/0x53
RSP: 0018:ffffffff8059bf70  EFLAGS: 00000246
RAX: 0000000000000000 RBX: ffffffff80109675 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: ffffffff8052d698
RBP: ffffffff8059bf70 R08: 00000000ffffffff R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffffff805d7184
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
FS:  0000000000000000(0000) GS:ffffffff8058d000(0000) knlGS:0000000000000000
CS:  0010 DS: 0018 ES: 0018 CR0: 000000008005003b
CR2: 00002abae842f000 CR3: 00000000763b3000 CR4: 00000000000006e0
Call Trace:
        [<ffffffff80109654>] cpu_idle+0x6c/0x8d
        [<ffffffff8010802b>] rest_init+0x2b/0x31
        [<ffffffff8059c89a>] start_kernel+0x1dc/0x1de
        [<ffffffff8059c2a9>] _sinittext+0x2a9/0x2b0
 arch/x86_64/kernel/process.c |    4 +-
 arch/x86_64/kernel/traps.c   |   75 +++++++++++++------------------------------
 include/linux/kallsyms.h     |    7 ++--
 kernel/kallsyms.c            |    4 +-
 4 files changed, 32 insertions(+), 58 deletions(-)
arch/x86_64/kernel/process.c +2 -2
index 8ded407..6a29b0e 100644
@@ -302,9 +302,9 @@ void __show_regs(struct pt_regs * regs)
                system_utsname.release,
                (int)strcspn(system_utsname.version, " "),
                system_utsname.version);
-       printk("RIP: %04lx:[<%016lx>] ", regs->cs & 0xffff, regs->rip);
+       printk("RIP: %04lx:", regs->cs & 0xffff);
        printk_address(regs->rip); 
-       printk("\nRSP: %04lx:%016lx  EFLAGS: %08lx\n", regs->ss, regs->rsp,
+       printk("RSP: %04lx:%016lx  EFLAGS: %08lx\n", regs->ss, regs->rsp,
                regs->eflags);
        printk("RAX: %016lx RBX: %016lx RCX: %016lx\n",
               regs->rax, regs->rbx, regs->rcx);
arch/x86_64/kernel/traps.c +23 -52

120 lines not on this page · raw message

include/linux/kallsyms.h +5 -2
index 9bbd040..f668e64 100644
@@ -20,7 +20,7 @@ const char *kallsyms_lookup(unsigned lon
                            char **modname, char *namebuf);
 
 /* Replace "%s" in format with address, if found */
-extern void __print_symbol(const char *fmt, unsigned long address);
+extern int __print_symbol(const char *fmt, unsigned long address);
 
 #else /* !CONFIG_KALLSYMS */
 
@@ -38,7 +38,10 @@ static inline const char *kallsyms_looku
 }
 
 /* Stupid that this does nothing, but I didn't create this mess. */
-#define __print_symbol(fmt, addr)
+static inline int __print_symbol(const char *fmt, unsigned long addr)
+{
+       return 0;
+}
 #endif /*CONFIG_KALLSYMS*/
 
 /* This macro allows us to keep printk typechecking */
kernel/kallsyms.c +2 -2
index 39277dd..fbd7cb4 100644
@@ -231,7 +231,7 @@ const char *kallsyms_lookup(unsigned lon
 }
 
 /* Replace "%s" in format with address, or returns -errno. */
-void __print_symbol(const char *fmt, unsigned long address)
+int __print_symbol(const char *fmt, unsigned long address)
 {
        char *modname;
        const char *name;
@@ -251,7 +251,7 @@ void __print_symbol(const char *fmt, uns
                else
                        sprintf(buffer, "%s+%#lx/%#lx", name, offset, size);
        }
-       printk(fmt, buffer);
+       return printk(fmt, buffer);
 }
 
 /* To avoid using get_symbol_offset for every symbol, we carry prefix along. */
#2 lore raw
Quoted 2 lines · Luben Tuikov

Improve the format of stack dumps for x86-64.
* Single column of stack entries. (similar to other arches)

I don't like that part as I wrote earlier.It's a waste of precious screen space, no matter how often you retransmit the patch. The old format had a chance to even fit on a 80x25 screen, with your new one it is extremly unlikely.

Overall you're making less information available in a common case for cosmetics.

-Andi

#3 lore raw
Quoted 11 lines · --- Andi Kleen
Quoted 2 lines · Luben Tuikov

Improve the format of stack dumps for x86-64.
* Single column of stack entries. (similar to other arches)

I don't like that part as I wrote earlier.It's a waste of precious screen space, no matter how often you retransmit the patch. The old format had a chance to even fit on a 80x25 screen, with your new one it is extremly unlikely.

Overall you're making less information available in a common case for cosmetics.

And as I wrote earlier, this patch doesn't only improve output, it also _reuses_ code, i.e. __print_symbol() which your code recreates in printk_address(). Now printk_address() reuses the common __print_symbol().

One very important thing this patch also does is that it prints the offsets in hexadecimal, as opposed to decimal. I.e. from

0xNNNNNNNN+DDD to 0xNNNNNNNNN+0xTTT/0xWWW

As to "less space", this patch prints _identical_ information as the code before it, as I'm sure you can see by reading the patch itself.

Thanks,
Luben

#4 lore raw
Quoted 3 lines · Luben Tuikov

As to "less space", this patch prints _identical_ information as the code before it, as I'm sure you can see by reading the patch itself.

It prints basically the same information in more screen space, which is a regression.

-Andi