This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] Report the correct thread-specific breakpoint
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 1 Feb 2004 13:07:45 -0500
- Subject: [patch] Report the correct thread-specific breakpoint
While working on something else yesterday I stumbled on this.
bpstat_stop_status ignores any thread markers; thread-specific breakpoints
are handled completely in infrun. This mostly works but has the confusing
effect that GDB may print "switching to thread 1" and then "hit breakpoint
2" where breakpoint 2 is specific to a different thread. I suspect this
could cause problems with conditional thread-specific breakpoints also; we
might stop if the condition for some different thread were met.
Committed; testcase in the next message.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
2004-02-01 Daniel Jacobowitz <drow@mvista.com>
* breakpoint.c (bpstat_stop_status): Take a ptid_t argument,
and check the specified thread for each breakpoint.
* breakpoint.h (bpstat_stop_status): Update prototype.
* infrun.c (handle_inferior_event): Update calls to
bpstat_stop_status.
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.133
diff -u -p -r1.133 infrun.c
--- infrun.c 31 Jan 2004 19:59:06 -0000 1.133
+++ infrun.c 1 Feb 2004 17:55:20 -0000
@@ -1589,7 +1589,7 @@ handle_inferior_event (struct execution_
stop_pc = read_pc ();
- stop_bpstat = bpstat_stop_status (stop_pc);
+ stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
ecs->random_signal = !bpstat_explains_signal (stop_bpstat);
@@ -1638,7 +1638,7 @@ handle_inferior_event (struct execution_
ecs->saved_inferior_ptid = inferior_ptid;
inferior_ptid = ecs->ptid;
- stop_bpstat = bpstat_stop_status (stop_pc);
+ stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
ecs->random_signal = !bpstat_explains_signal (stop_bpstat);
inferior_ptid = ecs->saved_inferior_ptid;
@@ -2028,7 +2028,7 @@ handle_inferior_event (struct execution_
else
{
/* See if there is a breakpoint at the current PC. */
- stop_bpstat = bpstat_stop_status (stop_pc);
+ stop_bpstat = bpstat_stop_status (stop_pc, ecs->ptid);
/* Following in case break condition called a
function. */
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.155
diff -u -p -r1.155 breakpoint.c
--- breakpoint.c 31 Jan 2004 19:59:06 -0000 1.155
+++ breakpoint.c 1 Feb 2004 17:55:21 -0000
@@ -2588,7 +2588,7 @@ which its expression is valid.\n");
commands, FIXME??? fields. */
bpstat
-bpstat_stop_status (CORE_ADDR bp_addr)
+bpstat_stop_status (CORE_ADDR bp_addr, ptid_t ptid)
{
struct breakpoint *b, *temp;
/* True if we've hit a breakpoint (as opposed to a watchpoint). */
@@ -2597,6 +2597,7 @@ bpstat_stop_status (CORE_ADDR bp_addr)
struct bpstats root_bs[1];
/* Pointer to the last thing in the chain currently. */
bpstat bs = root_bs;
+ int thread_id = pid_to_thread_id (ptid);
ALL_BREAKPOINTS_SAFE (b, temp)
{
@@ -2845,6 +2846,12 @@ bpstat_stop_status (CORE_ADDR bp_addr)
free_all_values ();
}
if (b->cond && value_is_zero)
+ {
+ bs->stop = 0;
+ /* Don't consider this a hit. */
+ --(b->hit_count);
+ }
+ else if (b->thread != -1 && b->thread != thread_id)
{
bs->stop = 0;
/* Don't consider this a hit. */
Index: breakpoint.h
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.h,v
retrieving revision 1.29
diff -u -p -r1.29 breakpoint.h
--- breakpoint.h 31 Jan 2004 19:59:06 -0000 1.29
+++ breakpoint.h 1 Feb 2004 17:55:21 -0000
@@ -403,7 +403,7 @@ extern void bpstat_clear (bpstat *);
is part of the bpstat is copied as well. */
extern bpstat bpstat_copy (bpstat);
-extern bpstat bpstat_stop_status (CORE_ADDR pc);
+extern bpstat bpstat_stop_status (CORE_ADDR pc, ptid_t ptid);
/* This bpstat_what stuff tells wait_for_inferior what to do with a
breakpoint (a challenging task). */