From 4a035cf7eadf0bef3e972323e15d234d5ec4ded6 Mon Sep 17 00:00:00 2001 From: Carlo Wood Date: Thu, 2 Oct 2003 14:29:26 +0000 Subject: [PATCH] demangle.h (demangle::symbol(char const*)): Decode symbols that start with _GLOBAL_[ID]_ differently... * include/bits/demangle.h (demangle::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 --- libstdc++-v3/ChangeLog | 9 +++++++++ libstdc++-v3/include/bits/demangle.h | 10 ++++------ libstdc++-v3/src/demangle.cc | 9 +++------ libstdc++-v3/testsuite/demangle/regression/cw-13.cc | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8a76c07f1dd..9abb29f0fd4 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2003-10-02 Carlo Wood + + * include/bits/demangle.h (demangle::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 * testsuite/22_locale/locale/cons/12438.cc: Use diff --git a/libstdc++-v3/include/bits/demangle.h b/libstdc++-v3/include/bits/demangle.h index 9b1ff0fdb66..e5481b332cd 100644 --- a/libstdc++-v3/include/bits/demangle.h +++ b/libstdc++-v3/include/bits/demangle.h @@ -2293,7 +2293,7 @@ namespace __gnu_cxx demangle::symbol(char const* input) { // ::= _Z - // ::= _GLOBAL_ __ _Z + // ::= _GLOBAL_ __ // can be I or D (GNU extension) typedef demangler::session 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; diff --git a/libstdc++-v3/src/demangle.cc b/libstdc++-v3/src/demangle.cc index 24d7009a623..fc5672bb0ed 100644 --- a/libstdc++-v3/src/demangle.cc +++ b/libstdc++-v3/src/demangle.cc @@ -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); } } diff --git a/libstdc++-v3/testsuite/demangle/regression/cw-13.cc b/libstdc++-v3/testsuite/demangle/regression/cw-13.cc index ec883be1de3..606eb9c257d 100644 --- a/libstdc++-v3/testsuite/demangle/regression/cw-13.cc +++ b/libstdc++-v3/testsuite/demangle/regression/cw-13.cc @@ -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; }