From 532e4203c5be909af701df4dedfd36c9b8f85034 Mon Sep 17 00:00:00 2001 From: Pedro Tammela Date: Mon, 21 Dec 2020 17:59:35 +0000 Subject: [lldb/Lua] add support for Lua function breakpoint Adds support for running a Lua function when a breakpoint is hit. Example: breakpoint command add -s lua -F abc The above runs the Lua function 'abc' passing 2 arguments. 'frame', 'bp_loc' and 'extra_args'. A third parameter 'extra_args' is only present when there is structured data declared in the command line. Example: breakpoint command add -s lua -F abc -k foo -v bar Differential Revision: https://reviews.llvm.org/D93649 --- .../Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h | 14 ++++++++++++++ 1 file changed, 14 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 6c3fc01..1130cee 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h +++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h @@ -9,6 +9,7 @@ #ifndef liblldb_ScriptInterpreterLua_h_ #define liblldb_ScriptInterpreterLua_h_ +#include "lldb/Core/StructuredDataImpl.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" @@ -22,6 +23,11 @@ public: CommandDataLua() : BreakpointOptions::CommandData() { interpreter = lldb::eScriptLanguageLua; } + CommandDataLua(StructuredData::ObjectSP extra_args_sp) + : BreakpointOptions::CommandData(), m_extra_args_sp(extra_args_sp) { + interpreter = lldb::eScriptLanguageLua; + } + StructuredData::ObjectSP m_extra_args_sp; }; ScriptInterpreterLua(Debugger &debugger); @@ -72,9 +78,17 @@ public: Status SetBreakpointCommandCallback(BreakpointOptions *bp_options, const char *command_body_text) override; + Status SetBreakpointCommandCallbackFunction( + BreakpointOptions *bp_options, const char *function_name, + StructuredData::ObjectSP extra_args_sp) override; + private: std::unique_ptr m_lua; bool m_session_is_active = false; + + Status RegisterBreakpointCallback(BreakpointOptions *bp_options, + const char *command_body_text, + StructuredData::ObjectSP extra_args_sp); }; } // namespace lldb_private -- cgit v1.1