Closed glebm closed 1 month ago
Previously, printing a StaticVector in gdb printer the size and the raw bytes of data_.
StaticVector
data_
Example of using this pretty-printer:
$ gdb -iex 'add-autoload-safe-path .' build/devilutionx (gdb) b Source/engine/load_file.hpp:126 (gdb) run (gdb) p files $1 = devilution::StaticVector<devilution::AssetRef, 6> of length 5 = {{archive = 0x55555c8d7460 <devilution::diabdat_mpq>, fileNumber = 1420, filename = "monsters\\zombie\\zombien.cl2", directHandle = 0x0}, {archive = 0x55555c8d7460 <devilution::diabdat_mpq>, fileNumber = 1421, filename = "monsters\\zombie\\zombiew.cl2", directHandle = 0x0}, {archive = 0x55555c8d7460 <devilution::diabdat_mpq>, fileNumber = 1422, filename = "monsters\\zombie\\zombiea.cl2", directHandle = 0x0}, {archive = 0x55555c8d7460 <devilution::diabdat_mpq>, fileNumber = 1423, filename = "monsters\\zombie\\zombieh.cl2", directHandle = 0x0}, {archive = 0x55555c8d7460 <devilution::diabdat_mpq>, fileNumber = 1424, filename = "monsters\\zombie\\zombied.cl2", directHandle = 0x0}}
The pretty-printer implements the full array printer protocol, so it even works in IDEs.
For VS Code and CMake, add the following to your .vscode/settings.json:
.vscode/settings.json
"cmake.debugConfig": { "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true }, { "description": "Load StaticVector pretty-printer" "text": "source ${workspaceFolder}/tools/gdb/pretty_printers/utils/static_vector_pp.py", "ignoreFailures": false } ] }
To get this:
Previously, printing a
StaticVector
in gdb printer the size and the raw bytes ofdata_
.Example of using this pretty-printer:
The pretty-printer implements the full array printer protocol, so it even works in IDEs.
For VS Code and CMake, add the following to your
.vscode/settings.json
:To get this: