diff options
author | Pedro Tammela <pctammela@gmail.com> | 2020-11-15 19:39:16 +0000 |
---|---|---|
committer | Pedro Tammela <pctammela@gmail.com> | 2020-11-30 14:12:26 +0000 |
commit | a0d7406ae800c45dd9cb438c7ae1f55329d198e2 (patch) | |
tree | 8db3f5ff0f91bb858481bea5bc5570a2557f094d /lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h | |
parent | 8e504615e9f1b27c06237a56ee786a16568851f1 (diff) | |
download | llvm-a0d7406ae800c45dd9cb438c7ae1f55329d198e2.zip llvm-a0d7406ae800c45dd9cb438c7ae1f55329d198e2.tar.gz llvm-a0d7406ae800c45dd9cb438c7ae1f55329d198e2.tar.bz2 |
[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, ...)
<body>
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
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h')
-rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h | 17 |
1 files changed, 17 insertions, 0 deletions
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<Lua> m_lua; bool m_session_is_active = false; |