Mark Wielaard efb9f6
Index: valgrind/coregrind/m_gdbserver/m_gdbserver.c
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/coregrind/m_gdbserver/m_gdbserver.c	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/coregrind/m_gdbserver/m_gdbserver.c	(working copy)
Mark Wielaard efb9f6
@@ -33,6 +33,8 @@
Mark Wielaard efb9f6
 #include "pub_core_libcproc.h"
Mark Wielaard efb9f6
 #include "pub_core_libcprint.h"
Mark Wielaard efb9f6
 #include "pub_core_mallocfree.h"
Mark Wielaard efb9f6
+#include "pub_tool_libcsetjmp.h"
Mark Wielaard efb9f6
+#include "pub_core_threadstate.h"
Mark Wielaard efb9f6
 #include "pub_core_gdbserver.h"
Mark Wielaard efb9f6
 #include "pub_core_options.h"
Mark Wielaard efb9f6
 #include "pub_core_libcsetjmp.h"
Mark Wielaard efb9f6
@@ -68,7 +70,8 @@
Mark Wielaard efb9f6
       core_reason,    // gdbserver invocation by core (e.g. error encountered)
Mark Wielaard efb9f6
       break_reason,   // break encountered
Mark Wielaard efb9f6
       watch_reason,   // watchpoint detected by tool
Mark Wielaard efb9f6
-      signal_reason}  // signal encountered
Mark Wielaard efb9f6
+      signal_reason,  // signal encountered
Mark Wielaard efb9f6
+      exit_reason}    // process terminated
Mark Wielaard efb9f6
     CallReason;
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
 static char* ppCallReason(CallReason reason)
Mark Wielaard efb9f6
@@ -80,6 +83,7 @@
Mark Wielaard efb9f6
    case break_reason:   return "break_reason";
Mark Wielaard efb9f6
    case watch_reason:   return "watch_reason";
Mark Wielaard efb9f6
    case signal_reason:  return "signal_reason";
Mark Wielaard efb9f6
+   case exit_reason:    return "exit_reason";
Mark Wielaard efb9f6
    default: vg_assert (0);
Mark Wielaard efb9f6
    }
Mark Wielaard efb9f6
 }
Mark Wielaard efb9f6
@@ -641,6 +645,14 @@
Mark Wielaard efb9f6
         VG_(getpid) (), tid, VG_(name_of_ThreadStatus)(tst->status),
Mark Wielaard efb9f6
         tst->sched_jmpbuf_valid);
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
+   /* If we are about to die, then just run server_main() once to get
Mark Wielaard efb9f6
+      the message out and return immediately because most of the state
Mark Wielaard efb9f6
+      of this tid and process is about to be torn down. */
Mark Wielaard efb9f6
+   if (reason == exit_reason) {
Mark Wielaard efb9f6
+      server_main();
Mark Wielaard efb9f6
+      return;
Mark Wielaard efb9f6
+   }
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
    vg_assert(VG_(is_valid_tid)(tid));
Mark Wielaard efb9f6
    saved_pc = VG_(get_IP) (tid);
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
@@ -933,6 +945,29 @@
Mark Wielaard efb9f6
    }
Mark Wielaard efb9f6
 }
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
+void VG_(gdbserver_exit) (ThreadId tid, VgSchedReturnCode tids_schedretcode)
Mark Wielaard efb9f6
+{
Mark Wielaard efb9f6
+   dlog(1, "VG core calling VG_(gdbserver_exit) tid %d will exit\n", tid);
Mark Wielaard efb9f6
+   if (remote_connected()) {
Mark Wielaard efb9f6
+      /* Make sure vgdb knows we are about to die and why. */
Mark Wielaard efb9f6
+      if (tids_schedretcode == VgSrc_ExitThread
Mark Wielaard efb9f6
+          || tids_schedretcode == VgSrc_ExitProcess) {
Mark Wielaard efb9f6
+         gdbserver_process_exit ('W', VG_(threads)[tid].os_state.exitcode);
Mark Wielaard efb9f6
+         call_gdbserver (tid, exit_reason);
Mark Wielaard efb9f6
+      }
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+      if (tids_schedretcode == VgSrc_FatalSig) {
Mark Wielaard efb9f6
+         gdbserver_process_exit ('X', VG_(threads)[tid].os_state.fatalsig);
Mark Wielaard efb9f6
+         call_gdbserver (tid, exit_reason);
Mark Wielaard efb9f6
+      }
Mark Wielaard efb9f6
+   } else {
Mark Wielaard efb9f6
+      dlog(1, "not connected\n");
Mark Wielaard efb9f6
+   }
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+   /* Tear down the connection if it still exists. */
Mark Wielaard efb9f6
+   VG_(gdbserver) (0);
Mark Wielaard efb9f6
+}
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
 // Check if single_stepping or if there is a break requested at iaddr. 
