public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@arm.com>
To: Andrew Dinn <adinn@redhat.com>, hilbert <swdtian@163.com>
Cc: gdb@sourceware.org
Subject: Re: How does GDB get the function call stack
Date: Tue, 16 Aug 2022 14:27:02 +0100	[thread overview]
Message-ID: <b0533570-6705-e841-47ca-06168c048956@arm.com> (raw)
In-Reply-To: <6cfef95e-106b-0e06-368e-a340e8d77665@redhat.com>

On 8/16/22 13:48, Andrew Dinn wrote:
> On 16/08/2022 11:16, hilbert wrote:
>> @Andrew Dinn
>> Now I totally understand. Thank you very much for your patience.
> 
> You are very welcome.
> 
>> By the way, when a multithreaded program hits a breakpoint, GDB can use the command: /*thread ID */
>> /**/to switch between threads arbitrarily,  and view the memory and other information of each thread.
>> This is also implemented using ptrace, right?
> I would assume it relies on ptrace to stop all the threads. However, I have almost zero knowledge of how gdb actually controls the inferior process (my knowledge of gdb is exclusively on the gdb-process side of the fence). You will need to find someone else to obtain a definitive answer.

Sorry, for some funny reason (mailing list software/mail server) I'm not getting hilbert's replies. But Andrew provided great answers.

Reading memory is usually done through /proc/<pid>/mem these days, as it is fastest.

Reading registers for each thread is done by ptrace.

> 
> regards,
> 
> 
> Andrew Dinn
> -----------
> Red Hat Distinguished Engineer
> Red Hat UK Ltd
> Registered in England and Wales under Company Registration No. 03798903
> Directors: Michael Cunningham, Michael ("Mike") O'Neill
> 


  parent reply	other threads:[~2022-08-16 13:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16  7:43 hilbert
2022-08-16  7:56 ` Luis Machado
2022-08-16  9:19   ` hilbert
2022-08-16  9:33     ` Andrew Dinn
2022-08-16 10:16       ` hilbert
2022-08-16 12:48         ` Andrew Dinn
2022-08-16 13:18           ` hilbert
2022-08-16 13:27           ` Luis Machado [this message]
2022-08-16 13:46             ` hilbert
2022-08-18 14:05   ` Andrew Burgess
2022-08-19  1:57     ` hilbert

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=b0533570-6705-e841-47ca-06168c048956@arm.com \
    --to=luis.machado@arm.com \
    --cc=adinn@redhat.com \
    --cc=gdb@sourceware.org \
    --cc=swdtian@163.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).