From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A67921A1DFE for ; Fri, 9 Sep 2016 00:35:30 -0700 (PDT) Received: by mail-wm0-x232.google.com with SMTP id b187so16058962wme.1 for ; Fri, 09 Sep 2016 00:35:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=yNVz83sxNO6nUSuaxaVzCPh2Pg78V+HIkejIzdakW3c=; b=FOA0KDdJFZrIYm+dyD+mRpHgf+PXERtPXq8ukcHdPBA1KntEiMQhB3qAqnjki6Mh/z 8z3/3XZqKpImPC1q1mqx4ND5x8cK+N4jReRaWt32oky48OAFAjF4tfh5+JVvEASgqEqM pQFCiPlYXIa6ku3jcAO/yvNTSakvP3oBxUBbE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=yNVz83sxNO6nUSuaxaVzCPh2Pg78V+HIkejIzdakW3c=; b=Kms+cVRYLIOoQxwOGkAxrJ208OI99UvpFkjdSj6t7sDSrZKYcDNRtgNa75RTVrlsAo qRW9KwcPeRJDyu7AVbMJeGXGlae7yfs9gh/wS0C0tQ93esQDb6Ol2leQNRv8vpTf4OEp 4gtE9RjlmyKERhuKbFdgvA0EWQ9FK6TCqTbheouquHfpTmRaCsFocW/LM9IVPxP0uTvT gJtv8DmYPiuUtVR9xMskpq3FwB47YF07wQUq+HTwTwazAInT/bgTOWDt6A2ba4byuH/z TafkLXTENPifW+tvKOzunMIvdrNOoQF0IJ5A5ayI9vdT3QT+BOdPvrbWIerFObTg6H6S kSzQ== X-Gm-Message-State: AE9vXwPZ+CsAXdi4dfIq3I0HHZqV3xiubedsrXV7BFnvH/E9PynpMMPofT72EhTQwdzyRAzY X-Received: by 10.194.240.39 with SMTP id vx7mr1688190wjc.38.1473406529283; Fri, 09 Sep 2016 00:35:29 -0700 (PDT) Received: from localhost.localdomain ([197.253.238.91]) by smtp.gmail.com with ESMTPSA id bc5sm1959729wjb.37.2016.09.09.00.35.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Sep 2016 00:35:28 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Cc: vishalo@qti.qualcomm.com, Ard Biesheuvel Date: Fri, 9 Sep 2016 08:35:21 +0100 Message-Id: <1473406521-6216-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [PATCH] ArmPkg/DefaultExceptionHandlerLib: trim module name in backtrace output X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Sep 2016 07:35:31 -0000 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" Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- 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