Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions blog/_posts/2022-03-01-code-horsepower-f1.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ If you've ever rubbed your eyes trying to decrypt *C++* compilation errors from
- [Debugging tools](#debugging-tools)
* [Building ROOT in Debug Mode](#building-root-in-debug-mode)
* [Debugging your ROOT scripts or executables with GDB](#debugging-your-root-scripts-or-executables-with-gdb)
* [GDB pretty printers](#gdb-pretty-printers)
* [Memory error detection](#memory-error-detection)
* [Data race detection](#data-race-detection)
* [Performance analysis](#performance-analysis)
Expand Down Expand Up @@ -204,6 +205,13 @@ Below a screenshot of another example, while debugging [a deadlock in the TThrea

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).

### GDB pretty printers

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:

- 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`
- Going to "Preferences", "Debugger", "GDB", checking "Load system GDB printers" to use the GDB and not the default Qt pretty-printers.

### Memory error detection

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.
Expand Down