forked from ruediger/Boost-Pretty-Printer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
52 lines (38 loc) · 1.84 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
GDB (the GNU Debugger http://sourceware.org/gdb/) 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.
* 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'}