From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12617 invoked by alias); 8 Feb 2015 05:13:13 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 12145 invoked by uid 89); 8 Feb 2015 05:12:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f179.google.com Received: from mail-wi0-f179.google.com (HELO mail-wi0-f179.google.com) (209.85.212.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sun, 08 Feb 2015 05:12:09 +0000 Received: by mail-wi0-f179.google.com with SMTP id l15so10401956wiw.0 for ; Sat, 07 Feb 2015 21:12:06 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.180.189.67 with SMTP id gg3mr11472621wic.4.1423372326350; Sat, 07 Feb 2015 21:12:06 -0800 (PST) Received: by 10.27.20.5 with HTTP; Sat, 7 Feb 2015 21:12:06 -0800 (PST) In-Reply-To: References: Date: Sun, 08 Feb 2015 05:13:00 -0000 Message-ID: Subject: Re: How to get all threads of a definite process? From: Doug Evans To: fei ding Cc: gdb Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-02/txt/msg00011.txt.bz2 On Thu, Feb 5, 2015 at 10:15 PM, fei ding wrote: > BTW, I am talking about gdbserver, Thanks > > 2015-02-06 14:14 GMT+08:00 fei ding : >> 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).