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