Skip to content

Debug symbols in various languages and build systems

matu3ba edited this page Jul 25, 2021 · 1 revision

For debugging advanced language features like macros, check the build system/compiler documentation.

Languages


Build systems

C

clang/gcc/tcc.. -g # simpler C compilers like tcc dont have optimisation levels
clang/gcc -O0/O1/-O2/-O3 # prefer -O0 for getting more debugging symbols

C++

clang/gcc -g
clang/gcc -O0/O1/-O2/-O3 # prefer -O0 for getting more debugging symbols

Rust

RUSTFLAGS=-g cargo build # better use profiles in `Cargo.toml` 
RUSTFLAGS='-g --opt-level=1' cargo build # Both are slow to write and force debugging info for all projects.

Zig

zig build-exe -O Debug 

CMake

# `CMakeLists.txt` can require hard to understand stuff like `set(CMAKE_BUILD_TYPE "Release" CACHE STRING FORCE)` for debugging.
cmake -DCMAKE_BUILD_TYPE="Debug" # keep it simple. `RelWithDebInfo` also an option

Meson

meson setup buildfolder ----buildtype debug # default is `debug`
meson configure ----buildtype `debug|debugoptimized` # default is debug