From: Philippe Waroquiers Date: Fri, 19 Sep 2014 08:57:29 +0000 (+0000) Subject: fix 339156 - gdbsrv not called for fatal signal X-Git-Tag: svn/VALGRIND_3_11_0~976 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aaf3f62ddb65eae41d200adfb449eabc61b9221b;p=thirdparty%2Fvalgrind.git fix 339156 - gdbsrv not called for fatal signal 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 --- diff --git a/NEWS b/NEWS index de374fd50f..cfd5e62818 100644 --- 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. diff --git a/coregrind/m_gdbserver/m_gdbserver.c b/coregrind/m_gdbserver/m_gdbserver.c index 04ca77c9af..46bfbed19d 100644 --- a/coregrind/m_gdbserver/m_gdbserver.c +++ b/coregrind/m_gdbserver/m_gdbserver.c @@ -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) " diff --git a/coregrind/m_signals.c b/coregrind/m_signals.c index 77c1c8da00..cf61137203 100644 --- a/coregrind/m_signals.c +++ b/coregrind/m_signals.c @@ -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 ); } diff --git a/coregrind/pub_core_gdbserver.h b/coregrind/pub_core_gdbserver.h index bfa306fc13..de5b5dae73 100644 --- a/coregrind/pub_core_gdbserver.h +++ b/coregrind/pub_core_gdbserver.h @@ -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.