|
From: Carlo W. <li...@us...> - 2002-01-09 16:16:18
|
CVSROOT : /cvsroot/libcw
Module : src
Commit time: 2002-00-09 16:16:14 UTC
Modified files:
libcwd/demangle.cc libcwd/demangle3.cc
libcwd/testsuite/libcwd.tst/demangler.cc
libcwd/testsuite/libcwd.tst/demangler.re
Log message:
Bug fix in demangle.cc.
Added a demangler test for the case that triggered the bug.
Note that this same variable makes gdb-5 core dump
(see: http://sources.redhat.com/ml/bug-binutils/2002-q1/msg00021.html)
---------------------- diff included ----------------------
Index: src/libcwd/demangle.cc
diff -u src/libcwd/demangle.cc:1.23 src/libcwd/demangle.cc:1.24
--- src/libcwd/demangle.cc:1.23 Sat Dec 29 20:17:46 2001
+++ src/libcwd/demangle.cc Wed Jan 9 08:16:04 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/demangle.cc,v 1.23 2001/12/30 04:17:46 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/demangle.cc,v 1.24 2002/01/09 16:16:04 libcw Exp $
//
// Copyright (C) 2000 - 2001, by
//
@@ -24,6 +24,9 @@
//
// Currently this file has been tested with gcc-2.95.2 and gcc-2.96 (RedHat).
//
+// For a standalone demangler, compile this file as:
+// g++ -pthread -DSTANDALONE -DCWDEBUG -Iinclude demangle.cc -Wl,-rpath,`pwd`/.libs -L.libs -lcwd -o c++filt
+//
#undef CPPFILTCOMPATIBLE
@@ -798,12 +801,12 @@
// `input' is of the form
//
- // [m]<digit>
+ // [m]<digit>[<digit>...]
// _[m]<digit>[<digit>...]_
//
- bool just_one_digit = (*input != '_');
- if (!just_one_digit)
+ bool underscore = (*input == '_');
+ if (underscore)
++input;
bool is_negative = (*input == 'm' && numeric_limits<INTEGRAL_TYPE>::is_signed);
if (is_negative)
@@ -830,7 +833,7 @@
x = x * 10 - (*input - '0');
output += *input;
}
- while (isdigit(*++input) && !just_one_digit);
+ while (isdigit(*++input));
else
do
{
@@ -839,7 +842,10 @@
x = x * 10 + (*input - '0');
output += *input;
}
- while (isdigit(*++input) && !just_one_digit);
+ while (isdigit(*++input));
+
+ if (underscore && *input == '_')
+ ++input;
#ifndef CPPFILTCOMPATIBLE
if (!numeric_limits<INTEGRAL_TYPE>::is_signed)
Index: src/libcwd/demangle3.cc
diff -u src/libcwd/demangle3.cc:1.12 src/libcwd/demangle3.cc:1.13
--- src/libcwd/demangle3.cc:1.12 Sat Dec 29 20:17:46 2001
+++ src/libcwd/demangle3.cc Wed Jan 9 08:16:04 2002
@@ -1,4 +1,4 @@
-// $Header: /cvsroot/l/li/libcw/src/libcwd/demangle3.cc,v 1.12 2001/12/30 04:17:46 libcw Exp $
+// $Header: /cvsroot/l/li/libcw/src/libcwd/demangle3.cc,v 1.13 2002/01/09 16:16:04 libcw Exp $
//
// Copyright (C) 2001, by
//
@@ -36,6 +36,9 @@
//
// The description of how the mangling is done in the new ABI was found on
// http://www.codesourcery.com/cxx-abi/abi.html#mangling
+//
+// To compile a standalone demangler:
+// g++ -pthread -DSTANDALONE -DCWDEBUG -Iinclude demangle3.cc -Wl,-rpath,`pwd`/.libs -L.libs -lcwd -o c++filt
//
#undef CPPFILTCOMPATIBLE
Index: src/libcwd/testsuite/libcwd.tst/demangler.cc
diff -u src/libcwd/testsuite/libcwd.tst/demangler.cc:1.7 src/libcwd/testsuite/libcwd.tst/demangler.cc:1.8
--- src/libcwd/testsuite/libcwd.tst/demangler.cc:1.7 Sat Dec 29 20:17:51 2001
+++ src/libcwd/testsuite/libcwd.tst/demangler.cc Wed Jan 9 08:16:04 2002
@@ -18,7 +18,8 @@
"foo__FiPiPPiPPPiPPPPiPPPPPiPPPPPPiPPPPPPPiPPPPPPPPiPPPPPPPPPiPPPPPPPPPPiPPPPPPPPPPPiPPPPPPPPPPPPiPPPPPPPPPPPPPiPPPPPPPPPPPPPPiPPPPPPPPPPPPPPPi",
"B__H3Zt1D3ZP1AZRCP1AZPCP1AZt1D3ZP1AZRP1AZPP1AZP1A_X01X01X11PX21_t1D3ZX21ZRX21ZPX21",
"SKIPPED",
- "_X11TransParseAddress"
+ "_X11TransParseAddress",
+ "_t13_Alloc_traits2Zt12basic_string3ZcZt18string_char_traits1ZcZQ45libcw5debug9_private_t17allocator_adaptor3ZcZt24__default_alloc_template2b0i327664b1ZQ45libcw5debug9_private_t17allocator_adaptor3Zt12basic_string3ZcZt18string_char_traits1ZcZQ45libcw5debug9_private_t17allocator_adaptor3ZcZt24__default_alloc_template2b0i327664b1Zt24__default_alloc_template2b0i327664b1._S_instanceless"
};
#else
char const* test_cases [] = {
@@ -33,7 +34,8 @@
"_Z3fooiPiPS_PS0_PS1_PS2_PS3_PS4_PS5_PS6_PS7_PS8_PS9_PSA_PSB_PSC_",
"_ZSt1BISt1DIP1ARKS2_PS3_ES0_IS2_RS2_PS2_ES2_ET0_T_SB_SA_PT1_",
"_ZngILi42EEvN1AIXplT_Li2EEE1TE",
- "_X11TransParseAddress"
+ "_X11TransParseAddress",
+ "_ZNSt13_Alloc_traitsISbIcSt18string_char_traitsIcEN5libcw5debug9_private_17allocator_adaptorIcSt24__default_alloc_templateILb0ELi327664EELb1EEEENS5_IS9_S7_Lb1EEEE15_S_instancelessE"
};
#endif
@@ -303,5 +305,57 @@
}
#endif
+
+namespace std {
+ template<bool b, int i>
+ class __default_alloc_template { };
+
+ template<typename CHAR>
+ class string_char_traits { };
+
+ template<class BASIC_STRING, class ADAPTOR>
+ struct _Alloc_traits {
+ static char _S_instanceless;
+ };
+ template<class BASIC_STRING, class ADAPTOR>
+ char _Alloc_traits<BASIC_STRING, ADAPTOR>::_S_instanceless;
+}
+namespace libcw {
+ namespace debug {
+ namespace _private_ {
+ template<typename CHAR, class ALLOCATOR, bool b>
+ class allocator_adaptor { };
+ }
+ }
+}
+
+void q(void)
+{
+ std::_Alloc_traits<
+ std::basic_string<
+ char,
+ std::string_char_traits<char>,
+ libcw::debug::_private_::allocator_adaptor<
+ char,
+ std::__default_alloc_template<false, 327664>,
+ true
+ >
+ >,
+ libcw::debug::_private_::allocator_adaptor<
+ std::basic_string<
+ char,
+ std::string_char_traits<char>,
+ libcw::debug::_private_::allocator_adaptor<
+ char,
+ std::__default_alloc_template<false, 327664>,
+ true
+ >
+ >,
+ std::__default_alloc_template<false, 327664>,
+ true
+ >
+ > dummy1;
+ char x = dummy1._S_instanceless;
+}
#endif // INSTANTIATE
Index: src/libcwd/testsuite/libcwd.tst/demangler.re
diff -u src/libcwd/testsuite/libcwd.tst/demangler.re:1.8 src/libcwd/testsuite/libcwd.tst/demangler.re:1.9
--- src/libcwd/testsuite/libcwd.tst/demangler.re:1.8 Tue Jan 8 18:20:52 2002
+++ src/libcwd/testsuite/libcwd.tst/demangler.re Wed Jan 9 08:16:04 2002
@@ -16,3 +16,4 @@
(std::)*D<A\*, A\*&, A\*\*> (std::)*B<(std::)*D<A\*, A\* const&, A\* const\*>, (std::)*D<A\*, A\*&, A\*\*>, A\*>\((std::)*D<A\*, A\* const&, A\* const\*>, (std::)*D<A\*, A\* const&, A\* const\*>, (std::)*D<A\*, A\*&, A\*\*>, A\*\*\)
(void operator-<42>\(A<\(42\) \+ \(2\)>::T\)|SKIPPED)
_X11TransParseAddress
+(std::)*_Alloc_traits<(std::)*basic_string<char, (std::)*string_char_traits<char>, libcw::debug::_private_::allocator_adaptor<char, (std::)*__default_alloc_template<false, 327664>, true> >, libcw::debug::_private_::allocator_adaptor<(std::)*basic_string<char, (std::)*string_char_traits<char>, libcw::debug::_private_::allocator_adaptor<char, (std::)*__default_alloc_template<false, 327664>, true> >, (std::)*__default_alloc_template<false, 327664>, true> >::_S_instanceless
----------------------- End of diff -----------------------
|