aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-event.h
diff options
context:
space:
mode:
authorSimon Farre <simon.farre.cx@gmail.com>2022-04-20 10:25:47 +0200
committerSimon Farre <simon.farre.cx@gmail.com>2023-06-19 16:17:21 +0200
commit28ab59607ef40b9571c0702ffba8f6aa6fb1b033 (patch)
tree67dca4daefc0eb09ab33f7e93d21cf23124aadfc /gdb/python/py-event.h
parentf1a614dc8f015743e9fe7fe5f3f019303f8db718 (diff)
downloadgdb-28ab59607ef40b9571c0702ffba8f6aa6fb1b033.zip
gdb-28ab59607ef40b9571c0702ffba8f6aa6fb1b033.tar.gz
gdb-28ab59607ef40b9571c0702ffba8f6aa6fb1b033.tar.bz2
gdb/Python: Added ThreadExitedEvent
v6: Fix comments. Fix copyright Remove unnecessary test suite stuff. save_var had to stay, as it mutates some test suite state that otherwise fails. v5: Did what Tom Tromey requested in v4; which can be found here: https://pi.simark.ca/gdb-patches/87pmjm0xar.fsf@tromey.com/ v4: Doc formatting fixed. v3: Eli: Updated docs & NEWS to reflect new changes. Added a reference from the .ptid attribute of the ThreadExitedEvent to the ptid attribute of InferiorThread. To do this, I've added an anchor to that attribute. Tom: Tom requested that I should probably just emit the thread object; I ran into two issues for this, which I could not resolve in this patch; 1 - The Thread Object (the python type) checks it's own validity by doing a comparison of it's `thread_info* thread` to nullptr. This means that any access of it's attributes may (probably, since we are in "async" land) throw Python exceptions because the thread has been removed from the thread object. Therefore I've decided in v3 of this patch to just emit most of the same fields that gdb.InferiorThread has, namely global_num, name, num and ptid (the 3-attribute tuple provided by gdb.InferiorThread.ptid). 2 - A python user can hold a global reference to an exiting thread. Thus in order to have a ThreadExit event that can provide attribute access reliably (both as a global reference, but also inside the thread exit handler, as we can never guarantee that it's executed _before_ the thread_info pointer is removed from the gdbpy thread object), the `thread_info *` thread pointer must not be null. However, this comes at the cost of gdb.InferiorThread believing it is "valid" - which means, that if a user holds takes a global reference to that exiting event thread object, they can some time later do `t.switch()` at which point GDB will 'explode' so to speak. v2: Fixed white space issues and NULL/nullptr stuff, as requested by Tom Tromey. v1: Currently no event is emitted for a thread exit. This adds this functionality by emitting a new gdb.ThreadExitedEvent. It currently provides four attributes: - global_num: The GDB assigned global thread number - num: the per-inferior thread number - name: name of the thread or none if not set - ptid: the PTID of the thread, a 3-attribute tuple, identical to InferiorThread.ptid attribute Added info to docs & the NEWS file as well. Added test to test suite. Fixed formatting. Feedback wanted and appreciated.
Diffstat (limited to 'gdb/python/py-event.h')
-rw-r--r--gdb/python/py-event.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index 0a7d31d..01386dd 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -61,6 +61,9 @@ extern int emit_memory_changed_event (CORE_ADDR addr, ssize_t len);
extern int evpy_emit_event (PyObject *event,
eventregistry_object *registry);
+/* Emits a thread exit event for THREAD */
+extern int emit_thread_exit_event (thread_info * thread);
+
extern gdbpy_ref<> create_event_object (PyTypeObject *py_type);
/* thread events can either be thread specific or process wide. If gdb is