From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21225 invoked by alias); 31 Mar 2005 02:32:13 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 21063 invoked from network); 31 Mar 2005 02:31:54 -0000 Received: from unknown (HELO nevyn.them.org) (66.93.172.17) by sourceware.org with SMTP; 31 Mar 2005 02:31:54 -0000 Received: from drow by nevyn.them.org with local (Exim 4.50 #1 (Debian)) id 1DGpUZ-0002SG-VM; Wed, 30 Mar 2005 21:33:08 -0500 Date: Thu, 31 Mar 2005 02:32:00 -0000 From: Daniel Jacobowitz To: Eli Zaretskii Cc: GDB Subject: Re: [mi] watchpoint-scope exec async command Message-ID: <20050331023307.GA8637@nevyn.them.org> Mail-Followup-To: Eli Zaretskii , GDB References: <20050328224101.GA629@nevyn.them.org> <20050328235310.GA3699@white> <20050328230048.GA1697@nevyn.them.org> <20050329014203.GB3801@white> <20050329013634.GB6373@nevyn.them.org> <20050329024945.GC3957@white> <20050329020123.GA7266@nevyn.them.org> <01c534a6$Blat.v2.4$944e44a0@zahav.net.il> <20050329214414.GA3498@nevyn.them.org> <01c53564$Blat.v2.4$1da3c140@zahav.net.il> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01c53564$Blat.v2.4$1da3c140@zahav.net.il> User-Agent: Mutt/1.5.6+20040907i X-SW-Source: 2005-03/txt/msg00307.txt.bz2 On Wed, Mar 30, 2005 at 10:06:33PM +0200, Eli Zaretskii wrote: > > Date: Tue, 29 Mar 2005 16:44:14 -0500 > > From: Daniel Jacobowitz > > Cc: GDB > > > > If the scope breakpoint triggers, we delete it. From watch_command_1: > > /* Automatically delete the breakpoint when it hits. */ > > scope_breakpoint->disposition = disp_del; > > > > That's what's happening in this case. Then, shortly thereafter, the > > watchpoint triggers. That's when we detect that it has gone out of > > scope, and set it to delete at next stop; and we crash, because we > > already deleted the scope breakpoint when it was hit. > > I hoped to see this from Bob's tracebacks, but I only saw the first > part of what you describe: that the scope breakpoint is being deleted > after it triggers (not _when_, _after_: it is deleted by > breakpoint_auto_delete). Immediately after, though. We're in the first loop in breakpoint_auto_delete, for breakpoints in the current bpstate. > Assuming that the watchpoint triggers after that, it is marked as > disp_del_at_next_stop, so it would be slated for deletion by the same > breakpoint_auto_delete function when it is called shortly after. This > is the part that I didn't see in Bob's session. I will assume that > things indeed happen like you say: that when we try to delete that > watchpoint, we crash when we access its scope breakpoint, which was > already deleted and freed. No, we're crashing earlier than that. This was in one of Bob's earlier messages; we crash here: 1021 if (bpt->owner->related_breakpoint) 1022 bpt->owner->related_breakpoint->disposition = disp_del_at_next_stop; 1023 bpt->owner->disposition = disp_del_at_next_stop; Since the related breakpoint has already been freed... well, accessing it isn't so clever. > I think we have the following alternatives to fix this. First, we > could stop using scope breakpoints for hardware-assisted watchpoints. > (The scope breakpoint is not needed in this case, since they don't > slow down the executable, and because we have an independent facility > to detect that a hardware watchpoint went out of scope: that is the > code run by insert_bp_location and watchpoint_check which prints a > warning about the fact that the watchpoint went out of scope.) > Software watchpoints do need the scope breakpoint (to stop > single-stepping the inferior once the watchpoint goes out of scope), > and in that case Bob's testing demonstrates that the scope breakpoint > machinery works correctly. So we need to continue using scope > breakpoints for software watchpoints alone. > > If we don't arrange a scope breakpoint for a hardware watchpoint, we > won't hit the problem Bob reported. I think this would be pretty tricky. We would have to recognize that if the next thing to trigger is the watchpoint, it doesn't "count". There's machinery for this, but it's pretty tricky. > The second alternative is to treat scope breakpoints specially in > breakpoint_auto_delete: when we see a scope breakpoint that is marked > for deletion, we will have to find its watchpoint, and if that > watchpoint is a hardware watchpoint, we will have to delete that > watchpoint as well. > > I like the first alternative better, since it seems cleaner. The second seems marginally cleaner to me. Even better would be deleting the software watchpoint at the same time, i.e. decreasing divergence between the two; do you see any reason why this wouldn't work out? -- Daniel Jacobowitz CodeSourcery, LLC