This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[python] [patch] Fix prettyprinter of std::map<const char *, ...>
- From: ppluzhnikov at google dot com (Paul Pluzhnikov)
- To: archer at sourceware dot org
- Date: Tue, 16 Dec 2008 18:10:25 -0800 (PST)
- Subject: [python] [patch] Fix prettyprinter of std::map<const char *, ...>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta;t=1229479828; bh=fZ2xxxgmIY5cvR0x2wr4ZWvFd5Y=;h=DomainKey-Signature:To:Subject:Message-Id:Date:From; b=VS4mbHQCQAMn/qGOCWpKK8IrB4WjGLX9c1cyFyYwmU+dmKx2rYNnlvGzAGWEwce1ifkaQ43Divt5Scin7jxskQ==
- Domainkey-signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns;h=to:subject:message-id:date:from;b=YXVyKmM6K9Y2bvmflV37xXbHkw00P4FV/UwgYIueFJkQhkyCWKVCCaa8zhDVpYoRG8PQu8XUi8QjLr9XnFebag==
Greetings,
This is something I have seen before, but forgot about :(
/// --- cut ---
#include <map>
int main()
{
std::map<const char *, int> m;
m["hello"] = 1;
return 0;
}
/// --- cut ---
g++ -g -o stl2 stl2.cc
gdb -q ./stl2
(gdb) b 7
Breakpoint 1 at 0x40033b: file stl2.cc, line 7.
(gdb) r
Breakpoint 1, main () at stl2.cc:7
7 return 0;
(gdb) source python/lib/gdb/libstdcxx/v6/printers.py
(gdb) print m
$1 = std::map with 1 elementsTraceback (most recent call last):
File "python/lib/gdb/libstdcxx/v6/printers.py", line 284, in children
nodetype = gdb.Type('std::_Rb_tree_node< std::pair< const %s, %s > >' % (keytype, valuetype))
RuntimeError: No type named std::_Rb_tree_node< std::pair< const const char *, int > >.
This is happening because there really is no "pair<const const char *, int>" type.
Attached patch fixes this by brute force :(
Not sure if there is a better fix.
Thanks,
--
Paul Pluzhnikov
diff --git a/gdb/python/lib/gdb/libstdcxx/v6/printers.py b/gdb/python/lib/gdb/libstdcxx/v6/printers.py
index c03c682..9fb26b4 100644
--- a/gdb/python/lib/gdb/libstdcxx/v6/printers.py
+++ b/gdb/python/lib/gdb/libstdcxx/v6/printers.py
@@ -234,7 +234,10 @@ class StdMapPrinter:
def children (self):
keytype = self.val.type().template_argument(0)
valuetype = self.val.type().template_argument(1)
- nodetype = gdb.Type('std::_Rb_tree_node< std::pair< const %s, %s > >' % (keytype, valuetype))
+ try:
+ nodetype = gdb.Type('std::_Rb_tree_node< std::pair< const %s, %s > >' % (keytype, valuetype))
+ except:
+ nodetype = gdb.Type('std::_Rb_tree_node< std::pair< %s const, %s > >' % (keytype, valuetype))
nodetype = nodetype.pointer()
return self._iter (self.iter, nodetype)