LLDB  mainline
ScriptInterpreterLua.h
Go to the documentation of this file.
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_ScriptInterpreterLua_h_
10 #define liblldb_ScriptInterpreterLua_h_
11 
12 #include <vector>
13 
17 #include "lldb/Utility/Status.h"
18 #include "lldb/lldb-enumerations.h"
19 
20 namespace lldb_private {
21 class Lua;
23 public:
25  public:
28  }
30  : BreakpointOptions::CommandData(), m_extra_args_sp(extra_args_sp) {
32  }
34  };
35 
36  ScriptInterpreterLua(Debugger &debugger);
37 
38  ~ScriptInterpreterLua() override;
39 
40  bool ExecuteOneLine(
41  llvm::StringRef command, CommandReturnObject *result,
42  const ExecuteScriptOptions &options = ExecuteScriptOptions()) override;
43 
44  void ExecuteInterpreterLoop() override;
45 
46  bool LoadScriptingModule(const char *filename,
47  const LoadScriptOptions &options,
49  StructuredData::ObjectSP *module_sp = nullptr,
50  FileSpec extra_search_dir = {}) override;
51 
52  // Static Functions
53  static void Initialize();
54 
55  static void Terminate();
56 
57  static lldb::ScriptInterpreterSP CreateInstance(Debugger &debugger);
58 
60 
61  static const char *GetPluginDescriptionStatic();
62 
63  static bool BreakpointCallbackFunction(void *baton,
64  StoppointCallbackContext *context,
65  lldb::user_id_t break_id,
66  lldb::user_id_t break_loc_id);
67 
68  static bool WatchpointCallbackFunction(void *baton,
69  StoppointCallbackContext *context,
70  lldb::user_id_t watch_id);
71 
72  // PluginInterface protocol
73  llvm::StringRef GetPluginName() override {
75  }
76 
77  Lua &GetLua();
78 
81 
83  std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
84  CommandReturnObject &result) override;
85 
86  void
88  CommandReturnObject &result) override;
89 
91  const char *command_body_text) override;
92 
94  const char *command_body_text) override;
95 
97  BreakpointOptions &bp_options, const char *function_name,
98  StructuredData::ObjectSP extra_args_sp) override;
99 
100 private:
101  std::unique_ptr<Lua> m_lua;
102  bool m_session_is_active = false;
103 
105  const char *command_body_text,
106  StructuredData::ObjectSP extra_args_sp);
107 
109  const char *command_body_text,
110  StructuredData::ObjectSP extra_args_sp);
111 };
112 
113 } // namespace lldb_private
114 
115 #endif // liblldb_ScriptInterpreterLua_h_
lldb_private::ScriptInterpreterLua::LeaveSession
llvm::Error LeaveSession()
Definition: ScriptInterpreterLua.cpp:248
lldb_private::ScriptInterpreterLua::EnterSession
llvm::Error EnterSession(lldb::user_id_t debugger_id)
Definition: ScriptInterpreterLua.cpp:235
lldb_private::StoppointCallbackContext
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
Definition: StoppointCallbackContext.h:26
lldb_private::ScriptInterpreterLua::m_lua
std::unique_ptr< Lua > m_lua
Definition: ScriptInterpreterLua.h:101
lldb_private::BreakpointOptions::CommandData
Definition: BreakpointOptions.h:45
lldb_private::Lua
Definition: Lua.h:29
lldb_private::ScriptInterpreterLua::SetBreakpointCommandCallbackFunction
Status SetBreakpointCommandCallbackFunction(BreakpointOptions &bp_options, const char *function_name, StructuredData::ObjectSP extra_args_sp) override
Set a script function as the callback for the breakpoint.
Definition: ScriptInterpreterLua.cpp:336
lldb_private::ScriptInterpreterLua::Initialize
static void Initialize()
Definition: ScriptInterpreterLua.cpp:223
lldb_private::ScriptInterpreterLua::RegisterBreakpointCallback
Status RegisterBreakpointCallback(BreakpointOptions &bp_options, const char *command_body_text, StructuredData::ObjectSP extra_args_sp)
Definition: ScriptInterpreterLua.cpp:350
lldb_private::ScriptInterpreterLua::CollectDataForWatchpointCommandCallback
void CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options, CommandReturnObject &result) override
Definition: ScriptInterpreterLua.cpp:328
lldb_private::ScriptInterpreterLua::BreakpointCallbackFunction
static bool BreakpointCallbackFunction(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Definition: ScriptInterpreterLua.cpp:262
lldb_private::ScriptInterpreterLua::SetBreakpointCommandCallback
Status SetBreakpointCommandCallback(BreakpointOptions &bp_options, const char *command_body_text) override
Definition: ScriptInterpreterLua.cpp:345
WatchpointOptions.h
lldb_private::ScriptInterpreterLua::ExecuteOneLine
bool ExecuteOneLine(llvm::StringRef command, CommandReturnObject *result, const ExecuteScriptOptions &options=ExecuteScriptOptions()) override
Definition: ScriptInterpreterLua.cpp:151
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:202
lldb_private::ScriptInterpreterLua::WatchpointCallbackFunction
static bool WatchpointCallbackFunction(void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id)
Definition: ScriptInterpreterLua.cpp:292
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
lldb_private::WatchpointOptions
Definition: WatchpointOptions.h:25
lldb_private::ScriptInterpreterLua::m_session_is_active
bool m_session_is_active
Definition: ScriptInterpreterLua.h:102
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::BreakpointOptions
Definition: BreakpointOptions.h:27
lldb_private::ScriptInterpreterLua::RegisterWatchpointCallback
Status RegisterWatchpointCallback(WatchpointOptions *wp_options, const char *command_body_text, StructuredData::ObjectSP extra_args_sp)
Definition: ScriptInterpreterLua.cpp:370
lldb-enumerations.h
lldb_private::ScriptInterpreterLua::GetPluginName
llvm::StringRef GetPluginName() override
Definition: ScriptInterpreterLua.h:73
lldb_private::ExecuteScriptOptions
Definition: ScriptInterpreter.h:41
lldb_private::ScriptInterpreterLua::GetPluginDescriptionStatic
static const char * GetPluginDescriptionStatic()
Definition: ScriptInterpreterLua.cpp:395
lldb_private::Debugger
Definition: Debugger.h:70
lldb_private::ScriptInterpreterLua::CreateInstance
static lldb::ScriptInterpreterSP CreateInstance(Debugger &debugger)
Definition: ScriptInterpreterLua.cpp:386
lldb_private::BreakpointOptions::CommandData::CommandData
CommandData()
Definition: BreakpointOptions.h:46
lldb_private::ScriptInterpreterLua::GetPluginNameStatic
static lldb_private::ConstString GetPluginNameStatic()
Definition: ScriptInterpreterLua.cpp:390
lldb_private::ScriptInterpreterLua::CommandDataLua::m_extra_args_sp
StructuredData::ObjectSP m_extra_args_sp
Definition: ScriptInterpreterLua.h:33
lldb_private::BreakpointOptions::CommandData::interpreter
enum lldb::ScriptLanguage interpreter
Definition: BreakpointOptions.h:64
lldb_private::Status
Definition: Status.h:44
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:25
lldb_private::ScriptInterpreterLua::CollectDataForBreakpointCommandCallback
void CollectDataForBreakpointCommandCallback(std::vector< std::reference_wrapper< BreakpointOptions >> &bp_options_vec, CommandReturnObject &result) override
Definition: ScriptInterpreterLua.cpp:319
lldb_private::ScriptInterpreterLua::GetLua
Lua & GetLua()
Definition: ScriptInterpreterLua.cpp:399
lldb_private::ScriptInterpreterLua::~ScriptInterpreterLua
~ScriptInterpreterLua() override
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:126
StructuredDataImpl.h
lldb_private::ScriptInterpreterLua::CommandDataLua
Definition: ScriptInterpreterLua.h:24
lldb_private::ScriptInterpreterLua::CommandDataLua::CommandDataLua
CommandDataLua(StructuredData::ObjectSP extra_args_sp)
Definition: ScriptInterpreterLua.h:29
Status.h
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:29
lldb_private::ScriptInterpreterLua
Definition: ScriptInterpreterLua.h:22
lldb_private::ScriptInterpreterLua::ScriptInterpreterLua
ScriptInterpreterLua(Debugger &debugger)
Definition: ScriptInterpreterLua.cpp:145
lldb_private::ScriptInterpreterLua::ExecuteInterpreterLoop
void ExecuteInterpreterLoop() override
Definition: ScriptInterpreterLua.cpp:194
lldb::eScriptLanguageLua
@ eScriptLanguageLua
Definition: lldb-enumerations.h:219
lldb_private::ScriptInterpreterLua::SetWatchpointCommandCallback
void SetWatchpointCommandCallback(WatchpointOptions *wp_options, const char *command_body_text) override
Set a one-liner as the callback for the watchpoint.
Definition: ScriptInterpreterLua.cpp:365
lldb_private::LoadScriptOptions
Definition: ScriptInterpreter.h:75
ScriptInterpreter.h
lldb_private::ScriptInterpreterLua::CommandDataLua::CommandDataLua
CommandDataLua()
Definition: ScriptInterpreterLua.h:26
lldb_private::ScriptInterpreterLua::Terminate
static void Terminate()
Definition: ScriptInterpreterLua.cpp:233
lldb_private::ScriptInterpreterLua::LoadScriptingModule
bool LoadScriptingModule(const char *filename, const LoadScriptOptions &options, lldb_private::Status &error, StructuredData::ObjectSP *module_sp=nullptr, FileSpec extra_search_dir={}) override
Definition: ScriptInterpreterLua.cpp:209