]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/DefaultExceptionHandlerLib: walk call stack unconditionally
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 16 Mar 2017 13:23:42 +0000 (13:23 +0000)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 22 Mar 2017 15:48:01 +0000 (15:48 +0000)
Currently, we only attempt to walk the call stack and print a backtrace
if the program counter refers to a location covered by a PE/COFF image.
However, regardless of the value of PC, the frame pointer may still have
a meaningful value, and so we can still produce the remainder of the
backtrace.

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 2f9c2ede37c1d149dfceb3b3e85f477665f7f1fa..1024bf48c63d2fac3398f87bde09647b2f3727c9 100644 (file)
@@ -181,37 +181,43 @@ DefaultExceptionHandler (
       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
+    } else {\r
+      DEBUG ((EFI_D_ERROR, "PC 0x%012lx\n", SystemContext.SystemContextAArch64->ELR));\r
+    }\r
 \r
-      if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) {\r
-        Idx = 0;\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
+      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
+        } else {\r
+          DEBUG ((EFI_D_ERROR, "PC 0x%012lx\n", Fp[1]));\r
         }\r
-        PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);\r
+      }\r
+      PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);\r
+      if (Pdb != NULL) {\r
         DEBUG ((EFI_D_ERROR, "\n[ 0] %a\n", Pdb));\r
+      }\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
+      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