Mark Wielaard efb9f6
 // If yes, call debugger
Mark Wielaard efb9f6
 VG_REGPARM(1)
Mark Wielaard efb9f6
Index: valgrind/coregrind/m_gdbserver/server.c
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/coregrind/m_gdbserver/server.c	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/coregrind/m_gdbserver/server.c	(working copy)
Mark Wielaard efb9f6
@@ -765,6 +765,13 @@
Mark Wielaard efb9f6
          putpkt (own_buf);
Mark Wielaard efb9f6
       }
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
+      /* If we our status is terminal (exit or fatal signal) get out
Mark Wielaard efb9f6
+         as quickly as we can. We won't be able to handle any request
Mark Wielaard efb9f6
+         anymore.  */
Mark Wielaard efb9f6
+      if (status == 'W' || status == 'X') {
Mark Wielaard efb9f6
+         return;
Mark Wielaard efb9f6
+      }
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
       packet_len = getpkt (own_buf);
Mark Wielaard efb9f6
       if (packet_len <= 0)
Mark Wielaard efb9f6
          break;
Mark Wielaard efb9f6
Index: valgrind/coregrind/m_gdbserver/server.h
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/coregrind/m_gdbserver/server.h	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/coregrind/m_gdbserver/server.h	(working copy)
Mark Wielaard efb9f6
@@ -40,9 +40,9 @@
Mark Wielaard efb9f6
 #include "pub_tool_libcassert.h"
Mark Wielaard efb9f6
 #include "pub_tool_libcbase.h"
Mark Wielaard efb9f6
 #include "pub_tool_options.h"
Mark Wielaard efb9f6
-#include "pub_core_gdbserver.h"
Mark Wielaard efb9f6
 #include "pub_tool_libcsetjmp.h"
Mark Wielaard efb9f6
 #include "pub_core_threadstate.h"
Mark Wielaard efb9f6
+#include "pub_core_gdbserver.h"
Mark Wielaard efb9f6
 #include "pub_core_aspacemgr.h"
Mark Wielaard efb9f6
 #include "pub_tool_vki.h"
Mark Wielaard efb9f6
 #include "valgrind.h"
Mark Wielaard efb9f6
@@ -208,6 +208,9 @@
Mark Wielaard efb9f6
    to ignore the signal, so signal can be delivered to the guest. */
Mark Wielaard efb9f6
 extern Bool gdbserver_deliver_signal (Int vki_sigNo);
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
+/* Called when a process is about to go with reason ('W' or 'X') and code. */
Mark Wielaard efb9f6
+extern void gdbserver_process_exit (unsigned char status, Int code);
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
 /* To optimise signal handling, gdb can instruct gdbserver to
Mark Wielaard efb9f6
    not stop on some signals. In the below, a 1 indicates the gdb_nr signal
Mark Wielaard efb9f6
    has to be passed directly to the guest, without asking gdb.
Mark Wielaard efb9f6
Index: valgrind/coregrind/m_gdbserver/target.c
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/coregrind/m_gdbserver/target.c	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/coregrind/m_gdbserver/target.c	(working copy)
Mark Wielaard efb9f6
@@ -165,6 +165,14 @@
Mark Wielaard efb9f6
    return vki_sigNo == vki_signal_to_deliver;
Mark Wielaard efb9f6
 }
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
+static unsigned char exit_status_to_report;
Mark Wielaard efb9f6
+static int exit_code_to_report;
Mark Wielaard efb9f6
+void gdbserver_process_exit (unsigned char status, Int code)
Mark Wielaard efb9f6
+{
Mark Wielaard efb9f6
+   exit_status_to_report = status;
Mark Wielaard efb9f6
+   exit_code_to_report = code;
Mark Wielaard efb9f6
+}
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
 static
Mark Wielaard efb9f6
 char* sym (Addr addr)
Mark Wielaard efb9f6
 {
Mark Wielaard efb9f6
@@ -248,6 +256,7 @@
Mark Wielaard efb9f6
    unsigned long wptid;
Mark Wielaard efb9f6
    ThreadState *tst;
Mark Wielaard efb9f6
    enum target_signal sig;
Mark Wielaard efb9f6
+   int code;
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
    pid = VG_(getpid) ();
Mark Wielaard efb9f6
    dlog(1, "enter valgrind_wait pid %d\n", pid);
Mark Wielaard efb9f6
@@ -255,6 +264,24 @@
Mark Wielaard efb9f6
    regcache_invalidate();
Mark Wielaard efb9f6
    valgrind_update_threads(pid);
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
+   /* First see if we are done with this process. */
Mark Wielaard efb9f6
+   if (exit_status_to_report != 0) {
Mark Wielaard efb9f6
+      *ourstatus = exit_status_to_report;
Mark Wielaard efb9f6
+      exit_status_to_report = 0;
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+      if (*ourstatus == 'W') {
Mark Wielaard efb9f6
+         code = exit_code_to_report;
Mark Wielaard efb9f6
+         exit_code_to_report = 0;
Mark Wielaard efb9f6
+         return code;
Mark Wielaard efb9f6
+      }
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+      if (*ourstatus == 'X') {
Mark Wielaard efb9f6
+         sig = target_signal_from_host(exit_code_to_report);
Mark Wielaard efb9f6
+         exit_code_to_report = 0;
Mark Wielaard efb9f6
+         return sig;
Mark Wielaard efb9f6
+      }
Mark Wielaard efb9f6
+   }
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
    /* in valgrind, we consider that a wait always succeeds with STOPPED 'T' 
Mark Wielaard efb9f6
       and with a signal TRAP (i.e. a breakpoint), unless there is
Mark Wielaard efb9f6
       a signal to report. */
