difference between -g, -ggdb and -ggdb3

John (Eljay) Love-Jensen eljay@adobe.com
Wed Feb 18 16:44:00 GMT 2009


Hi lehe,

> I was wondering what the difference between -g, -ggdb and -ggdb3 as option for
gcc?

-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).

It is *possible* (I've heard) that the -ggdb can produce debugging
information that can confuse other debuggers if you are not using gdb.  I
only use gdb, so I cannot confirm or refute that rumor.

So...

If you use gdb, use -ggdb (same as -ggdb2), or -ggdb1 (to help reduce the
debug footprint), or -ggdb3 (for additional debugging info).

If you do not use gdb...

Use -g and keep in mind that gdb works with the OS's native format too.

I use -g even though I use gdb exclusively when I use gcc/g++.  I could use
-ggdb ... but I forget to type those extra three characters.

HTH,
--Eljay



More information about the Gcc-help mailing list