From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48230 invoked by alias); 4 Mar 2017 21:43:54 -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 48168 invoked by uid 89); 4 Mar 2017 21:43:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=H*M:154, H*MI:154, frames, Hx-languages-length:1401 X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 04 Mar 2017 21:43:51 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ckHSr-0008KO-Rm for gdb@sourceware.org; Sat, 04 Mar 2017 16:43:49 -0500 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50417) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ckHSr-0008KI-O3 for gdb@sourceware.org; Sat, 04 Mar 2017 16:43:45 -0500 Received: from pool-173-76-103-90.bstnma.fios.verizon.net ([173.76.103.90]:33194 helo=homebase) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ckHSr-0001zf-DL for gdb@sourceware.org; Sat, 04 Mar 2017 16:43:45 -0500 Message-ID: <1488663824.3228.154.camel@gnu.org> Subject: Examining threads with Python extensions From: Paul Smith Reply-To: psmith@gnu.org To: gdb@sourceware.org Date: Sat, 04 Mar 2017 21:43:00 -0000 Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00001.txt.bz2 Hi all. I'm trying to write some useful commands for my debugging using the Python API in GDB. What I want to do is write a Python command that will visit each of the threads in my process (or coredump) and examine the stacktrace, etc. for interesting content and display that. I have a lot of threads, and there are certain ones that are always present, plus thread pools, etc. I'd like to be able to generate a summary of the thread numbers (GDB thread IDs), what that thread is for in my process, and what its status is, etc. I can see https://sourceware.org/gdb/onlinedocs/gdb/Python-API.html and I can walk all stack frames in the currently selected thread, using the gdb.newest() / Frame.older() etc. methods, which I can use to figure out what the current thread is doing. However, I can't seem to find any way to operate on all the threads. In https://sourceware.org/gdb/onlinedocs/gdb/Threads-In-Python.html the only thread function available to me, from what I can see, is gdb.selected_thread() which gives me an InferiorThread object for the selected thread. But I can't find any methods that would switch to the "next" thread or whatever. There's InferiorThread.switch() but that makes the current InferiorThread object be the current thread... but how do I get the InferiorThread objects for all the threads so I can use it?! Help? Thanks!