Mark Wielaard efb9f6
Index: valgrind/coregrind/m_libcprint.c
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/coregrind/m_libcprint.c	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/coregrind/m_libcprint.c	(working copy)
Mark Wielaard efb9f6
@@ -31,7 +31,6 @@
Mark Wielaard efb9f6
 #include "pub_core_basics.h"
Mark Wielaard efb9f6
 #include "pub_core_vki.h"
Mark Wielaard efb9f6
 #include "pub_core_debuglog.h"
Mark Wielaard efb9f6
-#include "pub_core_gdbserver.h"
Mark Wielaard efb9f6
 #include "pub_core_libcbase.h"
Mark Wielaard efb9f6
 #include "pub_core_libcassert.h"
Mark Wielaard efb9f6
 #include "pub_core_libcfile.h"   // VG_(write)(), VG_(write_socket)()
Mark Wielaard efb9f6
Index: valgrind/coregrind/m_main.c
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/coregrind/m_main.c	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/coregrind/m_main.c	(working copy)
Mark Wielaard efb9f6
@@ -2543,7 +2543,7 @@
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
    /* terminate gdbserver if ever it was started. We terminate it here so that it get
Mark Wielaard efb9f6
       the output above if output was redirected to gdb */
Mark Wielaard efb9f6
-   VG_(gdbserver) (0);
Mark Wielaard efb9f6
+   VG_(gdbserver_exit) (tid, tids_schedretcode);
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
    /* Ok, finally exit in the os-specific way, according to the scheduler's
Mark Wielaard efb9f6
       return code.  In short, if the (last) thread exited by calling
Mark Wielaard efb9f6
Index: valgrind/coregrind/pub_core_gdbserver.h
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/coregrind/pub_core_gdbserver.h	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/coregrind/pub_core_gdbserver.h	(working copy)
Mark Wielaard efb9f6
@@ -48,7 +48,10 @@
Mark Wielaard efb9f6
 // to handle this incoming vgdb request.                                
Mark Wielaard efb9f6
 extern Bool VG_(gdbserver_activity) (ThreadId tid);
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
+// Called by low level when the process is about to exit and why.
Mark Wielaard efb9f6
+void VG_(gdbserver_exit) (ThreadId, VgSchedReturnCode);
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
 /* Called by low level to insert or remove a break or watch point.
Mark Wielaard efb9f6
    Break or watch point implementation is done using help from the tool.
Mark Wielaard efb9f6
    break point support implies some (small) specific instrumentation
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/Makefile.am
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/Makefile.am	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/Makefile.am	(working copy)
Mark Wielaard efb9f6
@@ -100,7 +100,22 @@
Mark Wielaard efb9f6
 	nlsigvgdb.vgtest \
Mark Wielaard efb9f6
 	nlsigvgdb.stderr.exp \
Mark Wielaard efb9f6
 	nlsigvgdb.stderrB.exp \
Mark Wielaard efb9f6
-	nlsigvgdb.stdinB.gdb
Mark Wielaard efb9f6
+	nlsigvgdb.stdinB.gdb \
Mark Wielaard efb9f6
+	gone_abrt.stderr.exp \
Mark Wielaard efb9f6
+	gone_abrt.stderrB.exp \
Mark Wielaard efb9f6
+	gone_abrt.stdinB.gdb \
Mark Wielaard efb9f6
+	gone_abrt.stdoutB.exp \
Mark Wielaard efb9f6
+	gone_abrt.vgtest \
Mark Wielaard efb9f6
+	gone_exit.stderr.exp \
Mark Wielaard efb9f6
+	gone_exit.stderrB.exp \
Mark Wielaard efb9f6
+	gone_exit.stdinB.gdb \
Mark Wielaard efb9f6
+	gone_exit.stdoutB.exp \
Mark Wielaard efb9f6
+	gone_exit.vgtest \
Mark Wielaard efb9f6
+	gone_return.stderr.exp \
Mark Wielaard efb9f6
+	gone_return.stderrB.exp \
Mark Wielaard efb9f6
+	gone_return.stdinB.gdb \
Mark Wielaard efb9f6
+	gone_return.stdoutB.exp \
Mark Wielaard efb9f6
+	gone_return.vgtest
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
 check_PROGRAMS = \
Mark Wielaard efb9f6
 	clean_after_fork \
Mark Wielaard efb9f6
@@ -109,7 +124,8 @@
Mark Wielaard efb9f6
 	sleepers \
Mark Wielaard efb9f6
 	main_pic \
Mark Wielaard efb9f6
 	t \
Mark Wielaard efb9f6
-	watchpoints
Mark Wielaard efb9f6
+	watchpoints \
Mark Wielaard efb9f6
+	gone
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
 AM_CFLAGS   += $(AM_FLAG_M3264_PRI)
Mark Wielaard efb9f6
 AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/filter_gdb
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/filter_gdb	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/filter_gdb	(working copy)
Mark Wielaard efb9f6
@@ -49,6 +51,8 @@
Mark Wielaard efb9f6
 #         a.o. produced by gdb 7.2 on arm (same with standard gdbserver)
Mark Wielaard efb9f6
 #       delete empty lines (the last line (only made of prompts) sometimes
Mark Wielaard efb9f6
 #           finishes with a new line, sometimes not ???).
Mark Wielaard efb9f6
+#       'exited with code' and 'exited normally' are printed slightly
Mark Wielaard efb9f6
+#       differently between gdb versions, normalize to "Program exited...".
Mark Wielaard efb9f6
 sed -e '/Remote debugging using/,/vgdb launched process attached/d'                                   \
Mark Wielaard efb9f6
     -e 's/^\[?1034hReading symbols/Reading symbols/'                                                \
Mark Wielaard efb9f6
     -e '/^Missing separate debuginfo/d'                                                               \
Mark Wielaard efb9f6
@@ -64,6 +68,8 @@
Mark Wielaard efb9f6
     -e '/^Loaded symbols for .*$/d'                                                                   \
Mark Wielaard efb9f6
     -e '/^Current language.*/d'                                                                       \
Mark Wielaard efb9f6
     -e '/^The current source language is.*/d'                                                         \
