File: README.prettyprinter

package info (click to toggle)
seergdb 2.5%2Bgit20250220%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 8,064 kB
  • sloc: cpp: 27,553; ansic: 1,268; makefile: 666; python: 665; asm: 244; ada: 102; fortran: 12
file content (22 lines) | stat: -rw-r--r-- 776 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Pretty Printer is a GDB feature to print the contents of structures in
a pleasant way.

Printing the value of a std::string may look like:

    {static npos = 18446744073709551615, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7fffffffd330 "Hello, World!"}, _M_string_length = 13, {_M_local_buf = "Hello, World!\\000\\000", _M_allocated_capacity = 6278066737626506568}}

Printing the value with Pretty Pretty:

    "Hello, World!"

Enable Pretty Printers via the ~/.gdbinit file.

    % cat ~/.gdbinit
    python
    import sys
    sys.path.insert(0, '/usr/share/gcc-9/python')
    from libstdcxx.v6.printers import register_libstdcxx_printers
    register_libstdcxx_printers (None)
    end
    %