From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20689 invoked by alias); 8 Jan 2010 09:58:18 -0000 Received: (qmail 20676 invoked by uid 22791); 8 Jan 2010 09:58:16 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_00,SPF_SOFTFAIL X-Spam-Check-By: sourceware.org Received: from mtaout23.012.net.il (HELO mtaout23.012.net.il) (80.179.55.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Jan 2010 09:58:08 +0000 Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0KVX00400A3HWF00@a-mtaout23.012.net.il> for gdb-patches@sourceware.org; Fri, 08 Jan 2010 11:58:05 +0200 (IST) Received: from HOME-C4E4A596F7 ([77.127.222.44]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0KVX0025LACT7JJ0@a-mtaout23.012.net.il>; Fri, 08 Jan 2010 11:58:05 +0200 (IST) Date: Fri, 08 Jan 2010 09:58:00 -0000 From: Eli Zaretskii Subject: Re: [RFC] Wrong hw_watchpoint_used_count? (multiple location watchpoints) In-reply-to: <20100108075701.GE4589@adacore.com> To: Joel Brobecker Cc: gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83fx6gc43p.fsf@gnu.org> References: <20100108075701.GE4589@adacore.com> X-IsSubscribed: yes 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/msg00159.txt.bz2 > Date: Fri, 8 Jan 2010 11:57:01 +0400 > From: Joel Brobecker > > 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... But this is something only the target knows. There's no way for breakpoint.c to know that, unless we introduce an API through which breakpoint.c can ask the target to provide that number. Please note, for example, that some watchpoints can actually need *zero* bp_locations, because some other watchpoint already watches the same address. x86 uses reference counting to not waste hardware resources for the same address.