summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/Module.cpp86
-rw-r--r--lldb/source/Core/PluginManager.cpp102
-rw-r--r--lldb/source/Core/ValueObjectDynamicValue.cpp2
-rw-r--r--lldb/source/Core/ValueObjectRegister.cpp6
4 files changed, 128 insertions, 68 deletions
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 256673361a7..8f6a4a10ac2 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -15,6 +15,7 @@
#include "lldb/Core/Log.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamString.h"
@@ -23,17 +24,16 @@
#include "lldb/Host/Symbols.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
-#include "lldb/Symbol/GoASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
-#include "lldb/Symbol/SymbolFile.h"
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
#include "Plugins/Language/ObjC/ObjCLanguage.h"
@@ -148,14 +148,12 @@ Module::Module (const ModuleSpec &module_spec) :
m_object_mod_time (),
m_objfile_sp (),
m_symfile_ap (),
- m_ast (new ClangASTContext),
- m_go_ast(),
+ m_type_system_map(),
m_source_mappings (),
m_sections_ap(),
m_did_load_objfile (false),
m_did_load_symbol_vendor (false),
m_did_parse_uuid (false),
- m_did_init_ast (false),
m_file_has_changed (false),
m_first_file_changed_log (false)
{
@@ -253,14 +251,12 @@ Module::Module(const FileSpec& file_spec,
m_object_mod_time (),
m_objfile_sp (),
m_symfile_ap (),
- m_ast (new ClangASTContext),
- m_go_ast(),
+ m_type_system_map(),
m_source_mappings (),
m_sections_ap(),
m_did_load_objfile (false),
m_did_load_symbol_vendor (false),
m_did_parse_uuid (false),
- m_did_init_ast (false),
m_file_has_changed (false),
m_first_file_changed_log (false)
{
@@ -300,14 +296,12 @@ Module::Module () :
m_object_mod_time (),
m_objfile_sp (),
m_symfile_ap (),
- m_ast (new ClangASTContext),
- m_go_ast(),
+ m_type_system_map(),
m_source_mappings (),
m_sections_ap(),
m_did_load_objfile (false),
m_did_load_symbol_vendor (false),
m_did_parse_uuid (false),
- m_did_init_ast (false),
m_file_has_changed (false),
m_first_file_changed_log (false)
{
@@ -424,64 +418,26 @@ Module::GetUUID()
TypeSystem *
Module::GetTypeSystemForLanguage (LanguageType language)
{
- if (language == eLanguageTypeGo)
- {
- Mutex::Locker locker (m_mutex);
- if (!m_go_ast)
- {
- ObjectFile * objfile = GetObjectFile();
- ArchSpec object_arch;
- if (objfile && objfile->GetArchitecture(object_arch))
- {
- m_go_ast.reset(new GoASTContext);
- m_go_ast->SetAddressByteSize(object_arch.GetAddressByteSize());
- }
- }
- return m_go_ast.get();
- }
- else if (language != eLanguageTypeSwift)
- {
- // For now assume all languages except swift use the ClangASTContext for types
- return &GetClangASTContext();
- }
- return nullptr;
-}
+ Mutex::Locker locker (m_mutex);
+ TypeSystemMap::iterator pos = m_type_system_map.find(language);
+ if (pos != m_type_system_map.end())
+ return pos->second.get();
-ClangASTContext &
-Module::GetClangASTContext ()
-{
- if (m_did_init_ast.load() == false)
+ for (const auto &pair : m_type_system_map)
{
- Mutex::Locker locker (m_mutex);
- if (m_did_init_ast.load() == false)
+ if (pair.second && pair.second->SupportsLanguage(language))
{
- ObjectFile * objfile = GetObjectFile();
- ArchSpec object_arch;
- if (objfile && objfile->GetArchitecture(object_arch))
- {
- m_did_init_ast = true;
-
- // LLVM wants this to be set to iOS or MacOSX; if we're working on
- // a bare-boards type image, change the triple for llvm's benefit.
- if (object_arch.GetTriple().getVendor() == llvm::Triple::Apple
- && object_arch.GetTriple().getOS() == llvm::Triple::UnknownOS)
- {
- if (object_arch.GetTriple().getArch() == llvm::Triple::arm ||
- object_arch.GetTriple().getArch() == llvm::Triple::aarch64 ||
- object_arch.GetTriple().getArch() == llvm::Triple::thumb)
- {
- object_arch.GetTriple().setOS(llvm::Triple::IOS);
- }
- else
- {
- object_arch.GetTriple().setOS(llvm::Triple::MacOSX);
- }
- }
- m_ast->SetArchitecture (object_arch);
- }
+ // Add a new mapping for "language" to point to an already existing
+ // TypeSystem that supports this language
+ m_type_system_map[language] = pair.second;
+ return pair.second.get();
}
}
- return *m_ast;
+
+ // Cache even if we get a shared pointer that contains null type system back
+ lldb::TypeSystemSP type_system_sp = TypeSystem::CreateInstance (language, GetArchitecture());
+ m_type_system_map[language] = type_system_sp;
+ return type_system_sp.get();
}
void
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index 4c0d2e772f0..7bf4348fafb 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -2516,6 +2516,108 @@ PluginManager::GetInstrumentationRuntimeCreateCallbackForPluginName (const Const
return NULL;
}
+#pragma mark TypeSystem
+
+
+struct TypeSystemInstance
+{
+ TypeSystemInstance() :
+ name(),
+ description(),
+ create_callback(NULL)
+ {
+ }
+
+ ConstString name;
+ std::string description;
+ TypeSystemCreateInstance create_callback;
+};
+
+typedef std::vector<TypeSystemInstance> TypeSystemInstances;
+
+static Mutex &
+GetTypeSystemMutex ()
+{
+ static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+ return g_instances_mutex;
+}
+
+static TypeSystemInstances &
+GetTypeSystemInstances ()
+{
+ static TypeSystemInstances g_instances;
+ return g_instances;
+}
+
+bool
+PluginManager::RegisterPlugin (const ConstString &name,
+ const char *description,
+ TypeSystemCreateInstance create_callback)
+{
+ if (create_callback)
+ {
+ TypeSystemInstance instance;
+ assert ((bool)name);
+ instance.name = name;
+ if (description && description[0])
+ instance.description = description;
+ instance.create_callback = create_callback;
+ Mutex::Locker locker (GetTypeSystemMutex ());
+ GetTypeSystemInstances ().push_back (instance);
+ }
+ return false;
+}
+
+bool
+PluginManager::UnregisterPlugin (TypeSystemCreateInstance create_callback)
+{
+ if (create_callback)
+ {
+ Mutex::Locker locker (GetTypeSystemMutex ());
+ TypeSystemInstances &instances = GetTypeSystemInstances ();
+
+ TypeSystemInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (pos->create_callback == create_callback)
+ {
+ instances.erase(pos);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+TypeSystemCreateInstance
+PluginManager::GetTypeSystemCreateCallbackAtIndex (uint32_t idx)
+{
+ Mutex::Locker locker (GetTypeSystemMutex ());
+ TypeSystemInstances &instances = GetTypeSystemInstances ();
+ if (idx < instances.size())
+ return instances[idx].create_callback;
+ return NULL;
+}
+
+TypeSystemCreateInstance
+PluginManager::GetTypeSystemCreateCallbackForPluginName (const ConstString &name)
+{
+ if (name)
+ {
+ Mutex::Locker locker (GetTypeSystemMutex ());
+ TypeSystemInstances &instances = GetTypeSystemInstances ();
+
+ TypeSystemInstances::iterator pos, end = instances.end();
+ for (pos = instances.begin(); pos != end; ++ pos)
+ {
+ if (name == pos->name)
+ return pos->create_callback;
+ }
+ }
+ return NULL;
+}
+
+
#pragma mark PluginManager
void
diff --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp
index 57304c06c08..794c537b23a 100644
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -154,7 +154,7 @@ FixupTypeAndOrName (const TypeAndOrName& type_andor_name,
if (parent.IsPointerType())
corrected_type = orig_type.GetPointerType ();
else if (parent.IsPointerOrReferenceType())
- corrected_type = ClangASTContext::GetLValueReferenceType(orig_type);
+ corrected_type = orig_type.GetLValueReferenceType();
ret.SetCompilerType(corrected_type);
}
else /*if (m_dynamic_type_info.HasName())*/
diff --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp
index d332706a858..a0d87ec64a1 100644
--- a/lldb/source/Core/ValueObjectRegister.cpp
+++ b/lldb/source/Core/ValueObjectRegister.cpp
@@ -319,8 +319,10 @@ ValueObjectRegister::GetCompilerTypeImpl ()
Module *exe_module = target->GetExecutableModulePointer();
if (exe_module)
{
- m_clang_type = exe_module->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize (m_reg_info.encoding,
- m_reg_info.byte_size * 8);
+ TypeSystem *type_system = exe_module->GetTypeSystemForLanguage (eLanguageTypeC);
+ if (type_system)
+ m_clang_type = type_system->GetBuiltinTypeForEncodingAndBitSize (m_reg_info.encoding,
+ m_reg_info.byte_size * 8);
}
}
}
OpenPOWER on IntegriCloud