LLDB  mainline
CommandObjectBreakpointCommand.cpp
Go to the documentation of this file.
1 //===-- CommandObjectBreakpointCommand.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 
14 #include "lldb/Core/IOHandler.h"
15 #include "lldb/Host/OptionParser.h"
21 #include "lldb/Target/Target.h"
22 
23 using namespace lldb;
24 using namespace lldb_private;
25 
26 #define LLDB_OPTIONS_breakpoint_command_add
27 #include "CommandOptions.inc"
28 
31 public:
33  : CommandObjectParsed(interpreter, "add",
34  "Add LLDB commands to a breakpoint, to be executed "
35  "whenever the breakpoint is hit. "
36  "The commands added to the breakpoint replace any "
37  "commands previously added to it."
38  " If no breakpoint is specified, adds the "
39  "commands to the last created breakpoint.",
40  nullptr),
42  IOHandlerDelegate::Completion::LLDBCommand),
43  m_func_options("breakpoint command", false, 'F') {
44  SetHelpLong(
45  R"(
46 General information about entering breakpoint commands
47 ------------------------------------------------------
48 
49 )"
50  "This command will prompt for commands to be executed when the specified \
51 breakpoint is hit. Each command is typed on its own line following the '> ' \
52 prompt until 'DONE' is entered."
53  R"(
54 
55 )"
56  "Syntactic errors may not be detected when initially entered, and many \
57 malformed commands can silently fail when executed. If your breakpoint commands \
58 do not appear to be executing, double-check the command syntax."
59  R"(
60 
61 )"
62  "Note: You may enter any debugger command exactly as you would at the debugger \
63 prompt. There is no limit to the number of commands supplied, but do NOT enter \
64 more than one command per line."
65  R"(
66 
67 Special information about PYTHON breakpoint commands
68 ----------------------------------------------------
69 
70 )"
71  "You may enter either one or more lines of Python, including function \
72 definitions or calls to functions that will have been imported by the time \
73 the code executes. Single line breakpoint commands will be interpreted 'as is' \
74 when the breakpoint is hit. Multiple lines of Python will be wrapped in a \
75 generated function, and a call to the function will be attached to the breakpoint."
76  R"(
77 
78 This auto-generated function is passed in three arguments:
79 
80  frame: an lldb.SBFrame object for the frame which hit breakpoint.
81 
82  bp_loc: an lldb.SBBreakpointLocation object that represents the breakpoint location that was hit.
83 
84  dict: the python session dictionary hit.
85 
86 )"
87  "When specifying a python function with the --python-function option, you need \
88 to supply the function name prepended by the module name:"
89  R"(
90 
91  --python-function myutils.breakpoint_callback
92 
93 The function itself must have either of the following prototypes:
94 
95 def breakpoint_callback(frame, bp_loc, internal_dict):
96  # Your code goes here
97 
98 or:
99 
100 def breakpoint_callback(frame, bp_loc, extra_args, internal_dict):
101  # Your code goes here
102 
103 )"
104  "The arguments are the same as the arguments passed to generated functions as \
105 described above. In the second form, any -k and -v pairs provided to the command will \
106 be packaged into a SBDictionary in an SBStructuredData and passed as the extra_args parameter. \
107 \n\n\
108 Note that the global variable 'lldb.frame' will NOT be updated when \
109 this function is called, so be sure to use the 'frame' argument. The 'frame' argument \
110 can get you to the thread via frame.GetThread(), the thread can get you to the \
111 process via thread.GetProcess(), and the process can get you back to the target \
112 via process.GetTarget()."
113  R"(
114 
115 )"
116  "Important Note: As Python code gets collected into functions, access to global \
117 variables requires explicit scoping using the 'global' keyword. Be sure to use correct \
118 Python syntax, including indentation, when entering Python breakpoint commands."
119  R"(
120 
121 Example Python one-line breakpoint command:
122 
123 (lldb) breakpoint command add -s python 1
124 Enter your Python command(s). Type 'DONE' to end.
125 def function (frame, bp_loc, internal_dict):
126  """frame: the lldb.SBFrame for the location at which you stopped
127  bp_loc: an lldb.SBBreakpointLocation for the breakpoint location information
128  internal_dict: an LLDB support object not to be used"""
129  print("Hit this breakpoint!")
130  DONE
131 
132 As a convenience, this also works for a short Python one-liner:
133 
134 (lldb) breakpoint command add -s python 1 -o 'import time; print(time.asctime())'
135 (lldb) run
136 Launching '.../a.out' (x86_64)
137 (lldb) Fri Sep 10 12:17:45 2010
138 Process 21778 Stopped
139 * thread #1: tid = 0x2e03, 0x0000000100000de8 a.out`c + 7 at main.c:39, stop reason = breakpoint 1.1, queue = com.apple.main-thread
140  36
141  37 int c(int val)
142  38 {
143  39 -> return val + 3;
144  40 }
145  41
146  42 int main (int argc, char const *argv[])
147 
148 Example multiple line Python breakpoint command:
149 
150 (lldb) breakpoint command add -s p 1
151 Enter your Python command(s). Type 'DONE' to end.
152 def function (frame, bp_loc, internal_dict):
153  """frame: the lldb.SBFrame for the location at which you stopped
154  bp_loc: an lldb.SBBreakpointLocation for the breakpoint location information
155  internal_dict: an LLDB support object not to be used"""
156  global bp_count
157  bp_count = bp_count + 1
158  print("Hit this breakpoint " + repr(bp_count) + " times!")
159  DONE
160 
161 )"
162  "In this case, since there is a reference to a global variable, \
163 'bp_count', you will also need to make sure 'bp_count' exists and is \
164 initialized:"
165  R"(
166 
167 (lldb) script
168 >>> bp_count = 0
169 >>> quit()
170 
171 )"
172  "Your Python code, however organized, can optionally return a value. \
173 If the returned value is False, that tells LLDB not to stop at the breakpoint \
174 to which the code is associated. Returning anything other than False, or even \
175 returning None, or even omitting a return statement entirely, will cause \
176 LLDB to stop."
177  R"(
178 
179 )"
180  "Final Note: A warning that no breakpoint command was generated when there \
181 are no syntax errors may indicate that a function was declared but never called.");
182 
183  m_all_options.Append(&m_options);
184  m_all_options.Append(&m_func_options, LLDB_OPT_SET_2 | LLDB_OPT_SET_3,
186  m_all_options.Finalize();
187 
189  CommandArgumentData bp_id_arg;
190 
191  // Define the first (and only) variant of this arg.
192  bp_id_arg.arg_type = eArgTypeBreakpointID;
194 
195  // There is only one variant this argument could be; put it into the
196  // argument entry.
197  arg.push_back(bp_id_arg);
198 
199  // Push the data for the first argument into the m_arguments vector.
200  m_arguments.push_back(arg);
201  }
202 
203  ~CommandObjectBreakpointCommandAdd() override = default;
204 
205  Options *GetOptions() override { return &m_all_options; }
206 
207  void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
208  StreamFileSP output_sp(io_handler.GetOutputStreamFileSP());
209  if (output_sp && interactive) {
210  output_sp->PutCString(g_reader_instructions);
211  output_sp->Flush();
212  }
213  }
214 
215  void IOHandlerInputComplete(IOHandler &io_handler,
216  std::string &line) override {
217  io_handler.SetIsDone(true);
218 
219  std::vector<std::reference_wrapper<BreakpointOptions>> *bp_options_vec =
220  (std::vector<std::reference_wrapper<BreakpointOptions>> *)
221  io_handler.GetUserData();
222  for (BreakpointOptions &bp_options : *bp_options_vec) {
223  auto cmd_data = std::make_unique<BreakpointOptions::CommandData>();
224  cmd_data->user_source.SplitIntoLines(line.c_str(), line.size());
225  bp_options.SetCommandDataCallback(cmd_data);
226  }
227  }
228 
229  void CollectDataForBreakpointCommandCallback(
230  std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
231  CommandReturnObject &result) {
232  m_interpreter.GetLLDBCommandsFromIOHandler(
233  "> ", // Prompt
234  *this, // IOHandlerDelegate
235  &bp_options_vec); // Baton for the "io_handler" that will be passed back
236  // into our IOHandlerDelegate functions
237  }
238 
239  /// Set a one-liner as the callback for the breakpoint.
240  void SetBreakpointCommandCallback(
241  std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
242  const char *oneliner) {
243  for (BreakpointOptions &bp_options : bp_options_vec) {
244  auto cmd_data = std::make_unique<BreakpointOptions::CommandData>();
245 
246  cmd_data->user_source.AppendString(oneliner);
247  cmd_data->stop_on_error = m_options.m_stop_on_error;
248 
249  bp_options.SetCommandDataCallback(cmd_data);
250  }
251  }
252 
253  class CommandOptions : public OptionGroup {
254  public:
255  CommandOptions() = default;
256 
257  ~CommandOptions() override = default;
258 
259  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
260  ExecutionContext *execution_context) override {
261  Status error;
262  const int short_option =
263  g_breakpoint_command_add_options[option_idx].short_option;
264 
265  switch (short_option) {
266  case 'o':
267  m_use_one_liner = true;
268  m_one_liner = std::string(option_arg);
269  break;
270 
271  case 's':
272  m_script_language = (lldb::ScriptLanguage)OptionArgParser::ToOptionEnum(
273  option_arg,
274  g_breakpoint_command_add_options[option_idx].enum_values,
276  switch (m_script_language) {
278  case eScriptLanguageLua:
279  m_use_script_language = true;
280  break;
281  case eScriptLanguageNone:
283  m_use_script_language = false;
284  break;
285  }
286  break;
287 
288  case 'e': {
289  bool success = false;
290  m_stop_on_error =
291  OptionArgParser::ToBoolean(option_arg, false, &success);
292  if (!success)
293  error.SetErrorStringWithFormat(
294  "invalid value for stop-on-error: \"%s\"",
295  option_arg.str().c_str());
296  } break;
297 
298  case 'D':
299  m_use_dummy = true;
300  break;
301 
302  default:
303  llvm_unreachable("Unimplemented option");
304  }
305  return error;
306  }
307 
308  void OptionParsingStarting(ExecutionContext *execution_context) override {
309  m_use_commands = true;
310  m_use_script_language = false;
311  m_script_language = eScriptLanguageNone;
312 
313  m_use_one_liner = false;
314  m_stop_on_error = true;
315  m_one_liner.clear();
316  m_use_dummy = false;
317  }
318 
319  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
320  return llvm::makeArrayRef(g_breakpoint_command_add_options);
321  }
322 
323  // Instance variables to hold the values for command options.
324 
325  bool m_use_commands = false;
326  bool m_use_script_language = false;
327  lldb::ScriptLanguage m_script_language = eScriptLanguageNone;
328 
329  // Instance variables to hold the values for one_liner options.
330  bool m_use_one_liner = false;
331  std::string m_one_liner;
332  bool m_stop_on_error;
333  bool m_use_dummy;
334  };
335 
336 protected:
337  bool DoExecute(Args &command, CommandReturnObject &result) override {
338  Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
339 
340  const BreakpointList &breakpoints = target.GetBreakpointList();
341  size_t num_breakpoints = breakpoints.GetSize();
342 
343  if (num_breakpoints == 0) {
344  result.AppendError("No breakpoints exist to have commands added");
345  return false;
346  }
347 
348  if (!m_func_options.GetName().empty()) {
349  m_options.m_use_one_liner = false;
350  if (!m_options.m_use_script_language) {
351  m_options.m_script_language = GetDebugger().GetScriptLanguage();
352  m_options.m_use_script_language = true;
353  }
354  }
355 
356  BreakpointIDList valid_bp_ids;
357  CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
358  command, &target, result, &valid_bp_ids,
359  BreakpointName::Permissions::PermissionKinds::listPerm);
360 
361  m_bp_options_vec.clear();
362 
363  if (result.Succeeded()) {
364  const size_t count = valid_bp_ids.GetSize();
365 
366  for (size_t i = 0; i < count; ++i) {
367  BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
368  if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
369  Breakpoint *bp =
370  target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
371  if (cur_bp_id.GetLocationID() == LLDB_INVALID_BREAK_ID) {
372  // This breakpoint does not have an associated location.
373  m_bp_options_vec.push_back(bp->GetOptions());
374  } else {
375  BreakpointLocationSP bp_loc_sp(
376  bp->FindLocationByID(cur_bp_id.GetLocationID()));
377  // This breakpoint does have an associated location. Get its
378  // breakpoint options.
379  if (bp_loc_sp)
380  m_bp_options_vec.push_back(bp_loc_sp->GetLocationOptions());
381  }
382  }
383  }
384 
385  // If we are using script language, get the script interpreter in order
386  // to set or collect command callback. Otherwise, call the methods
387  // associated with this object.
388  if (m_options.m_use_script_language) {
389  Status error;
390  ScriptInterpreter *script_interp = GetDebugger().GetScriptInterpreter(
391  /*can_create=*/true, m_options.m_script_language);
392  // Special handling for one-liner specified inline.
393  if (m_options.m_use_one_liner) {
394  error = script_interp->SetBreakpointCommandCallback(
395  m_bp_options_vec, m_options.m_one_liner.c_str());
396  } else if (!m_func_options.GetName().empty()) {
398  m_bp_options_vec, m_func_options.GetName().c_str(),
399  m_func_options.GetStructuredData());
400  } else {
402  m_bp_options_vec, result);
403  }
404  if (!error.Success())
405  result.SetError(error);
406  } else {
407  // Special handling for one-liner specified inline.
408  if (m_options.m_use_one_liner)
409  SetBreakpointCommandCallback(m_bp_options_vec,
410  m_options.m_one_liner.c_str());
411  else
412  CollectDataForBreakpointCommandCallback(m_bp_options_vec, result);
413  }
414  }
415 
416  return result.Succeeded();
417  }
418 
419 private:
420  CommandOptions m_options;
421  OptionGroupPythonClassWithDict m_func_options;
422  OptionGroupOptions m_all_options;
423 
424  std::vector<std::reference_wrapper<BreakpointOptions>>
425  m_bp_options_vec; // This stores the
426  // breakpoint options that
427  // we are currently
428  // collecting commands for. In the CollectData... calls we need to hand this
429  // off to the IOHandler, which may run asynchronously. So we have to have
430  // some way to keep it alive, and not leak it. Making it an ivar of the
431  // command object, which never goes away achieves this. Note that if we were
432  // able to run the same command concurrently in one interpreter we'd have to
433  // make this "per invocation". But there are many more reasons why it is not
434  // in general safe to do that in lldb at present, so it isn't worthwhile to
435  // come up with a more complex mechanism to address this particular weakness
436  // right now.
437  static const char *g_reader_instructions;
438 };
439 
441  "Enter your debugger command(s). Type 'DONE' to end.\n";
442 
443 // CommandObjectBreakpointCommandDelete
444 
445 #define LLDB_OPTIONS_breakpoint_command_delete
446 #include "CommandOptions.inc"
447 
449 public:
451  : CommandObjectParsed(interpreter, "delete",
452  "Delete the set of commands from a breakpoint.",
453  nullptr) {
455  CommandArgumentData bp_id_arg;
456 
457  // Define the first (and only) variant of this arg.
458  bp_id_arg.arg_type = eArgTypeBreakpointID;
459  bp_id_arg.arg_repetition = eArgRepeatPlain;
460 
461  // There is only one variant this argument could be; put it into the
462  // argument entry.
463  arg.push_back(bp_id_arg);
464 
465  // Push the data for the first argument into the m_arguments vector.
466  m_arguments.push_back(arg);
467  }
468 
469  ~CommandObjectBreakpointCommandDelete() override = default;
470 
471  Options *GetOptions() override { return &m_options; }
472 
473  class CommandOptions : public Options {
474  public:
475  CommandOptions() = default;
476 
477  ~CommandOptions() override = default;
478 
479  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
480  ExecutionContext *execution_context) override {
481  Status error;
482  const int short_option = m_getopt_table[option_idx].val;
483 
484  switch (short_option) {
485  case 'D':
486  m_use_dummy = true;
487  break;
488 
489  default:
490  llvm_unreachable("Unimplemented option");
491  }
492 
493  return error;
494  }
495 
496  void OptionParsingStarting(ExecutionContext *execution_context) override {
497  m_use_dummy = false;
498  }
499 
500  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
501  return llvm::makeArrayRef(g_breakpoint_command_delete_options);
502  }
503 
504  // Instance variables to hold the values for command options.
505  bool m_use_dummy = false;
506  };
507 
508 protected:
509  bool DoExecute(Args &command, CommandReturnObject &result) override {
510  Target &target = GetSelectedOrDummyTarget(m_options.m_use_dummy);
511 
512  const BreakpointList &breakpoints = target.GetBreakpointList();
513  size_t num_breakpoints = breakpoints.GetSize();
514 
515  if (num_breakpoints == 0) {
516  result.AppendError("No breakpoints exist to have commands deleted");
517  return false;
518  }
519 
520  if (command.empty()) {
521  result.AppendError(
522  "No breakpoint specified from which to delete the commands");
523  return false;
524  }
525 
526  BreakpointIDList valid_bp_ids;
527  CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
528  command, &target, result, &valid_bp_ids,
529  BreakpointName::Permissions::PermissionKinds::listPerm);
530 
531  if (result.Succeeded()) {
532  const size_t count = valid_bp_ids.GetSize();
533  for (size_t i = 0; i < count; ++i) {
534  BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
535  if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
536  Breakpoint *bp =
537  target.GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
538  if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
539  BreakpointLocationSP bp_loc_sp(
540  bp->FindLocationByID(cur_bp_id.GetLocationID()));
541  if (bp_loc_sp)
542  bp_loc_sp->ClearCallback();
543  else {
544  result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n",
545  cur_bp_id.GetBreakpointID(),
546  cur_bp_id.GetLocationID());
547  return false;
548  }
549  } else {
550  bp->ClearCallback();
551  }
552  }
553  }
554  }
555  return result.Succeeded();
556  }
557 
558 private:
560 };
561 
562 // CommandObjectBreakpointCommandList
563 
565 public:
567  : CommandObjectParsed(interpreter, "list",
568  "List the script or set of commands to be "
569  "executed when the breakpoint is hit.",
570  nullptr, eCommandRequiresTarget) {
572  CommandArgumentData bp_id_arg;
573 
574  // Define the first (and only) variant of this arg.
575  bp_id_arg.arg_type = eArgTypeBreakpointID;
576  bp_id_arg.arg_repetition = eArgRepeatPlain;
577 
578  // There is only one variant this argument could be; put it into the
579  // argument entry.
580  arg.push_back(bp_id_arg);
581 
582  // Push the data for the first argument into the m_arguments vector.
583  m_arguments.push_back(arg);
584  }
585 
586  ~CommandObjectBreakpointCommandList() override = default;
587 
588 protected:
589  bool DoExecute(Args &command, CommandReturnObject &result) override {
590  Target *target = &GetSelectedTarget();
591 
592  const BreakpointList &breakpoints = target->GetBreakpointList();
593  size_t num_breakpoints = breakpoints.GetSize();
594 
595  if (num_breakpoints == 0) {
596  result.AppendError("No breakpoints exist for which to list commands");
597  return false;
598  }
599 
600  if (command.empty()) {
601  result.AppendError(
602  "No breakpoint specified for which to list the commands");
603  return false;
604  }
605 
606  BreakpointIDList valid_bp_ids;
607  CommandObjectMultiwordBreakpoint::VerifyBreakpointOrLocationIDs(
608  command, target, result, &valid_bp_ids,
609  BreakpointName::Permissions::PermissionKinds::listPerm);
610 
611  if (result.Succeeded()) {
612  const size_t count = valid_bp_ids.GetSize();
613  for (size_t i = 0; i < count; ++i) {
614  BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex(i);
615  if (cur_bp_id.GetBreakpointID() != LLDB_INVALID_BREAK_ID) {
616  Breakpoint *bp =
617  target->GetBreakpointByID(cur_bp_id.GetBreakpointID()).get();
618 
619  if (bp) {
620  BreakpointLocationSP bp_loc_sp;
621  if (cur_bp_id.GetLocationID() != LLDB_INVALID_BREAK_ID) {
622  bp_loc_sp = bp->FindLocationByID(cur_bp_id.GetLocationID());
623  if (!bp_loc_sp) {
624  result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n",
625  cur_bp_id.GetBreakpointID(),
626  cur_bp_id.GetLocationID());
627  return false;
628  }
629  }
630 
631  StreamString id_str;
632  BreakpointID::GetCanonicalReference(&id_str,
633  cur_bp_id.GetBreakpointID(),
634  cur_bp_id.GetLocationID());
635  const Baton *baton = nullptr;
636  if (bp_loc_sp)
637  baton =
638  bp_loc_sp
639  ->GetOptionsSpecifyingKind(BreakpointOptions::eCallback)
640  .GetBaton();
641  else
642  baton = bp->GetOptions().GetBaton();
643 
644  if (baton) {
645  result.GetOutputStream().Printf("Breakpoint %s:\n",
646  id_str.GetData());
647  baton->GetDescription(result.GetOutputStream().AsRawOstream(),
649  result.GetOutputStream().GetIndentLevel() +
650  2);
651  } else {
653  "Breakpoint %s does not have an associated command.\n",
654  id_str.GetData());
655  }
656  }
658  } else {
659  result.AppendErrorWithFormat("Invalid breakpoint ID: %u.\n",
660  cur_bp_id.GetBreakpointID());
661  }
662  }
663  }
664 
665  return result.Succeeded();
666  }
667 };
668 
669 // CommandObjectBreakpointCommand
670 
671 CommandObjectBreakpointCommand::CommandObjectBreakpointCommand(
672  CommandInterpreter &interpreter)
674  interpreter, "command",
675  "Commands for adding, removing and listing "
676  "LLDB commands executed when a breakpoint is "
677  "hit.",
678  "command <sub-command> [<sub-command-options>] <breakpoint-id>") {
679  CommandObjectSP add_command_object(
680  new CommandObjectBreakpointCommandAdd(interpreter));
681  CommandObjectSP delete_command_object(
682  new CommandObjectBreakpointCommandDelete(interpreter));
683  CommandObjectSP list_command_object(
684  new CommandObjectBreakpointCommandList(interpreter));
685 
686  add_command_object->SetCommandName("breakpoint command add");
687  delete_command_object->SetCommandName("breakpoint command delete");
688  list_command_object->SetCommandName("breakpoint command list");
689 
690  LoadSubCommand("add", add_command_object);
691  LoadSubCommand("delete", delete_command_object);
692  LoadSubCommand("list", list_command_object);
693 }
694 
lldb_private::Breakpoint::GetOptions
BreakpointOptions & GetOptions()
Returns the BreakpointOptions structure set at the breakpoint level.
Definition: Breakpoint.cpp:438
lldb_private::eArgRepeatOptional
@ eArgRepeatOptional
Definition: lldb-private-enumerations.h:96
lldb_private::CommandObjectParsed
Definition: CommandObject.h:389
lldb_private::ScriptInterpreter::SetBreakpointCommandCallback
Status SetBreakpointCommandCallback(std::vector< std::reference_wrapper< BreakpointOptions >> &bp_options_vec, const char *callback_text)
Set the specified text as the callback for the breakpoint.
Definition: ScriptInterpreter.cpp:109
lldb_private::OptionGroupPythonClassWithDict
Definition: OptionGroupPythonClassWithDict.h:25
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb::ScriptLanguage
ScriptLanguage
Script interpreter types.
Definition: lldb-enumerations.h:216
lldb_private::BreakpointList
General Outline: Allows adding and removing breakpoints and find by ID and index.
Definition: BreakpointList.h:25
CommandObjectBreakpointCommand.h
lldb_private::eArgRepeatPlain
@ eArgRepeatPlain
Definition: lldb-private-enumerations.h:95
CommandObjectBreakpointCommandDelete::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectBreakpointCommand.cpp:500
lldb_private::CommandReturnObject::SetError
void SetError(const Status &error, const char *fallback_error_cstr=nullptr)
Definition: CommandReturnObject.cpp:107
IOHandler.h
lldb_private::BreakpointOptions::GetBaton
Baton * GetBaton()
Fetch the baton from the callback.
Definition: BreakpointOptions.cpp:431
CommandObjectBreakpointCommandAdd::CommandObjectBreakpointCommandAdd
CommandObjectBreakpointCommandAdd(CommandInterpreter &interpreter)
Definition: CommandObjectBreakpointCommand.cpp:32
lldb_private::OptionGroupOptions
Definition: Options.h:255
BreakpointLocation.h
lldb_private::CommandObject::CommandArgumentData
Used to build individual command argument lists.
Definition: CommandObject.h:91
lldb_private::OptionGroup
Definition: Options.h:233
OptionArgParser.h
lldb_private::ScriptInterpreter::SetBreakpointCommandCallbackFunction
Status SetBreakpointCommandCallbackFunction(std::vector< std::reference_wrapper< BreakpointOptions >> &bp_options_vec, const char *function_name, StructuredData::ObjectSP extra_args_sp)
Definition: ScriptInterpreter.cpp:121
lldb_private::CommandObject::CommandArgumentData::arg_repetition
ArgumentRepetitionType arg_repetition
Definition: CommandObject.h:93
CommandObjectBreakpointCommandList::CommandObjectBreakpointCommandList
CommandObjectBreakpointCommandList(CommandInterpreter &interpreter)
Definition: CommandObjectBreakpointCommand.cpp:566
CommandObjectBreakpoint.h
lldb_private::Args
Definition: Args.h:33
lldb_private::CommandReturnObject::Succeeded
bool Succeeded() const
Definition: CommandReturnObject.cpp:131
lldb_private::Target::GetBreakpointList
BreakpointList & GetBreakpointList(bool internal=false)
Definition: Target.cpp:308
CommandObjectBreakpointCommandList::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectBreakpointCommand.cpp:589
CommandObjectBreakpointCommandList
Definition: CommandObjectBreakpointCommand.cpp:564
CommandReturnObject.h
lldb_private::Baton::GetDescription
virtual void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level, unsigned indentation) const =0
lldb_private::Target
Definition: Target.h:467
CommandObjectBreakpointCommandDelete::m_options
CommandOptions m_options
Definition: CommandObjectBreakpointCommand.cpp:559
lldb::eScriptLanguageNone
@ eScriptLanguageNone
Definition: lldb-enumerations.h:217
lldb_private::IOHandlerDelegate::Completion
Completion
Definition: IOHandler.h:197
Target.h
CommandObjectBreakpointCommandDelete::GetOptions
Options * GetOptions() override
Definition: CommandObjectBreakpointCommand.cpp:471
lldb_private::CommandObjectMultiword
Definition: CommandObjectMultiword.h:19
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::Options
Definition: Options.h:57
CommandObjectBreakpointCommandDelete::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectBreakpointCommand.cpp:479
OptionGroupPythonClassWithDict.h
lldb_private::CommandObjectMultiword::LoadSubCommand
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
Definition: CommandObjectMultiword.cpp:80
CommandObjectBreakpointCommandAdd
Definition: CommandObjectBreakpointCommand.cpp:29
lldb_private::CommandReturnObject::SetStatus
void SetStatus(lldb::ReturnStatus status)
Definition: CommandReturnObject.cpp:127
lldb::eArgTypeBreakpointID
@ eArgTypeBreakpointID
Definition: lldb-enumerations.h:522
LLDB_OPT_SET_3
#define LLDB_OPT_SET_3
Definition: lldb-defines.h:103
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
lldb_private::CommandObjectBreakpointCommand::~CommandObjectBreakpointCommand
~CommandObjectBreakpointCommand() override
lldb_private::CommandReturnObject::GetOutputStream
Stream & GetOutputStream()
Definition: CommandReturnObject.h:46
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::BreakpointOptions
Definition: BreakpointOptions.h:27
lldb_private::BreakpointID::GetBreakpointID
lldb::break_id_t GetBreakpointID() const
Definition: BreakpointID.h:29
lldb_private::IOHandler
Definition: IOHandler.h:46
lldb::eDescriptionLevelFull
@ eDescriptionLevelFull
Definition: lldb-enumerations.h:209
lldb::eScriptLanguagePython
@ eScriptLanguagePython
Definition: lldb-enumerations.h:218
CommandObjectBreakpointCommandDelete::CommandOptions
Definition: CommandObjectBreakpointCommand.cpp:473
CommandObjectBreakpointCommandAdd::g_reader_instructions
static const char * g_reader_instructions
Definition: CommandObjectBreakpointCommand.cpp:348
CommandObjectBreakpointCommandDelete::CommandObjectBreakpointCommandDelete
CommandObjectBreakpointCommandDelete(CommandInterpreter &interpreter)
Definition: CommandObjectBreakpointCommand.cpp:450
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
CommandObjectBreakpointCommandDelete::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectBreakpointCommand.cpp:509
lldb_private::Stream::GetIndentLevel
unsigned GetIndentLevel() const
Get the current indentation level.
Definition: Stream.cpp:160
lldb::eScriptLanguageUnknown
@ eScriptLanguageUnknown
Definition: lldb-enumerations.h:220
lldb_private::CommandObject::CommandArgumentData::arg_type
lldb::CommandArgumentType arg_type
Definition: CommandObject.h:92
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_BREAK_ID
Definition: lldb-defines.h:37
lldb_private::Status
Definition: Status.h:44
lldb_private::Breakpoint::ClearCallback
void ClearCallback()
Definition: Breakpoint.cpp:431
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:26
BreakpointIDList.h
uint32_t
lldb::eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishResult
Definition: lldb-enumerations.h:261
lldb_private::BreakpointID
Definition: BreakpointID.h:22
lldb_private::CommandReturnObject::AppendMessageWithFormat
void AppendMessageWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:64
lldb_private::Stream::AsRawOstream
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:357
lldb_private::IOHandler::GetUserData
void * GetUserData()
Definition: IOHandler.h:139
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:126
lldb_private::BreakpointList::GetSize
size_t GetSize() const
Returns the number of elements in this breakpoint list.
Definition: BreakpointList.h:79
lldb_private::IOHandler::SetIsDone
void SetIsDone(bool b)
Definition: IOHandler.h:90
lldb_private::Baton
Definition: Baton.h:35
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::CommandReturnObject::AppendErrorWithFormat
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:46
lldb_private::IOHandlerDelegate
A delegate class for use with IOHandler subclasses.
Definition: IOHandler.h:195
OptionParser.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
Breakpoint.h
CommandObjectBreakpointCommandDelete
Definition: CommandObjectBreakpointCommand.cpp:448
CommandInterpreter.h
lldb_private::Args::empty
bool empty() const
Definition: Args.h:120
lldb_private::BreakpointIDList::GetSize
size_t GetSize() const
Definition: BreakpointIDList.cpp:28
CommandOptionArgumentTable.h
lldb::eScriptLanguageLua
@ eScriptLanguageLua
Definition: lldb-enumerations.h:219
lldb_private::BreakpointIDList::GetBreakpointIDAtIndex
const BreakpointID & GetBreakpointIDAtIndex(size_t index) const
Definition: BreakpointIDList.cpp:31
lldb_private::Target::GetBreakpointByID
lldb::BreakpointSP GetBreakpointByID(lldb::break_id_t break_id)
Definition: Target.cpp:322
lldb_private::CommandObject::CommandArgumentEntry
std::vector< CommandArgumentData > CommandArgumentEntry
Definition: CommandObject.h:106
lldb_private::CommandReturnObject::AppendError
void void AppendError(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:100
lldb_private::BreakpointID::GetLocationID
lldb::break_id_t GetLocationID() const
Definition: BreakpointID.h:31
LLDB_OPT_SET_2
#define LLDB_OPT_SET_2
Definition: lldb-defines.h:102
lldb
Definition: SBAddress.h:15
lldb_private::IOHandler::GetOutputStreamFileSP
lldb::StreamFileSP GetOutputStreamFileSP()
Definition: IOHandler.cpp:109
lldb_private::BreakpointIDList
Definition: BreakpointIDList.h:25
lldb_private::Breakpoint::FindLocationByID
lldb::BreakpointLocationSP FindLocationByID(lldb::break_id_t bp_loc_id)
Find a breakpoint location for a given breakpoint location ID.
Definition: Breakpoint.cpp:275
lldb_private::IOHandlerDelegateMultiline
Definition: IOHandler.h:300
CommandObjectBreakpointCommandDelete::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectBreakpointCommand.cpp:496
lldb_private::Breakpoint
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:80
lldb_private::ScriptInterpreter::CollectDataForBreakpointCommandCallback
virtual void CollectDataForBreakpointCommandCallback(std::vector< std::reference_wrapper< BreakpointOptions >> &options, CommandReturnObject &result)
Definition: ScriptInterpreter.cpp:36