public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Make cxxfilt demangle internal-linkage templates
@ 2013-08-07 18:51 Paul Pluzhnikov
  2013-08-17  2:12 ` Paul Pluzhnikov
  2013-10-10 21:35 ` Ian Lance Taylor
  0 siblings, 2 replies; 9+ messages in thread
From: Paul Pluzhnikov @ 2013-08-07 18:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: ppluzhnikov, richardsmith

Greetings,

I've been redirected here from binutils:
http://sourceware.org/ml/binutils/2013-08/msg00052.html
http://sourceware.org/ml/binutils/2013-08/msg00056.html

The following source:

  template<typename T> static void f();
  void g() { f<int>(); }

results in "_Z1fIiEvv" under g++, but in "_ZL1fIiEvv" under clang.

Richard Smith says:

  The ABI doesn't cover manglings for local symbols ...
  ... and c++filt is not able to cope with the L prefix here.

  I'm having a hard time seeing how this isn't a g++ bug and a matching
  c++filt bug.

It's hard for me to argue that this is a 'g++' bug (since there is no
ABI violation here), but c++filt should be able to handle this, and does
with attached patch.

Ok for trunk?

Thanks,

Google ref: b/10137049
---
Paul Pluzhnikov


2013-08-07  Paul Pluzhnikov  <ppluzhnikov@google.com>

	* cp-demangle.c (d_name): Handle internal-linkage templates.
	* testsuite/demangle-expected: New case.


Index: libiberty/testsuite/demangle-expected
===================================================================
--- libiberty/testsuite/demangle-expected	(revision 201577)
+++ libiberty/testsuite/demangle-expected	(working copy)
@@ -4291,3 +4291,6 @@
 --format=gnu-v3
 _Z1nIM1AKFvvREEvT_
 void n<void (A::*)() const &>(void (A::*)() const &)
+--format=gnu-v3
+_ZL1fIiEvv
+void f<int>()
Index: libiberty/cp-demangle.c
===================================================================
--- libiberty/cp-demangle.c	(revision 201577)
+++ libiberty/cp-demangle.c	(working copy)
@@ -1276,7 +1276,6 @@
     case 'Z':
       return d_local_name (di);
 
-    case 'L':
     case 'U':
       return d_unqualified_name (di);
 
@@ -1323,6 +1322,7 @@
 	return dc;
       }
 
+    case 'L':
     default:
       dc = d_unqualified_name (di);
       if (d_peek_char (di) == 'I')

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Make cxxfilt demangle internal-linkage templates
  2013-08-07 18:51 [patch] Make cxxfilt demangle internal-linkage templates Paul Pluzhnikov
@ 2013-08-17  2:12 ` Paul Pluzhnikov
       [not found]   ` <CALoOobMQG+zsjTtShhNw+w=6qHbmQgfcO5-BPjNLsh0MwPf1DQ@mail.gmail.com>
  2013-10-10 21:35 ` Ian Lance Taylor
  1 sibling, 1 reply; 9+ messages in thread
From: Paul Pluzhnikov @ 2013-08-17  2:12 UTC (permalink / raw)
  To: gcc-patches; +Cc: ppluzhnikov, richardsmith

Ping?

On Wed, Aug 7, 2013 at 11:51 AM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:

> The following source:
>
>   template<typename T> static void f();
>   void g() { f<int>(); }
>
> results in "_Z1fIiEvv" under g++, but in "_ZL1fIiEvv" under clang.
>
> Richard Smith says:
>
>   The ABI doesn't cover manglings for local symbols ...
>   ... and c++filt is not able to cope with the L prefix here.
>
>   I'm having a hard time seeing how this isn't a g++ bug and a matching
>   c++filt bug.


-- 
Paul Pluzhnikov

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Make cxxfilt demangle internal-linkage templates
       [not found]   ` <CALoOobMQG+zsjTtShhNw+w=6qHbmQgfcO5-BPjNLsh0MwPf1DQ@mail.gmail.com>
@ 2013-09-11 22:51     ` Paul Pluzhnikov
  2013-09-18 20:21       ` Paul Pluzhnikov
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Pluzhnikov @ 2013-09-11 22:51 UTC (permalink / raw)
  To: gcc-patches

Ping x2?

