Skip to content

melintea/Boost-Pretty-Printer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GDB (the GNU Debugger) Pretty Printers for Boost

Since version 7.0 GDB has Python scripting support. This can be used to provide “Pretty Printers” to make the output of GDB more usable. The libstdc++ project currently provides a set of pretty printers for their implementation of the C++ standard library. This projects goal is to provide a similar set of pretty printers for the Boost library.

Help is appreciated!

See supported.txt for supported classes and names of contributors.

Installation:

GDB version 7 or better is required!

Check out the git repository

git clone git://github.com/ruediger/Boost-Pretty-Printer.git

and add the following lines to your ~/.gdbinit

python
import sys
sys.path.insert(0, 'PATH-TO-THE-REPO/Boost-Pretty-Printer')
from boost.v1_40.printers import register_boost_printers
register_boost_printers(None)
end

and of course replace PATH-TO-THE-REPO with the absolute path to the Boost Pretty Printer repository. If you have no ~/.gdbinit file just create it.

Now you can simply use GDB’s print (short p) statement to pretty print the supported boost objects.

Example

$ cat > foo.c++
#include <boost/range/iterator_range.hpp>
using namespace boost;

int main() {
  char buf[] = "Hello World";
  iterator_range<char const*> range(buf, buf + sizeof(buf));

  return range[0];
}
^D
$ g++ -g3 foo.c++
$ gdb -q a.out
Reading symbols from /home/ruediger/develop/demos/a.out...done.
(gdb) break 7
Breakpoint 1 at 0x4006cb: file /home/ruediger/develop/demos/foo.c++, line 7.
(gdb) run
Starting program: /home/ruediger/develop/demos/a.out

Breakpoint 1, main () at /home/ruediger/develop/demos/foo.c++:8
8         return range[0];
(gdb) p range
$1 = boost::iterator_range<char const*> of length 12 = {72 'H', 101 'e', 108 'l', 108 'l', 111 'o', 32 ' ', 87 'W', 111 'o', 114 'r', 108 'l', 100 'd', 0 '\000'}

About

GDB Pretty Printers for Boost

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published