diff options
-rw-r--r-- | gdb/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/doc/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/doc/gdb.texinfo | 12 | ||||
-rw-r--r-- | gdb/python/py-event.h | 2 | ||||
-rw-r--r-- | gdb/python/py-exitedevent.c | 13 | ||||
-rw-r--r-- | gdb/python/py-inferior.c | 2 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-events.c | 1 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-events.exp | 11 | ||||
-rw-r--r-- | gdb/testsuite/gdb.python/py-events.py | 1 |
10 files changed, 53 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 191ac2f..5ea2c05 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +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-03 Joel Brobecker <brobecker@adacore.com> * ada-tasks.c (print_ada_task_info): Add "thread-id" field diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 262c656..4ccd64c 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,8 @@ +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. + 2011-10-03 Joel Brobecker <brobecker@adacore.com> * gdb.texinfo (GDB/MI Miscellaneous Commands): Minor diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index aa7cdca..dd0f7f6 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22306,12 +22306,16 @@ inherited attribute refer to @code{gdb.ThreadEvent} above. @item events.exited Emits @code{events.ExitedEvent} which indicates that the inferior has exited. -@code{events.ExitedEvent} has one optional attribute. This attribute -will exist only in the case that the inferior exited with some -status. +@code{events.ExitedEvent} has two attributes: @table @code @defvar ExitedEvent.exit_code -An integer representing the exit code which the inferior has returned. +An integer representing the exit code, if available, which the inferior +has returned. (The exit code could be unavailable if, for example, +@value{GDBN} detaches from the inferior.) If the exit code is unavailable, +the attribute does not exist. +@end defvar +@defvar ExitedEvent inferior +A reference to the inferior which triggered the @code{exited} event. @end defvar @end table 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); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 9b5ff14..125316e 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +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-03 Edjunior Machado <emachado@linux.vnet.ibm.com> * gdb.base/jit.exp: Add testcase name to log message diff --git a/gdb/testsuite/gdb.python/py-events.c b/gdb/testsuite/gdb.python/py-events.c index ceb697e..665ca51 100644 --- a/gdb/testsuite/gdb.python/py-events.c +++ b/gdb/testsuite/gdb.python/py-events.c @@ -17,6 +17,7 @@ */ int second(){ + fork() ; return 12; } diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index 2d2139d..18419fa 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -37,6 +37,8 @@ if ![runto_main ] then { return -1 } +gdb_test_no_output "set detach-on-fork off" "" + gdb_test "Test_Events" "Event testers registered." gdb_breakpoint "first" @@ -54,4 +56,11 @@ all threads stopped" #test exited event. gdb_test "continue" ".*event type: continue.* .*event type: exit.* -.*exit code: 12.*" +.*exit code: 12.* +.*exit inf: 1.*" "Inferior 1 terminated." + +gdb_test "inferior 2" ".*Switching to inferior 2.*" +gdb_test "continue" ".*event type: continue.* +.*event type: exit.* +.*exit code: 12.* +.*exit inf: 2.*" "Inferior 2 terminated." diff --git a/gdb/testsuite/gdb.python/py-events.py b/gdb/testsuite/gdb.python/py-events.py index 10aea4f..6bdd935 100644 --- a/gdb/testsuite/gdb.python/py-events.py +++ b/gdb/testsuite/gdb.python/py-events.py @@ -43,6 +43,7 @@ def exit_handler (event): if (isinstance (event, gdb.ExitedEvent)): print "event type: exit" print "exit code: %d" % (event.exit_code) + print "exit inf: %d" % (event.inferior.num) def continue_handler (event): if (isinstance (event, gdb.ContinueEvent)): |