ruediger / Boost-Pretty-Printer

GDB Pretty Printers for Boost
197 stars 61 forks source link

How to register sub printers? #51

Open g199209 opened 3 years ago

g199209 commented 3 years ago

My ./gdbinit:

python
import sys
sys.path.insert(1, '/home/xxx/Boost-Pretty-Printer')
import boost
boost.register_printers()
end
$gdb
GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
*** boost: registering top-level printers: (name="boost" id=140709847321104) (name="trivial" id=140709847321168) with objfile=None
(gdb) info pretty-printer
global pretty-printers:
  boost
  builtin
    mpx_bound128
  trivial

Only top level boost pretty-printer is registered, no any sub printers.

I have tried the example program in README, the pretty-printer has no effect:

(gdb) p range
$1 = {<boost::iterator_range_detail::iterator_range_base<char const*, boost::iterators::random_access_traversal_tag>> = {<boost::iterator_range_detail::iterator_range_base<char const*, boost::iterators::bidirectional_traversal_tag>> = {<boost::iterator_range_detail::iterator_range_base<char const*, boost::iterators::incrementable_traversal_tag>> = {<boost::iterator_range_detail::iterator_range_tag> = {<No data fields>}, m_Begin = 0x7fffffffde24 "Hello World",
        m_End = 0x7fffffffde30 ""}, <No data fields>}, <No data fields>}, <No data fields>}

BTW, when I tried to specified boost version in .gdbinit like this:

boost.register_printers(boost_version=(1,72,0))

Python error occured:

Traceback (most recent call last):
  File "<string>", line 4, in <module>
TypeError: register_printers() got an unexpected keyword argument 'boost_version'
/home/xxx/.gdbinit:16: Error in sourced command file:
Error while executing Python code.

Is README doc out of date? How to use this printer correctly now?