This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
python pretty print gdb script error on map
- From: asmwarrior <asmwarrior at gmail dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Fri, 18 Jun 2010 16:01:08 +0800
- Subject: python pretty print gdb script error on map
Hi, all. I have found that the python pretty print script failed to
print the map values. Here is the sample code:
Here is the gdb log: (I'm using TDM-MinGW 4.5, gdb cvs 0613 selfbuild
with python support, python 2.6.5 Windows XP)
I use the py script followed from this wiki
http://sourceware.org/gdb/wiki/STLSupport
Here, mymap is a map structure.
> output mymap
std::map with 4 elementsTraceback (most recent call last):
File "D:\MinGW\bin\libstdcxx\v6\printers.py", line 353, in next
n = self.rbiter.next()
File "D:\MinGW\bin\libstdcxx\v6\printers.py", line 297, in next
if node.dereference()['_M_right']:
RuntimeError: Attempt to dereference a generic pointer.
>>>>>>cb_gdb:
> print mymap
$1 = std::map with 4 elementsTraceback (most recent call last):
File "D:\MinGW\bin\libstdcxx\v6\printers.py", line 353, in next
n = self.rbiter.next()
File "D:\MinGW\bin\libstdcxx\v6\printers.py", line 297, in next
if node.dereference()['_M_right']:
RuntimeError: Attempt to dereference a generic pointer.
>>>>>>cb_gdb:
if I want to print the raw information,then
> print /r mymap
$2 = {
_M_t = {
_M_impl = {
<std::allocator<std::_Rb_tree_node<std::pair<char const, int> > >> = {
<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<char const, int>
> >> = {<No data fields>}, <No data fields>},
members of std::_Rb_tree<char, std::pair<char const, int>,
std::_Select1st<std::pair<char const, int> >, std::less<char>,
std::allocator<std::pair<char const, int> >
>::_Rb_tree_impl<std::less<char>, false>:
_M_key_compare = {
<std::binary_function<char, char, bool>> = {<No data fields>}, <No data
fields>},
_M_header = {
_M_color = std::_S_red,
_M_parent = 0x33d48,
_M_left = 0x33ce8,
_M_right = 0x33d18
},
_M_node_count = 4
}
}
}
>>>>>>cb_gdb:
> quit
And here is the sample code.
------------------------------------------------------------------------
// map::insert
#include <iostream>
#include <map>
using namespace std;
int main ()
{
map<char,int> mymap;
map<char,int>::iterator it;
pair<map<char,int>::iterator,bool> ret;
// first insert function version (single parameter):
mymap.insert ( pair<char,int>('a',100) );
mymap.insert ( pair<char,int>('z',200) );
ret=mymap.insert (pair<char,int>('z',500) );
if (ret.second==false)
{
cout << "element 'z' already existed";
cout << " with a value of " << ret.first->second << endl;
}
// second insert function version (with hint position):
it=mymap.begin();
mymap.insert (it, pair<char,int>('b',300)); // max efficiency inserting
mymap.insert (it, pair<char,int>('c',400)); // no max efficiency
inserting
// third insert function version (range insertion):
map<char,int> anothermap;
anothermap.insert(mymap.begin(),mymap.find('c'));
// showing contents:
cout << "mymap contains:\n";
for ( it=mymap.begin() ; it != mymap.end(); it++ )
cout << (*it).first << " => " << (*it).second << endl;
cout << "anothermap contains:\n";
for ( it=anothermap.begin() ; it != anothermap.end(); it++ )
cout << (*it).first << " => " << (*it).second << endl;
return 0;
}
------------------------------------------------------------------------
can some one help me?
By the way, I have found when I used python pretty printer to show the
local variables, there are some problems. Sometimes, gdb command "info
local" shows some variables that are not initialized, then gdb will get
crashed, because python script will resolve the wrong address when a
variable is not initialized. Is there any way to solve this.
Also, you can see a gdb discussion here.
http://sourceware.org/bugzilla/show_bug.cgi?id=11407
Thanks
Asmwarrior ollydbg from codeblocks' forum