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 <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Tested-by: Leif Lindholm <leif.lindholm@linaro.org>
This commit is contained in:
Ard Biesheuvel 2016-09-07 09:12:29 +01:00
parent 8f0b62a5da
commit 960d0de80b
1 changed files with 21 additions and 0 deletions

View File

@ -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 ();