News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Display 2d Vector in Watches

Started by nyislander, December 30, 2010, 06:16:29 PM

Previous topic - Next topic

nyislander

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?

#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

oBFusCATed

Does watches for 1d vector work?
Does watches work for simple variables (int,float)?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

nyislander

Yes, for a 1d vector Watches works.  When I watched 2d & 3d vectors in 8.02 I could see them.

ollydbg

works  here (latest debugger branch nightly, windows, gdb with python)
here is the log:

> 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> >


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

But the watch window does not parse the output quite well. :(
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

oBFusCATed

Watch windows doesn't parse the pretty printer output...

And I suppose that nyislander doesn't have pretty printers...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

nyislander

I went back to C::B 8.02 - all is well.

ollydbg

Quote from: nyislander on January 05, 2011, 03:56:33 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).
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.