Original message:
http://gcc.gnu.org/ml/gcc-patches/2013-08/msg00394.html

On Fri, Aug 16, 2013 at 6:10 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
> Ping?


--
Paul Pluzhnikov

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Make cxxfilt demangle internal-linkage templates
  2013-09-11 22:51     ` Paul Pluzhnikov
@ 2013-09-18 20:21       ` Paul Pluzhnikov
  2013-09-19  0:04         ` Paolo Carlini
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Pluzhnikov @ 2013-09-18 20:21 UTC (permalink / raw)
  To: gcc-patches

Ping x3?

2013/9/11 Paul Pluzhnikov <ppluzhnikov@google.com>:
> Ping x2?
>
> Original message:
> http://gcc.gnu.org/ml/gcc-patches/2013-08/msg00394.html

Thanks,
-- 
Paul Pluzhnikov

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Make cxxfilt demangle internal-linkage templates
  2013-09-18 20:21       ` Paul Pluzhnikov
@ 2013-09-19  0:04         ` Paolo Carlini
  2013-10-10 19:31           ` Paul Pluzhnikov
  0 siblings, 1 reply; 9+ messages in thread
From: Paolo Carlini @ 2013-09-19  0:04 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: gcc-patches, Ian Lance Taylor

Hi,

On 09/18/2013 09:23 PM, Paul Pluzhnikov wrote:
> Ping x3?
>
> 2013/9/11 Paul Pluzhnikov <ppluzhnikov@google.com>:
>> Ping x2?
>>
>> Original message:
>> http://gcc.gnu.org/ml/gcc-patches/2013-08/msg00394.html
>
I'm adding Ian in CC.

Paolo.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Make cxxfilt demangle internal-linkage templates
  2013-09-19  0:04         ` Paolo Carlini
@ 2013-10-10 19:31           ` Paul Pluzhnikov
  0 siblings, 0 replies; 9+ messages in thread
From: Paul Pluzhnikov @ 2013-10-10 19:31 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: gcc-patches, Ian Lance Taylor

Ian?

Ping x4.

On Wed, Sep 18, 2013 at 4:24 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:

>>> Original message:
>>> http://gcc.gnu.org/ml/gcc-patches/2013-08/msg00394.html
>>
>>
> I'm adding Ian in CC.



-- 
Paul Pluzhnikov

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Make cxxfilt demangle internal-linkage templates
  2013-08-07 18:51 [patch] Make cxxfilt demangle internal-linkage templates Paul Pluzhnikov
  2013-08-17  2:12 ` Paul Pluzhnikov
@ 2013-10-10 21:35 ` Ian Lance Taylor
  1 sibling, 0 replies; 9+ messages in thread
From: Ian Lance Taylor @ 2013-10-10 21:35 UTC (permalink / raw)
  To: Paul Pluzhnikov; +Cc: gcc-patches, Richard Smith

On Wed, Aug 7, 2013 at 11:51 AM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
>
> The following source:
>
>   template<typename T> static void f();
>   void g() { f<int>(); }
>
> results in "_Z1fIiEvv" under g++, but in "_ZL1fIiEvv" under clang.
>
> Richard Smith says:
>
>   The ABI doesn't cover manglings for local symbols ...
>   ... and c++filt is not able to cope with the L prefix here.
>
>   I'm having a hard time seeing how this isn't a g++ bug and a matching
>   c++filt bug.
>
> It's hard for me to argue that this is a 'g++' bug (since there is no
> ABI violation here), but c++filt should be able to handle this, and does
> with attached patch.

OK, I finally took a look.

The demangler treates _ZL as a local-source-name.  This is not part of
the C++ ABI (http://codesourcery.com/cxx-abi/).  It was added by Geoff
Keating: http://gcc.gnu.org/PR31775,
http://gcc.gnu.org/ml/gcc-patches/2007-05/msg00309.html .

With Geoff's patch the demangling is

_Z <encoding>
  <encoding> => <(data) name>
_Z <(data) name>
  <name> => <unscoped-name>
_Z <unscoped-name>
  <unscoped-name> => <unqualified-name>
_Z <unqualified-name>
  <unqualified-name> => <local-source-name> (not in ABI)
_Z <local-source-name>
  <local-source-name> => L <source-name> [<discriminator>] (not in ABI)
_ZL <source-name> [<discriminator>]
  <source-name> => <number> <identifier>
_ZL1f [<discriminator>]

The discriminator is not present, and at this point we are in trouble
because IiE is extraneous.

But really the demangling should be

_Z <encoding>
  <encoding> => <(data) name>
_Z <(data) name>
  <name> => <unscoped-template-name> <template-args>
_Z <unscoped-template-name> <template-args>
  <unscoped-template-name> => <unscoped-name>
_Z <unscoped-name> <template-args>
  <unscoped-name> => <unqualified-name>
_Z <unqualified-name> <template-args>
  <unqualified-name> => <local-source-name> (not in ABI)
_Z <local-source-name> <template-args>
  <local-source-name> => L <source-name> [<discriminator>] (not in ABI)
_ZL <source-name> [<discriminator>] <template-args>
  <source-name> => <number> <identifier>
_ZL1f [<discriminator>] <template-args>
  [<discriminator>] =>
_ZL1f <template-args>

etc.

So it looks to me like Geoff's original patch was wrong, and your
patch is correct.

So this is OK.

Thanks.

Sorry for ignoring this for so long.

Ian

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Make cxxfilt demangle internal-linkage templates
  2013-08-07 18:34     ` Andrew Pinski
@ 2013-08-07 18:53       ` Paul Pluzhnikov
  0 siblings, 0 replies; 9+ messages in thread
From: Paul Pluzhnikov @ 2013-08-07 18:53 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches, Jan Kratochvil, binutils, richardsmith

On Wed, Aug 7, 2013 at 11:34 AM, Andrew Pinski <pinskia@gmail.com> wrote:

> I think this should also be send to the GCC List as libiberty is
> officially maintained by GCC.

http://gcc.gnu.org/ml/gcc-patches/2013-08/msg00394.html

Thanks,
-- 
Paul Pluzhnikov

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [patch] Make cxxfilt demangle internal-linkage templates
       [not found]   ` <CALoOobNDo+wOD8BkV0wMPGJ=ZLmwyZDBPhtQZYjVyVKwsJj=cw@mail.gmail.com>
@ 2013-08-07 18:34     ` Andrew Pinski
  2013-08-07 18:53       ` Paul Pluzhnikov
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Pinski @ 2013-08-07 18:34 UTC (permalink / raw)
  To: Paul Pluzhnikov, GCC Patches; +Cc: Jan Kratochvil, binutils, richardsmith

On Wed, Aug 7, 2013 at 11:31 AM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
> On Wed, Aug 7, 2013 at 11:09 AM, Jan Kratochvil
> <jan.kratochvil@redhat.com> wrote:
>
>> there should be a new case in:
>>         libiberty/testsuite/demangle-expected
>
> Thanks. I updated the patch.
> --
> Paul Pluzhnikov


I think this should also be send to the GCC List as libiberty is
officially maintained by GCC.

Thanks,
Andrew

>
>
> 2013-08-07  Paul Pluzhnikov  <ppluzhnikov@google.com>
>
>         * cp-demangle.c (d_name): Handle internal-linkage templates.
>         * testsuite/demangle-expected: New case.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-10-10 20:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-07 18:51 [patch] Make cxxfilt demangle internal-linkage templates Paul Pluzhnikov
2013-08-17  2:12 ` Paul Pluzhnikov
     [not found]   ` <CALoOobMQG+zsjTtShhNw+w=6qHbmQgfcO5-BPjNLsh0MwPf1DQ@mail.gmail.com>
2013-09-11 22:51     ` Paul Pluzhnikov
2013-09-18 20:21       ` Paul Pluzhnikov
2013-09-19  0:04         ` Paolo Carlini
2013-10-10 19:31           ` Paul Pluzhnikov
2013-10-10 21:35 ` Ian Lance Taylor
     [not found] <ye6qsiymr0ix.fsf@elbrus2.mtv.corp.google.com>
     [not found] ` <20130807180950.GA23161@host2.jankratochvil.net>
     [not found]   ` <CALoOobNDo+wOD8BkV0wMPGJ=ZLmwyZDBPhtQZYjVyVKwsJj=cw@mail.gmail.com>
2013-08-07 18:34     ` Andrew Pinski
2013-08-07 18:53       ` Paul Pluzhnikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).