Index: lldb/cmake/modules/LLDBConfig.cmake =================================================================== --- lldb/cmake/modules/LLDBConfig.cmake +++ lldb/cmake/modules/LLDBConfig.cmake @@ -27,6 +27,8 @@ set(default_disable_python OFF) set(default_disable_curses OFF) set(default_disable_libedit OFF) +# Lua is still experimental so off by default. +set(default_disable_lua ON) if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT) set(default_disable_libedit ON) @@ -37,13 +39,16 @@ set(default_disable_libedit ON) elseif(CMAKE_SYSTEM_NAME MATCHES "Android") set(default_disable_python ON) + set(default_disable_lua ON) set(default_disable_curses ON) set(default_disable_libedit ON) elseif(IOS) set(default_disable_python ON) + set(default_disable_lua ON) endif() option(LLDB_DISABLE_PYTHON "Disable Python scripting integration." ${default_disable_python}) +option(LLDB_DISABLE_LUA "Disable Lua scripting integration." ${default_disable_lua}) option(LLDB_DISABLE_CURSES "Disable Curses integration." ${default_disable_curses}) option(LLDB_DISABLE_LIBEDIT "Disable the use of editline." ${default_disable_libedit}) option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF) Index: lldb/include/lldb/Host/Config.h.cmake =================================================================== --- lldb/include/lldb/Host/Config.h.cmake +++ lldb/include/lldb/Host/Config.h.cmake @@ -39,6 +39,8 @@ #cmakedefine LLDB_DISABLE_LIBEDIT +#cmakedefine LLDB_DISABLE_LUA + #cmakedefine LLDB_DISABLE_PYTHON #cmakedefine LLDB_PYTHON_HOME "${LLDB_PYTHON_HOME}" Index: lldb/include/lldb/lldb-enumerations.h =================================================================== --- lldb/include/lldb/lldb-enumerations.h +++ lldb/include/lldb/lldb-enumerations.h @@ -213,6 +213,7 @@ enum ScriptLanguage { eScriptLanguageNone, eScriptLanguagePython, + eScriptLanguageLua, eScriptLanguageDefault = eScriptLanguagePython, eScriptLanguageUnknown }; Index: lldb/source/API/SystemInitializerFull.cpp =================================================================== --- lldb/source/API/SystemInitializerFull.cpp +++ lldb/source/API/SystemInitializerFull.cpp @@ -14,6 +14,10 @@ #include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h" #endif +#if !defined(LLDB_DISABLE_LUA) +#include "Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h" +#endif + #include "lldb/Core/Debugger.h" #include "lldb/Host/Host.h" #include "lldb/Initialization/SystemInitializerCommon.h" @@ -187,6 +191,10 @@ ScriptInterpreterPython::Initialize(); #endif +#if !defined(LLDB_DISABLE_LUA) + ScriptInterpreterLua::Initialize(); +#endif + platform_freebsd::PlatformFreeBSD::Initialize(); platform_linux::PlatformLinux::Initialize(); platform_netbsd::PlatformNetBSD::Initialize(); Index: lldb/source/Interpreter/OptionArgParser.cpp =================================================================== --- lldb/source/Interpreter/OptionArgParser.cpp +++ lldb/source/Interpreter/OptionArgParser.cpp @@ -127,6 +127,8 @@ if (s.equals_lower("python")) return eScriptLanguagePython; + if (s.equals_lower("lua")) + return eScriptLanguageLua; if (s.equals_lower("default")) return eScriptLanguageDefault; if (s.equals_lower("none")) Index: lldb/source/Plugins/ScriptInterpreter/CMakeLists.txt =================================================================== --- lldb/source/Plugins/ScriptInterpreter/CMakeLists.txt +++ lldb/source/Plugins/ScriptInterpreter/CMakeLists.txt @@ -2,3 +2,7 @@ if (NOT LLDB_DISABLE_PYTHON) add_subdirectory(Python) endif() + +if (NOT LLDB_DISABLE_LUA) + add_subdirectory(Lua) +endif() Index: lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt =================================================================== --- /dev/null +++ lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt @@ -0,0 +1,7 @@ +add_lldb_library(lldbPluginScriptInterpreterLua PLUGIN + ScriptInterpreterLua.cpp + + LINK_LIBS + lldbCore + lldbInterpreter + ) \ No newline at end of file Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h =================================================================== --- /dev/null +++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h @@ -0,0 +1,47 @@ +//===-- ScriptInterpreterLua.h ----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_ScriptInterpreterLua_h_ +#define liblldb_ScriptInterpreterLua_h_ + +#include "lldb/Interpreter/ScriptInterpreter.h" + +namespace lldb_private { + +class ScriptInterpreterLua : public ScriptInterpreter { +public: + ScriptInterpreterLua(Debugger &debugger); + + ~ScriptInterpreterLua() override; + + bool ExecuteOneLine( + llvm::StringRef command, CommandReturnObject *result, + const ExecuteScriptOptions &options = ExecuteScriptOptions()) override; + + void ExecuteInterpreterLoop() override; + + // Static Functions + static void Initialize(); + + static void Terminate(); + + static lldb::ScriptInterpreterSP CreateInstance(Debugger &debugger); + + static lldb_private::ConstString GetPluginNameStatic(); + + static const char *GetPluginDescriptionStatic(); + + // PluginInterface protocol + lldb_private::ConstString GetPluginName() override; + + uint32_t GetPluginVersion() override; +}; + +} // namespace lldb_private + +#endif // liblldb_ScriptInterpreterLua_h_ Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp =================================================================== --- /dev/null +++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp @@ -0,0 +1,71 @@ +//===-- ScriptInterpreterLua.cpp --------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "ScriptInterpreterLua.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/StreamFile.h" +#include "lldb/Utility/Stream.h" +#include "lldb/Utility/StringList.h" + +#include "llvm/Support/Threading.h" + +#include + +using namespace lldb; +using namespace lldb_private; + +ScriptInterpreterLua::ScriptInterpreterLua(Debugger &debugger) + : ScriptInterpreter(debugger, eScriptLanguageLua) {} + +ScriptInterpreterLua::~ScriptInterpreterLua() {} + +bool ScriptInterpreterLua::ExecuteOneLine(llvm::StringRef command, + CommandReturnObject *, + const ExecuteScriptOptions &) { + m_debugger.GetErrorStream().PutCString( + "error: the lua script interpreter is not yet implemented.\n"); + return false; +} + +void ScriptInterpreterLua::ExecuteInterpreterLoop() { + m_debugger.GetErrorStream().PutCString( + "error: the lua script interpreter is not yet implemented.\n"); +} + +void ScriptInterpreterLua::Initialize() { + static llvm::once_flag g_once_flag; + + llvm::call_once(g_once_flag, []() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), + lldb::eScriptLanguageLua, CreateInstance); + }); +} + +void ScriptInterpreterLua::Terminate() {} + +lldb::ScriptInterpreterSP +ScriptInterpreterLua::CreateInstance(Debugger &debugger) { + return std::make_shared(debugger); +} + +lldb_private::ConstString ScriptInterpreterLua::GetPluginNameStatic() { + static ConstString g_name("script-lua"); + return g_name; +} + +const char *ScriptInterpreterLua::GetPluginDescriptionStatic() { + return "Lua script interpreter"; +} + +lldb_private::ConstString ScriptInterpreterLua::GetPluginName() { + return GetPluginNameStatic(); +} + +uint32_t ScriptInterpreterLua::GetPluginVersion() { return 1; }