# Copyright (C) 1992 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

# Please email any bugs, comments, and/or additions to this file to:
# bug-gdb@prep.ai.mit.edu

# This file was written by Fred Fish. (fnf@cygnus.com)

if $tracelevel then {
	strace $tracelevel
}

#
#  Test gnu style name demangling
#

proc test_gnu_style_demangling {} {
    global prompt

    # Set the demangling style to "gnu" and then check to make sure
    # it really got set.  Return if the style failed to get set for
    # some reason.

    send "set demangle-style gnu\n"
    expect {
	-re "set demangle-style gnu\[\r\n\]+$prompt $" {}
	-re ".*$prompt $" { fail "set demangle-style gnu failed" ; return }
	timeout { fail "set demangle-style gnu failed (timeout)" ; return }
    }

    send "show demangle-style\n"
    expect {
	-re "The current C\[+\]+ demangling style is \"gnu\".\r\n$prompt $" {}
	-re ".*$prompt $" { fail "demangling style not set to gnu" }
	timeout { fail "show demangle-style timed out" }
    }

    gdb_test "maint dem Abort__FP6EditoriPCc" \
	"Abort\[(\]+Editor \[*\]+, int, (const char|char const) \[*\]+\[)\]+"
    gdb_test_exact "maint demangle AddAlignment__9ivTSolverUiP12ivInteractorP7ivTGlue" "ivTSolver::AddAlignment(unsigned int, ivInteractor *, ivTGlue *)"
    gdb_test "maint dem Append__15NameChooserViewPCc" \
	"NameChooserView::Append\[(\]+(const char|char const) \[*\]+\[)\]+"
    gdb_test_exact "maint demangle ArrowheadIntersects__9ArrowLineP9ArrowheadR6BoxObjP7Graphic" "ArrowLine::ArrowheadIntersects(Arrowhead *, BoxObj &, Graphic *)"
    gdb_test_exact "maint demangle AtEnd__13ivRubberGroup" "ivRubberGroup::AtEnd(void)"
    gdb_test_exact "maint demangle BgFilter__9ivTSolverP12ivInteractor" "ivTSolver::BgFilter(ivInteractor *)"
    gdb_test "maint dem BitPatterntoa__FRC10BitPatternccc" \
	"BitPatterntoa\[(\]+(const BitPattern|BitPattern const) &, char, char, char\[)\]+"
    gdb_test_exact "maint demangle Check__6UArrayi" "UArray::Check(int)"
    gdb_test_exact "maint demangle CoreConstDecls__8TextCodeR7ostream" "TextCode::CoreConstDecls(ostream &)"
    gdb_test_exact "maint demangle Detach__8StateVarP12StateVarView" "StateVar::Detach(StateVarView *)"
    gdb_test_exact "maint demangle Done__9ComponentG8Iterator" "Component::Done(Iterator)"
    gdb_test "maint dem DrawDestinationTransformedImage__FP7_XImageiiT0iiUlUiiiUiUlUlP4_XGCRC13ivTransformeriiii" \
	"DrawDestinationTransformedImage\[(\]+_XImage \[*\]+, int, int, _XImage \[*\]+, int, int, unsigned long, unsigned int, int, int, unsigned int, unsigned long, unsigned long, _XGC \[*\]+, (const ivTransformer|ivTransformer const) &, int, int, int, int\[)\]+"

    gdb_test "maint dem Edit__12StringEditorPCcii" \
	"StringEditor::Edit\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
    gdb_test_exact "maint demangle Effect__11RelateManipR7ivEvent" "RelateManip::Effect(ivEvent &)"
    gdb_test "maint dem FilterName__FPCc" \
	"FilterName\[(\]+(const char|char const) \[*\]+\[)\]+"
    gdb_test "maint dem Filter__6PSTextPCci" \
	"PSText::Filter\[(\]+(const char|char const) \[*\]+, int\[)\]+"
    gdb_test "maint dem FindColor__7CatalogPCciii" \
	"Catalog::FindColor\[(\]+(const char|char const) \[*\]+, int, int, int\[)\]+"
    gdb_test_exact "maint demangle FindFixed__FRP4CNetP4CNet" "FindFixed(CNet *&, CNet *)"
    gdb_test "maint dem FindFont__7CatalogPCcN21" \
	"Catalog::FindFont\[(\]+(const char|char const) \[*\]+, (const char|char const) \[*\]+, (const char|char const) \[*\]+\[)\]+"
    gdb_test_exact "maint demangle Fix48_abort__FR8twolongs" "Fix48_abort(twolongs &)"
    gdb_test_exact "maint demangle GetBarInfo__15iv2_6_VScrollerP13ivPerspectiveRiT2" "iv2_6_VScroller::GetBarInfo(ivPerspective *, int &, int &)"
    gdb_test_exact "maint demangle GetBgColor__C9ivPainter" "ivPainter::GetBgColor(void) const"

    gdb_test "maint dem Iisdouble__FPC6IntRep" \
	"Iisdouble\[(\]+(const IntRep|IntRep const) \[*\]+\[)\]+"
    gdb_test_exact "maint demangle InsertBody__15H_PullrightMenuii" "H_PullrightMenu::InsertBody(int, int)"
    gdb_test_exact "maint demangle InsertCharacter__9TextManipc" "TextManip::InsertCharacter(char)"

    gdb_test_exact "maint demangle InsertToplevel__7ivWorldP12ivInteractorT1" "ivWorld::InsertToplevel(ivInteractor *, ivInteractor *)"
    gdb_test_exact "maint demangle InsertToplevel__7ivWorldP12ivInteractorT1iiUi" "ivWorld::InsertToplevel(ivInteractor *, ivInteractor *, int, int, unsigned int)"
    gdb_test "maint dem IsADirectory__FPCcR4stat" \
	"IsADirectory\[(\]+(const char|char const) \[*\]+, stat &\[)\]+"
    gdb_test_exact "maint demangle IsAGroup__FP11GraphicViewP11GraphicComp" "IsAGroup(GraphicView *, GraphicComp *)"
    gdb_test_exact "maint demangle IsA__10ButtonCodeUl" "ButtonCode::IsA(unsigned long)"

    gdb_test_exact "maint demangle ReadName__FR7istreamPc" "ReadName(istream &, char *)"
    gdb_test_exact "maint demangle Redraw__13StringBrowseriiii" "StringBrowser::Redraw(int, int, int, int)"
    gdb_test_exact "maint demangle Rotate__13ivTransformerf" "ivTransformer::Rotate(float)"
    gdb_test_exact "maint demangle Rotated__C13ivTransformerf" "ivTransformer::Rotated(float) const"
    gdb_test_exact "maint demangle Round__Ff" "Round(float)"

    gdb_test_exact "maint demangle SetExport__16MemberSharedNameUi" "MemberSharedName::SetExport(unsigned int)"
    gdb_test_exact "maint demangle Set__14ivControlState13ControlStatusUi" "ivControlState::Set(ControlStatus, unsigned int)"
    gdb_test_exact "maint demangle Set__5DFacePcii" "DFace::Set(char *, int, int)"

    gdb_test_exact "maint demangle VConvert__9ivTSolverP12ivInteractorRP8TElementT2" "ivTSolver::VConvert(ivInteractor *, TElement *&, TElement *&)"
    gdb_test_exact "maint demangle VConvert__9ivTSolverP7ivTGlueRP8TElement" "ivTSolver::VConvert(ivTGlue *, TElement *&)"
    gdb_test_exact "maint demangle VOrder__9ivTSolverUiRP12ivInteractorT2" "ivTSolver::VOrder(unsigned int, ivInteractor *&, ivInteractor *&)"
    gdb_test "maint dem Valid__7CatalogPCcRP4Tool" \
	"Catalog::Valid\[(\]+(const char|char const) \[*\]+, Tool \[*\]+&\[)\]+"
    gdb_test_exact "maint demangle _10PageButton\$__both" "PageButton::__both"
    gdb_test_exact "maint demangle _3RNG\$singleMantissa" "RNG::singleMantissa"
    gdb_test_exact "maint demangle _5IComp\$_release" "IComp::_release"
    gdb_test_exact "maint demangle _\$_10BitmapComp" "BitmapComp::~BitmapComp(void)"

    gdb_test_exact "maint demangle _\$_9__io_defs" "__io_defs::~__io_defs(void)"
    gdb_test_exact "maint demangle _\$_Q23foo3bar" "foo::bar::~bar(void)"
    gdb_test_exact "maint demangle _\$_Q33foo3bar4bell" "foo::bar::bell::~bell(void)"
    gdb_test_exact "maint demangle __10ivTelltaleiP7ivGlyph" "ivTelltale::ivTelltale(int, ivGlyph *)"
    gdb_test_exact "maint demangle __10ivViewportiP12ivInteractorUi" "ivViewport::ivViewport(int, ivInteractor *, unsigned int)"
    gdb_test_exact "maint demangle __10ostrstream" "ostrstream::ostrstream(void)"
    gdb_test_exact "maint demangle __10ostrstreamPcii" "ostrstream::ostrstream(char *, int, int)"
    gdb_test "maint dem __11BasicDialogiPCcP13ivButtonStateN22Ui" \
	"BasicDialog::BasicDialog\[(\]+int, (const char|char const) \[*\]+, ivButtonState \[*\]+, (const char|char const) \[*\]+, (const char|char const) \[*\]+, unsigned int\[)\]+"
    gdb_test_exact "maint demangle __11BitmapTablei" "BitmapTable::BitmapTable(int)"
    gdb_test_exact "maint demangle __12ViewportCodeP12ViewportComp" "ViewportCode::ViewportCode(ViewportComp *)"
    gdb_test "maint dem __12iv2_6_BorderiPCci" \
	"iv2_6_Border::iv2_6_Border\[(\]+int, (const char|char const) \[*\]+, int\[)\]+"
    gdb_test_exact "maint demangle __12iv2_6_Borderii" "iv2_6_Border::iv2_6_Border(int, int)"
    gdb_test "maint dem __12ivBackgroundiP7ivGlyphPC7ivColor" \
	"ivBackground::ivBackground\[(\]+int, ivGlyph \[*\]+, (const ivColor|ivColor const) \[*\]+\[)\]+"
    gdb_test_exact "maint demangle __12ivBreak_Listl" "ivBreak_List::ivBreak_List(long)"
    gdb_test "maint dem __14TextInteractoriPCcUi" \
	"TextInteractor::TextInteractor\[(\]+int, (const char|char const) \[*\]+, unsigned int\[)\]+"
    gdb_test_exact "maint demangle __14iv2_6_MenuItemiP12ivInteractor" "iv2_6_MenuItem::iv2_6_MenuItem(int, ivInteractor *)"
    gdb_test "maint dem __14iv2_6_MenuItemiPCcP12ivInteractor" \
	"iv2_6_MenuItem::iv2_6_MenuItem\[(\]+int, (const char|char const) \[*\]+, ivInteractor \[*\]+\[)\]+"

    gdb_test_exact "maint demangle __20DisplayList_IteratorR11DisplayList" "DisplayList_Iterator::DisplayList_Iterator(DisplayList &)"
    gdb_test_exact "maint demangle __3fooRT0" "foo::foo(foo &)"
    gdb_test_exact "maint demangle __3fooiN31" "foo::foo(int, int, int, int)"
    gdb_test "maint dem __3fooiPCc" \
	"foo::foo\[(\]+int, (const char|char const) \[*\]+\[)\]+"
    gdb_test_exact "maint demangle __3fooiRT0iT2iT2" "foo::foo(int, foo &, int, foo &, int, foo &)"
    gdb_test "maint dem __6GetOptiPPcPCc" \
	"GetOpt::GetOpt\[(\]+int, char \[*\]+\[*\]+, (const char|char const) \[*\]+\[)\]+"
    gdb_test_exact "maint demangle __6KeyMapPT0" "KeyMap::KeyMap(KeyMap *)"
    gdb_test "maint dem __7ivWorldPCcRiPPcPC12ivOptionDescPC14ivPropertyData" \
	"ivWorld::ivWorld\[(\]+(const char|char const) \[*\]+, int &, char \[*\]+\[*\]+, (const ivOptionDesc|ivOptionDesc const) \[*\]+, (const ivPropertyData|ivPropertyData const) \[*\]+\[)\]+"
    gdb_test "maint dem __7procbufPCci" \
	"procbuf::procbuf\[(\]+(const char|char const) \[*\]+, int\[)\]+"
    gdb_test_exact "maint demangle __8ArrowCmdP6EditorUiUi" "ArrowCmd::ArrowCmd(Editor *, unsigned int, unsigned int)"

    gdb_test_exact "maint demangle __9F_EllipseiiiiP7Graphic" "F_Ellipse::F_Ellipse(int, int, int, int, Graphic *)"
    gdb_test_exact "maint demangle __9FrameDataP9FrameCompi" "FrameData::FrameData(FrameComp *, int)"
    gdb_test_exact "maint demangle __9HVGraphicP9CanvasVarP7Graphic" "HVGraphic::HVGraphic(CanvasVar *, Graphic *)"
    gdb_test_exact "maint demangle __Q23foo3bar" "foo::bar::bar(void)"
    gdb_test_exact "maint demangle __Q33foo3bar4bell" "foo::bar::bell::bell(void)"
    gdb_test_exact "maint demangle __aa__3fooRT0" "foo::operator&&(foo &)"
    gdb_test_exact "maint demangle __aad__3fooRT0" "foo::operator&=(foo &)"
    gdb_test_exact "maint demangle __ad__3fooRT0" "foo::operator&(foo &)"
    gdb_test_exact "maint demangle __adv__3fooRT0" "foo::operator/=(foo &)"
    gdb_test_exact "maint demangle __aer__3fooRT0" "foo::operator^=(foo &)"
    gdb_test_exact "maint demangle __als__3fooRT0" "foo::operator<<=(foo &)"
    gdb_test_exact "maint demangle __amd__3fooRT0" "foo::operator%=(foo &)"
    gdb_test_exact "maint demangle __ami__3fooRT0" "foo::operator-=(foo &)"
    gdb_test_exact "maint demangle __aml__3FixRT0" "Fix::operator*=(Fix &)"
    gdb_test_exact "maint demangle __aml__5Fix16i" "Fix16::operator*=(int)"
    gdb_test_exact "maint demangle __aml__5Fix32RT0" "Fix32::operator*=(Fix32 &)"
    gdb_test_exact "maint demangle __aor__3fooRT0" "foo::operator|=(foo &)"
    gdb_test_exact "maint demangle __apl__3fooRT0" "foo::operator+=(foo &)"
    gdb_test_exact "maint demangle __ars__3fooRT0" "foo::operator>>=(foo &)"

    gdb_test_exact "maint demangle __as__3fooRT0" "foo::operator=(foo &)"
    gdb_test_exact "maint demangle __cl__3fooRT0" "foo::operator()(foo &)"
    gdb_test_exact "maint demangle __cl__6Normal" "Normal::operator()(void)"
    gdb_test_exact "maint demangle __cl__6Stringii" "String::operator()(int, int)"
    gdb_test_exact "maint demangle __cm__3fooRT0" "foo::operator, (foo &)"
    gdb_test_exact "maint demangle __co__3foo" "foo::operator~(void)"
    gdb_test_exact "maint demangle __dl__3fooPv" "foo::operator delete(void *)"
    gdb_test_exact "maint demangle __dv__3fooRT0" "foo::operator/(foo &)"
    gdb_test_exact "maint demangle __eq__3fooRT0" "foo::operator==(foo &)"
    gdb_test_exact "maint demangle __er__3fooRT0" "foo::operator^(foo &)"
    gdb_test_exact "maint demangle __ge__3fooRT0" "foo::operator>=(foo &)"
    gdb_test_exact "maint demangle __gt__3fooRT0" "foo::operator>(foo &)"
    gdb_test_exact "maint demangle __le__3fooRT0" "foo::operator<=(foo &)"
    gdb_test_exact "maint demangle __ls__3fooRT0" "foo::operator<<(foo &)"
    gdb_test_exact "maint demangle __ls__FR7ostreamPFR3ios_R3ios" "operator<<(ostream &, ios &(*)(ios &))"
    gdb_test_exact "maint demangle __ls__FR7ostreamR3Fix" "operator<<(ostream &, Fix &)"
    gdb_test_exact "maint demangle __lt__3fooRT0" "foo::operator<(foo &)"
    gdb_test_exact "maint demangle __md__3fooRT0" "foo::operator%(foo &)"
    gdb_test_exact "maint demangle __mi__3fooRT0" "foo::operator-(foo &)"
    gdb_test_exact "maint demangle __ml__3fooRT0" "foo::operator*(foo &)"
    gdb_test_exact "maint demangle __mm__3fooi" "foo::operator--(int)"

    gdb_test_exact "maint demangle __ne__3fooRT0" "foo::operator!=(foo &)"
    gdb_test "maint dem __ne__FRC7ComplexT0" \
	"operator!=\[(\]+(const Complex|Complex const) &, (const Complex|Complex const) &\[)\]+"
    gdb_test "maint dem __ne__FRC7Complexd" \
	"operator!=\[(\]+(const Complex|Complex const) &, double\[)\]+"
    gdb_test "maint dem __ne__FRC9SubStringRC6String" \
	"operator!=\[(\]+(const SubString|SubString const) &, (const String|String const) &\[)\]+"
    gdb_test_exact "maint demangle __nt__3foo" "foo::operator!(void)"
    gdb_test_exact "maint demangle __nw__3fooi" "foo::operator new(int)"
    gdb_test_exact "maint demangle __oo__3fooRT0" "foo::operator||(foo &)"
    gdb_test_exact "maint demangle __opPc__3foo" "foo::operator char *(void)"
    gdb_test_exact "maint demangle __opi__3foo" "foo::operator int(void)"
    gdb_test_exact "maint demangle __or__3fooRT0" "foo::operator|(foo &)"
    gdb_test_exact "maint demangle __pl__3fooRT0" "foo::operator+(foo &)"
    gdb_test_exact "maint demangle __pp__3fooi" "foo::operator++(int)"
    gdb_test_exact "maint demangle __rf__3foo" "foo::operator->(void)"
    gdb_test_exact "maint demangle __rm__3fooRT0" "foo::operator->*(foo &)"
    gdb_test_exact "maint demangle __rs__3fooRT0" "foo::operator>>(foo &)"
    gdb_test "maint dem __vc__3fooRT0" "foo::operator\\\[\\\]\\(foo &\\)"
    gdb_test "maint dem _gsub__6StringRC5RegexPCci" \
	"String::_gsub\[(\]+(const Regex|Regex const) &, (const char|char const) \[*\]+, int\[)\]+"
    gdb_test_exact "maint demangle _new_Fix__FUs" "_new_Fix(unsigned short)"

    # gcc 2.4.5 (and earlier) style virtual tables.  We want to continue to
    # correctly demangle these even if newer compilers use a different form.
    gdb_test_exact "maint demangle _vt.foo" "foo virtual table"
    gdb_test_exact "maint demangle _vt.foo.bar" "foo::bar virtual table"
    gdb_test_exact "maint demangle _vt\$foo" "foo virtual table"
    gdb_test_exact "maint demangle _vt\$foo\$bar" "foo::bar virtual table"

    gdb_test_exact "maint demangle append__7ivGlyphPT0" "ivGlyph::append(ivGlyph *)"
    gdb_test "maint dem arg__FRC7Complex" \
	"arg\[(\]+(const Complex|Complex const) &\[)\]+"
    gdb_test_exact "maint demangle clearok__FP7_win_sti" "clearok(_win_st *, int)"

    gdb_test_exact "maint demangle complexfunc2__FPFPc_i" "complexfunc2(int (*)(char *))"
    gdb_test_exact "maint demangle complexfunc3__FPFPFPl_s_i" "complexfunc3(int (*)(short (*)(long *)))"
    gdb_test_exact "maint demangle complexfunc4__FPFPFPc_s_i" "complexfunc4(int (*)(short (*)(char *)))"
    gdb_test_exact "maint demangle complexfunc5__FPFPc_PFl_i" "complexfunc5(int (*(*)(char *))(long))"
    gdb_test_exact "maint demangle complexfunc6__FPFPi_PFl_i" "complexfunc6(int (*(*)(int *))(long))"
    gdb_test_exact "maint demangle complexfunc7__FPFPFPc_i_PFl_i" "complexfunc7(int (*(*)(int (*)(char *)))(long))"
    gdb_test "maint dem contains__C9BitStringRC10BitPattern" \
	"BitString::contains\[(\]+(const BitPattern|BitPattern const) &\[)\]+ const"
    gdb_test "maint dem contains__C9BitStringRC12BitSubStringi" \
	"BitString::contains\[(\]+(const BitSubString|BitSubString const) &, int\[)\]+ const"
    gdb_test "maint dem contains__C9BitStringRT0" \
	"BitString::contains\[(\]+(const BitString|BitString const) &\[)\]+ const"
    gdb_test "maint dem div__FPC6IntRepT0P6IntRep" \
	"div\[(\]+(const IntRep|IntRep const) \[*\]+, (const IntRep|IntRep const) \[*\]+, IntRep \[*\]+\[)\]+"
    gdb_test "maint dem div__FPC6IntReplP6IntRep" \
	"div\[(\]+(const IntRep|IntRep const) \[*\]+, long, IntRep \[*\]+\[)\]+"
    gdb_test "maint dem div__FRC8RationalT0R8Rational" \
	"div\[(\]+(const Rational|Rational const) &, (const Rational|Rational const) &, Rational &\[)\]+"
    gdb_test "maint dem divide__FRC7IntegerT0R7IntegerT2" \
	"divide\[(\]+(const Integer|Integer const) &, (const Integer|Integer const) &, Integer &, Integer &\[)\]+"
    gdb_test "maint dem divide__FRC7IntegerlR7IntegerRl" \
	"divide\[(\]+(const Integer|Integer const) &, long, Integer &, long &\[)\]+"
    gdb_test "maint dem enable__14DocumentViewerPCcUi" \
	"DocumentViewer::enable\[(\]+(const char|char const) \[*\]+, unsigned int\[)\]+"

    gdb_test_exact "maint demangle foo__FiN30" "foo(int, int, int, int)"
    gdb_test_exact "maint demangle foo__FiR3fooiT1iT1" "foo(int, foo &, int, foo &, int, foo &)"
    gdb_test_exact "maint demangle foo___3barl" "bar::foo_(long)"
    gdb_test_exact "maint demangle insert__15ivClippingStacklRP8_XRegion" "ivClippingStack::insert(long, _XRegion *&)"
    gdb_test_exact "maint demangle insert__16ChooserInfo_ListlR11ChooserInfo" "ChooserInfo_List::insert(long, ChooserInfo &)"
    gdb_test_exact "maint demangle insert__17FontFamilyRepListlRP15ivFontFamilyRep" "FontFamilyRepList::insert(long, ivFontFamilyRep *&)"
    gdb_test_exact "maint demangle leaveok__FP7_win_stc" "leaveok(_win_st *, char)"
    gdb_test_exact "maint demangle left_mover__C7ivMFKitP12ivAdjustableP7ivStyle" "ivMFKit::left_mover(ivAdjustable *, ivStyle *) const"
    gdb_test "maint dem matches__C9BitStringRC10BitPatterni" \
	"BitString::matches\[(\]+(const BitPattern|BitPattern const) &, int\[)\]+ const"
    gdb_test "maint dem matches__C9SubStringRC5Regex" \
	"SubString::matches\[(\]+(const Regex|Regex const) &\[)\]+ const"

    gdb_test_exact "maint demangle overload1arg__FSc" "overload1arg(signed char)"
    gdb_test_exact "maint demangle overload1arg__FUc" "overload1arg(unsigned char)"
    gdb_test_exact "maint demangle overload1arg__FUi" "overload1arg(unsigned int)"
    gdb_test_exact "maint demangle overload1arg__FUl" "overload1arg(unsigned long)"
    gdb_test_exact "maint demangle overload1arg__FUs" "overload1arg(unsigned short)"
    gdb_test_exact "maint demangle overload1arg__Fc" "overload1arg(char)"
    gdb_test_exact "maint demangle overload1arg__Fd" "overload1arg(double)"
    gdb_test_exact "maint demangle overload1arg__Ff" "overload1arg(float)"
    gdb_test_exact "maint demangle overload1arg__Fi" "overload1arg(int)"
    gdb_test_exact "maint demangle overload1arg__Fl" "overload1arg(long)"
    gdb_test_exact "maint demangle overload1arg__Fs" "overload1arg(short)"
    gdb_test_exact "maint demangle overload1arg__Fv" "overload1arg(void)"
    gdb_test_exact "maint demangle overloadargs__Fi" "overloadargs(int)"
    gdb_test_exact "maint demangle overloadargs__Fii" "overloadargs(int, int)"
    gdb_test_exact "maint demangle overloadargs__Fiii" "overloadargs(int, int, int)"
    gdb_test_exact "maint demangle overloadargs__Fiiii" "overloadargs(int, int, int, int)"

    gdb_test_exact "maint demangle overloadargs__Fiiiii" "overloadargs(int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__Fiiiiii" "overloadargs(int, int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__Fiiiiiii" "overloadargs(int, int, int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__Fiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__Fiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__Fiiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__Fiiiiiiiiiii" "overloadargs(int, int, int, int, int, int, int, int, int, int, int)"
    gdb_test "maint dem pick__13ivCompositionP8ivCanvasRC12ivAllocationiR5ivHit" \
	"ivComposition::pick\[(\]+ivCanvas \[*\]+, (const ivAllocation|ivAllocation const) &, int, ivHit &\[)\]+"
    gdb_test "maint dem pointer__C11ivHScrollerRC7ivEventRC12ivAllocation" \
	"ivHScroller::pointer\[(\]+(const ivEvent|ivEvent const) &, (const ivAllocation|ivAllocation const) &\[)\]+ const"
    gdb_test_exact "maint demangle poke__8ivRasterUlUlffff" "ivRaster::poke(unsigned long, unsigned long, float, float, float, float)"
    gdb_test_exact "maint demangle polar__Fdd" "polar(double, double)"
    gdb_test "maint dem read__10osStdInputRPCc" \
	"osStdInput::read\[(\]+(const char|char const) \[*\]+&\[)\]+"

    gdb_test_exact "maint demangle scale__13ivTransformerff" "ivTransformer::scale(float, float)"
    gdb_test "maint dem scanw__12CursesWindowPCce" \
	"CursesWindow::scanw\[(\]+(const char|char const) \[*\]+,...\[)\]+"
    gdb_test "maint dem scmp__FPCcT0" \
	"scmp\[(\]+(const char|char const) \[*\]+, (const char|char const) \[*\]+\[)\]+"
    gdb_test_exact "maint demangle sgetn__7filebufPci" "filebuf::sgetn(char *, int)"
    gdb_test_exact "maint demangle shift__FP5_FrepiT0" "shift(_Frep *, int, _Frep *)"
    gdb_test_exact "maint demangle test__C6BitSeti" "BitSet::test(int) const"
    gdb_test_exact "maint demangle test__C6BitSetii" "BitSet::test(int, int) const"
    gdb_test "maint dem testbit__FRC7Integerl" \
	"testbit\[(\]+(const Integer|Integer const) &, long\[)\]+"
    gdb_test_exact "maint demangle text_source__8Documentl" "Document::text_source(long)"
    gdb_test_exact "maint demangle variance__6Erlangd" "Erlang::variance(double)"
    gdb_test "maint dem vform__8iostreamPCcPc" \
	"iostream::vform\[(\]+(const char|char const) \[*\]+, char \[*\]+\[)\]+"
    gdb_test_exact "maint demangle view__14DocumentViewerP8ItemViewP11TabularItem" "DocumentViewer::view(ItemView *, TabularItem *)"
    gdb_test_exact "maint demangle xy_extents__11ivExtensionffff" "ivExtension::xy_extents(float, float, float, float)"
    gdb_test_exact "maint demangle zero__8osMemoryPvUi" "osMemory::zero(void *, unsigned int)"
    gdb_test_exact "maint demangle _2T4\$N" "T4::N"
    gdb_test_exact "maint demangle _Q22T42t1\$N" "T4::t1::N"
    gdb_test_exact "maint demangle get__2T1" "T1::get(void)"
    gdb_test_exact "maint demangle get__Q22T11a" "T1::a::get(void)"
    gdb_test_exact "maint demangle get__Q32T11a1b" "T1::a::b::get(void)"
    gdb_test_exact "maint demangle get__Q42T11a1b1c" "T1::a::b::c::get(void)"
    gdb_test_exact "maint demangle get__Q52T11a1b1c1d" "T1::a::b::c::d::get(void)"
    gdb_test_exact "maint demangle put__2T1i" "T1::put(int)"
    gdb_test_exact "maint demangle put__Q22T11ai" "T1::a::put(int)"
    gdb_test_exact "maint demangle put__Q32T11a1bi" "T1::a::b::put(int)"
    gdb_test_exact "maint demangle put__Q42T11a1b1ci" "T1::a::b::c::put(int)"
    gdb_test_exact "maint demangle put__Q52T11a1b1c1di" "T1::a::b::c::d::put(int)"

    gdb_test_exact "maint demangle bar__3fooPv"       "foo::bar(void *)"
    gdb_test "maint dem bar__3fooPCv" \
	"foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+"
    gdb_test_exact "maint demangle bar__C3fooPv"      "foo::bar(void *) const"
    gdb_test "maint dem bar__C3fooPCv" \
	"foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+ const"
    gdb_test_exact "maint demangle __eq__3fooRT0"     "foo::operator==(foo &)"
    gdb_test "maint dem __eq__3fooRC3foo" \
	 "foo::operator==\[(\]+(const foo|foo const) &\[)\]+"
    gdb_test_exact "maint demangle __eq__C3fooR3foo"  "foo::operator==(foo &) const"
    gdb_test "maint dem __eq__C3fooRT0" \
	   "foo::operator==\[(\]+(const foo|foo const) &\[)\]+ const"

    gdb_test_exact "maint demangle elem__t6vector1Zdi" "vector<double>::elem(int)"
    gdb_test_exact "maint demangle elem__t6vector1Zii" "vector<int>::elem(int)"
    gdb_test_exact "maint demangle __t6vector1Zdi"     "vector<double>::vector(int)"
    gdb_test_exact "maint demangle __t6vector1Zii"     "vector<int>::vector(int)"
    gdb_test_exact "maint demangle _\$_t6vector1Zdi"    "vector<double>::~vector(int)"
    gdb_test_exact "maint demangle _\$_t6vector1Zii"    "vector<int>::~vector(int)"

    gdb_test_exact "maint demangle __nw__t2T11ZcUi" "T1<char>::operator new(unsigned int)"
    gdb_test_exact "maint demangle __nw__t2T11Z1tUi" "T1<t>::operator new(unsigned int)"
    gdb_test_exact "maint demangle __dl__t2T11ZcPv" "T1<char>::operator delete(void *)"
    gdb_test_exact "maint demangle __dl__t2T11Z1tPv" "T1<t>::operator delete(void *)"
    gdb_test_exact "maint demangle __t2T11Zci" "T1<char>::T1(int)"
    gdb_test_exact "maint demangle __t2T11Zc" "T1<char>::T1(void)"
    gdb_test_exact "maint demangle __t2T11Z1ti" "T1<t>::T1(int)"
    gdb_test_exact "maint demangle __t2T11Z1t" "T1<t>::T1(void)"

    gdb_test_exact "maint demangle __Q2t4List1Z10VHDLEntity3Pix" \
	"List<VHDLEntity>::Pix::Pix(void)"

    gdb_test_exact "maint demangle __Q2t4List1Z10VHDLEntity3PixPQ2t4List1Z10VHDLEntity7element" \
	"List<VHDLEntity>::Pix::Pix(List<VHDLEntity>::element *)"

    gdb_test_exact "maint demangle __Q2t4List1Z10VHDLEntity3PixRCQ2t4List1Z10VHDLEntity3Pix" \
	"List<VHDLEntity>::Pix::Pix(List<VHDLEntity>::Pix const &)"

    gdb_test_exact "maint demangle __Q2t4List1Z10VHDLEntity7elementRC10VHDLEntityPT0" \
	"List<VHDLEntity>::element::element(VHDLEntity const &, List<VHDLEntity>::element *)"

    gdb_test_exact "maint demangle __Q2t4List1Z10VHDLEntity7elementRCQ2t4List1Z10VHDLEntity7element" \
	"List<VHDLEntity>::element::element(List<VHDLEntity>::element const &)"

    gdb_test_exact "maint demangle __cl__C11VHDLLibraryGt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
	"VHDLLibrary::operator()(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >) const"

    gdb_test_exact "maint demangle __cl__Ct4List1Z10VHDLEntityRCQ2t4List1Z10VHDLEntity3Pix" \
	"List<VHDLEntity>::operator()(List<VHDLEntity>::Pix const &) const"

    gdb_test_exact "maint demangle __ne__FPvRCQ2t4List1Z10VHDLEntity3Pix" \
	"operator!=(void *, List<VHDLEntity>::Pix const &)"

    gdb_test_exact "maint demangle __ne__FPvRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
	"operator!=(void *, PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> > const &)"

    gdb_test_exact "maint demangle __t4List1Z10VHDLEntityRCt4List1Z10VHDLEntity" \
	"List<VHDLEntity>::List(List<VHDLEntity> const &)"

    gdb_test_exact "maint demangle __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
	"PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(void)"

    gdb_test_exact "maint demangle __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityP14VHDLLibraryRepGQ2t4List1Z10VHDLEntity3Pix" \
	"PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(VHDLLibraryRep *, List<VHDLEntity>::Pix)"

    gdb_test_exact "maint demangle __t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
	"PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> >::PixX(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> > const &)"

    gdb_test_exact "maint demangle nextE__C11VHDLLibraryRt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity" \
	"VHDLLibrary::nextE(PixX<VHDLLibrary, VHDLLibraryRep, List<VHDLEntity> > &) const"

    gdb_test_exact "maint demangle next__Ct4List1Z10VHDLEntityRQ2t4List1Z10VHDLEntity3Pix" \
	"List<VHDLEntity>::next(List<VHDLEntity>::Pix &) const"

    gdb_test_exact "maint demangle _GLOBAL_\$D\$set" "global destructors keyed to set"

    gdb_test_exact "maint demangle _GLOBAL_\$I\$set" "global constructors keyed to set"

    gdb_test_exact "maint demangle __as__t5ListS1ZUiRCt5ListS1ZUi" \
	"ListS<unsigned int>::operator=(ListS<unsigned int> const &)"

    gdb_test_exact "maint demangle __cl__Ct5ListS1ZUiRCQ2t5ListS1ZUi3Vix" \
	"ListS<unsigned int>::operator()(ListS<unsigned int>::Vix const &) const"

    gdb_test_exact "maint demangle __cl__Ct5SetLS1ZUiRCQ2t5SetLS1ZUi3Vix" \
	"SetLS<unsigned int>::operator()(SetLS<unsigned int>::Vix const &) const"

    gdb_test_exact "maint demangle __t10ListS_link1ZUiRCUiPT0" \
	"ListS_link<unsigned int>::ListS_link(unsigned int const &, ListS_link<unsigned int> *)"

    gdb_test_exact "maint demangle __t10ListS_link1ZUiRCt10ListS_link1ZUi" \
	"ListS_link<unsigned int>::ListS_link(ListS_link<unsigned int> const &)"

    gdb_test_exact "maint demangle __t5ListS1ZUiRCt5ListS1ZUi" \
	"ListS<unsigned int>::ListS(ListS<unsigned int> const &)"

    gdb_test_exact "maint demangle next__Ct5ListS1ZUiRQ2t5ListS1ZUi3Vix" \
	"ListS<unsigned int>::next(ListS<unsigned int>::Vix &) const"

    gdb_test_exact "maint demangle __ne__FPvRCQ2t5SetLS1ZUi3Vix" \
	"operator!=(void *, SetLS<unsigned int>::Vix const &)"
    gdb_test_exact "maint demangle __t8ListElem1Z5LabelRt4List1Z5Label" \
	"ListElem<Label>::ListElem(List<Label> &)"
    gdb_test_exact "maint demangle __t8BDDHookV1ZPcRCPc" \
	"BDDHookV<char *>::BDDHookV(char *const &)"

    gdb_test_exact "maint demangle _vt\$t8BDDHookV1ZPc" "BDDHookV<char *> virtual table"

    gdb_test_exact "maint demangle __ne__FPvRCQ211BDDFunction4VixB" \
	"operator!=(void *, BDDFunction::VixB const &)"
    gdb_test_exact "maint demangle __eq__FPvRCQ211BDDFunction4VixB" \
	"operator==(void *, BDDFunction::VixB const &)"

    gdb_test_exact "maint demangle relativeId__CQ36T_phi210T_preserve8FPC_nextRCQ26T_phi210T_preserveRC10Parameters" \
	 "T_phi2::T_preserve::FPC_next::relativeId(T_phi2::T_preserve const &, Parameters const &) const"

}

