From 22a0232400ea09c57ab70d97cffc1f25e6320da7 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 13 Jan 2016 10:56:08 +0000 Subject: 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 * 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 * 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 * python.texi (Breakpoints In Python) : Add anchor. (Threads In Python): Document new InferiorThread.global_num attribute. --- gdb/python/py-infthread.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'gdb/python/py-infthread.c') diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index a9dd5cb..3a9bae7 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, -- cgit v1.1