aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2011-06-03 15:32:44 +0000
committerTom Tromey <tromey@redhat.com>2011-06-03 15:32:44 +0000
commit8cf64490f293549a0b8e64342d7c97099df19974 (patch)
tree2aa409936b65cf0a40f19a32c9d2b053132f9bba /gdb/python
parent8ddd9a20a759fb2dd5d221914747eaf62c62c994 (diff)
downloadgdb-8cf64490f293549a0b8e64342d7c97099df19974.zip
gdb-8cf64490f293549a0b8e64342d7c97099df19974.tar.gz
gdb-8cf64490f293549a0b8e64342d7c97099df19974.tar.bz2
gdb
* python/py-inferior.c (python_inferior_exit): Use inferior's exit code fields. * python/py-exitedevent.c (create_exited_event_object): Change type of 'exit_code'. Optionally add exit_code attribute. (emit_exited_event): Change type of 'exit_code'. * python/py-event.h (emit_exited_event): Update. * mi/mi-interp.c (mi_inferior_exit): Print exit code. * infrun.c (handle_inferior_event): Set exit code fields on inferior. * inferior.h (struct inferior) <has_exit_code, exit_code>: New fields. * inferior.c (exit_inferior_1): Initialize new fields. gdb/doc * gdb.texinfo (GDB/MI Async Records): Document 'exit-code' field. (Events In Python): Note that exit_code is optional.
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.c12
3 files changed, 12 insertions, 15 deletions
diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h
index bc95521..f4b3ee2 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 (LONGEST exit_code);
+extern int emit_exited_event (const LONGEST *exit_code);
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 457a4fe..08150e5 100644
--- a/gdb/python/py-exitedevent.c
+++ b/gdb/python/py-exitedevent.c
@@ -21,8 +21,8 @@
static PyTypeObject exited_event_object_type;
-PyObject *
-create_exited_event_object (LONGEST exit_code)
+static PyObject *
+create_exited_event_object (const LONGEST *exit_code)
{
PyObject *exited_event;
@@ -31,9 +31,10 @@ create_exited_event_object (LONGEST exit_code)
if (!exited_event)
goto fail;
- if (evpy_add_attribute (exited_event,
- "exit_code",
- PyLong_FromLongLong (exit_code)) < 0)
+ if (exit_code
+ && evpy_add_attribute (exited_event,
+ "exit_code",
+ PyLong_FromLongLong (*exit_code)) < 0)
goto fail;
return exited_event;
@@ -47,7 +48,7 @@ create_exited_event_object (LONGEST exit_code)
will create a new Python exited event object. */
int
-emit_exited_event (LONGEST exit_code)
+emit_exited_event (const LONGEST *exit_code)
{
PyObject *event;
diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c
index 45f5f04..da0a4b6 100644
--- a/gdb/python/py-inferior.c
+++ b/gdb/python/py-inferior.c
@@ -112,18 +112,14 @@ static void
python_inferior_exit (struct inferior *inf)
{
struct cleanup *cleanup;
- LONGEST exit_code = -1;
- ptid_t ptidp;
- struct target_waitstatus status;
+ const LONGEST *exit_code = NULL;
cleanup = ensure_python_env (target_gdbarch, current_language);
- get_last_target_status (&ptidp, &status);
+ if (inf->has_exit_code)
+ exit_code = &inf->exit_code;
- exit_code = status.value.integer;
-
- if (exit_code >= 0
- && emit_exited_event (exit_code) < 0)
+ if (emit_exited_event (exit_code) < 0)
gdbpy_print_stack ();
do_cleanups (cleanup);