When I use gcc to compile C programs
I usually use -g to get some debug information into the elf file
so that gdb can help me if needed.
However, I not
-g and -ggdb are similar with some slight differences, I read this here:
-gproduces debugging information in the OS¹s native format (stabs, COFF, XCOFF, or DWARF 2).
-ggdbproduces debugging information specifically intended for gdb.
-ggdb3produces extra debugging information, for example: including macro definitions.
-ggdbby itself without specifying the level defaults to-ggdb2(i.e., gdb for level 2).