Re: How does GDB get the function call stack
Luis Machado via Gdb <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <[email protected]> |
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
>