From 205afe679855a4ce8149cdaa94d3f0868ce796dc Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Fri, 6 Feb 2015 21:38:51 +0000 Subject: Import LLDB as of upstream SVN r225923 (git 2b588ecd) This corresponds with the branchpoint for the 3.6 release. A number of files not required for the FreeBSD build have been removed. Sponsored by: DARPA, AFRL --- source/Core/Mangled.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'source/Core/Mangled.cpp') diff --git a/source/Core/Mangled.cpp b/source/Core/Mangled.cpp index c4fa10fedd863..c0ab66cd2880a 100644 --- a/source/Core/Mangled.cpp +++ b/source/Core/Mangled.cpp @@ -4986,10 +4986,12 @@ __cxa_demangle(const char* mangled_name, char* buf, size_t* n, int* status) #include "lldb/Core/RegularExpression.h" #include "lldb/Core/Stream.h" #include "lldb/Core/Timer.h" +#include "lldb/Target/CPPLanguageRuntime.h" #include #include #include + using namespace lldb_private; static inline bool @@ -5000,6 +5002,57 @@ cstring_is_mangled (const char *s) return false; } +static const ConstString & +get_demangled_name_without_arguments (const Mangled *obj) +{ + // This pair is + static std::pair g_most_recent_mangled_to_name_sans_args; + + // Need to have the mangled & demangled names we're currently examining as statics + // so we can return a const ref to them at the end of the func if we don't have + // anything better. + static ConstString g_last_mangled; + static ConstString g_last_demangled; + + ConstString mangled = obj->GetMangledName (); + ConstString demangled = obj->GetDemangledName (); + + if (mangled && g_most_recent_mangled_to_name_sans_args.first == mangled) + { + return g_most_recent_mangled_to_name_sans_args.second; + } + + g_last_demangled = demangled; + g_last_mangled = mangled; + + const char *mangled_name_cstr = mangled.GetCString(); + + if (demangled && mangled_name_cstr && mangled_name_cstr[0]) + { + if (mangled_name_cstr[0] == '_' && mangled_name_cstr[1] == 'Z' && + (mangled_name_cstr[2] != 'T' && // avoid virtual table, VTT structure, typeinfo structure, and typeinfo mangled_name + mangled_name_cstr[2] != 'G' && // avoid guard variables + mangled_name_cstr[2] != 'Z')) // named local entities (if we eventually handle eSymbolTypeData, we will want this back) + { + CPPLanguageRuntime::MethodName cxx_method (demangled); + if (!cxx_method.GetBasename().empty() && !cxx_method.GetContext().empty()) + { + std::string shortname = cxx_method.GetContext().str(); + shortname += "::"; + shortname += cxx_method.GetBasename().str(); + ConstString result(shortname.c_str()); + g_most_recent_mangled_to_name_sans_args.first = mangled; + g_most_recent_mangled_to_name_sans_args.second = result; + return g_most_recent_mangled_to_name_sans_args.second; + } + } + } + + if (demangled) + return g_last_demangled; + return g_last_mangled; +} + #pragma mark Mangled //---------------------------------------------------------------------- // Default constructor @@ -5215,6 +5268,14 @@ Mangled::NameMatches (const RegularExpression& regex) const const ConstString& Mangled::GetName (Mangled::NamePreference preference) const { + if (preference == ePreferDemangledWithoutArguments) + { + // Call the accessor to make sure we get a demangled name in case + // it hasn't been demangled yet... + GetDemangledName(); + + return get_demangled_name_without_arguments (this); + } if (preference == ePreferDemangled) { // Call the accessor to make sure we get a demangled name in case -- cgit v1.2.3