This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How to get all threads of a definite process?
- From: Doug Evans <xdje42 at gmail dot com>
- To: fei ding <fdingiit at gmail dot com>
- Cc: gdb <gdb at sourceware dot org>
- Date: Sat, 7 Feb 2015 21:12:06 -0800
- Subject: Re: How to get all threads of a definite process?
- Authentication-results: sourceware.org; auth=none
- References: <CAGmPkfLZB=1ZeA-qrXm9Uf+6VMJ-yZbfaA91Q44TO=7Q7Aa_ZQ at mail dot gmail dot com> <CAGmPkfJXp2Dr97U0dETN84-qkBumxD845XBVrnbYBCD=gW43YA at mail dot gmail dot com>
On Thu, Feb 5, 2015 at 10:15 PM, fei ding <fdingiit@gmail.com> wrote:
> BTW, I am talking about gdbserver, Thanks
>
> 2015-02-06 14:14 GMT+08:00 fei ding <fdingiit@gmail.com>:
>> Hi, everyone:
>>
>> I want to get all threads of one definite process, and I've found some
>> data structure such as 'all_threads', which is not what I want, i
>> guess. I don't understand the relationship between process and thread,
>> from the gdb-source-code-level (pointers for example), and I don't
>> understand the meaning of 'ptid_t', does this mean 'process_thread_id'
>> ? and I've found this data's value is not the thread's PID that Linux
>> shell tell me, it just some number like 0 or 1.
You'll need to clarify. ptid_t is a struct of three values,
it is not "just some number like 0 or 1".
>>
>> If you know something about this, please help me. Thanks.
ptid_t is the type gdb uses internally to identify both processes and threads.
Its API is defined in gdb/common/ptid.[ch].
There is ptid_match() which could be given a process ptid for the filter,
and then you just need to iterate over all_threads, e.g. with
for_each_inferior_with_data, for threads that match (IOW for threads
that have the same process id).