Debug format (-g -ggdb -gstabs ...)

Daniel Berlin dan@cgsoftware.com
Sun Apr 22 08:25:00 GMT 2001


Gordon Sadler <gbsadler1@lcisp.com> writes:

> I hope someone can explain this better.
> 
> gdb 5.0 info gdb:
> Support...C...
>  For best results when using GNU C++, use the stabs debugging format.
>  You can select that format explicitly with the `g++' command-line
>  options `-gstabs' or `-gstabs+'.

Remind me to change this, it's completely wrong now.
This was correct about 5 years ago.

> 
> gcc 2.95.3 info gcc:
> Invoking GCC...Debugging Options...
>  
>  `-g'
>       Produce debugging information in the operating system's native
>       format (stabs, COFF, XCOFF, or DWARF).  GDB can work with this
>       debugging information.
> 
>       On most systems that use stabs format, `-g' enables use of extra
>       debugging information that only GDB can use; this extra information
>       makes debugging work better in GDB but will probably make other
>       debuggers crash or refuse to read the program.  If you want to
>       control for certain whether to generate the extra information, use
>       `-gstabs+', `-gstabs', `-gxcoff+', `-gxcoff', `-gdwarf-1+', or
>       `-gdwarf-1' (see below).
> ...
> 
> `-ggdb'
>      Produce debugging information for use by GDB.  This means to use
>      the most expressive format available (DWARF 2, stabs, or the
>      native format if neither of those are supported), including GDB
>      extensions if at all possible.
> 
> My understanding:
> 1. Using -g is the standard if you use gdb.
> 2. Using -ggdb should provide even more/better info for gdb to use.
> 3. gdb wants/uses -gstabs{+} for c++.

Not since about 5 years ago.

> 
> cat test.cpp
> #include<stdio.h>
>  
>  int main()
>  {
>      printf("hello ... \n");
>      return 0;
>  }
> 
> ls -l a.out ggdb gstabs* dwarf2
> -rwxr-xr-x    1 gbsadler gbsadler    17773 Apr 22 01:25 a.out
> -rwxr-xr-x    1 gbsadler gbsadler    15345 Apr 22 01:31 dwarf2
> -rwxr-xr-x    1 gbsadler gbsadler    15345 Apr 22 01:26 ggdb
> -rwxr-xr-x    1 gbsadler gbsadler    14261 Apr 22 01:26 gstabs
> -rwxr-xr-x    1 gbsadler gbsadler    17773 Apr 22 01:26 gstabs_p
> 
> a.out    is -g
> dwarf2   is -gdwarf-2
> ggdb     is -ggdb
> gstabs   is -gstabs
> gstabs_p is -gstabs+
> 
> So, apparently -g does use/produce a file with gstabs+. My question is,
> why then does -ggdb not use gstabs+ for c++? 
Because whoever thought STABS was good for C++ was on the crack pipe.
> Is -ggdb misdocumented?
> Apparently -ggdb uses dwarf2... Is this 'correct'?
Yes.

> 
> Same results with gcc (2.95.3) and test.c (test.cpp renamed).
> 
> Gordon Sadler
> 

-- 
"Last year I went fishing with Salvador Dali.  He was using a
dotted line.  He caught every other fish.
"-Steven Wright



More information about the Gcc mailing list