LLDB  mainline
CommandObjectWatchpoint.cpp
Go to the documentation of this file.
1 //===-- CommandObjectWatchpoint.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 
11 
12 #include <vector>
13 
14 #include "llvm/ADT/StringRef.h"
15 
18 #include "lldb/Core/ValueObject.h"
19 #include "lldb/Host/OptionParser.h"
22 #include "lldb/Symbol/Variable.h"
24 #include "lldb/Target/StackFrame.h"
25 #include "lldb/Target/Target.h"
27 
28 using namespace lldb;
29 using namespace lldb_private;
30 
32  lldb::DescriptionLevel level) {
33  s->IndentMore();
34  wp->GetDescription(s, level);
35  s->IndentLess();
36  s->EOL();
37 }
38 
40  CommandReturnObject &result) {
41  bool process_is_valid =
42  target->GetProcessSP() && target->GetProcessSP()->IsAlive();
43  if (!process_is_valid) {
44  result.AppendError("There's no process or it is not alive.");
46  return false;
47  }
48  // Target passes our checks, return true.
49  return true;
50 }
51 
52 // Equivalent class: {"-", "to", "To", "TO"} of range specifier array.
53 static const char *RSA[4] = {"-", "to", "To", "TO"};
54 
55 // Return the index to RSA if found; otherwise -1 is returned.
56 static int32_t WithRSAIndex(llvm::StringRef Arg) {
57 
58  uint32_t i;
59  for (i = 0; i < 4; ++i)
60  if (Arg.find(RSA[i]) != llvm::StringRef::npos)
61  return i;
62  return -1;
63 }
64 
65 // Return true if wp_ids is successfully populated with the watch ids. False
66 // otherwise.
67 bool CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
68  Target *target, Args &args, std::vector<uint32_t> &wp_ids) {
69  // Pre-condition: args.GetArgumentCount() > 0.
70  if (args.GetArgumentCount() == 0) {
71  if (target == nullptr)
72  return false;
73  WatchpointSP watch_sp = target->GetLastCreatedWatchpoint();
74  if (watch_sp) {
75  wp_ids.push_back(watch_sp->GetID());
76  return true;
77  } else
78  return false;
79  }
80 
81  llvm::StringRef Minus("-");
82  std::vector<llvm::StringRef> StrRefArgs;
83  llvm::StringRef first;
84  llvm::StringRef second;
85  size_t i;
86  int32_t idx;
87  // Go through the arguments and make a canonical form of arg list containing
88  // only numbers with possible "-" in between.
89  for (auto &entry : args.entries()) {
90  if ((idx = WithRSAIndex(entry.ref())) == -1) {
91  StrRefArgs.push_back(entry.ref());
92  continue;
93  }
94  // The Arg contains the range specifier, split it, then.
95  std::tie(first, second) = entry.ref().split(RSA[idx]);
96  if (!first.empty())
97  StrRefArgs.push_back(first);
98  StrRefArgs.push_back(Minus);
99  if (!second.empty())
100  StrRefArgs.push_back(second);
101  }
102  // Now process the canonical list and fill in the vector of uint32_t's. If
103  // there is any error, return false and the client should ignore wp_ids.
104  uint32_t beg, end, id;
105  size_t size = StrRefArgs.size();
106  bool in_range = false;
107  for (i = 0; i < size; ++i) {
108  llvm::StringRef Arg = StrRefArgs[i];
109  if (in_range) {
110  // Look for the 'end' of the range. Note StringRef::getAsInteger()
111  // returns true to signify error while parsing.
112  if (Arg.getAsInteger(0, end))
113  return false;
114  // Found a range! Now append the elements.
115  for (id = beg; id <= end; ++id)
116  wp_ids.push_back(id);
117  in_range = false;
118  continue;
119  }
120  if (i < (size - 1) && StrRefArgs[i + 1] == Minus) {
121  if (Arg.getAsInteger(0, beg))
122  return false;
123  // Turn on the in_range flag, we are looking for end of range next.
124  ++i;
125  in_range = true;
126  continue;
127  }
128  // Otherwise, we have a simple ID. Just append it.
129  if (Arg.getAsInteger(0, beg))
130  return false;
131  wp_ids.push_back(beg);
132  }
133 
134  // It is an error if after the loop, we're still in_range.
135  return !in_range;
136 }
137 
138 // CommandObjectWatchpointList
139 
140 // CommandObjectWatchpointList::Options
141 #pragma mark List::CommandOptions
142 #define LLDB_OPTIONS_watchpoint_list
143 #include "CommandOptions.inc"
144 
145 #pragma mark List
146 
148 public:
151  interpreter, "watchpoint list",
152  "List all watchpoints at configurable levels of detail.", nullptr,
153  eCommandRequiresTarget),
154  m_options() {
156  CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID,
158  // Add the entry for the first argument for this command to the object's
159  // arguments vector.
160  m_arguments.push_back(arg);
161  }
162 
163  ~CommandObjectWatchpointList() override = default;
164 
165  Options *GetOptions() override { return &m_options; }
166 
167  class CommandOptions : public Options {
168  public:
170  : Options(),
171  m_level(lldb::eDescriptionLevelBrief) // Watchpoint List defaults to
172  // brief descriptions
173  {}
174 
175  ~CommandOptions() override = default;
176 
177  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
178  ExecutionContext *execution_context) override {
179  Status error;
180  const int short_option = m_getopt_table[option_idx].val;
181 
182  switch (short_option) {
183  case 'b':
185  break;
186  case 'f':
187  m_level = lldb::eDescriptionLevelFull;
188  break;
189  case 'v':
191  break;
192  default:
193  llvm_unreachable("Unimplemented option");
194  }
195 
196  return error;
197  }
198 
199  void OptionParsingStarting(ExecutionContext *execution_context) override {
200  m_level = lldb::eDescriptionLevelFull;
201  }
202 
203  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
204  return llvm::makeArrayRef(g_watchpoint_list_options);
205  }
206 
207  // Instance variables to hold the values for command options.
208 
210  };
211 
212 protected:
213  bool DoExecute(Args &command, CommandReturnObject &result) override {
214  Target *target = &GetSelectedTarget();
215 
216  if (target->GetProcessSP() && target->GetProcessSP()->IsAlive()) {
217  uint32_t num_supported_hardware_watchpoints;
218  Status error = target->GetProcessSP()->GetWatchpointSupportInfo(
219  num_supported_hardware_watchpoints);
220  if (error.Success())
222  "Number of supported hardware watchpoints: %u\n",
223  num_supported_hardware_watchpoints);
224  }
225 
226  const WatchpointList &watchpoints = target->GetWatchpointList();
227 
228  std::unique_lock<std::recursive_mutex> lock;
229  target->GetWatchpointList().GetListMutex(lock);
230 
231  size_t num_watchpoints = watchpoints.GetSize();
232 
233  if (num_watchpoints == 0) {
234  result.AppendMessage("No watchpoints currently set.");
236  return true;
237  }
238 
239  Stream &output_stream = result.GetOutputStream();
240 
241  if (command.GetArgumentCount() == 0) {
242  // No watchpoint selected; show info about all currently set watchpoints.
243  result.AppendMessage("Current watchpoints:");
244  for (size_t i = 0; i < num_watchpoints; ++i) {
245  Watchpoint *wp = watchpoints.GetByIndex(i).get();
246  AddWatchpointDescription(&output_stream, wp, m_options.m_level);
247  }
249  } else {
250  // Particular watchpoints selected; enable them.
251  std::vector<uint32_t> wp_ids;
252  if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
253  target, command, wp_ids)) {
254  result.AppendError("Invalid watchpoints specification.");
256  return false;
257  }
258 
259  const size_t size = wp_ids.size();
260  for (size_t i = 0; i < size; ++i) {
261  Watchpoint *wp = watchpoints.FindByID(wp_ids[i]).get();
262  if (wp)
263  AddWatchpointDescription(&output_stream, wp, m_options.m_level);
265  }
266  }
267 
268  return result.Succeeded();
269  }
270 
271 private:
273 };
274 
275 // CommandObjectWatchpointEnable
276 #pragma mark Enable
277 
279 public:
281  : CommandObjectParsed(interpreter, "enable",
282  "Enable the specified disabled watchpoint(s). If "
283  "no watchpoints are specified, enable all of them.",
284  nullptr, eCommandRequiresTarget) {
286  CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID,
288  // Add the entry for the first argument for this command to the object's
289  // arguments vector.
290  m_arguments.push_back(arg);
291  }
292 
293  ~CommandObjectWatchpointEnable() override = default;
294 
295  void
297  OptionElementVector &opt_element_vector) override {
298  CommandCompletions::InvokeCommonCompletionCallbacks(
299  GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
300  request, nullptr);
301  }
302 
303 protected:
304  bool DoExecute(Args &command, CommandReturnObject &result) override {
305  Target *target = &GetSelectedTarget();
306  if (!CheckTargetForWatchpointOperations(target, result))
307  return false;
308 
309  std::unique_lock<std::recursive_mutex> lock;
310  target->GetWatchpointList().GetListMutex(lock);
311 
312  const WatchpointList &watchpoints = target->GetWatchpointList();
313 
314  size_t num_watchpoints = watchpoints.GetSize();
315 
316  if (num_watchpoints == 0) {
317  result.AppendError("No watchpoints exist to be enabled.");
319  return false;
320  }
321 
322  if (command.GetArgumentCount() == 0) {
323  // No watchpoint selected; enable all currently set watchpoints.
324  target->EnableAllWatchpoints();
325  result.AppendMessageWithFormat("All watchpoints enabled. (%" PRIu64
326  " watchpoints)\n",
327  (uint64_t)num_watchpoints);
329  } else {
330  // Particular watchpoints selected; enable them.
331  std::vector<uint32_t> wp_ids;
332  if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
333  target, command, wp_ids)) {
334  result.AppendError("Invalid watchpoints specification.");
336  return false;
337  }
338 
339  int count = 0;
340  const size_t size = wp_ids.size();
341  for (size_t i = 0; i < size; ++i)
342  if (target->EnableWatchpointByID(wp_ids[i]))
343  ++count;
344  result.AppendMessageWithFormat("%d watchpoints enabled.\n", count);
346  }
347 
348  return result.Succeeded();
349  }
350 };
351 
352 // CommandObjectWatchpointDisable
353 #pragma mark Disable
354 
356 public:
358  : CommandObjectParsed(interpreter, "watchpoint disable",
359  "Disable the specified watchpoint(s) without "
360  "removing it/them. If no watchpoints are "
361  "specified, disable them all.",
362  nullptr, eCommandRequiresTarget) {
364  CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID,
366  // Add the entry for the first argument for this command to the object's
367  // arguments vector.
368  m_arguments.push_back(arg);
369  }
370 
371  ~CommandObjectWatchpointDisable() override = default;
372 
373  void
375  OptionElementVector &opt_element_vector) override {
376  CommandCompletions::InvokeCommonCompletionCallbacks(
377  GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
378  request, nullptr);
379  }
380 
381 protected:
382  bool DoExecute(Args &command, CommandReturnObject &result) override {
383  Target *target = &GetSelectedTarget();
384  if (!CheckTargetForWatchpointOperations(target, result))
385  return false;
386 
387  std::unique_lock<std::recursive_mutex> lock;
388  target->GetWatchpointList().GetListMutex(lock);
389 
390  const WatchpointList &watchpoints = target->GetWatchpointList();
391  size_t num_watchpoints = watchpoints.GetSize();
392 
393  if (num_watchpoints == 0) {
394  result.AppendError("No watchpoints exist to be disabled.");
396  return false;
397  }
398 
399  if (command.GetArgumentCount() == 0) {
400  // No watchpoint selected; disable all currently set watchpoints.
401  if (target->DisableAllWatchpoints()) {
402  result.AppendMessageWithFormat("All watchpoints disabled. (%" PRIu64
403  " watchpoints)\n",
404  (uint64_t)num_watchpoints);
406  } else {
407  result.AppendError("Disable all watchpoints failed\n");
409  }
410  } else {
411  // Particular watchpoints selected; disable them.
412  std::vector<uint32_t> wp_ids;
413  if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
414  target, command, wp_ids)) {
415  result.AppendError("Invalid watchpoints specification.");
417  return false;
418  }
419 
420  int count = 0;
421  const size_t size = wp_ids.size();
422  for (size_t i = 0; i < size; ++i)
423  if (target->DisableWatchpointByID(wp_ids[i]))
424  ++count;
425  result.AppendMessageWithFormat("%d watchpoints disabled.\n", count);
427  }
428 
429  return result.Succeeded();
430  }
431 };
432 
433 // CommandObjectWatchpointDelete
434 #define LLDB_OPTIONS_watchpoint_delete
435 #include "CommandOptions.inc"
436 
437 // CommandObjectWatchpointDelete
438 #pragma mark Delete
439 
441 public:
443  : CommandObjectParsed(interpreter, "watchpoint delete",
444  "Delete the specified watchpoint(s). If no "
445  "watchpoints are specified, delete them all.",
446  nullptr, eCommandRequiresTarget),
447  m_options() {
449  CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID,
451  // Add the entry for the first argument for this command to the object's
452  // arguments vector.
453  m_arguments.push_back(arg);
454  }
455 
456  ~CommandObjectWatchpointDelete() override = default;
457 
458  void
460  OptionElementVector &opt_element_vector) override {
461  CommandCompletions::InvokeCommonCompletionCallbacks(
462  GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
463  request, nullptr);
464  }
465 
466  Options *GetOptions() override { return &m_options; }
467 
468  class CommandOptions : public Options {
469  public:
470  CommandOptions() : Options(), m_force(false) {}
471 
472  ~CommandOptions() override = default;
473 
474  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
475  ExecutionContext *execution_context) override {
476  const int short_option = m_getopt_table[option_idx].val;
477 
478  switch (short_option) {
479  case 'f':
480  m_force = true;
481  break;
482  default:
483  llvm_unreachable("Unimplemented option");
484  }
485 
486  return {};
487  }
488 
489  void OptionParsingStarting(ExecutionContext *execution_context) override {
490  m_force = false;
491  }
492 
493  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
494  return llvm::makeArrayRef(g_watchpoint_delete_options);
495  }
496 
497  // Instance variables to hold the values for command options.
498  bool m_force;
499  };
500 
501 protected:
502  bool DoExecute(Args &command, CommandReturnObject &result) override {
503  Target *target = &GetSelectedTarget();
504  if (!CheckTargetForWatchpointOperations(target, result))
505  return false;
506 
507  std::unique_lock<std::recursive_mutex> lock;
508  target->GetWatchpointList().GetListMutex(lock);
509 
510  const WatchpointList &watchpoints = target->GetWatchpointList();
511 
512  size_t num_watchpoints = watchpoints.GetSize();
513 
514  if (num_watchpoints == 0) {
515  result.AppendError("No watchpoints exist to be deleted.");
517  return false;
518  }
519 
520  if (command.empty()) {
521  if (!m_options.m_force &&
522  !m_interpreter.Confirm(
523  "About to delete all watchpoints, do you want to do that?",
524  true)) {
525  result.AppendMessage("Operation cancelled...");
526  } else {
527  target->RemoveAllWatchpoints();
528  result.AppendMessageWithFormat("All watchpoints removed. (%" PRIu64
529  " watchpoints)\n",
530  (uint64_t)num_watchpoints);
531  }
533  return result.Succeeded();
534  }
535 
536  // Particular watchpoints selected; delete them.
537  std::vector<uint32_t> wp_ids;
538  if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command,
539  wp_ids)) {
540  result.AppendError("Invalid watchpoints specification.");
542  return false;
543  }
544 
545  int count = 0;
546  const size_t size = wp_ids.size();
547  for (size_t i = 0; i < size; ++i)
548  if (target->RemoveWatchpointByID(wp_ids[i]))
549  ++count;
550  result.AppendMessageWithFormat("%d watchpoints deleted.\n", count);
552 
553  return result.Succeeded();
554  }
555 
556 private:
558 };
559 
560 // CommandObjectWatchpointIgnore
561 
562 #pragma mark Ignore::CommandOptions
563 #define LLDB_OPTIONS_watchpoint_ignore
564 #include "CommandOptions.inc"
565 
567 public:
569  : CommandObjectParsed(interpreter, "watchpoint ignore",
570  "Set ignore count on the specified watchpoint(s). "
571  "If no watchpoints are specified, set them all.",
572  nullptr, eCommandRequiresTarget),
573  m_options() {
575  CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID,
577  // Add the entry for the first argument for this command to the object's
578  // arguments vector.
579  m_arguments.push_back(arg);
580  }
581 
582  ~CommandObjectWatchpointIgnore() override = default;
583 
584  void
586  OptionElementVector &opt_element_vector) override {
587  CommandCompletions::InvokeCommonCompletionCallbacks(
588  GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
589  request, nullptr);
590  }
591 
592  Options *GetOptions() override { return &m_options; }
593 
594  class CommandOptions : public Options {
595  public:
596  CommandOptions() : Options(), m_ignore_count(0) {}
597 
598  ~CommandOptions() override = default;
599 
600  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
601  ExecutionContext *execution_context) override {
602  Status error;
603  const int short_option = m_getopt_table[option_idx].val;
604 
605  switch (short_option) {
606  case 'i':
607  if (option_arg.getAsInteger(0, m_ignore_count))
608  error.SetErrorStringWithFormat("invalid ignore count '%s'",
609  option_arg.str().c_str());
610  break;
611  default:
612  llvm_unreachable("Unimplemented option");
613  }
614 
615  return error;
616  }
617 
618  void OptionParsingStarting(ExecutionContext *execution_context) override {
619  m_ignore_count = 0;
620  }
621 
622  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
623  return llvm::makeArrayRef(g_watchpoint_ignore_options);
624  }
625 
626  // Instance variables to hold the values for command options.
627 
629  };
630 
631 protected:
632  bool DoExecute(Args &command, CommandReturnObject &result) override {
633  Target *target = &GetSelectedTarget();
634  if (!CheckTargetForWatchpointOperations(target, result))
635  return false;
636 
637  std::unique_lock<std::recursive_mutex> lock;
638  target->GetWatchpointList().GetListMutex(lock);
639 
640  const WatchpointList &watchpoints = target->GetWatchpointList();
641 
642  size_t num_watchpoints = watchpoints.GetSize();
643 
644  if (num_watchpoints == 0) {
645  result.AppendError("No watchpoints exist to be ignored.");
647  return false;
648  }
649 
650  if (command.GetArgumentCount() == 0) {
651  target->IgnoreAllWatchpoints(m_options.m_ignore_count);
652  result.AppendMessageWithFormat("All watchpoints ignored. (%" PRIu64
653  " watchpoints)\n",
654  (uint64_t)num_watchpoints);
656  } else {
657  // Particular watchpoints selected; ignore them.
658  std::vector<uint32_t> wp_ids;
659  if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
660  target, command, wp_ids)) {
661  result.AppendError("Invalid watchpoints specification.");
663  return false;
664  }
665 
666  int count = 0;
667  const size_t size = wp_ids.size();
668  for (size_t i = 0; i < size; ++i)
669  if (target->IgnoreWatchpointByID(wp_ids[i], m_options.m_ignore_count))
670  ++count;
671  result.AppendMessageWithFormat("%d watchpoints ignored.\n", count);
673  }
674 
675  return result.Succeeded();
676  }
677 
678 private:
680 };
681 
682 // CommandObjectWatchpointModify
683 
684 #pragma mark Modify::CommandOptions
685 #define LLDB_OPTIONS_watchpoint_modify
686 #include "CommandOptions.inc"
687 
688 #pragma mark Modify
689 
691 public:
694  interpreter, "watchpoint modify",
695  "Modify the options on a watchpoint or set of watchpoints in the "
696  "executable. "
697  "If no watchpoint is specified, act on the last created "
698  "watchpoint. "
699  "Passing an empty argument clears the modification.",
700  nullptr, eCommandRequiresTarget),
701  m_options() {
703  CommandObject::AddIDsArgumentData(arg, eArgTypeWatchpointID,
705  // Add the entry for the first argument for this command to the object's
706  // arguments vector.
707  m_arguments.push_back(arg);
708  }
709 
710  ~CommandObjectWatchpointModify() override = default;
711 
712  void
714  OptionElementVector &opt_element_vector) override {
715  CommandCompletions::InvokeCommonCompletionCallbacks(
716  GetCommandInterpreter(), CommandCompletions::eWatchPointIDCompletion,
717  request, nullptr);
718  }
719 
720  Options *GetOptions() override { return &m_options; }
721 
722  class CommandOptions : public Options {
723  public:
724  CommandOptions() : Options(), m_condition(), m_condition_passed(false) {}
725 
726  ~CommandOptions() override = default;
727 
728  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
729  ExecutionContext *execution_context) override {
730  Status error;
731  const int short_option = m_getopt_table[option_idx].val;
732 
733  switch (short_option) {
734  case 'c':
735  m_condition = std::string(option_arg);
736  m_condition_passed = true;
737  break;
738  default:
739  llvm_unreachable("Unimplemented option");
740  }
741 
742  return error;
743  }
744 
745  void OptionParsingStarting(ExecutionContext *execution_context) override {
746  m_condition.clear();
747  m_condition_passed = false;
748  }
749 
750  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
751  return llvm::makeArrayRef(g_watchpoint_modify_options);
752  }
753 
754  // Instance variables to hold the values for command options.
755 
758  };
759 
760 protected:
761  bool DoExecute(Args &command, CommandReturnObject &result) override {
762  Target *target = &GetSelectedTarget();
763  if (!CheckTargetForWatchpointOperations(target, result))
764  return false;
765 
766  std::unique_lock<std::recursive_mutex> lock;
767  target->GetWatchpointList().GetListMutex(lock);
768 
769  const WatchpointList &watchpoints = target->GetWatchpointList();
770 
771  size_t num_watchpoints = watchpoints.GetSize();
772 
773  if (num_watchpoints == 0) {
774  result.AppendError("No watchpoints exist to be modified.");
776  return false;
777  }
778 
779  if (command.GetArgumentCount() == 0) {
780  WatchpointSP wp_sp = target->GetLastCreatedWatchpoint();
781  wp_sp->SetCondition(m_options.m_condition.c_str());
783  } else {
784  // Particular watchpoints selected; set condition on them.
785  std::vector<uint32_t> wp_ids;
786  if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
787  target, command, wp_ids)) {
788  result.AppendError("Invalid watchpoints specification.");
790  return false;
791  }
792 
793  int count = 0;
794  const size_t size = wp_ids.size();
795  for (size_t i = 0; i < size; ++i) {
796  WatchpointSP wp_sp = watchpoints.FindByID(wp_ids[i]);
797  if (wp_sp) {
798  wp_sp->SetCondition(m_options.m_condition.c_str());
799  ++count;
800  }
801  }
802  result.AppendMessageWithFormat("%d watchpoints modified.\n", count);
804  }
805 
806  return result.Succeeded();
807  }
808 
809 private:
811 };
812 
813 // CommandObjectWatchpointSetVariable
814 #pragma mark SetVariable
815 
817 public:
820  interpreter, "watchpoint set variable",
821  "Set a watchpoint on a variable. "
822  "Use the '-w' option to specify the type of watchpoint and "
823  "the '-s' option to specify the byte size to watch for. "
824  "If no '-w' option is specified, it defaults to write. "
825  "If no '-s' option is specified, it defaults to the variable's "
826  "byte size. "
827  "Note that there are limited hardware resources for watchpoints. "
828  "If watchpoint setting fails, consider disable/delete existing "
829  "ones "
830  "to free up resources.",
831  nullptr,
832  eCommandRequiresFrame | eCommandTryTargetAPILock |
833  eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
834  m_option_group(), m_option_watchpoint() {
835  SetHelpLong(
836  R"(
837 Examples:
838 
839 (lldb) watchpoint set variable -w read_write my_global_var
840 
841 )"
842  " Watches my_global_var for read/write access, with the region to watch \
843 corresponding to the byte size of the data type.");
844 
846  CommandArgumentData var_name_arg;
847 
848  // Define the only variant of this arg.
849  var_name_arg.arg_type = eArgTypeVarName;
850  var_name_arg.arg_repetition = eArgRepeatPlain;
851 
852  // Push the variant into the argument entry.
853  arg.push_back(var_name_arg);
854 
855  // Push the data for the only argument into the m_arguments vector.
856  m_arguments.push_back(arg);
857 
858  // Absorb the '-w' and '-s' options into our option group.
859  m_option_group.Append(&m_option_watchpoint, LLDB_OPT_SET_ALL,
861  m_option_group.Finalize();
862  }
863 
864  ~CommandObjectWatchpointSetVariable() override = default;
865 
866  void
867  HandleArgumentCompletion(CompletionRequest &request,
868  OptionElementVector &opt_element_vector) override {
869  if (request.GetCursorIndex() != 0)
870  return;
871  CommandCompletions::InvokeCommonCompletionCallbacks(
872  GetCommandInterpreter(), CommandCompletions::eVariablePathCompletion,
873  request, nullptr);
874  }
875 
876  Options *GetOptions() override { return &m_option_group; }
877 
878 protected:
879  static size_t GetVariableCallback(void *baton, const char *name,
880  VariableList &variable_list) {
881  size_t old_size = variable_list.GetSize();
882  Target *target = static_cast<Target *>(baton);
883  if (target)
885  variable_list);
886  return variable_list.GetSize() - old_size;
887  }
888 
889  bool DoExecute(Args &command, CommandReturnObject &result) override {
890  Target *target = GetDebugger().GetSelectedTarget().get();
891  StackFrame *frame = m_exe_ctx.GetFramePtr();
892 
893  // If no argument is present, issue an error message. There's no way to
894  // set a watchpoint.
895  if (command.GetArgumentCount() <= 0) {
896  result.GetErrorStream().Printf("error: required argument missing; "
897  "specify your program variable to watch "
898  "for\n");
900  return false;
901  }
902 
903  // If no '-w' is specified, default to '-w write'.
904  if (!m_option_watchpoint.watch_type_specified) {
905  m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchWrite;
906  }
907 
908  // We passed the sanity check for the command. Proceed to set the
909  // watchpoint now.
910  lldb::addr_t addr = 0;
911  size_t size = 0;
912 
913  VariableSP var_sp;
914  ValueObjectSP valobj_sp;
915  Stream &output_stream = result.GetOutputStream();
916 
917  // A simple watch variable gesture allows only one argument.
918  if (command.GetArgumentCount() != 1) {
919  result.GetErrorStream().Printf(
920  "error: specify exactly one variable to watch for\n");
922  return false;
923  }
924 
925  // Things have checked out ok...
926  Status error;
927  uint32_t expr_path_options =
928  StackFrame::eExpressionPathOptionCheckPtrVsMember |
929  StackFrame::eExpressionPathOptionsAllowDirectIVarAccess;
930  valobj_sp = frame->GetValueForVariableExpressionPath(
931  command.GetArgumentAtIndex(0), eNoDynamicValues, expr_path_options,
932  var_sp, error);
933 
934  if (!valobj_sp) {
935  // Not in the frame; let's check the globals.
936 
937  VariableList variable_list;
938  ValueObjectList valobj_list;
939 
940  Status error(Variable::GetValuesForVariableExpressionPath(
941  command.GetArgumentAtIndex(0),
942  m_exe_ctx.GetBestExecutionContextScope(), GetVariableCallback, target,
943  variable_list, valobj_list));
944 
945  if (valobj_list.GetSize())
946  valobj_sp = valobj_list.GetValueObjectAtIndex(0);
947  }
948 
949  CompilerType compiler_type;
950 
951  if (valobj_sp) {
952  AddressType addr_type;
953  addr = valobj_sp->GetAddressOf(false, &addr_type);
954  if (addr_type == eAddressTypeLoad) {
955  // We're in business.
956  // Find out the size of this variable.
957  size = m_option_watchpoint.watch_size == 0
958  ? valobj_sp->GetByteSize().getValueOr(0)
959  : m_option_watchpoint.watch_size;
960  }
961  compiler_type = valobj_sp->GetCompilerType();
962  } else {
963  const char *error_cstr = error.AsCString(nullptr);
964  if (error_cstr)
965  result.GetErrorStream().Printf("error: %s\n", error_cstr);
966  else
967  result.GetErrorStream().Printf("error: unable to find any variable "
968  "expression path that matches '%s'\n",
969  command.GetArgumentAtIndex(0));
970  return false;
971  }
972 
973  // Now it's time to create the watchpoint.
974  uint32_t watch_type = m_option_watchpoint.watch_type;
975 
976  error.Clear();
977  Watchpoint *wp =
978  target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error)
979  .get();
980  if (wp) {
981  wp->SetWatchSpec(command.GetArgumentAtIndex(0));
982  wp->SetWatchVariable(true);
983  if (var_sp && var_sp->GetDeclaration().GetFile()) {
984  StreamString ss;
985  // True to show fullpath for declaration file.
986  var_sp->GetDeclaration().DumpStopContext(&ss, true);
987  wp->SetDeclInfo(std::string(ss.GetString()));
988  }
989  output_stream.Printf("Watchpoint created: ");
990  wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
991  output_stream.EOL();
993  } else {
994  result.AppendErrorWithFormat(
995  "Watchpoint creation failed (addr=0x%" PRIx64 ", size=%" PRIu64
996  ", variable expression='%s').\n",
997  addr, (uint64_t)size, command.GetArgumentAtIndex(0));
998  if (error.AsCString(nullptr))
999  result.AppendError(error.AsCString());
1001  }
1003  return result.Succeeded();
1004  }
1005 
1006 private:
1007  OptionGroupOptions m_option_group;
1008  OptionGroupWatchpoint m_option_watchpoint;
1009 };
1010 
1011 // CommandObjectWatchpointSetExpression
1012 #pragma mark Set
1013 
1015 public:
1017  : CommandObjectRaw(
1018  interpreter, "watchpoint set expression",
1019  "Set a watchpoint on an address by supplying an expression. "
1020  "Use the '-w' option to specify the type of watchpoint and "
1021  "the '-s' option to specify the byte size to watch for. "
1022  "If no '-w' option is specified, it defaults to write. "
1023  "If no '-s' option is specified, it defaults to the target's "
1024  "pointer byte size. "
1025  "Note that there are limited hardware resources for watchpoints. "
1026  "If watchpoint setting fails, consider disable/delete existing "
1027  "ones "
1028  "to free up resources.",
1029  "",
1030  eCommandRequiresFrame | eCommandTryTargetAPILock |
1031  eCommandProcessMustBeLaunched | eCommandProcessMustBePaused),
1032  m_option_group(), m_option_watchpoint() {
1033  SetHelpLong(
1034  R"(
1035 Examples:
1036 
1037 (lldb) watchpoint set expression -w write -s 1 -- foo + 32
1038 
1039  Watches write access for the 1-byte region pointed to by the address 'foo + 32')");
1040 
1042  CommandArgumentData expression_arg;
1043 
1044  // Define the only variant of this arg.
1045  expression_arg.arg_type = eArgTypeExpression;
1046  expression_arg.arg_repetition = eArgRepeatPlain;
1047 
1048  // Push the only variant into the argument entry.
1049  arg.push_back(expression_arg);
1050 
1051  // Push the data for the only argument into the m_arguments vector.
1052  m_arguments.push_back(arg);
1053 
1054  // Absorb the '-w' and '-s' options into our option group.
1055  m_option_group.Append(&m_option_watchpoint, LLDB_OPT_SET_ALL,
1056  LLDB_OPT_SET_1);
1057  m_option_group.Finalize();
1058  }
1060  ~CommandObjectWatchpointSetExpression() override = default;
1062  // Overrides base class's behavior where WantsCompletion =
1063  // !WantsRawCommandString.
1064  bool WantsCompletion() override { return true; }
1065 
1066  Options *GetOptions() override { return &m_option_group; }
1067 
1068 protected:
1069  bool DoExecute(llvm::StringRef raw_command,
1070  CommandReturnObject &result) override {
1071  auto exe_ctx = GetCommandInterpreter().GetExecutionContext();
1072  m_option_group.NotifyOptionParsingStarting(
1073  &exe_ctx); // This is a raw command, so notify the option group
1074 
1075  Target *target = GetDebugger().GetSelectedTarget().get();
1076  StackFrame *frame = m_exe_ctx.GetFramePtr();
1077 
1078  OptionsWithRaw args(raw_command);
1079 
1080  llvm::StringRef expr = args.GetRawPart();
1081 
1082  if (args.HasArgs())
1083  if (!ParseOptionsAndNotify(args.GetArgs(), result, m_option_group,
1084  exe_ctx))
1085  return false;
1086 
1087  // If no argument is present, issue an error message. There's no way to
1088  // set a watchpoint.
1089  if (raw_command.trim().empty()) {
1090  result.GetErrorStream().Printf("error: required argument missing; "
1091  "specify an expression to evaluate into "
1092  "the address to watch for\n");
1094  return false;
1095  }
1096 
1097  // If no '-w' is specified, default to '-w write'.
1098  if (!m_option_watchpoint.watch_type_specified) {
1099  m_option_watchpoint.watch_type = OptionGroupWatchpoint::eWatchWrite;
1100  }
1101 
1102  // We passed the sanity check for the command. Proceed to set the
1103  // watchpoint now.
1104  lldb::addr_t addr = 0;
1105  size_t size = 0;
1106 
1107  ValueObjectSP valobj_sp;
1108 
1109  // Use expression evaluation to arrive at the address to watch.
1110  EvaluateExpressionOptions options;
1111  options.SetCoerceToId(false);
1112  options.SetUnwindOnError(true);
1113  options.SetKeepInMemory(false);
1114  options.SetTryAllThreads(true);
1115  options.SetTimeout(llvm::None);
1116 
1117  ExpressionResults expr_result =
1118  target->EvaluateExpression(expr, frame, valobj_sp, options);
1119  if (expr_result != eExpressionCompleted) {
1120  result.GetErrorStream().Printf(
1121  "error: expression evaluation of address to watch failed\n");
1122  result.GetErrorStream() << "expression evaluated: \n" << expr << "\n";
1123  if (valobj_sp && !valobj_sp->GetError().Success())
1124  result.GetErrorStream() << valobj_sp->GetError().AsCString() << "\n";
1126  return false;
1127  }
1128 
1129  // Get the address to watch.
1130  bool success = false;
1131  addr = valobj_sp->GetValueAsUnsigned(0, &success);
1132  if (!success) {
1133  result.GetErrorStream().Printf(
1134  "error: expression did not evaluate to an address\n");
1136  return false;
1137  }
1138 
1139  if (m_option_watchpoint.watch_size != 0)
1140  size = m_option_watchpoint.watch_size;
1141  else
1142  size = target->GetArchitecture().GetAddressByteSize();
1143 
1144  // Now it's time to create the watchpoint.
1145  uint32_t watch_type = m_option_watchpoint.watch_type;
1146 
1147  // Fetch the type from the value object, the type of the watched object is
1148  // the pointee type
1149  /// of the expression, so convert to that if we found a valid type.
1150  CompilerType compiler_type(valobj_sp->GetCompilerType());
1151 
1152  Status error;
1153  Watchpoint *wp =
1154  target->CreateWatchpoint(addr, size, &compiler_type, watch_type, error)
1155  .get();
1156  if (wp) {
1157  Stream &output_stream = result.GetOutputStream();
1158  output_stream.Printf("Watchpoint created: ");
1159  wp->GetDescription(&output_stream, lldb::eDescriptionLevelFull);
1160  output_stream.EOL();
1162  } else {
1163  result.AppendErrorWithFormat("Watchpoint creation failed (addr=0x%" PRIx64
1164  ", size=%" PRIu64 ").\n",
1165  addr, (uint64_t)size);
1166  if (error.AsCString(nullptr))
1167  result.AppendError(error.AsCString());
1169  }
1171  return result.Succeeded();
1172  }
1173 
1174 private:
1175  OptionGroupOptions m_option_group;
1176  OptionGroupWatchpoint m_option_watchpoint;
1177 };
1178 
1179 // CommandObjectWatchpointSet
1180 #pragma mark Set
1181 
1183 public:
1186  interpreter, "watchpoint set", "Commands for setting a watchpoint.",
1187  "watchpoint set <subcommand> [<subcommand-options>]") {
1188 
1189  LoadSubCommand(
1190  "variable",
1191  CommandObjectSP(new CommandObjectWatchpointSetVariable(interpreter)));
1192  LoadSubCommand(
1193  "expression",
1194  CommandObjectSP(new CommandObjectWatchpointSetExpression(interpreter)));
1195  }
1196 
1197  ~CommandObjectWatchpointSet() override = default;
1198 };
1199 
1200 // CommandObjectMultiwordWatchpoint
1201 #pragma mark MultiwordWatchpoint
1202 
1203 CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint(
1204  CommandInterpreter &interpreter)
1205  : CommandObjectMultiword(interpreter, "watchpoint",
1206  "Commands for operating on watchpoints.",
1207  "watchpoint <subcommand> [<command-options>]") {
1208  CommandObjectSP list_command_object(
1209  new CommandObjectWatchpointList(interpreter));
1210  CommandObjectSP enable_command_object(
1211  new CommandObjectWatchpointEnable(interpreter));
1212  CommandObjectSP disable_command_object(
1213  new CommandObjectWatchpointDisable(interpreter));
1214  CommandObjectSP delete_command_object(
1215  new CommandObjectWatchpointDelete(interpreter));
1216  CommandObjectSP ignore_command_object(
1217  new CommandObjectWatchpointIgnore(interpreter));
1218  CommandObjectSP command_command_object(
1219  new CommandObjectWatchpointCommand(interpreter));
1220  CommandObjectSP modify_command_object(
1221  new CommandObjectWatchpointModify(interpreter));
1222  CommandObjectSP set_command_object(
1223  new CommandObjectWatchpointSet(interpreter));
1224 
1225  list_command_object->SetCommandName("watchpoint list");
1226  enable_command_object->SetCommandName("watchpoint enable");
1227  disable_command_object->SetCommandName("watchpoint disable");
1228  delete_command_object->SetCommandName("watchpoint delete");
1229  ignore_command_object->SetCommandName("watchpoint ignore");
1230  command_command_object->SetCommandName("watchpoint command");
1231  modify_command_object->SetCommandName("watchpoint modify");
1232  set_command_object->SetCommandName("watchpoint set");
1233 
1234  LoadSubCommand("list", list_command_object);
1235  LoadSubCommand("enable", enable_command_object);
1236  LoadSubCommand("disable", disable_command_object);
1237  LoadSubCommand("delete", delete_command_object);
1238  LoadSubCommand("ignore", ignore_command_object);
1239  LoadSubCommand("command", command_command_object);
1240  LoadSubCommand("modify", modify_command_object);
1241  LoadSubCommand("set", set_command_object);
1242 }
1243 
CommandObjectWatchpointDelete
Definition: CommandObjectWatchpoint.cpp:440
lldb_private::Stream::IndentLess
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition: Stream.cpp:171
lldb_private::CommandObjectParsed
Definition: CommandObject.h:378
lldb_private::OptionGroupWatchpoint
Definition: OptionGroupWatchpoint.h:18
lldb_private::ValueObjectList
A collection of ValueObject values that.
Definition: ValueObjectList.h:23
CommandObjectWatchpointList::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectWatchpoint.cpp:199
lldb_private::ExecutionContext
Definition: ExecutionContext.h:291
CommandObjectWatchpointDelete::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectWatchpoint.cpp:474
lldb_private::eArgRepeatPlain
@ eArgRepeatPlain
Definition: lldb-private-enumerations.h:95
CommandObjectWatchpointList::CommandOptions::m_level
lldb::DescriptionLevel m_level
Definition: CommandObjectWatchpoint.cpp:209
lldb_private::EvaluateExpressionOptions::SetTimeout
void SetTimeout(const Timeout< std::micro > &timeout)
Definition: Target.h:323
CommandObjectWatchpoint.h
lldb::eNoDynamicValues
@ eNoDynamicValues
Definition: lldb-enumerations.h:495
lldb_private::Options::NotifyOptionParsingStarting
void NotifyOptionParsingStarting(ExecutionContext *execution_context)
Definition: Options.cpp:32
CommandObjectWatchpointIgnore::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectWatchpoint.cpp:632
WithRSAIndex
static int32_t WithRSAIndex(llvm::StringRef Arg)
Definition: CommandObjectWatchpoint.cpp:56
lldb_private::ValueObjectList::GetValueObjectAtIndex
lldb::ValueObjectSP GetValueObjectAtIndex(size_t idx)
Definition: ValueObjectList.cpp:39
lldb::ExpressionResults
ExpressionResults
The results of expression evaluation.
Definition: lldb-enumerations.h:270
CommandObjectWatchpointSetExpression
Definition: CommandObjectWatchpoint.cpp:1014
lldb::eArgTypeWatchpointIDRange
@ eArgTypeWatchpointIDRange
Definition: lldb-enumerations.h:598
CommandObjectWatchpointSet::CommandObjectWatchpointSet
CommandObjectWatchpointSet(CommandInterpreter &interpreter)
Definition: CommandObjectWatchpoint.cpp:1184
lldb_private::AddressType
AddressType
Definition: lldb-private-enumerations.h:30
AddWatchpointDescription
static void AddWatchpointDescription(Stream *s, Watchpoint *wp, lldb::DescriptionLevel level)
Definition: CommandObjectWatchpoint.cpp:31
CommandObjectWatchpointModify::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectWatchpoint.cpp:750
lldb_private::OptionGroupOptions
Definition: Options.h:255
CommandObjectWatchpointIgnore::CommandOptions
Definition: CommandObjectWatchpoint.cpp:594
CommandObjectWatchpointDisable::CommandObjectWatchpointDisable
CommandObjectWatchpointDisable(CommandInterpreter &interpreter)
Definition: CommandObjectWatchpoint.cpp:357
lldb_private::CommandObject::CommandArgumentData
Definition: CommandObject.h:89
lldb_private::EvaluateExpressionOptions
Definition: Target.h:255
lldb_private::VariableList::GetSize
size_t GetSize() const
Definition: VariableList.cpp:165
CommandObjectWatchpointModify::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectWatchpoint.cpp:728
lldb_private::Watchpoint::SetWatchSpec
void SetWatchSpec(const std::string &str)
Definition: Watchpoint.cpp:92
lldb::eArgTypeExpression
@ eArgTypeExpression
Definition: lldb-enumerations.h:533
CommandObjectWatchpointDelete::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectWatchpoint.cpp:470
lldb_private::CompilerType::GetByteSize
llvm::Optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
Definition: CompilerType.cpp:489
CommandObjectWatchpointModify
Definition: CommandObjectWatchpoint.cpp:690
CommandObjectWatchpointDisable::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectWatchpoint.cpp:382
StackFrame.h
CommandObjectWatchpointModify::CommandOptions
Definition: CommandObjectWatchpoint.cpp:722
lldb_private::CommandObject::CommandArgumentData::arg_repetition
ArgumentRepetitionType arg_repetition
Definition: CommandObject.h:92
CommandObjectWatchpointDelete::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectWatchpoint.cpp:489
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:112
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Target::GetWatchpointList
WatchpointList & GetWatchpointList()
Definition: Target.h:717
lldb_private::Args
Definition: Args.h:33
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
CommandReturnObject.h
CommandObjectWatchpointSet
Definition: CommandObjectWatchpoint.cpp:1182
lldb_private::Target
Definition: Target.h:447
CommandObjectWatchpointIgnore::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectWatchpoint.cpp:600
CommandObjectWatchpointModify::CommandOptions::m_condition
std::string m_condition
Definition: CommandObjectWatchpoint.cpp:756
lldb_private::Target::GetImages
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:921
lldb_private::VariableList
Definition: VariableList.h:18
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::ModuleList::FindGlobalVariables
void FindGlobalVariables(ConstString name, size_t max_matches, VariableList &variable_list) const
Find global and static variables by name.
Definition: ModuleList.cpp:444
CommandObjectWatchpointList::m_options
CommandOptions m_options
Definition: CommandObjectWatchpoint.cpp:272
lldb_private::Watchpoint::SetDeclInfo
void SetDeclInfo(const std::string &str)
Definition: Watchpoint.cpp:88
lldb::eReturnStatusSuccessFinishNoResult
@ eReturnStatusSuccessFinishNoResult
Definition: lldb-enumerations.h:260
CommandObjectWatchpointModify::GetOptions
Options * GetOptions() override
Definition: CommandObjectWatchpoint.cpp:720
CommandObjectWatchpointList::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectWatchpoint.cpp:213
lldb_private::Target::IgnoreWatchpointByID
bool IgnoreWatchpointByID(lldb::watch_id_t watch_id, uint32_t ignore_count)
Definition: Target.cpp:1337
Target.h
lldb::eArgTypeVarName
@ eArgTypeVarName
Definition: lldb-enumerations.h:592
CommandObjectWatchpointIgnore::GetOptions
Options * GetOptions() override
Definition: CommandObjectWatchpoint.cpp:592
RSA
static const char * RSA[4]
Definition: CommandObjectWatchpoint.cpp:53
lldb_private::CommandObjectMultiword
Definition: CommandObjectMultiword.h:19
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
CommandObjectWatchpointList::CommandObjectWatchpointList
CommandObjectWatchpointList(CommandInterpreter &interpreter)
Definition: CommandObjectWatchpoint.cpp:149
CommandObjectWatchpointDelete::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectWatchpoint.cpp:502
lldb_private::Options
Definition: Options.h:57
Watchpoint.h
lldb_private::CommandObjectMultiwordWatchpoint::~CommandObjectMultiwordWatchpoint
~CommandObjectMultiwordWatchpoint() override
lldb_private::Target::GetLastCreatedWatchpoint
lldb::WatchpointSP GetLastCreatedWatchpoint()
Definition: Target.h:713
CommandObjectWatchpointDelete::GetOptions
Options * GetOptions() override
Definition: CommandObjectWatchpoint.cpp:466
CommandObjectWatchpointEnable::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectWatchpoint.cpp:296
lldb_private::CommandObjectMultiword::LoadSubCommand
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
Definition: CommandObjectMultiword.cpp:68
lldb_private::ValueObjectList::GetSize
size_t GetSize() const
Definition: ValueObjectList.cpp:35
LLDB_OPT_SET_1
#define LLDB_OPT_SET_1
Definition: lldb-defines.h:112
lldb_private::CommandReturnObject::SetStatus
void SetStatus(lldb::ReturnStatus status)
Definition: CommandReturnObject.cpp:131
lldb_private::Watchpoint
Definition: Watchpoint.h:24
lldb::eExpressionCompleted
@ eExpressionCompleted
Definition: lldb-enumerations.h:271
StreamString.h
CommandObjectWatchpointDelete::CommandOptions
Definition: CommandObjectWatchpoint.cpp:468
lldb_private::CommandReturnObject::GetOutputStream
Stream & GetOutputStream()
Definition: CommandReturnObject.h:45
LLDB_OPT_SET_ALL
#define LLDB_OPT_SET_ALL
Definition: lldb-defines.h:111
lldb_private::WatchpointList::GetSize
size_t GetSize() const
Returns the number of elements in this watchpoint list.
Definition: WatchpointList.h:160
lldb_private::StackFrame::GetValueForVariableExpressionPath
lldb::ValueObjectSP GetValueForVariableExpressionPath(llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic, uint32_t options, lldb::VariableSP &var_sp, Status &error)
Create a ValueObject for a variable name / pathname, possibly including simple dereference/child sele...
Definition: StackFrame.cpp:494
lldb_private::ConstString
Definition: ConstString.h:40
CommandObjectWatchpointModify::CommandObjectWatchpointModify
CommandObjectWatchpointModify(CommandInterpreter &interpreter)
Definition: CommandObjectWatchpoint.cpp:692
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::Target::DisableAllWatchpoints
bool DisableAllWatchpoints(bool end_to_end=true)
Definition: Target.cpp:1174
lldb::eDescriptionLevelFull
@ eDescriptionLevelFull
Definition: lldb-enumerations.h:209
lldb_private::Args::entries
llvm::ArrayRef< ArgEntry > entries() const
Definition: Args.h:130
CommandObjectWatchpointEnable::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectWatchpoint.cpp:304
lldb_private::EvaluateExpressionOptions::SetTryAllThreads
void SetTryAllThreads(bool try_others=true)
Definition: Target.h:335
CommandObjectWatchpointSetExpression::CommandObjectWatchpointSetExpression
CommandObjectWatchpointSetExpression(CommandInterpreter &interpreter)
Definition: CommandObjectWatchpoint.cpp:1016
CommandObjectWatchpointDelete::CommandObjectWatchpointDelete
CommandObjectWatchpointDelete(CommandInterpreter &interpreter)
Definition: CommandObjectWatchpoint.cpp:442
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:221
lldb::eReturnStatusFailed
@ eReturnStatusFailed
Definition: lldb-enumerations.h:265
lldb_private::CommandObject::CommandArgumentData::arg_type
lldb::CommandArgumentType arg_type
Definition: CommandObject.h:91
lldb_private::OptionElementVector
std::vector< OptionArgElement > OptionElementVector
Definition: Options.h:42
lldb_private::CommandReturnObject::GetErrorStream
Stream & GetErrorStream()
Definition: CommandReturnObject.h:55
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:38
lldb_private::eAddressTypeLoad
@ eAddressTypeLoad
Address is an address as in the current target inferior process.
Definition: lldb-private-enumerations.h:34
lldb_private::EvaluateExpressionOptions::SetUnwindOnError
void SetUnwindOnError(bool unwind=false)
Definition: Target.h:302
CommandObjectWatchpointList::GetOptions
Options * GetOptions() override
Definition: CommandObjectWatchpoint.cpp:165
lldb_private::EvaluateExpressionOptions::SetKeepInMemory
void SetKeepInMemory(bool keep=true)
Definition: Target.h:312
lldb_private::Target::CreateWatchpoint
lldb::WatchpointSP CreateWatchpoint(lldb::addr_t addr, size_t size, const CompilerType *type, uint32_t kind, Status &error)
Definition: Target.cpp:791
CommandObjectWatchpointDelete::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectWatchpoint.cpp:459
CommandObjectWatchpointIgnore::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectWatchpoint.cpp:596
lldb_private::CommandObjectRaw
Definition: CommandObject.h:395
VariableList.h
CommandObjectWatchpointModify::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectWatchpoint.cpp:724
ValueObject.h
lldb_private::ArchSpec::GetAddressByteSize
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:683
CommandObjectWatchpointEnable
Definition: CommandObjectWatchpoint.cpp:278
CommandObjectWatchpointList::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectWatchpoint.cpp:203
CheckTargetForWatchpointOperations
static bool CheckTargetForWatchpointOperations(Target *target, CommandReturnObject &result)
Definition: CommandObjectWatchpoint.cpp:39
CommandObjectWatchpointList::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectWatchpoint.cpp:169
CommandObjectWatchpointSetVariable::CommandObjectWatchpointSetVariable
CommandObjectWatchpointSetVariable(CommandInterpreter &interpreter)
Definition: CommandObjectWatchpoint.cpp:818
CommandObjectWatchpointIgnore::m_options
CommandOptions m_options
Definition: CommandObjectWatchpoint.cpp:679
lldb_private::Target::GetProcessSP
const lldb::ProcessSP & GetProcessSP() const
Definition: Target.cpp:212
lldb_private::Target::DisableWatchpointByID
bool DisableWatchpointByID(lldb::watch_id_t watch_id)
Definition: Target.cpp:1283
CommandObjectWatchpointIgnore::CommandObjectWatchpointIgnore
CommandObjectWatchpointIgnore(CommandInterpreter &interpreter)
Definition: CommandObjectWatchpoint.cpp:568
CommandObjectWatchpointList
Definition: CommandObjectWatchpoint.cpp:147
CommandObjectWatchpointDelete::m_options
CommandOptions m_options
Definition: CommandObjectWatchpoint.cpp:557
lldb_private::Target::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Target.h:963
lldb_private::Status
Definition: Status.h:44
lldb_private::WatchpointList
Definition: WatchpointList.h:26
CommandObjectWatchpointEnable::CommandObjectWatchpointEnable
CommandObjectWatchpointEnable(CommandInterpreter &interpreter)
Definition: CommandObjectWatchpoint.cpp:280
lldb_private::Args::GetArgumentAtIndex
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
Definition: Args.cpp:259
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:25
uint32_t
lldb_private::EvaluateExpressionOptions::SetCoerceToId
void SetCoerceToId(bool coerce=true)
Definition: Target.h:298
lldb_private::Stream::IndentMore
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition: Stream.cpp:168
lldb::eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishResult
Definition: lldb-enumerations.h:261
CommandObjectWatchpointIgnore::CommandOptions::m_ignore_count
uint32_t m_ignore_count
Definition: CommandObjectWatchpoint.cpp:628
lldb::eArgTypeWatchpointID
@ eArgTypeWatchpointID
Definition: lldb-enumerations.h:597
lldb_private::Watchpoint::GetDescription
void GetDescription(Stream *s, lldb::DescriptionLevel level)
Definition: Watchpoint.cpp:146
id
void * id
Definition: PlatformiOSSimulatorCoreSimulatorSupport.h:20
lldb_private::Target::EvaluateExpression
lldb::ExpressionResults EvaluateExpression(llvm::StringRef expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, const EvaluateExpressionOptions &options=EvaluateExpressionOptions(), std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
Definition: Target.cpp:2397
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
lldb_private::CommandReturnObject::AppendMessageWithFormat
void AppendMessageWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:64
CommandObjectWatchpointDisable
Definition: CommandObjectWatchpoint.cpp:355
CommandObjectWatchpointModify::CommandOptions::m_condition_passed
bool m_condition_passed
Definition: CommandObjectWatchpoint.cpp:757
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
CommandObjectWatchpointIgnore::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectWatchpoint.cpp:622
lldb_private::Watchpoint::SetWatchVariable
void SetWatchVariable(bool val)
Definition: Watchpoint.cpp:103
lldb_private::OptionsWithRaw
Definition: Args.h:319
CommandObjectWatchpointDisable::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectWatchpoint.cpp:374
lldb_private::CommandReturnObject::Succeeded
bool Succeeded()
Definition: CommandReturnObject.cpp:135
CommandObjectWatchpointModify::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectWatchpoint.cpp:713
CommandObjectWatchpointList::CommandOptions
Definition: CommandObjectWatchpoint.cpp:167
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
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::Target::RemoveWatchpointByID
bool RemoveWatchpointByID(lldb::watch_id_t watch_id)
Definition: Target.cpp:1321
CommandObjectWatchpointCommand.h
lldb_private::CommandReturnObject::AppendErrorWithFormat
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:48
OptionParser.h
CommandObjectWatchpointModify::m_options
CommandOptions m_options
Definition: CommandObjectWatchpoint.cpp:810
lldb_private::CompletionRequest::GetCursorIndex
size_t GetCursorIndex() const
Definition: CompletionRequest.h:156
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::eDescriptionLevelVerbose
@ eDescriptionLevelVerbose
Definition: lldb-enumerations.h:210
CommandObjectWatchpointSetVariable
Definition: CommandObjectWatchpoint.cpp:816
CommandObjectWatchpointIgnore::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectWatchpoint.cpp:618
CommandObjectWatchpointDelete::CommandOptions::m_force
bool m_force
Definition: CommandObjectWatchpoint.cpp:498
CommandInterpreter.h
lldb_private::Args::empty
bool empty() const
Definition: Args.h:120
lldb_private::Target::IgnoreAllWatchpoints
bool IgnoreAllWatchpoints(uint32_t ignore_count)
Definition: Target.cpp:1264
CommandObjectWatchpointModify::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectWatchpoint.cpp:745
lldb_private::CommandObjectWatchpointCommand
Definition: CommandObjectWatchpointCommand.h:18
lldb_private::Target::EnableAllWatchpoints
bool EnableAllWatchpoints(bool end_to_end=true)
Definition: Target.cpp:1203
lldb_private::CommandObject::CommandArgumentEntry
std::vector< CommandArgumentData > CommandArgumentEntry
Definition: CommandObject.h:105
CommandObjectWatchpointIgnore::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectWatchpoint.cpp:585
Variable.h
WatchpointList.h
CommandObjectWatchpointDelete::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectWatchpoint.cpp:493
lldb_private::CommandReturnObject::AppendError
void void AppendError(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:100
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb_private::Args::GetArgumentCount
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:118
lldb_private::Target::EnableWatchpointByID
bool EnableWatchpointByID(lldb::watch_id_t watch_id)
Definition: Target.cpp:1302
lldb
Definition: SBAddress.h:15
lldb_private::WatchpointList::GetByIndex
lldb::WatchpointSP GetByIndex(uint32_t i)
Returns a shared pointer to the watchpoint with index i.
Definition: WatchpointList.cpp:138
lldb_private::WatchpointList::GetListMutex
void GetListMutex(std::unique_lock< std::recursive_mutex > &lock)
Sets the passed in Locker to hold the Watchpoint List mutex.
Definition: WatchpointList.cpp:249
CommandObjectWatchpointModify::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectWatchpoint.cpp:761
CommandObjectWatchpointList::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectWatchpoint.cpp:177
lldb_private::CommandReturnObject::AppendMessage
void AppendMessage(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:88
CommandObjectWatchpointIgnore
Definition: CommandObjectWatchpoint.cpp:566
lldb::eDescriptionLevelBrief
@ eDescriptionLevelBrief
Definition: lldb-enumerations.h:208
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
lldb_private::Target::RemoveAllWatchpoints
bool RemoveAllWatchpoints(bool end_to_end=true)
Definition: Target.cpp:1143