diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2016-05-09 16:24:18 +0200 |
---|---|---|
committer | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2016-05-09 17:25:52 +0200 |
commit | cd82e330bbb1329b5ab8bd236e063af41cd4007a (patch) | |
tree | 01cf855e5508efc6000addc99ad68a2e777aae45 /ArmPkg/Library/DefaultExceptionHandlerLib | |
parent | 1549fb607b50c814072d18229ca423acb150cb68 (diff) | |
download | edk2-cd82e330bbb1329b5ab8bd236e063af41cd4007a.zip edk2-cd82e330bbb1329b5ab8bd236e063af41cd4007a.tar.gz edk2-cd82e330bbb1329b5ab8bd236e063af41cd4007a.tar.bz2 |
ArmPkg/DefaultExceptionHandlerLib: add stack dump to exception handling code
This adds a partial stack dump (256 bytes at either side of the stack
pointer) to the CPU state dumping routine that is invoked when taking an
unexpected exception. Since dereferencing the stack pointer may itself
fault, ensure that we don't enter the dumping routine recursively.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'ArmPkg/Library/DefaultExceptionHandlerLib')
-rw-r--r-- | ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c index df30c4f..ca2c48c 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c @@ -34,6 +34,8 @@ STATIC CHAR8 *gExceptionTypeString[] = { "SError"
};
+STATIC BOOLEAN mRecursiveException;
+
CHAR8 *
GetImageName (
IN UINTN FaultAddress,
@@ -134,6 +136,14 @@ DefaultExceptionHandler ( {
CHAR8 Buffer[100];
UINTN CharCount;
+ INT32 Offset;
+
+ if (mRecursiveException) {
+ CharCount = AsciiSPrint (Buffer, sizeof (Buffer),"\nRecursive exception occurred while dumping the CPU state\n");
+ SerialPortWrite ((UINT8 *) Buffer, CharCount);
+ CpuDeadLoop ();
+ }
+ mRecursiveException = TRUE;
CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n\n%a Exception at 0x%016lx\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextAArch64->ELR);
SerialPortWrite ((UINT8 *) Buffer, CharCount);
@@ -183,5 +193,16 @@ DefaultExceptionHandler ( DescribeExceptionSyndrome (SystemContext.SystemContextAArch64->ESR);
ASSERT (FALSE):
+ DEBUG ((EFI_D_ERROR, "\nStack dump:\n"));
+ for (Offset = -256; Offset < 256; Offset += 32) {
+ DEBUG ((EFI_D_ERROR, "%c %013lx: %016lx %016lx %016lx %016lx\n",
+ Offset == 0 ? '>' : ' ',
+ SystemContext.SystemContextAArch64->SP + Offset,
+ *(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset),
+ *(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 8),
+ *(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 16),
+ *(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 24)));
+ }
+
CpuDeadLoop ();
}
|