Re: macros, debug information, and parse_macro_definition

Jim Blandy
2003-05-02T19:21:21Z

Andrew Cagney <ac131313@redhat.com> writes:

> > These encodings are simple enough that I wouldn't expect them to
> > change over time.
> > I would think it more likely that there would be a bug, either in
> > gcc's encoding of them or in gdb's processing of them. And if the
> > code is duplicated, then both locations need to be modified to fix the
> > bug -- with the attendant risk that someone will modify one and forget
> > to modify the other. Or will modify it, but accidentally make it
> > slightly different.
>
>
> > I don't know how people would feel about having STABS have a
> > description of the encoding combined with a caveat that the DWARF
> > 2.0.0 spec is authoritative. I would certainly prefer that the STABS
> > document remain self contained.
>
> I think this is a good strategy. It's already a ``gcc extension'',
> and stealing an existing (known to be working) spec is always a good
> strategy :-)
>
> Have you thought about link time information compression? One of the
> complaints leveled at the macro stuff is the size of the resultant
> debug info.

Actually, I think that David's proposed representation will compress
really well, with no new linker work. The linker's current behavior
will do everything that's needed.

Each entry in the .stab section is a fixed-size record; the textual
portion of the stab is represented as an offset into the .stabstr
section, which contains null-terminated strings. The .stabstr section
is a SHT_STRTAB type section, which means that the linker will
automatically factor out duplicates. So if two .stab entries have the
same text, they'll end up pointing to the same bytes in .stabstr in
the final executable.

In David's proposed representation, #including a file into many
different .o files will produce stabs entries with identical strings,
so they'll all get factored out nicely.

All this is completely independent of the BINCL/EINCL -> EXCL
compression the linker also does for STABS, to factor out duplicated
entries from the .stab section itself.