-g
and -ggdb
are similar with some slight differences, I read this here:
-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).