This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Don't evaluate condition for non-matching thread


Pedro Alves <palves@redhat.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.

Thanks.
Next patch.

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  <xdje42@gmail.com>

	* breakpoint.c (bpstat_check_breakpoint_conditions): For thread
	specific breakpoints, don't evaluate breakpoint condition if
	different thread.

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 36252ee..ebb8336 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5132,6 +5132,14 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
       return;
     }
 
+  /* 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;
+      return;
+    }
+
   /* Evaluate Python breakpoints that have a "stop" method implemented.  */
   if (b->py_bp_object)
     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)
     {
       b->ignore_count--;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]