public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/8] cleanup and speed up (software_)breakpoint_inserted_here_p
Date: Fri, 26 Dec 2014 20:31:00 -0000	[thread overview]
Message-ID: <1419625871-28848-4-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1419625871-28848-1-git-send-email-palves@redhat.com>

Factor out common code, and use the more efficient
ALL_BP_LOCATIONS_AT_ADDR.

gdb/
2014-12-26  Pedro Alves  <palves@redhat.com>

	* breakpoint.c (bp_location_inserted_here_p): New function,
	factored out from ...
	(breakpoint_inserted_here_p): ... here.  Use
	ALL_BP_LOCATIONS_AT_ADDR.
	(software_breakpoint_inserted_here_p): Use
	bp_location_inserted_here_p and ALL_BP_LOCATIONS_AT_ADDR.
---
 gdb/breakpoint.c | 60 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 35 insertions(+), 25 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8ccaf43..99b9190 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4226,29 +4226,45 @@ moribund_breakpoint_here_p (struct address_space *aspace, CORE_ADDR pc)
   return 0;
 }
 
+/* Returns non-zero iff BL is inserted at PC, in address space
+   ASPACE.  */
+
+static int
+bp_location_inserted_here_p (struct bp_location *bl,
+			     struct address_space *aspace, CORE_ADDR pc)
+{
+  if (bl->inserted
+      && breakpoint_address_match (bl->pspace->aspace, bl->address,
+				   aspace, pc))
+    {
+      if (overlay_debugging
+	  && section_is_overlay (bl->section)
+	  && !section_is_mapped (bl->section))
+	return 0;		/* unmapped overlay -- can't be a match */
+      else
+	return 1;
+    }
+  return 0;
+}
+
 /* Returns non-zero iff there's a breakpoint inserted at PC.  */
 
 int
 breakpoint_inserted_here_p (struct address_space *aspace, CORE_ADDR pc)
 {
-  struct bp_location *bl, **blp_tmp;
+  struct bp_location **blp, **blp_tmp = NULL;
+  struct bp_location *bl;
 
-  ALL_BP_LOCATIONS (bl, blp_tmp)
+  ALL_BP_LOCATIONS_AT_ADDR (blp, blp_tmp, pc)
     {
+      struct bp_location *bl = *blp;
+
       if (bl->loc_type != bp_loc_software_breakpoint
 	  && bl->loc_type != bp_loc_hardware_breakpoint)
 	continue;
 
-      if (bl->inserted
-	  && breakpoint_location_address_match (bl, aspace, pc))
-	{
-	  if (overlay_debugging 
-	      && section_is_overlay (bl->section)
-	      && !section_is_mapped (bl->section))
-	    continue;		/* unmapped overlay -- can't be a match */
-	  else
-	    return 1;
-	}
+      if (bp_location_inserted_here_p (bl, aspace, pc))
+	return 1;
     }
   return 0;
 }
@@ -4260,24 +4276,18 @@ int
 software_breakpoint_inserted_here_p (struct address_space *aspace,
 				     CORE_ADDR pc)
 {
-  struct bp_location *bl, **blp_tmp;
+  struct bp_location **blp, **blp_tmp = NULL;
+  struct bp_location *bl;
 
-  ALL_BP_LOCATIONS (bl, blp_tmp)
+  ALL_BP_LOCATIONS_AT_ADDR (blp, blp_tmp, pc)
     {
+      struct bp_location *bl = *blp;
+
       if (bl->loc_type != bp_loc_software_breakpoint)
 	continue;
 
-      if (bl->inserted
-	  && breakpoint_address_match (bl->pspace->aspace, bl->address,
-				       aspace, pc))
-	{
-	  if (overlay_debugging 
-	      && section_is_overlay (bl->section)
-	      && !section_is_mapped (bl->section))
-	    continue;		/* unmapped overlay -- can't be a match */
-	  else
-	    return 1;
-	}
+      if (bp_location_inserted_here_p (bl, aspace, pc))
+	return 1;
     }
 
   return 0;
-- 
1.9.3

  reply	other threads:[~2014-12-26 20:31 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-26 20:31 [PATCH 0/8] Linux: starvation avoidance in non-stop mode Pedro Alves
2014-12-26 20:31 ` Pedro Alves [this message]
2014-12-26 20:31 ` [PATCH 2/8] watch_thread_num.exp and targets with fairer event reporting Pedro Alves
2014-12-26 20:31 ` [PATCH 1/8] gdb.threads/{siginfo-thread.c,watchthreads-reorder.c,ia64-sigill.c} races with GDB Pedro Alves
2015-01-06  6:20   ` Yao Qi
2014-12-26 20:32 ` [PATCH 6/8] linux-nat.c: better starvation avoidance, handle non-stop mode too Pedro Alves
2015-01-07  7:06   ` Yao Qi
2015-01-07 13:22     ` Pedro Alves
2015-01-07 14:08       ` Yao Qi
2015-01-07 14:36         ` Pedro Alves
2014-12-26 20:32 ` [PATCH 8/8] add non-stop test that stresses thread starvation issues Pedro Alves
2015-04-02 14:53   ` Yao Qi
2015-04-06 11:26     ` Pedro Alves
2015-04-07 10:10       ` Yao Qi
2015-04-07 10:22         ` Pedro Alves
2015-04-07 10:31           ` Yao Qi
2014-12-26 20:32 ` [PATCH 5/8] linux-nat.c: always mark execing LWP as resumed Pedro Alves
2014-12-26 20:32 ` [PATCH 4/8] linux-nat.c: clean up pending status checking and resuming LWPs Pedro Alves
2015-01-06  8:12   ` Yao Qi
2015-01-07 13:22     ` Pedro Alves
2015-01-07 14:10       ` Yao Qi
2014-12-26 20:32 ` [PATCH 7/8] [gdbserver] linux-low.c: better starvation avoidance, handle non-stop mode too Pedro Alves
2015-01-09 15:07 ` [PATCH 0/8] Linux: starvation avoidance in non-stop mode Pedro Alves

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=1419625871-28848-4-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).