Code::Blocks Forums
User forums => Help => Topic started by: Danikar on August 30, 2008, 02:11:56 am
-
I am trying to debug so code where I want to see the values that are contained in a particular vector while I am stepping through the code. However, when I set a watch on a vector variable it gives me memory addresses and etc, but the the values.
Is there a way to view the contents of the vector in the watch window? Or is there any way at all? Thanks.
I am migrating from VS2005. Finally decided I wanted a IDE that could use on any OS that I am using. =)
Thanks in advanced for any help, it is greatly appreciated.
-
At the lowest level you could enter a gdb command like:
"p *array-variable@length"
See: http://www.yolinux.com/TUTORIALS/GDB-Commands.html
containing a useful example of a "print vector" gdbinit script.
or write a CB script to do it for you. Search on: "script" in
http://wiki.codeblocks.org/index.php?title=Special:Allpages
All articles - CodeBlocks
Example debugger scripts are in SVN trunk/src/scripts
http://svn.berlios.de/wsvn/codeblocks/trunk/src/scripts/gdb_types.script?rev=5200&sc=1
Wiki:
http://wiki.codeblocks.org/index.php?title=Debugger_scripts
Debugg
-
One important thing, I did a very quick test on a console app (debug target) with the following contents for main.cpp :
#include <iostream>
#include <vector>
int main()
{
std::vector<int> Test;
Test.push_back(1);
Test.push_back(2);
Test.push_back(3);
Test.push_back(4);
std::cout << "Hello World" << std::endl;
return 0;
}
==> on my linux box I have the following results
1) when the debugger plug-in is configured to evaluate the variable under the cursor, it is not feasible to right click on the 'Test' variable to add it to the watches
==> I manually added it ;-)
2) tooltip : evaluate under cursor gives for 'Test' : Cannot evaluate function -- may be inlined
3) 'Test' in the watches gives : evaluate under cursor gives for 'Test' : Cannot evaluate function -- may be inlined
4) Watches : Local variables -> Test gives : <std::_Vector_base<int, std::allocator<int> >> <no data field>
.
.
.
5) trying to dock the watches windows ===> CB CRASH
So although the gdb_types.script contains support for the vector (as requested by the OP), I doesn't seem to work.
@Everyone : please write scripts to enhance the debugging/watches experience ;-)