From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: drow@false.org (Daniel Jacobowitz)
Cc: jan.kratochvil@redhat.com (Jan Kratochvil),
gdb-patches@sourceware.org,
keiths@redhat.com (Keith Seitz)
Subject: Re: Is physname mangled or not? (PR c++/8216)
Date: Thu, 05 May 2011 17:10:00 -0000 [thread overview]
Message-ID: <201105051710.p45HA4Ym016889@d06av02.portsmouth.uk.ibm.com> (raw)
In-Reply-To: <20110504175821.GA3141@caradoc.them.org> from "Daniel Jacobowitz" at May 04, 2011 01:58:21 PM
Daniel Jacobowitz wrote:
> On Wed, May 04, 2011 at 07:32:43PM +0200, Ulrich Weigand wrote:
> > It seems that by now we have agreement that GCC is correct here. So I guess
> > I see two options remaining:
> >
> > - Code a test that compares class name and (demangled) function name, but
> > explicitly removes template instance parameters first
> >
> > or
> >
> > - Have the symbol reader call is_constructor_name on the mangled name while
> > it is still available, and store that information somewhere in the type
> > information
> >
> > Thoughts?
>
> I'd suggest the former. Anything you do with mangled names will be
> unexpectedly complex; sometimes you just can't count on having them.
OK, I see. I've done a little more digging through the history, and I guess
I understand a little better why things were done the way they were.
Mostly, it seems to have come down to the problem that some past compilers
used to fill in silly things for the debug data method names of special
methods like constructors (e.g. __comp_ctor). See the long comment in
stabsread.c:read_member_functions.
To work around this, the code tries to "re-create" the proper method name
using a variety of approaches, amongst others by looking at the physname
(which at this point is a mangled name) if present (in stabs).
Mostly, this gets done when the method definition is read in. However, there
are cases where this is apparently not possible, and the method is marked as
a "stub". There is a routine check_stub_method_group that users of the
method list are apparently supposed to call before looking at method names,
which "unstubs" methods and corrects all names as appropriate. This is done
in various places (search_struct_method etc.).
However, there are other places -in particular c_type_print_base, which is
what initially started this discussion- that do *not* call the helper
check_stub_method_group to fix things up. Instead (apparently) those places
try to handle stubbed methods directly, duplicating various parts of what
check_stub_method_group would do (e.g. call gdb_mangle_name).
*This* in turn appears to be the reason why c_type_print_base does the
weird duplicate check for constructors/destructors looking both at the
method name and the physname -- the former is needed because physname
is not always available, the latter is needed because the method name
may be wrong for stubbed methods.
So, if the analysis so far is correct, it would appear to me that the
best way forward is actually to:
- change c_type_print_base (and other places) to actually just call
check_stub_method_group, and then assume the method name is always
correct -- removing all the extra code required for stubbed methods,
including the physname-based constructor/destructor checks
- update the method name based checks to handle templates.
B.t.w. at yet another location in linespec.c:find_methods, an attempt
to handle templates seems to have been made when detecting constructors:
else if (strncmp (class_name, name, name_len) == 0
&& (class_name[name_len] == '\0'
|| class_name[name_len] == '<'))
Does this look reasonable?
Thanks,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
prev parent reply other threads:[~2011-05-05 17:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-03 18:59 Ulrich Weigand
2011-05-04 15:09 ` Jan Kratochvil
2011-05-04 17:00 ` Daniel Jacobowitz
2011-05-04 17:10 ` Jan Kratochvil
2011-05-04 17:33 ` Ulrich Weigand
2011-05-04 17:57 ` Jan Kratochvil
2011-05-04 17:58 ` Daniel Jacobowitz
2011-05-05 17:10 ` Ulrich Weigand [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201105051710.p45HA4Ym016889@d06av02.portsmouth.uk.ibm.com \
--to=uweigand@de.ibm.com \
--cc=drow@false.org \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=keiths@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox