Split up the Python script interpreter code to allow multiple script interpreter objects to
exist within the same process (one script interpreter object per debugger object).  The
python script interpreter objects are all using the same global Python script interpreter;
they use separate dictionaries to keep their data separate, and mutex's to prevent any object
attempting to use the global Python interpreter when another object is already using it.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@123415 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index 9e5e6a5..129dd61 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -50,6 +50,8 @@
 
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/ScriptInterpreterNone.h"
+#include "lldb/Interpreter/ScriptInterpreterPython.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -63,7 +65,8 @@
     Broadcaster ("lldb.command-interpreter"),
     m_debugger (debugger),
     m_synchronous_execution (synchronous_execution),
-    m_skip_lldbinit_files (false)
+    m_skip_lldbinit_files (false),
+    m_script_interpreter_ap ()
 {
     const char *dbg_name = debugger.GetInstanceName().AsCString();
     std::string lang_name = ScriptInterpreter::LanguageToString (script_language);
@@ -1460,15 +1463,23 @@
 ScriptInterpreter *
 CommandInterpreter::GetScriptInterpreter ()
 {
-    CommandObject::CommandMap::iterator pos;
+    if (m_script_interpreter_ap.get() != NULL)
+        return m_script_interpreter_ap.get();
     
-    pos = m_command_dict.find ("script");
-    if (pos != m_command_dict.end())
+    lldb::ScriptLanguage script_lang = GetDebugger().GetScriptLanguage();
+    switch (script_lang)
     {
-        CommandObject *script_cmd_obj = pos->second.get();
-        return ((CommandObjectScript *) script_cmd_obj)->GetInterpreter ();
-    }
-    return NULL;
+        case eScriptLanguageNone:
+            m_script_interpreter_ap.reset (new ScriptInterpreterNone (*this));
+            break;
+        case eScriptLanguagePython:
+            m_script_interpreter_ap.reset (new ScriptInterpreterPython (*this));
+            break;
+        default:
+            break;
+    };
+    
+    return m_script_interpreter_ap.get();
 }