runtime mangling API

Alex Samuel samuel at codesourcery.com
Fri Aug 25 22:36:45 UTC 2000


Folks,

Here's some correspondence between Ulrich Drepper and me regarding
runtime mangling.  I forgot to CC the cxx-abi list.

------------------------------------------------------------------------
From: Alex Samuel <samuel at codesourcery.com>
To: drepper at cygnus.com (Ulrich Drepper)
Subject: Re: runtime demangler API

Ulrich Drepper <drepper at redhat.com> writes:

  Ulrich> Sorry to step in without really follwoing the discussion.  I
  Ulrich> just want to make sure you also have a runtime mangler
  Ulrich> interface.  This is needed to handle dlsym() + C++.

I'm not sure what you mean.  Do you mean a text-to-text mangling API?
Is this possible even in principal?

Regards
Alex Samuel

------------------------------------------------------------------------
From: Ulrich Drepper <drepper at redhat.com>
To: Alex Samuel <samuel at codesourcery.com>
Subject: Re: runtime demangler API

Alex Samuel <samuel at codesourcery.com> writes:

> I'm not sure what you mean.  Do you mean a text-to-text mangling API?

Yes.  I'm calling

	char **arr;
	mangle (buf, bufsize, "intfoo(int)", &arr)

and get an array with the possible mangled names back.  Due to the
wide variety of possible mangling schemes it probably should be
allowed to return more than one.

> Is this possible even in principal?

The compiler does it, so why shouldn't it be possible at runtime?

------------------------------------------------------------------------
From: Alex Samuel <samuel at codesourcery.com>
To: drepper at cygnus.com (Ulrich Drepper)
Subject: Re: runtime demangler API

Ulrich Drepper <drepper at redhat.com> writes:

  Ulrich> The compiler does it, so why shouldn't it be possible at
  Ulrich> runtime?

I understand the need for it, but the compiler has a lot more context
that a text-to-text mangling function will not.  

In your example, for instance, you'd need to specify at least the full
scope of all names, as in

    mangle (buf, bufsize, "int ::foo(int)", &arr);

Here's a more insidious example.  In this code,

    template<int I> class C {};
    void foo (C<1>) {}

foo is mangled `_Z3foo1CILi1EE', but in this code,

    template<short I> class C {};
    void foo (C<1>) {}

it's mangled `_Z3foo1CILs1EE'.  Which do you expect to get back from

    mangle (buf, bufsize, "void ::foo(::C<1>)", &arr);

?  There are a lot more examples like this where you'll have to supply
a lot more information in the name than you normally would.
Furthermore, preprocessor macros will not be visible, which can make
things even more confusing.

Even if we can sort all this out, do we want to link most of a C++
parser into programs?

Regards
Alex

------------------------------------------------------------------------
From: Ulrich Drepper <drepper at redhat.com>
To: Alex Samuel <samuel at codesourcery.com>
Subject: Re: runtime demangler API

Alex Samuel <samuel at codesourcery.com> writes:

> ?  There are a lot more examples like this where you'll have to supply
> a lot more information in the name than you normally would.
> Furthermore, preprocessor macros will not be visible, which can make
> things even more confusing.
> 
> Even if we can sort all this out, do we want to link most of a C++
> parser into programs?

Make it a library function which people can use.  I get requests for
things like this since people don't want to know the mangled name.  If
it's not possible: fine.





More information about the cxx-abi-dev mailing list