Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Debugging C++ code and STL classes

<< < (2/2)

ghorwin:
After some testing I could compose a "safe" GDB command to evaluate a std::vector:


--- Code: (cpp) ---p   (vec._M_impl._M_start == vec._M_impl._M_end_of_storage) ? "<empty>" : ((start+count) < (vec._M_impl._M_end_of_storage - vec._M_impl._M_start)) ? vec._M_impl._M_start@count : "<index out of range>"

--- End code ---

This, however, returns either one of the error strings or the content of the vector range in hex, so one of the following:

"<empty>"
"<index out of range>"
{0x3e4f58, 0x3e5f00, 0x3e5f58, 0x3e5f70, 0x3e6f18, 0x3e6f18, 0x3eae20, 0x3ebdc8, 0x3ebdc8, 0x3e6f30}

regardless of the actual type of the vector (the example above was obtained from a vector<double>).

Using
p /f ...

I will get the content of the vector<double> correctly, but the strings are converted to numbers :-( So, the parsing and conversion of each type would have to be done either in Parse_StlVector or in the CodeBlocks GUI.

Any suggestion about how to do this best?

Btw, the option of floating point format for the watched expression is missing: "Decimal" is misleading (should be "Signed" or "Integer") and "Floating point" should be added.

Bye,
Andreas

adfm:
hey,

sorry for waking this thread up, but I am wondering what is the status of the proposed solutions for debugging stl!

What I get when I try to watch a string and a vector of this sort


--- Code: ---    vector<int> bla;
    bla.push_back(1);
    bla.push_back(2);
    bla.push_back(3);
    bla.push_back(4);
    bla.push_back(5);

    string blob="Hello World";

--- End code ---

is something like...

[img=http://img231.imageshack.us/img231/5286/debugoutput.png]

what's all this stuff about anyway? shouldn't be something pretty much simpler than this?


Regards
Andre

Navigation

[0] Message Index

[*] Previous page

Go to full version