Skip to content

Commit bc3dd1f

Browse files
ferdymercurydpiparo
authored andcommitted
mention GDB pretty printers
1 parent 2478a6a commit bc3dd1f

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

blog/_posts/2022-03-01-code-horsepower-f1.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ If you've ever rubbed your eyes trying to decrypt *C++* compilation errors from
2222
- [Debugging tools](#debugging-tools)
2323
* [Building ROOT in Debug Mode](#building-root-in-debug-mode)
2424
* [Debugging your ROOT scripts or executables with GDB](#debugging-your-root-scripts-or-executables-with-gdb)
25+
* [GDB pretty printers](#gdb-pretty-printers)
2526
* [Memory error detection](#memory-error-detection)
2627
* [Data race detection](#data-race-detection)
2728
* [Performance analysis](#performance-analysis)
@@ -204,6 +205,13 @@ Below a screenshot of another example, while debugging [a deadlock in the TThrea
204205

205206
Side note: if at some point, your *ROOT* script gets very complex long, I recommend instead to use a standalone *C++* application using *CMake*, and link the *ROOT* libraries easily to it, as explained [here](https://root.cern/manual/integrate_root_into_my_cmake_project/#full-example-event-project).
206207

208+
### GDB pretty printers
209+
210+
In the debugger, classes such as TString are complex objects where one does not immediately see the string it represents. To get a better visual overview, one can deploy the predefined GDB pretty printers embedded in the ROOT project by:
211+
212+
- Creating a file `~/.gdbinit` with content `add-auto-load-safe-path /path/to/build-root_src-Desktop-Debug/lib/` to avoid a warning with `libCore.so-gdb.py`
213+
- Going to "Preferences", "Debugger", "GDB", checking "Load system GDB printers" to use the GDB and not the default Qt pretty-printers.
214+
207215
### Memory error detection
208216

209217
To check for memory leaks and corruption, *QtCreator* offers a seamless integration with valgrind (or [heob on Windows](https://doc.qt.io/qtcreator/creator-analyzer.html)), making the backtrace of your errors fully interactive. To run it, press on the big "Debug button" on the left. Then, on the dropdown menu, change from "Debugger" to "Memcheck" and click on the small play button.

0 commit comments

Comments
 (0)