From a0d7406ae800c45dd9cb438c7ae1f55329d198e2 Mon Sep 17 00:00:00 2001 From: Pedro Tammela Date: Sun, 15 Nov 2020 19:39:16 +0000 Subject: [LLDB/Lua] add support for one-liner breakpoint callback These callbacks are set using the following: breakpoint command add -s lua -o "print('hello world!')" The user supplied script is executed as: function (frame, bp_loc, ...) end So the local variables 'frame', 'bp_loc' and vararg are all accessible. Any global variables declared will persist in the Lua interpreter. A user should never hold 'frame' and 'bp_loc' in a global variable as these userdatas are context dependent. Differential Revision: https://reviews.llvm.org/D91508 --- .../ScriptInterpreter/Lua/ScriptInterpreterLua.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h') diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h index 004222b..1238b89 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h +++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h @@ -10,11 +10,20 @@ #define liblldb_ScriptInterpreterLua_h_ #include "lldb/Interpreter/ScriptInterpreter.h" +#include "lldb/Utility/Status.h" +#include "lldb/lldb-enumerations.h" namespace lldb_private { class Lua; class ScriptInterpreterLua : public ScriptInterpreter { public: + class CommandDataLua : public BreakpointOptions::CommandData { + public: + CommandDataLua() : BreakpointOptions::CommandData() { + interpreter = lldb::eScriptLanguageLua; + } + }; + ScriptInterpreterLua(Debugger &debugger); ~ScriptInterpreterLua() override; @@ -41,6 +50,11 @@ public: static const char *GetPluginDescriptionStatic(); + static bool BreakpointCallbackFunction(void *baton, + StoppointCallbackContext *context, + lldb::user_id_t break_id, + lldb::user_id_t break_loc_id); + // PluginInterface protocol lldb_private::ConstString GetPluginName() override; @@ -51,6 +65,9 @@ public: llvm::Error EnterSession(lldb::user_id_t debugger_id); llvm::Error LeaveSession(); + Status SetBreakpointCommandCallback(BreakpointOptions *bp_options, + const char *command_body_text) override; + private: std::unique_ptr m_lua; bool m_session_is_active = false; -- cgit v1.1