1 //===-- ScriptInterpreterLua.h ----------------------------------*- C++ -*-===// 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 #ifndef liblldb_ScriptInterpreterLua_h_ 10 #define liblldb_ScriptInterpreterLua_h_ 11 12 #include "lldb/Interpreter/ScriptInterpreter.h" 13 #include "lldb/Utility/Status.h" 14 #include "lldb/lldb-enumerations.h" 15 16 namespace lldb_private { 17 class Lua; 18 class ScriptInterpreterLua : public ScriptInterpreter { 19 public: 20 class CommandDataLua : public BreakpointOptions::CommandData { 21 public: CommandDataLua()22 CommandDataLua() : BreakpointOptions::CommandData() { 23 interpreter = lldb::eScriptLanguageLua; 24 } 25 }; 26 27 ScriptInterpreterLua(Debugger &debugger); 28 29 ~ScriptInterpreterLua() override; 30 31 bool ExecuteOneLine( 32 llvm::StringRef command, CommandReturnObject *result, 33 const ExecuteScriptOptions &options = ExecuteScriptOptions()) override; 34 35 void ExecuteInterpreterLoop() override; 36 37 bool LoadScriptingModule(const char *filename, bool init_session, 38 lldb_private::Status &error, 39 StructuredData::ObjectSP *module_sp = nullptr, 40 FileSpec extra_search_dir = {}) override; 41 42 // Static Functions 43 static void Initialize(); 44 45 static void Terminate(); 46 47 static lldb::ScriptInterpreterSP CreateInstance(Debugger &debugger); 48 49 static lldb_private::ConstString GetPluginNameStatic(); 50 51 static const char *GetPluginDescriptionStatic(); 52 53 static bool BreakpointCallbackFunction(void *baton, 54 StoppointCallbackContext *context, 55 lldb::user_id_t break_id, 56 lldb::user_id_t break_loc_id); 57 58 // PluginInterface protocol 59 lldb_private::ConstString GetPluginName() override; 60 61 uint32_t GetPluginVersion() override; 62 63 Lua &GetLua(); 64 65 llvm::Error EnterSession(lldb::user_id_t debugger_id); 66 llvm::Error LeaveSession(); 67 68 Status SetBreakpointCommandCallback(BreakpointOptions *bp_options, 69 const char *command_body_text) override; 70 71 private: 72 std::unique_ptr<Lua> m_lua; 73 bool m_session_is_active = false; 74 }; 75 76 } // namespace lldb_private 77 78 #endif // liblldb_ScriptInterpreterLua_h_ 79