I am using Eclipse 4.4.2 on Ubuntu 14.04, and GDB 7.7.1. I am trying to inspect the contents of some C++ standard library containers in the Eclipse debugger.
What I have tried so far: following instructions here, I ran the command
svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
Copying it into /home/myusername/prettyprint
.
Then I copied this text into my .gdbinit:
python
import sys
sys.path.insert(0, '/home/myusername/prettyprint/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
When I ran gdb
, I got this error message:
Traceback (most recent call last):
File "<string>", line 4, in <module>
File "/home/myusername/prettyprint/python/libstdcxx/v6/printers.py", line 1266, in register_libstdcxx_printers
gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
File "/usr/myusername/gdb/python/gdb/printing.py", line 146, in register_pretty_printer
printer.name)
RuntimeError: pretty-printer already registered: libstdc++-v6
I searched for help on this, and found that the second last line in the file (register_libstdcxx_printers (None)
) was not necessary, so I removed it. Then, when I ran gdb
and typed:
info pretty-print
I got this output, indicating that the backend was installed properly:
global pretty-printers:
.*
bound
libstdc++-v6
__gnu_cxx::_Slist_iterator
__gnu_cxx::__7::_Slist_iterator
__gnu_cxx::__7::__normal_iterator
__gnu_cxx::__7::slist
__gnu_cxx::__normal_iterator
__gnu_cxx::slist
__gnu_debug::_Safe_iterator
std::_Deque_const_iterator
std::_Deque_iterator
std::_List_const_iterator
std::_List_iterator
std::_Rb_tree_const_iterator
std::_Rb_tree_iterator
std::__7::_Deque_const_iterator
std::__7::_Deque_iterator
std::__7::_List_const_iterator
std::__7::_List_iterator
std::__7::_Rb_tree_const_iterator
---Type <return> to continue, or q <return> to quit---
std::__7::_Rb_tree_iterator
std::__7::__cxx11::basic_string
std::__7::basic_string
std::__7::bitset
std::__7::deque
std::__7::forward_list
std::__7::list
std::__7::map
std::__7::multimap
std::__7::multiset
std::__7::priority_queue
std::__7::queue
std::__7::set
std::__7::shared_ptr
std::__7::stack
std::__7::tuple
std::__7::unique_ptr
std::__7::unordered_map
std::__7::unordered_multimap
std::__7::unordered_multiset
std::__7::unordered_set
std::__7::vector
[... many more lines of output omitted]
For good measure, I added the following lines to .gdbinit
:
set print pretty on
set print object on
set print static-members on
set print vtbl on
set print demangle on
set demangle-style gnu-v3
set print sevenbit-strings off
So I opened Eclipse and started debugging my application, only to find that the ugly print was still in effect:
How can I fix this to use GDB's pretty print; is pretty print even installed?