LLDB  mainline
ScriptInterpreterLua.cpp
Go to the documentation of this file.
1 //===-- ScriptInterpreterLua.cpp ------------------------------------------===//
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 #include "ScriptInterpreterLua.h"
10 #include "Lua.h"
12 #include "lldb/Core/Debugger.h"
14 #include "lldb/Core/StreamFile.h"
17 #include "lldb/Utility/Stream.h"
19 #include "lldb/Utility/Timer.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/Support/FormatAdapters.h"
22 #include <memory>
23 #include <vector>
24 
25 using namespace lldb;
26 using namespace lldb_private;
27 
29 
34 };
35 
37  public IOHandlerEditline {
38 public:
40  ScriptInterpreterLua &script_interpreter,
41  ActiveIOHandler active_io_handler = eIOHandlerNone)
42  : IOHandlerEditline(debugger, IOHandler::Type::LuaInterpreter, "lua",
43  ">>> ", "..> ", true, debugger.GetUseColor(), 0,
44  *this, nullptr),
45  m_script_interpreter(script_interpreter),
46  m_active_io_handler(active_io_handler) {
47  llvm::cantFail(m_script_interpreter.GetLua().ChangeIO(
48  debugger.GetOutputFile().GetStream(),
49  debugger.GetErrorFile().GetStream()));
50  llvm::cantFail(m_script_interpreter.EnterSession(debugger.GetID()));
51  }
52 
54  llvm::cantFail(m_script_interpreter.LeaveSession());
55  }
56 
57  void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
58  const char *instructions = nullptr;
59  switch (m_active_io_handler) {
60  case eIOHandlerNone:
61  break;
63  instructions = "Enter your Lua command(s). Type 'quit' to end.\n"
64  "The commands are compiled as the body of the following "
65  "Lua function\n"
66  "function (frame, wp) end\n";
67  SetPrompt(llvm::StringRef("..> "));
68  break;
70  instructions = "Enter your Lua command(s). Type 'quit' to end.\n"
71  "The commands are compiled as the body of the following "
72  "Lua function\n"
73  "function (frame, bp_loc, ...) end\n";
74  SetPrompt(llvm::StringRef("..> "));
75  break;
76  }
77  if (instructions == nullptr)
78  return;
79  if (interactive)
80  *io_handler.GetOutputStreamFileSP() << instructions;
81  }
82 
84  StringList &lines) override {
85  size_t last = lines.GetSize() - 1;
86  if (IsQuitCommand(lines.GetStringAtIndex(last))) {
87  if (m_active_io_handler == eIOHandlerBreakpoint ||
88  m_active_io_handler == eIOHandlerWatchpoint)
89  lines.DeleteStringAtIndex(last);
90  return true;
91  }
92  StreamString str;
93  lines.Join("\n", str);
94  if (llvm::Error E =
95  m_script_interpreter.GetLua().CheckSyntax(str.GetString())) {
96  std::string error_str = toString(std::move(E));
97  // Lua always errors out to incomplete code with '<eof>'
98  return error_str.find("<eof>") == std::string::npos;
99  }
100  // The breakpoint and watchpoint handler only exits with a explicit 'quit'
101  return m_active_io_handler != eIOHandlerBreakpoint &&
102  m_active_io_handler != eIOHandlerWatchpoint;
103  }
104 
106  std::string &data) override {
107  switch (m_active_io_handler) {
108  case eIOHandlerBreakpoint: {
109  auto *bp_options_vec =
110  static_cast<std::vector<std::reference_wrapper<BreakpointOptions>> *>(
111  io_handler.GetUserData());
112  for (BreakpointOptions &bp_options : *bp_options_vec) {
113  Status error = m_script_interpreter.SetBreakpointCommandCallback(
114  bp_options, data.c_str());
115  if (error.Fail())
116  *io_handler.GetErrorStreamFileSP() << error.AsCString() << '\n';
117  }
118  io_handler.SetIsDone(true);
119  } break;
120  case eIOHandlerWatchpoint: {
121  auto *wp_options =
122  static_cast<WatchpointOptions *>(io_handler.GetUserData());
123  m_script_interpreter.SetWatchpointCommandCallback(wp_options,
124  data.c_str());
125  io_handler.SetIsDone(true);
126  } break;
127  case eIOHandlerNone:
128  if (IsQuitCommand(data)) {
129  io_handler.SetIsDone(true);
130  return;
131  }
132  if (llvm::Error error = m_script_interpreter.GetLua().Run(data))
133  *io_handler.GetErrorStreamFileSP() << toString(std::move(error));
134  break;
135  }
136  }
137 
138 private:
141 
142  bool IsQuitCommand(llvm::StringRef cmd) { return cmd.rtrim() == "quit"; }
143 };
144 
145 ScriptInterpreterLua::ScriptInterpreterLua(Debugger &debugger)
147  m_lua(std::make_unique<Lua>()) {}
148 
150 
152  auto info = std::make_shared<StructuredData::Dictionary>();
153  info->AddStringItem("language", "lua");
154  return info;
155 }
156 
157 bool ScriptInterpreterLua::ExecuteOneLine(llvm::StringRef command,
158  CommandReturnObject *result,
159  const ExecuteScriptOptions &options) {
160  if (command.empty()) {
161  if (result)
162  result->AppendError("empty command passed to lua\n");
163  return false;
164  }
165 
166  llvm::Expected<std::unique_ptr<ScriptInterpreterIORedirect>>
167  io_redirect_or_error = ScriptInterpreterIORedirect::Create(
168  options.GetEnableIO(), m_debugger, result);
169  if (!io_redirect_or_error) {
170  if (result)
171  result->AppendErrorWithFormatv(
172  "failed to redirect I/O: {0}\n",
173  llvm::fmt_consume(io_redirect_or_error.takeError()));
174  else
175  llvm::consumeError(io_redirect_or_error.takeError());
176  return false;
177  }
178 
179  ScriptInterpreterIORedirect &io_redirect = **io_redirect_or_error;
180 
181  if (llvm::Error e =
182  m_lua->ChangeIO(io_redirect.GetOutputFile()->GetStream(),
183  io_redirect.GetErrorFile()->GetStream())) {
184  result->AppendErrorWithFormatv("lua failed to redirect I/O: {0}\n",
185  llvm::toString(std::move(e)));
186  return false;
187  }
188 
189  if (llvm::Error e = m_lua->Run(command)) {
190  result->AppendErrorWithFormatv(
191  "lua failed attempting to evaluate '{0}': {1}\n", command,
192  llvm::toString(std::move(e)));
193  return false;
194  }
195 
196  io_redirect.Flush();
197  return true;
198 }
199 
202 
203  // At the moment, the only time the debugger does not have an input file
204  // handle is when this is called directly from lua, in which case it is
205  // both dangerous and unnecessary (not to mention confusing) to try to embed
206  // a running interpreter loop inside the already running lua interpreter
207  // loop, so we won't do it.
209  return;
210 
211  IOHandlerSP io_handler_sp(new IOHandlerLuaInterpreter(m_debugger, *this));
212  m_debugger.RunIOHandlerAsync(io_handler_sp);
213 }
214 
216  const char *filename, const LoadScriptOptions &options,
218  FileSpec extra_search_dir) {
219 
220  if (llvm::Error e = m_lua->LoadModule(filename)) {
221  error.SetErrorStringWithFormatv("lua failed to import '{0}': {1}\n",
222  filename, llvm::toString(std::move(e)));
223  return false;
224  }
225  return true;
226 }
227 
229  static llvm::once_flag g_once_flag;
230 
231  llvm::call_once(g_once_flag, []() {
235  });
236 }
237 
239 
242  return llvm::Error::success();
243 
244  const char *fmt_str =
245  "lldb.debugger = lldb.SBDebugger.FindDebuggerWithID({0}); "
246  "lldb.target = lldb.debugger:GetSelectedTarget(); "
247  "lldb.process = lldb.target:GetProcess(); "
248  "lldb.thread = lldb.process:GetSelectedThread(); "
249  "lldb.frame = lldb.thread:GetSelectedFrame()";
250  return m_lua->Run(llvm::formatv(fmt_str, debugger_id).str());
251 }
252 
254  if (!m_session_is_active)
255  return llvm::Error::success();
256 
257  m_session_is_active = false;
258 
259  llvm::StringRef str = "lldb.debugger = nil; "
260  "lldb.target = nil; "
261  "lldb.process = nil; "
262  "lldb.thread = nil; "
263  "lldb.frame = nil";
264  return m_lua->Run(str);
265 }
266 
268  void *baton, StoppointCallbackContext *context, user_id_t break_id,
269  user_id_t break_loc_id) {
270  assert(context);
271 
272  ExecutionContext exe_ctx(context->exe_ctx_ref);
273  Target *target = exe_ctx.GetTargetPtr();
274  if (target == nullptr)
275  return true;
276 
277  StackFrameSP stop_frame_sp(exe_ctx.GetFrameSP());
278  BreakpointSP breakpoint_sp = target->GetBreakpointByID(break_id);
279  BreakpointLocationSP bp_loc_sp(breakpoint_sp->FindLocationByID(break_loc_id));
280 
281  Debugger &debugger = target->GetDebugger();
282  ScriptInterpreterLua *lua_interpreter = static_cast<ScriptInterpreterLua *>(
283  debugger.GetScriptInterpreter(true, eScriptLanguageLua));
284  Lua &lua = lua_interpreter->GetLua();
285 
286  CommandDataLua *bp_option_data = static_cast<CommandDataLua *>(baton);
287  llvm::Expected<bool> BoolOrErr = lua.CallBreakpointCallback(
288  baton, stop_frame_sp, bp_loc_sp, bp_option_data->m_extra_args_sp);
289  if (llvm::Error E = BoolOrErr.takeError()) {
290  debugger.GetErrorStream() << toString(std::move(E));
291  return true;
292  }
293 
294  return *BoolOrErr;
295 }
296 
298  void *baton, StoppointCallbackContext *context, user_id_t watch_id) {
299  assert(context);
300 
301  ExecutionContext exe_ctx(context->exe_ctx_ref);
302  Target *target = exe_ctx.GetTargetPtr();
303  if (target == nullptr)
304  return true;
305 
306  StackFrameSP stop_frame_sp(exe_ctx.GetFrameSP());
307  WatchpointSP wp_sp = target->GetWatchpointList().FindByID(watch_id);
308 
309  Debugger &debugger = target->GetDebugger();
310  ScriptInterpreterLua *lua_interpreter = static_cast<ScriptInterpreterLua *>(
311  debugger.GetScriptInterpreter(true, eScriptLanguageLua));
312  Lua &lua = lua_interpreter->GetLua();
313 
314  llvm::Expected<bool> BoolOrErr =
315  lua.CallWatchpointCallback(baton, stop_frame_sp, wp_sp);
316  if (llvm::Error E = BoolOrErr.takeError()) {
317  debugger.GetErrorStream() << toString(std::move(E));
318  return true;
319  }
320 
321  return *BoolOrErr;
322 }
323 
325  std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
326  CommandReturnObject &result) {
327  IOHandlerSP io_handler_sp(
329  io_handler_sp->SetUserData(&bp_options_vec);
330  m_debugger.RunIOHandlerAsync(io_handler_sp);
331 }
332 
334  WatchpointOptions *wp_options, CommandReturnObject &result) {
335  IOHandlerSP io_handler_sp(
337  io_handler_sp->SetUserData(wp_options);
338  m_debugger.RunIOHandlerAsync(io_handler_sp);
339 }
340 
342  BreakpointOptions &bp_options, const char *function_name,
343  StructuredData::ObjectSP extra_args_sp) {
344  const char *fmt_str = "return {0}(frame, bp_loc, ...)";
345  std::string oneliner = llvm::formatv(fmt_str, function_name).str();
346  return RegisterBreakpointCallback(bp_options, oneliner.c_str(),
347  extra_args_sp);
348 }
349 
351  BreakpointOptions &bp_options, const char *command_body_text) {
352  return RegisterBreakpointCallback(bp_options, command_body_text, {});
353 }
354 
356  BreakpointOptions &bp_options, const char *command_body_text,
357  StructuredData::ObjectSP extra_args_sp) {
358  Status error;
359  auto data_up = std::make_unique<CommandDataLua>(extra_args_sp);
360  error = m_lua->RegisterBreakpointCallback(data_up.get(), command_body_text);
361  if (error.Fail())
362  return error;
363  auto baton_sp =
364  std::make_shared<BreakpointOptions::CommandBaton>(std::move(data_up));
366  baton_sp);
367  return error;
368 }
369 
371  WatchpointOptions *wp_options, const char *command_body_text) {
372  RegisterWatchpointCallback(wp_options, command_body_text, {});
373 }
374 
376  WatchpointOptions *wp_options, const char *command_body_text,
377  StructuredData::ObjectSP extra_args_sp) {
378  Status error;
379  auto data_up = std::make_unique<WatchpointOptions::CommandData>();
380  error = m_lua->RegisterWatchpointCallback(data_up.get(), command_body_text);
381  if (error.Fail())
382  return error;
383  auto baton_sp =
384  std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_up));
386  baton_sp);
387  return error;
388 }
389 
390 lldb::ScriptInterpreterSP
392  return std::make_shared<ScriptInterpreterLua>(debugger);
393 }
394 
396  return "Lua script interpreter";
397 }
398 
lldb_private::toString
const char * toString(AppleArm64ExceptionClass EC)
Definition: AppleArm64ExceptionClass.h:38
lldb_private::ScriptInterpreterLua::GetInterpreterInfo
StructuredData::DictionarySP GetInterpreterInfo() override
Definition: ScriptInterpreterLua.cpp:151
lldb_private::ScriptInterpreterLua::LeaveSession
llvm::Error LeaveSession()
Definition: ScriptInterpreterLua.cpp:253
lldb_private::ExecuteScriptOptions::GetEnableIO
bool GetEnableIO() const
Definition: ScriptInterpreter.h:45
lldb_private::ScriptInterpreterLua::EnterSession
llvm::Error EnterSession(lldb::user_id_t debugger_id)
Definition: ScriptInterpreterLua.cpp:240
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
IOHandlerLuaInterpreter::m_active_io_handler
ActiveIOHandler m_active_io_handler
Definition: ScriptInterpreterLua.cpp:140
lldb_private::Debugger::GetErrorFile
File & GetErrorFile()
Definition: Debugger.h:144
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::ScriptInterpreterIORedirect
Definition: ScriptInterpreter.h:97
lldb_private::Lua
Definition: Lua.h:29
Lua.h
ScriptInterpreterLua.h
lldb_private::ScriptInterpreterIORedirect::GetErrorFile
lldb::FileSP GetErrorFile() const
Definition: ScriptInterpreter.h:109
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:341
lldb_private::WatchpointOptions::SetCallback
void SetCallback(WatchpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous=false)
Adds a callback to the watchpoint option set.
Definition: WatchpointOptions.cpp:69
lldb_private::Lua::CallWatchpointCallback
llvm::Expected< bool > CallWatchpointCallback(void *baton, lldb::StackFrameSP stop_frame_sp, lldb::WatchpointSP wp_sp)
Definition: Lua.cpp:107
lldb_private::Debugger::RunIOHandlerAsync
void RunIOHandlerAsync(const lldb::IOHandlerSP &reader_sp, bool cancel_top_handler=true)
Run the given IO handler and return immediately.
Definition: Debugger.cpp:1103
lldb_private::StoppointCallbackContext::exe_ctx_ref
ExecutionContextRef exe_ctx_ref
Definition: StoppointCallbackContext.h:43
StoppointCallbackContext.h
lldb_private::ScriptInterpreterLua::Initialize
static void Initialize()
Definition: ScriptInterpreterLua.cpp:228
eIOHandlerBreakpoint
@ eIOHandlerBreakpoint
Definition: ScriptInterpreterLua.cpp:32
lldb_private::ScriptInterpreterLua::RegisterBreakpointCallback
Status RegisterBreakpointCallback(BreakpointOptions &bp_options, const char *command_body_text, StructuredData::ObjectSP extra_args_sp)
Definition: ScriptInterpreterLua.cpp:355
eIOHandlerNone
@ eIOHandlerNone
Definition: ScriptInterpreterLua.cpp:31
lldb_private::ScriptInterpreterLua::CollectDataForWatchpointCommandCallback
void CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options, CommandReturnObject &result) override
Definition: ScriptInterpreterLua.cpp:333
lldb_private::WatchpointList::FindByID
lldb::WatchpointSP FindByID(lldb::watch_id_t watchID) const
Returns a shared pointer to the watchpoint with id watchID, const version.
Definition: WatchpointList.cpp:111
lldb_private::Target::GetWatchpointList
WatchpointList & GetWatchpointList()
Definition: Target.h:737
lldb_private::ScriptInterpreterIORedirect::Create
static llvm::Expected< std::unique_ptr< ScriptInterpreterIORedirect > > Create(bool enable_io, Debugger &debugger, CommandReturnObject *result)
Create an IO redirect.
Definition: ScriptInterpreter.cpp:149
lldb_private::Target::GetDebugger
Debugger & GetDebugger()
Definition: Target.h:1019
CommandReturnObject.h
Debugger.h
lldb_private::Target
Definition: Target.h:467
lldb_private::CommandReturnObject::AppendErrorWithFormatv
void AppendErrorWithFormatv(const char *format, Args &&... args)
Definition: CommandReturnObject.h:130
lldb_private::Debugger::GetScriptInterpreter
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, llvm::Optional< lldb::ScriptLanguage > language={})
Definition: Debugger.cpp:1476
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
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:267
IOHandlerLuaInterpreter
Definition: ScriptInterpreterLua.cpp:36
lldb_private::ScriptInterpreter::m_debugger
Debugger & m_debugger
Definition: ScriptInterpreter.h:574
lldb_private::StringList::GetSize
size_t GetSize() const
Definition: StringList.cpp:74
lldb_private::ScriptInterpreterLua::SetBreakpointCommandCallback
Status SetBreakpointCommandCallback(BreakpointOptions &bp_options, const char *command_body_text) override
Definition: ScriptInterpreterLua.cpp:350
lldb_private::ScriptInterpreterLua::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: ScriptInterpreterLua.h:61
IOHandlerLuaInterpreter::~IOHandlerLuaInterpreter
~IOHandlerLuaInterpreter() override
Definition: ScriptInterpreterLua.cpp:53
IOHandlerLuaInterpreter::IOHandlerLuaInterpreter
IOHandlerLuaInterpreter(Debugger &debugger, ScriptInterpreterLua &script_interpreter, ActiveIOHandler active_io_handler=eIOHandlerNone)
Definition: ScriptInterpreterLua.cpp:39
lldb_private::Debugger::GetInputFile
File & GetInputFile()
Definition: Debugger.h:140
lldb_private::ScriptInterpreterLua::ExecuteOneLine
bool ExecuteOneLine(llvm::StringRef command, CommandReturnObject *result, const ExecuteScriptOptions &options=ExecuteScriptOptions()) override
Definition: ScriptInterpreterLua.cpp:157
lldb_private::File::IsValid
bool IsValid() const override
IsValid.
Definition: File.cpp:111
lldb_private::FileSpec
Definition: FileSpec.h:56
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::Lua::CallBreakpointCallback
llvm::Expected< bool > CallBreakpointCallback(void *baton, lldb::StackFrameSP stop_frame_sp, lldb::BreakpointLocationSP bp_loc_sp, StructuredData::ObjectSP extra_args_sp)
Definition: Lua.cpp:79
lldb_private::StringList::GetStringAtIndex
const char * GetStringAtIndex(size_t idx) const
Definition: StringList.cpp:86
IOHandlerLuaInterpreter::m_script_interpreter
ScriptInterpreterLua & m_script_interpreter
Definition: ScriptInterpreterLua.cpp:139
lldb_private::Debugger::GetOutputFile
File & GetOutputFile()
Definition: Debugger.h:142
lldb_private::ScriptInterpreterIORedirect::GetOutputFile
lldb::FileSP GetOutputFile() const
Definition: ScriptInterpreter.h:108
lldb_private::ScriptInterpreterLua::WatchpointCallbackFunction
static bool WatchpointCallbackFunction(void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id)
Definition: ScriptInterpreterLua.cpp:297
lldb_private::BreakpointOptions::SetCallback
void SetCallback(BreakpointHitCallback callback, const lldb::BatonSP &baton_sp, bool synchronous=false)
Adds a callback to the breakpoint option set.
Definition: BreakpointOptions.cpp:392
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
ActiveIOHandler
ActiveIOHandler
Definition: ScriptInterpreterLua.cpp:30
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::StringList
Definition: StringList.h:26
lldb_private::StreamString
Definition: StreamString.h:23
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:375
lldb_private::IOHandler
Definition: IOHandler.h:46
Timer.h
lldb_private::ExecuteScriptOptions
Definition: ScriptInterpreter.h:41
LLDB_SCOPED_TIMER
#define LLDB_SCOPED_TIMER()
Definition: Timer.h:83
lldb_private::StructuredData::DictionarySP
std::shared_ptr< Dictionary > DictionarySP
Definition: StructuredData.h:67
lldb_private::Debugger
Definition: Debugger.h:74
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
StringList.h
eIOHandlerWatchpoint
@ eIOHandlerWatchpoint
Definition: ScriptInterpreterLua.cpp:33
lldb_private::ScriptInterpreterLua::CreateInstance
static lldb::ScriptInterpreterSP CreateInstance(Debugger &debugger)
Definition: ScriptInterpreterLua.cpp:391
IOHandlerLuaInterpreter::IOHandlerInputComplete
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
Definition: ScriptInterpreterLua.cpp:105
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
StreamFile.h
lldb_private::ScriptInterpreterLua::CommandDataLua::m_extra_args_sp
StructuredData::ObjectSP m_extra_args_sp
Definition: ScriptInterpreterLua.h:33
lldb_private::Status
Definition: Status.h:44
lldb_private::ScriptInterpreterLua::GetPluginDescriptionStatic
static llvm::StringRef GetPluginDescriptionStatic()
Definition: ScriptInterpreterLua.cpp:395
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:26
lldb_private::ExecutionContext::GetFrameSP
const lldb::StackFrameSP & GetFrameSP() const
Get accessor to get the frame shared pointer.
Definition: ExecutionContext.h:469
lldb_private::ScriptInterpreterLua::CollectDataForBreakpointCommandCallback
void CollectDataForBreakpointCommandCallback(std::vector< std::reference_wrapper< BreakpointOptions >> &bp_options_vec, CommandReturnObject &result) override
Definition: ScriptInterpreterLua.cpp:324
lldb_private::ScriptInterpreterLua::GetLua
Lua & GetLua()
Definition: ScriptInterpreterLua.cpp:399
lldb_private::StringList::DeleteStringAtIndex
void DeleteStringAtIndex(size_t id)
Definition: StringList.cpp:147
lldb_private::IOHandler::GetUserData
void * GetUserData()
Definition: IOHandler.h:139
lldb_private::ScriptInterpreterLua::~ScriptInterpreterLua
~ScriptInterpreterLua() override
lldb_private::IOHandler::Type
Type
Definition: IOHandler.h:48
PluginManager.h
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:126
lldb_private::IOHandler::SetIsDone
void SetIsDone(bool b)
Definition: IOHandler.h:90
lldb_private::ScriptInterpreterIORedirect::Flush
void Flush()
Flush our output and error file handles.
Definition: ScriptInterpreter.cpp:221
IOHandlerLuaInterpreter::IsQuitCommand
bool IsQuitCommand(llvm::StringRef cmd)
Definition: ScriptInterpreterLua.cpp:142
lldb_private::ScriptInterpreterLua::CommandDataLua
Definition: ScriptInterpreterLua.h:24
IOHandlerLuaInterpreter::IOHandlerIsInputComplete
bool IOHandlerIsInputComplete(IOHandler &io_handler, StringList &lines) override
Called to determine whether typing enter after the last line in lines should end input.
Definition: ScriptInterpreterLua.cpp:83
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private::PluginManager::RegisterPlugin
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
Definition: PluginManager.cpp:287
lldb_private::IOHandlerDelegate
A delegate class for use with IOHandler subclasses.
Definition: IOHandler.h:195
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:30
lldb_private::ScriptInterpreterLua
Definition: ScriptInterpreterLua.h:22
lldb_private::ScriptInterpreterLua::ExecuteInterpreterLoop
void ExecuteInterpreterLoop() override
Definition: ScriptInterpreterLua.cpp:200
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:370
lldb_private::File::GetStream
virtual FILE * GetStream()
Get the underlying libc stream for this file, or NULL.
Definition: File.cpp:126
lldb_private::LoadScriptOptions
Definition: ScriptInterpreter.h:75
Stream.h
LLDB_PLUGIN_DEFINE
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:31
lldb_private::Target::GetBreakpointByID
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Definition: Target.cpp:322
lldb_private::CommandReturnObject::AppendError
void void AppendError(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:100
lldb_private::StringList::Join
void Join(const char *separator, Stream &strm)
Definition: StringList.cpp:92
lldb_private::Debugger::GetErrorStream
StreamFile & GetErrorStream()
Definition: Debugger.h:148
lldb
Definition: SBAddress.h:15
lldb_private::IOHandler::GetOutputStreamFileSP
lldb::StreamFileSP GetOutputStreamFileSP()
Definition: IOHandler.cpp:109
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:198
ExecutionContext.h
lldb_private::ScriptInterpreterLua::Terminate
static void Terminate()
Definition: ScriptInterpreterLua.cpp:238
lldb_private::IOHandler::GetErrorStreamFileSP
lldb::StreamFileSP GetErrorStreamFileSP()
Definition: IOHandler.cpp:111
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:215
lldb_private::IOHandlerEditline
Definition: IOHandler.h:332
IOHandlerLuaInterpreter::IOHandlerActivated
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
Definition: ScriptInterpreterLua.cpp:57