[Lldb-commits] [PATCH] D91508: [LLDB/Lua] add support for one-liner breakpoint callback

Pedro Tammela via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 17 01:30:08 PST 2020


tammela added inline comments.


================
Comment at: lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp:60-78
+static int runCallback(lua_State *L) {
+  LuaCallback *callback = static_cast<LuaCallback *>(lua_touserdata(L, -1));
+  return (*callback)(L);
+}
+
+llvm::Error Lua::Run(LuaCallback &callback) {
+  lua_pushcfunction(m_lua_state, runCallback);
----------------
labath wrote:
> I'm confused. Why use lua to call a c callback, when you could just do `calllback()`?
Some Lua API functions throw errors, if there's any it will `abort()` the program if no panic handler or protected call is provided.
To guarantee that the callback always runs in a protected environment and it has error handling, we do the above.
Delegating this to the callback itself makes it cumbersome to write.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91508/new/

https://reviews.llvm.org/D91508



More information about the lldb-commits mailing list