public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  tromey/catch-exit: set $_exitcode when exiting
@ 2013-08-02 17:22 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2013-08-02 17:22 UTC (permalink / raw)
  To: archer-commits

The branch, tromey/catch-exit has been updated
       via  921b251ae9c48ae12273bfe3f742d190c0514fc6 (commit)
      from  385be8429c1bce524f7b2fcb284e92ed396eb472 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 921b251ae9c48ae12273bfe3f742d190c0514fc6
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri Aug 2 11:19:02 2013 -0600

    set $_exitcode when exiting
    
    this sets $_exitcode when TARGET_WAITKIND_EXITING is handled
    note that this will have to be redone when the $_exitcode change
    goes in

-----------------------------------------------------------------------

Summary of changes:
 gdb/inferior.c |   14 ++++++++++++++
 gdb/inferior.h |    3 +++
 gdb/infrun.c   |   11 ++---------
 3 files changed, 19 insertions(+), 9 deletions(-)

First 500 lines of diff:
diff --git a/gdb/inferior.c b/gdb/inferior.c
index b9e9a8d..eef22ba 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -237,6 +237,20 @@ delete_inferior_silent (int pid)
   delete_inferior_1 (inf, 1);
 }
 
+/* Set the inferior's exit code and $_exitcode as well.  Note that it
+  is ok to set it more than once.  For example we might see a "catch
+  exit" event and then a real exit.  */
+
+void
+set_inferior_exit_code (struct inferior *inf, LONGEST code)
+{
+  /* Record the exit code in the convenience variable $_exitcode, so
+     that the user can inspect this again later.  */
+  set_internalvar_integer (lookup_internalvar ("_exitcode"), code);
+
+  inf->has_exit_code = 1;
+  inf->exit_code = code;
+}
 
 /* If SILENT then be quiet -- don't announce a inferior exit, or the
    exit of its threads.  */
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 2a5770d..e312494 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -526,6 +526,9 @@ DECLARE_REGISTRY (inferior);
 /* Create an empty inferior list, or empty the existing one.  */
 extern void init_inferior_list (void);
 
+/* Set inferior's exit code.  */
+extern void set_inferior_exit_code (struct inferior *inf, LONGEST code);
+
 /* Add an inferior to the inferior list, print a message that a new
    inferior is found, and return the pointer to the new inferior.
    Caller may use this pointer to initialize the private inferior
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 31bd51f..f72a04b 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3423,15 +3423,7 @@ handle_inferior_event (struct execution_control_state *ecs)
 
       if (ecs->ws.kind == TARGET_WAITKIND_EXITED)
 	{
-	  /* Record the exit code in the convenience variable $_exitcode, so
-	     that the user can inspect this again later.  */
-	  set_internalvar_integer (lookup_internalvar ("_exitcode"),
-				   (LONGEST) ecs->ws.value.integer);
-
-	  /* Also record this in the inferior itself.  */
-	  current_inferior ()->has_exit_code = 1;
-	  current_inferior ()->exit_code = (LONGEST) ecs->ws.value.integer;
-
+	  set_inferior_exit_code (current_inferior (), ecs->ws.value.integer);
 	  print_exited_reason (ecs->ws.value.integer);
 	}
       else
@@ -3690,6 +3682,7 @@ handle_inferior_event (struct execution_control_state *ecs)
       goto process_event_stop_test;
 
     case TARGET_WAITKIND_EXITING:
+      set_inferior_exit_code (current_inferior (), ecs->ws.value.integer);
       if (debug_infrun)
         fprintf_unfiltered (gdb_stdlog, "infrun: TARGET_WAITKIND_EXITING\n");
       ecs->event_thread->control.stop_bpstat


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-08-02 17:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-02 17:22 [SCM] tromey/catch-exit: set $_exitcode when exiting tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).