====== C++ development cheat sheet ====== ===== gdb ===== Problem ''gdb'' warns about unhandled signal: Program received signal SIGILL, illegal instruction. The solutio is to add a signal handler handle SIGILL pass nostop noprint ===== Sanitizer ===== log to file ASAN_OPTIONS="log_path=asan.log" ./a.out full docs: https://github.com/google/sanitizers/wiki/AddressSanitizerFlags globally for the ''CMakeLists.txt'' project: add_compile_options(-fsanitize=address) add_link_options(-fsanitize=address) for a target: target_compile_options( PRIVATE -fsanitize=address) target_link_options( PRIVATE -fsanitize=address) ==== tsan ==== Problem when executing a binary: FATAL: ThreadSanitizer: unexpected memory mapping 0x5a36aaebd000-0x5a36aafd2000 Sulution, disable ASLR for testing: setarch --addr-no-randomize build/path/to/binary or: sudo sysctl vm.mmap_rnd_bits=30 # 30: partly, 28 totally ==== alternatives ==== declare alternatives: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 20 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 20 sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-12 20 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 30 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 30 sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-13 30 select the right alternatives: sudo update-alternatives --config gcc sudo update-alternatives --config g++ sudo update-alternatives --config gcov