From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29337 invoked by alias); 13 Sep 2011 15:23:06 -0000 Received: (qmail 29328 invoked by uid 22791); 13 Sep 2011 15:23:05 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate1.uk.ibm.com (HELO mtagate1.uk.ibm.com) (194.196.100.161) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 13 Sep 2011 15:22:47 +0000 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate1.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p8DFMjdg011632 for ; Tue, 13 Sep 2011 15:22:45 GMT Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8DFMjxG2019506 for ; Tue, 13 Sep 2011 16:22:45 +0100 Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8DFMhkK032690 for ; Tue, 13 Sep 2011 09:22:43 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id p8DFMg93032568; Tue, 13 Sep 2011 09:22:42 -0600 Message-Id: <201109131522.p8DFMg93032568@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Tue, 13 Sep 2011 17:22:42 +0200 Subject: Re: Watchpoint resource accounting broken (Re: [5/6] breakpoints_ops for all kinds of breakpoints: new watchpoints instance type To: pedro@codesourcery.com (Pedro Alves) Date: Tue, 13 Sep 2011 16:49:00 -0000 From: "Ulrich Weigand" Cc: emachado@linux.vnet.ibm.com (Edjunior Barbosa Machado), gdb-patches@sourceware.org In-Reply-To: <201109131355.11485.pedro@codesourcery.com> from "Pedro Alves" at Sep 13, 2011 01:55:11 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: 2011-09/txt/msg00215.txt.bz2 Pedro Alves wrote: > Does the patch below work? Never consider the current watchpoint when > going over the breakpoint list counting resources, and then > add the resources of the current watchpoint on top. This way we > don't have to care of the current watchpoint being on the list yet or > not. As bonus, we no longer have to frog the watchpoint's type before > knowing if it'll fit. Yes, this patch looks good to me, and does fix the problem I've been seeing. Thanks! > On Monday 12 September 2011 16:16:53, Edjunior Barbosa Machado wrote: > > I noticed this problem too and was considering use "i + reg_cnt" instead > > of only "i" when calling hw_watchpoint_used_count() (actually, I saw gdb > > used to use this previously). > > However, with this change, due to the same problem with the watchpoint > > added to breakpoint list that Ulrich mentioned, watchpoints added before > > run the inferior will not work. > > Can you expand on this? I don't think I'm understanding that problem. In addition to what Edjunior replied, this reminds me that there is now some unnecessary code duplication in the can_use_hardware_watchpoint routine: reg_cnt = can_use_hardware_watchpoint (val_chain); [snip] /* Add in the resources needed for B. */ i += hw_watchpoint_use_count (&b->base); The return value of this hw_watchpoint_use_count call ought to be always equal to reg_cnt; and in fact the whole logic in can_use_hardware_watchpoint ought to be redundant with what update_watchpoint does anyway. However, this is not completely true: 1. can_use_hardware_watchpoint respects the can_use_hw_watchpoints flag 2. can_use_hardware_watchpoint takes note of sub-expressions that cannot be implemented via HW watchpoints (e.g. lval_register) [ -- this seems to be incomplete anyway these days ] It seems to me that it would be preferable to integrate these missing checks into the code in update_watchpoint, and then remove the can_use_hardware_watchpoint routine ... [ But that's clearly a follow-on cleanup, and shouldn't prevent your bug-fix patch from going in now. ] Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com