When you would like to enable debug on CMake, you use cmake .. -DCMAKE_BUILD_TYPE=Debug
, but this only sets -g
which is the default debug level.
-glevel Request debugging information and also use level to specify how much information. The default level is 2.
Level 0 produces no debug information at all. Thus, -g0 negates -g.
Level 1 produces minimal information, enough for making backtraces in parts of the program that you don't plan to debug. This includes descriptions of functions and external variables, but no information about local variables and no line numbers.
Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3.
How to make the cmake .. -DCMAKE_BUILD_TYPE=Debug
set -g3
instead of -g
?