-g produces debugging information in the OS¹s native format (stabs, COFF, XCOFF, or DWARF 2).
-ggdb produces debugging information specifically intended for gdb.
-ggdb3 produces extra debugging information, for example: including macro definitions.
-ggdb by itself without specifying the level defaults to -ggdb2 (i.e., gdb for level 2).
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.
If you use multiple -g options, with or without level numbers, the last such option is the one that is effective.
-gdwarf does not accept a concatenated debug level, to avoid confusion with -gdwarf-level. Instead use an additional -glevel option to change the debug level for DWARF.
If we turn on the debugging option, wouldn't it be convenient to debug with level 3?
[`Makefile`](https://github.com/namhyung/uftrace/blob/master/Makefile)
I was curious about the debug options at compile time, so I looked into the gnu documentation.
Re: difference between -g, -ggdb and -ggdb3
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.
If you use multiple -g options, with or without level numbers, the last such option is the one that is effective.
-gdwarf does not accept a concatenated debug level, to avoid confusion with -gdwarf-level. Instead use an additional -glevel option to change the debug level for DWARF.
ifeq ($(DEBUG), 1) COMMON_CFLAGS += -O0 -g -DDEBUG_MODE=1 else COMMON_CFLAGS += -O2 -g -DDEBUG_MODE=0 endif