#
#  Test lucid style name demangling
#

proc test_lucid_style_demangling {} {
    global prompt

    # Set the demangling style to "lucid" and then check to make sure
    # it really got set.  Return if the style failed to get set for
    # some reason.

    send "set demangle-style lucid\n"
    expect {
	-re "set demangle-style lucid\[\r\n\]+$prompt $" {}
	-re ".*$prompt $" { fail "set demangle-style lucid failed" ; return }
	timeout { fail "set demangle-style lucid failed (timeout)" ; return }
    }

    send "show demangle-style\n"
    expect {
	-re "The current C\[+\]+ demangling style is \"lucid\".\r\n$prompt $" {}
	-re ".*$prompt $" { fail "demangling style not set to lucid" }
	timeout { fail "show demangle-style timed out" }
    }

    gdb_test_exact "maint demangle WS__FR7istream" "WS(istream &)"
    gdb_test_exact "maint demangle __aa__3fooFR3foo" "foo::operator&&(foo &)"
    gdb_test_exact "maint demangle __aad__3fooFR3foo" "foo::operator&=(foo &)"
    gdb_test_exact "maint demangle __ad__3fooFR3foo" "foo::operator&(foo &)"
    gdb_test_exact "maint demangle __adv__3fooFR3foo" "foo::operator/=(foo &)"
    gdb_test_exact "maint demangle __adv__7complexF7complex" "complex::operator/=(complex)"
    gdb_test_exact "maint demangle __aer__3fooFR3foo" "foo::operator^=(foo &)"
    gdb_test_exact "maint demangle __als__3fooFR3foo" "foo::operator<<=(foo &)"
    gdb_test_exact "maint demangle __amd__3fooFR3foo" "foo::operator%=(foo &)"
    gdb_test_exact "maint demangle __ami__3fooFR3foo" "foo::operator-=(foo &)"
    gdb_test_exact "maint demangle __amu__3fooFR3foo" "foo::operator*=(foo &)"
    gdb_test_exact "maint demangle __amu__7complexF7complex" "complex::operator*=(complex)"
    gdb_test_exact "maint demangle __aor__3fooFR3foo" "foo::operator|=(foo &)"
    gdb_test_exact "maint demangle __apl__3fooFR3foo" "foo::operator+=(foo &)"
    gdb_test_exact "maint demangle __ars__3fooFR3foo" "foo::operator>>=(foo &)"
    gdb_test_exact "maint demangle __as__18istream_withassignFP9streambuf" "istream_withassign::operator=(streambuf *)"
    gdb_test_exact "maint demangle __as__18istream_withassignFR7istream" "istream_withassign::operator=(istream &)"
    gdb_test_exact "maint demangle __as__3fooFR3foo" "foo::operator=(foo &)"
    gdb_test_exact "maint demangle __as__3iosFR3ios" "ios::operator=(ios &)"
    gdb_test_exact "maint demangle __cl__3fooFR3foo" "foo::operator()(foo &)"
    gdb_test_exact "maint demangle __cm__3fooFR3foo" "foo::operator, (foo &)"

    gdb_test_exact "maint demangle __co__3fooFv" "foo::operator~(void)"
    gdb_test_exact "maint demangle __ct__10istrstreamFPc" "istrstream::istrstream(char *)"
    gdb_test_exact "maint demangle __ct__10istrstreamFPci" "istrstream::istrstream(char *, int)"
    gdb_test_exact "maint demangle __ct__10ostrstreamFPciT2" "ostrstream::ostrstream(char *, int, int)"
    gdb_test_exact "maint demangle __ct__10ostrstreamFv" "ostrstream::ostrstream(void)"
    gdb_test_exact "maint demangle __ct__10smanip_intFPFR3iosi_R3iosi" "smanip_int::smanip_int(ios &(*)(ios &, int), int)"
    gdb_test "maint dem __ct__11c_exceptionFPcRC7complexT2" "c_exception::c_exception\[(\]+char \[*\]+, (const complex|complex const) &, (const complex|complex const) &\[)\]+"
    gdb_test "maint dem __ct__11fstreambaseFPCciT2" "fstreambase::fstreambase\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
    gdb_test_exact "maint demangle __ct__11fstreambaseFi" "fstreambase::fstreambase(int)"
    gdb_test_exact "maint demangle __ct__11fstreambaseFiPcT1" "fstreambase::fstreambase(int, char *, int)"
    gdb_test_exact "maint demangle __ct__11fstreambaseFv" "fstreambase::fstreambase(void)"
    gdb_test_exact "maint demangle __ct__11smanip_longFPFR3iosl_R3iosl" "smanip_long::smanip_long(ios &(*)(ios &, long), long)"
    gdb_test_exact "maint demangle __ct__11stdiostreamFP4FILE" "stdiostream::stdiostream(FILE *)"
    gdb_test_exact "maint demangle __ct__12strstreambufFPFl_PvPFPv_v" "strstreambuf::strstreambuf(void *(*)(long), void (*)(void *))"
    gdb_test_exact "maint demangle __ct__12strstreambufFPUciT1" "strstreambuf::strstreambuf(unsigned char *, int, unsigned char *)"
    gdb_test_exact "maint demangle __ct__12strstreambufFPciT1" "strstreambuf::strstreambuf(char *, int, char *)"
    gdb_test_exact "maint demangle __ct__12strstreambufFi" "strstreambuf::strstreambuf(int)"
    gdb_test_exact "maint demangle __ct__12strstreambufFv" "strstreambuf::strstreambuf(void)"
    gdb_test_exact "maint demangle __ct__13strstreambaseFPciT1" "strstreambase::strstreambase(char *, int, char *)"
    gdb_test_exact "maint demangle __ct__3fooFR3foo" "foo::foo(foo &)"

    gdb_test_exact "maint demangle __ct__3fooFi" "foo::foo(int)"
    gdb_test_exact "maint demangle __ct__3fooFiN31" "foo::foo(int, int, int, int)"
    gdb_test "maint dem __ct__3fooFiPCc" \
	"foo::foo\[(\]+int, (const char|char const) \[*\]+\[)\]+"
    gdb_test_exact "maint demangle __ct__3fooFiR3fooT1T2T1T2" "foo::foo(int, foo &, int, foo &, int, foo &)"
    gdb_test_exact "maint demangle __ct__3iosFP9streambuf" "ios::ios(streambuf *)"
    gdb_test_exact "maint demangle __ct__7filebufFiPcT1" "filebuf::filebuf(int, char *, int)"
    gdb_test "maint dem __ct__7fstreamFPCciT2" \
	"fstream::fstream\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
    gdb_test_exact "maint demangle __ct__7fstreamFiPcT1" "fstream::fstream(int, char *, int)"
    gdb_test_exact "maint demangle __ct__7istreamFP9streambuf" "istream::istream(streambuf *)"
    gdb_test_exact "maint demangle __ct__7istreamFP9streambufiP7ostream" "istream::istream(streambuf *, int, ostream *)"
    gdb_test_exact "maint demangle __ct__7istreamFiPcT1" "istream::istream(int, char *, int)"
    gdb_test_exact "maint demangle __ct__7istreamFiT1P7ostream" "istream::istream(int, int, ostream *)"
    gdb_test_exact "maint demangle __ct__7ostreamFP9streambuf" "ostream::ostream(streambuf *)"
    gdb_test_exact "maint demangle __ct__7ostreamFiPc" "ostream::ostream(int, char *)"
    gdb_test "maint dem __ct__8ifstreamFPCciT2" \
	"ifstream::ifstream\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
    gdb_test_exact "maint demangle __ct__8ifstreamFiPcT1" "ifstream::ifstream(int, char *, int)"

    gdb_test_exact "maint demangle __ct__Q23foo3barFv" "foo::bar::bar(void)"
    gdb_test_exact "maint demangle __ct__Q33foo3bar4bellFv" "foo::bar::bell::bell(void)"
    gdb_test_exact "maint demangle __dl__3fooSFPv" "foo::operator delete(void *) static"
    gdb_test_exact "maint demangle __dl__FPv" "operator delete(void *)"
    gdb_test_exact "maint demangle __dt__10istrstreamFv" "istrstream::~istrstream(void)"

    gdb_test_exact "maint demangle __dt__Q23foo3barFv" "foo::bar::~bar(void)"
    gdb_test_exact "maint demangle __dt__Q33foo3bar4bellFv" "foo::bar::bell::~bell(void)"
    gdb_test_exact "maint demangle __dv__3fooFR3foo" "foo::operator/(foo &)"
    gdb_test_exact "maint demangle __dv__F7complexT1" "operator/(complex, complex)"
    gdb_test_exact "maint demangle __eq__3fooFR3foo" "foo::operator==(foo &)"
    gdb_test_exact "maint demangle __er__3fooFR3foo" "foo::operator^(foo &)"
    gdb_test_exact "maint demangle __ge__3fooFR3foo" "foo::operator>=(foo &)"
    gdb_test_exact "maint demangle __gt__3fooFR3foo" "foo::operator>(foo &)"
    gdb_test_exact "maint demangle __le__3fooFR3foo" "foo::operator<=(foo &)"
    gdb_test_exact "maint demangle __ls__3fooFR3foo" "foo::operator<<(foo &)"
    gdb_test_exact "maint demangle __ls__7ostreamFP9streambuf" "ostream::operator<<(streambuf *)"

    gdb_test "maint dem __ls__7ostreamFPCc" \
	"ostream::operator<<\[(\]+(const char|char const) \[*\]+\[)\]+"
    gdb_test_exact "maint demangle __ls__7ostreamFPFR3ios_R3ios" "ostream::operator<<(ios &(*)(ios &))"
    gdb_test_exact "maint demangle __ls__7ostreamFPv" "ostream::operator<<(void *)"
    gdb_test_exact "maint demangle __ls__7ostreamFUi" "ostream::operator<<(unsigned int)"
    gdb_test_exact "maint demangle __ls__7ostreamFUl" "ostream::operator<<(unsigned long)"
    gdb_test_exact "maint demangle __ls__7ostreamFd" "ostream::operator<<(double)"
    gdb_test_exact "maint demangle __ls__7ostreamFf" "ostream::operator<<(float)"
    gdb_test_exact "maint demangle __ls__7ostreamFi" "ostream::operator<<(int)"
    gdb_test_exact "maint demangle __ls__7ostreamFl" "ostream::operator<<(long)"
    gdb_test_exact "maint demangle __ls__FR7ostream7complex" "operator<<(ostream &, complex)"
    gdb_test_exact "maint demangle __lt__3fooFR3foo" "foo::operator<(foo &)"
    gdb_test_exact "maint demangle __md__3fooFR3foo" "foo::operator%(foo &)"
    gdb_test_exact "maint demangle __mi__3fooFR3foo" "foo::operator-(foo &)"
    gdb_test_exact "maint demangle __ml__3fooFR3foo" "foo::operator*(foo &)"
    gdb_test_exact "maint demangle __ml__F7complexT1" "operator*(complex, complex)"
    gdb_test_exact "maint demangle __mm__3fooFi" "foo::operator--(int)"
    gdb_test_exact "maint demangle __ne__3fooFR3foo" "foo::operator!=(foo &)"
    gdb_test_exact "maint demangle __nt__3fooFv" "foo::operator!(void)"
    gdb_test_exact "maint demangle __nw__3fooSFi" "foo::operator new(int) static"
    gdb_test_exact "maint demangle __nw__FUi" "operator new(unsigned int)"
    gdb_test_exact "maint demangle __nw__FUiPv" "operator new(unsigned int, void *)"
    gdb_test_exact "maint demangle __oo__3fooFR3foo" "foo::operator||(foo &)"
    gdb_test_exact "maint demangle __opPc__3fooFv" "foo::operator char *(void)"
    gdb_test_exact "maint demangle __opi__3fooFv" "foo::operator int(void)"
    gdb_test_exact "maint demangle __or__3fooFR3foo" "foo::operator|(foo &)"

    gdb_test_exact "maint demangle __pl__3fooFR3foo" "foo::operator+(foo &)"
    gdb_test_exact "maint demangle __pp__3fooFi" "foo::operator++(int)"
    gdb_test_exact "maint demangle __pt__3fooFv" "foo::operator->(void)"
    gdb_test_exact "maint demangle __rm__3fooFR3foo" "foo::operator->*(foo &)"
    gdb_test_exact "maint demangle __rs__3fooFR3foo" "foo::operator>>(foo &)"
    gdb_test_exact "maint demangle __rs__7istreamFP9streambuf" "istream::operator>>(streambuf *)"
    gdb_test_exact "maint demangle __rs__7istreamFPFR3ios_R3ios" "istream::operator>>(ios &(*)(ios &))"
    gdb_test_exact "maint demangle __rs__7istreamFPFR7istream_R7istream" "istream::operator>>(istream &(*)(istream &))"
    gdb_test_exact "maint demangle __rs__7istreamFPUc" "istream::operator>>(unsigned char *)"
    gdb_test_exact "maint demangle __rs__7istreamFPc" "istream::operator>>(char *)"
    gdb_test_exact "maint demangle __rs__7istreamFRUi" "istream::operator>>(unsigned int &)"
    gdb_test_exact "maint demangle __rs__7istreamFRUl" "istream::operator>>(unsigned long &)"
    gdb_test_exact "maint demangle __rs__7istreamFRUs" "istream::operator>>(unsigned short &)"
    gdb_test_exact "maint demangle __rs__7istreamFRd" "istream::operator>>(double &)"
    gdb_test_exact "maint demangle __rs__7istreamFRf" "istream::operator>>(float &)"
    gdb_test_exact "maint demangle __rs__7istreamFRi" "istream::operator>>(int &)"
    gdb_test_exact "maint demangle __rs__7istreamFRl" "istream::operator>>(long &)"
    gdb_test_exact "maint demangle __rs__7istreamFRs" "istream::operator>>(short &)"
    gdb_test_exact "maint demangle __rs__FR7istreamR7complex" "operator>>(istream &, complex &)"
    gdb_test "maint dem __vc__3fooFR3foo" "foo::operator\\\[\\\]\\(foo &\\)"
    gdb_test_exact "maint demangle __vtbl__10istrstream" "istrstream virtual table"
    gdb_test_exact "maint demangle __vtbl__17ostream__iostream__19iostream_withassign" "iostream_withassign::ostream__iostream virtual table"

    gdb_test_exact "maint demangle __vtbl__3ios" "ios virtual table"
    gdb_test_exact "maint demangle __vtbl__3ios__13strstreambase" "strstreambase::ios virtual table"

    # GDB 930414 demangles this as t_cc_main_ (obviously wrong).
    # GDB 930701 gets into an infinite loop.
    # GDB 930727 says "Can't demangle".
    # What is the correct demangling?  FIXME.
    gdb_test_exact "maint demangle __vtbl__3foo__vt_cc_main_" ""

    gdb_test_exact "maint demangle abs__F7complex" "abs(complex)"
    gdb_test_exact "maint demangle allocate__9streambufFv" "streambuf::allocate(void)"
    gdb_test_exact "maint demangle attach__11fstreambaseFi" "fstreambase::attach(int)"
    gdb_test_exact "maint demangle bitalloc__3iosSFv" "ios::bitalloc(void) static"
    gdb_test_exact "maint demangle chr__FiT1" "chr(int, int)"
    gdb_test_exact "maint demangle complex_error__FR11c_exception" "complex_error(c_exception &)"
    gdb_test_exact "maint demangle complexfunc2__FPFPc_i" "complexfunc2(int (*)(char *))"
    gdb_test_exact "maint demangle complexfunc3__FPFPFPl_s_i" "complexfunc3(int (*)(short (*)(long *)))"

    gdb_test_exact "maint demangle complexfunc4__FPFPFPc_s_i" "complexfunc4(int (*)(short (*)(char *)))"
    gdb_test_exact "maint demangle complexfunc5__FPFPc_PFl_i" "complexfunc5(int (*(*)(char *))(long))"
    gdb_test_exact "maint demangle complexfunc6__FPFPi_PFl_i" "complexfunc6(int (*(*)(int *))(long))"
    gdb_test_exact "maint demangle complexfunc7__FPFPFPc_i_PFl_i" "complexfunc7(int (*(*)(int (*)(char *)))(long))"
    gdb_test_exact "maint demangle complicated_put__7ostreamFc" "ostream::complicated_put(char)"
    gdb_test_exact "maint demangle conv10__FlPc" "conv10(long, char *)"
    gdb_test_exact "maint demangle conv16__FUlPc" "conv16(unsigned long, char *)"
    gdb_test_exact "maint demangle dec__FR3ios" "dec(ios &)"
    gdb_test_exact "maint demangle dec__Fli" "dec(long, int)"
    gdb_test_exact "maint demangle dofield__FP7ostreamPciT2T3" "dofield(ostream *, char *, int, char *, int)"

    gdb_test_exact "maint demangle flags__3iosFl" "ios::flags(long)"
    gdb_test_exact "maint demangle flags__3iosFv" "ios::flags(void)"
    gdb_test_exact "maint demangle foo__FiN31" "foo(int, int, int, int)"
    gdb_test_exact "maint demangle foo__FiR3fooT1T2T1T2" "foo(int, foo &, int, foo &, int, foo &)"
    gdb_test_exact "maint demangle foo___3barFl" "bar::foo_(long)"
    gdb_test "maint dem form__FPCce" "form\[(\]+(const char|char const) \[*\]+,...\[)\]+"
    gdb_test_exact "maint demangle get__7istreamFPcic" "istream::get(char *, int, char)"
    gdb_test_exact "maint demangle get__7istreamFR9streambufc" "istream::get(streambuf &, char)"
    gdb_test_exact "maint demangle get_complicated__7istreamFRUc" "istream::get_complicated(unsigned char &)"
    gdb_test_exact "maint demangle get_complicated__7istreamFRc" "istream::get_complicated(char &)"
    gdb_test_exact "maint demangle getline__7istreamFPUcic" "istream::getline(unsigned char *, int, char)"
    gdb_test_exact "maint demangle getline__7istreamFPcic" "istream::getline(char *, int, char)"

    gdb_test_exact "maint demangle ignore__7istreamFiT1" "istream::ignore(int, int)"
    gdb_test_exact "maint demangle init__12strstreambufFPciT1" "strstreambuf::init(char *, int, char *)"
    gdb_test_exact "maint demangle init__3iosFP9streambuf" "ios::init(streambuf *)"
    gdb_test_exact "maint demangle initcount__13Iostream_init" "Iostream_init::initcount"
    gdb_test_exact "maint demangle ipfx__7istreamFi" "istream::ipfx(int)"
    gdb_test_exact "maint demangle ls_complicated__7ostreamFUc" "ostream::ls_complicated(unsigned char)"
    gdb_test_exact "maint demangle ls_complicated__7ostreamFc" "ostream::ls_complicated(char)"
    gdb_test "maint dem open__11fstreambaseFPCciT2" \
	"fstreambase::open\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"
    gdb_test "maint dem open__7filebufFPCciT2" \
	"filebuf::open\[(\]+(const char|char const) \[*\]+, int, int\[)\]+"

    gdb_test_exact "maint demangle overload1arg__FSc" "overload1arg(signed char)"
    gdb_test_exact "maint demangle overload1arg__FUc" "overload1arg(unsigned char)"
    gdb_test_exact "maint demangle overload1arg__FUi" "overload1arg(unsigned int)"
    gdb_test_exact "maint demangle overload1arg__FUl" "overload1arg(unsigned long)"
    gdb_test_exact "maint demangle overload1arg__FUs" "overload1arg(unsigned short)"
    gdb_test_exact "maint demangle overload1arg__Fc" "overload1arg(char)"
    gdb_test_exact "maint demangle overload1arg__Fd" "overload1arg(double)"
    gdb_test_exact "maint demangle overload1arg__Ff" "overload1arg(float)"
    gdb_test_exact "maint demangle overload1arg__Fi" "overload1arg(int)"
    gdb_test_exact "maint demangle overload1arg__Fl" "overload1arg(long)"
    gdb_test_exact "maint demangle overload1arg__Fs" "overload1arg(short)"
    gdb_test_exact "maint demangle overload1arg__Fv" "overload1arg(void)"
    gdb_test_exact "maint demangle overloadargs__FiN21" "overloadargs(int, int, int)"
    gdb_test_exact "maint demangle overloadargs__FiN31" "overloadargs(int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__FiN41" "overloadargs(int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__FiN51" "overloadargs(int, int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__FiN61" "overloadargs(int, int, int, int, int, int, int)"

    gdb_test_exact "maint demangle overloadargs__FiN71" "overloadargs(int, int, int, int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__FiN81" "overloadargs(int, int, int, int, int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__FiN91" "overloadargs(int, int, int, int, int, int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__FiN91N11" "overloadargs(int, int, int, int, int, int, int, int, int, int, int)"
    gdb_test_exact "maint demangle overloadargs__FiT1" "overloadargs(int, int)"
    gdb_test_exact "maint demangle polar__FdT1" "polar(double, double)"
    gdb_test_exact "maint demangle pow__F7complexT1" "pow(complex, complex)"
    gdb_test_exact "maint demangle pow__F7complexd" "pow(complex, double)"
    gdb_test_exact "maint demangle pow__F7complexi" "pow(complex, int)"
    gdb_test_exact "maint demangle pow__Fd7complex" "pow(double, complex)"
    gdb_test_exact "maint demangle pstart__FPciT2" "pstart(char *, int, int)"
    gdb_test_exact "maint demangle put__7ostreamFc" "ostream::put(char)"

    gdb_test_exact "maint demangle read__7istreamFPci" "istream::read(char *, int)"
    gdb_test_exact "maint demangle resetiosflags__FR3iosl" "resetiosflags(ios &, long)"
    gdb_test_exact "maint demangle restore_errno__FRi" "restore_errno(int &)"
    gdb_test_exact "maint demangle rs_complicated__7istreamFRUc" "istream::rs_complicated(unsigned char &)"
    gdb_test_exact "maint demangle rs_complicated__7istreamFRc" "istream::rs_complicated(char &)"
    gdb_test_exact "maint demangle seekg__7istreamFl8seek_dir" "istream::seekg(long, seek_dir)"
    gdb_test_exact "maint demangle seekoff__12strstreambufFl8seek_diri" "strstreambuf::seekoff(long, seek_dir, int)"
    gdb_test_exact "maint demangle seekoff__9streambufFlQ2_3ios12ios_seek_diri" "streambuf::seekoff(long, ios::ios_seek_dir, int)"
    gdb_test_exact "maint demangle seekpos__9streambufFli" "streambuf::seekpos(long, int)"
    gdb_test_exact "maint demangle set_new_handler__FPFv_v" "set_new_handler(void (*)(void))"
    gdb_test_exact "maint demangle setb__9streambufFPcT1i" "streambuf::setb(char *, char *, int)"

    gdb_test_exact "maint demangle setb__FR3iosi" "setb(ios &, int)"
    gdb_test_exact "maint demangle setbuf__11fstreambaseFPci" "fstreambase::setbuf(char *, int)"
    gdb_test_exact "maint demangle setbuf__9streambufFPUci" "streambuf::setbuf(unsigned char *, int)"
    gdb_test_exact "maint demangle setbuf__9streambufFPciT2" "streambuf::setbuf(char *, int, int)"
    gdb_test_exact "maint demangle setf__3iosFlT1" "ios::setf(long, long)"
    gdb_test_exact "maint demangle setfill__FR3iosi" "setfill(ios &, int)"
    gdb_test_exact "maint demangle setg__9streambufFPcN21" "streambuf::setg(char *, char *, char *)"
    gdb_test_exact "maint demangle setp__9streambufFPcT1" "streambuf::setp(char *, char *)"

    gdb_test "maint dem sputn__9streambufFPCci" \
	"streambuf::sputn\[(\]+(const char|char const) \[*\]+, int\[)\]+"
    gdb_test "maint dem str__FPCci" \
	"str\[(\]+(const char|char const) \[*\]+, int\[)\]+"
    gdb_test_exact "maint demangle tie__3iosFP7ostream" "ios::tie(ostream *)"
    gdb_test_exact "maint demangle uconv10__FUlPc" "uconv10(unsigned long, char *)"

    gdb_test "maint dem write__7ostreamFPCci" \
	"ostream::write\[(\]+(const char|char const) \[*\]+, int\[)\]+"
    gdb_test_exact "maint demangle xget__7istreamFPc" "istream::xget(char *)"
    gdb_test_exact "maint demangle xsgetn__9streambufFPci" "streambuf::xsgetn(char *, int)"
    gdb_test "maint dem xsputn__9streambufFPCci" \
	"streambuf::xsputn\[(\]+(const char|char const) \[*\]+, int\[)\]+"
}

