X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=ArmPkg%2FLibrary%2FDefaultExceptionHandlerLib%2FAArch64%2FDefaultExceptionHandler.c;h=2f9c2ede37c1d149dfceb3b3e85f477665f7f1fa;hp=ca2c48c82824169a47072361863680d6a6c824ac;hb=062f9fd2cfaad09f6dd0e302094bc030827eb706;hpb=cd82e330bbb1329b5ab8bd236e063af41cd4007a diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c index ca2c48c828..2f9c2ede37 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c @@ -119,6 +119,26 @@ DescribeExceptionSyndrome ( DEBUG ((EFI_D_ERROR, "\n %a \n", Message)); } +#ifndef MDEPKG_NDEBUG +STATIC +CONST CHAR8 * +BaseName ( + IN CONST CHAR8 *FullName + ) +{ + CONST CHAR8 *Str; + + Str = FullName + AsciiStrLen (FullName); + + while (--Str > FullName) { + if (*Str == '/' || *Str == '\\') { + return Str + 1; + } + } + return Str; +} +#endif + /** This is the default action to take on an unexpected exception @@ -149,12 +169,51 @@ DefaultExceptionHandler ( SerialPortWrite ((UINT8 *) Buffer, CharCount); DEBUG_CODE_BEGIN (); - CHAR8 *Pdb; + CHAR8 *Pdb, *PrevPdb; UINTN ImageBase; UINTN PeCoffSizeOfHeader; - Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader); + UINT64 *Fp; + UINT64 RootFp[2]; + UINTN Idx; + + PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader); if (Pdb != NULL) { - DEBUG ((EFI_D_ERROR, "%a loaded at 0x%016lx \n", Pdb, ImageBase)); + DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n", + SystemContext.SystemContextAArch64->ELR, ImageBase, + SystemContext.SystemContextAArch64->ELR - ImageBase, BaseName (Pdb))); + + if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) { + Idx = 0; + + RootFp[0] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[0]; + RootFp[1] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[1]; + if (RootFp[1] != SystemContext.SystemContextAArch64->LR) { + RootFp[0] = SystemContext.SystemContextAArch64->FP; + RootFp[1] = SystemContext.SystemContextAArch64->LR; + } + for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) { + Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader); + if (Pdb != NULL) { + if (Pdb != PrevPdb) { + Idx++; + PrevPdb = Pdb; + } + DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\n", + Fp[1], ImageBase, Fp[1] - ImageBase, Idx, BaseName (Pdb))); + } + } + PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader); + DEBUG ((EFI_D_ERROR, "\n[ 0] %a\n", Pdb)); + + Idx = 0; + for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) { + Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader); + if (Pdb != NULL && Pdb != PrevPdb) { + DEBUG ((EFI_D_ERROR, "[% 2d] %a\n", ++Idx, Pdb)); + PrevPdb = Pdb; + } + } + } } DEBUG_CODE_END (); @@ -191,7 +250,6 @@ DefaultExceptionHandler ( DEBUG ((EFI_D_ERROR, "\n ESR : EC 0x%02x IL 0x%x ISS 0x%08x\n", (SystemContext.SystemContextAArch64->ESR & 0xFC000000) >> 26, (SystemContext.SystemContextAArch64->ESR >> 25) & 0x1, SystemContext.SystemContextAArch64->ESR & 0x1FFFFFF )); DescribeExceptionSyndrome (SystemContext.SystemContextAArch64->ESR); - ASSERT (FALSE): DEBUG ((EFI_D_ERROR, "\nStack dump:\n")); for (Offset = -256; Offset < 256; Offset += 32) { @@ -204,5 +262,6 @@ DefaultExceptionHandler ( *(UINT64 *)(SystemContext.SystemContextAArch64->SP + Offset + 24))); } + ASSERT (FALSE); CpuDeadLoop (); }