From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33471 invoked by alias); 6 Mar 2017 22:58:03 -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 31928 invoked by uid 89); 6 Mar 2017 22:58:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=Hx-languages-length:1713, Examining, H*f:sk:1488663, H*MI:sk:1488663 X-HELO: gproxy6-pub.mail.unifiedlayer.com Received: from gproxy6-pub.mail.unifiedlayer.com (HELO gproxy6-pub.mail.unifiedlayer.com) (67.222.39.168) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Mon, 06 Mar 2017 22:58:00 +0000 Received: (qmail 10326 invoked by uid 0); 6 Mar 2017 22:57:59 -0000 Received: from unknown (HELO cmgw3) (10.0.90.84) by gproxy6.mail.unifiedlayer.com with SMTP; 6 Mar 2017 22:57:59 -0000 Received: from box5008.bluehost.com ([50.116.64.19]) by cmgw3 with id smxv1u00j0QvKlu01mxyVo; Mon, 06 Mar 2017 15:57:59 -0700 X-Authority-Analysis: v=2.1 cv=WOnsABcR c=1 sm=1 tr=0 a=gch/BGY/Gm5DEW28s2kmlQ==:117 a=gch/BGY/Gm5DEW28s2kmlQ==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=6Iz7jQTuP9IA:10 a=CCpqsmhAAAAA:8 a=eVGVHlSY0GHO_nNT_Y0A:9 a=QEXdDO2ut3YA:10 a=YnpRVXZqeOMA:10 a=3W_kTjee8QsA:10 a=ul9cdbp4aOFLsgKbc677:22 Received: from [64.238.138.90] (port=56602 helo=pdsdesk) by box5008.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1cl1Zj-0004yO-Fp for gdb@sourceware.org; Mon, 06 Mar 2017 15:57:55 -0700 Message-ID: <1488841073.4328.50.camel@mad-scientist.net> Subject: Re: Examining threads with Python extensions From: Paul Smith Reply-To: paul@mad-scientist.net To: gdb@sourceware.org Date: Mon, 06 Mar 2017 22:58:00 -0000 In-Reply-To: <1488663824.3228.154.camel@gnu.org> References: <1488663824.3228.154.camel@gnu.org> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BWhitelist: no X-Exim-ID: 1cl1Zj-0004yO-Fp X-Source-Sender: (pdsdesk) [64.238.138.90]:56602 X-Source-Auth: paul@mad-scientist.us X-Email-Count: 1 X-Source-Cap: bWFkc2NpZTE7bWFkc2NpZTE7Ym94NTAwOC5ibHVlaG9zdC5jb20= X-SW-Source: 2017-03/txt/msg00002.txt.bz2 Don't mean to be a noodge but I wonder if anyone has any thoughts about this?  Is it not possible to write a function that works with multiple threads using the GDB Python extensions? On Sat, 2017-03-04 at 16:43 -0500, Paul Smith wrote: > 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!