This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[1/4] RFC:
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 19 Jan 2012 13:14:45 -0700
- Subject: [1/4] RFC:
This patch comes from:
http://sourceware.org/ml/gdb-patches/2011-09/msg00164.html
It is a nice cleanup that removes some code from infrun.
This patch differs from Pedro's original patch because I had to update
pc_at_non_inline_function as well.
Tom
2011-09-09 Pedro Alves <pedro@codesourcery.com>
gdb/
* breakpoint.c (bpstat_check_location, bpstat_stop_status,
pc_at_non_inline_function): Add `ws' parameter, and pass it down.
(breakpoint_hit_catch_fork, breakpoint_hit_catch_vfork)
(breakpoint_hit_catch_syscall, breakpoint_hit_catch_exec): Add
`ws' parameter.
(breakpoint_hit_ranged_breakpoint): Add `ws' parameter. Return
false for events other than TARGET_SIGNAL_TRAP.
(breakpoint_hit_watchpoint, base_breakpoint_breakpoint_hit):
Add `ws' parameter.
(bkpt_breakpoint_hit): Add `ws' parameter. Return false for
events other than TARGET_SIGNAL_TRAP.
(tracepoint_breakpoint_hit): Add `ws' parameter.
* breakpoint.h (struct breakpoint_ops) <breakpoint_hit>: Add `ws'
parameter.
(bpstat_stop_status): Same.
(pc_at_non_inline_function): Same.
* infrun.c (handle_syscall_event, handle_inferior_event): Adjust
to pass the current event's waitstatus to bpstat_stop_status
and pc_at_non_inline_function.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index f6a0276..1344d6d 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3824,14 +3824,15 @@ which its expression is valid.\n");
static int
bpstat_check_location (const struct bp_location *bl,
- struct address_space *aspace, CORE_ADDR bp_addr)
+ struct address_space *aspace, CORE_ADDR bp_addr,
+ const struct target_waitstatus *ws)
{
struct breakpoint *b = bl->owner;
/* BL is from an existing breakpoint. */
gdb_assert (b != NULL);
- return b->ops->breakpoint_hit (bl, aspace, bp_addr);
+ return b->ops->breakpoint_hit (bl, aspace, bp_addr, ws);
}
/* Determine if the watched values have actually changed, and we
@@ -4141,7 +4142,8 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
bpstat
bpstat_stop_status (struct address_space *aspace,
- CORE_ADDR bp_addr, ptid_t ptid)
+ CORE_ADDR bp_addr, ptid_t ptid,
+ const struct target_waitstatus *ws)
{
struct breakpoint *b = NULL;
struct bp_location *bl;
@@ -4179,7 +4181,7 @@ bpstat_stop_status (struct address_space *aspace,
if (bl->shlib_disabled)
continue;
- if (!bpstat_check_location (bl, aspace, bp_addr))
+ if (!bpstat_check_location (bl, aspace, bp_addr, ws))
continue;
/* Come here if it's a watchpoint, or if the break address
@@ -6230,7 +6232,8 @@ remove_catch_fork (struct bp_location *bl)
static int
breakpoint_hit_catch_fork (const struct bp_location *bl,
- struct address_space *aspace, CORE_ADDR bp_addr)
+ struct address_space *aspace, CORE_ADDR bp_addr,
+ const struct target_waitstatus *ws)
{
struct fork_catchpoint *c = (struct fork_catchpoint *) bl->owner;
@@ -6339,7 +6342,8 @@ remove_catch_vfork (struct bp_location *bl)
static int
breakpoint_hit_catch_vfork (const struct bp_location *bl,
- struct address_space *aspace, CORE_ADDR bp_addr)
+ struct address_space *aspace, CORE_ADDR bp_addr,
+ const struct target_waitstatus *ws)
{
struct fork_catchpoint *c = (struct fork_catchpoint *) bl->owner;
@@ -6543,7 +6547,8 @@ remove_catch_syscall (struct bp_location *bl)
static int
breakpoint_hit_catch_syscall (const struct bp_location *bl,
- struct address_space *aspace, CORE_ADDR bp_addr)
+ struct address_space *aspace, CORE_ADDR bp_addr,
+ const struct target_waitstatus *ws)
{
/* We must check if we are catching specific syscalls in this
breakpoint. If we are, then we must guarantee that the called
@@ -6855,7 +6860,8 @@ remove_catch_exec (struct bp_location *bl)
static int
breakpoint_hit_catch_exec (const struct bp_location *bl,
- struct address_space *aspace, CORE_ADDR bp_addr)
+ struct address_space *aspace, CORE_ADDR bp_addr,
+ const struct target_waitstatus *ws)
{
struct exec_catchpoint *c = (struct exec_catchpoint *) bl->owner;
@@ -8099,8 +8105,13 @@ stopat_command (char *arg, int from_tty)
static int
breakpoint_hit_ranged_breakpoint (const struct bp_location *bl,
struct address_space *aspace,
- CORE_ADDR bp_addr)
+ CORE_ADDR bp_addr,
+ const struct target_waitstatus *ws)
{
+ if (ws->kind != TARGET_WAITKIND_STOPPED
+ || ws->value.sig != TARGET_SIGNAL_TRAP)
+ return 0;
+
return breakpoint_address_match_range (bl->pspace->aspace, bl->address,
bl->length, aspace, bp_addr);
}
@@ -8567,7 +8578,8 @@ remove_watchpoint (struct bp_location *bl)
static int
breakpoint_hit_watchpoint (const struct bp_location *bl,
- struct address_space *aspace, CORE_ADDR bp_addr)
+ struct address_space *aspace, CORE_ADDR bp_addr,
+ const struct target_waitstatus *ws)
{
struct breakpoint *b = bl->owner;
struct watchpoint *w = (struct watchpoint *) b;
@@ -10826,7 +10838,8 @@ base_breakpoint_remove_location (struct bp_location *bl)
static int
base_breakpoint_breakpoint_hit (const struct bp_location *bl,
struct address_space *aspace,
- CORE_ADDR bp_addr)
+ CORE_ADDR bp_addr,
+ const struct target_waitstatus *ws)
{
internal_error_pure_virtual_called ();
}
@@ -10972,10 +10985,15 @@ bkpt_remove_location (struct bp_location *bl)
static int
bkpt_breakpoint_hit (const struct bp_location *bl,
- struct address_space *aspace, CORE_ADDR bp_addr)
+ struct address_space *aspace, CORE_ADDR bp_addr,
+ const struct target_waitstatus *ws)
{
struct breakpoint *b = bl->owner;
+ if (ws->kind != TARGET_WAITKIND_STOPPED
+ || ws->value.sig != TARGET_SIGNAL_TRAP)
+ return 0;
+
if (!breakpoint_address_match (bl->pspace->aspace, bl->address,
aspace, bp_addr))
return 0;
@@ -11267,7 +11285,8 @@ tracepoint_re_set (struct breakpoint *b)
static int
tracepoint_breakpoint_hit (const struct bp_location *bl,
- struct address_space *aspace, CORE_ADDR bp_addr)
+ struct address_space *aspace, CORE_ADDR bp_addr,
+ const struct target_waitstatus *ws)
{
/* By definition, the inferior does not report stops at
tracepoints. */
@@ -13622,7 +13641,8 @@ is_non_inline_function (struct breakpoint *b)
have been inlined. */
int
-pc_at_non_inline_function (struct address_space *aspace, CORE_ADDR pc)
+pc_at_non_inline_function (struct address_space *aspace, CORE_ADDR pc,
+ const struct target_waitstatus *ws)
{
struct breakpoint *b;
struct bp_location *bl;
@@ -13635,7 +13655,7 @@ pc_at_non_inline_function (struct address_space *aspace, CORE_ADDR pc)
for (bl = b->loc; bl != NULL; bl = bl->next)
{
if (!bl->shlib_disabled
- && bpstat_check_location (bl, aspace, pc))
+ && bpstat_check_location (bl, aspace, pc, ws))
return 1;
}
}
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 8a8d5f2..f1c2c52 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -440,7 +440,7 @@ struct breakpoint_ops
breakpoint location BL. This function does not check if we
should stop, only if BL explains the stop. */
int (*breakpoint_hit) (const struct bp_location *bl, struct address_space *,
- CORE_ADDR);
+ CORE_ADDR, const struct target_waitstatus *);
/* Check internal conditions of the breakpoint referred to by BS.
If we should not stop for this breakpoint, set BS->stop to 0. */
@@ -774,7 +774,8 @@ extern void bpstat_clear (bpstat *);
extern bpstat bpstat_copy (bpstat);
extern bpstat bpstat_stop_status (struct address_space *aspace,
- CORE_ADDR pc, ptid_t ptid);
+ CORE_ADDR pc, ptid_t ptid,
+ const struct target_waitstatus *ws);
/* This bpstat_what stuff tells wait_for_inferior what to do with a
breakpoint (a challenging task).
@@ -1405,7 +1406,8 @@ extern struct breakpoint *iterate_over_breakpoints (int (*) (struct breakpoint *
have been inlined. */
extern int pc_at_non_inline_function (struct address_space *aspace,
- CORE_ADDR pc);
+ CORE_ADDR pc,
+ const struct target_waitstatus *ws);
extern int user_breakpoint_p (struct breakpoint *);
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 24d2720..4b7422f 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -3086,7 +3086,7 @@ handle_syscall_event (struct execution_control_state *ecs)
ecs->event_thread->control.stop_bpstat
= bpstat_stop_status (get_regcache_aspace (regcache),
- stop_pc, ecs->ptid);
+ stop_pc, ecs->ptid, &ecs->ws);
ecs->random_signal
= !bpstat_explains_signal (ecs->event_thread->control.stop_bpstat);
@@ -3537,7 +3537,7 @@ handle_inferior_event (struct execution_control_state *ecs)
ecs->event_thread->control.stop_bpstat
= bpstat_stop_status (get_regcache_aspace (get_current_regcache ()),
- stop_pc, ecs->ptid);
+ stop_pc, ecs->ptid, &ecs->ws);
/* Note that we're interested in knowing the bpstat actually
causes a stop, not just if it may explain the signal.
@@ -3635,7 +3635,7 @@ handle_inferior_event (struct execution_control_state *ecs)
ecs->event_thread->control.stop_bpstat
= bpstat_stop_status (get_regcache_aspace (get_current_regcache ()),
- stop_pc, ecs->ptid);
+ stop_pc, ecs->ptid, &ecs->ws);
ecs->random_signal
= !bpstat_explains_signal (ecs->event_thread->control.stop_bpstat);
@@ -4094,11 +4094,12 @@ handle_inferior_event (struct execution_control_state *ecs)
user had set a breakpoint on that inlined code, the missing
skip_inline_frames call would break things. Fortunately
that's an extremely unlikely scenario. */
- if (!pc_at_non_inline_function (aspace, stop_pc)
+ if (!pc_at_non_inline_function (aspace, stop_pc, &ecs->ws)
&& !(ecs->event_thread->suspend.stop_signal == TARGET_SIGNAL_TRAP
&& ecs->event_thread->control.trap_expected
&& pc_at_non_inline_function (aspace,
- ecs->event_thread->prev_pc)))
+ ecs->event_thread->prev_pc,
+ &ecs->ws)))
skip_inline_frames (ecs->ptid);
}
@@ -4200,10 +4201,11 @@ handle_inferior_event (struct execution_control_state *ecs)
return;
}
- /* See if there is a breakpoint at the current PC. */
+ /* See if there is a breakpoint/watchpoint/catchpoint/etc. that
+ handles this signal. */
ecs->event_thread->control.stop_bpstat
= bpstat_stop_status (get_regcache_aspace (get_current_regcache ()),
- stop_pc, ecs->ptid);
+ stop_pc, ecs->ptid, &ecs->ws);
/* Following in case break condition called a
function. */
--
1.7.6.5