This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH 5/7] Eliminate enum bpstat_signal_value, simplify random signal checks further.
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 31 Oct 2013 21:32:03 +0000
- Subject: [PATCH 5/7] Eliminate enum bpstat_signal_value, simplify random signal checks further.
- Authentication-results: sourceware.org; auth=none
- References: <1383255125-9977-1-git-send-email-palves at redhat dot com>
After the previous patch, there's actually no breakpoint type that
returns BPSTAT_SIGNAL_HIDE, so we can go back to having
bpstat_explains_signal return a boolean. The signal hiding actually
disappears.
gdb/
2013-10-31 Pedro Alves <palves@redhat.com>
* break-catch-sig.c (signal_catchpoint_explains_signal): Adjust to
return a boolean.
* breakpoint.c (bpstat_explains_signal): Adjust to return a
boolean.
(explains_signal_watchpoint, base_breakpoint_explains_signal):
Adjust to return a boolean.
* breakpoint.h (enum bpstat_signal_value): Delete.
(struct breakpoint_ops) <explains_signal>: New returns a boolean.
(bpstat_explains_signal): Likewise.
* infrun.c (handle_inferior_event) <random signal checks>:
bpstat_explains_signal now returns a boolean - adjust. No longer
consider hiding signals.
---
gdb/break-catch-sig.c | 4 ++--
gdb/breakpoint.c | 34 +++++++++++++---------------------
gdb/breakpoint.h | 32 ++++++--------------------------
gdb/infrun.c | 13 ++++---------
4 files changed, 25 insertions(+), 58 deletions(-)
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index 02d8b4a..c82984a 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -350,10 +350,10 @@ signal_catchpoint_print_recreate (struct breakpoint *b, struct ui_file *fp)
/* Implement the "explains_signal" breakpoint_ops method for signal
catchpoints. */
-static enum bpstat_signal_value
+static int
signal_catchpoint_explains_signal (struct breakpoint *b, enum gdb_signal sig)
{
- return BPSTAT_SIGNAL_PASS;
+ return 1;
}
/* Create a new signal catchpoint. TEMPFLAG is true if this should be
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index c506fc0..ab5f26c 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4221,35 +4221,27 @@ bpstat_find_breakpoint (bpstat bsp, struct breakpoint *breakpoint)
/* See breakpoint.h. */
-enum bpstat_signal_value
+int
bpstat_explains_signal (bpstat bsp, enum gdb_signal sig)
{
- enum bpstat_signal_value result = BPSTAT_SIGNAL_NO;
-
for (; bsp != NULL; bsp = bsp->next)
{
- /* Ensure that, if we ever entered this loop, then we at least
- return BPSTAT_SIGNAL_HIDE. */
- enum bpstat_signal_value newval;
-
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_PASS;
- else
- newval = BPSTAT_SIGNAL_NO;
+ return 1;
}
else
- newval = bsp->breakpoint_at->ops->explains_signal (bsp->breakpoint_at,
- sig);
-
- if (newval > result)
- result = newval;
+ {
+ if (bsp->breakpoint_at->ops->explains_signal (bsp->breakpoint_at,
+ sig))
+ return 1;
+ }
}
- return result;
+ return 0;
}
/* Put in *NUM the breakpoint number of the first breakpoint we are
@@ -10763,15 +10755,15 @@ print_recreate_watchpoint (struct breakpoint *b, struct ui_file *fp)
/* Implement the "explains_signal" breakpoint_ops method for
watchpoints. */
-static enum bpstat_signal_value
+static int
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 0;
- return BPSTAT_SIGNAL_PASS;
+ return 1;
}
/* The breakpoint_ops structure to be used in hardware watchpoints. */
@@ -12879,10 +12871,10 @@ base_breakpoint_decode_linespec (struct breakpoint *b, char **s,
/* The default 'explains_signal' method. */
-static enum bpstat_signal_value
+static int
base_breakpoint_explains_signal (struct breakpoint *b, enum gdb_signal sig)
{
- return BPSTAT_SIGNAL_PASS;
+ return 1;
}
/* The default "after_condition_true" method. */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 4a25fb7..b2ff02c 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -470,22 +470,6 @@ struct bp_location
struct symtab *symtab;
};
-/* Return values for bpstat_explains_signal. Note that the order of
- the constants is important here; they are compared directly in
- bpstat_explains_signal. */
-
-enum bpstat_signal_value
- {
- /* bpstat does not explain this signal. */
- BPSTAT_SIGNAL_NO = 0,
-
- /* bpstat explains this signal; signal should not be delivered. */
- BPSTAT_SIGNAL_HIDE,
-
- /* bpstat explains this signal; signal should be delivered. */
- BPSTAT_SIGNAL_PASS
- };
-
/* This structure is a collection of function pointers that, if available,
will be called instead of the performing the default action for this
bptype. */
@@ -600,12 +584,9 @@ struct breakpoint_ops
void (*decode_linespec) (struct breakpoint *, char **,
struct symtabs_and_lines *);
- /* Return true if this breakpoint explains a signal, but the signal
- should still be delivered to the inferior. This is used to make
- 'catch signal' interact properly with 'handle'; see
+ /* Return true if this breakpoint explains a signal. See
bpstat_explains_signal. */
- enum bpstat_signal_value (*explains_signal) (struct breakpoint *,
- enum gdb_signal);
+ int (*explains_signal) (struct breakpoint *, enum gdb_signal);
/* Called after evaluating the breakpoint's condition,
and only if it evaluated true. */
@@ -1002,11 +983,10 @@ struct bpstat_what bpstat_what (bpstat);
/* Find the bpstat associated with a breakpoint. NULL otherwise. */
bpstat bpstat_find_breakpoint (bpstat, struct breakpoint *);
-/* Nonzero if a signal that we got in wait() was due to circumstances
- explained by the bpstat; and the signal should therefore not be
- delivered. */
-extern enum bpstat_signal_value bpstat_explains_signal (bpstat,
- enum gdb_signal);
+/* Nonzero if a signal that we got in target_wait() was due to
+ circumstances explained by the bpstat; the signal is therefore not
+ random. */
+extern int bpstat_explains_signal (bpstat, enum gdb_signal);
/* Nonzero is this bpstat causes a stop. */
extern int bpstat_causes_stop (bpstat);
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 8eb2ddd..4d26e37 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3154,7 +3154,6 @@ handle_inferior_event (struct execution_control_state *ecs)
int stepped_after_stopped_by_watchpoint = 0;
enum stop_kind stop_soon;
int random_signal;
- enum bpstat_signal_value sval;
if (ecs->ws.kind == TARGET_WAITKIND_IGNORE)
{
@@ -4226,9 +4225,8 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
if (debug_infrun
&& ecs->event_thread->suspend.stop_signal == GDB_SIGNAL_TRAP
- && (bpstat_explains_signal (ecs->event_thread->control.stop_bpstat,
+ && !bpstat_explains_signal (ecs->event_thread->control.stop_bpstat,
GDB_SIGNAL_TRAP)
- == BPSTAT_SIGNAL_NO)
&& stopped_by_watchpoint)
fprintf_unfiltered (gdb_stdlog,
"infrun: no user watchpoint explains "
@@ -4255,9 +4253,9 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
SPARC. */
/* See if the breakpoints module can explain the signal. */
- sval = bpstat_explains_signal (ecs->event_thread->control.stop_bpstat,
- ecs->event_thread->suspend.stop_signal);
- random_signal = (sval == BPSTAT_SIGNAL_NO);
+ random_signal
+ = !bpstat_explains_signal (ecs->event_thread->control.stop_bpstat,
+ ecs->event_thread->suspend.stop_signal);
/* If not, perhaps stepping/nexting can. */
if (random_signal)
@@ -4268,9 +4266,6 @@ Cannot fill $_exitsignal with the correct signal number.\n"));
if (random_signal)
random_signal = !stopped_by_watchpoint;
- if (sval == BPSTAT_SIGNAL_HIDE)
- ecs->event_thread->suspend.stop_signal = GDB_SIGNAL_0;
-
/* For the program's own signals, act according to
the signal handling tables. */
--
1.7.11.7