aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorKevin Pouget <kpouget@sourceware.org>2011-10-04 08:04:13 +0000
committerKevin Pouget <kpouget@sourceware.org>2011-10-04 08:04:13 +0000
commitcb6be26b8b0a1bf6bb4da1eb5841119d73220fd5 (patch)
tree11b0b25089d45ebd5636ac0e8e34ccf094b25dd2 /gdb/python
parent54d2bafcf26d239467a921fb1c37f4a5e12cfdba (diff)
downloadfsf-binutils-gdb-cb6be26b8b0a1bf6bb4da1eb5841119d73220fd5.zip
fsf-binutils-gdb-cb6be26b8b0a1bf6bb4da1eb5841119d73220fd5.tar.gz
fsf-binutils-gdb-cb6be26b8b0a1bf6bb4da1eb5841119d73220fd5.tar.bz2
2011-10-04 Kevin Pouget <kevin.pouget@st.com>
PR python/12691: Add the inferior to Python exited event * python/py-exitedevent.c (create_exited_event_object): Add inferior to exited_event. * python/py-event.h (emit_exited_event): Likewise * python/-inferior.c (python_inferior_exit): Likewise 2011-10-04 Kevin Pouget <kevin.pouget@st.com> PR python/12691: Add the inferior to Python exited event * gdb.python/py-events.exp: Test the inferior attribute of exited event with a fork. * gdb.python/py-events.py: Print inferior number on exit. * gdb.python/py-events.c: Fork the inferior. 2011-10-04 Kevin Pouget <kevin.pouget@st.com> PR python/12691: Add the inferior to Python exited event * gdb.texinfo (Events In Python): Describe exited inferior attribute.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/py-event.h2
-rw-r--r--gdb/python/py-exitedevent.c13
-rw-r--r--gdb/python/py-inferior.c2
3 files changed, 12 insertions, 5 deletions
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index f4b3ee2..49d7b6a 100644
--- a/gdb/python/py-event.h
+++ b/gdb/python/py-event.h
@@ -104,7 +104,7 @@ typedef struct
} event_object;
extern int emit_continue_event (ptid_t ptid);
-extern int emit_exited_event (const LONGEST *exit_code);
+extern int emit_exited_event (const LONGEST *exit_code, struct inferior *inf);
extern int evpy_emit_event (PyObject *event,
eventregistry_object *registry);
diff --git a/gdb/python/py-exitedevent.c b/gdb/python/py-exitedevent.c
index 08150e5..85ea2e2 100644
--- a/gdb/python/py-exitedevent.c
+++ b/gdb/python/py-exitedevent.c
@@ -22,9 +22,10 @@
static PyTypeObject exited_event_object_type;
static PyObject *
-create_exited_event_object (const LONGEST *exit_code)
+create_exited_event_object (const LONGEST *exit_code, struct inferior *inf)
{
PyObject *exited_event;
+ PyObject *inf_obj;
exited_event = create_event_object (&exited_event_object_type);
@@ -37,6 +38,12 @@ create_exited_event_object (const LONGEST *exit_code)
PyLong_FromLongLong (*exit_code)) < 0)
goto fail;
+ inf_obj = inferior_to_inferior_object (inf);
+ if (!inf_obj || evpy_add_attribute (exited_event,
+ "inferior",
+ inf_obj) < 0)
+ goto fail;
+
return exited_event;
fail:
@@ -48,14 +55,14 @@ create_exited_event_object (const LONGEST *exit_code)
will create a new Python exited event object. */
int
-emit_exited_event (const LONGEST *exit_code)
+emit_exited_event (const LONGEST *exit_code, struct inferior *inf)
{
PyObject *event;
if (evregpy_no_listeners_p (gdb_py_events.exited))
return 0;
- event = create_exited_event_object (exit_code);
+ event = create_exited_event_object (exit_code, inf);
if (event)
return evpy_emit_event (event, gdb_py_events.exited);
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 8ed3ea5..275caea 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -119,7 +119,7 @@ python_inferior_exit (struct inferior *inf)
if (inf->has_exit_code)
exit_code = &inf->exit_code;
- if (emit_exited_event (exit_code) < 0)
+ if (emit_exited_event (exit_code, inf) < 0)
gdbpy_print_stack ();
do_cleanups (cleanup);