Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[lldb][test] Test all libcxxabi demangler test-cases against TrackingOutputBuffer #137793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Michael137
Copy link
Member

@Michael137 Michael137 commented Apr 29, 2025

To test the infrastructure added in #131836 in would be nice to confirm that we can reconstruct all kinds of demangled names. The libcxxabi test-suite already has all those test-cases.

This patch copies those test-cases (taken from libcxxabi/test/test_demangle.pass.cpp), reconstructs the name like LLDB would when showing backtraces, and confirms that all demangled names can be fully reconstructed.

Two open questions:

  1. Do we really want a copy of all those test-cases in LLDB? It's
    unlikely to be kept in sync with the demangler test-suite. It includes 30,000+ test-cases
  2. Do we want to turn the GetDemangledBasename/GetDemangledScope/etc. into public APIs (e.g., on TrackingOutputBuffer) so that we can use the exact same method of extraction in the tests?

@llvmbot llvmbot added the lldb label Apr 29, 2025
@Michael137 Michael137 requested a review from labath April 29, 2025 11:58
@llvmbot
Copy link
Member

llvmbot commented Apr 29, 2025

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

To test the infrastructure added in #131836 in would be nice to confirm that we can reconstruct all kinds of demangled names. The libcxxabi test-suite already has all those test-cases.

This patch copies those test-cases (taken from libcxxabi/test/test_demangle.pass.cpp), reconstructs the name like LLDB would when showing backtraces, and confirms that all demangled names can be fully reconstructed.

Two open questions:

  1. Do we really want a copy of all those test-cases in LLDB? It's
    unlikely to be kept in sync with the demangler test-suite.
  2. Do we want to turn the GetDemangledBasename/GetDemangledScope/etc. into public APIs (e.g., on TrackingOutputBuffer) so that we can use the exact same method of extraction in the tests?

Patch is 5.03 MiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/137793.diff

2 Files Affected:

  • (added) lldb/unittests/Core/DemanglingCorrectness.inc (+30218)
  • (modified) lldb/unittests/Core/MangledTest.cpp (+56)
