Re: stabs vs. dwarf-2 for C programs

Daniel Berlin
2001-04-12T19:55:00Z

jtc@redback.com (J.T. Conklin) writes:

> In general, are there any advantages for using dwarf-2 over
> stabs debugging symbols for C (not C++) programs?

Unless you want optimized code debugging, only space savings
(theoretical, of course, right now. For C, anyway).

>
> I did a quick test of rebuilding our system with dwarf-2 debug
> symbols, and found that the image file grew from 35MB to 167MB
> and link times nearly quadrupled,

Sounds right, link time is dominated by disk i/o. The file got 4 times
bigger, the link takes 4 times longer. :)
> so dwarf-2 isn't looking so
> good so far. If I had to guess, it looks like duplicate debug
> info (from headers, etc.) isn't being eliminated as is done
> for stabs.

Correct.
I added support for this to gcc 3.0. It's not currently the default
because gdb, whose dwarf2 reader, being based on
the dwarf1 reader, was wholly unprepared to handle it (It assumes to
only have to process one CU at a time, and only see things inside that
CU. So when you do elimination, and end up with references into other
CU's, it barfs). I've rewritten large parts of the dwarf2 reader to
support it, and hopefully, will submit the work sometime next week,
after i finish adding a few features.

If you want to get an idea of space savings, use -feliminate-dwarf2-dups.

However, it's meant for C++, mainly, i doubt it'll do much for C, if
anything at all.

It's mainly handling the case of duplication caused by real code in
header files, which can't occur in C.

Doing more space saving than that requires implementing the elimination in the
linker, or using a lot of space for labels and whatnot. I tried this
once, but because of how LD works, it's impossible (we don't have
access to the labels offsets and whatnot we need. STABS, has support built
into the format for this type of thing. We don't, and thus, can't
leave these things lying around in the object files, unless we are
guaranteed GNU LD.) It would need to be done as a pre-linker pass run
by ld or something.

>
> --jtc
>
> --
> J.T. Conklin
> RedBack Networks

--
Under my bed I have shoe box full of telephone rings. Whenever
I get lonely I open it up just a bit and I get a call. One time
I dropped the box all over the floor and the phone wouldn't stop
ringing, so I had it disconnected. I bought a new phone though.
I didn't have much money so I had to buy an irregular phone --
it had no number 5 on it. I saw a close friend of mine the
other day... He said, "Steven, why haven't you called me?" I
said, "I can't call everyone I want. My new phone has no five
on it." He said, "How long have you had it?" I said, "I don't
know... My calendar has no sevens on it."