Mark Wielaard efb9f6
+    -e 's/^.*\( exited with code [0-9]\+\).$/Program\1\./g'                              \
Mark Wielaard efb9f6
+    -e 's/^.*\( exited normally\).$/Program\1\./g'                              \
Mark Wielaard efb9f6
     -e 's/(gdb) //g'                                                                                  \
Mark Wielaard efb9f6
     -e 's/^>[> ]*//'                                                                                  \
Mark Wielaard efb9f6
     -e '/^done\.$/d'                                                                                  \
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone.c
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone.c	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone.c	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,33 @@
Mark Wielaard efb9f6
+#include <signal.h>
Mark Wielaard efb9f6
+#include <stdio.h>
Mark Wielaard efb9f6
+#include <stdlib.h>
Mark Wielaard efb9f6
+#include <string.h>
Mark Wielaard efb9f6
+#include <unistd.h>
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+int
Mark Wielaard efb9f6
+main (int argc, char **argv)
Mark Wielaard efb9f6
+{
Mark Wielaard efb9f6
+  fprintf(stderr, "starting ...\n");
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+  // Three ways of going away...
Mark Wielaard efb9f6
+  if (argc > 1)
Mark Wielaard efb9f6
+    {
Mark Wielaard efb9f6
+      // Explicit exit() with exit code.
Mark Wielaard efb9f6
+      if (strcmp (argv[1], "exit") == 0)
Mark Wielaard efb9f6
+	{
Mark Wielaard efb9f6
+	  fprintf(stderr, "exiting ...\n");
Mark Wielaard efb9f6
+	  exit (1);
Mark Wielaard efb9f6
+	}
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+      // Get killed by a signal.
Mark Wielaard efb9f6
+      if (strcmp (argv[1], "abort") == 0)
Mark Wielaard efb9f6
+	{
Mark Wielaard efb9f6
+	  fprintf(stderr, "aborting ...\n");
Mark Wielaard efb9f6
+	  kill(getpid(), SIGABRT);
Mark Wielaard efb9f6
+	}
Mark Wielaard efb9f6
+    }
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+  // And finally, just return from main with success.
Mark Wielaard efb9f6
+  fprintf(stderr, "returning ...\n");
Mark Wielaard efb9f6
+  return 0;
Mark Wielaard efb9f6
+}
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_abrt.stderr.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_abrt.stderr.exp	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_abrt.stderr.exp	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,8 @@
Mark Wielaard efb9f6
+Nulgrind, the minimal Valgrind tool
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+(action at startup) vgdb me ... 
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+starting ...
Mark Wielaard efb9f6
+aborting ...
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_abrt.stderrB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_abrt.stderrB.exp	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_abrt.stderrB.exp	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1 @@
Mark Wielaard efb9f6
+relaying data between gdb and process ....
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_abrt.stdinB.gdb
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_abrt.stdinB.gdb	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_abrt.stdinB.gdb	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,9 @@
Mark Wielaard efb9f6
+# connect gdb to Valgrind gdbserver:
Mark Wielaard efb9f6
+target remote | ./vgdb --wait=60 --vgdb-prefix=./vgdb-prefix-gone-abrt
Mark Wielaard efb9f6
+echo vgdb launched process attached\n
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+continue
Mark Wielaard efb9f6
+# see process get a fatal signal
Mark Wielaard efb9f6
+continue
Mark Wielaard efb9f6
+# see program is gone
Mark Wielaard efb9f6
+quit
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_abrt.stdoutB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_abrt.stdoutB.exp	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_abrt.stdoutB.exp	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,7 @@
Mark Wielaard efb9f6
+vgdb launched process attached
Mark Wielaard efb9f6
+Continuing.
Mark Wielaard efb9f6
+Program received signal SIGABRT, Aborted.
Mark Wielaard efb9f6
+0x........ in syscall ...
Mark Wielaard efb9f6
+Continuing.
Mark Wielaard efb9f6
+Program terminated with signal SIGABRT, Aborted.
Mark Wielaard efb9f6
+The program no longer exists.
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_abrt.vgtest
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_abrt.vgtest	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_abrt.vgtest	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,12 @@
Mark Wielaard efb9f6
+# test that a fatal SIGABRT signal is properly passed on to gdb.
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+prog: gone
Mark Wielaard efb9f6
+args: abort
Mark Wielaard efb9f6
+vgopts: --tool=none --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-gone-abrt
Mark Wielaard efb9f6
+stderr_filter: filter_stderr
Mark Wielaard efb9f6
+prereq: test -e gdb
Mark Wielaard efb9f6
+progB: gdb
Mark Wielaard efb9f6
+argsB: --quiet -l 60 --nx ./gone
Mark Wielaard efb9f6
+stdinB: gone_abrt.stdinB.gdb
Mark Wielaard efb9f6
+stdoutB_filter: filter_gdb
Mark Wielaard efb9f6
+stderrB_filter: filter_gdb
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_exit.stderr.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_exit.stderr.exp	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_exit.stderr.exp	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,8 @@
Mark Wielaard efb9f6
+Nulgrind, the minimal Valgrind tool
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+(action at startup) vgdb me ... 
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+starting ...
Mark Wielaard efb9f6
+exiting ...
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_exit.stderrB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_exit.stderrB.exp	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_exit.stderrB.exp	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1 @@
Mark Wielaard efb9f6
+relaying data between gdb and process ....
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_exit.stdinB.gdb
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_exit.stdinB.gdb	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_exit.stdinB.gdb	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,7 @@
Mark Wielaard efb9f6
+# connect gdb to Valgrind gdbserver:
Mark Wielaard efb9f6
+target remote | ./vgdb --wait=60 --vgdb-prefix=./vgdb-prefix-gone-exit
Mark Wielaard efb9f6
+echo vgdb launched process attached\n
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+continue
Mark Wielaard efb9f6
+# see program is gone with exit code
Mark Wielaard efb9f6
+quit
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_exit.stdoutB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_exit.stdoutB.exp	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_exit.stdoutB.exp	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,3 @@
Mark Wielaard efb9f6
+vgdb launched process attached
Mark Wielaard efb9f6
+Continuing.
Mark Wielaard efb9f6
+Program exited with code 01.
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_exit.vgtest
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_exit.vgtest	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_exit.vgtest	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,12 @@
Mark Wielaard efb9f6
+# test that an exit (with return value) is properly passed on to gdb.
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+prog: gone
Mark Wielaard efb9f6
+args: exit
Mark Wielaard efb9f6
+vgopts: --tool=none --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-gone-exit
Mark Wielaard efb9f6
+stderr_filter: filter_stderr
Mark Wielaard efb9f6
+prereq: test -e gdb
Mark Wielaard efb9f6
+progB: gdb
Mark Wielaard efb9f6
+argsB: --quiet -l 60 --nx ./gone
Mark Wielaard efb9f6
+stdinB: gone_exit.stdinB.gdb
Mark Wielaard efb9f6
+stdoutB_filter: filter_gdb
Mark Wielaard efb9f6
+stderrB_filter: filter_gdb
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_return.stderr.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_return.stderr.exp	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_return.stderr.exp	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,8 @@
Mark Wielaard efb9f6
+Nulgrind, the minimal Valgrind tool
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+(action at startup) vgdb me ... 
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+starting ...
Mark Wielaard efb9f6
+returning ...
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_return.stderrB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_return.stderrB.exp	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_return.stderrB.exp	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1 @@
Mark Wielaard efb9f6
+relaying data between gdb and process ....
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_return.stdinB.gdb
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_return.stdinB.gdb	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_return.stdinB.gdb	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,7 @@
Mark Wielaard efb9f6
+# connect gdb to Valgrind gdbserver:
Mark Wielaard efb9f6
+target remote | ./vgdb --wait=60 --vgdb-prefix=./vgdb-prefix-gone-return
Mark Wielaard efb9f6
+echo vgdb launched process attached\n
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+continue
Mark Wielaard efb9f6
+# see program is gone
Mark Wielaard efb9f6
+quit
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_return.stdoutB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_return.stdoutB.exp	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_return.stdoutB.exp	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,3 @@
Mark Wielaard efb9f6
+vgdb launched process attached
Mark Wielaard efb9f6
+Continuing.
Mark Wielaard efb9f6
+Program exited normally.
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/gone_return.vgtest
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/gone_return.vgtest	(revision 0)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/gone_return.vgtest	(working copy)
Mark Wielaard efb9f6
@@ -0,0 +1,12 @@
Mark Wielaard efb9f6
+# test that a normal (successful) return is properly passed on to gdb.
Mark Wielaard efb9f6
+
Mark Wielaard efb9f6
+prog: gone
Mark Wielaard efb9f6
+args: return
Mark Wielaard efb9f6
+vgopts: --tool=none --vgdb=yes --vgdb-error=0 --vgdb-prefix=./vgdb-prefix-gone-return
Mark Wielaard efb9f6
+stderr_filter: filter_stderr
Mark Wielaard efb9f6
+prereq: test -e gdb
Mark Wielaard efb9f6
+progB: gdb
Mark Wielaard efb9f6
+argsB: --quiet -l 60 --nx ./gone
Mark Wielaard efb9f6
+stdinB: gone_return.stdinB.gdb
Mark Wielaard efb9f6
+stdoutB_filter: filter_gdb
Mark Wielaard efb9f6
+stderrB_filter: filter_gdb
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/mcleak.stderrB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/mcleak.stderrB.exp	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/mcleak.stderrB.exp	(working copy)
Mark Wielaard efb9f6
@@ -95,4 +95,3 @@
Mark Wielaard efb9f6
    by 0x........: f (leak-delta.c:28)
