]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
fix 339156 - gdbsrv not called for fatal signal
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 19 Sep 2014 08:57:29 +0000 (08:57 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 19 Sep 2014 08:57:29 +0000 (08:57 +0000)
In preparation for removing --db-attach=yes, call gdbserver
for a fatal signal (where --db-attach=yes is also calling gdb)

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14556

NEWS
coregrind/m_gdbserver/m_gdbserver.c
coregrind/m_signals.c
coregrind/pub_core_gdbserver.h

diff --git a/NEWS b/NEWS
index de374fd50f5946e94ec79b4f88b5ace998272cd0..cfd5e628182e61244de0baecd991043bdd6f38a5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,7 @@ To see details of a given bug, visit
 where XXXXXX is the bug number as listed below.
 
 339020 ppc64: memcheck/tests/ppc64/power_ISA2_05 failing in nightly build
+339156 - gdbsrv not called for fatal signal
 n-i-bz Old STABS code is still being compiled, but never used. Remove it.
 
 
index 04ca77c9af4a3b4736f12ba2b60cba1266acfd33..46bfbed19d5adfcf9b8cf3a690783a78f5e56804 100644 (file)
@@ -931,6 +931,31 @@ Bool VG_(gdbserver_activity) (ThreadId tid)
    return ret;
 }
 
+
+void VG_(gdbserver_report_fatal_signal) (Int vki_sigNo, ThreadId tid)
+{
+   dlog(1, "VG core calling VG_(gdbserver_report_fatal_signal) "
+        "vki_nr %d %s gdb_nr %d %s tid %d\n", 
+        vki_sigNo, VG_(signame)(vki_sigNo),
+        target_signal_from_host (vki_sigNo),
+        target_signal_to_name(target_signal_from_host (vki_sigNo)), 
+        tid);
+
+   if (remote_connected()) {
+      dlog(1, "already connected, assuming already reported\n");
+      return;
+   }
+
+   VG_(umsg)("(action on fatal signal) vgdb me ... \n");
+
+   /* indicate to gdbserver that there is a signal */
+   gdbserver_signal_encountered (vki_sigNo);
+
+   /* let gdbserver do some work, e.g. show the signal to the user */
+   call_gdbserver (tid, signal_reason);
+   
+}
+
 Bool VG_(gdbserver_report_signal) (Int vki_sigNo, ThreadId tid)
 {
    dlog(1, "VG core calling VG_(gdbserver_report_signal) "
index 77c1c8da000b733ef286552980530fbf37c6f5a4..cf61137203a90381e7f60d13436cf89aec8904ea 100644 (file)
@@ -1760,6 +1760,13 @@ static void default_action(const vki_siginfo_t *info, ThreadId tid)
       }
    }
 
+   if (VG_(clo_vgdb) != Vg_VgdbNo
+       && VG_(dyn_vgdb_error) <= VG_(get_n_errs_shown)() + 1) {
+      /* Note: we add + 1 to n_errs_shown as the fatal signal was not
+         reported through error msg, and so was not counted. */
+      VG_(gdbserver_report_fatal_signal) (sigNo, tid);
+   }
+
    if (VG_(is_action_requested)( "Attach to debugger", & VG_(clo_db_attach) )) {
       VG_(start_debugger)( tid );
    }
index bfa306fc13f5bf0d82989224db880ca6950a7c3e..de5b5dae730be80fd8c6a410a036c520546c38ac 100644 (file)
@@ -100,11 +100,19 @@ Bool VG_(has_gdbserver_breakpoint) (Addr addr);
 extern void VG_(invoke_gdbserver) ( int check );
 
 // To be called by core (m_signals.c) before delivering a signal.
-// Returns True unless gdb user asks to not pass the signal to the client.
+// Returns False if gdb user asks to not pass the signal to the client.
+// Returns True if signal must be passed to the client, either because
+// no gdb is connected, or gdb instructs to pass the signal.
 // Note that if the below returns True, the signal might
 // still be ignored if this is the action desired by the
 // guest program.
-extern Bool VG_(gdbserver_report_signal) (Int signo, ThreadId tid);
+extern Bool VG_(gdbserver_report_signal) (Int vki_signo, ThreadId tid);
+
+// If no gdb is connected yet, wait for a gdb to connect and report
+// this (supposedly) fatal signal.
+// If a gdb is already connected, this does nothing (as normally 
+// the signal was already reported to the already connected gdb).
+extern void VG_(gdbserver_report_fatal_signal) (Int vki_signo, ThreadId tid);
 
 /* Entry point invoked by scheduler.c to execute the request 
    VALGRIND_CLIENT_MONITOR_COMMAND.