From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4083 invoked by alias); 8 Jan 2010 07:57:18 -0000 Received: (qmail 4070 invoked by uid 22791); 8 Jan 2010 07:57:17 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Jan 2010 07:57:12 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 50F272BABA2 for ; Fri, 8 Jan 2010 02:57:10 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id QNjTZxQ2oE-w for ; Fri, 8 Jan 2010 02:57:10 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id BFABA2BAB22 for ; Fri, 8 Jan 2010 02:57:09 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 48D5BF595E; Fri, 8 Jan 2010 11:57:01 +0400 (RET) Date: Fri, 08 Jan 2010 07:57:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [RFC] Wrong hw_watchpoint_used_count? (multiple location watchpoints) Message-ID: <20100108075701.GE4589@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="LQksG6bCIzRHxTLp" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00157.txt.bz2 --LQksG6bCIzRHxTLp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1420 This is mostly from code inspection, while investigating something else, but I think that the current implementation of hw_watchpoint_used_count is inaccurate. It counts the number of breakpoints which match the given type. But in fact, when I looked at the way the watchpoint is created, watchpoints may have multiple bp_locations. So, a better approximation would be to count the number of bp_locations, no? Even so, this does not appear to be entirely accurate either. For instance, if the user tries to watch an entity that does not fit in one watchpoint, I think we can still end up with a situation where we have one bp_location needing 2 h/w watchpoints. In the end, it looks like the only way to really clean things up would be to store for each watchpoint the associated number of needed hardware watchpoints... I thought about making the following change. It's not clear that it is a step in the right direction or not. Pragmatically, I think it gives more accurate results. In terms of implementation, if we eventually decide to store the mem_cnt in the breakpoint, then we'll have to go back to iterating over all breakpoints (not bp_locations)... When in doubt, do nothing? * breakpoint.c (hw_watchpoint_used_count): Compute the number of hardware watchpoints by iterating over all bp_locations instead of all breakpoints. Tested on x86_64-linux. No regression... -- Joel --LQksG6bCIzRHxTLp Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Wrong-hw_watchpoint_used_count-multiple-location-wat.patch" Content-length: 1051 >From 6b81fca8153717a836ecee2d4e7ce891b3d32a6e Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Tue, 29 Dec 2009 19:06:50 +0400 Subject: [PATCH] Wrong hw_watchpoint_used_count? (multiple location watchpoints) * breakpoint.c (hw_watchpoint_used_count): Compute the number of hardware watchpoints by iterating over all bp_locations instead of all breakpoints. --- gdb/breakpoint.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 0dc8474..91587cb 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5820,12 +5820,14 @@ hw_breakpoint_used_count (void) static int hw_watchpoint_used_count (enum bptype type, int *other_type_used) { - struct breakpoint *b; + struct bp_location *loc, **loc_temp; int i = 0; *other_type_used = 0; - ALL_BREAKPOINTS (b) + ALL_BP_LOCATIONS (loc, loc_temp) { + struct breakpoint *b = loc->owner; + if (breakpoint_enabled (b)) { if (b->type == type) -- 1.6.3.3 --LQksG6bCIzRHxTLp--