This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- From: Michael Matz <matz at suse dot de>
- To: Daniel Jacobowitz <drow at false dot org>
- Cc: Richard Guenther <rguenther at suse dot de>, Jason Merrill <jason at redhat dot com>, Gabriel Dos Reis <gdr at cs dot tamu dot edu>, Nathan Sidwell <nathan at codesourcery dot com>, Mark Mitchell <mark at codesourcery dot com>, Richard Guenther <richard dot guenther at gmail dot com>, gcc-patches at gcc dot gnu dot org, mrs at apple dot com, Paolo Carlini <pcarlini at suse dot de>
- Date: Tue, 12 Dec 2006 18:45:33 +0100 (CET)
- Subject: Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- References: <457D726E.7060905@redhat.com> <Pine.LNX.4.64.0612111628100.3105@zhemvz.fhfr.qr> <Pine.GSO.4.58.0612110926270.19022@sun> <Pine.LNX.4.64.0612111635030.3105@zhemvz.fhfr.qr> <457D7AB1.10706@redhat.com> <Pine.LNX.4.64.0612111647520.3105@zhemvz.fhfr.qr> <20061211155733.GA2660@nevyn.them.org> <Pine.LNX.4.64.0612111658590.29962@wotan.suse.de> <20061211174548.GA7094@nevyn.them.org> <Pine.LNX.4.64.0612121519200.29962@wotan.suse.de> <20061212150652.GA18750@nevyn.them.org>
Hi,
On Tue, 12 Dec 2006, Daniel Jacobowitz wrote:
> What else do you expect to happen?
Since you asked ;-) :
For starters I wouldn't output default args. I.e. given these decls:
template <typename T> class X {};
template <typename T> class Y {};
template <typename T> class Z {};
template <typename T, typename H=X<T>, typename I=Y<T>, typename J=Z<T>>
class A {};
template <typename T, typename H=A<T>, typename I=A<A<T>>>
class B {};
B<int> an_object;
I wouldn't like to see the type of 'an_object' in the debugger to be shown
as (and I cite):
"B<int,A<int, X<int>, Y<int>, Z<int> >,A<A<int, X<int>, Y<int>,
Z<int> >, X<A<int, X<int>, Y<int>, Z<int> > >, Y<A<int, X<int>, Y<int>,
Z<int> > >, Z<A<int, X<int>, Y<int>, Z<int> > > > >"
That is just kafkaesque. I would accept "B<int>" or "B" (I would prefer
for the debugger to give me both possibilities). I wouldn't like to have
to store the above abomination into debug infos as I can foresee no
sensible use for that which justifies the space bloat (in object files
_and_ debugger runtime memory use).
Further I wouldn't transitively elaborate the type, but only look at depth
1 (think template meta programming). I can see uses for someone who might
want a larger depth (though I'm completely convinced that no human wants
to really look at type names nested deeper than say 10), so that's more
discussable.
Further, I would stop at typedefs. Given the above decls, and adding
this:
typedef B<float> new_B;
B<new_B> another_object;
The type of 'another_object' starts with (I cite again from readelf -wi):
"B<B<float, A<float, X<float>, Y<float>, Z<float> >, A<A<float, X<float>,
Y<float>, Z<float> >, X<A<float, X<float>, Y<float>, Z<float> > >,
Y<A<float, X<float>, Y<float>, Z<float> > >, Z<A<float, X<float>,
Y<float>, Z<float> > > > >,A<B<float, A<float, X<float>, Y<float>,
Z<float> >, A<A<float, X<float>, Y<float>, Z<float> >, X<A<float,
X<float>, Y<float>, Z<float> > >, Y<A<float, X<float>, Y<float>, Z<float>
> >, Z<A<float, X<float>, Y<float>, "
and continues for another 4440 characters. I would want "B<new_B>".
What we currently output is less than useless, it actively hinders
debugging larger C++ programs. Let it be a sign that I actually sometimes
even _wished_ for the debugger to print out mangled names. They certainly
are easier to read and compare via copy&paste. For instance the mangled
name for the above 5KB string is just two lines. Not very good
("B<new_B>" still is nicer) but much better in this case.
> Sure, we could throttle the debug info and omit the name. But that's
> much like reintroducing a 63 character (or however many) limit on unique
> identifiers; the debug info wouldn't unambiguously identify the source
> type.
I claim that for all practical matters a 5000 character string doesn't
identify anything at all, it's just character salad :-) Sometimes limits
are good, one can make it configurable if one absolutely must, but it
seems more sensible to use a compressed form of the name which debuggers
then can decompress in various ways. A mangled representation is a
natural choice, but a DIE based seems to work too (though more complex to
implement).
[I seem to remember that sometimes even now DW_AT_name isn't unambiguous
anyway, sometimes scopes are missing (certainly when declared and used
inside the same namespace, but that's natural, and can be seen from the
nesting context of the DIEs), but I may misremember.]
Ciao,
Michael.
- References:
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory
- Re: [PATCH][C++] Fix PR29433, make C++ use a lot less time/memory