From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1013 invoked by alias); 2 Sep 2005 13:21:26 -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 523 invoked by uid 22791); 2 Sep 2005 13:20:47 -0000 Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Fri, 02 Sep 2005 13:20:47 +0000 Received: from drow by nevyn.them.org with local (Exim 4.52) id 1EBBTJ-0003Pr-Su; Fri, 02 Sep 2005 09:20:45 -0400 Date: Fri, 02 Sep 2005 13:21:00 -0000 From: Daniel Jacobowitz To: Vladimir Prus Cc: gdb@sources.redhat.com Subject: Re: "info locals" -- is variable initialized Message-ID: <20050902132045.GA13068@nevyn.them.org> Mail-Followup-To: Vladimir Prus , gdb@sources.redhat.com References: <20050902131321.GA12830@nevyn.them.org> <200509021718.47151.ghost@cs.msu.su> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200509021718.47151.ghost@cs.msu.su> User-Agent: Mutt/1.5.8i X-SW-Source: 2005-09/txt/msg00016.txt.bz2 On Fri, Sep 02, 2005 at 05:18:46PM +0400, Vladimir Prus wrote: > On Friday 02 September 2005 17:13, Daniel Jacobowitz wrote: > > On Fri, Sep 02, 2005 at 01:53:41PM +0400, Vladimir Prus wrote: > > > So, there's a window there variable does not exists according to C++, but > > > exists according to gdb. > > > > With better debug information, this doesn't happen (or the window is > > reduced to an instruction or two in the call sequence for the > > constructor). GCC 4's variable tracking feature does this passably > > well, IIRC, by use of dwarf2 location lists. > > Do I need for extra flags for gcc? I've tried with gcc-4.0 before posting the > message, and it did printed all vars. I think it's activated with optimization, but with -O0 you may need -fvar-tracking. I don't know for sure. > > In general no there is nothing gdb can do. > > How about using decl_line. Here's what debug info says > > <2><2188c>: Abbrev Number: 140 (DW_TAG_variable) > DW_AT_name : url > DW_AT_decl_file : 1 > DW_AT_decl_line : 14 > DW_AT_type : <1d555> > DW_AT_location : 3 byte block: 91 98 7f (DW_OP_fbreg: -104) > > If gdb could tell the value of 'decl_line' via some command, that might be a > good approximation. Using line numbers for this sort of thing is really not a good idea. They're useful for displaying source to the user, but for anything else, there are too many potential strangenesses... -- Daniel Jacobowitz CodeSourcery, LLC