Skip to content

Use RaZ's pretty printers

Romain Milbert edited this page Feb 3, 2020 · 3 revisions

Pretty printers are specific configurations for a debugger, in order to alter the output when printing variable values.

As an example, printing a Raz::Vector of 12 ints without pretty printing on GDB:

(gdb) print vecTest
$1 = {m_data = {_M_elems = {8, 1, 3, 4, 2, 1, 9, 0, 4, 0, 1, 2}}}

With pretty printing (any information can be given, this result may not be the current one):

(gdb) print vecTest
$1 = {8, 1, 3, 4, 2, 1, 9, 0, 4, 0, 1, 2}

The above example is basic, but can become much more useful with more complex structures.


RaZ provides pretty printers for its types. To use those, you must tell your debugger where to search for them. This is made with a certain configuration file.

GDB

With GDB, the configuration files are small files named .gdbinit, associated with Python scripts which handle the actual printers. A .gdbinit file & the scripts are provided for RaZ, but a global configuration file must be created by the user to reference RaZ's one.

Create a file named .gdbinit in your home directory (~/ under Linux, C:\Users\YourUsername\ under Windows). At least two instructions must be put in this file:

  • set auto-load local-gdbinit on, so that GDB references local configuration files
  • add-auto-load-safe-path <path(s)>, to tell GDB to search for any .gdbinit from the given path(s)
    • Wildcards (*) can be used to match a pattern; these do not match directory separators
    • Several paths can be specified by separating them (: separator under Linux & ; under Windows)

To reference RaZ's printers, the following lines must be written:

set auto-load local-gdbinit on
add-auto-load-safe-path path/to/RaZ

Instead of path/to/RaZ, you can also simply write /. This will take any .gdbinit found on your system.

LLDB

TODO

MSVC

TODO

Clone this wiki locally