public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Can GCC emit debug information to support debug uninitialized local variables
@ 2010-06-19  8:17 asmwarrior
  2010-06-20  7:02 ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: asmwarrior @ 2010-06-19  8:17 UTC (permalink / raw)
  To: gcc

Hi, I have some problem using GCC and GDB, you know, the current GDB has 
python pretty printer enabled, so that the variables can be show quite 
nicely.

My problem is when gdb try to show some variable that is not 
initialized. For example:

void test()
{
     std::string stdStr("std::string");
     stdStr.append(" value");
     std::map<int, std::string> m;
     m[0] = "000";
     m[1] = "111";
}

If I set a breakpoint in the first line of test function, and send 
command "info local" to gdb, then gdb get crashed. That is because GDB 
regard every local variables are initialized,then the associated python 
pretty printer code was executed. In fact, in this situation, none of 
the local variables were initialized, then gdb or python may access to 
some random numbers, and it get crashed.

My question is: Is there any possible that GCC can emit some debug 
information to indicate that one variable is initialed or not.(at least 
in the DEBUG build mode)

So that gdb can firstly check if this variable is already initialed, 
other wise, it will give some tip that "this variable is not initiated yet"

You can see two related discussions at
http://sourceware.org/bugzilla/show_bug.cgi?id=11407
and
http://forums.codeblocks.org/index.php/topic,12747.msg86349.html#msg86349

Thanks

asmwarrior ollydbg from codeblocks' forum

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can GCC emit debug information to support debug uninitialized local variables
  2010-06-19  8:17 Can GCC emit debug information to support debug uninitialized local variables asmwarrior
@ 2010-06-20  7:02 ` Ian Lance Taylor
  2010-06-20 12:55   ` asmwarrior
  2010-06-21  5:57   ` asmwarrior
  0 siblings, 2 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2010-06-20  7:02 UTC (permalink / raw)
  To: asmwarrior; +Cc: gcc

asmwarrior <asmwarrior@gmail.com> writes:

> My question is: Is there any possible that GCC can emit some debug
> information to indicate that one variable is initialed or not.(at
> least in the DEBUG build mode)

You didn't mention which version of gcc you are testing.  With current
gcc see if the -fvar-tracking option helps.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can GCC emit debug information to support debug uninitialized local variables
  2010-06-20  7:02 ` Ian Lance Taylor
@ 2010-06-20 12:55   ` asmwarrior
  2010-06-21  5:57   ` asmwarrior
  1 sibling, 0 replies; 4+ messages in thread
From: asmwarrior @ 2010-06-20 12:55 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

On 2010-6-20 14:18, Ian Lance Taylor wrote:
> asmwarrior<asmwarrior@gmail.com>  writes:
>    
>> My question is: Is there any possible that GCC can emit some debug
>> information to indicate that one variable is initialed or not.(at
>> least in the DEBUG build mode)
>>      
> You didn't mention which version of gcc you are testing.  With current
> gcc see if the -fvar-tracking option helps.
>
> Ian
>    
Thanks for your time and help. I'm currently using two versions of GCC 
under Windows. (MinGW GCC 4.4.4 and MinGW GCC 4.5).
The gdb I built was (gdb cvs 20100613 and gdb cvs 20100618, both with 
python support), but both of the gdb will get crash when I run the "info 
locals" command.


I'm not sure I have catch the core idea about my question, because I 
found an old post here:
http://gcc.gnu.org/ml/gcc/2007-04/msg00138.html ,there, you suggest add 
the DW_AT_start_scope somewhere.

As you said, if I add the "-fvar-tracking" option, there will have debug 
information included. Then, GDB can use this information to avoid to 
print the uninitialized local variables?

Thanks.

Asmwarrior ollydbg from codeblocks' forum.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can GCC emit debug information to support debug uninitialized local variables
  2010-06-20  7:02 ` Ian Lance Taylor
  2010-06-20 12:55   ` asmwarrior
@ 2010-06-21  5:57   ` asmwarrior
  1 sibling, 0 replies; 4+ messages in thread
From: asmwarrior @ 2010-06-21  5:57 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc

On 2010-6-20 14:18, Ian Lance Taylor wrote:
> asmwarrior<asmwarrior@gmail.com>  writes:
>
>    
>> My question is: Is there any possible that GCC can emit some debug
>> information to indicate that one variable is initialed or not.(at
>> least in the DEBUG build mode)
>>      
> You didn't mention which version of gcc you are testing.  With current
> gcc see if the -fvar-tracking option helps.
>
> Ian
>    
Hi, Ian. I have solved this problem by hacking the GDB source code.
You can see my report here:

http://forums.codeblocks.org/index.php/topic,12747.msg86443.html#msg86443

Now, only the variables been initialized will be shown in the "info 
locals" command.

I will publish the related GDB code to GDB maillist.

Thanks

Asmwarrior ollydbg from codeblocks' forum

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-06-21  2:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-19  8:17 Can GCC emit debug information to support debug uninitialized local variables asmwarrior
2010-06-20  7:02 ` Ian Lance Taylor
2010-06-20 12:55   ` asmwarrior
2010-06-21  5:57   ` asmwarrior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).