diff options
author | Raul E Rangel <rrangel@chromium.org> | 2020-06-29 11:28:25 -0600 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2020-07-10 15:39:51 +0000 |
commit | 5bb926e3c9bc00edef45b8a119469fc70e92990d (patch) | |
tree | 183d02053460f25f52454a29aa96c856d1e8aec9 /src/arch/x86 | |
parent | 812efb1fc21c1b54bc5b0657481a8f6616f663e1 (diff) |
arch/x86/exception: Print stack on exception
It's useful to see the stack when an exception happens so you can see
the variables on the stack, and also manually recreate the back trace.
If you need to recreate the back trace, you will need to add
-fno-omit-frame-pointer to the CFLAGS.
BUG=b:159081993
TEST=Caused an exception and saw the stack dumped. Then I manually
recreated the back trace.
0xcc6fff6c: 0xcc6ce02e <- 0xcc6ce02e is in dev_initialize
0xcc6fff68: 0xcc6fff88 <-- frame 1
0xcc6fff64: 0x00000005
0xcc6fff60: 0x000000dc
0xcc6fff5c: 0x00000000
0xcc6fff58: 0x00000200
0xcc6fff54: 0x00000000
0xcc6fff50: 0x00000400
0xcc6fff4c: 0xcc6d72d4 <- 0xcc6d72d4 is in setup_default_ebdad
0xcc6fff48: 0xcc6fff68 <-ebp
0xcc6fff44: 0x00000005
0xcc6fff40: 0xcc6f571c <-esp
Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: I3822ea7aa23202ecc98612850402eeb4b1f7b5ef
Reviewed-on: https://review.coreboot.org/c/coreboot/+/42884
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/arch/x86')
-rw-r--r-- | src/arch/x86/exception.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/arch/x86/exception.c b/src/arch/x86/exception.c index 318a219ac9..958ebfc41c 100644 --- a/src/arch/x86/exception.c +++ b/src/arch/x86/exception.c @@ -544,7 +544,18 @@ void x86_exception(struct eregs *info) printk(BIOS_EMERG, "\n%p:\t", code + i); printk(BIOS_EMERG, "%.2x ", code[i]); } - die(""); + + /* Align to 4-byte boundary and up the stack. */ + u32 *ptr = (u32 *)(ALIGN_DOWN((uintptr_t)info->esp, sizeof(u32)) + MDUMP_SIZE - 4); + for (i = 0; i < MDUMP_SIZE / sizeof(u32); ++i, --ptr) { + printk(BIOS_EMERG, "\n%p:\t0x%08x", ptr, *ptr); + if ((uintptr_t)ptr == info->ebp) + printk(BIOS_EMERG, " <-ebp"); + else if ((uintptr_t)ptr == info->esp) + printk(BIOS_EMERG, " <-esp"); + } + + die("\n"); #endif } |