From b5919edf5c374921b25789117ab8980eebc8830f Mon Sep 17 00:00:00 2001 From: chaoticgd <43898262+chaoticgd@users.noreply.github.com> Date: Thu, 11 Jan 2024 00:12:37 +0000 Subject: [PATCH 1/6] Add original GNU demangler test suite --- CMakeLists.txt | 6 +- thirdparty/demanglegnu/CMakeLists.txt | 5 + .../demanglegnu/testsuite/demangle-expected | 1661 +++++++++++++++++ .../demanglegnu/testsuite/demangler-fuzzer.c | 108 ++ .../demanglegnu/testsuite/test-demangle.c | 352 ++++ 5 files changed, 2129 insertions(+), 3 deletions(-) create mode 100644 thirdparty/demanglegnu/testsuite/demangle-expected create mode 100644 thirdparty/demanglegnu/testsuite/demangler-fuzzer.c create mode 100644 thirdparty/demanglegnu/testsuite/test-demangle.c diff --git a/CMakeLists.txt b/CMakeLists.txt index a9cc751d..842bfff0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,12 +122,12 @@ if(WIN32) target_sources(tests PUBLIC src/ccc.manifest) endif() -add_subdirectory(thirdparty/demanglegnu) +add_subdirectory(thirdparty/demanglegnu EXCLUDE_FROM_ALL) set(gtest_force_shared_crt on) -add_subdirectory(thirdparty/googletest) +add_subdirectory(thirdparty/googletest EXCLUDE_FROM_ALL) -add_subdirectory(thirdparty/rapidjson) +add_subdirectory(thirdparty/rapidjson EXCLUDE_FROM_ALL) # All the files to be included in a release. set(RELEASE_CONTENTS diff --git a/thirdparty/demanglegnu/CMakeLists.txt b/thirdparty/demanglegnu/CMakeLists.txt index 9ef08b3f..a320187e 100644 --- a/thirdparty/demanglegnu/CMakeLists.txt +++ b/thirdparty/demanglegnu/CMakeLists.txt @@ -15,3 +15,8 @@ add_library(demanglegnu STATIC ) target_include_directories(demanglegnu PUBLIC .) target_compile_definitions(demanglegnu PRIVATE -DHAVE_LIMITS_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1) + +add_executable(demangler_fuzzer testsuite/demangler-fuzzer.c) +add_executable(demangler_test testsuite/test-demangle.c) +target_link_libraries(demangler_fuzzer demanglegnu) +target_link_libraries(demangler_test demanglegnu) diff --git a/thirdparty/demanglegnu/testsuite/demangle-expected b/thirdparty/demanglegnu/testsuite/demangle-expected new file mode 100644 index 00000000..d9bc7ed4 --- /dev/null +++ b/thirdparty/demanglegnu/testsuite/demangle-expected @@ -0,0 +1,1661 @@ +# This file holds test cases for the demangler. +# Each test case looks like this: +# options +# input to be demangled +# expected output +# +# Supported options: +# --format= Sets the demangling style. +# --no-params There are two lines of expected output; the first +# is with DMGL_PARAMS, the second is without it. +# --is-v3-ctor Calls is_gnu_v3_mangled_ctor on input; expected +# output is an integer representing ctor_kind. +# --is-v3-dtor Likewise, but for dtors. +# --ret-postfix Passes the DMGL_RET_POSTFIX option +# +# For compatibility, just in case it matters, the options line may be +# empty, to mean --format=auto. If it doesn't start with --, then it +# may contain only a format name. +# +# A line starting with `#' is ignored. +# However, blank lines in this file are NOT ignored. +# +# +# Tests integer overflow problem PR70492 + +__vt_90000000000cafebabe +__vt_90000000000cafebabe +# +# Tests write access violation PR70498 + +_Z80800000000000000000000 +_Z80800000000000000000000 +# +# Tests write access violation PR70926 + +0__Ot2m02R5T0000500000 +0__Ot2m02R5T0000500000 +# + +0__GT50000000000_ +0__GT50000000000_ +# + +__t2m05B500000000000000000_ +__t2m05B500000000000000000_ +## +## Tests stack overflow PR71696 +# +#__10%0__S4_0T0T0 +#%0<>::%0(%0<>) +# Could crash + +_ +_ +# Could crash + +_vt +_vt +# Could crash + +_$_1Acitz +_$_1Acitz +# Could crash + +_$_H1R +_$_H1R +# Could crash + +_Q8ccQ4M2e. +_Q8ccQ4M2e. +# Could crash + +_ZmmAtl +_ZmmAtl +# Could crash +--no-params +_ZZaSFvOEES_ +_ZZaSFvOEES_ +_ZZaSFvOEES_ +# Could crash + +_ZZeqFvOEES_z +_ZZeqFvOEES_z +# +# demangler/80513 Test for bogus characters after __thunk_ + +__thunk_16a_$_1x +__thunk_16a_$_1x +# +# demangler/80513 Test for overflow in consume_count + +__thunk_4294967297__$_1x +__thunk_4294967297__$_1x +# +--format=gnu-v3 --no-params +_Z3fo5n +fo5(__int128) +fo5 +# +--format=gnu-v3 --no-params +_Z3fo5o +fo5(unsigned __int128) +fo5 +# +--format=java +_ZN4java3awt10ScrollPane7addImplEPNS0_9ComponentEPNS_4lang6ObjectEi +java.awt.ScrollPane.addImpl(java.awt.Component, java.lang.Object, int) +# +--format=java +_ZN4java3awt4geom15AffineTransform9getMatrixEP6JArrayIdE +java.awt.geom.AffineTransform.getMatrix(double[]) +# +--format=java +_ZN23Mangle$Inner$InnerInner3fooEP6JArrayIPS0_IiEEdPS0_IPS0_IPS0_IPS0_IPN4java4lang6StringEEEEEPS0_IPS0_IPN6MangleEEE +Mangle$Inner$InnerInner.foo(int[][], double, java.lang.String[][][][], Mangle[][]) +# +--format=java +_ZN6JArray1tEP6JArrayIPS_E +JArray.t(JArray[]) +# +--format=java +_ZN4Prim1iEibcdfwPN4java4lang6StringEsx +Prim.i(int, boolean, byte, double, float, char, java.lang.String, short, long) +# +--format=java +_ZN4java4util14Map__U24_Entry11class__U24_E +java.util.Map$Entry.class$ +# +--format=java +_ZN3org7eclipse3cdt5debug8internal4core5model9CVariable6sizeof$Ev +org.eclipse.cdt.debug.internal.core.model.CVariable.sizeof() +# +--format=auto --no-params +_Utf58_0_1__1_2147483647__2147483648 +_Utf58_0_1__1_2147483647__2147483648 +_Utf58_0_1__1_2147483647__2147483648 +# +--format=gnu-v3 --no-params +St9bad_alloc +std::bad_alloc +std::bad_alloc +# +--format=gnu-v3 --no-params +_ZN1f1fE +f::f +f::f +# +--format=gnu-v3 --no-params +_Z1fv +f() +f +# +--format=gnu-v3 --no-params +_Z1fi +f(int) +f +# +--format=gnu-v3 --no-params +_Z3foo3bar +foo(bar) +foo +# +--format=gnu-v3 --no-params +_Zrm1XS_ +operator%(X, X) +operator% +# +--format=gnu-v3 --no-params +_ZplR1XS0_ +operator+(X&, X&) +operator+ +# +--format=gnu-v3 --no-params +_ZlsRK1XS1_ +operator<<(X const&, X const&) +operator<< +# +--format=gnu-v3 --no-params +_ZN3FooIA4_iE3barE +Foo::bar +Foo::bar +# +--format=gnu-v3 --no-params +_Z1fIiEvi +void f(int) +f +# +--format=gnu-v3 --no-params +_Z5firstI3DuoEvS0_ +void first(Duo) +first +# +--format=gnu-v3 --no-params +_Z5firstI3DuoEvT_ +void first(Duo) +first +# +--format=gnu-v3 --no-params +_Z3fooIiFvdEiEvv +void foo() +foo +# +--format=gnu-v3 --no-params +_Z1fIFvvEEvv +void f() +f +# +--format=gnu-v3 --no-params +_ZN1N1fE +N::f +N::f +# +--format=gnu-v3 --no-params +_ZN6System5Sound4beepEv +System::Sound::beep() +System::Sound::beep +# +--format=gnu-v3 --no-params +_ZN5Arena5levelE +Arena::level +Arena::level +# +--format=gnu-v3 --no-params +_ZN5StackIiiE5levelE +Stack::level +Stack::level +# +--format=gnu-v3 --no-params +_Z1fI1XEvPVN1AIT_E1TE +void f(A::T volatile*) +f +# +--format=gnu-v3 --no-params +_ZngILi42EEvN1AIXplT_Li2EEE1TE +void operator-<42>(A<(42)+(2)>::T) +operator-<42> +# +--format=gnu-v3 --no-params +_Z4makeI7FactoryiET_IT0_Ev +Factory make() +make +# +--format=gnu-v3 --no-params +_Z4makeI7FactoryiET_IT0_Ev +Factory make() +make +# +--format=gnu-v3 --no-params +_Z3foo5Hello5WorldS0_S_ +foo(Hello, World, World, Hello) +foo +# +--format=gnu-v3 --no-params +_Z3fooPM2ABi +foo(int AB::**) +foo +# +--format=gnu-v3 --no-params +_ZlsRSoRKSs +operator<<(std::ostream&, std::string const&) +operator<< +# +--format=gnu-v3 --no-params +_ZTI7a_class +typeinfo for a_class +typeinfo for a_class +# +--format=gnu-v3 --no-params +U4_farrVKPi +int* const volatile restrict _far +int* const volatile restrict _far +# +--format=gnu-v3 --no-params +_Z3fooILi2EEvRAplT_Li1E_i +void foo<2>(int (&) [(2)+(1)]) +foo<2> +# +--format=gnu-v3 --no-params +_Z3fooILi2EEvOAplT_Li1E_i +void foo<2>(int (&&) [(2)+(1)]) +foo<2> +# +--format=gnu-v3 --no-params +_Z1fM1AKFvvE +f(void (A::*)() const) +f +# +--format=gnu-v3 --no-params +_Z3fooc +foo(char) +foo +# +--format=gnu-v3 --no-params +_Z2f0u8char16_t +f0(char16_t) +f0 +# +--format=gnu-v3 --no-params +_Z2f0Pu8char16_t +f0(char16_t*) +f0 +# +--format=gnu-v3 --no-params +_Z2f0u8char32_t +f0(char32_t) +f0 +# +--format=gnu-v3 --no-params +_Z2f0Pu8char32_t +f0(char32_t*) +f0 +# +--format=gnu-v3 --no-params +2CBIL_Z3foocEE +CB +CB +# +--format=gnu-v3 --no-params +2CBIL_Z7IsEmptyEE +CB +CB +# +--format=gnu-v3 --no-params +_ZZN1N1fEiE1p +N::f(int)::p +N::f(int)::p +# +--format=gnu-v3 --no-params +_ZZN1N1fEiEs +N::f(int)::string literal +N::f(int)::string literal +# +--format=gnu-v3 --no-params +_Z1fPFvvEM1SFvvE +f(void (*)(), void (S::*)()) +f +# +--format=gnu-v3 --no-params +_ZN1N1TIiiE2mfES0_IddE +N::T::mf(N::T) +N::T::mf +# +--format=gnu-v3 --no-params +_ZSt5state +std::state +std::state +# +--format=gnu-v3 --no-params +_ZNSt3_In4wardE +std::_In::ward +std::_In::ward +# +--format=gnu-v3 --no-params +_Z1fKPFiiE +f(int (* const)(int)) +f +# +--format=gnu-v3 --no-params +_Z1fAszL_ZZNK1N1A1fEvE3foo_0E_i +f(int [sizeof (N::A::f() const::foo)]) +f +# +--format=gnu-v3 --no-params +_Z1fA37_iPS_ +f(int [37], int (*) [37]) +f +# +--format=gnu-v3 --no-params +_Z1fM1AFivEPS0_ +f(int (A::*)(), int (*)()) +f +# +--format=gnu-v3 --no-params +_Z1fPFPA1_ivE +f(int (*(*)()) [1]) +f +# +--format=gnu-v3 --no-params +_Z1fPKM1AFivE +f(int (A::* const*)()) +f +# +--format=gnu-v3 --no-params +_Z1jM1AFivEPS1_ +j(int (A::*)(), int (A::**)()) +j +# +--format=gnu-v3 --no-params +_Z1sPA37_iPS0_ +s(int (*) [37], int (**) [37]) +s +# +--format=gnu-v3 --no-params +_Z3fooA30_A_i +foo(int [30][]) +foo +# +--format=gnu-v3 --no-params +_Z3kooPA28_A30_i +koo(int (*) [28][30]) +koo +# +--format=gnu-v3 --no-params +_ZlsRKU3fooU4bart1XS0_ +operator<<(X bart foo const&, X bart) +operator<< +# +--format=gnu-v3 --no-params +_ZlsRKU3fooU4bart1XS2_ +operator<<(X bart foo const&, X bart foo const) +operator<< +# +--format=gnu-v3 --no-params +_Z1fM1AKFivE +f(int (A::*)() const) +f +# +--format=gnu-v3 --no-params +_Z3absILi11EEvv +void abs<11>() +abs<11> +# +--format=gnu-v3 --no-params +_ZN1AIfEcvT_IiEEv +A::operator int() +A::operator int +# +--format=gnu-v3 --no-params +_ZN12libcw_app_ct10add_optionIS_EEvMT_FvPKcES3_cS3_S3_ +void libcw_app_ct::add_option(void (libcw_app_ct::*)(char const*), char const*, char, char const*, char const*) +libcw_app_ct::add_option +# +--format=gnu-v3 --no-params +_ZGVN5libcw24_GLOBAL__N_cbll.cc0ZhUKa23compiler_bug_workaroundISt6vectorINS_13omanip_id_tctINS_5debug32memblk_types_manipulator_data_ctEEESaIS6_EEE3idsE +guard variable for libcw::(anonymous namespace)::compiler_bug_workaround, std::allocator > > >::ids +guard variable for libcw::(anonymous namespace)::compiler_bug_workaround, std::allocator > > >::ids +# +--format=gnu-v3 --no-params +_ZN5libcw5debug13cwprint_usingINS_9_private_12GlobalObjectEEENS0_17cwprint_using_tctIT_EERKS5_MS5_KFvRSt7ostreamE +libcw::debug::cwprint_using_tct libcw::debug::cwprint_using(libcw::_private_::GlobalObject const&, void (libcw::_private_::GlobalObject::*)(std::ostream&) const) +libcw::debug::cwprint_using +# +--format=gnu-v3 --no-params +_ZNKSt14priority_queueIP27timer_event_request_base_ctSt5dequeIS1_SaIS1_EE13timer_greaterE3topEv +std::priority_queue >, timer_greater>::top() const +std::priority_queue >, timer_greater>::top +# +--format=gnu-v3 --no-params +_ZNKSt15_Deque_iteratorIP15memory_block_stRKS1_PS2_EeqERKS5_ +std::_Deque_iterator::operator==(std::_Deque_iterator const&) const +std::_Deque_iterator::operator== +# +--format=gnu-v3 --no-params +_ZNKSt17__normal_iteratorIPK6optionSt6vectorIS0_SaIS0_EEEmiERKS6_ +std::__normal_iterator