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/Interpreter/ScriptInterpreter.h" 11 12 #include <stdio.h> 13 #include <stdlib.h> 14 #include <string> 15 16 #include "lldb/Core/Error.h" 17 #include "lldb/Core/Stream.h" 18 #include "lldb/Core/StringList.h" 19 #include "lldb/Interpreter/CommandReturnObject.h" 20 #include "lldb/Utility/PseudoTerminal.h" 21 22 using namespace lldb; 23 using namespace lldb_private; 24 25 ScriptInterpreter::ScriptInterpreter(CommandInterpreter &interpreter, 26 lldb::ScriptLanguage script_lang) 27 : m_interpreter(interpreter), m_script_lang(script_lang) {} 28 29 ScriptInterpreter::~ScriptInterpreter() {} 30 31 CommandInterpreter &ScriptInterpreter::GetCommandInterpreter() { 32 return m_interpreter; 33 } 34 35 void ScriptInterpreter::CollectDataForBreakpointCommandCallback( 36 std::vector<BreakpointOptions *> &bp_options_vec, 37 CommandReturnObject &result) { 38 result.SetStatus(eReturnStatusFailed); 39 result.AppendError( 40 "ScriptInterpreter::GetScriptCommands(StringList &) is not implemented."); 41 } 42 43 void ScriptInterpreter::CollectDataForWatchpointCommandCallback( 44 WatchpointOptions *bp_options, CommandReturnObject &result) { 45 result.SetStatus(eReturnStatusFailed); 46 result.AppendError( 47 "ScriptInterpreter::GetScriptCommands(StringList &) is not implemented."); 48 } 49 50 std::string ScriptInterpreter::LanguageToString(lldb::ScriptLanguage language) { 51 std::string return_value; 52 53 switch (language) { 54 case eScriptLanguageNone: 55 return_value = "None"; 56 break; 57 case eScriptLanguagePython: 58 return_value = "Python"; 59 break; 60 } 61 62 return return_value; 63 } 64 65 Error ScriptInterpreter::SetBreakpointCommandCallback( 66 std::vector<BreakpointOptions *> &bp_options_vec, 67 const char *callback_text) { 68 Error return_error; 69 for (BreakpointOptions *bp_options : bp_options_vec) { 70 return_error = SetBreakpointCommandCallback(bp_options, callback_text); 71 if (return_error.Success()) 72 break; 73 } 74 return return_error; 75 } 76 77 void ScriptInterpreter::SetBreakpointCommandCallbackFunction( 78 std::vector<BreakpointOptions *> &bp_options_vec, 79 const char *function_name) { 80 for (BreakpointOptions *bp_options : bp_options_vec) { 81 SetBreakpointCommandCallbackFunction(bp_options, function_name); 82 } 83 } 84 85 std::unique_ptr<ScriptInterpreterLocker> 86 ScriptInterpreter::AcquireInterpreterLock() { 87 return std::unique_ptr<ScriptInterpreterLocker>( 88 new ScriptInterpreterLocker()); 89 } 90