Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA/commit] Minor cleanup in breakpoint_thread_match
Date: Wed, 25 Mar 2009 22:12:00 -0000	[thread overview]
Message-ID: <20090325221141.GG9472@adacore.com> (raw)
In-Reply-To: <200903251811.35835.pedro@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 372 bytes --]

> > > 2009-03-25  Joel Brobecker  <brobecker@adacore.com>
> > > 
> > >         * breakpoint.c (breakpoint_thread_match): Split a large condition
> > >         into several smaller conditions.  No behavior change.
> > > 
> Looks sane to me.

Thanks, much, Pedro. Here is what I ended checking in. It's identical
to the above, except for some whitespace screwups.

-- 
Joel

[-- Attachment #2: cleanup.diff --]
[-- Type: text/x-diff, Size: 1621 bytes --]

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 7e50342..7ffdf77 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1893,28 +1893,39 @@ int
 breakpoint_thread_match (CORE_ADDR pc, ptid_t ptid)
 {
   const struct bp_location *bpt;
-  int thread;
-
-  thread = pid_to_thread_id (ptid);
-
+  /* The thread ID associated to PTID, computed lazily.  */
+  int thread = -1;
+  
   ALL_BP_LOCATIONS (bpt)
     {
       if (bpt->loc_type != bp_loc_software_breakpoint
 	  && bpt->loc_type != bp_loc_hardware_breakpoint)
 	continue;
 
-      if ((breakpoint_enabled (bpt->owner)
-	   || bpt->owner->enable_state == bp_permanent)
-	  && bpt->address == pc
-	  && (bpt->owner->thread == -1 || bpt->owner->thread == thread))
+      if (!breakpoint_enabled (bpt->owner)
+	  && bpt->owner->enable_state != bp_permanent)
+	continue;
+
+      if (bpt->address != pc)
+	continue;
+
+      if (bpt->owner->thread != -1)
 	{
-	  if (overlay_debugging 
-	      && section_is_overlay (bpt->section) 
-	      && !section_is_mapped (bpt->section))
-	    continue;		/* unmapped overlay -- can't be a match */
-	  else
-	    return 1;
+	  /* This is a thread-specific breakpoint.  Check that ptid
+	     matches that thread.  If thread hasn't been computed yet,
+	     it is now time to do so.  */
+	  if (thread == -1)
+	    thread = pid_to_thread_id (ptid);
+	  if (bpt->owner->thread != thread)
+	    continue;
 	}
+
+      if (overlay_debugging 
+	  && section_is_overlay (bpt->section) 
+	  && !section_is_mapped (bpt->section))
+	continue;	    /* unmapped overlay -- can't be a match */
+
+      return 1;
     }
 
   return 0;

      reply	other threads:[~2009-03-25 22:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-25 18:00 Joel Brobecker
2009-03-25 18:12 ` Joel Brobecker
2009-03-25 19:25   ` Pedro Alves
2009-03-25 22:12     ` Joel Brobecker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090325221141.GG9472@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox