ArmPkg/DefaultExceptionHandlerLib: trim module name in backtrace output

As reported by Vishal, the new backtrace output would be more useful if
it did not contain the full absolute path of each module in the list.
So strip off everything up to the last forward slash or backslash in the
string.

Example output:

  IRQ Exception at 0x000000005EF110E0
  DxeCore.dll loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EF121F0) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EF1289C) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EEFB6B4) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EEFAA44) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EEFB450) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EEF938C) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EEF8D04) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EEFA8E8) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EEF3C14) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EEF3E48) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EF0C838) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EEEF70C) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EEEE93C) loaded at 0x000000005EEED000
  called from DxeCore.dll (0x000000005EEEE024) loaded at 0x000000005EEED000

Suggested-by: "Oliyil Kunnil, Vishal" <vishalo@qti.qualcomm.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
This commit is contained in:
Ard Biesheuvel 2016-09-09 08:28:53 +01:00
parent bdb10148fc
commit 1f8f4e33a1
1 changed files with 23 additions and 3 deletions

View File

@ -119,6 +119,26 @@ DescribeExceptionSyndrome (
DEBUG ((EFI_D_ERROR, "\n %a \n", Message)); 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 This is the default action to take on an unexpected exception
@ -156,13 +176,13 @@ DefaultExceptionHandler (
Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader); Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
if (Pdb != NULL) { if (Pdb != NULL) {
DEBUG ((EFI_D_ERROR, "%a loaded at 0x%016lx \n", Pdb, ImageBase)); DEBUG ((EFI_D_ERROR, "%a loaded at 0x%016lx \n", BaseName (Pdb), ImageBase));
Pdb = GetImageName (SystemContext.SystemContextAArch64->LR, &ImageBase, Pdb = GetImageName (SystemContext.SystemContextAArch64->LR, &ImageBase,
&PeCoffSizeOfHeader); &PeCoffSizeOfHeader);
if (Pdb != NULL) { if (Pdb != NULL) {
DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n", DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n",
Pdb, SystemContext.SystemContextAArch64->LR, ImageBase)); BaseName (Pdb), SystemContext.SystemContextAArch64->LR, ImageBase));
} }
for (Fp = (UINT64 *)SystemContext.SystemContextAArch64->FP; for (Fp = (UINT64 *)SystemContext.SystemContextAArch64->FP;
*Fp != 0; *Fp != 0;
@ -173,7 +193,7 @@ DefaultExceptionHandler (
Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader); Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
if (Pdb != NULL) { if (Pdb != NULL) {
DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n", DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n",
Pdb, Fp[1], ImageBase)); BaseName (Pdb), Fp[1], ImageBase));
} }
} }
} }