#
#  Test arm style name demangling
#

proc test_arm_style_demangling {} {
    global prompt

    # Set the demangling style to "arm" and then check to make sure
    # it really got set.  Return if the style failed to get set for
    # some reason.

    send "set demangle-style arm\n"
    expect {
	-re "set demangle-style arm\[\r\n\]+$prompt $" {}
	-re ".*$prompt $" { fail "set demangle-style arm failed" ; return }
	timeout { fail "set demangle-style arm failed (timeout)" ; return }
    }

    send "show demangle-style\n"
    expect {
	-re "The current C\[+\]+ demangling style is \"arm\".\r\n$prompt $" {}
	-re ".*$prompt $" { fail "demangling style not set to arm" }
	timeout { fail "show demangle-style timed out" }
    }

    gdb_test_exact "maint demangle __dt__21T5__pt__11_PFiPPdPv_iFv" "T5<int (*)(int, double **, void *)>::~T5<int (*)(int, double **, void *)>(void)"

    gdb_test_exact "maint demangle __ct__1cFi" "c::c(int)"

    gdb_test_exact "maint demangle __dt__11T5__pt__2_iFv" "T5<int>::~T5<int>(void)"

    gdb_test_exact "maint demangle __dt__11T5__pt__2_cFv" "T5<char>::~T5<char>(void)"

    gdb_test_exact "maint demangle __ct__2T2Fi" "T2::T2(int)"
    gdb_test_exact "maint demangle __dt__2T1Fv" "T1::~T1(void)"

    gdb_test_exact "maint demangle __dt__12T5__pt__3_1xFv" "T5<x>::~T5<x>(void)"

    gdb_test_exact "maint demangle __dt__17T5__pt__8_PFcPv_iFv" "T5<int (*)(char, void *)>::~T5<int (*)(char, void *)>(void)"

    gdb_test "maint dem g__FP1cPC1cT1" \
	"g\[(\]+c *\[*\]+, (const c|c const) *\[*\]+, c *\[*\]+\[)\]+"
    gdb_test "maint dem g__FPUlPCUlT1" \
	"g\[(\]+unsigned long \[*\]+, (const unsigned long|unsigned long const) \[*\]+, unsigned long \[*\]+\[)\]+"
    gdb_test "maint dem g__FPUiPCUiT1" \
	"g\[(\]+unsigned int \[*\]+, (const unsigned int|unsigned int const) \[*\]+, unsigned int \[*\]+\[)\]+"
    gdb_test "maint dem g__FPUsPCUsT1" \
	"g\[(\]+unsigned short \[*\]+, (const unsigned short|unsigned short const) \[*\]+, unsigned short \[*\]+\[)\]+"
    gdb_test "maint dem g__FPUcPCUcT1" \
	"g\[(\]+unsigned char \[*\]+, (const unsigned char|unsigned char const) \[*\]+, unsigned char \[*\]+\[)\]+"
    gdb_test "maint dem g__F1TPlPClT2" \
	"g\[(\]+T, long \[*\]+, (const long|long const) \[*\]+, long \[*\]+\[)\]+"
    gdb_test "maint dem g__F1RRlRClT2" \
	"g\[(\]+R, long &, (const long|long const) &, long &\[)\]+"
    gdb_test "maint dem g__F1TPiPCiT2" \
	"g\[(\]+T, int \[*\]+, (const int|int const) \[*\]+, int \[*\]+\[)\]+"
    gdb_test "maint dem g__F1RRiRCiT2" \
	"g\[(\]+R, int &, (const int|int const) &, int &\[)\]+"
    gdb_test "maint dem g__F1TPsPCsT2" \
	"g\[(\]+T, short \[*\]+, (const short|short const) \[*\]+, short \[*\]+\[)\]+"
    gdb_test "maint dem g__F1RRsRCsT2" \
	"g\[(\]+R, short &, (const short|short const) &, short &\[)\]+"
    gdb_test "maint dem g__F1TPcPCcT2" \
	"g\[(\]+T, char \[*\]+, (const char|char const) \[*\]+, char \[*\]+\[)\]+"
    gdb_test "maint dem g__F1RRcRCcT2" \
	"g\[(\]+R, char &, (const char|char const) &, char &\[)\]+"

    gdb_test_exact "maint demangle __ct__21T5__pt__11_PFiPPdPv_iFi" "T5<int (*)(int, double **, void *)>::T5<int (*)(int, double **, void *)>(int)"

    gdb_test "maint dem __gt__FRC2T2c" \
	"operator>\[(\]+(const T2|T2 const) &, char\[)\]+"
    gdb_test "maint dem __ge__FRC2T2c" \
	"operator>=\[(\]+(const T2|T2 const) &, char\[)\]+"
    gdb_test "maint dem __lt__FRC2T2c" \
	"operator<\[(\]+(const T2|T2 const) &, char\[)\]+"

    gdb_test "maint dem __le__FRC2T2c" \
	"operator<=\[(\]+(const T2|T2 const) &, char\[)\]+"
    gdb_test "maint dem __ne__FRC2T2c" \
	"operator!=\[(\]+(const T2|T2 const) &, char\[)\]+"
    gdb_test "maint dem __eq__FRC2T2c" \
	"operator==\[(\]+(const T2|T2 const) &, char\[)\]+"
    gdb_test_exact "maint demangle __amd__FR2T2i" "operator%=(T2 &, int)"
    gdb_test_exact "maint demangle __adv__FR2T2i" "operator/=(T2 &, int)"
    gdb_test_exact "maint demangle __amu__FR2T2i" "operator*=(T2 &, int)"
    gdb_test_exact "maint demangle __ami__FR2T2i" "operator-=(T2 &, int)"
    gdb_test_exact "maint demangle __apl__FR2T2i" "operator+=(T2 &, int)"
    gdb_test_exact "maint demangle __nw__2T1SFUi" "T1::operator new(unsigned int) static"
    gdb_test_exact "maint demangle __dl__2T1SFPv" "T1::operator delete(void *) static"
    gdb_test_exact "maint demangle put__2T7SFi" "T7::put(int) static"

    gdb_test_exact "maint demangle __dl__12T5__pt__3_1xSFPv" "T5<x>::operator delete(void *) static"

    gdb_test_exact "maint demangle h__FUc" "h(unsigned char)"
    gdb_test_exact "maint demangle f__Fic" "f(int, char)"
    gdb_test_exact "maint demangle h__FUi" "h(unsigned int)"
    gdb_test_exact "maint demangle h__Fci" "h(char, int)"
    gdb_test_exact "maint demangle h__FUl" "h(unsigned long)"
    gdb_test_exact "maint demangle h__Fcl" "h(char, long)"
    gdb_test_exact "maint demangle h__FUs" "h(unsigned short)"
    gdb_test_exact "maint demangle h__Fcs" "h(char, short)"
    gdb_test "maint dem __amd__FR2T2RC2T2" \
	"operator%=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __adv__FR2T2RC2T2" \
	"operator/=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __amu__FR2T2RC2T2" \
	"operator\[*\]+=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __ami__FR2T2RC2T2" \
	"operator-=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __apl__FR2T2RC2T2" \
	"operator\[+\]+=\[(\]+T2 &, (const T2|T2 const) &\[)\]+"

    gdb_test "maint dem g__F1SRPUlRPCUlT2" \
	"g\[(\]+S, unsigned long \[*\]+&, (const unsigned long|unsigned long const) \[*\]+&, unsigned long \[*\]+&\[)\]+"
    gdb_test "maint dem g__F1SRPUiRPCUiT2" \
	"g\[(\]+S, unsigned int \[*\]+&, (const unsigned int|unsigned int const) \[*\]+&, unsigned int \[*\]+&\[)\]+"
    gdb_test "maint dem g__F1SRPUsRPCUsT2" \
	"g\[(\]+S, unsigned short \[*\]+&, (const unsigned short|unsigned short const) \[*\]+&, unsigned short \[*\]+&\[)\]+"
    gdb_test "maint dem g__F1SRPUcRPCUcT2" \
	"g\[(\]+S, unsigned char \[*\]+&, (const unsigned char|unsigned char const) \[*\]+&, unsigned char \[*\]+&\[)\]+"
    gdb_test "maint dem g__F1T1SRPlRPClT3" \
	"g\[(\]+T, S, long \[*\]+&, (const long|long const) \[*\]+&, long \[*\]+&\[)\]+"
    gdb_test "maint dem g__F1T1SRPiRPCiT3" \
	"g\[(\]+T, S, int \[*\]+&, (const int|int const) \[*\]+&, int \[*\]+&\[)\]+"
    gdb_test "maint dem g__F1T1SRPcRPCcT3" \
	"g\[(\]+T, S, char \[*\]+&, (const char|char const) \[*\]+&, char \[*\]+&\[)\]+"

    gdb_test_exact "maint demangle X__12T5__pt__3_1x" "T5<x>::X"

    gdb_test_exact "maint demangle __ct__11T5__pt__2_iFi" "T5<int>::T5<int>(int)"

    gdb_test_exact "maint demangle __ct__11T5__pt__2_cFi" "T5<char>::T5<char>(int)"

    gdb_test "maint dem __gt__FRC2T2T1" \
	"operator>\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __ge__FRC2T2T1" \
	"operator>=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __lt__FRC2T2T1" \
	"operator<\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __le__FRC2T2T1" \
	"operator<=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __ne__FRC2T2T1" \
	"operator!=\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __eq__FRC2T2T1" \
	"operator==\[(\]+(const T2|T2 const) &, (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem g__FcR1cRC1cT2" \
	"g\[(\]+char, c &, (const c|c const) &, c &\[)\]+"
    gdb_test "maint dem g__FcRPdRPCdT2" \
	"g\[(\]+char, double *\[*\]+&, (const double|double const) *\[*\]+&, double *\[*\]+&\[)\]+"
    gdb_test "maint dem g__FcRPfRPCfT2" \
	"g\[(\]+char, float *\[*\]+&, (const float|float const) *\[*\]+&, float *\[*\]+&\[)\]+"
    gdb_test_exact "maint demangle h__FcT1" "h(char, char)"
    gdb_test_exact "maint demangle f__Ficd" "f(int, char, double)"
    gdb_test "maint dem g__F1T1SdRPsRPCsT4" \
	"g\[(\]+T, S, double, short \[*\]+&, (const short|short const) \[*\]+&, short \[*\]+&\[)\]+"
    gdb_test "maint dem g__F1cC1cT1" \
	"g\[(\]+c, (const c|c const), c\[)\]+"
    gdb_test "maint dem g__FPdPCdT1" \
	"g\[(\]+double *\[*\]+, (const double|double const) *\[*\]+, double *\[*\]+\[)\]+"
    gdb_test "maint dem g__FPfPCfT1" \
	"g\[(\]+float *\[*\]+, (const float|float const) *\[*\]+, float *\[*\]+\[)\]+"

    gdb_test "maint dem g__FUlCUlT1" \
	"g\[(\]+unsigned long, (const unsigned long|unsigned long const), unsigned long\[)\]+"
    gdb_test "maint dem g__FPlPClT1" \
	"g\[(\]+long \[*\]+, (const long|long const) \[*\]+, long \[*\]+\[)\]+"
    gdb_test "maint dem g__FUiCUiT1" \
	"g\[(\]+unsigned int, (const unsigned int|unsigned int const), unsigned int\[)\]+"
    gdb_test "maint dem g__FPiPCiT1" \
	"g\[(\]+int \[*\]+, (const int|int const) \[*\]+, int \[*\]+\[)\]+"
    gdb_test "maint dem g__FUsCUsT1" \
	"g\[(\]+unsigned short, (const unsigned short|unsigned short const), unsigned short\[)\]+"
    gdb_test "maint dem g__FPsPCsT1" \
	"g\[(\]+short \[*\]+, (const short|short const) \[*\]+, short \[*\]+\[)\]+"
    gdb_test "maint dem g__FUcCUcT1" \
	"g\[(\]+unsigned char, (const unsigned char|unsigned char const), unsigned char\[)\]+"
    gdb_test "maint dem g__FPcPCcT1" \
	"g\[(\]+char \[*\]+, (const char|char const) \[*\]+, char \[*\]+\[)\]+"
    gdb_test "maint dem g__F1TlClT2" \
	"g\[(\]+T, long, (const long|long const), long\[)\]+"
    gdb_test "maint dem g__F1TiCiT2" \
	"g\[(\]+T, int, (const int|int const), int\[)\]+"
    gdb_test "maint dem g__F1TsCsT2" \
	"g\[(\]+T, short, (const short|short const), short\[)\]+"
    gdb_test "maint dem g__F1TcCcT2" \
	"g\[(\]+T, char, (const char|char const), char\[)\]+"

    gdb_test_exact "maint demangle __dl__17T5__pt__8_PFcPv_iSFPv" "T5<int (*)(char, void *)>::operator delete(void *) static"

    gdb_test "maint dem printf__FPCce" \
	"printf\[(\]+(const char|char const) \[*\]+,...\[)\]+"

    gdb_test_exact "maint demangle X__17T5__pt__8_PFcPv_i" "T5<int (*)(char, void *)>::X"

    gdb_test_exact "maint demangle __ct__12T5__pt__3_1xFi" "T5<x>::T5<x>(int)"

    gdb_test "maint dem g__F1SRUlRCUlT2" \
	"g\[(\]+S, unsigned long &, (const unsigned long|unsigned long const) &, unsigned long &\[)\]+"
    gdb_test "maint dem g__F1SRPlRPClT2" \
	"g\[(\]+S, long \[*\]+&, (const long|long const) \[*\]+&, long \[*\]+&\[)\]+"
    gdb_test "maint dem g__F1RRUiRCUiT2" \
	"g\[(\]+R, unsigned int &, (const unsigned int|unsigned int const) &, unsigned int &\[)\]+"
    gdb_test "maint dem g__F1SRPiRPCiT2" \
	"g\[(\]+S, int \[*\]+&, (const int|int const) \[*\]+&, int \[*\]+&\[)\]+"
    gdb_test "maint dem g__F1RRUsRCUsT2" \
	"g\[(\]+R, unsigned short &, (const unsigned short|unsigned short const) &, unsigned short &\[)\]+"
    gdb_test "maint dem g__F1SRPsRPCsT2" \
	"g\[(\]+S, short \[*\]+&, (const short|short const) \[*\]+&, short \[*\]+&\[)\]+"
    gdb_test "maint dem g__F1RRUcRCUcT2" \
	"g\[(\]+R, unsigned char &, (const unsigned char|unsigned char const) &, unsigned char &\[)\]+"
    gdb_test "maint dem g__F1SRPcRPCcT2" \
	"g\[(\]+S, char \[*\]+&, (const char|char const) \[*\]+&, char \[*\]+&\[)\]+"
    gdb_test "maint dem g__F1T1RRlRClT3" \
	"g\[(\]+T, R, long &, (const long|long const) &, long &\[)\]+"
    gdb_test "maint dem g__F1T1RRiRCiT3" \
	"g\[(\]+T, R, int &, (const int|int const) &, int &\[)\]+"
    gdb_test "maint dem g__F1T1RRsRCsT3" \
	"g\[(\]+T, R, short &, (const short|short const) &, short &\[)\]+"
    gdb_test "maint dem g__F1T1RRcRCcT3" \
	"g\[(\]+T, R, char &, (const char|char const) &, char &\[)\]+"

    gdb_test_exact "maint demangle __dl__21T5__pt__11_PFiPPdPv_iSFPv" "T5<int (*)(int, double **, void *)>::operator delete(void *) static"

    gdb_test_exact "maint demangle __std__foo" "global destructors keyed to foo"

    gdb_test_exact "maint demangle __sti__bar" "global constructors keyed to bar"

    gdb_test_exact "maint demangle f__FicdPcPFci_v" "f(int, char, double, char *, void (*)(char, int))"
    gdb_test_exact "maint demangle f__FicdPcPFic_v" "f(int, char, double, char *, void (*)(int, char))"
    gdb_test_exact "maint demangle get__2T7SFv" "T7::get(void) static"

    gdb_test_exact "maint demangle X__21T5__pt__11_PFiPPdPv_i" "T5<int (*)(int, double **, void *)>::X"

    gdb_test "maint dem g__FcRdRCdT2" \
	"g\[(\]+char, double &, (const double|double const) &, double &\[)\]+"
    gdb_test "maint dem g__FcRfRCfT2" \
	"g\[(\]+char, float &, (const float|float const) &, float &\[)\]+"
    gdb_test "maint dem __md__FC2T2i" \
	"operator%\[(\]+(const T2|T2 const), int\[)\]+"
    gdb_test "maint dem __dv__FC2T2i" \
	"operator/\[(\]+(const T2|T2 const), int\[)\]+"
    gdb_test "maint dem __ml__FC2T2i" \
	"operator\[*\]+\[(\]+(const T2|T2 const), int\[)\]+"
    gdb_test "maint dem __mi__FC2T2i" \
	"operator-\[(\]+(const T2|T2 const), int\[)\]+"
    gdb_test "maint dem __pl__FC2T2i" \
	"operator\[+\]+\[(\]+(const T2|T2 const), int\[)\]+"

    gdb_test_exact "maint demangle __dl__11T5__pt__2_iSFPv" "T5<int>::operator delete(void *) static"

    gdb_test_exact "maint demangle __dl__11T5__pt__2_cSFPv" "T5<char>::operator delete(void *) static"

    gdb_test_exact "maint demangle h__Fc" "h(char)"
    gdb_test_exact "maint demangle h__Fd" "h(double)"
    gdb_test_exact "maint demangle h__Ff" "h(float)"
    gdb_test_exact "maint demangle h__Fi" "h(int)"
    gdb_test_exact "maint demangle f__Fi" "f(int)"
    gdb_test_exact "maint demangle h__Fl" "h(long)"

    gdb_test_exact "maint demangle h__Fs" "h(short)"
    gdb_test "maint dem __md__FC2T2RC2T2" \
	"operator%\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __dv__FC2T2RC2T2" \
	"operator/\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __ml__FC2T2RC2T2" \
	"operator\[*\]+\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __mi__FC2T2RC2T2" \
	"operator-\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem __pl__FC2T2RC2T2" \
	"operator\[+\]+\[(\]+(const T2|T2 const), (const T2|T2 const) &\[)\]+"
    gdb_test "maint dem g__FcRP1cRPC1cT2" \
	"g\[(\]+char, c *\[*\]+&, (const c|c const) *\[*\]+&, c *\[*\]+&\[)\]+"

    gdb_test_exact "maint demangle X__11T5__pt__2_c" "T5<char>::X"

    gdb_test_exact "maint demangle X__11T5__pt__2_i" "T5<int>::X"

    gdb_test "maint dem g__FdCdT1" \
	"g\[(\]+double, (const double|double const), double\[)\]+"
    gdb_test "maint dem g__FfCfT1" \
	"g\[(\]+float, (const float|float const), float\[)\]+"
    gdb_test "maint dem g__FlClT1" \
	"g\[(\]+long, (const long|long const), long\[)\]+"
    gdb_test "maint dem g__FiCiT1" \
	"g\[(\]+int, (const int|int const), int\[)\]+"
    gdb_test "maint dem g__FsCsT1" \
	"g\[(\]+short, (const short|short const), short\[)\]+"
    gdb_test "maint dem g__FcCcT1" \
	"g\[(\]+char, (const char|char const), char\[)\]+"

    gdb_test_exact "maint demangle __ct__17T5__pt__8_PFcPv_iFi" "T5<int (*)(char, void *)>::T5<int (*)(char, void *)>(int)"

    gdb_test_exact "maint demangle f__FicdPc" "f(int, char, double, char *)"
    gdb_test_exact "maint demangle __nw__FUi" "operator new(unsigned int)"
    gdb_test_exact "maint demangle __ct__Q3_2T11a1bSFi" "T1::a::b::b(int) static"
    gdb_test_exact "maint demangle __dt__Q3_2T11a1bSFi" "T1::a::b::~b(int) static"
    gdb_test_exact "maint demangle put__Q3_2T11a1bSFi" "T1::a::b::put(int) static"
    gdb_test_exact "maint demangle get__Q2_2T11aSFv" "T1::a::get(void) static"
    gdb_test_exact "maint demangle put__2T1SFi" "T1::put(int) static"
    gdb_test_exact "maint demangle put__Q5_2T11a1b1c1dSFi" "T1::a::b::c::d::put(int) static"
    gdb_test_exact "maint demangle get__Q4_2T11a1b1cSFv" "T1::a::b::c::get(void) static"
    gdb_test_exact "maint demangle put__Q2_2T11aSFi" "T1::a::put(int) static"
    gdb_test_exact "maint demangle put__Q4_2T11a1b1cSFi" "T1::a::b::c::put(int) static"
    gdb_test_exact "maint demangle get__Q3_2T11a1bSFv" "T1::a::b::get(void) static"
    gdb_test_exact "maint demangle get__2T1SFv" "T1::get(void) static"
    gdb_test_exact "maint demangle get__Q5_2T11a1b1c1dSFv" "T1::a::b::c::d::get(void) static"

    gdb_test_exact "maint demangle __dt__11T1__pt__2_cFv" "T1<char>::~T1<char>(void)"

    gdb_test_exact "maint demangle __dt__12T1__pt__3_1tFv" "T1<t>::~T1<t>(void)"

    gdb_test_exact "maint demangle __dl__12T1__pt__3_1tSFPv" "T1<t>::operator delete(void *) static"

    gdb_test_exact "maint demangle __ct__11T1__pt__2_cFi" "T1<char>::T1<char>(int)"

    gdb_test_exact "maint demangle __ct__11T1__pt__2_cFv" "T1<char>::T1<char>(void)"

    gdb_test_exact "maint demangle __ct__12T1__pt__3_1tFi" "T1<t>::T1<t>(int)"

    gdb_test_exact "maint demangle __ct__12T1__pt__3_1tFv" "T1<t>::T1<t>(void)"

    gdb_test_exact "maint demangle __dl__11T1__pt__2_cSFPv" "T1<char>::operator delete(void *) static"

    gdb_test_exact "maint demangle bar__3fooFPv"       "foo::bar(void *)"
    gdb_test "maint dem bar__3fooFPCv" \
	     "foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+"
    gdb_test_exact "maint demangle bar__3fooCFPv"      "foo::bar(void *) const"
    gdb_test "maint dem bar__3fooCFPCv" \
	    "foo::bar\[(\]+(const void|void const) *\[*\]+\[)\]+ const"
    gdb_test_exact "maint demangle __eq__3fooFR3foo"   "foo::operator==(foo &)"
    gdb_test "maint dem __eq__3fooFRC3foo" \
	 "foo::operator==\[(\]+(const foo|foo const) &\[)\]+"
    gdb_test_exact "maint demangle __eq__3fooCFR3foo"  "foo::operator==(foo &) const"
    gdb_test "maint dem __eq__3fooCFRC3foo" \
	"foo::operator==\[(\]+(const foo|foo const) &\[)\]+ const"

    gdb_test_exact "maint demangle elem__15vector__pt__2_dFi" "vector<double>::elem(int)"

    gdb_test_exact "maint demangle elem__15vector__pt__2_iFi" "vector<int>::elem(int)"

    gdb_test_exact "maint demangle __ct__15vector__pt__2_dFi" "vector<double>::vector<double>(int)"

    gdb_test_exact "maint demangle __ct__15vector__pt__2_iFi" "vector<int>::vector<int>(int)"

    gdb_test_exact "maint demangle __ct__25DListNode__pt__9_R6RLabelFR6RLabelP25DListNode__pt__9_R6RLabelT2" \
	"DListNode<RLabel &>::DListNode<RLabel &>(RLabel &, DListNode<RLabel &> *, DListNode<RLabel &> *)"

    gdb_test_exact "maint demangle bar__3fooFiT16FooBar" "foo::bar(int, int, FooBar)"

    gdb_test_exact "maint demangle bar__3fooFPiN51PdN37PcN211T1iN215" \
      "foo::bar(int *, int *, int *, int *, int *, int *, double *, double *, double *, double *, char *, char *, char *, int *, int, int, int)"

}

# Test support for different demangling styles.  Note that this does
# not depend upon running the test program and does not depend upon
# gdb being able to lookup any C++ symbols.  It simply calls the 
# internal demangler with synthesized strings and tests the results.

proc do_tests {} {
    global prms_id
    global bug_id
    global subdir
    global prompt

    set prms_id 0
    set bug_id 0

    # Start with a fresh gdb.

    gdb_exit
    gdb_start

    send "set language c++\n"
    expect -re "$prompt $"
    send "set width 0\n"
    expect -re "$prompt $"
    
    test_lucid_style_demangling
    test_gnu_style_demangling
    test_arm_style_demangling
}

do_tests
