Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Loaden on January 13, 2010, 08:14:09 am

Title: Need help, about debug std::map
Post by: Loaden on January 13, 2010, 08:14:09 am
Hello everyone, I am using CB debugging, found it impossible to print std:: map <int, std::string> value.
You have any good ideas? Thanks!
Code
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main()
{
map<int, string> m = {{1, "Hello everybody!"}, {2, "How to debug map?"}};
m.insert (make_pair (3, "pmap m int int no-work!") );
m.insert (make_pair (4, "Need help, thanks!") );
return 0;
}



[attachment deleted by admin]
Title: Re: Need help, about debug std::map
Post by: oBFusCATed on January 13, 2010, 10:49:51 am
You can write a Evaluation script, see here http://wiki.codeblocks.org/index.php?title=Debugger_scripts
Also look at the implementation of the Vector's script, it uses the gdb's script "stl-views-1.0.3.gdb", which should have command for maps.

The script is taken from here: http://sourceware.org/gdb/wiki/STLSupport
You can use the python pretty printers if you have python enabled gdb-7.x+ (the windows one is not :( )

Also enable the debugger's debug log pane (settings -> compiler & debugger -> debugger)
Title: Re: Need help, about debug std::map
Post by: Loaden on January 13, 2010, 01:36:45 pm
Thanks to oBFusCATed !
I will try it.