Author Topic: std vector debugging  (Read 9881 times)

daniel_i_l

  • Guest
std vector debugging
« on: April 01, 2009, 07:22:43 pm »
I recently started using C::B and like it a lot.  One thing has been bothering me though.  Is there anyway to see the contents of a std vector in the debugger?  After a lot of experimenting I found two partial solutions:
1) Apparently the gdb_types script is supposed to support std vectors.  It didn't work for me so I edited it so that the function Evaluate_StlVector is defined as
function Evaluate_StlVector(type, a_str, start, count)
{
return _T("p *(") + a_str + _T("._M_impl._M_start)");
}
and the Parse_StlVector just returns the a_str string.
This gives me the first element of the list in the toolpoint but the "watches" window doesn't.  How can I get this output to be displayed in the watches window?

2) On the "yolinux" site I found a gdbinit file that supports vectors.  But when I put the "pvector" command (as explained on that site) in the gdb_types file or into the command line during a debugging session I get an error saying that the command doesn't exist.  How can I get C::B to read the gdbinit file?  I tried putting it in my home directory and in the project directory with no results.

Is there another, or better way to add std vector support?
Thanks.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5913
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: std vector debugging
« Reply #1 on: June 17, 2009, 06:12:11 pm »
We are discuss on this topic and find a nice solution. see here:

http://forums.codeblocks.org/index.php/topic,10667.msg73032.html#msg73032
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.