Raul Rangel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/42884 )
Change subject: arch/x86/exception: Print stack on exception ......................................................................
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 --- M src/arch/x86/exception.c 1 file changed, 12 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/84/42884/1
diff --git a/src/arch/x86/exception.c b/src/arch/x86/exception.c index 46ba370..3a921c0 100644 --- a/src/arch/x86/exception.c +++ b/src/arch/x86/exception.c @@ -517,7 +517,18 @@ 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 *)(((uintptr_t)info->esp & ~0x3) + 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 }