This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Examining threads with Python extensions
- From: Paul Smith <paul at mad-scientist dot net>
- To: gdb at sourceware dot org
- Date: Mon, 06 Mar 2017 17:57:53 -0500
- Subject: Re: Examining threads with Python extensions
- Authentication-results: sourceware.org; auth=none
- References: <1488663824.3228.154.camel@gnu.org>
- Reply-to: paul at mad-scientist dot net
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!