This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug python/12421] New: prettyprinting STL map fails in C frameswith No type named std::_Rb_tree_node...
- From: "nomura at netapp dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Thu, 20 Jan 2011 03:17:19 +0000
- Subject: [Bug python/12421] New: prettyprinting STL map fails in C frameswith No type named std::_Rb_tree_node...
- Auto-submitted: auto-generated
http://sourceware.org/bugzilla/show_bug.cgi?id=12421
Summary: prettyprinting STL map fails in C frames with No type
named std::_Rb_tree_node...
Product: gdb
Version: 7.2
Status: NEW
Severity: normal
Priority: P2
Component: python
AssignedTo: unassigned@sourceware.org
ReportedBy: nomura@netapp.com
gdb 7.2 with python 2.6
prettyprinting certain STL types fails if the current frame is non-C++, or if
e.g "set language c" is used to force this condition. This leads to erratic
behavior when printing global variables in a mixed-language application.
Testcase:
[cyclsvl06]$ cat a.C
#include <string>
#include <map>
class C {
static C *_db;
std::map<std::string, int> x;
};
C root;
C* C::_db = &root;
main() {}
Compile with: g++ -g a.C (using g++ 4.1.2 on RHEL 5.4 64-bit in this case)
Debug with gdb 7,2, built --with-python (python 2.6) and sourcing in
printers.py
per http://sourceware.org/gdb/wiki/STLSupport
# immediately on entry to gdb we print the global variable. we have no
# frame - language might default to C++
(gdb) print *'C::_db'
$1 = {static _db = 0x6014e0, x = std::map with 0 elements}
# force language to c. Alternatively, if a C-language stack frame is
# available, switch to it. We get a type lookup error.
(gdb) set lang c
(gdb) print *'C::_db'
$2 = {static _db = 0x6014e0, x = std::map with 0 elements
Traceback (most recent call last):
File "/usr/software/gdb/share/python/libstdcxx/v6/printers.py", line 374, in
children
nodetype = gdb.lookup_type('std::_Rb_tree_node< std::pair< %s, %s > >' %
(keytype, valuetype))
RuntimeError: No type named std::_Rb_tree_node< std::pair< const
std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int >
>.
}
# back to C++ to toggle the behaviour
(gdb) set lang c++
(gdb) print *'C::_db'
$3 = {static _db = 0x6014e0, x = std::map with 0 elements}
(gdb)
It seems the subtype "const std::basic_string<char, std::char_traits<char>,
std::allocator<char> >" is an issue. In "C language mode", lookup_type()
fails with this, but if it were coded with the const qualifier at the end
rather than the beginning, lookup will succeed. In "C++ language mode"
either placement of the const qualifier is tolerated by lookup_type().
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.