Mark Wielaard efb9f6
    by 0x........: main (leak-delta.c:60)
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
-Remote connection closed
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/mcleak.stdoutB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/mcleak.stdoutB.exp	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/mcleak.stdoutB.exp	(working copy)
Mark Wielaard efb9f6
@@ -45,3 +45,4 @@
Mark Wielaard efb9f6
 #1  0x........ in f () at leak-delta.c:48
Mark Wielaard efb9f6
 48	   fprintf(stderr, "expecting details 32 (+32) bytes lost, 33 (-32) bytes reachable\n"); fflush(stderr); breakme();
Mark Wielaard efb9f6
 Continuing.
Mark Wielaard efb9f6
+Program exited normally.
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/mcmain_pic.stderrB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/mcmain_pic.stderrB.exp	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/mcmain_pic.stderrB.exp	(working copy)
Mark Wielaard efb9f6
@@ -1,3 +1,2 @@
Mark Wielaard efb9f6
 relaying data between gdb and process ....
Mark Wielaard efb9f6
 vgdb-error value changed from 0 to 999999
Mark Wielaard efb9f6
-Remote connection closed
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/mcmain_pic.stdoutB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/mcmain_pic.stdoutB.exp	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/mcmain_pic.stdoutB.exp	(working copy)
Mark Wielaard efb9f6
@@ -6,3 +6,4 @@
Mark Wielaard efb9f6
 $2 = (int (*)(int, char **)) 0x........ <main>
