1 //===-- ScriptInterpreter.cpp -----------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "lldb/lldb-python.h" 11 12 #include "lldb/Interpreter/ScriptInterpreter.h" 13 14 #include <string> 15 #include <stdlib.h> 16 #include <stdio.h> 17 18 #include "lldb/Core/Error.h" 19 #include "lldb/Core/Stream.h" 20 #include "lldb/Core/StringList.h" 21 #include "lldb/Interpreter/CommandReturnObject.h" 22 #include "lldb/Interpreter/ScriptInterpreterPython.h" 23 #include "lldb/Utility/PseudoTerminal.h" 24 25 using namespace lldb; 26 using namespace lldb_private; 27 28 ScriptInterpreter::ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang) : 29 m_interpreter (interpreter), 30 m_script_lang (script_lang) 31 { 32 } 33 34 ScriptInterpreter::~ScriptInterpreter () 35 { 36 } 37 38 CommandInterpreter & 39 ScriptInterpreter::GetCommandInterpreter () 40 { 41 return m_interpreter; 42 } 43 44 void 45 ScriptInterpreter::CollectDataForBreakpointCommandCallback 46 ( 47 BreakpointOptions *bp_options, 48 CommandReturnObject &result 49 ) 50 { 51 result.SetStatus (eReturnStatusFailed); 52 result.AppendError ("ScriptInterpreter::GetScriptCommands(StringList &) is not implemented."); 53 } 54 55 void 56 ScriptInterpreter::CollectDataForWatchpointCommandCallback 57 ( 58 WatchpointOptions *bp_options, 59 CommandReturnObject &result 60 ) 61 { 62 result.SetStatus (eReturnStatusFailed); 63 result.AppendError ("ScriptInterpreter::GetScriptCommands(StringList &) is not implemented."); 64 } 65 66 std::string 67 ScriptInterpreter::LanguageToString (lldb::ScriptLanguage language) 68 { 69 std::string return_value; 70 71 switch (language) 72 { 73 case eScriptLanguageNone: 74 return_value = "None"; 75 break; 76 case eScriptLanguagePython: 77 return_value = "Python"; 78 break; 79 } 80 81 return return_value; 82 } 83 84 std::unique_ptr<ScriptInterpreterLocker> 85 ScriptInterpreter::AcquireInterpreterLock () 86 { 87 return std::unique_ptr<ScriptInterpreterLocker>(new ScriptInterpreterLocker()); 88 } 89 90 void 91 ScriptInterpreter::InitializeInterpreter (SWIGInitCallback python_swig_init_callback) 92 { 93 #ifndef LLDB_DISABLE_PYTHON 94 ScriptInterpreterPython::InitializeInterpreter (python_swig_init_callback); 95 #endif // #ifndef LLDB_DISABLE_PYTHON 96 } 97 98 void 99 ScriptInterpreter::TerminateInterpreter () 100 { 101 #ifndef LLDB_DISABLE_PYTHON 102 ScriptInterpreterPython::TerminateInterpreter (); 103 #endif // #ifndef LLDB_DISABLE_PYTHON 104 } 105 106