public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ArmPkg/DefaultExceptionHandlerLib: trim module name in backtrace output
@ 2016-09-09  7:35 Ard Biesheuvel
  2016-09-09 11:26 ` Leif Lindholm
  0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2016-09-09  7:35 UTC (permalink / raw)
  To: edk2-devel, leif.lindholm; +Cc: vishalo, Ard Biesheuvel

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>
---
 ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c | 24 +++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
index 84b442f2b6f4..177231dbdb97 100644
--- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
@@ -119,6 +119,24 @@ DescribeExceptionSyndrome (
   DEBUG ((EFI_D_ERROR, "\n %a \n", Message));
 }
 
+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;
+}
+
 /**
   This is the default action to take on an unexpected exception
 
@@ -156,13 +174,13 @@ DefaultExceptionHandler (
 
     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, "%a loaded at 0x%016lx \n", BaseName (Pdb), ImageBase));
 
       Pdb = GetImageName (SystemContext.SystemContextAArch64->LR, &ImageBase,
               &PeCoffSizeOfHeader);
       if (Pdb != NULL) {
         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;
            *Fp != 0;
@@ -173,7 +191,7 @@ DefaultExceptionHandler (
         Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
         if (Pdb != NULL) {
           DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n",
-            Pdb, Fp[1], ImageBase));
+            BaseName (Pdb), Fp[1], ImageBase));
         }
       }
     }
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ArmPkg/DefaultExceptionHandlerLib: trim module name in backtrace output
  2016-09-09  7:35 [PATCH] ArmPkg/DefaultExceptionHandlerLib: trim module name in backtrace output Ard Biesheuvel
@ 2016-09-09 11:26 ` Leif Lindholm
  2016-09-09 13:04   ` Ard Biesheuvel
  0 siblings, 1 reply; 3+ messages in thread
From: Leif Lindholm @ 2016-09-09 11:26 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: edk2-devel, vishalo

On Fri, Sep 09, 2016 at 08:35:21AM +0100, Ard Biesheuvel wrote:
> 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>

Yes, that is cleaner.
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>

> ---
>  ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c | 24 +++++++++++++++++---
>  1 file changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> index 84b442f2b6f4..177231dbdb97 100644
> --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> @@ -119,6 +119,24 @@ DescribeExceptionSyndrome (
>    DEBUG ((EFI_D_ERROR, "\n %a \n", Message));
>  }
>  
> +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;
> +}
> +
>  /**
>    This is the default action to take on an unexpected exception
>  
> @@ -156,13 +174,13 @@ DefaultExceptionHandler (
>  
>      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, "%a loaded at 0x%016lx \n", BaseName (Pdb), ImageBase));
>  
>        Pdb = GetImageName (SystemContext.SystemContextAArch64->LR, &ImageBase,
>                &PeCoffSizeOfHeader);
>        if (Pdb != NULL) {
>          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;
>             *Fp != 0;
> @@ -173,7 +191,7 @@ DefaultExceptionHandler (
>          Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader);
>          if (Pdb != NULL) {
>            DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n",
> -            Pdb, Fp[1], ImageBase));
> +            BaseName (Pdb), Fp[1], ImageBase));
>          }
>        }
>      }
> -- 
> 2.7.4
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ArmPkg/DefaultExceptionHandlerLib: trim module name in backtrace output
  2016-09-09 11:26 ` Leif Lindholm
@ 2016-09-09 13:04   ` Ard Biesheuvel
  0 siblings, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2016-09-09 13:04 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: edk2-devel-01, Oliyil Kunnil, Vishal

On 9 September 2016 at 12:26, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> On Fri, Sep 09, 2016 at 08:35:21AM +0100, Ard Biesheuvel wrote:
>> 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>
>
> Yes, that is cleaner.
> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
>

Pushed, with the below folded in to prevent the RELEASE build from
breaking on an 'unused function'

Thanks,
Ard.


--- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
+++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
@@ -119,6 +119,7 @@ DescribeExceptionSyndrome (
   DEBUG ((EFI_D_ERROR, "\n %a \n", Message));
 }

+#ifndef MDEPKG_NDEBUG
 STATIC
 CONST CHAR8 *
 BaseName (
@@ -136,6 +137,7 @@ BaseName (
   }
   return Str;
 }
+#endif

 /**
   This is the default action to take on an unexpected exception


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-09 13:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-09  7:35 [PATCH] ArmPkg/DefaultExceptionHandlerLib: trim module name in backtrace output Ard Biesheuvel
2016-09-09 11:26 ` Leif Lindholm
2016-09-09 13:04   ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox