This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: "info locals" -- is variable initialized
On Friday 02 September 2005 17:20, Daniel Jacobowitz wrote:
> 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.
-fvar-tracking is accepted, but does not have any result on "info locals".
> > > 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...
I realize, but given that no better mechanism exist, what can I do?
- Volodya