forked from OSchip/llvm-project
Extend FindTypes with CompilerContext to allow filtering by language.
This patch is also motivated by the Swift branch and is effectively NFC for the single-TypeSystem llvm.org branch. In multi-language projects it is extremely common to have, e.g., a Clang type and a similarly-named rendition of that same type in another language. When searching for a type It is much cheaper to pass a set of supported languages to the SymbolFile than having it materialize every result and then rejecting the materialized types that have the wrong language. Differential Revision: https://reviews.llvm.org/D66546 <rdar://problem/54471165> This reapplies r369690 with a previously missing constructor for LanguageSet. llvm-svn: 369710
This commit is contained in:
parent
f88dfd8309
commit
aa97a89d83
|
@ -454,6 +454,14 @@ public:
|
||||||
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
|
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
|
||||||
TypeList &types);
|
TypeList &types);
|
||||||
|
|
||||||
|
/// Find types by name.
|
||||||
|
///
|
||||||
|
/// This behaves like the other FindTypes method but allows to
|
||||||
|
/// specify a DeclContext and a language for the type being searched
|
||||||
|
/// for.
|
||||||
|
size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
||||||
|
LanguageSet languages, bool append, TypeMap &types);
|
||||||
|
|
||||||
lldb::TypeSP FindFirstType(const SymbolContext &sc,
|
lldb::TypeSP FindFirstType(const SymbolContext &sc,
|
||||||
ConstString type_name, bool exact_match);
|
ConstString type_name, bool exact_match);
|
||||||
|
|
||||||
|
|
|
@ -385,10 +385,10 @@ public:
|
||||||
GetInstrumentationRuntimeCreateCallbackForPluginName(ConstString name);
|
GetInstrumentationRuntimeCreateCallbackForPluginName(ConstString name);
|
||||||
|
|
||||||
// TypeSystem
|
// TypeSystem
|
||||||
static bool RegisterPlugin(
|
static bool RegisterPlugin(ConstString name, const char *description,
|
||||||
ConstString name, const char *description,
|
TypeSystemCreateInstance create_callback,
|
||||||
TypeSystemCreateInstance create_callback,
|
LanguageSet supported_languages_for_types,
|
||||||
TypeSystemEnumerateSupportedLanguages enumerate_languages_callback);
|
LanguageSet supported_languages_for_expressions);
|
||||||
|
|
||||||
static bool UnregisterPlugin(TypeSystemCreateInstance create_callback);
|
static bool UnregisterPlugin(TypeSystemCreateInstance create_callback);
|
||||||
|
|
||||||
|
@ -398,18 +398,14 @@ public:
|
||||||
static TypeSystemCreateInstance
|
static TypeSystemCreateInstance
|
||||||
GetTypeSystemCreateCallbackForPluginName(ConstString name);
|
GetTypeSystemCreateCallbackForPluginName(ConstString name);
|
||||||
|
|
||||||
static TypeSystemEnumerateSupportedLanguages
|
static LanguageSet GetAllTypeSystemSupportedLanguagesForTypes();
|
||||||
GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
|
|
||||||
|
|
||||||
static TypeSystemEnumerateSupportedLanguages
|
static LanguageSet GetAllTypeSystemSupportedLanguagesForExpressions();
|
||||||
GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName(
|
|
||||||
ConstString name);
|
|
||||||
|
|
||||||
// REPL
|
// REPL
|
||||||
static bool
|
static bool RegisterPlugin(ConstString name, const char *description,
|
||||||
RegisterPlugin(ConstString name, const char *description,
|
REPLCreateInstance create_callback,
|
||||||
REPLCreateInstance create_callback,
|
LanguageSet supported_languages);
|
||||||
REPLEnumerateSupportedLanguages enumerate_languages_callback);
|
|
||||||
|
|
||||||
static bool UnregisterPlugin(REPLCreateInstance create_callback);
|
static bool UnregisterPlugin(REPLCreateInstance create_callback);
|
||||||
|
|
||||||
|
@ -418,12 +414,7 @@ public:
|
||||||
static REPLCreateInstance
|
static REPLCreateInstance
|
||||||
GetREPLCreateCallbackForPluginName(ConstString name);
|
GetREPLCreateCallbackForPluginName(ConstString name);
|
||||||
|
|
||||||
static REPLEnumerateSupportedLanguages
|
static LanguageSet GetREPLAllTypeSystemSupportedLanguages();
|
||||||
GetREPLEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
|
|
||||||
|
|
||||||
static REPLEnumerateSupportedLanguages
|
|
||||||
GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName(
|
|
||||||
ConstString name);
|
|
||||||
|
|
||||||
// Some plug-ins might register a DebuggerInitializeCallback callback when
|
// Some plug-ins might register a DebuggerInitializeCallback callback when
|
||||||
// registering the plug-in. After a new Debugger instance is created, this
|
// registering the plug-in. After a new Debugger instance is created, this
|
||||||
|
@ -441,32 +432,28 @@ public:
|
||||||
ConstString description, bool is_global_property);
|
ConstString description, bool is_global_property);
|
||||||
|
|
||||||
static lldb::OptionValuePropertiesSP
|
static lldb::OptionValuePropertiesSP
|
||||||
GetSettingForPlatformPlugin(Debugger &debugger,
|
GetSettingForPlatformPlugin(Debugger &debugger, ConstString setting_name);
|
||||||
ConstString setting_name);
|
|
||||||
|
|
||||||
static bool CreateSettingForPlatformPlugin(
|
static bool CreateSettingForPlatformPlugin(
|
||||||
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
||||||
ConstString description, bool is_global_property);
|
ConstString description, bool is_global_property);
|
||||||
|
|
||||||
static lldb::OptionValuePropertiesSP
|
static lldb::OptionValuePropertiesSP
|
||||||
GetSettingForProcessPlugin(Debugger &debugger,
|
GetSettingForProcessPlugin(Debugger &debugger, ConstString setting_name);
|
||||||
ConstString setting_name);
|
|
||||||
|
|
||||||
static bool CreateSettingForProcessPlugin(
|
static bool CreateSettingForProcessPlugin(
|
||||||
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
||||||
ConstString description, bool is_global_property);
|
ConstString description, bool is_global_property);
|
||||||
|
|
||||||
static lldb::OptionValuePropertiesSP
|
static lldb::OptionValuePropertiesSP
|
||||||
GetSettingForSymbolFilePlugin(Debugger &debugger,
|
GetSettingForSymbolFilePlugin(Debugger &debugger, ConstString setting_name);
|
||||||
ConstString setting_name);
|
|
||||||
|
|
||||||
static bool CreateSettingForSymbolFilePlugin(
|
static bool CreateSettingForSymbolFilePlugin(
|
||||||
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
||||||
ConstString description, bool is_global_property);
|
ConstString description, bool is_global_property);
|
||||||
|
|
||||||
static lldb::OptionValuePropertiesSP
|
static lldb::OptionValuePropertiesSP
|
||||||
GetSettingForJITLoaderPlugin(Debugger &debugger,
|
GetSettingForJITLoaderPlugin(Debugger &debugger, ConstString setting_name);
|
||||||
ConstString setting_name);
|
|
||||||
|
|
||||||
static bool CreateSettingForJITLoaderPlugin(
|
static bool CreateSettingForJITLoaderPlugin(
|
||||||
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
|
||||||
|
|
|
@ -68,9 +68,8 @@ public:
|
||||||
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
|
static lldb::TypeSystemSP CreateInstance(lldb::LanguageType language,
|
||||||
Module *module, Target *target);
|
Module *module, Target *target);
|
||||||
|
|
||||||
static void EnumerateSupportedLanguages(
|
static LanguageSet GetSupportedLanguagesForTypes();
|
||||||
std::set<lldb::LanguageType> &languages_for_types,
|
static LanguageSet GetSupportedLanguagesForExpressions();
|
||||||
std::set<lldb::LanguageType> &languages_for_expressions);
|
|
||||||
|
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "lldb/Symbol/SourceModule.h"
|
#include "lldb/Symbol/SourceModule.h"
|
||||||
#include "lldb/Symbol/Type.h"
|
#include "lldb/Symbol/Type.h"
|
||||||
#include "lldb/Symbol/TypeList.h"
|
#include "lldb/Symbol/TypeList.h"
|
||||||
|
#include "lldb/Symbol/TypeSystem.h"
|
||||||
#include "lldb/lldb-private.h"
|
#include "lldb/lldb-private.h"
|
||||||
|
|
||||||
#include "llvm/ADT/DenseSet.h"
|
#include "llvm/ADT/DenseSet.h"
|
||||||
|
@ -189,7 +190,11 @@ public:
|
||||||
bool append, uint32_t max_matches,
|
bool append, uint32_t max_matches,
|
||||||
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
|
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
|
||||||
TypeMap &types);
|
TypeMap &types);
|
||||||
virtual size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern, bool append,
|
|
||||||
|
/// Find types specified by a CompilerContextPattern.
|
||||||
|
/// \param languages Only return results in these languages.
|
||||||
|
virtual size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
||||||
|
LanguageSet languages, bool append,
|
||||||
TypeMap &types);
|
TypeMap &types);
|
||||||
|
|
||||||
virtual void
|
virtual void
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "llvm/ADT/APSInt.h"
|
#include "llvm/ADT/APSInt.h"
|
||||||
|
#include "llvm/ADT/SmallBitVector.h"
|
||||||
#include "llvm/Support/Casting.h"
|
#include "llvm/Support/Casting.h"
|
||||||
#include "llvm/Support/Error.h"
|
#include "llvm/Support/Error.h"
|
||||||
|
|
||||||
|
@ -30,7 +31,24 @@ class PDBASTParser;
|
||||||
|
|
||||||
namespace lldb_private {
|
namespace lldb_private {
|
||||||
|
|
||||||
// Interface for representing the Type Systems in different languages.
|
/// A SmallBitVector that represents a set of source languages (\p
|
||||||
|
/// lldb::LanguageType). Each lldb::LanguageType is represented by
|
||||||
|
/// the bit with the position of its enumerator. The largest
|
||||||
|
/// LanguageType is < 64, so this is space-efficient and on 64-bit
|
||||||
|
/// architectures a LanguageSet can be completely stack-allocated.
|
||||||
|
struct LanguageSet {
|
||||||
|
llvm::SmallBitVector bitvector;
|
||||||
|
LanguageSet();
|
||||||
|
|
||||||
|
/// If the set contains a single language only, return it.
|
||||||
|
llvm::Optional<lldb::LanguageType> GetSingularLanguage();
|
||||||
|
void Insert(lldb::LanguageType language);
|
||||||
|
bool Empty() const;
|
||||||
|
size_t Size() const;
|
||||||
|
bool operator[](unsigned i) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Interface for representing the Type Systems in different languages.
|
||||||
class TypeSystem : public PluginInterface {
|
class TypeSystem : public PluginInterface {
|
||||||
public:
|
public:
|
||||||
// Intrusive type system that allows us to use llvm casting.
|
// Intrusive type system that allows us to use llvm casting.
|
||||||
|
|
|
@ -267,12 +267,9 @@ public:
|
||||||
|
|
||||||
static std::set<lldb::LanguageType> GetSupportedLanguages();
|
static std::set<lldb::LanguageType> GetSupportedLanguages();
|
||||||
|
|
||||||
static void GetLanguagesSupportingTypeSystems(
|
static LanguageSet GetLanguagesSupportingTypeSystems();
|
||||||
std::set<lldb::LanguageType> &languages,
|
static LanguageSet GetLanguagesSupportingTypeSystemsForExpressions();
|
||||||
std::set<lldb::LanguageType> &languages_for_expressions);
|
static LanguageSet GetLanguagesSupportingREPLs();
|
||||||
|
|
||||||
static void
|
|
||||||
GetLanguagesSupportingREPLs(std::set<lldb::LanguageType> &languages);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Classes that inherit from Language can see and modify these
|
// Classes that inherit from Language can see and modify these
|
||||||
|
|
|
@ -102,11 +102,6 @@ typedef lldb::REPLSP (*REPLCreateInstance)(Status &error,
|
||||||
lldb::LanguageType language,
|
lldb::LanguageType language,
|
||||||
Debugger *debugger, Target *target,
|
Debugger *debugger, Target *target,
|
||||||
const char *repl_options);
|
const char *repl_options);
|
||||||
typedef void (*TypeSystemEnumerateSupportedLanguages)(
|
|
||||||
std::set<lldb::LanguageType> &languages_for_types,
|
|
||||||
std::set<lldb::LanguageType> &languages_for_expressions);
|
|
||||||
typedef void (*REPLEnumerateSupportedLanguages)(
|
|
||||||
std::set<lldb::LanguageType> &languages);
|
|
||||||
typedef int (*ComparisonFunction)(const void *, const void *);
|
typedef int (*ComparisonFunction)(const void *, const void *);
|
||||||
typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
|
typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,21 @@
|
||||||
; Test finding types by CompilerContext.
|
; Test finding types by CompilerContext.
|
||||||
; RUN: llc %s -filetype=obj -o %t.o
|
; RUN: llc %s -filetype=obj -o %t.o
|
||||||
; RUN: lldb-test symbols %t.o -find=type \
|
; RUN: lldb-test symbols %t.o -find=type --language=C99 \
|
||||||
; RUN: -compiler-context="Module:CModule,Module:SubModule,Struct:FromSubmoduleX" \
|
; RUN: -compiler-context="Module:CModule,Module:SubModule,Struct:FromSubmoduleX" \
|
||||||
; RUN: | FileCheck %s --check-prefix=NORESULTS
|
; RUN: | FileCheck %s --check-prefix=NORESULTS
|
||||||
; RUN: lldb-test symbols %t.o -find=type \
|
; RUN: lldb-test symbols %t.o -find=type --language=C++ \
|
||||||
|
; RUN: -compiler-context="Module:CModule,Module:SubModule,Struct:FromSubmodule" \
|
||||||
|
; RUN: | FileCheck %s --check-prefix=NORESULTS
|
||||||
|
; RUN: lldb-test symbols %t.o -find=type --language=C99 \
|
||||||
; RUN: -compiler-context="Module:CModule,Module:SubModule,Struct:FromSubmodule" \
|
; RUN: -compiler-context="Module:CModule,Module:SubModule,Struct:FromSubmodule" \
|
||||||
; RUN: | FileCheck %s
|
; RUN: | FileCheck %s
|
||||||
; RUN: lldb-test symbols %t.o -find=type \
|
; RUN: lldb-test symbols %t.o -find=type --language=C99 \
|
||||||
; RUN: -compiler-context="Module:CModule,AnyModule:*,Struct:FromSubmodule" \
|
; RUN: -compiler-context="Module:CModule,AnyModule:*,Struct:FromSubmodule" \
|
||||||
; RUN: | FileCheck %s
|
; RUN: | FileCheck %s
|
||||||
; RUN: lldb-test symbols %t.o -find=type \
|
; RUN: lldb-test symbols %t.o -find=type --language=C99 \
|
||||||
; RUN: -compiler-context="AnyModule:*,Struct:FromSubmodule" \
|
; RUN: -compiler-context="AnyModule:*,Struct:FromSubmodule" \
|
||||||
; RUN: | FileCheck %s
|
; RUN: | FileCheck %s
|
||||||
; RUN: lldb-test symbols %t.o -find=type \
|
; RUN: lldb-test symbols %t.o -find=type --language=C99 \
|
||||||
; RUN: -compiler-context="Module:CModule,Module:SubModule,AnyType:FromSubmodule" \
|
; RUN: -compiler-context="Module:CModule,Module:SubModule,AnyType:FromSubmodule" \
|
||||||
; RUN: | FileCheck %s
|
; RUN: | FileCheck %s
|
||||||
;
|
;
|
||||||
|
|
|
@ -1623,13 +1623,11 @@ Status Debugger::RunREPL(LanguageType language, const char *repl_options) {
|
||||||
FileSpec repl_executable;
|
FileSpec repl_executable;
|
||||||
|
|
||||||
if (language == eLanguageTypeUnknown) {
|
if (language == eLanguageTypeUnknown) {
|
||||||
std::set<LanguageType> repl_languages;
|
LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs();
|
||||||
|
|
||||||
Language::GetLanguagesSupportingREPLs(repl_languages);
|
if (auto single_lang = repl_languages.GetSingularLanguage()) {
|
||||||
|
language = *single_lang;
|
||||||
if (repl_languages.size() == 1) {
|
} else if (repl_languages.Empty()) {
|
||||||
language = *repl_languages.begin();
|
|
||||||
} else if (repl_languages.empty()) {
|
|
||||||
err.SetErrorStringWithFormat(
|
err.SetErrorStringWithFormat(
|
||||||
"LLDB isn't configured with REPL support for any languages.");
|
"LLDB isn't configured with REPL support for any languages.");
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -1037,6 +1037,15 @@ size_t Module::FindTypes(
|
||||||
return num_matches;
|
return num_matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t Module::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
||||||
|
LanguageSet languages, bool append, TypeMap &types) {
|
||||||
|
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
|
||||||
|
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
|
||||||
|
if (SymbolFile *symbols = GetSymbolFile())
|
||||||
|
return symbols->FindTypes(pattern, languages, append, types);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
SymbolFile *Module::GetSymbolFile(bool can_create, Stream *feedback_strm) {
|
SymbolFile *Module::GetSymbolFile(bool can_create, Stream *feedback_strm) {
|
||||||
if (!m_did_load_symfile.load()) {
|
if (!m_did_load_symfile.load()) {
|
||||||
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
std::lock_guard<std::recursive_mutex> guard(m_mutex);
|
||||||
|
|
|
@ -2083,12 +2083,11 @@ PluginManager::GetInstrumentationRuntimeCreateCallbackForPluginName(
|
||||||
#pragma mark TypeSystem
|
#pragma mark TypeSystem
|
||||||
|
|
||||||
struct TypeSystemInstance {
|
struct TypeSystemInstance {
|
||||||
TypeSystemInstance() : name(), description(), create_callback(nullptr) {}
|
|
||||||
|
|
||||||
ConstString name;
|
ConstString name;
|
||||||
std::string description;
|
std::string description;
|
||||||
TypeSystemCreateInstance create_callback;
|
TypeSystemCreateInstance create_callback;
|
||||||
TypeSystemEnumerateSupportedLanguages enumerate_callback;
|
LanguageSet supported_languages_for_types;
|
||||||
|
LanguageSet supported_languages_for_expressions;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<TypeSystemInstance> TypeSystemInstances;
|
typedef std::vector<TypeSystemInstance> TypeSystemInstances;
|
||||||
|
@ -2103,11 +2102,11 @@ static TypeSystemInstances &GetTypeSystemInstances() {
|
||||||
return g_instances;
|
return g_instances;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PluginManager::RegisterPlugin(ConstString name,
|
bool PluginManager::RegisterPlugin(
|
||||||
const char *description,
|
ConstString name, const char *description,
|
||||||
TypeSystemCreateInstance create_callback,
|
TypeSystemCreateInstance create_callback,
|
||||||
TypeSystemEnumerateSupportedLanguages
|
LanguageSet supported_languages_for_types,
|
||||||
enumerate_supported_languages_callback) {
|
LanguageSet supported_languages_for_expressions) {
|
||||||
if (create_callback) {
|
if (create_callback) {
|
||||||
TypeSystemInstance instance;
|
TypeSystemInstance instance;
|
||||||
assert((bool)name);
|
assert((bool)name);
|
||||||
|
@ -2115,7 +2114,8 @@ bool PluginManager::RegisterPlugin(ConstString name,
|
||||||
if (description && description[0])
|
if (description && description[0])
|
||||||
instance.description = description;
|
instance.description = description;
|
||||||
instance.create_callback = create_callback;
|
instance.create_callback = create_callback;
|
||||||
instance.enumerate_callback = enumerate_supported_languages_callback;
|
instance.supported_languages_for_types = supported_languages_for_types;
|
||||||
|
instance.supported_languages_for_expressions = supported_languages_for_expressions;
|
||||||
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
|
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
|
||||||
GetTypeSystemInstances().push_back(instance);
|
GetTypeSystemInstances().push_back(instance);
|
||||||
}
|
}
|
||||||
|
@ -2163,30 +2163,22 @@ PluginManager::GetTypeSystemCreateCallbackForPluginName(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeSystemEnumerateSupportedLanguages
|
LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForTypes() {
|
||||||
PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(
|
|
||||||
uint32_t idx) {
|
|
||||||
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
|
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
|
||||||
|
LanguageSet all;
|
||||||
TypeSystemInstances &instances = GetTypeSystemInstances();
|
TypeSystemInstances &instances = GetTypeSystemInstances();
|
||||||
if (idx < instances.size())
|
for (unsigned i = 0; i < instances.size(); ++i)
|
||||||
return instances[idx].enumerate_callback;
|
all.bitvector |= instances[i].supported_languages_for_types.bitvector;
|
||||||
return nullptr;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeSystemEnumerateSupportedLanguages
|
LanguageSet PluginManager::GetAllTypeSystemSupportedLanguagesForExpressions() {
|
||||||
PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName(
|
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
|
||||||
ConstString name) {
|
LanguageSet all;
|
||||||
if (name) {
|
TypeSystemInstances &instances = GetTypeSystemInstances();
|
||||||
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
|
for (unsigned i = 0; i < instances.size(); ++i)
|
||||||
TypeSystemInstances &instances = GetTypeSystemInstances();
|
all.bitvector |= instances[i].supported_languages_for_expressions.bitvector;
|
||||||
|
return all;
|
||||||
TypeSystemInstances::iterator pos, end = instances.end();
|
|
||||||
for (pos = instances.begin(); pos != end; ++pos) {
|
|
||||||
if (name == pos->name)
|
|
||||||
return pos->enumerate_callback;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark REPL
|
#pragma mark REPL
|
||||||
|
@ -2197,7 +2189,7 @@ struct REPLInstance {
|
||||||
ConstString name;
|
ConstString name;
|
||||||
std::string description;
|
std::string description;
|
||||||
REPLCreateInstance create_callback;
|
REPLCreateInstance create_callback;
|
||||||
REPLEnumerateSupportedLanguages enumerate_languages_callback;
|
LanguageSet supported_languages;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector<REPLInstance> REPLInstances;
|
typedef std::vector<REPLInstance> REPLInstances;
|
||||||
|
@ -2212,10 +2204,9 @@ static REPLInstances &GetREPLInstances() {
|
||||||
return g_instances;
|
return g_instances;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PluginManager::RegisterPlugin(
|
bool PluginManager::RegisterPlugin(ConstString name, const char *description,
|
||||||
ConstString name, const char *description,
|
REPLCreateInstance create_callback,
|
||||||
REPLCreateInstance create_callback,
|
LanguageSet supported_languages) {
|
||||||
REPLEnumerateSupportedLanguages enumerate_languages_callback) {
|
|
||||||
if (create_callback) {
|
if (create_callback) {
|
||||||
REPLInstance instance;
|
REPLInstance instance;
|
||||||
assert((bool)name);
|
assert((bool)name);
|
||||||
|
@ -2223,7 +2214,7 @@ bool PluginManager::RegisterPlugin(
|
||||||
if (description && description[0])
|
if (description && description[0])
|
||||||
instance.description = description;
|
instance.description = description;
|
||||||
instance.create_callback = create_callback;
|
instance.create_callback = create_callback;
|
||||||
instance.enumerate_languages_callback = enumerate_languages_callback;
|
instance.supported_languages = supported_languages;
|
||||||
std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
|
std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
|
||||||
GetREPLInstances().push_back(instance);
|
GetREPLInstances().push_back(instance);
|
||||||
}
|
}
|
||||||
|
@ -2269,29 +2260,13 @@ PluginManager::GetREPLCreateCallbackForPluginName(ConstString name) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
REPLEnumerateSupportedLanguages
|
LanguageSet PluginManager::GetREPLAllTypeSystemSupportedLanguages() {
|
||||||
PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx) {
|
|
||||||
std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
|
std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
|
||||||
|
LanguageSet all;
|
||||||
REPLInstances &instances = GetREPLInstances();
|
REPLInstances &instances = GetREPLInstances();
|
||||||
if (idx < instances.size())
|
for (unsigned i = 0; i < instances.size(); ++i)
|
||||||
return instances[idx].enumerate_languages_callback;
|
all.bitvector |= instances[i].supported_languages.bitvector;
|
||||||
return nullptr;
|
return all;
|
||||||
}
|
|
||||||
|
|
||||||
REPLEnumerateSupportedLanguages
|
|
||||||
PluginManager::GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName(
|
|
||||||
ConstString name) {
|
|
||||||
if (name) {
|
|
||||||
std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
|
|
||||||
REPLInstances &instances = GetREPLInstances();
|
|
||||||
|
|
||||||
REPLInstances::iterator pos, end = instances.end();
|
|
||||||
for (pos = instances.begin(); pos != end; ++pos) {
|
|
||||||
if (name == pos->name)
|
|
||||||
return pos->enumerate_languages_callback;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark PluginManager
|
#pragma mark PluginManager
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "lldb/DataFormatters/FormatManager.h"
|
#include "lldb/DataFormatters/FormatManager.h"
|
||||||
#include "lldb/Target/Language.h"
|
#include "lldb/Target/Language.h"
|
||||||
|
#include "lldb/Symbol/TypeSystem.h"
|
||||||
#include "lldb/Utility/Args.h"
|
#include "lldb/Utility/Args.h"
|
||||||
#include "lldb/Utility/Stream.h"
|
#include "lldb/Utility/Stream.h"
|
||||||
|
|
||||||
|
@ -39,23 +40,20 @@ Status OptionValueLanguage::SetValueFromString(llvm::StringRef value,
|
||||||
case eVarSetOperationReplace:
|
case eVarSetOperationReplace:
|
||||||
case eVarSetOperationAssign: {
|
case eVarSetOperationAssign: {
|
||||||
ConstString lang_name(value.trim());
|
ConstString lang_name(value.trim());
|
||||||
std::set<lldb::LanguageType> languages_for_types;
|
LanguageSet languages_for_types = Language::GetLanguagesSupportingTypeSystems();
|
||||||
std::set<lldb::LanguageType> languages_for_expressions;
|
|
||||||
Language::GetLanguagesSupportingTypeSystems(languages_for_types,
|
|
||||||
languages_for_expressions);
|
|
||||||
|
|
||||||
LanguageType new_type =
|
LanguageType new_type =
|
||||||
Language::GetLanguageTypeFromString(lang_name.GetStringRef());
|
Language::GetLanguageTypeFromString(lang_name.GetStringRef());
|
||||||
if (new_type && languages_for_types.count(new_type)) {
|
if (new_type && languages_for_types[new_type]) {
|
||||||
m_value_was_set = true;
|
m_value_was_set = true;
|
||||||
m_current_value = new_type;
|
m_current_value = new_type;
|
||||||
} else {
|
} else {
|
||||||
StreamString error_strm;
|
StreamString error_strm;
|
||||||
error_strm.Printf("invalid language type '%s', ", value.str().c_str());
|
error_strm.Printf("invalid language type '%s', ", value.str().c_str());
|
||||||
error_strm.Printf("valid values are:\n");
|
error_strm.Printf("valid values are:\n");
|
||||||
for (lldb::LanguageType language : languages_for_types) {
|
for (int bit : languages_for_types.bitvector.set_bits()) {
|
||||||
error_strm.Printf("%s%s%s", " ",
|
auto language = (LanguageType)bit;
|
||||||
Language::GetNameForLanguageType(language), "\n");
|
error_strm.Printf(" %s\n",
|
||||||
|
Language::GetNameForLanguageType(language));
|
||||||
}
|
}
|
||||||
error.SetErrorString(error_strm.GetString());
|
error.SetErrorString(error_strm.GetString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,7 +319,8 @@ uint32_t SymbolFileBreakpad::FindTypes(
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SymbolFileBreakpad::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
size_t SymbolFileBreakpad::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
||||||
bool append, TypeMap &types) {
|
LanguageSet languages, bool append,
|
||||||
|
TypeMap &types) {
|
||||||
if (!append)
|
if (!append)
|
||||||
types.Clear();
|
types.Clear();
|
||||||
return types.GetSize();
|
return types.GetSize();
|
||||||
|
|
|
@ -116,8 +116,8 @@ public:
|
||||||
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
|
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
|
||||||
TypeMap &types) override;
|
TypeMap &types) override;
|
||||||
|
|
||||||
size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern, bool append,
|
size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
||||||
TypeMap &types) override;
|
LanguageSet languages, bool append, TypeMap &types) override;
|
||||||
|
|
||||||
llvm::Expected<TypeSystem &>
|
llvm::Expected<TypeSystem &>
|
||||||
GetTypeSystemForLanguage(lldb::LanguageType language) override {
|
GetTypeSystemForLanguage(lldb::LanguageType language) override {
|
||||||
|
|
|
@ -148,7 +148,10 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWO(const DWARFDIE &die, Log *log) {
|
||||||
die.GetDeclContext(decl_context);
|
die.GetDeclContext(decl_context);
|
||||||
TypeMap dwo_types;
|
TypeMap dwo_types;
|
||||||
|
|
||||||
if (!dwo_module_sp->GetSymbolFile()->FindTypes(decl_context, true,
|
// The type in the Clang module must have the same langage as the current CU.
|
||||||
|
LanguageSet languages;
|
||||||
|
languages.Insert(die.GetCU()->GetLanguageType());
|
||||||
|
if (!dwo_module_sp->GetSymbolFile()->FindTypes(decl_context, languages, true,
|
||||||
dwo_types)) {
|
dwo_types)) {
|
||||||
if (!IsClangModuleFwdDecl(die))
|
if (!IsClangModuleFwdDecl(die))
|
||||||
return TypeSP();
|
return TypeSP();
|
||||||
|
@ -159,8 +162,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWO(const DWARFDIE &die, Log *log) {
|
||||||
for (const auto &name_module : sym_file.getExternalTypeModules()) {
|
for (const auto &name_module : sym_file.getExternalTypeModules()) {
|
||||||
if (!name_module.second)
|
if (!name_module.second)
|
||||||
continue;
|
continue;
|
||||||
if (name_module.second->GetSymbolFile()->FindTypes(decl_context, true,
|
if (name_module.second->GetSymbolFile()->FindTypes(
|
||||||
dwo_types))
|
decl_context, languages, true, dwo_types))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2485,7 +2485,8 @@ uint32_t SymbolFileDWARF::FindTypes(
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SymbolFileDWARF::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
size_t SymbolFileDWARF::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
||||||
bool append, TypeMap &types) {
|
LanguageSet languages, bool append,
|
||||||
|
TypeMap &types) {
|
||||||
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
|
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
|
||||||
if (!append)
|
if (!append)
|
||||||
types.Clear();
|
types.Clear();
|
||||||
|
@ -2508,6 +2509,9 @@ size_t SymbolFileDWARF::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
||||||
DWARFDIE die = GetDIE(die_ref);
|
DWARFDIE die = GetDIE(die_ref);
|
||||||
|
|
||||||
if (die) {
|
if (die) {
|
||||||
|
if (!languages[die.GetCU()->GetLanguageType()])
|
||||||
|
continue;
|
||||||
|
|
||||||
llvm::SmallVector<CompilerContext, 4> die_context;
|
llvm::SmallVector<CompilerContext, 4> die_context;
|
||||||
die.GetDeclContext(die_context);
|
die.GetDeclContext(die_context);
|
||||||
if (!contextMatches(die_context, pattern))
|
if (!contextMatches(die_context, pattern))
|
||||||
|
|
|
@ -185,7 +185,8 @@ public:
|
||||||
lldb_private::TypeMap &types) override;
|
lldb_private::TypeMap &types) override;
|
||||||
|
|
||||||
size_t FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern,
|
size_t FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern,
|
||||||
bool append, lldb_private::TypeMap &types) override;
|
lldb_private::LanguageSet languages, bool append,
|
||||||
|
lldb_private::TypeMap &types) override;
|
||||||
|
|
||||||
size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
|
size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
|
||||||
lldb::TypeClass type_mask,
|
lldb::TypeClass type_mask,
|
||||||
|
|
|
@ -1270,7 +1270,10 @@ uint32_t SymbolFileNativePDB::FindTypes(
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SymbolFileNativePDB::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
size_t SymbolFileNativePDB::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
||||||
bool append, TypeMap &types) {
|
LanguageSet languages, bool append,
|
||||||
|
TypeMap &types) {
|
||||||
|
if (!append)
|
||||||
|
types.Clear();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,8 +134,8 @@ public:
|
||||||
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
|
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
|
||||||
TypeMap &types) override;
|
TypeMap &types) override;
|
||||||
|
|
||||||
size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern, bool append,
|
size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
||||||
TypeMap &types) override;
|
LanguageSet languages, bool append, TypeMap &types) override;
|
||||||
|
|
||||||
llvm::Expected<TypeSystem &>
|
llvm::Expected<TypeSystem &>
|
||||||
GetTypeSystemForLanguage(lldb::LanguageType language) override;
|
GetTypeSystemForLanguage(lldb::LanguageType language) override;
|
||||||
|
|
|
@ -1585,7 +1585,10 @@ void SymbolFilePDB::FindTypesByName(
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SymbolFilePDB::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
size_t SymbolFilePDB::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
||||||
bool append, lldb_private::TypeMap &types) {
|
LanguageSet languages, bool append,
|
||||||
|
lldb_private::TypeMap &types) {
|
||||||
|
if (!append)
|
||||||
|
types.Clear();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,8 @@ public:
|
||||||
lldb_private::TypeMap &types) override;
|
lldb_private::TypeMap &types) override;
|
||||||
|
|
||||||
size_t FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern,
|
size_t FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern,
|
||||||
bool append, lldb_private::TypeMap &types) override;
|
lldb_private::LanguageSet languages, bool append,
|
||||||
|
lldb_private::TypeMap &types) override;
|
||||||
|
|
||||||
void FindTypesByRegex(const lldb_private::RegularExpression ®ex,
|
void FindTypesByRegex(const lldb_private::RegularExpression ®ex,
|
||||||
uint32_t max_matches, lldb_private::TypeMap &types);
|
uint32_t max_matches, lldb_private::TypeMap &types);
|
||||||
|
|
|
@ -734,32 +734,36 @@ lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language,
|
||||||
return lldb::TypeSystemSP();
|
return lldb::TypeSystemSP();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangASTContext::EnumerateSupportedLanguages(
|
LanguageSet ClangASTContext::GetSupportedLanguagesForTypes() {
|
||||||
std::set<lldb::LanguageType> &languages_for_types,
|
LanguageSet languages;
|
||||||
std::set<lldb::LanguageType> &languages_for_expressions) {
|
languages.Insert(lldb::eLanguageTypeC89);
|
||||||
static std::vector<lldb::LanguageType> s_supported_languages_for_types(
|
languages.Insert(lldb::eLanguageTypeC);
|
||||||
{lldb::eLanguageTypeC89, lldb::eLanguageTypeC, lldb::eLanguageTypeC11,
|
languages.Insert(lldb::eLanguageTypeC11);
|
||||||
lldb::eLanguageTypeC_plus_plus, lldb::eLanguageTypeC99,
|
languages.Insert(lldb::eLanguageTypeC_plus_plus);
|
||||||
lldb::eLanguageTypeObjC, lldb::eLanguageTypeObjC_plus_plus,
|
languages.Insert(lldb::eLanguageTypeC99);
|
||||||
lldb::eLanguageTypeC_plus_plus_03, lldb::eLanguageTypeC_plus_plus_11,
|
languages.Insert(lldb::eLanguageTypeObjC);
|
||||||
lldb::eLanguageTypeC11, lldb::eLanguageTypeC_plus_plus_14});
|
languages.Insert(lldb::eLanguageTypeObjC_plus_plus);
|
||||||
|
languages.Insert(lldb::eLanguageTypeC_plus_plus_03);
|
||||||
|
languages.Insert(lldb::eLanguageTypeC_plus_plus_11);
|
||||||
|
languages.Insert(lldb::eLanguageTypeC11);
|
||||||
|
languages.Insert(lldb::eLanguageTypeC_plus_plus_14);
|
||||||
|
return languages;
|
||||||
|
}
|
||||||
|
|
||||||
static std::vector<lldb::LanguageType> s_supported_languages_for_expressions(
|
LanguageSet ClangASTContext::GetSupportedLanguagesForExpressions() {
|
||||||
{lldb::eLanguageTypeC_plus_plus, lldb::eLanguageTypeObjC_plus_plus,
|
LanguageSet languages;
|
||||||
lldb::eLanguageTypeC_plus_plus_03, lldb::eLanguageTypeC_plus_plus_11,
|
languages.Insert(lldb::eLanguageTypeC_plus_plus);
|
||||||
lldb::eLanguageTypeC_plus_plus_14});
|
languages.Insert(lldb::eLanguageTypeObjC_plus_plus);
|
||||||
|
languages.Insert(lldb::eLanguageTypeC_plus_plus_03);
|
||||||
languages_for_types.insert(s_supported_languages_for_types.begin(),
|
languages.Insert(lldb::eLanguageTypeC_plus_plus_11);
|
||||||
s_supported_languages_for_types.end());
|
languages.Insert(lldb::eLanguageTypeC_plus_plus_14);
|
||||||
languages_for_expressions.insert(
|
return languages;
|
||||||
s_supported_languages_for_expressions.begin(),
|
|
||||||
s_supported_languages_for_expressions.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangASTContext::Initialize() {
|
void ClangASTContext::Initialize() {
|
||||||
PluginManager::RegisterPlugin(GetPluginNameStatic(),
|
PluginManager::RegisterPlugin(
|
||||||
"clang base AST context plug-in",
|
GetPluginNameStatic(), "clang base AST context plug-in", CreateInstance,
|
||||||
CreateInstance, EnumerateSupportedLanguages);
|
GetSupportedLanguagesForTypes(), GetSupportedLanguagesForExpressions());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangASTContext::Terminate() {
|
void ClangASTContext::Terminate() {
|
||||||
|
|
|
@ -150,7 +150,8 @@ uint32_t SymbolFile::FindTypes(
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SymbolFile::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
size_t SymbolFile::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
|
||||||
bool append, TypeMap &types) {
|
LanguageSet languages, bool append,
|
||||||
|
TypeMap &types) {
|
||||||
if (!append)
|
if (!append)
|
||||||
types.Clear();
|
types.Clear();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -25,6 +25,24 @@
|
||||||
using namespace lldb_private;
|
using namespace lldb_private;
|
||||||
using namespace lldb;
|
using namespace lldb;
|
||||||
|
|
||||||
|
/// A 64-bit SmallBitVector is only small up to 64-7 bits, and the
|
||||||
|
/// setBitsInMask interface wants to write full bytes.
|
||||||
|
static const size_t g_num_small_bitvector_bits = 64 - 8;
|
||||||
|
static_assert(eNumLanguageTypes < g_num_small_bitvector_bits,
|
||||||
|
"Languages bit vector is no longer small on 64 bit systems");
|
||||||
|
LanguageSet::LanguageSet() : bitvector(eNumLanguageTypes, 0) {}
|
||||||
|
|
||||||
|
llvm::Optional<LanguageType> LanguageSet::GetSingularLanguage() {
|
||||||
|
if (bitvector.count() == 1)
|
||||||
|
return (LanguageType)bitvector.find_first();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void LanguageSet::Insert(LanguageType language) { bitvector.set(language); }
|
||||||
|
size_t LanguageSet::Size() const { return bitvector.count(); }
|
||||||
|
bool LanguageSet::Empty() const { return bitvector.none(); }
|
||||||
|
bool LanguageSet::operator[](unsigned i) const { return bitvector[i]; }
|
||||||
|
|
||||||
TypeSystem::TypeSystem(LLVMCastKind kind) : m_kind(kind), m_sym_file(nullptr) {}
|
TypeSystem::TypeSystem(LLVMCastKind kind) : m_kind(kind), m_sym_file(nullptr) {}
|
||||||
|
|
||||||
TypeSystem::~TypeSystem() {}
|
TypeSystem::~TypeSystem() {}
|
||||||
|
|
|
@ -357,26 +357,16 @@ std::set<lldb::LanguageType> Language::GetSupportedLanguages() {
|
||||||
return supported_languages;
|
return supported_languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Language::GetLanguagesSupportingTypeSystems(
|
LanguageSet Language::GetLanguagesSupportingTypeSystems() {
|
||||||
std::set<lldb::LanguageType> &languages,
|
return PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
|
||||||
std::set<lldb::LanguageType> &languages_for_expressions) {
|
|
||||||
uint32_t idx = 0;
|
|
||||||
|
|
||||||
while (TypeSystemEnumerateSupportedLanguages enumerate = PluginManager::
|
|
||||||
GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(idx++)) {
|
|
||||||
(*enumerate)(languages, languages_for_expressions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Language::GetLanguagesSupportingREPLs(
|
LanguageSet Language::GetLanguagesSupportingTypeSystemsForExpressions() {
|
||||||
std::set<lldb::LanguageType> &languages) {
|
return PluginManager::GetAllTypeSystemSupportedLanguagesForExpressions();
|
||||||
uint32_t idx = 0;
|
}
|
||||||
|
|
||||||
while (REPLEnumerateSupportedLanguages enumerate =
|
LanguageSet Language::GetLanguagesSupportingREPLs() {
|
||||||
PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(
|
return PluginManager::GetREPLAllTypeSystemSupportedLanguages();
|
||||||
idx++)) {
|
|
||||||
(*enumerate)(languages);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Language::TypeScavenger> Language::GetTypeScavenger() {
|
std::unique_ptr<Language::TypeScavenger> Language::GetTypeScavenger() {
|
||||||
|
|
|
@ -206,13 +206,11 @@ const lldb::ProcessSP &Target::GetProcessSP() const { return m_process_sp; }
|
||||||
lldb::REPLSP Target::GetREPL(Status &err, lldb::LanguageType language,
|
lldb::REPLSP Target::GetREPL(Status &err, lldb::LanguageType language,
|
||||||
const char *repl_options, bool can_create) {
|
const char *repl_options, bool can_create) {
|
||||||
if (language == eLanguageTypeUnknown) {
|
if (language == eLanguageTypeUnknown) {
|
||||||
std::set<LanguageType> repl_languages;
|
LanguageSet repl_languages = Language::GetLanguagesSupportingREPLs();
|
||||||
|
|
||||||
Language::GetLanguagesSupportingREPLs(repl_languages);
|
if (auto single_lang = repl_languages.GetSingularLanguage()) {
|
||||||
|
language = *single_lang;
|
||||||
if (repl_languages.size() == 1) {
|
} else if (repl_languages.Empty()) {
|
||||||
language = *repl_languages.begin();
|
|
||||||
} else if (repl_languages.size() == 0) {
|
|
||||||
err.SetErrorStringWithFormat(
|
err.SetErrorStringWithFormat(
|
||||||
"LLDB isn't configured with REPL support for any languages.");
|
"LLDB isn't configured with REPL support for any languages.");
|
||||||
return REPLSP();
|
return REPLSP();
|
||||||
|
@ -2129,23 +2127,18 @@ Target::GetScratchTypeSystemForLanguage(lldb::LanguageType language,
|
||||||
if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all
|
if (language == eLanguageTypeMipsAssembler // GNU AS and LLVM use it for all
|
||||||
// assembly code
|
// assembly code
|
||||||
|| language == eLanguageTypeUnknown) {
|
|| language == eLanguageTypeUnknown) {
|
||||||
std::set<lldb::LanguageType> languages_for_types;
|
LanguageSet languages_for_expressions =
|
||||||
std::set<lldb::LanguageType> languages_for_expressions;
|
Language::GetLanguagesSupportingTypeSystemsForExpressions();
|
||||||
|
|
||||||
Language::GetLanguagesSupportingTypeSystems(languages_for_types,
|
if (languages_for_expressions[eLanguageTypeC]) {
|
||||||
languages_for_expressions);
|
|
||||||
|
|
||||||
if (languages_for_expressions.count(eLanguageTypeC)) {
|
|
||||||
language = eLanguageTypeC; // LLDB's default. Override by setting the
|
language = eLanguageTypeC; // LLDB's default. Override by setting the
|
||||||
// target language.
|
// target language.
|
||||||
} else {
|
} else {
|
||||||
if (languages_for_expressions.empty()) {
|
if (languages_for_expressions.Empty())
|
||||||
return llvm::make_error<llvm::StringError>(
|
return llvm::make_error<llvm::StringError>(
|
||||||
"No expression support for any languages",
|
"No expression support for any languages",
|
||||||
llvm::inconvertibleErrorCode());
|
llvm::inconvertibleErrorCode());
|
||||||
} else {
|
language = (LanguageType)languages_for_expressions.bitvector.find_first();
|
||||||
language = *languages_for_expressions.begin();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2159,21 +2152,19 @@ std::vector<TypeSystem *> Target::GetScratchTypeSystems(bool create_on_demand) {
|
||||||
|
|
||||||
std::vector<TypeSystem *> scratch_type_systems;
|
std::vector<TypeSystem *> scratch_type_systems;
|
||||||
|
|
||||||
std::set<lldb::LanguageType> languages_for_types;
|
LanguageSet languages_for_expressions =
|
||||||
std::set<lldb::LanguageType> languages_for_expressions;
|
Language::GetLanguagesSupportingTypeSystemsForExpressions();
|
||||||
|
|
||||||
Language::GetLanguagesSupportingTypeSystems(languages_for_types,
|
for (auto bit : languages_for_expressions.bitvector.set_bits()) {
|
||||||
languages_for_expressions);
|
auto language = (LanguageType)bit;
|
||||||
|
|
||||||
for (auto lang : languages_for_expressions) {
|
|
||||||
auto type_system_or_err =
|
auto type_system_or_err =
|
||||||
GetScratchTypeSystemForLanguage(lang, create_on_demand);
|
GetScratchTypeSystemForLanguage(language, create_on_demand);
|
||||||
if (!type_system_or_err)
|
if (!type_system_or_err)
|
||||||
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
|
LLDB_LOG_ERROR(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TARGET),
|
||||||
type_system_or_err.takeError(),
|
type_system_or_err.takeError(),
|
||||||
"Language '{}' has expression support but no scratch type "
|
"Language '{}' has expression support but no scratch type "
|
||||||
"system available",
|
"system available",
|
||||||
Language::GetNameForLanguageType(lang));
|
Language::GetNameForLanguageType(language));
|
||||||
else
|
else
|
||||||
scratch_type_systems.emplace_back(&type_system_or_err.get());
|
scratch_type_systems.emplace_back(&type_system_or_err.get());
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "lldb/Symbol/TypeList.h"
|
#include "lldb/Symbol/TypeList.h"
|
||||||
#include "lldb/Symbol/TypeMap.h"
|
#include "lldb/Symbol/TypeMap.h"
|
||||||
#include "lldb/Symbol/VariableList.h"
|
#include "lldb/Symbol/VariableList.h"
|
||||||
|
#include "lldb/Target/Language.h"
|
||||||
#include "lldb/Target/Process.h"
|
#include "lldb/Target/Process.h"
|
||||||
#include "lldb/Target/Target.h"
|
#include "lldb/Target/Target.h"
|
||||||
#include "lldb/Utility/CleanUp.h"
|
#include "lldb/Utility/CleanUp.h"
|
||||||
|
@ -144,6 +145,10 @@ static cl::opt<std::string> CompilerContext(
|
||||||
cl::desc("Specify a compiler context as \"kind:name,...\"."),
|
cl::desc("Specify a compiler context as \"kind:name,...\"."),
|
||||||
cl::value_desc("context"), cl::sub(SymbolsSubcommand));
|
cl::value_desc("context"), cl::sub(SymbolsSubcommand));
|
||||||
|
|
||||||
|
static cl::opt<std::string>
|
||||||
|
Language("language", cl::desc("Specify a language type, like C99."),
|
||||||
|
cl::value_desc("language"), cl::sub(SymbolsSubcommand));
|
||||||
|
|
||||||
static cl::list<FunctionNameType> FunctionNameFlags(
|
static cl::list<FunctionNameType> FunctionNameFlags(
|
||||||
"function-flags", cl::desc("Function search flags:"),
|
"function-flags", cl::desc("Function search flags:"),
|
||||||
cl::values(clEnumValN(eFunctionNameTypeAuto, "auto",
|
cl::values(clEnumValN(eFunctionNameTypeAuto, "auto",
|
||||||
|
@ -507,13 +512,17 @@ Error opts::symbols::findTypes(lldb_private::Module &Module) {
|
||||||
CompilerDeclContext *ContextPtr =
|
CompilerDeclContext *ContextPtr =
|
||||||
ContextOr->IsValid() ? &*ContextOr : nullptr;
|
ContextOr->IsValid() ? &*ContextOr : nullptr;
|
||||||
|
|
||||||
|
LanguageSet languages;
|
||||||
|
if (!Language.empty())
|
||||||
|
languages.Insert(Language::GetLanguageTypeFromString(Language));
|
||||||
|
|
||||||
DenseSet<SymbolFile *> SearchedFiles;
|
DenseSet<SymbolFile *> SearchedFiles;
|
||||||
TypeMap Map;
|
TypeMap Map;
|
||||||
if (!Name.empty())
|
if (!Name.empty())
|
||||||
Symfile.FindTypes(ConstString(Name), ContextPtr, true, UINT32_MAX,
|
Symfile.FindTypes(ConstString(Name), ContextPtr, true, UINT32_MAX,
|
||||||
SearchedFiles, Map);
|
SearchedFiles, Map);
|
||||||
else
|
else
|
||||||
Symfile.FindTypes(parseCompilerContext(), true, Map);
|
Module.FindTypes(parseCompilerContext(), languages, true, Map);
|
||||||
|
|
||||||
outs() << formatv("Found {0} types:\n", Map.GetSize());
|
outs() << formatv("Found {0} types:\n", Map.GetSize());
|
||||||
StreamString Stream;
|
StreamString Stream;
|
||||||
|
|
Loading…
Reference in New Issue