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: About the "info locals" command of gdb and python pretty printer


On Sunday 20 June 2010 11:13:20 asmwarrior wrote:
> Hi, I have some problems to show some uninitialized local variables.
> 
> For example, here is the test code:
> 
> void test()
> {
>      int aaaa = 1;
>      int bbbb = 2;
>      int cccc = 3;
> }
> 
> int main()
> {
>      test();
>      return 0;
> }
> 
> Here, if I set a breakpoint at the first statement of the "test()", then 
> run "info locals" command. gdb will plot all the information about both 
> "aaaa, bbbb and cccc".
> 
> Things becomes more complex when bbbb and cccc are not simple type, but 
> instead, they are stl containers like vector<int> or maps.
> like:
> 
> void test()
> {
>      int aaaa = 1;
>      vector <int> bbbb;
>      map<int,string>cccc;
> }
> 
> At this time, if we run the "info locals" with python stl pretty printer 
> enabled, as you see, if you breakpoint is still at the first line "int 
> aaa = 1;", then bbbb and cccc are not initialized, this may cause the 
> python script to plot random values, some times, gdb or python will get 
> crashed.

As data "damaged" after the initialization can look pretty much like
uninitialized data, taking the scope information into account would
not solve the problem, only reduce the likelihood of running into it.

Andre'


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