Code::Blocks Forums

User forums => Help => Topic started by: nyislander on December 30, 2010, 06:16:29 pm

Title: Display 2d Vector in Watches
Post by: nyislander on December 30, 2010, 06:16:29 pm
C::B 10.02

In debug if I set a breakpoint on the "Pause" and try to display let's say temp[1] in the Watches for the following code I get the message "no available data" under the temp[1] watch.  What am I doing wrong?

Code
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

using namespace std;

int main()
{ // main

int j = 0, h = 0;
vector< vector< int > > temp (5);

        for (h = 0; h < 5; ++h)
           {for (j = 0; j < 5; ++j){temp[h].push_back(j); cout << setw(2) << temp[h][j];} cout << endl;}
        system("PAUSE");

} // end main
Title: Re: Display 2d Vector in Watches
Post by: oBFusCATed on December 30, 2010, 07:18:01 pm
Does watches for 1d vector work?
Does watches work for simple variables (int,float)?
Title: Re: Display 2d Vector in Watches
Post by: nyislander on December 30, 2010, 07:21:14 pm
Yes, for a 1d vector Watches works.  When I watched 2d & 3d vectors in 8.02 I could see them.
Title: Re: Display 2d Vector in Watches
Post by: ollydbg on December 31, 2010, 01:27:52 am
works  here (latest debugger branch nightly, windows, gdb with python)
here is the log:
Code
> p temp
$6 = std::vector of length 5, capacity 5 = {std::vector of length 5, capacity 8 = {0, 1, 2, 3, 4}, std::vector of length 5, capacity 8 = {0, 1, 2, 3, 4}, std::vector of length 5, capacity 8 = {0, 1, 2, 3, 4}, std::vector of length 5, capacity 8 = {0, 1, 2, 3, 4}, std::vector of length 5, capacity 8 = {0, 1, 2, 3, 4}}
>>>>>>cb_gdb:
> pvector temp
elem[0]: $7 = std::vector of length 5, capacity 8 = {0, 1, 2, 3, 4}
elem[1]: $8 = std::vector of length 5, capacity 8 = {0, 1, 2, 3, 4}
elem[2]: $9 = std::vector of length 5, capacity 8 = {0, 1, 2, 3, 4}
elem[3]: $10 = std::vector of length 5, capacity 8 = {0, 1, 2, 3, 4}
elem[4]: $11 = std::vector of length 5, capacity 8 = {0, 1, 2, 3, 4}
Vector size = 5
Vector capacity = 5
Element type = std::vector<int, std::allocator<int> >

Code
p temp 
command internally call the python pretty printer.
Code
pvector temp
use the stl container script support.

But the watch window does not parse the output quite well. :(
Title: Re: Display 2d Vector in Watches
Post by: oBFusCATed on December 31, 2010, 01:57:34 am
Watch windows doesn't parse the pretty printer output...

And I suppose that nyislander doesn't have pretty printers...
Title: Re: Display 2d Vector in Watches
Post by: nyislander on January 05, 2011, 03:56:33 am
I went back to C::B 8.02 - all is well.
Title: Re: Display 2d Vector in Watches
Post by: ollydbg on January 05, 2011, 04:05:26 am
I went back to C::B 8.02 - all is well.
1, it seems only vector<int> is supported, so ,if you write vector<wxString>, I think you will get failed.
2, well, it seems there is a tiny bug in parsing the gdb's response string, I personally suggest using the python gdb script, it really support more types. (and can be extended to more user types).