Mark Wielaard efb9f6
 $3 = (void (*)(char *)) 0x........ <another_func>
Mark Wielaard efb9f6
 Continuing.
Mark Wielaard efb9f6
+Program exited normally.
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/mcwatchpoints.stdoutB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/mcwatchpoints.stdoutB.exp	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/mcwatchpoints.stdoutB.exp	(working copy)
Mark Wielaard efb9f6
@@ -32,3 +32,4 @@
Mark Wielaard efb9f6
 49	   fprintf(stderr, "after writing 8\n");
Mark Wielaard efb9f6
 Delete all breakpoints? (y or n) [answered Y; input not from terminal]
Mark Wielaard efb9f6
 Continuing.
Mark Wielaard efb9f6
+Program exited normally.
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/nlcontrolc.stdoutB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/nlcontrolc.stdoutB.exp	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/nlcontrolc.stdoutB.exp	(working copy)
Mark Wielaard efb9f6
@@ -21,3 +21,4 @@
Mark Wielaard efb9f6
 $6 = 0
Mark Wielaard efb9f6
 $7 = 0
Mark Wielaard efb9f6
 Continuing.
Mark Wielaard efb9f6
+Program exited normally.
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/nlpasssigalrm.stderrB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/nlpasssigalrm.stderrB.exp	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/nlpasssigalrm.stderrB.exp	(working copy)
Mark Wielaard efb9f6
@@ -1,3 +1,2 @@
Mark Wielaard efb9f6
 relaying data between gdb and process ....
