diff --git a/lldb/include/lldb/Target/Language.h b/lldb/include/lldb/Target/Language.h --- a/lldb/include/lldb/Target/Language.h +++ b/lldb/include/lldb/Target/Language.h @@ -187,9 +187,9 @@ // If a language can have more than one possible name for a method, this // function can be used to enumerate them. This is useful when doing name // lookups. - virtual std::vector + virtual std::vector> GetMethodNameVariants(ConstString method_name) const { - return std::vector(); + return std::vector>(); }; /// Returns true iff the given symbol name is compatible with the mangling diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp --- a/lldb/source/Breakpoint/BreakpointResolverName.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -220,7 +220,8 @@ m_lookups.emplace_back(lookup); auto add_variant_funcs = [&](Language *lang) { - for (ConstString variant_name : lang->GetMethodNameVariants(name)) { + for (auto variant_name_and_type : lang->GetMethodNameVariants(name)) { + auto variant_name = variant_name_and_type.first; Module::LookupInfo variant_lookup(name, name_type_mask, lang->GetLanguageType()); variant_lookup.SetLookupName(variant_name); diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.h @@ -100,7 +100,8 @@ // variant_names[1] => "-[NSString(my_additions) myStringWithCString:]" // variant_names[2] => "+[NSString myStringWithCString:]" // variant_names[3] => "-[NSString myStringWithCString:]" - std::vector + // We also return the FunctionNameType of each possible name. + std::vector> GetMethodNameVariants(ConstString method_name) const override; bool SymbolNameFitsToLanguage(Mangled mangled) const override; diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -225,14 +225,17 @@ return ConstString(); } -std::vector +std::vector> ObjCLanguage::GetMethodNameVariants(ConstString method_name) const { - std::vector variant_names; + std::vector> variant_names; ObjCLanguage::MethodName objc_method(method_name.GetCString(), false); if (!objc_method.IsValid(false)) { return variant_names; } + variant_names.emplace_back(std::make_pair(objc_method.GetSelector(), + lldb::eFunctionNameTypeSelector)); + const bool is_class_method = objc_method.GetType() == MethodName::eTypeClassMethod; const bool is_instance_method = @@ -242,25 +245,30 @@ if (is_class_method || is_instance_method) { if (name_sans_category) - variant_names.emplace_back(name_sans_category); + variant_names.emplace_back( + std::make_pair(name_sans_category, lldb::eFunctionNameTypeFull)); } else { StreamString strm; strm.Printf("+%s", objc_method.GetFullName().GetCString()); - variant_names.emplace_back(strm.GetString()); + variant_names.emplace_back( + std::make_pair(strm.GetString(), lldb::eFunctionNameTypeFull)); strm.Clear(); strm.Printf("-%s", objc_method.GetFullName().GetCString()); - variant_names.emplace_back(strm.GetString()); + variant_names.emplace_back( + std::make_pair(strm.GetString(), lldb::eFunctionNameTypeFull)); strm.Clear(); if (name_sans_category) { strm.Printf("+%s", name_sans_category.GetCString()); - variant_names.emplace_back(strm.GetString()); + variant_names.emplace_back( + std::make_pair(strm.GetString(), lldb::eFunctionNameTypeFull)); strm.Clear(); strm.Printf("-%s", name_sans_category.GetCString()); - variant_names.emplace_back(strm.GetString()); + variant_names.emplace_back( + std::make_pair(strm.GetString(), lldb::eFunctionNameTypeFull)); } } diff --git a/lldb/source/Symbol/CMakeLists.txt b/lldb/source/Symbol/CMakeLists.txt --- a/lldb/source/Symbol/CMakeLists.txt +++ b/lldb/source/Symbol/CMakeLists.txt @@ -44,7 +44,6 @@ lldbHost lldbTarget lldbUtility - lldbPluginObjCLanguage LINK_COMPONENTS Support diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -9,8 +9,6 @@ #include #include -#include "Plugins/Language/ObjC/ObjCLanguage.h" - #include "lldb/Core/Module.h" #include "lldb/Core/RichManglingContext.h" #include "lldb/Core/Section.h" @@ -18,6 +16,7 @@ #include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Symtab.h" +#include "lldb/Target/Language.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/Timer.h" @@ -330,13 +329,14 @@ // If the demangled name turns out to be an ObjC name, and is a category // name, add the version without categories to the index too. - ObjCLanguage::MethodName objc_method(name.GetStringRef(), true); - if (objc_method.IsValid(true)) { - selector_to_index.Append(objc_method.GetSelector(), value); - - if (ConstString objc_method_no_category = - objc_method.GetFullNameWithoutCategory(true)) - name_to_index.Append(objc_method_no_category, value); + if (auto *objc_lang = Language::FindPlugin(lldb::eLanguageTypeObjC)) { + for (auto variant_name_and_type : + objc_lang->GetMethodNameVariants(name)) { + if (variant_name_and_type.second & lldb::eFunctionNameTypeSelector) + selector_to_index.Append(variant_name_and_type.first, value); + else if (variant_name_and_type.second & lldb::eFunctionNameTypeFull) + name_to_index.Append(variant_name_and_type.first, value); + } } } }