[Lldb-commits] [lldb] r249769 - Added support for enumerating the languages that actually support TypeSystems
Sean Callanan via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 8 16:07:53 PDT 2015
Author: spyffe
Date: Thu Oct 8 18:07:53 2015
New Revision: 249769
URL: http://llvm.org/viewvc/llvm-project?rev=249769&view=rev
Log:
Added support for enumerating the languages that actually support TypeSystems
and expressions. Also wired that into the OptionValue infrastructure, although
it isn't used for tab-completion yet.
Modified:
lldb/trunk/include/lldb/Core/PluginManager.h
lldb/trunk/include/lldb/Symbol/ClangASTContext.h
lldb/trunk/include/lldb/Symbol/GoASTContext.h
lldb/trunk/include/lldb/Target/Language.h
lldb/trunk/include/lldb/lldb-private-interfaces.h
lldb/trunk/source/Core/PluginManager.cpp
lldb/trunk/source/Interpreter/OptionValueLanguage.cpp
lldb/trunk/source/Symbol/ClangASTContext.cpp
lldb/trunk/source/Symbol/GoASTContext.cpp
lldb/trunk/source/Target/Language.cpp
Modified: lldb/trunk/include/lldb/Core/PluginManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=249769&r1=249768&r2=249769&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/PluginManager.h (original)
+++ lldb/trunk/include/lldb/Core/PluginManager.h Thu Oct 8 18:07:53 2015
@@ -425,7 +425,8 @@ public:
static bool
RegisterPlugin (const ConstString &name,
const char *description,
- TypeSystemCreateInstance create_callback);
+ TypeSystemCreateInstance create_callback,
+ TypeSystemEnumerateSupportedLanguages enumerate_languages_callback);
static bool
UnregisterPlugin (TypeSystemCreateInstance create_callback);
@@ -436,6 +437,12 @@ public:
static TypeSystemCreateInstance
GetTypeSystemCreateCallbackForPluginName (const ConstString &name);
+ static TypeSystemEnumerateSupportedLanguages
+ GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx);
+
+ static TypeSystemEnumerateSupportedLanguages
+ GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name);
+
//------------------------------------------------------------------
// Some plug-ins might register a DebuggerInitializeCallback
// callback when registering the plug-in. After a new Debugger
Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=249769&r1=249768&r2=249769&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Oct 8 18:07:53 2015
@@ -72,6 +72,9 @@ public:
static lldb::TypeSystemSP
CreateInstance (lldb::LanguageType language, Module *module, Target *target);
+
+ static void
+ EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
static void
Initialize ();
Modified: lldb/trunk/include/lldb/Symbol/GoASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/GoASTContext.h?rev=249769&r1=249768&r2=249769&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/GoASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/GoASTContext.h Thu Oct 8 18:07:53 2015
@@ -41,6 +41,9 @@ class GoASTContext : public TypeSystem
static lldb::TypeSystemSP
CreateInstance (lldb::LanguageType language, Module *module, Target *target);
+
+ static void
+ EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
static void
Initialize ();
Modified: lldb/trunk/include/lldb/Target/Language.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Language.h?rev=249769&r1=249768&r2=249769&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Language.h (original)
+++ lldb/trunk/include/lldb/Target/Language.h Thu Oct 8 18:07:53 2015
@@ -139,7 +139,11 @@ public:
static bool
LanguageIsPascal (lldb::LanguageType language);
-
+
+ static void
+ GetLanguagesSupportingTypeSystems (std::set<lldb::LanguageType> &languages,
+ std::set<lldb::LanguageType> &languages_for_expressions);
+
protected:
//------------------------------------------------------------------
// Classes that inherit from Language can see and modify these
Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=249769&r1=249768&r2=249769&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-interfaces.h (original)
+++ lldb/trunk/include/lldb/lldb-private-interfaces.h Thu Oct 8 18:07:53 2015
@@ -14,6 +14,8 @@
#include "lldb/lldb-private.h"
+#include <set>
+
namespace lldb_private
{
typedef lldb::ABISP (*ABICreateInstance) (const ArchSpec &arch);
@@ -47,6 +49,7 @@ namespace lldb_private
typedef lldb::InstrumentationRuntimeType (*InstrumentationRuntimeGetType) ();
typedef lldb::InstrumentationRuntimeSP (*InstrumentationRuntimeCreateInstance) (const lldb::ProcessSP &process_sp);
typedef lldb::TypeSystemSP (*TypeSystemCreateInstance) (lldb::LanguageType language, Module *module, Target *target);
+ typedef void (*TypeSystemEnumerateSupportedLanguages) (std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions);
typedef int (*ComparisonFunction)(const void *, const void *);
typedef void (*DebuggerInitializeCallback)(Debugger &debugger);
Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=249769&r1=249768&r2=249769&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Thu Oct 8 18:07:53 2015
@@ -2531,6 +2531,7 @@ struct TypeSystemInstance
ConstString name;
std::string description;
TypeSystemCreateInstance create_callback;
+ TypeSystemEnumerateSupportedLanguages enumerate_callback;
};
typedef std::vector<TypeSystemInstance> TypeSystemInstances;
@@ -2552,7 +2553,8 @@ GetTypeSystemInstances ()
bool
PluginManager::RegisterPlugin (const ConstString &name,
const char *description,
- TypeSystemCreateInstance create_callback)
+ TypeSystemCreateInstance create_callback,
+ TypeSystemEnumerateSupportedLanguages enumerate_supported_languages_callback)
{
if (create_callback)
{
@@ -2617,6 +2619,33 @@ PluginManager::GetTypeSystemCreateCallba
return NULL;
}
+TypeSystemEnumerateSupportedLanguages
+PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx)
+{
+ Mutex::Locker locker (GetTypeSystemMutex ());
+ TypeSystemInstances &instances = GetTypeSystemInstances ();
+ if (idx < instances.size())
+ return instances[idx].enumerate_callback;
+ return NULL;
+}
+
+TypeSystemEnumerateSupportedLanguages
+PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName (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->enumerate_callback;
+ }
+ }
+ return NULL;
+}
#pragma mark PluginManager
Modified: lldb/trunk/source/Interpreter/OptionValueLanguage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueLanguage.cpp?rev=249769&r1=249768&r2=249769&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/OptionValueLanguage.cpp (original)
+++ lldb/trunk/source/Interpreter/OptionValueLanguage.cpp Thu Oct 8 18:07:53 2015
@@ -48,8 +48,12 @@ OptionValueLanguage::SetValueFromString
case eVarSetOperationAssign:
{
ConstString lang_name(value.trim());
+ std::set<lldb::LanguageType> languages_for_types;
+ std::set<lldb::LanguageType> languages_for_expressions;
+ Language::GetLanguagesSupportingTypeSystems(languages_for_types, languages_for_expressions);
+
LanguageType new_type = Language::GetLanguageTypeFromString(lang_name.GetCString());
- if (new_type)
+ if (new_type && languages_for_types.count(new_type))
{
m_value_was_set = true;
m_current_value = new_type;
@@ -59,7 +63,10 @@ OptionValueLanguage::SetValueFromString
StreamString error_strm;
error_strm.Printf("invalid language type '%s', ", value.str().c_str());
error_strm.Printf("valid values are:\n");
- Language::PrintAllLanguages(error_strm, " ", "\n");
+ for (lldb::LanguageType language : languages_for_types)
+ {
+ error_strm.Printf("%s%s%s", " ", Language::GetNameForLanguageType(language), "\n");
+ }
error.SetErrorString(error_strm.GetData());
}
}
Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=249769&r1=249768&r2=249769&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Oct 8 18:07:53 2015
@@ -13,6 +13,7 @@
// C++ Includes
#include <mutex> // std::once
#include <string>
+#include <vector>
// Other libraries and framework includes
@@ -424,13 +425,41 @@ ClangASTContext::CreateInstance (lldb::L
return lldb::TypeSystemSP();
}
+void
+ClangASTContext::EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions)
+{
+ static std::vector<lldb::LanguageType> s_supported_languages_for_types({
+ lldb::eLanguageTypeC89,
+ lldb::eLanguageTypeC,
+ lldb::eLanguageTypeC11,
+ lldb::eLanguageTypeC_plus_plus,
+ lldb::eLanguageTypeC99,
+ lldb::eLanguageTypeObjC,
+ lldb::eLanguageTypeObjC_plus_plus,
+ lldb::eLanguageTypeC_plus_plus_03,
+ lldb::eLanguageTypeC_plus_plus_11,
+ lldb::eLanguageTypeC11,
+ lldb::eLanguageTypeC_plus_plus_14});
+
+ static std::vector<lldb::LanguageType> s_supported_languages_for_expressions({
+ lldb::eLanguageTypeC_plus_plus,
+ lldb::eLanguageTypeObjC_plus_plus,
+ lldb::eLanguageTypeC_plus_plus_03,
+ lldb::eLanguageTypeC_plus_plus_11,
+ lldb::eLanguageTypeC_plus_plus_14});
+
+ languages_for_types.insert(s_supported_languages_for_types.begin(), s_supported_languages_for_types.end());
+ languages_for_expressions.insert(s_supported_languages_for_expressions.begin(), s_supported_languages_for_expressions.end());
+}
+
void
ClangASTContext::Initialize()
{
PluginManager::RegisterPlugin (GetPluginNameStatic(),
"clang base AST context plug-in",
- CreateInstance);
+ CreateInstance,
+ EnumerateSupportedLanguages);
}
void
Modified: lldb/trunk/source/Symbol/GoASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/GoASTContext.cpp?rev=249769&r1=249768&r2=249769&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/GoASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/GoASTContext.cpp Thu Oct 8 18:07:53 2015
@@ -342,13 +342,26 @@ GoASTContext::CreateInstance (lldb::Lang
return lldb::TypeSystemSP();
}
+void
+GoASTContext::EnumerateSupportedLanguages(std::set<lldb::LanguageType> &languages_for_types, std::set<lldb::LanguageType> &languages_for_expressions)
+{
+ static std::vector<lldb::LanguageType> s_supported_languages_for_types({
+ lldb::eLanguageTypeGo});
+
+ static std::vector<lldb::LanguageType> s_supported_languages_for_expressions({});
+
+ languages_for_types.insert(s_supported_languages_for_types.begin(), s_supported_languages_for_types.end());
+ languages_for_expressions.insert(s_supported_languages_for_expressions.begin(), s_supported_languages_for_expressions.end());
+}
+
void
GoASTContext::Initialize()
{
PluginManager::RegisterPlugin (GetPluginNameStatic(),
"AST context plug-in",
- CreateInstance);
+ CreateInstance,
+ EnumerateSupportedLanguages);
}
void
Modified: lldb/trunk/source/Target/Language.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Language.cpp?rev=249769&r1=249768&r2=249769&view=diff
==============================================================================
--- lldb/trunk/source/Target/Language.cpp (original)
+++ lldb/trunk/source/Target/Language.cpp Thu Oct 8 18:07:53 2015
@@ -287,6 +287,18 @@ Language::LanguageIsPascal (LanguageType
}
}
+void
+Language::GetLanguagesSupportingTypeSystems (std::set<lldb::LanguageType> &languages,
+ std::set<lldb::LanguageType> &languages_for_expressions)
+{
+ uint32_t idx = 0;
+
+ while (TypeSystemEnumerateSupportedLanguages enumerate = PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(idx++))
+ {
+ (*enumerate)(languages, languages_for_expressions);
+ }
+}
+
std::unique_ptr<Language::TypeScavenger>
Language::GetTypeScavenger ()
{
More information about the lldb-commits
mailing list