1 | //===-- ScriptInterpreterNone.cpp -----------------------------------------===// |
---|---|
2 | // |
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 |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "ScriptInterpreterNone.h" |
10 | #include "lldb/Core/Debugger.h" |
11 | #include "lldb/Core/PluginManager.h" |
12 | #include "lldb/Utility/Stream.h" |
13 | #include "lldb/Utility/StringList.h" |
14 | |
15 | #include "llvm/Support/Threading.h" |
16 | |
17 | #include <mutex> |
18 | |
19 | using namespace lldb; |
20 | using namespace lldb_private; |
21 | |
22 | LLDB_PLUGIN_DEFINE(ScriptInterpreterNone) |
23 | |
24 | ScriptInterpreterNone::ScriptInterpreterNone(Debugger &debugger) |
25 | : ScriptInterpreter(debugger, eScriptLanguageNone) {} |
26 | |
27 | ScriptInterpreterNone::~ScriptInterpreterNone() = default; |
28 | |
29 | static const char *no_interpreter_err_msg = |
30 | "error: Embedded script interpreter unavailable. LLDB was built without " |
31 | "scripting language support.\n"; |
32 | |
33 | bool ScriptInterpreterNone::ExecuteOneLine(llvm::StringRef command, |
34 | CommandReturnObject *, |
35 | const ExecuteScriptOptions &) { |
36 | m_debugger.GetErrorStream().PutCString(cstr: no_interpreter_err_msg); |
37 | return false; |
38 | } |
39 | |
40 | void ScriptInterpreterNone::ExecuteInterpreterLoop() { |
41 | m_debugger.GetErrorStream().PutCString(cstr: no_interpreter_err_msg); |
42 | } |
43 | |
44 | void ScriptInterpreterNone::Initialize() { |
45 | static llvm::once_flag g_once_flag; |
46 | |
47 | llvm::call_once(flag&: g_once_flag, F: []() { |
48 | PluginManager::RegisterPlugin(name: GetPluginNameStatic(), |
49 | description: GetPluginDescriptionStatic(), |
50 | script_lang: lldb::eScriptLanguageNone, create_callback: CreateInstance); |
51 | }); |
52 | } |
53 | |
54 | void ScriptInterpreterNone::Terminate() {} |
55 | |
56 | lldb::ScriptInterpreterSP |
57 | ScriptInterpreterNone::CreateInstance(Debugger &debugger) { |
58 | return std::make_shared<ScriptInterpreterNone>(args&: debugger); |
59 | } |
60 | |
61 | llvm::StringRef ScriptInterpreterNone::GetPluginDescriptionStatic() { |
62 | return "Null script interpreter"; |
63 | } |
64 |