diff --git a/lldb/unittests/Core/DemanglingCorrectness.inc b/lldb/unittests/Core/DemanglingCorrectness.inc
new file mode 100644
index 0000000000000..dee9de083c037
--- /dev/null
+++ b/lldb/unittests/Core/DemanglingCorrectness.inc
@@ -0,0 +1,30218 @@
+// Taken from libcxxabi/test/test_demangle.pass.cpp
+{"_Z1A", "A"},
+{"_Z1Av", "A()"},
+{"_Z1A1B1C", "A(B, C)"},
+{"_Z1fDB3_", "f(_BitInt(3))"},
+{"_Z1fDU10_", "f(unsigned _BitInt(10))"},
+{"_Z1fIfEvDUstPT__", "void f<float>(unsigned _BitInt(sizeof (float*)))"},
+{"_Z1fIiEvDBstPT__", "void f<int>(_BitInt(sizeof (int*)))"},
+{"_Z4testI1A1BE1Cv", "C test<A, B>()"},
+{"_Z4testI1A1BET0_T_S3_", "B test<A, B>(A, A)"},
+{"_ZN1SgtEi", "S::operator>(int)"},
+{"_ZrsI1QEiT_i", "int operator>><Q>(Q, int)"},
+{"_ZN13dyldbootstrap5startEPK12macho_headeriPPKcl", "dyldbootstrap::start(macho_header const*, int, char const**, long)"},
+{"_ZN4dyld17getExecutablePathEv", "dyld::getExecutablePath()"},
+{"_ZN4dyld22mainExecutablePreboundEv", "dyld::mainExecutablePrebound()"},
+{"_ZN4dyld14mainExecutableEv", "dyld::mainExecutable()"},
+{"_ZN4dyld21findImageByMachHeaderEPK11mach_header", "dyld::findImageByMachHeader(mach_header const*)"},
+{"_ZN4dyld26findImageContainingAddressEPKv", "dyld::findImageContainingAddress(void const*)"},
+{"_ZN4dyld17clearErrorMessageEv", "dyld::clearErrorMessage()"},
+{"_ZN4dyld15getErrorMessageEv", "dyld::getErrorMessage()"},
+{"_ZN4dyld24registerUndefinedHandlerEPFvPKcE", "dyld::registerUndefinedHandler(void (*)(char const*))"},
+{"_ZN4dyld19openSharedCacheFileEv", "dyld::openSharedCacheFile()"},
+{"_ZN4dyld15setErrorMessageEPKc", "dyld::setErrorMessage(char const*)"},
+{"_ZN4dyld22registerRemoveCallbackEPFvPK11mach_headerlE", "dyld::registerRemoveCallback(void (*)(mach_header const*, long))"},
+{"_ZN4dyld13inSharedCacheEPKc", "dyld::inSharedCache(char const*)"},
+{"_ZN4dyld15runInitializersEP11ImageLoader", "dyld::runInitializers(ImageLoader*)"},
+{"_ZN4dyld27findCoalescedExportedSymbolEPKcPPKN11ImageLoader6SymbolEPPKS2_", "dyld::findCoalescedExportedSymbol(char const*, ImageLoader::Symbol const**, ImageLoader const**)"},
+{"_ZN4dyld22flatFindExportedSymbolEPKcPPKN11ImageLoader6SymbolEPPKS2_", "dyld::flatFindExportedSymbol(char const*, ImageLoader::Symbol const**, ImageLoader const**)"},
+{"_ZN4dyld15findLoadedImageERK4stat", "dyld::findLoadedImage(stat const&)"},
+{"_ZN4dyld24initializeMainExecutableEv", "dyld::initializeMainExecutable()"},
+{"_ZN4dyld4warnEPKcz", "dyld::warn(char const*, ...)"},
+{"_ZN4dyld29processDyldEnvironmentVaribleEPKcS1_", "dyld::processDyldEnvironmentVarible(char const*, char const*)"},
+{"_ZN4dyld3logEPKcz", "dyld::log(char const*, ...)"},
+{"_ZN4dyld6throwfEPKcz", "dyld::throwf(char const*, ...)"},
+{"_ZN4dyld9mkstringfEPKcz", "dyld::mkstringf(char const*, ...)"},
+{"_ZN4dyld14addMappedRangeEP11ImageLoadermm", "dyld::addMappedRange(ImageLoader*, unsigned long, unsigned long)"},
+{"_Z28coresymbolication_load_imageP25CSCppDyldSharedMemoryPagePK11ImageLoadery", "coresymbolication_load_image(CSCppDyldSharedMemoryPage*, ImageLoader const*, unsigned long long)"},
+{"_Z30coresymbolication_unload_imageP25CSCppDyldSharedMemoryPagePK11ImageLoader", "coresymbolication_unload_image(CSCppDyldSharedMemoryPage*, ImageLoader const*)"},
+{"_ZN4dyld18getCoalescedImagesEPP11ImageLoader", "dyld::getCoalescedImages(ImageLoader**)"},
+{"_ZN4dyld25findImageContainingSymbolEPKv", "dyld::findImageContainingSymbol(void const*)"},
+{"_ZN4dyld19registerAddCallbackEPFvPK11mach_headerlE", "dyld::registerAddCallback(void (*)(mach_header const*, long))"},
+{"_ZN4dyld14forEachImageDoEPFvP11ImageLoaderPvES2_", "dyld::forEachImageDo(void (*)(ImageLoader*, void*), void*)"},
+{"_ZN4dyld15getIndexedImageEj", "dyld::getIndexedImage(unsigned int)"},
+{"_ZN4dyld13getImageCountEv", "dyld::getImageCount()"},
+{"_ZN4dyld10validImageEPK11ImageLoader", "dyld::validImage(ImageLoader const*)"},
+{"_ZN4dyld30flatFindExportedSymbolWithHintEPKcS1_PPKN11ImageLoader6SymbolEPPKS2_", "dyld::flatFindExportedSymbolWithHint(char const*, char const*, ImageLoader::Symbol const**, ImageLoader const**)"},
+{"_ZN4dyld14loadFromMemoryEPKhyPKc", "dyld::loadFromMemory(unsigned char const*, unsigned long long, char const*)"},
+{"_ZN4dyld36registerImageStateBatchChangeHandlerE17dyld_image_statesPFPKcS0_jPK15dyld_image_infoE", "dyld::registerImageStateBatchChangeHandler(dyld_image_states, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*))"},
+{"_ZN4dyld37registerImageStateSingleChangeHandlerE17dyld_image_statesPFPKcS0_jPK15dyld_image_infoE", "dyld::registerImageStateSingleChangeHandler(dyld_image_states, char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*))"},
+{"_ZN4dyld4haltEPKc", "dyld::halt(char const*)"},
+{"_ZN4dyld18fastBindLazySymbolEPP11ImageLoaderm", "dyld::fastBindLazySymbol(ImageLoader**, unsigned long)"},
+{"_ZN4dyld14bindLazySymbolEPK11mach_headerPm", "dyld::bindLazySymbol(mach_header const*, unsigned long*)"},
+{"_ZN4dyld14runTerminatorsEPv", "dyld::runTerminators(void*)"},
+{"_ZN4dyld11removeImageEP11ImageLoader", "dyld::removeImage(ImageLoader*)"},
+{"_ZN4dyld20garbageCollectImagesEv", "dyld::garbageCollectImages()"},
+{"_ZN4dyld9preflightEP11ImageLoaderRKNS0_10RPathChainE", "dyld::preflight(ImageLoader*, ImageLoader::RPathChain const&)"},
+{"_ZN4dyld4linkEP11ImageLoaderbRKNS0_10RPathChainE", "dyld::link(ImageLoader*, bool, ImageLoader::RPathChain const&)"},
+{"_ZN4dyld10cloneImageEP11ImageLoader", "dyld::cloneImage(ImageLoader*)"},
+{"_ZN4dyld4loadEPKcRKNS_11LoadContextE", "dyld::load(char const*, dyld::LoadContext const&)"},
+{"_ZN4dyld5_mainEPK12macho_headermiPPKcS5_S5_", "dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**)"},
+{"_ZNSt6vectorIN4dyld13RegisteredDOFESaIS1_EE5eraseEN9__gnu_cxx17__normal_iteratorIPS1_S3_EE", "std::vector<dyld::RegisteredDOF, std::allocator<dyld::RegisteredDOF>>::erase(__gnu_cxx::__normal_iterator<dyld::RegisteredDOF*, std::vector<dyld::RegisteredDOF, std::allocator<dyld::RegisteredDOF>>>)"},
+{"_ZNSt12_Vector_baseIPKcSaIS1_EED2Ev", "std::_Vector_base<char const*, std::allocator<char const*>>::~_Vector_base()"},
+{"_ZNSt6vectorIPKcSaIS1_EED2Ev", "std::vector<char const*, std::allocator<char const*>>::~vector()"},
+{"_ZNSt12_Vector_baseIPFPKc17dyld_image_statesjPK15dyld_image_infoESaIS7_EED2Ev", "std::_Vector_base<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), std::allocator<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)>>::~_Vector_base()"},
+{"_ZNSt6vectorIPFPKc17dyld_image_statesjPK15dyld_image_infoESaIS7_EED2Ev", "std::vector<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), std::allocator<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)>>::~vector()"},
+{"_ZNSt12_Vector_baseIPFvPK11mach_headerlESaIS4_EED2Ev", "std::_Vector_base<void (*)(mach_header const*, long), std::allocator<void (*)(mach_header const*, long)>>::~_Vector_base()"},
+{"_ZNSt6vectorIPFvPK11mach_headerlESaIS4_EED2Ev", "std::vector<void (*)(mach_header const*, long), std::allocator<void (*)(mach_header const*, long)>>::~vector()"},
+{"_ZNSt12_Vector_baseIN4dyld13RegisteredDOFESaIS1_EED2Ev", "std::_Vector_base<dyld::RegisteredDOF, std::allocator<dyld::RegisteredDOF>>::~_Vector_base()"},
+{"_ZNSt6vectorIN4dyld13RegisteredDOFESaIS1_EED2Ev", "std::vector<dyld::RegisteredDOF, std::allocator<dyld::RegisteredDOF>>::~vector()"},
+{"_ZNSt12_Vector_baseIP11ImageLoaderSaIS1_EED2Ev", "std::_Vector_base<ImageLoader*, std::allocator<ImageLoader*>>::~_Vector_base()"},
+{"_ZNSt6vectorIP11ImageLoaderSaIS1_EED2Ev", "std::vector<ImageLoader*, std::allocator<ImageLoader*>>::~vector()"},
+{"_ZN9__gnu_cxx13new_allocatorIPFPKc17dyld_image_statesjPK15dyld_image_infoEE8allocateEmPKv", "__gnu_cxx::new_allocator<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)>::allocate(unsigned long, void const*)"},
+{"_ZN9__gnu_cxx13new_allocatorIPFvPK11mach_headerlEE8allocateEmPKv", "__gnu_cxx::new_allocator<void (*)(mach_header const*, long)>::allocate(unsigned long, void const*)"},
+{"_ZN9__gnu_cxx13new_allocatorIPKcE8allocateEmPKv", "__gnu_cxx::new_allocator<char const*>::allocate(unsigned long, void const*)"},
+{"_ZN9__gnu_cxx13new_allocatorIP11ImageLoaderE8allocateEmPKv", "__gnu_cxx::new_allocator<ImageLoader*>::allocate(unsigned long, void const*)"},
+{"_ZN9__gnu_cxx13new_allocatorIN4dyld13RegisteredDOFEE8allocateEmPKv", "__gnu_cxx::new_allocator<dyld::RegisteredDOF>::allocate(unsigned long, void const*)"},
+{"_ZNSt6vectorIN4dyld13RegisteredDOFESaIS1_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS1_S3_EERKS1_", "std::vector<dyld::RegisteredDOF, std::allocator<dyld::RegisteredDOF>>::_M_insert_aux(__gnu_cxx::__normal_iterator<dyld::RegisteredDOF*, std::vector<dyld::RegisteredDOF, std::allocator<dyld::RegisteredDOF>>>, dyld::RegisteredDOF const&)"},
+{"_ZNSt6vectorIN4dyld13RegisteredDOFESaIS1_EE9push_backERKS1_", "std::vector<dyld::RegisteredDOF, std::allocator<dyld::RegisteredDOF>>::push_back(dyld::RegisteredDOF const&)"},
+{"_ZSt18uninitialized_copyIPPFPKc17dyld_image_statesjPK15dyld_image_infoES8_ET0_T_SA_S9_", "char const* (**std::uninitialized_copy<char const* (**)(dyld_image_states, unsigned int, dyld_image_info const*), char const* (**)(dyld_image_states, unsigned int, dyld_image_info const*)>(char const* (**)(dyld_image_states, unsigned int, dyld_image_info const*), char const* (**)(dyld_image_states, unsigned int, dyld_image_info const*), char const* (**)(dyld_image_states, unsigned int, dyld_image_info const*)))(dyld_image_states, unsigned int, dyld_image_info const*)"},
+{"_ZSt18uninitialized_copyIPPFvPK11mach_headerlES5_ET0_T_S7_S6_", "void (**std::uninitialized_copy<void (**)(mach_header const*, long), void (**)(mach_header const*, long)>(void (**)(mach_header const*, long), void (**)(mach_header const*, long), void (**)(mach_header const*, long)))(mach_header const*, long)"},
+{"_ZSt18uninitialized_copyIPPKcS2_ET0_T_S4_S3_", "char const** std::uninitialized_copy<char const**, char const**>(char const**, char const**, char const**)"},
+{"_ZNSt15__copy_backwardILb1ESt26random_access_iterator_tagE8__copy_bIPFPKc17dyld_image_statesjPK15dyld_image_infoEEEPT_PKSB_SE_SC_", "char const* (**std::__copy_backward<true, std::random_access_iterator_tag>::__copy_b<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)>(char const* (* const*)(dyld_image_states, unsigned int, dyld_image_info const*), char const* (* const*)(dyld_image_states, unsigned int, dyld_image_info const*), char const* (**)(dyld_image_states, unsigned int, dyld_image_info const*)))(dyld_image_states, unsigned int, dyld_image_info const*)"},
+{"_ZNSt6vectorIPFPKc17dyld_image_statesjPK15dyld_image_infoESaIS7_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS7_S9_EERKS7_", "std::vector<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), std::allocator<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)>>::_M_insert_aux(__gnu_cxx::__normal_iterator<char const* (**)(dyld_image_states, unsigned int, dyld_image_info const*), std::vector<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), std::allocator<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)>>>, char const* (* const&)(dyld_image_states, unsigned int, dyld_image_info const*))"},
+{"_ZNSt6vectorIPFPKc17dyld_image_statesjPK15dyld_image_infoESaIS7_EE6insertEN9__gnu_cxx17__normal_iteratorIPS7_S9_EERKS7_", "std::vector<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), std::allocator<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)>>::insert(__gnu_cxx::__normal_iterator<char const* (**)(dyld_image_states, unsigned int, dyld_image_info const*), std::vector<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), std::allocator<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)>>>, char const* (* const&)(dyld_image_states, unsigned int, dyld_image_info const*))"},
+{"_ZNSt6vectorIPFPKc17dyld_image_statesjPK15dyld_image_infoESaIS7_EE9push_backERKS7_", "std::vector<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*), std::allocator<char const* (*)(dyld_image_states, unsigned int, dyld_image_info const*)>>::push_back(char const* (* const&)(dyld_image_states, unsigned int, dyld_image_info const*))"},
+{"_ZNSt15__copy_backwardILb1ESt26random_access_iterator_tagE8__copy_bIPFvPK11mach_headerlEEEPT_PKS8_SB_S9_", "void (**std::__copy_backward<true, std::random_access_iterator_tag>::__copy_b<void (*)(mach_header const*, long)>(void (* const*)(mach_header const*, long), void (* const*)(mach_header const*, long), void (**)(mach_header const*, long)))(mach_header const*, long)"},
+{"_ZNSt6vectorIPFvPK11mach_headerlESaIS4_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS4_S6_EERKS4_", "std::vector<void (*)(mach_header const*, long), std::allocator<void (*)(mach_header const*, long)>>::_M_insert_aux(__gnu_cxx::__normal_iterator<void (**)(mach_header const*, long), std::vector<void (*)(mach_header const*, long), std::allocator<void (*)(mach_header const*, long)>>>, void (* const&)(mach_header const*, long))"},
+{"_ZNSt6vectorIPFvPK11mach_headerlESaIS4_EE9push_backERKS4_", "std::vector<void (*)(mach_header const*, long), std::allocator<void (*)(mach_header const*, long)>>::push_back(void (* const&)(mach_header const*, long))"},
+{"_ZNSt15__copy_backwardILb1ESt26random_access_iterator_tagE8__copy_bIPKcEEPT_PKS5_S8_S6_", "char const** std::__copy_backward<true, std::random_access_iterator_tag>::__copy_b<char const*>(char const* const*, char const* const*, char const**)"},
+{"_ZNSt6vectorIPKcSaIS1_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS1_S3_EERKS1_", "std::vector<char const*, std::allocator<char const*>>::_M_insert_aux(__gnu_cxx::__normal_iterator<char const**, std::vector<char const*, std::allocator<char const*>>>, char const* const&)"},
+{"_ZNSt6vectorIPKcSaIS1_EE9push_backERKS1_", "std::vector<char const*, std::allocator<char const*>>::push_back(char const* const&)"},
+{"_ZNSt15__copy_backwardILb1ESt26random_access_iterator_tagE8__copy_bIP11ImageLoaderEEPT_PKS5_S8_S6_", "ImageLoader** std::__copy_backward<true, std::random_access_iterator_tag>::__copy_b<ImageLoader*>(ImageLoader* const*, ImageLoader* const*, ImageLoader**)"},
+{"_ZNSt6vectorIPFvPK11mach_headerlESaIS4_EE20_M_allocate_and_copyIPS4_EES8_mT_S9_", "void (**std::vector<void (*)(mach_header const*, long), std::allocator<void (*)(mach_header const*, long)>>::_M_allocate_and_copy<void (**)(mach_header const*, long)>(unsigned long, void (**)(mach_header const*, long), void (**)(mach_header const*, long)))(mach_header const*, long)"},
+{"_ZNSt6vectorIPFvPK11mach_headerlESaIS4_EE7reserveEm", "std::vector<void (*)(mach_header const*, long), std::allocator<void (*)(mach_header const*, long)>>::reserve(unsigned long)"},
+{"_ZNSt6vectorIN4dyld13RegisteredDOFESaIS1_EE20_M_allocate_and_copyIPS1_EES5_mT_S6_", "dyld::RegisteredDOF* std::vector<dyld::RegisteredDOF, std::allocator<dyld::RegisteredDOF>>::_M_allocate_and_copy<dyld::RegisteredDOF*>(unsigned long, dyld::RegisteredDOF*, dyld::RegisteredDOF*)"},
+{"_ZNSt6vectorIN4dyld13RegisteredDOFESaIS1_EE7reserveEm", "std::vector<dyld::RegisteredDOF, std::allocator<dyld::RegisteredDOF>>::reserve(unsigned long)"},
+{"_ZSt18uninitialized_copyIPP11ImageLoaderS2_ET0_T_S4_S3_", "ImageLoader** std::uninitialized_copy<ImageLoader**, ImageLoader**>(ImageLoader**, ImageLoader**, ImageLoader**)"},
+{"_ZNSt6vectorIP11ImageLoaderSaIS1_EE20_M_allocate_and_copyIPS1_EES5_mT_S6_", "ImageLoader** std::vector<ImageLoader*, std::allocator<ImageLoader*>>::_M_allocate_and_copy<ImageLoader**>(unsigned long, ImageLoader**, ImageLoader**)"},
+{"_ZNSt6vectorIP11ImageLoaderSaIS1_EE7reserveEm", "std::vector<ImageLoader*, std::allocator<ImageLoader*>>::reserve(unsigned long)"},
+{"_ZNSt6vectorIP11ImageLoaderSaIS1_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS1_S3_EERKS1_", "std::vector<ImageLoader*, std::allocator<ImageLoader*>>::_M_insert_aux(__gnu_cxx::__normal_iterator<ImageLoader**, std::vector<ImageLoader*, std::allocator<ImageLoader*>>>, ImageLoader* const&)"},
+{"_ZNSt6vectorIP11ImageLoaderSaIS1_EE9push_backERKS1_", "std::vector<ImageLoader*, std::allocator<ImageLoader*>>::push_back(ImageLoader* const&)"},
+{"_ZNSt6vectorIP11ImageLoaderSaIS1_EE5eraseEN9__gnu_cxx17__normal_iteratorIPS1_S3_EE", "std::vector<ImageLoader*, std::allocator<ImageLoader*>>::erase(__gnu_cxx::__normal_iterator<ImageLoader**, std::vector<ImageLoader*, std::allocator<ImageLoader*>>>)"},
+{"_Z18lookupDyldFunctionPKcPm", "lookupDyldFunction(char const*, unsigned long*)"},
+{"_ZNSt12_Vector_baseIP19__NSObjectFileImageSaIS1_EED2Ev", "std::_Vector_base<__NSObjectFileImage*, std::allocator<__NSObjectFileImage*>>::~_Vector_base()"},
+{"_ZNSt6vectorIP19__NSObjectFileImageSaIS1_EED2Ev", "std::vector<__NSObjectFileImage*, std::allocator<__NSObjectFileImage*>>::~vector()"},
+{"_ZNSt15__copy_backwardILb1ESt26random_access_iterator_tagE8__copy_bIP19__NSObjectFileImageEEPT_PKS5_S8_S6_", "__NSObjectFileImage** std::__copy_backward<true, std::random_access_iterator_tag>::__copy_b<__NSObjectFileImage*>(__NSObjectFileImage* const*, __NSObjectFileImage* const*, __NSObjectFileImage**)"},
+{"_ZN9__gnu_cxx13new_allocatorIP19__NSObjectFileImageE8allocateEmPKv", "__gnu_cxx::new_allocator<__NSObjectFileImage*>::allocate(unsigned long, void const*)"},
+{"_ZNSt6vectorIP19__NSObjectFileImageSaIS1_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS1_S3_EERKS1_", "std::vector<__NSObjectFileImage*, std::allocator<__NSObjectFileImage*>>::_M_insert_aux(__gnu_cxx::__normal_iterator<__NSObjectFileImage**, std::vector<__NSObjectFileImage*, std::allocator<__NSObjectFileImage*>>>, __NSObjectFileImage* const&)"},
+{"_ZNSt6vectorIP19__NSObjectFileImageSaIS1_EE9push_backERKS1_", "std::vector<__NSObjectFileImage*, std::allocator<__NSObjectFileImage*>>::push_back(__NSObjectFileImage* const&)"},
+{"_ZNSt6vectorIP19__NSObjectFileImageSaIS1_EE5eraseEN9__gnu_cxx17__normal_iteratorIPS1_S3_EE", "std::vector<__NSObjectFileImage*, std::allocator<__NSObjectFileImage*>>::erase(__gnu_cxx::__normal_iterator<__NSObjectFileImage**, std::vector<__NSObjectFileImage*, std::allocator<__NSObjectFileImage*>>>)"},
+{"_Z19setAlImageInfosHaltPKcm", "setAlImageInfosHalt(char const*, unsigned long)"},
+{"_Z24removeImageFromAllImagesPK11mach_header", "removeImageFromAllImages(mach_header const*)"},
+{"_Z20addImagesToAllImagesjPK15dyld_image_info", "addImagesToAllImages(unsigned int, dyld_image_info const*)"},
+{"_ZNSt6vectorI15dyld_image_infoSaIS0_EE5eraseEN9__gnu_cxx17__normal_iteratorIPS0_S2_EE", "std::vector<dyld_image_info, std::allocator<dyld_image_info>>::erase(__gnu_cxx::__normal_iterator<dyld_image_info*, std::vector<dyld_image_info, std::allocator<dyld_image_info>>>)"},
+{"_ZNSt12_Vector_baseI15dyld_image_infoSaIS0_EED2Ev", "std::_Vector_base<dyld_image_info, std::allocator<dyld_image_info>>::~_Vector_base()"},
+{"_ZNSt6vectorI15dyld_image_infoSaIS0_EED2Ev", "std::vector<dyld_image_info, std::allocator<dyld_image_info>>::~vector()"},
+{"_ZN9__gnu_cxx13new_allocatorI15dyld_image_infoE8allocateEmPKv", "__gnu_cxx::new_allocator<dyld_image_info>::allocate(unsigned long, void const*)"},
+{"_ZNSt6vectorI15dyld_image_infoSaIS0_EE20_M_allocate_and_copyIPS0_EES4_mT_S5_", "dyld_image_info* std::vector<dyld_image_info, std::allocator<dyld_image_info>>::_M_allocate_and_copy<dyld_image_info*>(unsigned long, dyld_image_info*, dyld_image_info*)"},
+{"_ZNSt6vectorI15dyld_image_infoSaIS0_EE7reserveEm", "std::vector<dyld_image_info, std::allocator<dyld_image_info>>::reserve(unsigned long)"},
+{"_ZNSt6vectorI15dyld_image_infoSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_", "std::vector<dyld_image_info, std::allocator<dyld_image_info>>::_M_insert_aux(__gnu_cxx::__normal_iterator<dyld_image_info*, std::vector<dyld_image_info, std::allocator<dyld_image_info>>>, dyld_image_info const&)"},
+{"_ZNSt6vectorI15dyld_image_infoSaIS0_EE9push_backERKS0_", "std::vector<dyld_image_info, std::allocator<dyld_image_info>>::push_back(dyld_image_info const&)"},
+{"_ZN10__cxxabiv112__unexpectedEPFvvE", "__cxxabiv1::__unexpected(void (*)())"},
+{"_ZN10__cxxabiv111__terminateEPFvvE", "__cxxabiv1::__terminate(void (*)())"},
+{"_ZSt10unexpectedv", "std::unexpected()"},
+{"_ZSt9terminat...
[truncated]

Copy link

⚠️ undef deprecator found issues in your code. ⚠️

You can test this locally with the following command:
git diff -U0 --pickaxe-regex -S '([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)' 'HEAD~1' HEAD lldb/unittests/Core/DemanglingCorrectness.inc lldb/unittests/Core/MangledTest.cpp

The following files introduce new uses of undef:

  • lldb/unittests/Core/DemanglingCorrectness.inc

Undef is now deprecated and should only be used in the rare cases where no replacement is possible. For example, a load of uninitialized memory yields undef. You should use poison values for placeholders instead.

In tests, avoid using undef and having tests that trigger undefined behavior. If you need an operand with some unimportant value, you can add a new argument to the function and use that instead.

For example, this is considered a bad practice:

define void @fn() {
  ...
  br i1 undef, ...
}

Please use the following instead:

define void @fn(i1 %cond) {
  ...
  br i1 %cond, ...
}

Please refer to the Undefined Behavior Manual for more information.

@Michael137 Michael137 force-pushed the lldb/demangler-correctness-tests branch 2 times, most recently from 04bd72c to fd1526d Compare April 29, 2025 12:02
Copy link

github-actions bot commented Apr 29, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

…OutputBuffer

To test the infrastructure added in llvm#131836 in would be nice to confirm that we can reconstruct all kinds of demangled names. The libcxxabi test-suite already has all those test-cases.

This patch copies those test-cases (taken from `libcxxabi/test/test_demangle.pass.cpp`), reconstructs the name like LLDB would when showing backtraces, and confirms that all demangled names can be fully reconstructed.

Two open questions:
1. Do we really want a copy of all those test-cases in LLDB? It's
   unlikely to be kept in sync with the demangler test-suite.
2. Do we want to turn the `GetDemangledBasename`/`GetDemangledScope`/etc. into public APIs (e.g., on `TrackingOutputBuffer`) so that we can use the exact same method of extraction in the tests?
@Michael137 Michael137 force-pushed the lldb/demangler-correctness-tests branch from fd1526d to dcbaa3b Compare April 29, 2025 13:25
@adrian-prantl
Copy link
Collaborator

Do we really want a copy of all those test-cases in LLDB?

Is it also in the monorepo? Can we just use a relative path to the file?

@Michael137
Copy link
Member Author

Do we really want a copy of all those test-cases in LLDB?

Is it also in the monorepo? Can we just use a relative path to the file?

Yup it is in the libcxxabi subdirectory. Is there precendent for such cross-project references ? (i guess header includes would be an example :) ). Happy to do that if that's acceptable