Mark Wielaard efb9f6
 vgdb-error value changed from 0 to 999999
Mark Wielaard efb9f6
-Remote connection closed
Mark Wielaard efb9f6
Index: valgrind/gdbserver_tests/nlpasssigalrm.stdoutB.exp
Mark Wielaard efb9f6
===================================================================
Mark Wielaard efb9f6
--- valgrind/gdbserver_tests/nlpasssigalrm.stdoutB.exp	(revision 13036)
Mark Wielaard efb9f6
+++ valgrind/gdbserver_tests/nlpasssigalrm.stdoutB.exp	(working copy)
Mark Wielaard efb9f6
@@ -19,3 +19,4 @@
Mark Wielaard efb9f6
 Program received signal SIG34, Real-time event 34.
Mark Wielaard efb9f6
 0x........ in syscall ...
Mark Wielaard efb9f6
 Continuing.
Mark Wielaard efb9f6
+Program exited normally.
Mark Wielaard efb9f6
--- valgrind-3.8.1/gdbserver_tests/Makefile.in.orig	2012-10-13 16:35:43.846865557 +0200
Mark Wielaard efb9f6
+++ valgrind-3.8.1/gdbserver_tests/Makefile.in	2012-10-13 16:36:37.445641004 +0200
Mark Wielaard efb9f6
@@ -56,7 +56,7 @@
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
 check_PROGRAMS = clean_after_fork$(EXEEXT) fork_chain$(EXEEXT) \
Mark Wielaard efb9f6
 	passsigalrm$(EXEEXT) sleepers$(EXEEXT) main_pic$(EXEEXT) \
Mark Wielaard efb9f6
-	t$(EXEEXT) watchpoints$(EXEEXT)
Mark Wielaard efb9f6
+	t$(EXEEXT) watchpoints$(EXEEXT) gone$(EXEEXT)
Mark Wielaard efb9f6
 subdir = gdbserver_tests
Mark Wielaard efb9f6
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
Mark Wielaard efb9f6
 am__aclocal_m4_deps = $(top_srcdir)/configure.in
Mark Wielaard efb9f6
@@ -74,6 +74,10 @@
Mark Wielaard efb9f6
 fork_chain_OBJECTS = fork_chain.$(OBJEXT)
Mark Wielaard efb9f6
 fork_chain_LDADD = $(LDADD)
Mark Wielaard efb9f6
 fork_chain_DEPENDENCIES =
Mark Wielaard efb9f6
+gone_SOURCES = gone.c
Mark Wielaard efb9f6
+gone_OBJECTS = gone.$(OBJEXT)
Mark Wielaard efb9f6
+gone_LDADD = $(LDADD)
Mark Wielaard efb9f6
+gone_DEPENDENCIES =
Mark Wielaard efb9f6
 main_pic_SOURCES = main_pic.c
Mark Wielaard efb9f6
 main_pic_OBJECTS = main_pic-main_pic.$(OBJEXT)
Mark Wielaard efb9f6
 main_pic_LDADD = $(LDADD)
