]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/DefaultExceptionHandlerLib AARCH64: add minimal backtrace to crash dump
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 7 Sep 2016 08:12:29 +0000 (09:12 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 7 Sep 2016 16:22:39 +0000 (17:22 +0100)
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>
ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c

index 31fc936b21ff1bd6dd6977628c1887bfc3bed68b..84b442f2b6f48dbb557fa7d816ded2601bb0d2e1 100644 (file)
@@ -152,9 +152,30 @@ DefaultExceptionHandler (
     CHAR8  *Pdb;\r
     UINTN  ImageBase;\r
     UINTN  PeCoffSizeOfHeader;\r
+    UINT64 *Fp;\r
+\r
     Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);\r
     if (Pdb != NULL) {\r
       DEBUG ((EFI_D_ERROR, "%a loaded at 0x%016lx \n", 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
+          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
+        }\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
+            Pdb, Fp[1], ImageBase));\r
+        }\r
+      }\r
     }\r
   DEBUG_CODE_END ();\r
 \r