diff options
author | Chuck Ebbert <76306.1226@compuserve.com> | 2006-09-26 02:32:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-09-26 11:48:55 -0400 |
commit | 99325326a57b6a56595bb097655bee9fd27d77b0 (patch) | |
tree | c86702f5fdcd8a75ed35c448980d50ae43cd804a /arch/i386/kernel/traps.c | |
parent | 1447c27d38faf8fb03d4599e8082e507453ea3cf (diff) |
[PATCH] i386: show_registers(): try harder to print failing code
show_registers() tries to dump failing code starting 43 bytes before the
offending instruction, but this address can be bad, for example in a device
driver where the failing instruction is less than 43 bytes from the start
of the driver's code. When that happens, try to dump code starting at the
failing instruction instead of printing no code at all.
Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
Cc: Andi Kleen <ak@muc.de>
Cc: Keith Owens <kaos@ocs.com.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/i386/kernel/traps.c')
-rw-r--r-- | arch/i386/kernel/traps.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c index 7e9edafffd8a..4fcc6690be99 100644 --- a/arch/i386/kernel/traps.c +++ b/arch/i386/kernel/traps.c | |||
@@ -313,6 +313,8 @@ void show_registers(struct pt_regs *regs) | |||
313 | */ | 313 | */ |
314 | if (in_kernel) { | 314 | if (in_kernel) { |
315 | u8 __user *eip; | 315 | u8 __user *eip; |
316 | int code_bytes = 64; | ||
317 | unsigned char c; | ||
316 | 318 | ||
317 | printk("\n" KERN_EMERG "Stack: "); | 319 | printk("\n" KERN_EMERG "Stack: "); |
318 | show_stack_log_lvl(NULL, regs, (unsigned long *)esp, KERN_EMERG); | 320 | show_stack_log_lvl(NULL, regs, (unsigned long *)esp, KERN_EMERG); |
@@ -320,9 +322,12 @@ void show_registers(struct pt_regs *regs) | |||
320 | printk(KERN_EMERG "Code: "); | 322 | printk(KERN_EMERG "Code: "); |
321 | 323 | ||
322 | eip = (u8 __user *)regs->eip - 43; | 324 | eip = (u8 __user *)regs->eip - 43; |
323 | for (i = 0; i < 64; i++, eip++) { | 325 | if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) { |
324 | unsigned char c; | 326 | /* try starting at EIP */ |
325 | 327 | eip = (u8 __user *)regs->eip; | |
328 | code_bytes = 32; | ||
329 | } | ||
330 | for (i = 0; i < code_bytes; i++, eip++) { | ||
326 | if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) { | 331 | if (eip < (u8 __user *)PAGE_OFFSET || __get_user(c, eip)) { |
327 | printk(" Bad EIP value."); | 332 | printk(" Bad EIP value."); |
328 | break; | 333 | break; |