+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
+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
@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
} 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);
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);
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:
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);
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);
+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
*/
int second(){
+ fork() ;
return 12;
}
return -1
}
+gdb_test_no_output "set detach-on-fork off" ""
+
gdb_test "Test_Events" "Event testers registered."
gdb_breakpoint "first"
#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."
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)):