
Debug Optimized Builds
When GDB tells you "value optimized out" or your breakpoints land on the wrong line, this is what you need. It walks through choosing between -O0, -Og, and -O2 with debug symbols, explains why variables disappear in optimized code and how to work around it, and covers practical techniques like reading inlined frames, using scheduler-locking for multithreaded stepping, and split-DWARF for faster link times. The workflow is organized by problem type rather than tool feature, which makes it easy to jump to the right section when you're stuck. Best for anyone debugging RelWithDebInfo builds or trying to diagnose production crashes where you only have -O2 binaries with debug info.
- skills.sh installs
- 579
- GitHub stars
- 279
- last updated
- Aug 21, 2026
Install
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill debug-optimized-builds --agent claude-codeInstalls into .claude/skills of the current project.
Files
Debugging Optimized Builds
Purpose
Guide agents through debugging code compiled with optimization: choosing the right debug-friendly optimization level, reading inlined frames, diagnosing "value optimized out", using split-DWARF for faster debug builds, and applying GDB techniques specific to optimized code.
Triggers
- "GDB says 'value optimized out' — what does that mean?"
- "How do I debug a release build?"
- "How do I see inlined function frames in GDB?"
- "What's the difference between -O0 and -Og for debugging?"
- "How do I use RelWithDebInfo with CMake?"
- "Breakpoints in optimized code land on wrong lines"
Workflow
1. Choose the right build configuration
Goal?
├── Full debuggability, no optimization
│ → -O0 -g (slowest, all vars visible)
├── Debuggable, some optimization (recommended for most dev work)
│ → -Og -g (-Og keeps debug experience good)
├── Release build with debug info (shipped, debuggable crashes)
│ → -O2 -g -gsplit-dwarf (or -O2 -g1 for lighter info)
└── Full release (no debug symbols)
→ -O2 -DNDEBUG
Sponsors
Details
- Repository
- github.com/mohitmishra786/low-level-dev-skills
- Categories
- Release Management, Debugging
- First seen
- Jun 3, 2026
More from mohitmishra786/low-level-dev-skills
All 54- Cpp Templates574
- Rustc Basics567
- Rust Cross565
- Wasm Emscripten559
- Zig Debugging555
- Zig Build System552
- Zig Cross536
- Wasm Wasmtime532
- Zig Cinterop524
- Cmake1.8K
- Static Analysis1.2K
- Gdb1K
- Llvm948
- Sanitizers895
- Core Dumps828
- Linux Perf814
- Clang789
- Cross Gcc742
- Gcc741
- Valgrind740
- Flamegraphs728
- Assembly X86724
- Strace Ltrace711
- Cpu Cache Opt709