From 960d0de80b288c7cd9cbccfde7a12a48935055b4 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Wed, 7 Sep 2016 09:12:29 +0100 Subject: ArmPkg/DefaultExceptionHandlerLib AARCH64: add minimal backtrace to crash dump When dumping the CPU state after an unhandled fault, walk the stack frames and decode the return addresses so we can show a minimal backtrace. Unfortunately, we do not have sufficient information to show the function names, but at least we can see the modules and the return addresses inside the modules. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm Tested-by: Leif Lindholm --- .../AArch64/DefaultExceptionHandler.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'ArmPkg/Library/DefaultExceptionHandlerLib') diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c index 31fc936b21..84b442f2b6 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c @@ -152,9 +152,30 @@ DefaultExceptionHandler ( CHAR8 *Pdb; UINTN ImageBase; UINTN PeCoffSizeOfHeader; + UINT64 *Fp; + Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader); if (Pdb != NULL) { DEBUG ((EFI_D_ERROR, "%a loaded at 0x%016lx \n", Pdb, ImageBase)); + + Pdb = GetImageName (SystemContext.SystemContextAArch64->LR, &ImageBase, + &PeCoffSizeOfHeader); + if (Pdb != NULL) { + DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n", + Pdb, SystemContext.SystemContextAArch64->LR, ImageBase)); + } + for (Fp = (UINT64 *)SystemContext.SystemContextAArch64->FP; + *Fp != 0; + Fp = (UINT64 *)Fp[0]) { + if (Fp[1] == SystemContext.SystemContextAArch64->LR) { + continue; + } + Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader); + if (Pdb != NULL) { + DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n", + Pdb, Fp[1], ImageBase)); + } + } } DEBUG_CODE_END (); -- cgit v1.2.3