This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Allow breakpoints to generate SIGSEGV
- From: Mark Kettenis <kettenis at chello dot nl>
- To: gdb-patches at sources dot redhat dot com
- Date: Thu, 5 Feb 2004 20:57:00 +0100 (CET)
- Subject: [PATCH] Allow breakpoints to generate SIGSEGV
I did some testing on i386 (which is "DECR_PC_AFTER_BREAK"), trying to
get a breakpoint and a SIGSEGV generating instruction to coalesce. In
all cases, GDB behaved correctly. Given that both Andrew and Daniel
were in favour of this patch and only Eli objected, I committed the
patch we discussed. I also added a note to the NEWS file.
Mark
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* infrun.c (handle_inferior_event): Allow for breakpoint
instructions to generate a SIGSEGV in addition to SIGTRAP, SIGILL
and SIGEMT. Update comments.
* NEWS (Revised SPARC target): Mention support for non-executable
stack.
Index: NEWS
===================================================================
RCS file: /cvs/src/src/gdb/NEWS,v
retrieving revision 1.134
diff -u -p -r1.134 NEWS
--- NEWS 22 Jan 2004 23:18:03 -0000 1.134
+++ NEWS 5 Feb 2004 19:47:13 -0000
@@ -19,7 +19,9 @@ you should upgrade gdbserver on the remo
The SPARC target has been completely revised, incorporating the
FreeBSD/sparc64 support that was added for GDB 6.0. As a result
-support for LynxOS and SunOS 4 has been dropped.
+support for LynxOS and SunOS 4 has been dropped. Calling functions
+from within GDB on operating systems with a non-executable stack
+(Solaris, OpenBSD) now works.
* New C++ demangler
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.134
diff -u -p -r1.134 infrun.c
--- infrun.c 1 Feb 2004 18:05:09 -0000 1.134
+++ infrun.c 5 Feb 2004 19:47:15 -0000
@@ -1975,15 +1975,20 @@ handle_inferior_event (struct execution_
will be made according to the signal handling tables. */
/* First, distinguish signals caused by the debugger from signals
- that have to do with the program's own actions.
- Note that breakpoint insns may cause SIGTRAP or SIGILL
- or SIGEMT, depending on the operating system version.
- Here we detect when a SIGILL or SIGEMT is really a breakpoint
- and change it to SIGTRAP. */
+ that have to do with the program's own actions. Note that
+ breakpoint insns may cause SIGTRAP or SIGILL or SIGEMT, depending
+ on the operating system version. Here we detect when a SIGILL or
+ SIGEMT is really a breakpoint and change it to SIGTRAP. We do
+ something similar for SIGSEGV, since a SIGSEGV will be generated
+ when we're trying to execute a breakpoint instruction on a
+ non-executable stack. This happens for call dummy breakpoints
+ for architectures like SPARC that place call dummies on the
+ stack. */
if (stop_signal == TARGET_SIGNAL_TRAP
|| (breakpoints_inserted &&
(stop_signal == TARGET_SIGNAL_ILL
+ || stop_signal == TARGET_SIGNAL_SEGV
|| stop_signal == TARGET_SIGNAL_EMT))
|| stop_soon == STOP_QUIETLY
|| stop_soon == STOP_QUIETLY_NO_SIGSTOP)
@@ -2046,10 +2051,14 @@ handle_inferior_event (struct execution_
If someone ever tries to get get call dummys on a
non-executable stack to work (where the target would stop
- with something like a SIGSEG), then those tests might need to
- be re-instated. Given, however, that the tests were only
+ with something like a SIGSEGV), then those tests might need
+ to be re-instated. Given, however, that the tests were only
enabled when momentary breakpoints were not being used, I
- suspect that it won't be the case. */
+ suspect that it won't be the case.
+
+ NOTE: kettenis/2004-02-05: Indeed such checks don't seem to
+ be necessary for call dummies on a non-executable stack on
+ SPARC. */
if (stop_signal == TARGET_SIGNAL_TRAP)
ecs->random_signal