aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2019-02-27 14:59:02 -0700
committerKevin Buettner <kevinb@redhat.com>2019-04-08 20:12:45 -0700
commitcf63b0162b6cbf74bdb056609d1ad777c6d48954 (patch)
treed31fe395a2902e3abedf4e932a05343210c72eb2 /gdb/python
parent3d6c62048d8408fbfb6c66830e0c650e36259637 (diff)
downloadgdb-cf63b0162b6cbf74bdb056609d1ad777c6d48954.zip
gdb-cf63b0162b6cbf74bdb056609d1ad777c6d48954.tar.gz
gdb-cf63b0162b6cbf74bdb056609d1ad777c6d48954.tar.bz2
Add python method InferiorThread.handle
gdb/ChangeLog: * python/py-infthread.c (thpy_thread_handle): New function. (thread_object_methods): Register thpy_thread_handle.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-infthread.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c
index 33ed8d5..8c556f9 100644
--- a/gdb/python/py-infthread.c
+++ b/gdb/python/py-infthread.c
@@ -256,6 +256,36 @@ thpy_is_valid (PyObject *self, PyObject *args)
Py_RETURN_TRUE;
}
+/* Implementation of gdb.InferiorThread.handle (self) -> handle. */
+
+static PyObject *
+thpy_thread_handle (PyObject *self, PyObject *args)
+{
+ thread_object *thread_obj = (thread_object *) self;
+ THPY_REQUIRE_VALID (thread_obj);
+
+ gdb::byte_vector hv;
+
+ try
+ {
+ hv = target_thread_info_to_thread_handle (thread_obj->thread);
+ }
+ catch (const gdb_exception &except)
+ {
+ GDB_PY_HANDLE_EXCEPTION (except);
+ }
+
+ if (hv.size () == 0)
+ {
+ PyErr_SetString (PyExc_RuntimeError, _("Thread handle not found."));
+ return NULL;
+ }
+
+ PyObject *object = PyBytes_FromStringAndSize ((const char *) hv.data (),
+ hv.size());
+ return object;
+}
+
/* Return a reference to a new Python object representing a ptid_t.
The object is a tuple containing (pid, lwp, tid). */
PyObject *
@@ -335,6 +365,9 @@ Return whether the thread is running." },
{ "is_exited", thpy_is_exited, METH_NOARGS,
"is_exited () -> Boolean\n\
Return whether the thread is exited." },
+ { "handle", thpy_thread_handle, METH_NOARGS,
+ "handle () -> handle\n\
+Return thread library specific handle for thread." },
{ NULL }
};