diff options
| author | Zachary Turner <zturner@google.com> | 2015-07-30 20:28:07 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2015-07-30 20:28:07 +0000 |
| commit | 2c1f46dcc609a1bf61ab979eebdd72f81823ff74 (patch) | |
| tree | 9aea77c865bbaa3ec81fd85ca66913360dc6155b /lldb/source/Plugins/ScriptInterpreter/None | |
| parent | 13ac40ea6ef9621838068a70cbef86d544ee9700 (diff) | |
| download | bcm5719-llvm-2c1f46dcc609a1bf61ab979eebdd72f81823ff74.tar.gz bcm5719-llvm-2c1f46dcc609a1bf61ab979eebdd72f81823ff74.zip | |
Convert the ScriptInterpreter system to a plugin-based one.
Previously embedded interpreters were handled as ad-hoc source
files compiled into source/Interpreter. This made it hard to
disable a specific interpreter, or to add support for other
interpreters and allow the developer to choose which interpreter(s)
were enabled for a particular build.
This patch converts script interpreters over to a plugin-based system.
Script interpreters now live in source/Plugins/ScriptInterpreter, and
the canonical LLDB interpreter, ScriptInterpreterPython, is moved there
as well.
Any new code interfacing with the Python C API must live in this location
from here on out. Additionally, generic code should never need to
reference or make assumptions about the presence of a specific interpreter
going forward.
Differential Revision: http://reviews.llvm.org/D11431
Reviewed By: Greg Clayton
llvm-svn: 243681
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/None')
3 files changed, 158 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/None/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/None/CMakeLists.txt new file mode 100644 index 00000000000..5692d2f9071 --- /dev/null +++ b/lldb/source/Plugins/ScriptInterpreter/None/CMakeLists.txt @@ -0,0 +1,3 @@ +add_lldb_library(lldbPluginScriptInterpreterNone + ScriptInterpreterNone.cpp + )
\ No newline at end of file diff --git a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp new file mode 100644 index 00000000000..1a352fa1987 --- /dev/null +++ b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp @@ -0,0 +1,93 @@ +//===-- ScriptInterpreterNone.cpp -------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "ScriptInterpreterNone.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/Stream.h" +#include "lldb/Core/StreamFile.h" +#include "lldb/Core/StringList.h" +#include "lldb/Interpreter/CommandInterpreter.h" + +#include <mutex> + +using namespace lldb; +using namespace lldb_private; + +ScriptInterpreterNone::ScriptInterpreterNone(CommandInterpreter &interpreter) + : ScriptInterpreter(interpreter, eScriptLanguageNone) +{ +} + +ScriptInterpreterNone::~ScriptInterpreterNone() +{ +} + +bool +ScriptInterpreterNone::ExecuteOneLine(const char *command, CommandReturnObject *, const ExecuteScriptOptions &) +{ + m_interpreter.GetDebugger().GetErrorFile()->PutCString( + "error: there is no embedded script interpreter in this mode.\n"); + return false; +} + +void +ScriptInterpreterNone::ExecuteInterpreterLoop() +{ + m_interpreter.GetDebugger().GetErrorFile()->PutCString( + "error: there is no embedded script interpreter in this mode.\n"); +} + +void +ScriptInterpreterNone::Initialize() +{ + static std::once_flag g_once_flag; + + std::call_once(g_once_flag, []() + { + PluginManager::RegisterPlugin(GetPluginNameStatic(), GetPluginDescriptionStatic(), + lldb::eScriptLanguageNone, CreateInstance); + }); +} + +void +ScriptInterpreterNone::Terminate() +{ +} + +lldb::ScriptInterpreterSP +ScriptInterpreterNone::CreateInstance(CommandInterpreter &interpreter) +{ + return std::make_shared<ScriptInterpreterNone>(interpreter); +} + +lldb_private::ConstString +ScriptInterpreterNone::GetPluginNameStatic() +{ + static ConstString g_name("script-none"); + return g_name; +} + +const char * +ScriptInterpreterNone::GetPluginDescriptionStatic() +{ + return "Null script interpreter"; +} + +lldb_private::ConstString +ScriptInterpreterNone::GetPluginName() +{ + return GetPluginNameStatic(); +} + +uint32_t +ScriptInterpreterNone::GetPluginVersion() +{ + return 1; +} diff --git a/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h new file mode 100644 index 00000000000..d29600a7645 --- /dev/null +++ b/lldb/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h @@ -0,0 +1,62 @@ +//===-- ScriptInterpreterNone.h ---------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_ScriptInterpreterNone_h_ +#define liblldb_ScriptInterpreterNone_h_ + +#include "lldb/Interpreter/ScriptInterpreter.h" + +namespace lldb_private +{ + +class ScriptInterpreterNone : public ScriptInterpreter +{ + public: + ScriptInterpreterNone(CommandInterpreter &interpreter); + + ~ScriptInterpreterNone(); + + bool + ExecuteOneLine(const char *command, CommandReturnObject *result, + const ExecuteScriptOptions &options = ExecuteScriptOptions()); + + void + ExecuteInterpreterLoop(); + + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + static void + Initialize(); + + static void + Terminate(); + + static lldb::ScriptInterpreterSP + CreateInstance(CommandInterpreter &interpreter); + + static lldb_private::ConstString + GetPluginNameStatic(); + + static const char * + GetPluginDescriptionStatic(); + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + virtual lldb_private::ConstString + GetPluginName(); + + virtual uint32_t + GetPluginVersion(); +}; + +} // namespace lldb_private + +#endif // #ifndef liblldb_ScriptInterpreterNone_h_ |

