Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Paul Smith <psmith@gnu.org>
To: gdb@sourceware.org
Subject: Examining threads with Python extensions
Date: Sat, 04 Mar 2017 21:43:00 -0000	[thread overview]
Message-ID: <1488663824.3228.154.camel@gnu.org> (raw)

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!


             reply	other threads:[~2017-03-04 21:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-04 21:43 Paul Smith [this message]
2017-03-06 22:58 ` Paul Smith
2017-03-06 23:05 ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1488663824.3228.154.camel@gnu.org \
    --to=psmith@gnu.org \
    --cc=gdb@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox