1 //===-- ScriptInterpreter.cpp -----------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Interpreter/ScriptInterpreter.h"
15 #include "lldb/Host/PseudoTerminal.h"
16 #include "lldb/Interpreter/CommandReturnObject.h"
17 #include "lldb/Utility/Status.h"
18 #include "lldb/Utility/Stream.h"
19 #include "lldb/Utility/StringList.h"
22 using namespace lldb_private;
24 ScriptInterpreter::ScriptInterpreter(Debugger &debugger,
25 lldb::ScriptLanguage script_lang)
26 : m_debugger(debugger), m_script_lang(script_lang) {}
28 ScriptInterpreter::~ScriptInterpreter() {}
30 void ScriptInterpreter::CollectDataForBreakpointCommandCallback(
31 std::vector<BreakpointOptions *> &bp_options_vec,
32 CommandReturnObject &result) {
33 result.SetStatus(eReturnStatusFailed);
35 "ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
38 void ScriptInterpreter::CollectDataForWatchpointCommandCallback(
39 WatchpointOptions *bp_options, CommandReturnObject &result) {
40 result.SetStatus(eReturnStatusFailed);
42 "ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
45 std::string ScriptInterpreter::LanguageToString(lldb::ScriptLanguage language) {
46 std::string return_value;
49 case eScriptLanguageNone:
50 return_value = "None";
52 case eScriptLanguagePython:
53 return_value = "Python";
55 case eScriptLanguageUnknown:
56 return_value = "Unknown";
64 ScriptInterpreter::StringToLanguage(const llvm::StringRef &language) {
65 if (language.equals_lower(LanguageToString(eScriptLanguageNone)))
66 return eScriptLanguageNone;
67 if (language.equals_lower(LanguageToString(eScriptLanguagePython)))
68 return eScriptLanguagePython;
69 return eScriptLanguageUnknown;
72 Status ScriptInterpreter::SetBreakpointCommandCallback(
73 std::vector<BreakpointOptions *> &bp_options_vec,
74 const char *callback_text) {
76 for (BreakpointOptions *bp_options : bp_options_vec) {
77 return_error = SetBreakpointCommandCallback(bp_options, callback_text);
78 if (return_error.Success())
84 void ScriptInterpreter::SetBreakpointCommandCallbackFunction(
85 std::vector<BreakpointOptions *> &bp_options_vec,
86 const char *function_name) {
87 for (BreakpointOptions *bp_options : bp_options_vec) {
88 SetBreakpointCommandCallbackFunction(bp_options, function_name);
92 std::unique_ptr<ScriptInterpreterLocker>
93 ScriptInterpreter::AcquireInterpreterLock() {
94 return std::unique_ptr<ScriptInterpreterLocker>(
95 new ScriptInterpreterLocker());