This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: difference between -g, -ggdb and -ggdb3


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]