From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 361 invoked by alias); 23 Oct 2006 22:02:33 -0000 Received: (qmail 353 invoked by uid 22791); 23 Oct 2006 22:02:32 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 23 Oct 2006 22:02:29 +0000 Received: (qmail 16941 invoked from network); 23 Oct 2006 22:02:28 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 23 Oct 2006 22:02:28 -0000 To: Eli Zaretskii Cc: Daniel Jacobowitz , rodney.bates@wichita.edu, gdb@sourceware.org Subject: Re: breakpoint for accessing memory location References: <4537DBC6.1030807@hccnet.nl> <20061019201214.GA32332@nevyn.them.org> <4537DEDC.5000008@hccnet.nl> <453A3758.5090602@wichita.edu> <453A6D1D.1080009@wichita.edu> <453B8C22.3010206@wichita.edu> <20061022172431.GA15887@nevyn.them.org> From: Jim Blandy Date: Mon, 23 Oct 2006 22:02:00 -0000 In-Reply-To: (Eli Zaretskii's message of "Mon, 23 Oct 2006 00:22:27 +0200") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00219.txt.bz2 Eli Zaretskii writes: >> Date: Sun, 22 Oct 2006 13:24:31 -0400 >> From: Daniel Jacobowitz >> Cc: Eli Zaretskii , gdb@sourceware.org >> >> On Sun, Oct 22, 2006 at 10:20:02AM -0500, Rodney M. Bates wrote: >> > If p is local to an inner block, but the compiler did the common thing of >> > flattening p and all its cousins into one activation record for the >> > containing >> > function, does the watchpoint really get deleted when execution leaves the >> > block, or when the containing function returns? >> >> When the debug info says it goes out of scope, or more specifically, >> when GDB no longer knows where to find it. > > Don't we record the frame in the watchpoint structure? If so, the > watchpoint is deleted when its frame is popped off the stack. Actually, that's still not the ideal behavior. The language specification defines what it means for a variable to be "in scope" at a particular program location. That's the definition GDB should use, ideally. Consider code like this: int foo (void) { ...; { int b = 10; /* X */ ...; } /* Y */ ...; } If I set a watchpoint on b at '/* X */', then that watchpoint should be deleted at soon as we leave the local block in which it is defined. For example, if we step to '/* Y */', then the watchpoint should be deleted, because the variables it refers to are no longer in scope at that point. Unfortunately, GDB doesn't do this. Instead, it behaves just as Eli said it does, and waits for the frame to be popped before removing the watchpoint.