This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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]

Can GCC emit debug information to support debug uninitialized local variables


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


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