This is the mail archive of the
mailing list for the GDB project.
[PATCH] Don't evaluate condition for non-matching thread
- From: Doug Evans <xdje42 at gmail dot com>
- To: Pedro Alves <palves at redhat dot com>, gdb-patches at sourceware dot org
- Date: Tue, 12 Nov 2013 19:01:41 -0800
- Subject: [PATCH] Don't evaluate condition for non-matching thread
- Authentication-results: sourceware.org; auth=none
- References: <m3zjpap8m1 dot fsf at seba dot sebabeach dot org> <5281F6DB dot 2010603 at redhat dot com>
Pedro Alves <email@example.com> writes:
> On 11/12/2013 04:05 AM, Doug Evans wrote:
>> This patch simplifies bpstat_check_breakpoint_conditions a bit.
>> Regression tested on amd64-linux.
>> Ok to check in?
> Looks good to me.
Is there a reason the current code is the way it is?
Evaluating breakpoint conditions is expensive,
and to do so for a thread-specific breakpoint on a non-matching
thread is an awful waste.
I read the thread-specific breakpoints section of the docs
and didn't find anything.
Regression tested on amd64-linux,
but no claim is made that I'm sure there isn't some gotcha
for why things are the way they are (including "Oops, but it's in the
wild now and reason X means we can't change it." :-)).
Thank goodness the ignore_count check is done after the thread-id check
so there's no change w.r.t. ignore counts.
[I realize conditions can have side-effects, to, e.g., collect data,
but the user has made the breakpoint thread-specific already.]
If you think this warrants a NEWS entry I can certainly add one.
Ok to check in?
2013-11-12 Doug Evans <firstname.lastname@example.org>
* breakpoint.c (bpstat_check_breakpoint_conditions): For thread
specific breakpoints, don't evaluate breakpoint condition if
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 36252ee..ebb8336 100644
@@ -5132,6 +5132,14 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
+ /* If this is a thread-specific breakpoint, don't waste cpu evaluating the
+ condition if this isn't the specified thread. */
+ if (b->thread != -1 && b->thread != thread_id)
+ bs->stop = 0;
/* Evaluate Python breakpoints that have a "stop" method implemented. */
bs->stop = gdbpy_should_stop (b->py_bp_object);
@@ -5215,10 +5223,6 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
bs->stop = 0;
- else if (b->thread != -1 && b->thread != thread_id)
- bs->stop = 0;
else if (b->ignore_count > 0)