@DavidSpickett
Copy link
Collaborator

i guess header includes would be an example

Headers like ADT and so on are included in installed copies of LLVM but testing files are not.

So would this break testing a standalone LLDB build? Or do we expect "standalone" to mean you configure from lldb/ but you do have the rest of the monorepo there as well.

There are those per-project tar files for each release but I'm not sure what we intend people to do with them.

...but maybe you can sidestep that by saying that libcxx must be available?

@labath
Copy link
Collaborator

labath commented Apr 30, 2025

Including a random file from the libc++ subproject sounds like a bad idea to me. I certainly hope we don't have a precedent for that.

For the way you're using these files (as a gtest unit test), I think it'd be best if the tests were in llvm/include/llvm/Testing/Demangle. That would most likely be a problem for libc++ since they don't want to depend on llvm (even the demangler is copied into the llvm tree instead of being reused somehow). According to this, it might be possible to move the test to llvm and then you could do what I suggest. I don't know what's the amount of wishful thinking in that comment though...

Just a note, that if you do decide to copy the tests, it may be better to just copy the inputs (mangled names) and then compare the "normal" demangled names with the ones you reconstructed. This avoids needing to update two places in case e.g. the demangler produces extra spaces somewhere.

@Michael137
Copy link
Member Author

For the way you're using these files (as a gtest unit test), I think it'd be best if the tests were in llvm/include/llvm/Testing/Demangle.

Let me try proposing moving the test and see what they say. Making changes to the demangler you have to run two sets of test-suites already anyway (check-cxxabi and check-llvm-demangle, and there's other demangling tests sprinkled around llvm). Just having to run one target would be nice.

Just a note, that if you do decide to copy the tests, it may be better to just copy the inputs (mangled names) and then compare the "normal" demangled names with the ones you reconstructed. This avoids needing to update two places in case e.g. the demangler produces extra spaces somewhere.

Good point, will do!

@Michael137
Copy link
Member Author

Proposed moving the tests here: #137947

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants