Debug with GDB
GDBE setup - vscode
- Options for Debugging Your Program - at least use
-g
- GDB Dashboard - gdb split view with code interface
CMake
Edit Your CMakeLists.txt: Open the CMakeLists.txt file in the root directory of your project using a text editor.
Add Debug Information Flags: To include debug information, you typically need to add compiler flags. These flags can vary depending on your compiler, but common flags include:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
Reconfigure Your Build: After making changes to the CMakeLists.txt file, you need to reconfigure your build. You can do this by running the following commands in your project’s build directory: cmake ..
Recompile Your Program: After reconfiguring, you should recompile your program. This will rebuild it with the added debug information: make
see also
Written on February 3, 2023, Last update on June 27, 2024
debug-c++
vscode
gdb