One. Ubuntu system, using the GDB debug program, the method is as follows:
1) Compile the source code, GDB can only debug executable files. If you compile a C + + program with CMake, you need to add the following flag to the CMakeLists.txt, which provides basic debugging information and intermediate variable information during debugging.
Set (gcc_coverage_compile_flags "-G") Set (Cmake_cxx_flags "${cmake_cxx_flags} ${gcc_coverage_compile_flags}")
2) terminal jump to the directory where the compiled executable file is located, run gdb xxxx to start debugging the program.
Two. Debug multi-threaded threads
When I used GDB to debug multi-threaded threads, the error "interrupted system call", I referred to 37906091
Workaround: Set GDB to Non-stop mode, set as follows.
Open ~/.gdbinit (If you don't have this file, create a new document of the same name yourself), then add three lines.
set target-async 1set pagination offset non-stop on
< incurable diseases >GDB debugging multithreaded Program error: Interrupted system call