]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/DefaultExceptionHandlerLib: improve formatting of backtrace
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 9 Sep 2016 17:58:56 +0000 (18:58 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 14 Sep 2016 13:48:10 +0000 (14:48 +0100)
Implement the backtrace formattting suggested by Andrew, i.e.,

  IRQ Exception at 0x000000005BE182B0
  PC 0x00005BE182B0 (0x00005BE14000+0x000042B0) [ 0] ArmCpuDxe.dll
  PC 0x00005BE15770 (0x00005BE14000+0x00001770) [ 0] ArmCpuDxe.dll
  PC 0x00005EF08CC8 (0x00005EEEB000+0x0001DCC8) [ 1] DxeCore.dll
  PC 0x00005EF09008 (0x00005EEEB000+0x0001E008) [ 1] DxeCore.dll
  PC 0x00005EEF6ACC (0x00005EEEB000+0x0000BACC) [ 1] DxeCore.dll
  PC 0x00005EF0963C (0x00005EEEB000+0x0001E63C) [ 1] DxeCore.dll
  PC 0x00005EF09A38 (0x00005EEEB000+0x0001EA38) [ 1] DxeCore.dll
  PC 0x00005EF01560 (0x00005EEEB000+0x00016560) [ 1] DxeCore.dll
  PC 0x00005EF02FB4 (0x00005EEEB000+0x00017FB4) [ 1] DxeCore.dll
  PC 0x00005EF03098 (0x00005EEEB000+0x00018098) [ 1] DxeCore.dll
  PC 0x00005EF0460C (0x00005EEEB000+0x0001960C) [ 1] DxeCore.dll
  PC 0x00005EF005C4 (0x00005EEEB000+0x000155C4) [ 1] DxeCore.dll
  PC 0x00005EF00360 (0x00005EEEB000+0x00015360) [ 1] DxeCore.dll
  PC 0x00005EF003C8 (0x00005EEEB000+0x000153C8) [ 1] DxeCore.dll
  PC 0x00005EF128D0 (0x00005EEEB000+0x000278D0) [ 1] DxeCore.dll
  PC 0x00005EF12930 (0x00005EEEB000+0x00027930) [ 1] DxeCore.dll
  PC 0x00005EEEF594 (0x00005EEEB000+0x00004594) [ 1] DxeCore.dll
  PC 0x00005EF0CF18 (0x00005EEEB000+0x00021F18) [ 1] DxeCore.dll
  PC 0x00005EF1A310 (0x00005EEEB000+0x0002F310) [ 1] DxeCore.dll
  PC 0x00005EEF1808 (0x00005EEEB000+0x00006808) [ 1] DxeCore.dll
  PC 0x00005EEF1E48 (0x00005EEEB000+0x00006E48) [ 1] DxeCore.dll
  PC 0x00005EF0A838 (0x00005EEEB000+0x0001F838) [ 1] DxeCore.dll
  PC 0x00005EEED70C (0x00005EEEB000+0x0000270C) [ 1] DxeCore.dll
  PC 0x00005EEEC93C (0x00005EEEB000+0x0000193C) [ 1] DxeCore.dll
  PC 0x00005EEEC024 (0x00005EEEB000+0x00001024) [ 1] DxeCore.dll

  [ 0] /home/ard/build/edk2/Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/AARCH64/ArmPkg/Drivers/CpuDxe/CpuDxe/DEBUG/ArmCpuDxe.dll
  [ 1] /home/ard/build/edk2/Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/AARCH64/MdeModulePkg/Core/Dxe/DxeMain/DEBUG/DxeCore.dll

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c

index 1251bb8bd6fa9617f4b52e2124d11b4a217fefa0..2f9c2ede37c1d149dfceb3b3e85f477665f7f1fa 100644 (file)
@@ -169,31 +169,49 @@ DefaultExceptionHandler (
   SerialPortWrite ((UINT8 *) Buffer, CharCount);\r
 \r
   DEBUG_CODE_BEGIN ();\r
-    CHAR8  *Pdb;\r
+    CHAR8  *Pdb, *PrevPdb;\r
     UINTN  ImageBase;\r
     UINTN  PeCoffSizeOfHeader;\r
     UINT64 *Fp;\r
+    UINT64 RootFp[2];\r
+    UINTN  Idx;\r
 \r
-    Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);\r
+    PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);\r
     if (Pdb != NULL) {\r
-      DEBUG ((EFI_D_ERROR, "%a loaded at 0x%016lx \n", BaseName (Pdb), ImageBase));\r
-\r
-      Pdb = GetImageName (SystemContext.SystemContextAArch64->LR, &ImageBase,\r
-              &PeCoffSizeOfHeader);\r
-      if (Pdb != NULL) {\r
-        DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n",\r
-          BaseName (Pdb), SystemContext.SystemContextAArch64->LR, ImageBase));\r
-      }\r
-      for (Fp = (UINT64 *)SystemContext.SystemContextAArch64->FP;\r
-           *Fp != 0;\r
-           Fp = (UINT64 *)Fp[0]) {\r
-        if (Fp[1] == SystemContext.SystemContextAArch64->LR) {\r
-         continue;\r
+      DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n",\r
+        SystemContext.SystemContextAArch64->ELR, ImageBase,\r
+        SystemContext.SystemContextAArch64->ELR - ImageBase, BaseName (Pdb)));\r
+\r
+      if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) {\r
+        Idx = 0;\r
+\r
+        RootFp[0] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[0];\r
+        RootFp[1] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[1];\r
+        if (RootFp[1] != SystemContext.SystemContextAArch64->LR) {\r
+          RootFp[0] = SystemContext.SystemContextAArch64->FP;\r
+          RootFp[1] = SystemContext.SystemContextAArch64->LR;\r
+        }\r
+        for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {\r
+          Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);\r
+          if (Pdb != NULL) {\r
+            if (Pdb != PrevPdb) {\r
+              Idx++;\r
+              PrevPdb = Pdb;\r
+            }\r
+            DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\n",\r
+              Fp[1], ImageBase, Fp[1] - ImageBase, Idx, BaseName (Pdb)));\r
+          }\r
         }\r
-        Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);\r
-        if (Pdb != NULL) {\r
-          DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n",\r
-            BaseName (Pdb), Fp[1], ImageBase));\r
+        PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);\r
+        DEBUG ((EFI_D_ERROR, "\n[ 0] %a\n", Pdb));\r
+\r
+        Idx = 0;\r
+        for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) {\r
+          Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);\r
+          if (Pdb != NULL && Pdb != PrevPdb) {\r
+            DEBUG ((EFI_D_ERROR, "[% 2d] %a\n", ++Idx, Pdb));\r
+            PrevPdb = Pdb;\r
+          }\r
         }\r
       }\r
     }\r