From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x230.google.com (mail-wm0-x230.google.com [IPv6:2a00:1450:400c:c09::230]) (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 7142B1A1DF8 for ; Fri, 9 Sep 2016 11:00:50 -0700 (PDT) Received: by mail-wm0-x230.google.com with SMTP id 1so46371679wmz.1 for ; Fri, 09 Sep 2016 11:00:50 -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=FdCrncnPkhAia9B/s1hghGTqaTScon6aQWmmvR2KiEY=; b=SOnWaA6NW5Rq8PXPFCY5+CeyJZOkg7K4SzCi/ZT2wCgC3VUENAjrFrJFFujMMQ13UK 2DP70BLNlfoY68KWB1zAncjEKbfqWozz4XDSg7r4o++fRXT/AUpahXu7pT4VAjUB7xr+ 73f5Bb6sB5do+R/ghH7OoeWQXbAv7c075XXv0= 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=FdCrncnPkhAia9B/s1hghGTqaTScon6aQWmmvR2KiEY=; b=Mbcp67PFZXWSrSwppHysJEOVdhWYvT+nez8cg89recCrulYUisGYmpSveT0bOBPAf2 bvqUVflCvpFROvsm8b9oUMkTSaSv4fLhgC09FyRqG5tbkburPApGGYCxuLXBtEML2XEc z06QCH43X3a2p0yx0tTQBJlvo7quj4CevfjbSvbqV2k2rVFy/fT6S9Oo4l/85Oei/Kex AI8/7DILFGyYZZ1UJwHMplj9wAfVPoKgDe7bYC5X7p/q+UEEZ0LhJhLquBJU+O5yw5dx vR/oJosdICmr40LPVGcBl24c47foPVr3RIT64G7WSy/x0m50ozs4S34V0Oa0Z/vUNBLb TFbw== X-Gm-Message-State: AE9vXwMXflC8ptxzVo/zWgSbw4XALdnAVxGaB4BM0xtruWs7x1TyWOR+dKLXhG6wSe/iU9Ly X-Received: by 10.28.206.197 with SMTP id e188mr4481331wmg.65.1473444048792; Fri, 09 Sep 2016 11:00:48 -0700 (PDT) Received: from localhost.localdomain ([197.130.178.93]) by smtp.gmail.com with ESMTPSA id 1sm10690312wmm.0.2016.09.09.11.00.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Sep 2016 11:00:47 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, afish@apple.com Cc: Ard Biesheuvel Date: Fri, 9 Sep 2016 19:00:37 +0100 Message-Id: <1473444037-15016-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [PATCH] ArmPkg/DefaultExceptionHandlerLib: improve formatting of backtrace 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 18:00:50 -0000 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 --- .../AArch64/DefaultExceptionHandler.c | 56 ++++++++++++++-------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c index 1251bb8bd6fa..2f9c2ede37c1 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c @@ -169,31 +169,49 @@ DefaultExceptionHandler ( SerialPortWrite ((UINT8 *) Buffer, CharCount); DEBUG_CODE_BEGIN (); - CHAR8 *Pdb; + CHAR8 *Pdb, *PrevPdb; UINTN ImageBase; UINTN PeCoffSizeOfHeader; UINT64 *Fp; + UINT64 RootFp[2]; + UINTN Idx; - Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader); + PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader); if (Pdb != NULL) { - 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", - BaseName (Pdb), SystemContext.SystemContextAArch64->LR, ImageBase)); - } - for (Fp = (UINT64 *)SystemContext.SystemContextAArch64->FP; - *Fp != 0; - Fp = (UINT64 *)Fp[0]) { - if (Fp[1] == SystemContext.SystemContextAArch64->LR) { - continue; + DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n", + SystemContext.SystemContextAArch64->ELR, ImageBase, + SystemContext.SystemContextAArch64->ELR - ImageBase, BaseName (Pdb))); + + if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) { + Idx = 0; + + RootFp[0] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[0]; + RootFp[1] = ((UINT64 *)SystemContext.SystemContextAArch64->FP)[1]; + if (RootFp[1] != SystemContext.SystemContextAArch64->LR) { + RootFp[0] = SystemContext.SystemContextAArch64->FP; + RootFp[1] = SystemContext.SystemContextAArch64->LR; + } + for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) { + Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader); + if (Pdb != NULL) { + if (Pdb != PrevPdb) { + Idx++; + PrevPdb = Pdb; + } + DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [% 2d] %a\n", + Fp[1], ImageBase, Fp[1] - ImageBase, Idx, BaseName (Pdb))); + } } - Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader); - if (Pdb != NULL) { - DEBUG ((EFI_D_ERROR, "called from %a (0x%016lx) loaded at 0x%016lx \n", - BaseName (Pdb), Fp[1], ImageBase)); + PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader); + DEBUG ((EFI_D_ERROR, "\n[ 0] %a\n", Pdb)); + + Idx = 0; + for (Fp = RootFp; Fp[0] != 0; Fp = (UINT64 *)Fp[0]) { + Pdb = GetImageName (Fp[1], &ImageBase, &PeCoffSizeOfHeader); + if (Pdb != NULL && Pdb != PrevPdb) { + DEBUG ((EFI_D_ERROR, "[% 2d] %a\n", ++Idx, Pdb)); + PrevPdb = Pdb; + } } } } -- 2.7.4