From: Leif Lindholm <leif.lindholm@linaro.org>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: edk2-devel@lists.01.org, ryan.harkin@linaro.org, eugene@hp.com
Subject: Re: [PATCH 2/3] ArmPkg/DefaultExceptionHandlerLib: walk call stack unconditionally
Date: Wed, 22 Mar 2017 13:07:43 +0000 [thread overview]
Message-ID: <20170322130743.GX16034@bivouac.eciton.net> (raw)
In-Reply-To: <1490043181-20031-3-git-send-email-ard.biesheuvel@linaro.org>
On Mon, Mar 20, 2017 at 08:53:00PM +0000, Ard Biesheuvel wrote:
> 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>
> ---
> ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c | 56 +++++++++++---------
> 1 file changed, 31 insertions(+), 25 deletions(-)
>
> diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> index 2f9c2ede37c1..1024bf48c63d 100644
> --- a/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/AArch64/DefaultExceptionHandler.c
> @@ -181,37 +181,43 @@ DefaultExceptionHandler (
> DEBUG ((EFI_D_ERROR, "PC 0x%012lx (0x%012lx+0x%08x) [ 0] %a\n",
> SystemContext.SystemContextAArch64->ELR, ImageBase,
> SystemContext.SystemContextAArch64->ELR - ImageBase, BaseName (Pdb)));
> + } else {
> + DEBUG ((EFI_D_ERROR, "PC 0x%012lx\n", SystemContext.SystemContextAArch64->ELR));
> + }
>
come_from:
> - if ((UINT64 *)SystemContext.SystemContextAArch64->FP != 0) {
> - Idx = 0;
> + 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)));
> + 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)));
Diff's a bit iffy, but can you confirm there is no functional change
between come_from and here? Just the indentation shuffle?
> + } else {
> + DEBUG ((EFI_D_ERROR, "PC 0x%012lx\n", Fp[1]));
> }
> - PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
> + }
> + PrevPdb = Pdb = GetImageName (SystemContext.SystemContextAArch64->ELR, &ImageBase, &PeCoffSizeOfHeader);
> + if (Pdb != NULL) {
> 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;
> - }
> + 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
>
If so:
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
/
Leif
next prev parent reply other threads:[~2017-03-22 13:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-20 20:52 [PATCH 0/3] ArmPkg: increase robustness of the crash handler Ard Biesheuvel
2017-03-20 20:52 ` [PATCH 1/3] ArmPkg/DefaultExceptionHandlerLib: add missing GUID to .inf Ard Biesheuvel
2017-03-22 13:01 ` Leif Lindholm
2017-03-20 20:53 ` [PATCH 2/3] ArmPkg/DefaultExceptionHandlerLib: walk call stack unconditionally Ard Biesheuvel
2017-03-22 13:07 ` Leif Lindholm [this message]
2017-03-22 13:12 ` Ard Biesheuvel
2017-03-22 13:20 ` Leif Lindholm
2017-03-20 20:53 ` [PATCH 3/3] ArmPkg/ArmExceptionLib: use EL0 stack for synchronous exceptions Ard Biesheuvel
2017-03-22 13:18 ` Leif Lindholm
2017-03-22 13:20 ` Ard Biesheuvel
2017-03-27 12:54 ` Ard Biesheuvel
2017-03-27 12:55 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170322130743.GX16034@bivouac.eciton.net \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox