[Lldb-commits] [lldb] r250928 - Fixed version of r250913, which actually implements all the static functions.

Sean Callanan via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 21 12:14:34 PDT 2015


Author: spyffe
Date: Wed Oct 21 14:14:33 2015
New Revision: 250928

URL: http://llvm.org/viewvc/llvm-project?rev=250928&view=rev
Log:
Fixed version of r250913, which actually implements all the static functions.
Thanks to Siva Chandra and Oleksiy Vyalov for pouncing on this.

Modified:
    lldb/trunk/include/lldb/Core/PluginManager.h
    lldb/trunk/include/lldb/Target/Language.h
    lldb/trunk/include/lldb/lldb-private-interfaces.h
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Core/PluginManager.cpp
    lldb/trunk/source/Target/Language.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Core/PluginManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/PluginManager.h?rev=250928&r1=250927&r2=250928&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/PluginManager.h (original)
+++ lldb/trunk/include/lldb/Core/PluginManager.h Wed Oct 21 14:14:33 2015
@@ -449,7 +449,8 @@ public:
     static bool
     RegisterPlugin (const ConstString &name,
                     const char *description,
-                    REPLCreateInstance create_callback);
+                    REPLCreateInstance create_callback,
+                    REPLEnumerateSupportedLanguages enumerate_languages_callback);
     
     static bool
     UnregisterPlugin (REPLCreateInstance create_callback);
@@ -460,6 +461,12 @@ public:
     static REPLCreateInstance
     GetREPLCreateCallbackForPluginName (const ConstString &name);
     
+    static REPLEnumerateSupportedLanguages
+    GetREPLEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx);
+    
+    static REPLEnumerateSupportedLanguages
+    GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName (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/Target/Language.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Language.h?rev=250928&r1=250927&r2=250928&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Language.h (original)
+++ lldb/trunk/include/lldb/Target/Language.h Wed Oct 21 14:14:33 2015
@@ -149,6 +149,9 @@ public:
     static void
     GetLanguagesSupportingTypeSystems (std::set<lldb::LanguageType> &languages,
                                        std::set<lldb::LanguageType> &languages_for_expressions);
+
+    static void
+    GetLanguagesSupportingREPLs (std::set<lldb::LanguageType> &languages);
     
 protected:
     //------------------------------------------------------------------

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=250928&r1=250927&r2=250928&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-interfaces.h (original)
+++ lldb/trunk/include/lldb/lldb-private-interfaces.h Wed Oct 21 14:14:33 2015
@@ -51,6 +51,7 @@ namespace lldb_private
     typedef lldb::TypeSystemSP (*TypeSystemCreateInstance) (lldb::LanguageType language, Module *module, Target *target);
     typedef lldb::REPLSP (*REPLCreateInstance) (Error &error, lldb::LanguageType language, Debugger *debugger, Target *target, 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 void (*DebuggerInitializeCallback)(Debugger &debugger);
 

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=250928&r1=250927&r2=250928&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Wed Oct 21 14:14:33 2015
@@ -1805,11 +1805,6 @@ Debugger::RunREPL (LanguageType language
 {
     Error err;
     FileSpec repl_executable;
-    if (language == eLanguageTypeUnknown)
-    {
-        err.SetErrorString ("must specify a language for a REPL"); // TODO make it possible to specify a default language
-        return err;
-    }
     
     Target *const target = nullptr; // passing in an empty target means the REPL must create one
     

Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=250928&r1=250927&r2=250928&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Wed Oct 21 14:14:33 2015
@@ -2662,6 +2662,7 @@ struct REPLInstance
     ConstString name;
     std::string description;
     REPLCreateInstance create_callback;
+    REPLEnumerateSupportedLanguages enumerate_languages_callback;
 };
 
 typedef std::vector<REPLInstance> REPLInstances;
@@ -2683,7 +2684,8 @@ GetREPLInstances ()
 bool
 PluginManager::RegisterPlugin (const ConstString &name,
                                const char *description,
-                               REPLCreateInstance create_callback)
+                               REPLCreateInstance create_callback,
+                               REPLEnumerateSupportedLanguages enumerate_languages_callback)
 {
     if (create_callback)
     {
@@ -2693,6 +2695,7 @@ PluginManager::RegisterPlugin (const Con
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
+        instance.enumerate_languages_callback = enumerate_languages_callback;
         Mutex::Locker locker (GetREPLMutex ());
         GetREPLInstances ().push_back (instance);
     }
@@ -2746,6 +2749,35 @@ PluginManager::GetREPLCreateCallbackForP
         }
     }
     return NULL;
+}
+
+REPLEnumerateSupportedLanguages
+PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex (uint32_t idx)
+{
+    Mutex::Locker locker (GetREPLMutex ());
+    REPLInstances &instances = GetREPLInstances ();
+    if (idx < instances.size())
+        return instances[idx].enumerate_languages_callback;
+    return NULL;
+}
+
+
+REPLEnumerateSupportedLanguages
+PluginManager::GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName (const ConstString &name)
+{
+    if (name)
+    {
+        Mutex::Locker locker (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 NULL;
 }
 
 #pragma mark PluginManager

Modified: lldb/trunk/source/Target/Language.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Language.cpp?rev=250928&r1=250927&r2=250928&view=diff
==============================================================================
--- lldb/trunk/source/Target/Language.cpp (original)
+++ lldb/trunk/source/Target/Language.cpp Wed Oct 21 14:14:33 2015
@@ -299,6 +299,17 @@ Language::GetLanguagesSupportingTypeSyst
     }
 }
 
+void
+Language::GetLanguagesSupportingREPLs (std::set<lldb::LanguageType> &languages)
+{
+    uint32_t idx = 0;
+    
+    while (REPLEnumerateSupportedLanguages enumerate = PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(idx++))
+    {
+        (*enumerate)(languages);
+    }
+}
+
 std::unique_ptr<Language::TypeScavenger>
 Language::GetTypeScavenger ()
 {

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=250928&r1=250927&r2=250928&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Wed Oct 21 14:14:33 2015
@@ -218,7 +218,19 @@ Target::GetREPL (Error &err, lldb::Langu
 {
     if (language == eLanguageTypeUnknown)
     {
-        return REPLSP(); // must provide a language
+        std::set<LanguageType> repl_languages;
+        
+        Language::GetLanguagesSupportingREPLs(repl_languages);
+        
+        if (repl_languages.size() == 1)
+        {
+            language = *repl_languages.begin();
+        }
+        else
+        {
+            err.SetErrorStringWithFormat("Multiple possible REPL languages.  Please specify a language.");
+            return REPLSP(); // must provide a language
+        }
     }
     
     REPLMap::iterator pos = m_repl_map.find(language);




More information about the lldb-commits mailing list