Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Celelibi <celelibi@gmail.com>
To: Sterling Augustine <saugustine@google.com>
Cc: gdb@sourceware.org
Subject: Re: Tracing another stack
Date: Tue, 01 Dec 2015 08:57:00 -0000	[thread overview]
Message-ID: <CAJR2zJ8f0wL60rM3a2c3=2gnmKy8X6t1fEfGoWaWLkWCpK0uiQ@mail.gmail.com> (raw)
In-Reply-To: <CAEG7qUxk2qKo4RM9syqco26EtQkeiviP3GOrHkqyJJViwAX3dQ@mail.gmail.com>

2015-11-30 17:27 UTC+01:00, Sterling Augustine <saugustine@google.com>:
> On Fri, 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.
>>
>
> If you have a reasonably mature gdb-stub, you can use the following
> commands:
>
> # print a list of all threads known to gdb, with numbers
> info threads
>
> # switch to a thread numbered X from the above list
> thread X
>
> You can now get the back trace for that particular thread with "bt"
>
> You could also do:
>
> thread apply all backtrace
>
> To get a back trace of every thread.
>
> This may not work with certain immature stubs, but it should work with
> most.
>

Well, I think you missed 2 important informations. The stub I use is
that of qemu, its threads are mapped to the CPUs available. Second,
there is a single thread, the new stack is created by an interrupt
handler.

Having a single thread isn't incompatible with having several stacks.
Asynchronous events can run some code in a new and completely
different stack designed specifically for event handlers. AFAIK,
signal handlers in Linux can use a specific stack with the SA_ONSTACK
option of sigaction(2).


Best regards,
Celelibi


      parent reply	other threads:[~2015-12-01  8:57 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
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 [this message]

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='CAJR2zJ8f0wL60rM3a2c3=2gnmKy8X6t1fEfGoWaWLkWCpK0uiQ@mail.gmail.com' \
    --to=celelibi@gmail.com \
    --cc=gdb@sourceware.org \
    --cc=saugustine@google.com \
    /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