diff options
author | Andrew Burgess <aburgess@redhat.com> | 2022-02-14 17:02:03 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2022-02-28 17:01:31 +0000 |
commit | 659971cb0f8fd749aa951221d99de2868a860d07 (patch) | |
tree | a8d9a06e3d9b934d302dd05440c213b9ea35e3c9 /gdb/python/py-infthread.c | |
parent | ea764154c27a11619ba764a4c92f395ba5007234 (diff) | |
download | gdb-659971cb0f8fd749aa951221d99de2868a860d07.zip gdb-659971cb0f8fd749aa951221d99de2868a860d07.tar.gz gdb-659971cb0f8fd749aa951221d99de2868a860d07.tar.bz2 |
gdb/python: Add gdb.InferiorThread.details attribute
This adds a new read-only attribute gdb.InferiorThread.details, this
attribute contains a string, the results of target_extra_thread_info
for the thread, or None, if target_extra_thread_info returns nullptr.
As the string returned by target_extra_thread_info is unstructured,
this attribute is only really useful for echoing straight through to
the user, but, if a user wants to write a command that displays the
same, or a similar 'Thread Id' to the one seen in 'info threads', then
they need access to this string.
Given that the string produced by target_extra_thread_info varies by
target, there's only minimal testing of this attribute, I check that
the attribute can be accessed, and that the return value is either
None, or a string.
Diffstat (limited to 'gdb/python/py-infthread.c')
-rw-r--r-- | gdb/python/py-infthread.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index e568d8d..66c3efd 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -76,6 +76,32 @@ thpy_get_name (PyObject *self, void *ignore) return PyString_FromString (name); } +/* Return a string containing target specific additional information about + the state of the thread, or None, if there is no such additional + information. */ + +static PyObject * +thpy_get_details (PyObject *self, void *ignore) +{ + thread_object *thread_obj = (thread_object *) self; + + THPY_REQUIRE_VALID (thread_obj); + + const char *extra_info; + try + { + extra_info = target_extra_thread_info (thread_obj->thread); + } + catch (const gdb_exception &except) + { + GDB_PY_HANDLE_EXCEPTION (except); + } + if (extra_info == nullptr) + Py_RETURN_NONE; + + return PyString_FromString (extra_info); +} + static int thpy_set_name (PyObject *self, PyObject *newvalue, void *ignore) { @@ -347,6 +373,9 @@ static gdb_PyGetSetDef thread_object_getset[] = { { "name", thpy_get_name, thpy_set_name, "The name of the thread, as set by the user or the OS.", NULL }, + { "details", thpy_get_details, NULL, + "A target specific string containing extra thread state details.", + NULL }, { "num", thpy_get_num, NULL, "Per-inferior number of the thread, as assigned by GDB.", NULL }, { "global_num", thpy_get_global_num, NULL, |