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.
This commit is contained in:
Kevin Pouget 2011-10-04 08:04:13 +00:00
parent 54d2bafcf2
commit cb6be26b8b
10 changed files with 53 additions and 10 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -17,6 +17,7 @@
*/
int second(){
fork() ;
return 12;
}

View File

@ -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."

View File

@ -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)):