summaryrefslogtreecommitdiff
path: root/gdb/python/py-infthread.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-01-13 10:56:08 +0000
committerPedro Alves <palves@redhat.com>2016-01-13 11:00:54 +0000
commit22a0232400ea09c57ab70d97cffc1f25e6320da7 (patch)
tree795f4c5f87e23dea3bffb5c17cdb6f142f2401de /gdb/python/py-infthread.c
parent5d5658a1d3c3eb2a09c03f2f0662a1c01963c869 (diff)
downloadbinutils-gdb-22a0232400ea09c57ab70d97cffc1f25e6320da7.tar.gz
Add Python InferiorThread.global_num attribute
This commit adds a new Python InferiorThread.global_num attribute. This can be used to pass the correct thread ID to Breakpoint.thread, which takes a global thread ID, not a per-inferior thread number. gdb/ChangeLog: 2016-01-13 Pedro Alves <palves@redhat.com> * NEWS: Mention InferiorThread.global_num. * python/py-infthread.c (thpy_get_global_num): New function. (thread_object_getset): Register "global_num". gdb/testsuite/ChangeLog: 2016-01-13 Pedro Alves <palves@redhat.com> * gdb.multi/tids.exp: Test InferiorThread.global_num and Breakpoint.thread. * gdb.python/py-infthread.exp: Test InferiorThread.global_num. gdb/doc/ChangeLog: 2016-01-13 Pedro Alves <palves@redhat.com> * python.texi (Breakpoints In Python) <Breakpoint.thread>: Add anchor. (Threads In Python): Document new InferiorThread.global_num attribute.
Diffstat (limited to 'gdb/python/py-infthread.c')
-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 a9dd5cb3a41..3a9bae7e8d2 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -127,6 +127,18 @@ thpy_get_num (PyObject *self, void *closure)
return PyLong_FromLong (thread_obj->thread->per_inf_num);
}
+/* Getter for InferiorThread.global_num. */
+
+static PyObject *
+thpy_get_global_num (PyObject *self, void *closure)
+{
+ thread_object *thread_obj = (thread_object *) self;
+
+ THPY_REQUIRE_VALID (thread_obj);
+
+ return PyLong_FromLong (thread_obj->thread->global_num);
+}
+
/* Getter for InferiorThread.ptid -> (pid, lwp, tid).
Returns a tuple with the thread's ptid components. */
@@ -298,6 +310,8 @@ static PyGetSetDef thread_object_getset[] =
"The name of the thread, as set by the user or the OS.", NULL },
{ "num", thpy_get_num, NULL,
"Per-inferior number of the thread, as assigned by GDB.", NULL },
+ { "global_num", thpy_get_global_num, NULL,
+ "Global number 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,