Mark Wielaard efb9f6
@@ -105,9 +109,9 @@
Mark Wielaard efb9f6
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
Mark Wielaard efb9f6
 CCLD = $(CC)
Mark Wielaard efb9f6
 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
Mark Wielaard efb9f6
-SOURCES = clean_after_fork.c fork_chain.c main_pic.c passsigalrm.c \
Mark Wielaard efb9f6
-	sleepers.c t.c watchpoints.c
Mark Wielaard efb9f6
-DIST_SOURCES = clean_after_fork.c fork_chain.c main_pic.c \
Mark Wielaard efb9f6
+SOURCES = clean_after_fork.c fork_chain.c gone.c main_pic.c \
Mark Wielaard efb9f6
+	passsigalrm.c sleepers.c t.c watchpoints.c
Mark Wielaard efb9f6
+DIST_SOURCES = clean_after_fork.c fork_chain.c gone.c main_pic.c \
Mark Wielaard efb9f6
 	passsigalrm.c sleepers.c t.c watchpoints.c
Mark Wielaard efb9f6
 ETAGS = etags
Mark Wielaard efb9f6
 CTAGS = ctags
Mark Wielaard efb9f6
@@ -487,7 +491,22 @@
Mark Wielaard efb9f6
 	nlsigvgdb.vgtest \
Mark Wielaard efb9f6
 	nlsigvgdb.stderr.exp \
Mark Wielaard efb9f6
 	nlsigvgdb.stderrB.exp \
Mark Wielaard efb9f6
-	nlsigvgdb.stdinB.gdb
Mark Wielaard efb9f6
+	nlsigvgdb.stdinB.gdb \
Mark Wielaard efb9f6
+	gone_abrt.stderr.exp \
Mark Wielaard efb9f6
+	gone_abrt.stderrB.exp \
Mark Wielaard efb9f6
+	gone_abrt.stdinB.gdb \
Mark Wielaard efb9f6
+	gone_abrt.stdoutB.exp \
Mark Wielaard efb9f6
+	gone_abrt.vgtest \
Mark Wielaard efb9f6
+	gone_exit.stderr.exp \
Mark Wielaard efb9f6
+	gone_exit.stderrB.exp \
Mark Wielaard efb9f6
+	gone_exit.stdinB.gdb \
Mark Wielaard efb9f6
+	gone_exit.stdoutB.exp \
Mark Wielaard efb9f6
+	gone_exit.vgtest \
Mark Wielaard efb9f6
+	gone_return.stderr.exp \
Mark Wielaard efb9f6
+	gone_return.stderrB.exp \
Mark Wielaard efb9f6
+	gone_return.stdinB.gdb \
Mark Wielaard efb9f6
+	gone_return.stdoutB.exp \
Mark Wielaard efb9f6
+	gone_return.vgtest
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
 LDADD = -lpthread
Mark Wielaard efb9f6
 main_pic_LDFLAGS = -pie
Mark Wielaard efb9f6
@@ -535,6 +554,9 @@
Mark Wielaard efb9f6
 fork_chain$(EXEEXT): $(fork_chain_OBJECTS) $(fork_chain_DEPENDENCIES) 
Mark Wielaard efb9f6
 	@rm -f fork_chain$(EXEEXT)
Mark Wielaard efb9f6
 	$(LINK) $(fork_chain_OBJECTS) $(fork_chain_LDADD) $(LIBS)
Mark Wielaard efb9f6
+gone$(EXEEXT): $(gone_OBJECTS) $(gone_DEPENDENCIES) 
Mark Wielaard efb9f6
+	@rm -f gone$(EXEEXT)
Mark Wielaard efb9f6
+	$(LINK) $(gone_OBJECTS) $(gone_LDADD) $(LIBS)
Mark Wielaard efb9f6
 main_pic$(EXEEXT): $(main_pic_OBJECTS) $(main_pic_DEPENDENCIES) 
Mark Wielaard efb9f6
 	@rm -f main_pic$(EXEEXT)
Mark Wielaard efb9f6
 	$(main_pic_LINK) $(main_pic_OBJECTS) $(main_pic_LDADD) $(LIBS)
Mark Wielaard efb9f6
@@ -559,6 +581,7 @@
Mark Wielaard efb9f6
 
Mark Wielaard efb9f6
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clean_after_fork.Po@am__quote@
Mark Wielaard efb9f6
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fork_chain.Po@am__quote@
Mark Wielaard efb9f6
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gone.Po@am__quote@
Mark Wielaard efb9f6
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main_pic-main_pic.Po@am__quote@
Mark Wielaard efb9f6
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/passsigalrm.Po@am__quote@
Mark Wielaard efb9f6
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sleepers.Po@am__quote@