1 //===-- ScriptInterpreterLua.h ----------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef liblldb_Lua_h_ 10 #define liblldb_Lua_h_ 11 12 #include "lldb/API/SBBreakpointLocation.h" 13 #include "lldb/API/SBFrame.h" 14 #include "lldb/Core/StructuredDataImpl.h" 15 #include "lldb/lldb-types.h" 16 #include "llvm/ADT/StringRef.h" 17 #include "llvm/Support/Error.h" 18 19 #include "lua.hpp" 20 21 #include <mutex> 22 23 namespace lldb_private { 24 25 extern "C" { 26 int luaopen_lldb(lua_State *L); 27 } 28 29 class Lua { 30 public: 31 Lua(); 32 ~Lua(); 33 34 llvm::Error Run(llvm::StringRef buffer); 35 llvm::Error RegisterBreakpointCallback(void *baton, const char *body); 36 llvm::Expected<bool> 37 CallBreakpointCallback(void *baton, lldb::StackFrameSP stop_frame_sp, 38 lldb::BreakpointLocationSP bp_loc_sp, 39 StructuredData::ObjectSP extra_args_sp); 40 llvm::Error RegisterWatchpointCallback(void *baton, const char *body); 41 llvm::Expected<bool> CallWatchpointCallback(void *baton, 42 lldb::StackFrameSP stop_frame_sp, 43 lldb::WatchpointSP wp_sp); 44 llvm::Error LoadModule(llvm::StringRef filename); 45 llvm::Error CheckSyntax(llvm::StringRef buffer); 46 llvm::Error ChangeIO(FILE *out, FILE *err); 47 48 private: 49 lua_State *m_lua_state; 50 }; 51 52 } // namespace lldb_private 53 54 #endif // liblldb_Lua_h_ 55