Boost logo

Boost :

Subject: [boost] gdb pretty printers
From: Paul Fee (paul.f.fee_at_[hidden])
Date: 2014-11-18 09:01:05


Hi all,

On Linux, when using GDB to debug C++ programs that use Boost, it's
difficult to get human readable values from variables.

e.g.
== Source ==
boost::optional<std::string> s("hello world");

== GDB ==
(gdb) print s
$1 = {<boost::optional_detail::optional_base<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >> =
{<boost::optional_detail::optional_tag> = {<No data fields>}, m_initialized
= true, m_storage = {dummy_ = {data = "(0`\000\000\000\000", aligner_ =
{<No data fields>}}}}, <No data fields>}
========

A set of python pretty printers that understand the internals of some Boost
objects can be found here: https://github.com/ruediger/Boost-Pretty-Printer

The resulting output is more useful:

== GDB ==
(gdb) print s
$2 = boost::optional<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > is initialized = {value = "Hello world"}
=========

Some distros, e.g. Fedora, CentOS have STL pretty printers working out of
the box. It would be great to also have Boost pretty printers widely
available via Linux distros.

Since the pretty printers are tightly coupled to the objects they're
printing, it would be ideal if they were included with Boost. That way
both the class definitions and python printers should stay in sync.

Can someone provide guidance on how to get code in the above github repo
into Boost?

Thanks,
Paul


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk