From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18309 invoked by alias); 27 Nov 2006 20:09:01 -0000 Received: (qmail 18277 invoked by uid 22791); 27 Nov 2006 20:09:00 -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, 27 Nov 2006 20:08:53 +0000 Received: (qmail 31411 invoked from network); 27 Nov 2006 20:08:52 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 27 Nov 2006 20:08:52 -0000 To: gdb@sourceware.org Subject: Re: Variable values before initialisaton References: <20061123195521.GA18110@nevyn.them.org> <20061124151537.GA12695@nevyn.them.org> From: Jim Blandy Date: Mon, 27 Nov 2006 20:09:00 -0000 In-Reply-To: <20061124151537.GA12695@nevyn.them.org> (Daniel Jacobowitz's message of "Fri, 24 Nov 2006 10:15:38 -0500") 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-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-11/txt/msg00183.txt.bz2 Daniel Jacobowitz writes: > On Fri, Nov 24, 2006 at 09:52:52AM +0300, Vladimir Prus wrote: >> Can you clarify? Certainly, each constructor invocation produces a finite >> number of processor instruction. You can identify the "last" instruction of >> those, and hack gcc to produce file last_instructions_of_ctors.txt and make >> gdb read such file and do the right thing. > > You can have: > > - Initialize part A of structure > - Read part A of structure > - Initialize rest of structure > > You don't want GDB to be unable to display the structure at that read, > do you? So you need to know which bits of it are initialized and which > aren't. And, in some cases, you want to be able to debug a structure > pointer after "new" returns some storage but before the constructor is > invoked. > > I suppose this is doable though: a very interesting project for someone > interested in learning about debug info formats and generation would be > to annotate initializedness somehow. The compiler does know. But it > wouldn't be easy. I think this is a bit afield from Rob's original question. In the code he posted: int i = 0; int j = 2; int k = 3; the issue isn't initialization. Rather it's that the scope of k doesn't include the declarations of i and j, but GCC collapses all these declarations into one block, so GDB thinks k's scope does include the first two lines. If GCC produced DW_AT_start_scope attributes (p. 61, #11 in DWARF 3), and GDB understood them, then this would work.