By default, gcc
will add symbol table to the executable, so gdb
will get a readable stack trace.
Documentation for -ggdb1
option in gcc
man page says:
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.
...which looks to me the same as just calling gcc
without any debug-related arguments. But there are clearly extra symbols emitted (.debug_frame
, .debug_str
, .debug_loc
).
So what exactly is the difference, and is there any benefit of compiling with -ggdb1
as opposed to simply not stripping the executable?