This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Variable values before initialisaton


Daniel Jacobowitz <drow@false.org> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]