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 }
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42884 )
Change subject: arch/x86/exception: Print stack on exception ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/42884/1/src/arch/x86/exception.c File src/arch/x86/exception.c:
https://review.coreboot.org/c/coreboot/+/42884/1/src/arch/x86/exception.c@52... PS1, Line 522: (uintptr_t)info->esp & ~0x3 ALIGN_DOWN
Raul Rangel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42884 )
Change subject: arch/x86/exception: Print stack on exception ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/42884/1/src/arch/x86/exception.c File src/arch/x86/exception.c:
https://review.coreboot.org/c/coreboot/+/42884/1/src/arch/x86/exception.c@52... PS1, Line 522: (uintptr_t)info->esp & ~0x3
ALIGN_DOWN
Done
Hello build bot (Jenkins), Furquan Shaikh, Aaron Durbin,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/42884
to look at the new patch set (#2).
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/2
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42884 )
Change subject: arch/x86/exception: Print stack on exception ......................................................................
Patch Set 2: Code-Review+2
Aaron Durbin has submitted this change. ( 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 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 --- M src/arch/x86/exception.c 1 file changed, 12 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Aaron Durbin: Looks good to me, approved
diff --git a/src/arch/x86/exception.c b/src/arch/x86/exception.c index 318a219..958ebfc 100644 --- a/src/arch/x86/exception.c +++ b/src/arch/x86/exception.c @@ -544,7 +544,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 *)(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 }
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42884 )
Change subject: arch/x86/exception: Print stack on exception ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/42884/4/src/arch/x86/exception.c File src/arch/x86/exception.c:
https://review.coreboot.org/c/coreboot/+/42884/4/src/arch/x86/exception.c@54... PS4, Line 549: u32 I don't think this will work very well in places where pointers aren't 32-bit (x86_64)
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42884 )
Change subject: arch/x86/exception: Print stack on exception ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/42884/4/src/arch/x86/exception.c File src/arch/x86/exception.c:
https://review.coreboot.org/c/coreboot/+/42884/4/src/arch/x86/exception.c@54... PS4, Line 549: u32
I don't think this will work very well in places where pointers aren't 32-bit (x86_64)
That's a good point. We should adjust the type to uintptr_t.
Raul Rangel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/42884 )
Change subject: arch/x86/exception: Print stack on exception ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/42884/4/src/arch/x86/exception.c File src/arch/x86/exception.c:
https://review.coreboot.org/c/coreboot/+/42884/4/src/arch/x86/exception.c@54... PS4, Line 549: u32
That's a good point. We should adjust the type to uintptr_t.
I'll get a patch pushed up.