Author Topic: Need help, about debug std::map  (Read 6852 times)

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Need help, about debug std::map
« 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]

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: Need help, about debug std::map
« Reply #1 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)
(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!]

Offline Loaden

  • Lives here!
  • ****
  • Posts: 1014
Re: Need help, about debug std::map
« Reply #2 on: January 13, 2010, 01:36:45 pm »
Thanks to oBFusCATed !
I will try it.