aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-06-18 19:57:49 +0000
committerTom Tromey <tromey@redhat.com>2013-06-18 19:57:49 +0000
commit427cd150eed8c0dd4f0d0a1105448b4ebe36da6d (patch)
treeed94cd3b70e5de75895c7abcb57bc78ad1f83911 /gdb/breakpoint.c
parentc31f39360b3865a248055587778301e85da250fc (diff)
downloadgdb-427cd150eed8c0dd4f0d0a1105448b4ebe36da6d.zip
gdb-427cd150eed8c0dd4f0d0a1105448b4ebe36da6d.tar.gz
gdb-427cd150eed8c0dd4f0d0a1105448b4ebe36da6d.tar.bz2
Fix PR cli/15603
This fixes PR cli/15603. The bug here is that when a software watchpoint is being used, gdb will stop responding to C-c. This is a regression caused by the "catch signal" patch. The problem is that software watchpoints always end up on the bpstat list. However, this makes bpstat_explains_signal return BPSTAT_SIGNAL_HIDE, causing infrun to think that the signal is not a "random signal". The fix is to change bpstat_explains_signal to handle this better. I chose to do it in a "clean API" way, by passing the signal value to bpstat_explains_signal and then adding an explains_signal method for watchpoints, which handles the specifics. Built and regtested on x86-64 Fedora 18. New test case included. * break-catch-sig.c (signal_catchpoint_explains_signal): Add 'sig' argument. * breakpoint.c (bpstat_explains_signal): Add 'sig' argument. Special case signals other than GDB_SIGNAL_TRAP. (explains_signal_watchpoint): New function. (base_breakpoint_explains_signal): Add 'sig' argument. (initialize_breakpoint_ops): Set 'explains_signal' method for watchpoints. * breakpoint.h (struct breakpoint_ops) <explains_signal>: Add signal argument. (bpstat_explains_signal): Likewise. * infrun.c (handle_syscall_event, handle_inferior_event): Update. * gdb.base/random-signal.c: New file. * gdb.base/random-signal.exp: New file.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index d4ccc81..f4933fc 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4153,7 +4153,7 @@ bpstat_find_breakpoint (bpstat bsp, struct breakpoint *breakpoint)
/* See breakpoint.h. */
enum bpstat_signal_value
-bpstat_explains_signal (bpstat bsp)
+bpstat_explains_signal (bpstat bsp, enum gdb_signal sig)
{
enum bpstat_signal_value result = BPSTAT_SIGNAL_NO;
@@ -4161,10 +4161,20 @@ bpstat_explains_signal (bpstat bsp)
{
/* Ensure that, if we ever entered this loop, then we at least
return BPSTAT_SIGNAL_HIDE. */
- enum bpstat_signal_value newval = BPSTAT_SIGNAL_HIDE;
+ enum bpstat_signal_value newval;
- if (bsp->breakpoint_at != NULL)
- newval = bsp->breakpoint_at->ops->explains_signal (bsp->breakpoint_at);
+ if (bsp->breakpoint_at == NULL)
+ {
+ /* A moribund location can never explain a signal other than
+ GDB_SIGNAL_TRAP. */
+ if (sig == GDB_SIGNAL_TRAP)
+ newval = BPSTAT_SIGNAL_HIDE;
+ else
+ newval = BPSTAT_SIGNAL_NO;
+ }
+ else
+ newval = bsp->breakpoint_at->ops->explains_signal (bsp->breakpoint_at,
+ sig);
if (newval > result)
result = newval;
@@ -10630,6 +10640,20 @@ print_recreate_watchpoint (struct breakpoint *b, struct ui_file *fp)
print_recreate_thread (b, fp);
}
+/* Implement the "explains_signal" breakpoint_ops method for
+ watchpoints. */
+
+static enum bpstat_signal_value
+explains_signal_watchpoint (struct breakpoint *b, enum gdb_signal sig)
+{
+ /* A software watchpoint cannot cause a signal other than
+ GDB_SIGNAL_TRAP. */
+ if (b->type == bp_watchpoint && sig != GDB_SIGNAL_TRAP)
+ return BPSTAT_SIGNAL_NO;
+
+ return BPSTAT_SIGNAL_HIDE;
+}
+
/* The breakpoint_ops structure to be used in hardware watchpoints. */
static struct breakpoint_ops watchpoint_breakpoint_ops;
@@ -12733,7 +12757,7 @@ base_breakpoint_decode_linespec (struct breakpoint *b, char **s,
/* The default 'explains_signal' method. */
static enum bpstat_signal_value
-base_breakpoint_explains_signal (struct breakpoint *b)
+base_breakpoint_explains_signal (struct breakpoint *b, enum gdb_signal sig)
{
return BPSTAT_SIGNAL_HIDE;
}
@@ -15743,6 +15767,7 @@ initialize_breakpoint_ops (void)
ops->print_it = print_it_watchpoint;
ops->print_mention = print_mention_watchpoint;
ops->print_recreate = print_recreate_watchpoint;
+ ops->explains_signal = explains_signal_watchpoint;
/* Masked watchpoints. */
ops = &masked_watchpoint_breakpoint_ops;