diff options
author | Antoine Tremblay <antoine.tremblay@ericsson.com> | 2015-02-12 14:55:08 -0500 |
---|---|---|
committer | Antoine Tremblay <antoine.tremblay@ericsson.com> | 2015-02-19 11:04:21 -0500 |
commit | c9587f88230e9df836f17c195181aaf50c3a1117 (patch) | |
tree | ef8a222874050aef5c425aa624a11c8d178e6149 /gdb/linux-nat.c | |
parent | 53cf2ee0d933ac4d95530555854a6f8d3cefc2e8 (diff) | |
download | gdb-c9587f88230e9df836f17c195181aaf50c3a1117.zip gdb-c9587f88230e9df836f17c195181aaf50c3a1117.tar.gz gdb-c9587f88230e9df836f17c195181aaf50c3a1117.tar.bz2 |
Fix non executable stack handling when calling functions in the inferior.
When gdb creates a dummy frame to execute a function in the inferior,
the process may generate a SIGSEGV, SIGTRAP or SIGILL because the stack
is non executable. If the signal handler set in gdb has option print
or stop enabled for these signals gdb handles this correctly.
However, in the case of noprint and nostop the signal is short-circuited
and the inferior process is sent the signal directly. This causes the
inferior to crash because of gdb.
This patch adds a check for SIGSEGV, SIGTRAP or SIGILL so that these
signals are sent to gdb rather than short-circuited in the inferior.
gdb then handles them properly and the inferior process does not
crash.
This patch also fixes the same behavior in gdbserver.
Also added a small testcase to test the issue called catch-gdb-caused-signals.
This applies to Linux only, tested on Linux.
gdb/ChangeLog:
PR breakpoints/16812
* linux-nat.c (linux_nat_filter_event): Report SIGTRAP,SIGILL,SIGSEGV.
* nat/linux-ptrace.c (linux_wstatus_maybe_breakpoint): Add.
* nat/linux-ptrace.h: Add linux_wstatus_maybe_breakpoint.
gdb/gdbserver/ChangeLog:
PR breakpoints/16812
* linux-low.c (wstatus_maybe_breakpoint): Remove.
(linux_low_filter_event): Update wstatus_maybe_breakpoint name.
(linux_wait_1): Report SIGTRAP,SIGILL,SIGSEGV.
gdb/testsuite/ChangeLog:
PR breakpoints/16812
* gdb.base/catch-gdb-caused-signals.c: New file.
* gdb.base/catch-gdb-caused-signals.exp: New file.
Diffstat (limited to 'gdb/linux-nat.c')
-rw-r--r-- | gdb/linux-nat.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 169188a..ed007bd 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -3070,9 +3070,11 @@ linux_nat_filter_event (int lwpid, int status) } /* When using hardware single-step, we need to report every signal. - Otherwise, signals in pass_mask may be short-circuited. */ + Otherwise, signals in pass_mask may be short-circuited + except signals that might be caused by a breakpoint. */ if (!lp->step - && WSTOPSIG (status) && sigismember (&pass_mask, WSTOPSIG (status))) + && WSTOPSIG (status) && sigismember (&pass_mask, WSTOPSIG (status)) + && !linux_wstatus_maybe_breakpoint (status)) { linux_resume_one_lwp (lp, lp->step, signo); if (debug_linux_nat) |