demangle.h (demangle<Allocator>::symbol(char const*)): Decode symbols that start with _GLOBAL_[ID]_ differently...

* include/bits/demangle.h (demangle<Allocator>::symbol(char const*)):
Decode symbols that start with _GLOBAL_[ID]_ differently: the
trailing part ends with a terminating zero and is not necessarily an
encoding.
* src/demangle.cc (): Same.
* testsuite/demangle/regression/cw-13.cc: Adjust for new output.

From-SVN: r72027
This commit is contained in:
Carlo Wood 2003-10-02 14:29:26 +00:00 committed by Carlo Wood
parent 28a6085042
commit 4a035cf7ea
4 changed files with 17 additions and 13 deletions

View File

@ -1,3 +1,12 @@
2003-10-02 Carlo Wood <carlo@alinoe.com>
* include/bits/demangle.h (demangle<Allocator>::symbol(char const*)):
Decode symbols that start with _GLOBAL_[ID]_ differently: the
trailing part ends with a terminating zero and is not necessarily an
encoding.
* src/demangle.cc (): Same.
* testsuite/demangle/regression/cw-13.cc: Adjust for new output.
2003-10-02 Paolo Carlini <pcarlini@unitus.it>
* testsuite/22_locale/locale/cons/12438.cc: Use

View File

@ -2293,7 +2293,7 @@ namespace __gnu_cxx
demangle<Allocator>::symbol(char const* input)
{
// <mangled-name> ::= _Z <encoding>
// <mangled-name> ::= _GLOBAL_ _<type>_ _Z <encoding>
// <mangled-name> ::= _GLOBAL_ _<type>_ <disambiguation part>
// <type> can be I or D (GNU extension)
typedef demangler::session<Allocator> demangler_type;
string_type result;
@ -2305,16 +2305,14 @@ namespace __gnu_cxx
{
if (!strncmp(input, "_GLOBAL__", 9)
&& (input[9] == 'D' || input[9] == 'I')
&& input[10] == '_' && input[11] == '_' && input[12] == 'Z')
&& input[10] == '_')
{
if (input[9] == 'D')
result.assign("global destructors keyed to ", 28);
else
result.assign("global constructors keyed to ", 29);
int cnt = demangler_type::decode_encoding(result, input + 13,
INT_MAX);
if (cnt < 0 || input[cnt + 13] != 0)
failure = true;
// Output the disambiguation part as-is.
result += input + 11;
}
else
failure = true;

View File

@ -130,17 +130,14 @@ namespace __cxxabiv1
// Possible _GLOBAL__ extension?
if (!std::strncmp(mangled_name, "_GLOBAL__", 9)
&& (mangled_name[9] == 'D' || mangled_name[9] == 'I')
&& mangled_name[10] == '_' && mangled_name[11] == '_'
&& mangled_name[12] == 'Z')
&& mangled_name[10] == '_')
{
if (mangled_name[9] == 'D')
result.assign("global destructors keyed to ", 28);
else
result.assign("global constructors keyed to ", 29);
int cnt = session_type::
decode_encoding(result, mangled_name + 13, INT_MAX);
if (cnt < 0 || mangled_name[cnt + 13] != 0)
return failure(invalid_mangled_name, status);
// Output the disambiguation part as-is.
result += mangled_name + 11;
return finish(result.data(), result.size(), buf, n, status);
}
}

View File

@ -28,7 +28,7 @@ int main()
using namespace __gnu_test;
// cplus-dem CORE
verify_demangle("_GLOBAL__I__Z2fnv", "global constructors keyed to fn()");
verify_demangle("_GLOBAL__I__Z2fnv", "global constructors keyed to _Z2fnv");
return 0;
}