1 //===-- ScriptInterpreter.cpp -----------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Interpreter/ScriptInterpreter.h"
16 #include "lldb/Host/PseudoTerminal.h"
17 #include "lldb/Interpreter/CommandReturnObject.h"
18 #include "lldb/Utility/Status.h"
19 #include "lldb/Utility/Stream.h"
20 #include "lldb/Utility/StringList.h"
23 using namespace lldb_private;
25 ScriptInterpreter::ScriptInterpreter(CommandInterpreter &interpreter,
26 lldb::ScriptLanguage script_lang)
27 : m_interpreter(interpreter), m_script_lang(script_lang) {}
29 ScriptInterpreter::~ScriptInterpreter() {}
31 CommandInterpreter &ScriptInterpreter::GetCommandInterpreter() {
35 void ScriptInterpreter::CollectDataForBreakpointCommandCallback(
36 std::vector<BreakpointOptions *> &bp_options_vec,
37 CommandReturnObject &result) {
38 result.SetStatus(eReturnStatusFailed);
40 "ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
43 void ScriptInterpreter::CollectDataForWatchpointCommandCallback(
44 WatchpointOptions *bp_options, CommandReturnObject &result) {
45 result.SetStatus(eReturnStatusFailed);
47 "ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
50 std::string ScriptInterpreter::LanguageToString(lldb::ScriptLanguage language) {
51 std::string return_value;
54 case eScriptLanguageNone:
55 return_value = "None";
57 case eScriptLanguagePython:
58 return_value = "Python";
60 case eScriptLanguageUnknown:
61 return_value = "Unknown";
69 ScriptInterpreter::StringToLanguage(const llvm::StringRef &language) {
70 if (language.equals_lower(LanguageToString(eScriptLanguageNone)))
71 return eScriptLanguageNone;
72 if (language.equals_lower(LanguageToString(eScriptLanguagePython)))
73 return eScriptLanguagePython;
74 return eScriptLanguageUnknown;
77 Status ScriptInterpreter::SetBreakpointCommandCallback(
78 std::vector<BreakpointOptions *> &bp_options_vec,
79 const char *callback_text) {
81 for (BreakpointOptions *bp_options : bp_options_vec) {
82 return_error = SetBreakpointCommandCallback(bp_options, callback_text);
83 if (return_error.Success())
89 void ScriptInterpreter::SetBreakpointCommandCallbackFunction(
90 std::vector<BreakpointOptions *> &bp_options_vec,
91 const char *function_name) {
92 for (BreakpointOptions *bp_options : bp_options_vec) {
93 SetBreakpointCommandCallbackFunction(bp_options, function_name);
97 std::unique_ptr<ScriptInterpreterLocker>
98 ScriptInterpreter::AcquireInterpreterLock() {
99 return std::unique_ptr<ScriptInterpreterLocker>(
100 new ScriptInterpreterLocker());