aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-01-13 10:56:06 +0000
committerPedro Alves <palves@redhat.com>2016-01-13 10:58:03 +0000
commit8465445732dc04c3fb6cf954274e12d06b274f08 (patch)
treee65ec5f892665f2e5b31daa6a41171ddb82a37b5 /gdb/python
parente3940304fe75c91f99e260a89fe8c45ece7e373f (diff)
downloadgdb-8465445732dc04c3fb6cf954274e12d06b274f08.zip
gdb-8465445732dc04c3fb6cf954274e12d06b274f08.tar.gz
gdb-8465445732dc04c3fb6cf954274e12d06b274f08.tar.bz2
Add Python InferiorThread.inferior attribute
So a script can easily get at a thread's inferior and its number. gdb/ChangeLog: 2016-01-13 Pedro Alves <palves@redhat.com> * NEWS: Mention InferiorThread.inferior. * python/py-infthread.c (thpy_get_inferior): New. (thread_object_getset): Register "inferior". gdb/testsuite/ChangeLog: 2016-01-13 Pedro Alves <palves@redhat.com> * gdb.python/py-infthread.exp: Test InferiorThread.inferior. gdb/doc/ChangeLog: 2016-01-13 Pedro Alves <palves@redhat.com> * python.texi (Threads In Python): Document InferiorThread.inferior.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-infthread.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index 2637f60..5075071 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -140,6 +140,18 @@ thpy_get_ptid (PyObject *self, void *closure)
return gdbpy_create_ptid_object (thread_obj->thread->ptid);
}
+/* Getter for InferiorThread.inferior -> Inferior. */
+
+static PyObject *
+thpy_get_inferior (PyObject *self, void *ignore)
+{
+ thread_object *thread_obj = (thread_object *) self;
+
+ THPY_REQUIRE_VALID (thread_obj);
+
+ return thread_obj->inf_obj;
+}
+
/* Implementation of InferiorThread.switch ().
Makes this the GDB selected thread. */
@@ -285,6 +297,8 @@ static PyGetSetDef thread_object_getset[] =
{ "num", thpy_get_num, NULL, "ID of the thread, as assigned by GDB.", NULL },
{ "ptid", thpy_get_ptid, NULL, "ID of the thread, as assigned by the OS.",
NULL },
+ { "inferior", thpy_get_inferior, NULL,
+ "The Inferior object this thread belongs to.", NULL },
{ NULL }
};