tl;dr: To answer your specific question, -g3
"includes extra information such as macro definitions... Some debuggers support macro expansion when you use -g3
", while -g
does not include this extra information.
The broader answer is that gcc supports four levels of debug information, from -g0
(debug information disabled) through -g3
(maximum debug information).
Specifying -g
is equivalent to -g2
. Curiously, the gcc docs say little about what information -g
/-g2
includes or excludes:
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, and line number tables, but no information about local variables.
Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3.