From: Duane Ellis <duane@duaneellis.com>
To: Celelibi <celelibi@gmail.com>
Cc: gdb@sourceware.org
Subject: Re: Tracing another stack
Date: Sat, 28 Nov 2015 13:37:00 -0000 [thread overview]
Message-ID: <6270C782-0078-4B91-B8FC-B51A6338EB5E@duaneellis.com> (raw)
In-Reply-To: <CAJR2zJ_jwB14bPsMO_Gf661Atj+8GXncGX7dnEDLDhm3RN3Q3g@mail.gmail.com>
> On Nov 27, 2015, at 10:01 PM, Celelibi <celelibi@gmail.com> wrote:
>
> Hello,
>
> I use gdb with the gdb-stub of qemu to debug a boot loader. When a
> memory fault occurs, a message is printed with the content of most
> registers and a new stack is created to run the handler that never
> terminates.
>
> Can I tell gdb to examine the stack given the content of the stack
> pointer, stack base and program counter of a stack that is not the
> current one?
>
> I tried setting $rsp and $rip to the values I got from the printed
> message, but it turns out it confuses gdb. The "bt" commands shows the
> right first stack frame, but the next ones are those of the interrupt
> handler.
>
>
> Thanks in advance.
> Celelibi
>
What is your target? (arm? x86? mips?)
What I do in these situations is this:
Step 1: I create a global ‘volatile’ variable that is set to zero
Step 2: The code - loops on that variable until it is non-zero
So in the normal (non-debugger-attached) case the system hangs, and a watch dog reset occurs.
But - when I have the debugger attached I set a breakpoint on that endless loop so I get a breakpoint hit.
And using the debugger i set that global variable to 1
Step 3: I can now step out of this code :-) and back through the exception return
Which will eventually land me back in the offending location.
Depending upon the target (i.e.: ARM vrs X86) you might want to make this exception handler return to the PREV or NEXT instruction instead of the instruction that failed
At that point you have the location where the error occurs.
Another approach is this:
If you know the offending address… you can often set a hardware *read* or *write* breakpoint on that location
-Duane
next prev parent reply other threads:[~2015-11-28 13:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-28 6:03 Celelibi
2015-11-28 13:37 ` Duane Ellis [this message]
2015-12-01 8:46 ` Celelibi
[not found] ` <863D4E7B-2D4E-448B-8B41-EE97612A3BA3@duaneellis.com>
2015-12-05 18:33 ` Celelibi
2015-11-30 16:28 ` Sterling Augustine
[not found] ` <CAEG7qUxk2qKo4RM9syqco26EtQkeiviP3GOrHkqyJJViwAX3dQ@mail.gmail.com>
2015-12-01 8:57 ` Celelibi
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-all 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=6270C782-0078-4B91-B8FC-B51A6338EB5E@duaneellis.com \
--to=duane@duaneellis.com \
--cc=celelibi@gmail.com \
--cc=gdb@sourceware.org \
/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