From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24488 invoked by alias); 25 Sep 2005 17:25:53 -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 24291 invoked by uid 22791); 25 Sep 2005 17:25:39 -0000 Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Sun, 25 Sep 2005 17:25:39 +0000 Received: from drow by nevyn.them.org with local (Exim 4.52) id 1EJaFr-00042n-RH; Sun, 25 Sep 2005 13:25:36 -0400 Date: Sun, 25 Sep 2005 17:25:00 -0000 From: Daniel Jacobowitz To: Thomas Covenant Cc: gdb@sources.redhat.com Subject: Re: When do watchpoints go out of scope? Message-ID: <20050925172535.GA15486@nevyn.them.org> Mail-Followup-To: Thomas Covenant , gdb@sources.redhat.com References: <20050925143734.65016.qmail@web34809.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050925143734.65016.qmail@web34809.mail.mud.yahoo.com> User-Agent: Mutt/1.5.8i X-SW-Source: 2005-09/txt/msg00186.txt.bz2 On Sun, Sep 25, 2005 at 07:37:34AM -0700, Thomas Covenant wrote: > Consider this program: > > 1 int main(void) > 2 { > 3 { > 4 int i = 2; > 5 printf("i is %d.\n", i); > 6 i = 3; > 7 printf("i is %d.\n", i); > 8 } > 9 // lots more code > ... > 90 return 0; > 100 } > > The variable i goes in scope at line 4, out of scope > at line 8. > > If I set: > > watch i > > at line 4, I would assume the watchpoint would be > deleted at line 8, since i is no longer in scope. This depends on your compiler and the debug information it generates. If GDB still has location information, it will continue to watch the variable. If it doesn't, it will stop. You didn't say what your platform or compiler was, so it's hard to guess, but many older versions of GCC and most targets using the stabs format do not have accurate endings for lifetimes. -- Daniel Jacobowitz CodeSourcery, LLC