1%header %{ 2 3template <typename T> 4void 5PushSBClass(lua_State* L, T* obj); 6 7%} 8 9%wrapper %{ 10 11// This function is called from Lua::CallBreakpointCallback 12SWIGEXPORT llvm::Expected<bool> 13LLDBSwigLuaBreakpointCallbackFunction 14( 15 lua_State *L, 16 lldb::StackFrameSP stop_frame_sp, 17 lldb::BreakpointLocationSP bp_loc_sp 18) 19{ 20 lldb::SBFrame sb_frame(stop_frame_sp); 21 lldb::SBBreakpointLocation sb_bp_loc(bp_loc_sp); 22 23 // Push the Lua wrappers 24 PushSBClass(L, &sb_frame); 25 PushSBClass(L, &sb_bp_loc); 26 27 // Call into the Lua callback passing 'sb_frame' and 'sb_bp_loc'. 28 // Expects a boolean return. 29 if (lua_pcall(L, 2, 1, 0) != LUA_OK) { 30 llvm::Error E = llvm::make_error<llvm::StringError>( 31 llvm::formatv("{0}\n", lua_tostring(L, -1)), 32 llvm::inconvertibleErrorCode()); 33 // Pop error message from the stack. 34 lua_pop(L, 1); 35 return std::move(E); 36 } 37 38 // Boolean return from the callback 39 bool stop = lua_toboolean(L, -1); 40 lua_pop(L, 1); 41 42 return stop; 43} 44 45 46%} 47