From patchwork Fri Dec 26 20:31:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 4428 Received: (qmail 31798 invoked by alias); 26 Dec 2014 20:31:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 31716 invoked by uid 89); 26 Dec 2014 20:31:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 26 Dec 2014 20:31:48 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBQKVl1V015505 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 26 Dec 2014 15:31:47 -0500 Received: from brno.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBQKVG2q011395 for ; Fri, 26 Dec 2014 15:31:43 -0500 From: Pedro Alves 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:06 +0000 Message-Id: <1419625871-28848-4-git-send-email-palves@redhat.com> In-Reply-To: <1419625871-28848-1-git-send-email-palves@redhat.com> References: <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 * 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;