Skip to content

Commit d87e425

Browse files
authored
Add Debugging chapter and detail our just helping tools (#57)
1 parent f8f3202 commit d87e425

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
- [Unit Testing](developing/Unit-Testing-in-ldmx-sw.md)
4848
- [Logging](developing/Logging.md)
4949
- [Creating a new Event Bus Object](developing/Creating-a-new-Event-Bus-Object.md)
50+
- [Debugging](developing/Debugging.md)
5051
- [Creating your own production image](developing/custom-production-image.md)
5152
- [What the F.A.Q.?](developing/faq.md)
5253
- [Why this workflow?](developing/whyyyy.md)

src/developing/Debugging.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Debugging
2+
3+
CMAKE provides several useful flags for debugging and code analysis. We've included many of these in `just` recipes for convenience.
4+
5+
## Commands to use:
6+
7+
### Static Analysis
8+
- **`configure-clang-tidy`** - Enables clang-tidy static analysis during compilation to catch potential bugs and style issues before runtime. The CMAKE flag is `-DENABLE_CLANG_TIDY=ON`. This will slow down compilation but provides valuable feedback on code quality.
9+
10+
### Optimization
11+
- **`configure-clang-lto`** - Switches to the clang/clang++ compiler and enables LTO (Link Time Optimization), which can improve performance by optimizing across compilation units during linking. The flags are `-DENABLE_LTO=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang`. Note: LTO significantly increases link time but may catch additional optimization-related issues.
12+
13+
### Runtime Sanitizers
14+
- **`configure-asan-ubsan`** - Enables both ASAN (AddressSanitizer) and UBSAN (UndefinedBehaviorSanitizer) to detect memory errors (buffer overflows, use-after-free, etc.) and undefined behavior at runtime. The flags are `-DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON -DENABLE_SANITIZER_ADDRESS=ON`.
15+
- **Important:** These sanitizers only detect issues when the problematic code is actually executed.
16+
- If issues are detected, the program will abort and print detailed diagnostic information.
17+
18+
### Interactive Debugging
19+
- **`configure-gdb`** - Compiles with debug symbols preserved and optimizations disabled, enabling effective debugging with GDB (GNU Debugger). The flag is `-DCMAKE_BUILD_TYPE=Debug`. This allows you to:
20+
- Set breakpoints and step through code line-by-line
21+
- Inspect variable values during execution
22+
- View readable stack traces
23+
- Note: Debug builds are significantly slower than release builds due to disabled optimizations.

0 commit comments

Comments
 (0)