LLDB  mainline
CommandObjectType.cpp
Go to the documentation of this file.
1 //===-- CommandObjectType.cpp ---------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "CommandObjectType.h"
10 
11 #include "lldb/Core/Debugger.h"
12 #include "lldb/Core/IOHandler.h"
14 #include "lldb/Host/Config.h"
15 #include "lldb/Host/OptionParser.h"
26 #include "lldb/Symbol/Symbol.h"
27 #include "lldb/Target/Language.h"
28 #include "lldb/Target/StackFrame.h"
29 #include "lldb/Target/Target.h"
30 #include "lldb/Target/Thread.h"
34 
35 #include "llvm/ADT/STLExtras.h"
36 
37 #include <algorithm>
38 #include <functional>
39 #include <memory>
40 
41 #define CHECK_FORMATTER_KIND_MASK(VAL) \
42  ((m_formatter_kind_mask & (VAL)) == (VAL))
43 
44 using namespace lldb;
45 using namespace lldb_private;
46 
48 public:
51  bool m_regex;
54 
55  ScriptAddOptions(const TypeSummaryImpl::Flags &flags, bool regx,
56  ConstString name, std::string catg)
57  : m_flags(flags), m_regex(regx), m_name(name), m_category(catg) {}
58 
59  typedef std::shared_ptr<ScriptAddOptions> SharedPointer;
60 };
61 
63 public:
66  bool m_cascade;
67  bool m_regex;
70 
71  SynthAddOptions(bool sptr, bool sref, bool casc, bool regx, std::string catg)
72  : m_skip_pointers(sptr), m_skip_references(sref), m_cascade(casc),
73  m_regex(regx), m_category(catg) {}
74 
75  typedef std::shared_ptr<SynthAddOptions> SharedPointer;
76 };
77 
79  CommandReturnObject &result) {
80  if (command.empty())
81  return false;
82 
83  for (auto entry : llvm::enumerate(command.entries().drop_back())) {
84  if (entry.value().ref() != "unsigned")
85  continue;
86  auto next = command.entries()[entry.index() + 1].ref();
87  if (next == "int" || next == "short" || next == "char" || next == "long") {
89  "unsigned %s being treated as two types. if you meant the combined "
90  "type "
91  "name use quotes, as in \"unsigned %s\"\n",
92  next.str().c_str(), next.str().c_str());
93  return true;
94  }
95  }
96  return false;
97 }
98 
99 #define LLDB_OPTIONS_type_summary_add
100 #include "CommandOptions.inc"
101 
104 private:
105  class CommandOptions : public Options {
106  public:
108 
109  ~CommandOptions() override = default;
110 
111  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
112  ExecutionContext *execution_context) override;
113 
114  void OptionParsingStarting(ExecutionContext *execution_context) override;
115 
116  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
117  return llvm::makeArrayRef(g_type_summary_add_options);
118  }
119 
120  // Instance variables to hold the values for command options.
121 
123  bool m_regex = false;
128  bool m_is_add_script = false;
130  };
131 
133 
134  Options *GetOptions() override { return &m_options; }
135 
136  bool Execute_ScriptSummary(Args &command, CommandReturnObject &result);
137 
138  bool Execute_StringSummary(Args &command, CommandReturnObject &result);
139 
140 public:
141  enum SummaryFormatType { eRegularSummary, eRegexSummary, eNamedSummary };
142 
144 
145  ~CommandObjectTypeSummaryAdd() override = default;
146 
147  void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
148  static const char *g_summary_addreader_instructions =
149  "Enter your Python command(s). Type 'DONE' to end.\n"
150  "def function (valobj,internal_dict):\n"
151  " \"\"\"valobj: an SBValue which you want to provide a summary "
152  "for\n"
153  " internal_dict: an LLDB support object not to be used\"\"\"\n";
154 
155  StreamFileSP output_sp(io_handler.GetOutputStreamFileSP());
156  if (output_sp && interactive) {
157  output_sp->PutCString(g_summary_addreader_instructions);
158  output_sp->Flush();
159  }
160  }
161 
163  std::string &data) override {
164  StreamFileSP error_sp = io_handler.GetErrorStreamFileSP();
165 
166 #if LLDB_ENABLE_PYTHON
167  ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
168  if (interpreter) {
169  StringList lines;
170  lines.SplitIntoLines(data);
171  if (lines.GetSize() > 0) {
172  ScriptAddOptions *options_ptr =
173  ((ScriptAddOptions *)io_handler.GetUserData());
174  if (options_ptr) {
176  options_ptr); // this will ensure that we get rid of the pointer
177  // when going out of scope
178 
179  ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
180  if (interpreter) {
181  std::string funct_name_str;
182  if (interpreter->GenerateTypeScriptFunction(lines,
183  funct_name_str)) {
184  if (funct_name_str.empty()) {
185  error_sp->Printf("unable to obtain a valid function name from "
186  "the script interpreter.\n");
187  error_sp->Flush();
188  } else {
189  // now I have a valid function name, let's add this as script
190  // for every type in the list
191 
192  TypeSummaryImplSP script_format;
193  script_format = std::make_shared<ScriptSummaryFormat>(
194  options->m_flags, funct_name_str.c_str(),
195  lines.CopyList(" ").c_str());
196 
197  Status error;
198 
199  for (const std::string &type_name : options->m_target_types) {
201  ConstString(type_name), script_format,
202  (options->m_regex
205  options->m_category, &error);
206  if (error.Fail()) {
207  error_sp->Printf("error: %s", error.AsCString());
208  error_sp->Flush();
209  }
210  }
211 
212  if (options->m_name) {
214  options->m_name, script_format,
216  options->m_category, &error);
217  if (error.Fail()) {
219  options->m_name, script_format,
221  options->m_category, &error);
222  if (error.Fail()) {
223  error_sp->Printf("error: %s", error.AsCString());
224  error_sp->Flush();
225  }
226  } else {
227  error_sp->Printf("error: %s", error.AsCString());
228  error_sp->Flush();
229  }
230  } else {
231  if (error.AsCString()) {
232  error_sp->Printf("error: %s", error.AsCString());
233  error_sp->Flush();
234  }
235  }
236  }
237  } else {
238  error_sp->Printf("error: unable to generate a function.\n");
239  error_sp->Flush();
240  }
241  } else {
242  error_sp->Printf("error: no script interpreter.\n");
243  error_sp->Flush();
244  }
245  } else {
246  error_sp->Printf("error: internal synchronization information "
247  "missing or invalid.\n");
248  error_sp->Flush();
249  }
250  } else {
251  error_sp->Printf("error: empty function, didn't add python command.\n");
252  error_sp->Flush();
253  }
254  } else {
255  error_sp->Printf(
256  "error: script interpreter missing, didn't add python command.\n");
257  error_sp->Flush();
258  }
259 #endif
260  io_handler.SetIsDone(true);
261  }
262 
263  static bool AddSummary(ConstString type_name, lldb::TypeSummaryImplSP entry,
264  SummaryFormatType type, std::string category,
265  Status *error = nullptr);
266 
267 protected:
268  bool DoExecute(Args &command, CommandReturnObject &result) override;
269 };
270 
271 static const char *g_synth_addreader_instructions =
272  "Enter your Python command(s). Type 'DONE' to end.\n"
273  "You must define a Python class with these methods:\n"
274  " def __init__(self, valobj, internal_dict):\n"
275  " def num_children(self):\n"
276  " def get_child_at_index(self, index):\n"
277  " def get_child_index(self, name):\n"
278  " def update(self):\n"
279  " '''Optional'''\n"
280  "class synthProvider:\n";
281 
282 #define LLDB_OPTIONS_type_synth_add
283 #include "CommandOptions.inc"
284 
287 private:
288  class CommandOptions : public Options {
289  public:
290  CommandOptions() = default;
291 
292  ~CommandOptions() override = default;
293 
294  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
295  ExecutionContext *execution_context) override {
296  Status error;
297  const int short_option = m_getopt_table[option_idx].val;
298  bool success;
299 
300  switch (short_option) {
301  case 'C':
302  m_cascade = OptionArgParser::ToBoolean(option_arg, true, &success);
303  if (!success)
304  error.SetErrorStringWithFormat("invalid value for cascade: %s",
305  option_arg.str().c_str());
306  break;
307  case 'P':
308  handwrite_python = true;
309  break;
310  case 'l':
311  m_class_name = std::string(option_arg);
312  is_class_based = true;
313  break;
314  case 'p':
315  m_skip_pointers = true;
316  break;
317  case 'r':
318  m_skip_references = true;
319  break;
320  case 'w':
321  m_category = std::string(option_arg);
322  break;
323  case 'x':
324  m_regex = true;
325  break;
326  default:
327  llvm_unreachable("Unimplemented option");
328  }
329 
330  return error;
331  }
332 
333  void OptionParsingStarting(ExecutionContext *execution_context) override {
334  m_cascade = true;
335  m_class_name = "";
336  m_skip_pointers = false;
337  m_skip_references = false;
338  m_category = "default";
339  is_class_based = false;
340  handwrite_python = false;
341  m_regex = false;
342  }
343 
344  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
345  return llvm::makeArrayRef(g_type_synth_add_options);
346  }
347 
348  // Instance variables to hold the values for command options.
349 
350  bool m_cascade;
358  bool m_regex;
359  };
360 
362 
363  Options *GetOptions() override { return &m_options; }
364 
365  bool Execute_HandwritePython(Args &command, CommandReturnObject &result);
366 
367  bool Execute_PythonClass(Args &command, CommandReturnObject &result);
368 
369 protected:
370  bool DoExecute(Args &command, CommandReturnObject &result) override {
371  WarnOnPotentialUnquotedUnsignedType(command, result);
372 
373  if (m_options.handwrite_python)
374  return Execute_HandwritePython(command, result);
375  else if (m_options.is_class_based)
376  return Execute_PythonClass(command, result);
377  else {
378  result.AppendError("must either provide a children list, a Python class "
379  "name, or use -P and type a Python class "
380  "line-by-line");
381  return false;
382  }
383  }
384 
385  void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
386  StreamFileSP output_sp(io_handler.GetOutputStreamFileSP());
387  if (output_sp && interactive) {
388  output_sp->PutCString(g_synth_addreader_instructions);
389  output_sp->Flush();
390  }
391  }
392 
394  std::string &data) override {
395  StreamFileSP error_sp = io_handler.GetErrorStreamFileSP();
396 
397 #if LLDB_ENABLE_PYTHON
398  ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
399  if (interpreter) {
400  StringList lines;
401  lines.SplitIntoLines(data);
402  if (lines.GetSize() > 0) {
403  SynthAddOptions *options_ptr =
404  ((SynthAddOptions *)io_handler.GetUserData());
405  if (options_ptr) {
407  options_ptr); // this will ensure that we get rid of the pointer
408  // when going out of scope
409 
410  ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
411  if (interpreter) {
412  std::string class_name_str;
413  if (interpreter->GenerateTypeSynthClass(lines, class_name_str)) {
414  if (class_name_str.empty()) {
415  error_sp->Printf(
416  "error: unable to obtain a proper name for the class.\n");
417  error_sp->Flush();
418  } else {
419  // everything should be fine now, let's add the synth provider
420  // class
421 
422  SyntheticChildrenSP synth_provider;
423  synth_provider = std::make_shared<ScriptedSyntheticChildren>(
425  .SetCascades(options->m_cascade)
426  .SetSkipPointers(options->m_skip_pointers)
427  .SetSkipReferences(options->m_skip_references),
428  class_name_str.c_str());
429 
430  lldb::TypeCategoryImplSP category;
431  DataVisualization::Categories::GetCategory(
432  ConstString(options->m_category.c_str()), category);
433 
434  Status error;
435 
436  for (const std::string &type_name : options->m_target_types) {
437  if (!type_name.empty()) {
439  ConstString(type_name), synth_provider,
440  options->m_regex
443  options->m_category, &error)) {
444  error_sp->Printf("error: %s\n", error.AsCString());
445  error_sp->Flush();
446  break;
447  }
448  } else {
449  error_sp->Printf("error: invalid type name.\n");
450  error_sp->Flush();
451  break;
452  }
453  }
454  }
455  } else {
456  error_sp->Printf("error: unable to generate a class.\n");
457  error_sp->Flush();
458  }
459  } else {
460  error_sp->Printf("error: no script interpreter.\n");
461  error_sp->Flush();
462  }
463  } else {
464  error_sp->Printf("error: internal synchronization data missing.\n");
465  error_sp->Flush();
466  }
467  } else {
468  error_sp->Printf("error: empty function, didn't add python command.\n");
469  error_sp->Flush();
470  }
471  } else {
472  error_sp->Printf(
473  "error: script interpreter missing, didn't add python command.\n");
474  error_sp->Flush();
475  }
476 
477 #endif
478  io_handler.SetIsDone(true);
479  }
480 
481 public:
482  enum SynthFormatType { eRegularSynth, eRegexSynth };
483 
485 
486  ~CommandObjectTypeSynthAdd() override = default;
487 
488  static bool AddSynth(ConstString type_name, lldb::SyntheticChildrenSP entry,
489  SynthFormatType type, std::string category_name,
490  Status *error);
491 };
492 
493 // CommandObjectTypeFormatAdd
494 
495 #define LLDB_OPTIONS_type_format_add
496 #include "CommandOptions.inc"
497 
499 private:
500  class CommandOptions : public OptionGroup {
501  public:
502  CommandOptions() = default;
503 
504  ~CommandOptions() override = default;
505 
506  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
507  return llvm::makeArrayRef(g_type_format_add_options);
508  }
509 
510  void OptionParsingStarting(ExecutionContext *execution_context) override {
511  m_cascade = true;
512  m_skip_pointers = false;
513  m_skip_references = false;
514  m_regex = false;
515  m_category.assign("default");
516  m_custom_type_name.clear();
517  }
518 
519  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
520  ExecutionContext *execution_context) override {
521  Status error;
522  const int short_option =
523  g_type_format_add_options[option_idx].short_option;
524  bool success;
525 
526  switch (short_option) {
527  case 'C':
528  m_cascade = OptionArgParser::ToBoolean(option_value, true, &success);
529  if (!success)
530  error.SetErrorStringWithFormat("invalid value for cascade: %s",
531  option_value.str().c_str());
532  break;
533  case 'p':
534  m_skip_pointers = true;
535  break;
536  case 'w':
537  m_category.assign(std::string(option_value));
538  break;
539  case 'r':
540  m_skip_references = true;
541  break;
542  case 'x':
543  m_regex = true;
544  break;
545  case 't':
546  m_custom_type_name.assign(std::string(option_value));
547  break;
548  default:
549  llvm_unreachable("Unimplemented option");
550  }
551 
552  return error;
553  }
554 
555  // Instance variables to hold the values for command options.
556 
557  bool m_cascade;
560  bool m_regex;
563  };
564 
568 
569  Options *GetOptions() override { return &m_option_group; }
570 
571 public:
573  : CommandObjectParsed(interpreter, "type format add",
574  "Add a new formatting style for a type.", nullptr),
575  m_format_options(eFormatInvalid) {
576  CommandArgumentEntry type_arg;
577  CommandArgumentData type_style_arg;
578 
579  type_style_arg.arg_type = eArgTypeName;
580  type_style_arg.arg_repetition = eArgRepeatPlus;
581 
582  type_arg.push_back(type_style_arg);
583 
584  m_arguments.push_back(type_arg);
585 
586  SetHelpLong(
587  R"(
588 The following examples of 'type format add' refer to this code snippet for context:
589 
590  typedef int Aint;
591  typedef float Afloat;
592  typedef Aint Bint;
593  typedef Afloat Bfloat;
594 
595  Aint ix = 5;
596  Bint iy = 5;
597 
598  Afloat fx = 3.14;
599  BFloat fy = 3.14;
600 
601 Adding default formatting:
602 
603 (lldb) type format add -f hex AInt
604 (lldb) frame variable iy
605 
606 )"
607  " Produces hexadecimal display of iy, because no formatter is available for Bint and \
608 the one for Aint is used instead."
609  R"(
610 
611 To prevent this use the cascade option '-C no' to prevent evaluation of typedef chains:
612 
613 
614 (lldb) type format add -f hex -C no AInt
615 
616 Similar reasoning applies to this:
617 
618 (lldb) type format add -f hex -C no float -p
619 
620 )"
621  " All float values and float references are now formatted as hexadecimal, but not \
622 pointers to floats. Nor will it change the default display for Afloat and Bfloat objects.");
623 
624  // Add the "--format" to all options groups
625  m_option_group.Append(&m_format_options,
626  OptionGroupFormat::OPTION_GROUP_FORMAT,
628  m_option_group.Append(&m_command_options);
629  m_option_group.Finalize();
630  }
631 
632  ~CommandObjectTypeFormatAdd() override = default;
633 
634 protected:
635  bool DoExecute(Args &command, CommandReturnObject &result) override {
636  const size_t argc = command.GetArgumentCount();
637 
638  if (argc < 1) {
639  result.AppendErrorWithFormat("%s takes one or more args.\n",
640  m_cmd_name.c_str());
641  return false;
642  }
643 
644  const Format format = m_format_options.GetFormat();
645  if (format == eFormatInvalid &&
646  m_command_options.m_custom_type_name.empty()) {
647  result.AppendErrorWithFormat("%s needs a valid format.\n",
648  m_cmd_name.c_str());
649  return false;
650  }
651 
652  TypeFormatImplSP entry;
653 
654  if (m_command_options.m_custom_type_name.empty())
655  entry = std::make_shared<TypeFormatImpl_Format>(
656  format, TypeFormatImpl::Flags()
657  .SetCascades(m_command_options.m_cascade)
658  .SetSkipPointers(m_command_options.m_skip_pointers)
659  .SetSkipReferences(m_command_options.m_skip_references));
660  else
661  entry = std::make_shared<TypeFormatImpl_EnumType>(
662  ConstString(m_command_options.m_custom_type_name.c_str()),
664  .SetCascades(m_command_options.m_cascade)
665  .SetSkipPointers(m_command_options.m_skip_pointers)
666  .SetSkipReferences(m_command_options.m_skip_references));
667 
668  // now I have a valid format, let's add it to every type
669 
670  TypeCategoryImplSP category_sp;
671  DataVisualization::Categories::GetCategory(
672  ConstString(m_command_options.m_category), category_sp);
673  if (!category_sp)
674  return false;
675 
676  WarnOnPotentialUnquotedUnsignedType(command, result);
677 
678  for (auto &arg_entry : command.entries()) {
679  if (arg_entry.ref().empty()) {
680  result.AppendError("empty typenames not allowed");
681  return false;
682  }
683 
684  ConstString typeCS(arg_entry.ref());
685  if (m_command_options.m_regex) {
686  RegularExpression typeRX(arg_entry.ref());
687  if (!typeRX.IsValid()) {
688  result.AppendError(
689  "regex format error (maybe this is not really a regex?)");
690  return false;
691  }
692  category_sp->GetRegexTypeSummariesContainer()->Delete(typeCS);
693  category_sp->GetRegexTypeFormatsContainer()->Add(std::move(typeRX),
694  entry);
695  } else
696  category_sp->GetTypeFormatsContainer()->Add(std::move(typeCS), entry);
697  }
698 
700  return result.Succeeded();
701  }
702 };
703 
704 #define LLDB_OPTIONS_type_formatter_delete
705 #include "CommandOptions.inc"
706 
708 protected:
709  class CommandOptions : public Options {
710  public:
711  CommandOptions() = default;
712 
713  ~CommandOptions() override = default;
714 
715  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
716  ExecutionContext *execution_context) override {
717  Status error;
718  const int short_option = m_getopt_table[option_idx].val;
719 
720  switch (short_option) {
721  case 'a':
722  m_delete_all = true;
723  break;
724  case 'w':
725  m_category = std::string(option_arg);
726  break;
727  case 'l':
728  m_language = Language::GetLanguageTypeFromString(option_arg);
729  break;
730  default:
731  llvm_unreachable("Unimplemented option");
732  }
733 
734  return error;
735  }
736 
737  void OptionParsingStarting(ExecutionContext *execution_context) override {
738  m_delete_all = false;
739  m_category = "default";
740  m_language = lldb::eLanguageTypeUnknown;
741  }
742 
743  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
744  return llvm::makeArrayRef(g_type_formatter_delete_options);
745  }
746 
747  // Instance variables to hold the values for command options.
748 
752  };
753 
756 
757  Options *GetOptions() override { return &m_options; }
758 
759 public:
761  uint32_t formatter_kind_mask,
762  const char *name, const char *help)
763  : CommandObjectParsed(interpreter, name, help, nullptr),
764  m_formatter_kind_mask(formatter_kind_mask) {
765  CommandArgumentEntry type_arg;
766  CommandArgumentData type_style_arg;
767 
768  type_style_arg.arg_type = eArgTypeName;
769  type_style_arg.arg_repetition = eArgRepeatPlain;
770 
771  type_arg.push_back(type_style_arg);
772 
773  m_arguments.push_back(type_arg);
774  }
775 
776  ~CommandObjectTypeFormatterDelete() override = default;
777 
778  void
780  OptionElementVector &opt_element_vector) override {
781  if (request.GetCursorIndex())
782  return;
783 
784  DataVisualization::Categories::ForEach(
785  [this, &request](const lldb::TypeCategoryImplSP &category_sp) {
787  category_sp->GetTypeFormatsContainer()->AutoComplete(request);
789  category_sp->GetRegexTypeFormatsContainer()->AutoComplete(request);
790 
792  category_sp->GetTypeSummariesContainer()->AutoComplete(request);
794  category_sp->GetRegexTypeSummariesContainer()->AutoComplete(
795  request);
796 
798  category_sp->GetTypeFiltersContainer()->AutoComplete(request);
800  category_sp->GetRegexTypeFiltersContainer()->AutoComplete(request);
801 
803  category_sp->GetTypeSyntheticsContainer()->AutoComplete(request);
805  category_sp->GetRegexTypeSyntheticsContainer()->AutoComplete(
806  request);
807  return true;
808  });
809  }
810 
811 protected:
812  virtual bool FormatterSpecificDeletion(ConstString typeCS) { return false; }
813 
814  bool DoExecute(Args &command, CommandReturnObject &result) override {
815  const size_t argc = command.GetArgumentCount();
816 
817  if (argc != 1) {
818  result.AppendErrorWithFormat("%s takes 1 arg.\n", m_cmd_name.c_str());
819  return false;
820  }
821 
822  const char *typeA = command.GetArgumentAtIndex(0);
823  ConstString typeCS(typeA);
824 
825  if (!typeCS) {
826  result.AppendError("empty typenames not allowed");
827  return false;
828  }
829 
830  if (m_options.m_delete_all) {
831  DataVisualization::Categories::ForEach(
832  [this, typeCS](const lldb::TypeCategoryImplSP &category_sp) -> bool {
833  category_sp->Delete(typeCS, m_formatter_kind_mask);
834  return true;
835  });
837  return result.Succeeded();
838  }
839 
840  bool delete_category = false;
841  bool extra_deletion = false;
842 
843  if (m_options.m_language != lldb::eLanguageTypeUnknown) {
844  lldb::TypeCategoryImplSP category;
845  DataVisualization::Categories::GetCategory(m_options.m_language,
846  category);
847  if (category)
848  delete_category = category->Delete(typeCS, m_formatter_kind_mask);
849  extra_deletion = FormatterSpecificDeletion(typeCS);
850  } else {
851  lldb::TypeCategoryImplSP category;
852  DataVisualization::Categories::GetCategory(
853  ConstString(m_options.m_category.c_str()), category);
854  if (category)
855  delete_category = category->Delete(typeCS, m_formatter_kind_mask);
856  extra_deletion = FormatterSpecificDeletion(typeCS);
857  }
858 
859  if (delete_category || extra_deletion) {
861  return result.Succeeded();
862  } else {
863  result.AppendErrorWithFormat("no custom formatter for %s.\n", typeA);
864  return false;
865  }
866  }
867 };
868 
869 #define LLDB_OPTIONS_type_formatter_clear
870 #include "CommandOptions.inc"
871 
873 private:
874  class CommandOptions : public Options {
875  public:
876  CommandOptions() = default;
877 
878  ~CommandOptions() override = default;
879 
880  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
881  ExecutionContext *execution_context) override {
882  Status error;
883  const int short_option = m_getopt_table[option_idx].val;
884 
885  switch (short_option) {
886  case 'a':
887  m_delete_all = true;
888  break;
889  default:
890  llvm_unreachable("Unimplemented option");
891  }
892 
893  return error;
894  }
895 
896  void OptionParsingStarting(ExecutionContext *execution_context) override {
897  m_delete_all = false;
898  }
899 
900  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
901  return llvm::makeArrayRef(g_type_formatter_clear_options);
902  }
903 
904  // Instance variables to hold the values for command options.
906  };
907 
910 
911  Options *GetOptions() override { return &m_options; }
912 
913 public:
915  uint32_t formatter_kind_mask,
916  const char *name, const char *help)
917  : CommandObjectParsed(interpreter, name, help, nullptr),
918  m_formatter_kind_mask(formatter_kind_mask) {
920  m_arguments.push_back({category_arg});
921  }
922 
923  ~CommandObjectTypeFormatterClear() override = default;
924 
925 protected:
926  virtual void FormatterSpecificDeletion() {}
927 
928  bool DoExecute(Args &command, CommandReturnObject &result) override {
929  if (m_options.m_delete_all) {
930  DataVisualization::Categories::ForEach(
931  [this](const TypeCategoryImplSP &category_sp) -> bool {
932  category_sp->Clear(m_formatter_kind_mask);
933  return true;
934  });
935  } else {
936  lldb::TypeCategoryImplSP category;
937  if (command.GetArgumentCount() > 0) {
938  const char *cat_name = command.GetArgumentAtIndex(0);
939  ConstString cat_nameCS(cat_name);
940  DataVisualization::Categories::GetCategory(cat_nameCS, category);
941  } else {
942  DataVisualization::Categories::GetCategory(ConstString(nullptr),
943  category);
944  }
945  category->Clear(m_formatter_kind_mask);
946  }
947 
948  FormatterSpecificDeletion();
949 
951  return result.Succeeded();
952  }
953 };
954 
955 // CommandObjectTypeFormatDelete
956 
958 public:
961  interpreter,
963  "type format delete",
964  "Delete an existing formatting style for a type.") {}
965 
966  ~CommandObjectTypeFormatDelete() override = default;
967 };
968 
969 // CommandObjectTypeFormatClear
970 
972 public:
975  interpreter,
977  "type format clear", "Delete all existing format styles.") {}
978 };
979 
980 #define LLDB_OPTIONS_type_formatter_list
981 #include "CommandOptions.inc"
982 
983 template <typename FormatterType>
985  typedef typename FormatterType::SharedPointer FormatterSharedPointer;
986 
987  class CommandOptions : public Options {
988  public:
990  : Options(), m_category_regex("", ""),
991  m_category_language(lldb::eLanguageTypeUnknown,
993 
994  ~CommandOptions() override = default;
995 
996  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
997  ExecutionContext *execution_context) override {
998  Status error;
999  const int short_option = m_getopt_table[option_idx].val;
1000  switch (short_option) {
1001  case 'w':
1002  m_category_regex.SetCurrentValue(option_arg);
1003  m_category_regex.SetOptionWasSet();
1004  break;
1005  case 'l':
1006  error = m_category_language.SetValueFromString(option_arg);
1007  if (error.Success())
1008  m_category_language.SetOptionWasSet();
1009  break;
1010  default:
1011  llvm_unreachable("Unimplemented option");
1012  }
1013 
1014  return error;
1015  }
1016 
1017  void OptionParsingStarting(ExecutionContext *execution_context) override {
1018  m_category_regex.Clear();
1019  m_category_language.Clear();
1020  }
1021 
1022  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1023  return llvm::makeArrayRef(g_type_formatter_list_options);
1024  }
1025 
1026  // Instance variables to hold the values for command options.
1027 
1030  };
1031 
1032  CommandOptions m_options;
1033 
1034  Options *GetOptions() override { return &m_options; }
1035 
1036 public:
1038  const char *name, const char *help)
1039  : CommandObjectParsed(interpreter, name, help, nullptr), m_options() {
1040  CommandArgumentEntry type_arg;
1041  CommandArgumentData type_style_arg;
1042 
1043  type_style_arg.arg_type = eArgTypeName;
1044  type_style_arg.arg_repetition = eArgRepeatOptional;
1045 
1046  type_arg.push_back(type_style_arg);
1047 
1048  m_arguments.push_back(type_arg);
1049  }
1050 
1051  ~CommandObjectTypeFormatterList() override = default;
1052 
1053 protected:
1055  return false;
1056  }
1057 
1058  static bool ShouldListItem(llvm::StringRef s, RegularExpression *regex) {
1059  // If we have a regex, it can match two kinds of results:
1060  // - An item created with that same regex string (exact string match), so
1061  // the user can list it using the same string it used at creation time.
1062  // - Items that match the regex.
1063  // No regex means list everything.
1064  return regex == nullptr || s == regex->GetText() || regex->Execute(s);
1065  }
1066 
1067  bool DoExecute(Args &command, CommandReturnObject &result) override {
1068  const size_t argc = command.GetArgumentCount();
1069 
1070  std::unique_ptr<RegularExpression> category_regex;
1071  std::unique_ptr<RegularExpression> formatter_regex;
1072 
1073  if (m_options.m_category_regex.OptionWasSet()) {
1074  category_regex = std::make_unique<RegularExpression>(
1075  m_options.m_category_regex.GetCurrentValueAsRef());
1076  if (!category_regex->IsValid()) {
1077  result.AppendErrorWithFormat(
1078  "syntax error in category regular expression '%s'",
1079  m_options.m_category_regex.GetCurrentValueAsRef().str().c_str());
1080  return false;
1081  }
1082  }
1083 
1084  if (argc == 1) {
1085  const char *arg = command.GetArgumentAtIndex(0);
1086  formatter_regex = std::make_unique<RegularExpression>(arg);
1087  if (!formatter_regex->IsValid()) {
1088  result.AppendErrorWithFormat("syntax error in regular expression '%s'",
1089  arg);
1090  return false;
1091  }
1092  }
1093 
1094  bool any_printed = false;
1095 
1096  auto category_closure =
1097  [&result, &formatter_regex,
1098  &any_printed](const lldb::TypeCategoryImplSP &category) -> void {
1099  result.GetOutputStream().Printf(
1100  "-----------------------\nCategory: %s%s\n-----------------------\n",
1101  category->GetName(), category->IsEnabled() ? "" : " (disabled)");
1102 
1104  foreach
1105  .SetExact([&result, &formatter_regex, &any_printed](
1106  const TypeMatcher &type_matcher,
1107  const FormatterSharedPointer &format_sp) -> bool {
1108  if (ShouldListItem(type_matcher.GetMatchString().GetStringRef(),
1109  formatter_regex.get())) {
1110  any_printed = true;
1111  result.GetOutputStream().Printf(
1112  "%s: %s\n", type_matcher.GetMatchString().GetCString(),
1113  format_sp->GetDescription().c_str());
1114  }
1115  return true;
1116  });
1117 
1118  foreach
1119  .SetWithRegex([&result, &formatter_regex, &any_printed](
1120  const TypeMatcher &type_matcher,
1121  const FormatterSharedPointer &format_sp) -> bool {
1122  if (ShouldListItem(type_matcher.GetMatchString().GetStringRef(),
1123  formatter_regex.get())) {
1124  any_printed = true;
1125  result.GetOutputStream().Printf(
1126  "%s: %s\n", type_matcher.GetMatchString().GetCString(),
1127  format_sp->GetDescription().c_str());
1128  }
1129  return true;
1130  });
1131 
1132  category->ForEach(foreach);
1133  };
1134 
1135  if (m_options.m_category_language.OptionWasSet()) {
1136  lldb::TypeCategoryImplSP category_sp;
1137  DataVisualization::Categories::GetCategory(
1138  m_options.m_category_language.GetCurrentValue(), category_sp);
1139  if (category_sp)
1140  category_closure(category_sp);
1141  } else {
1142  DataVisualization::Categories::ForEach(
1143  [&category_regex, &category_closure](
1144  const lldb::TypeCategoryImplSP &category) -> bool {
1145  if (ShouldListItem(category->GetName(), category_regex.get())) {
1146  category_closure(category);
1147  }
1148  return true;
1149  });
1150 
1151  any_printed = FormatterSpecificList(result) | any_printed;
1152  }
1153 
1154  if (any_printed)
1156  else {
1157  result.GetOutputStream().PutCString("no matching results found.\n");
1159  }
1160  return result.Succeeded();
1161  }
1162 };
1163 
1164 // CommandObjectTypeFormatList
1165 
1167  : public CommandObjectTypeFormatterList<TypeFormatImpl> {
1168 public:
1170  : CommandObjectTypeFormatterList(interpreter, "type format list",
1171  "Show a list of current formats.") {}
1172 };
1173 
1175  uint32_t option_idx, llvm::StringRef option_arg,
1176  ExecutionContext *execution_context) {
1177  Status error;
1178  const int short_option = m_getopt_table[option_idx].val;
1179  bool success;
1180 
1181  switch (short_option) {
1182  case 'C':
1183  m_flags.SetCascades(OptionArgParser::ToBoolean(option_arg, true, &success));
1184  if (!success)
1185  error.SetErrorStringWithFormat("invalid value for cascade: %s",
1186  option_arg.str().c_str());
1187  break;
1188  case 'e':
1189  m_flags.SetDontShowChildren(false);
1190  break;
1191  case 'h':
1192  m_flags.SetHideEmptyAggregates(true);
1193  break;
1194  case 'v':
1195  m_flags.SetDontShowValue(true);
1196  break;
1197  case 'c':
1198  m_flags.SetShowMembersOneLiner(true);
1199  break;
1200  case 's':
1201  m_format_string = std::string(option_arg);
1202  break;
1203  case 'p':
1204  m_flags.SetSkipPointers(true);
1205  break;
1206  case 'r':
1207  m_flags.SetSkipReferences(true);
1208  break;
1209  case 'x':
1210  m_regex = true;
1211  break;
1212  case 'n':
1213  m_name.SetString(option_arg);
1214  break;
1215  case 'o':
1216  m_python_script = std::string(option_arg);
1217  m_is_add_script = true;
1218  break;
1219  case 'F':
1220  m_python_function = std::string(option_arg);
1221  m_is_add_script = true;
1222  break;
1223  case 'P':
1224  m_is_add_script = true;
1225  break;
1226  case 'w':
1227  m_category = std::string(option_arg);
1228  break;
1229  case 'O':
1230  m_flags.SetHideItemNames(true);
1231  break;
1232  default:
1233  llvm_unreachable("Unimplemented option");
1234  }
1235 
1236  return error;
1237 }
1238 
1240  ExecutionContext *execution_context) {
1241  m_flags.Clear().SetCascades().SetDontShowChildren().SetDontShowValue(false);
1242  m_flags.SetShowMembersOneLiner(false)
1243  .SetSkipPointers(false)
1244  .SetSkipReferences(false)
1245  .SetHideItemNames(false);
1246 
1247  m_regex = false;
1248  m_name.Clear();
1249  m_python_script = "";
1250  m_python_function = "";
1251  m_format_string = "";
1252  m_is_add_script = false;
1253  m_category = "default";
1254 }
1255 
1256 #if LLDB_ENABLE_PYTHON
1257 
1259  Args &command, CommandReturnObject &result) {
1260  const size_t argc = command.GetArgumentCount();
1261 
1262  if (argc < 1 && !m_options.m_name) {
1263  result.AppendErrorWithFormat("%s takes one or more args.\n",
1264  m_cmd_name.c_str());
1265  return false;
1266  }
1267 
1268  TypeSummaryImplSP script_format;
1269 
1270  if (!m_options.m_python_function
1271  .empty()) // we have a Python function ready to use
1272  {
1273  const char *funct_name = m_options.m_python_function.c_str();
1274  if (!funct_name || !funct_name[0]) {
1275  result.AppendError("function name empty.\n");
1276  return false;
1277  }
1278 
1279  std::string code =
1280  (" " + m_options.m_python_function + "(valobj,internal_dict)");
1281 
1282  script_format = std::make_shared<ScriptSummaryFormat>(
1283  m_options.m_flags, funct_name, code.c_str());
1284 
1285  ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
1286 
1287  if (interpreter && !interpreter->CheckObjectExists(funct_name))
1288  result.AppendWarningWithFormat(
1289  "The provided function \"%s\" does not exist - "
1290  "please define it before attempting to use this summary.\n",
1291  funct_name);
1292  } else if (!m_options.m_python_script
1293  .empty()) // we have a quick 1-line script, just use it
1294  {
1295  ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
1296  if (!interpreter) {
1297  result.AppendError("script interpreter missing - unable to generate "
1298  "function wrapper.\n");
1299  return false;
1300  }
1301  StringList funct_sl;
1302  funct_sl << m_options.m_python_script.c_str();
1303  std::string funct_name_str;
1304  if (!interpreter->GenerateTypeScriptFunction(funct_sl, funct_name_str)) {
1305  result.AppendError("unable to generate function wrapper.\n");
1306  return false;
1307  }
1308  if (funct_name_str.empty()) {
1309  result.AppendError(
1310  "script interpreter failed to generate a valid function name.\n");
1311  return false;
1312  }
1313 
1314  std::string code = " " + m_options.m_python_script;
1315 
1316  script_format = std::make_shared<ScriptSummaryFormat>(
1317  m_options.m_flags, funct_name_str.c_str(), code.c_str());
1318  } else {
1319  // Use an IOHandler to grab Python code from the user
1320  auto options = std::make_unique<ScriptAddOptions>(
1321  m_options.m_flags, m_options.m_regex, m_options.m_name,
1322  m_options.m_category);
1323 
1324  for (auto &entry : command.entries()) {
1325  if (entry.ref().empty()) {
1326  result.AppendError("empty typenames not allowed");
1327  return false;
1328  }
1329 
1330  options->m_target_types << std::string(entry.ref());
1331  }
1332 
1333  m_interpreter.GetPythonCommandsFromIOHandler(
1334  " ", // Prompt
1335  *this, // IOHandlerDelegate
1336  options.release()); // Baton for the "io_handler" that will be passed
1337  // back into our IOHandlerDelegate functions
1339 
1340  return result.Succeeded();
1341  }
1342 
1343  // if I am here, script_format must point to something good, so I can add
1344  // that as a script summary to all interested parties
1345 
1346  Status error;
1347 
1348  for (auto &entry : command.entries()) {
1350  ConstString(entry.ref()), script_format,
1351  (m_options.m_regex ? eRegexSummary : eRegularSummary),
1352  m_options.m_category, &error);
1353  if (error.Fail()) {
1354  result.AppendError(error.AsCString());
1355  return false;
1356  }
1357  }
1358 
1359  if (m_options.m_name) {
1360  AddSummary(m_options.m_name, script_format, eNamedSummary,
1361  m_options.m_category, &error);
1362  if (error.Fail()) {
1363  result.AppendError(error.AsCString());
1364  result.AppendError("added to types, but not given a name");
1365  return false;
1366  }
1367  }
1368 
1369  return result.Succeeded();
1370 }
1371 
1372 #endif
1373 
1375  Args &command, CommandReturnObject &result) {
1376  const size_t argc = command.GetArgumentCount();
1377 
1378  if (argc < 1 && !m_options.m_name) {
1379  result.AppendErrorWithFormat("%s takes one or more args.\n",
1380  m_cmd_name.c_str());
1381  return false;
1382  }
1383 
1384  if (!m_options.m_flags.GetShowMembersOneLiner() &&
1385  m_options.m_format_string.empty()) {
1386  result.AppendError("empty summary strings not allowed");
1387  return false;
1388  }
1389 
1390  const char *format_cstr = (m_options.m_flags.GetShowMembersOneLiner()
1391  ? ""
1392  : m_options.m_format_string.c_str());
1393 
1394  // ${var%S} is an endless recursion, prevent it
1395  if (strcmp(format_cstr, "${var%S}") == 0) {
1396  result.AppendError("recursive summary not allowed");
1397  return false;
1398  }
1399 
1400  std::unique_ptr<StringSummaryFormat> string_format(
1401  new StringSummaryFormat(m_options.m_flags, format_cstr));
1402  if (!string_format) {
1403  result.AppendError("summary creation failed");
1404  return false;
1405  }
1406  if (string_format->m_error.Fail()) {
1407  result.AppendErrorWithFormat("syntax error: %s",
1408  string_format->m_error.AsCString("<unknown>"));
1409  return false;
1410  }
1411  lldb::TypeSummaryImplSP entry(string_format.release());
1412 
1413  // now I have a valid format, let's add it to every type
1414  Status error;
1415  for (auto &arg_entry : command.entries()) {
1416  if (arg_entry.ref().empty()) {
1417  result.AppendError("empty typenames not allowed");
1418  return false;
1419  }
1420  ConstString typeCS(arg_entry.ref());
1421 
1422  AddSummary(typeCS, entry,
1423  (m_options.m_regex ? eRegexSummary : eRegularSummary),
1424  m_options.m_category, &error);
1425 
1426  if (error.Fail()) {
1427  result.AppendError(error.AsCString());
1428  return false;
1429  }
1430  }
1431 
1432  if (m_options.m_name) {
1433  AddSummary(m_options.m_name, entry, eNamedSummary, m_options.m_category,
1434  &error);
1435  if (error.Fail()) {
1436  result.AppendError(error.AsCString());
1437  result.AppendError("added to types, but not given a name");
1438  return false;
1439  }
1440  }
1441 
1443  return result.Succeeded();
1444 }
1445 
1447  CommandInterpreter &interpreter)
1448  : CommandObjectParsed(interpreter, "type summary add",
1449  "Add a new summary style for a type.", nullptr),
1450  IOHandlerDelegateMultiline("DONE"), m_options(interpreter) {
1451  CommandArgumentEntry type_arg;
1452  CommandArgumentData type_style_arg;
1453 
1454  type_style_arg.arg_type = eArgTypeName;
1455  type_style_arg.arg_repetition = eArgRepeatPlus;
1456 
1457  type_arg.push_back(type_style_arg);
1458 
1459  m_arguments.push_back(type_arg);
1460 
1461  SetHelpLong(
1462  R"(
1463 The following examples of 'type summary add' refer to this code snippet for context:
1464 
1465  struct JustADemo
1466  {
1467  int* ptr;
1468  float value;
1469  JustADemo(int p = 1, float v = 0.1) : ptr(new int(p)), value(v) {}
1470  };
1471  JustADemo demo_instance(42, 3.14);
1472 
1473  typedef JustADemo NewDemo;
1474  NewDemo new_demo_instance(42, 3.14);
1475 
1476 (lldb) type summary add --summary-string "the answer is ${*var.ptr}" JustADemo
1477 
1478  Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42"
1479 
1480 (lldb) type summary add --summary-string "the answer is ${*var.ptr}, and the question is ${var.value}" JustADemo
1481 
1482  Subsequently displaying demo_instance with 'frame variable' or 'expression' will display "the answer is 42 and the question is 3.14"
1483 
1484 )"
1485  "Alternatively, you could define formatting for all pointers to integers and \
1486 rely on that when formatting JustADemo to obtain the same result:"
1487  R"(
1488 
1489 (lldb) type summary add --summary-string "${var%V} -> ${*var}" "int *"
1490 (lldb) type summary add --summary-string "the answer is ${var.ptr}, and the question is ${var.value}" JustADemo
1492 )"
1493  "Type summaries are automatically applied to derived typedefs, so the examples \
1494 above apply to both JustADemo and NewDemo. The cascade option can be used to \
1495 suppress this behavior:"
1496  R"(
1497 
1498 (lldb) type summary add --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo -C no
1499 
1500  The summary will now be used for values of JustADemo but not NewDemo.
1501 
1502 )"
1503  "By default summaries are shown for pointers and references to values of the \
1504 specified type. To suppress formatting for pointers use the -p option, or apply \
1505 the corresponding -r option to suppress formatting for references:"
1506  R"(
1508 (lldb) type summary add -p -r --summary-string "${var.ptr}, ${var.value},{${var.byte}}" JustADemo
1509 
1510 )"
1511  "One-line summaries including all fields in a type can be inferred without supplying an \
1512 explicit summary string by passing the -c option:"
1513  R"(
1514 
1515 (lldb) type summary add -c JustADemo
1516 (lldb) frame variable demo_instance
1517 (ptr=<address>, value=3.14)
1518 
1519 )"
1520  "Type summaries normally suppress the nested display of individual fields. To \
1521 supply a summary to supplement the default structure add the -e option:"
1522  R"(
1523 
1524 (lldb) type summary add -e --summary-string "*ptr = ${*var.ptr}" JustADemo
1525 
1526 )"
1527  "Now when displaying JustADemo values the int* is displayed, followed by the \
1528 standard LLDB sequence of children, one per line:"
1529  R"(
1530 
1531 *ptr = 42 {
1532  ptr = <address>
1533  value = 3.14
1534 }
1535 
1536 )"
1537  "You can also add summaries written in Python. These scripts use lldb public API to \
1538 gather information from your variables and produce a meaningful summary. To start a \
1539 multi-line script use the -P option. The function declaration will be displayed along with \
1540 a comment describing the two arguments. End your script with the word 'DONE' on a line by \
1541 itself:"
1542  R"(
1543 
1544 (lldb) type summary add JustADemo -P
1545 def function (valobj,internal_dict): """valobj: an SBValue which you want to provide a summary for
1546 internal_dict: an LLDB support object not to be used"""
1547  value = valobj.GetChildMemberWithName('value');
1548  return 'My value is ' + value.GetValue();
1549  DONE
1550 
1551 Alternatively, the -o option can be used when providing a simple one-line Python script:
1552 
1553 (lldb) type summary add JustADemo -o "value = valobj.GetChildMemberWithName('value'); return 'My value is ' + value.GetValue();")");
1554 }
1555 
1557  CommandReturnObject &result) {
1558  WarnOnPotentialUnquotedUnsignedType(command, result);
1559 
1560  if (m_options.m_is_add_script) {
1561 #if LLDB_ENABLE_PYTHON
1562  return Execute_ScriptSummary(command, result);
1563 #else
1564  result.AppendError("python is disabled");
1565  return false;
1566 #endif
1567  }
1568 
1569  return Execute_StringSummary(command, result);
1570 }
1571 
1572 static bool FixArrayTypeNameWithRegex(ConstString &type_name) {
1573  llvm::StringRef type_name_ref(type_name.GetStringRef());
1574 
1575  if (type_name_ref.endswith("[]")) {
1576  std::string type_name_str(type_name.GetCString());
1577  type_name_str.resize(type_name_str.length() - 2);
1578  if (type_name_str.back() != ' ')
1579  type_name_str.append(" ?\\[[0-9]+\\]");
1580  else
1581  type_name_str.append("\\[[0-9]+\\]");
1582  type_name.SetCString(type_name_str.c_str());
1583  return true;
1584  }
1585  return false;
1586 }
1587 
1589  TypeSummaryImplSP entry,
1590  SummaryFormatType type,
1591  std::string category_name,
1592  Status *error) {
1593  lldb::TypeCategoryImplSP category;
1594  DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()),
1595  category);
1596 
1597  if (type == eRegularSummary) {
1598  if (FixArrayTypeNameWithRegex(type_name))
1599  type = eRegexSummary;
1600  }
1601 
1602  if (type == eRegexSummary) {
1603  RegularExpression typeRX(type_name.GetStringRef());
1604  if (!typeRX.IsValid()) {
1605  if (error)
1606  error->SetErrorString(
1607  "regex format error (maybe this is not really a regex?)");
1608  return false;
1609  }
1610 
1611  category->GetRegexTypeSummariesContainer()->Delete(type_name);
1612  category->GetRegexTypeSummariesContainer()->Add(std::move(typeRX), entry);
1613 
1614  return true;
1615  } else if (type == eNamedSummary) {
1616  // system named summaries do not exist (yet?)
1617  DataVisualization::NamedSummaryFormats::Add(type_name, entry);
1618  return true;
1619  } else {
1620  category->GetTypeSummariesContainer()->Add(std::move(type_name), entry);
1621  return true;
1622  }
1623 }
1624 
1625 // CommandObjectTypeSummaryDelete
1626 
1627 class CommandObjectTypeSummaryDelete : public CommandObjectTypeFormatterDelete {
1628 public:
1629  CommandObjectTypeSummaryDelete(CommandInterpreter &interpreter)
1631  interpreter,
1633  "type summary delete", "Delete an existing summary for a type.") {}
1634 
1635  ~CommandObjectTypeSummaryDelete() override = default;
1636 
1637 protected:
1638  bool FormatterSpecificDeletion(ConstString typeCS) override {
1639  if (m_options.m_language != lldb::eLanguageTypeUnknown)
1640  return false;
1641  return DataVisualization::NamedSummaryFormats::Delete(typeCS);
1642  }
1643 };
1644 
1645 class CommandObjectTypeSummaryClear : public CommandObjectTypeFormatterClear {
1646 public:
1647  CommandObjectTypeSummaryClear(CommandInterpreter &interpreter)
1649  interpreter,
1651  "type summary clear", "Delete all existing summaries.") {}
1652 
1653 protected:
1654  void FormatterSpecificDeletion() override {
1655  DataVisualization::NamedSummaryFormats::Clear();
1656  }
1657 };
1658 
1659 // CommandObjectTypeSummaryList
1660 
1661 class CommandObjectTypeSummaryList
1662  : public CommandObjectTypeFormatterList<TypeSummaryImpl> {
1663 public:
1664  CommandObjectTypeSummaryList(CommandInterpreter &interpreter)
1665  : CommandObjectTypeFormatterList(interpreter, "type summary list",
1666  "Show a list of current summaries.") {}
1667 
1668 protected:
1669  bool FormatterSpecificList(CommandReturnObject &result) override {
1670  if (DataVisualization::NamedSummaryFormats::GetCount() > 0) {
1671  result.GetOutputStream().Printf("Named summaries:\n");
1672  DataVisualization::NamedSummaryFormats::ForEach(
1673  [&result](const TypeMatcher &type_matcher,
1674  const TypeSummaryImplSP &summary_sp) -> bool {
1675  result.GetOutputStream().Printf(
1676  "%s: %s\n", type_matcher.GetMatchString().GetCString(),
1677  summary_sp->GetDescription().c_str());
1678  return true;
1679  });
1680  return true;
1681  }
1682  return false;
1683  }
1684 };
1685 
1686 // CommandObjectTypeCategoryDefine
1687 #define LLDB_OPTIONS_type_category_define
1688 #include "CommandOptions.inc"
1689 
1690 class CommandObjectTypeCategoryDefine : public CommandObjectParsed {
1691  class CommandOptions : public Options {
1692  public:
1693  CommandOptions()
1694  : m_define_enabled(false, false),
1695  m_cate_language(eLanguageTypeUnknown, eLanguageTypeUnknown) {}
1696 
1697  ~CommandOptions() override = default;
1698 
1699  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1700  ExecutionContext *execution_context) override {
1701  Status error;
1702  const int short_option = m_getopt_table[option_idx].val;
1703 
1704  switch (short_option) {
1705  case 'e':
1706  m_define_enabled.SetValueFromString(llvm::StringRef("true"));
1707  break;
1708  case 'l':
1709  error = m_cate_language.SetValueFromString(option_arg);
1710  break;
1711  default:
1712  llvm_unreachable("Unimplemented option");
1713  }
1714 
1715  return error;
1716  }
1717 
1718  void OptionParsingStarting(ExecutionContext *execution_context) override {
1719  m_define_enabled.Clear();
1720  m_cate_language.Clear();
1721  }
1722 
1723  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1724  return llvm::makeArrayRef(g_type_category_define_options);
1725  }
1726 
1727  // Instance variables to hold the values for command options.
1728 
1729  OptionValueBoolean m_define_enabled;
1730  OptionValueLanguage m_cate_language;
1731  };
1732 
1733  CommandOptions m_options;
1734 
1735  Options *GetOptions() override { return &m_options; }
1736 
1737 public:
1738  CommandObjectTypeCategoryDefine(CommandInterpreter &interpreter)
1739  : CommandObjectParsed(interpreter, "type category define",
1740  "Define a new category as a source of formatters.",
1741  nullptr) {
1742  CommandArgumentEntry type_arg;
1743  CommandArgumentData type_style_arg;
1744 
1745  type_style_arg.arg_type = eArgTypeName;
1746  type_style_arg.arg_repetition = eArgRepeatPlus;
1747 
1748  type_arg.push_back(type_style_arg);
1749 
1750  m_arguments.push_back(type_arg);
1751  }
1752 
1753  ~CommandObjectTypeCategoryDefine() override = default;
1754 
1755  void
1757  OptionElementVector &opt_element_vector) override {
1760  CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
1761  }
1762 
1763 protected:
1764  bool DoExecute(Args &command, CommandReturnObject &result) override {
1765  const size_t argc = command.GetArgumentCount();
1766 
1767  if (argc < 1) {
1768  result.AppendErrorWithFormat("%s takes 1 or more args.\n",
1769  m_cmd_name.c_str());
1770  return false;
1771  }
1772 
1773  for (auto &entry : command.entries()) {
1774  TypeCategoryImplSP category_sp;
1775  if (DataVisualization::Categories::GetCategory(ConstString(entry.ref()),
1776  category_sp) &&
1777  category_sp) {
1778  category_sp->AddLanguage(m_options.m_cate_language.GetCurrentValue());
1779  if (m_options.m_define_enabled.GetCurrentValue())
1781  TypeCategoryMap::Default);
1782  }
1783  }
1784 
1786  return result.Succeeded();
1787  }
1788 };
1789 
1790 // CommandObjectTypeCategoryEnable
1791 #define LLDB_OPTIONS_type_category_enable
1792 #include "CommandOptions.inc"
1793 
1794 class CommandObjectTypeCategoryEnable : public CommandObjectParsed {
1795  class CommandOptions : public Options {
1796  public:
1797  CommandOptions() = default;
1798 
1799  ~CommandOptions() override = default;
1800 
1801  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1802  ExecutionContext *execution_context) override {
1803  Status error;
1804  const int short_option = m_getopt_table[option_idx].val;
1805 
1806  switch (short_option) {
1807  case 'l':
1808  if (!option_arg.empty()) {
1809  m_language = Language::GetLanguageTypeFromString(option_arg);
1810  if (m_language == lldb::eLanguageTypeUnknown)
1811  error.SetErrorStringWithFormat("unrecognized language '%s'",
1812  option_arg.str().c_str());
1813  }
1814  break;
1815  default:
1816  llvm_unreachable("Unimplemented option");
1817  }
1818 
1819  return error;
1820  }
1821 
1822  void OptionParsingStarting(ExecutionContext *execution_context) override {
1823  m_language = lldb::eLanguageTypeUnknown;
1824  }
1825 
1826  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1827  return llvm::makeArrayRef(g_type_category_enable_options);
1828  }
1829 
1830  // Instance variables to hold the values for command options.
1831 
1832  lldb::LanguageType m_language;
1833  };
1834 
1835  CommandOptions m_options;
1836 
1837  Options *GetOptions() override { return &m_options; }
1838 
1839 public:
1840  CommandObjectTypeCategoryEnable(CommandInterpreter &interpreter)
1841  : CommandObjectParsed(interpreter, "type category enable",
1842  "Enable a category as a source of formatters.",
1843  nullptr) {
1844  CommandArgumentEntry type_arg;
1845  CommandArgumentData type_style_arg;
1846 
1847  type_style_arg.arg_type = eArgTypeName;
1848  type_style_arg.arg_repetition = eArgRepeatPlus;
1849 
1850  type_arg.push_back(type_style_arg);
1851 
1852  m_arguments.push_back(type_arg);
1853  }
1854 
1855  ~CommandObjectTypeCategoryEnable() override = default;
1856 
1857  void
1859  OptionElementVector &opt_element_vector) override {
1862  CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
1863  }
1864 
1865 protected:
1866  bool DoExecute(Args &command, CommandReturnObject &result) override {
1867  const size_t argc = command.GetArgumentCount();
1868 
1869  if (argc < 1 && m_options.m_language == lldb::eLanguageTypeUnknown) {
1870  result.AppendErrorWithFormat("%s takes arguments and/or a language",
1871  m_cmd_name.c_str());
1872  return false;
1873  }
1874 
1875  if (argc == 1 && strcmp(command.GetArgumentAtIndex(0), "*") == 0) {
1877  } else if (argc > 0) {
1878  for (int i = argc - 1; i >= 0; i--) {
1879  const char *typeA = command.GetArgumentAtIndex(i);
1880  ConstString typeCS(typeA);
1881 
1882  if (!typeCS) {
1883  result.AppendError("empty category name not allowed");
1884  return false;
1885  }
1887  lldb::TypeCategoryImplSP cate;
1888  if (DataVisualization::Categories::GetCategory(typeCS, cate) && cate) {
1889  if (cate->GetCount() == 0) {
1890  result.AppendWarning("empty category enabled (typo?)");
1891  }
1892  }
1893  }
1894  }
1895 
1896  if (m_options.m_language != lldb::eLanguageTypeUnknown)
1897  DataVisualization::Categories::Enable(m_options.m_language);
1898 
1900  return result.Succeeded();
1901  }
1902 };
1903 
1904 // CommandObjectTypeCategoryDelete
1905 
1906 class CommandObjectTypeCategoryDelete : public CommandObjectParsed {
1907 public:
1908  CommandObjectTypeCategoryDelete(CommandInterpreter &interpreter)
1909  : CommandObjectParsed(interpreter, "type category delete",
1910  "Delete a category and all associated formatters.",
1911  nullptr) {
1912  CommandArgumentEntry type_arg;
1913  CommandArgumentData type_style_arg;
1914 
1915  type_style_arg.arg_type = eArgTypeName;
1916  type_style_arg.arg_repetition = eArgRepeatPlus;
1917 
1918  type_arg.push_back(type_style_arg);
1919 
1920  m_arguments.push_back(type_arg);
1921  }
1922 
1923  ~CommandObjectTypeCategoryDelete() override = default;
1924 
1925  void
1927  OptionElementVector &opt_element_vector) override {
1930  CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
1931  }
1932 
1933 protected:
1934  bool DoExecute(Args &command, CommandReturnObject &result) override {
1935  const size_t argc = command.GetArgumentCount();
1936 
1937  if (argc < 1) {
1938  result.AppendErrorWithFormat("%s takes 1 or more arg.\n",
1939  m_cmd_name.c_str());
1940  return false;
1941  }
1942 
1943  bool success = true;
1944 
1945  // the order is not relevant here
1946  for (int i = argc - 1; i >= 0; i--) {
1947  const char *typeA = command.GetArgumentAtIndex(i);
1948  ConstString typeCS(typeA);
1949 
1950  if (!typeCS) {
1951  result.AppendError("empty category name not allowed");
1952  return false;
1953  }
1954  if (!DataVisualization::Categories::Delete(typeCS))
1955  success = false; // keep deleting even if we hit an error
1956  }
1957  if (success) {
1959  return result.Succeeded();
1960  } else {
1961  result.AppendError("cannot delete one or more categories\n");
1962  return false;
1963  }
1964  }
1965 };
1966 
1967 // CommandObjectTypeCategoryDisable
1968 #define LLDB_OPTIONS_type_category_disable
1969 #include "CommandOptions.inc"
1970 
1971 class CommandObjectTypeCategoryDisable : public CommandObjectParsed {
1972  class CommandOptions : public Options {
1973  public:
1974  CommandOptions() = default;
1975 
1976  ~CommandOptions() override = default;
1977 
1978  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1979  ExecutionContext *execution_context) override {
1980  Status error;
1981  const int short_option = m_getopt_table[option_idx].val;
1982 
1983  switch (short_option) {
1984  case 'l':
1985  if (!option_arg.empty()) {
1986  m_language = Language::GetLanguageTypeFromString(option_arg);
1987  if (m_language == lldb::eLanguageTypeUnknown)
1988  error.SetErrorStringWithFormat("unrecognized language '%s'",
1989  option_arg.str().c_str());
1990  }
1991  break;
1992  default:
1993  llvm_unreachable("Unimplemented option");
1994  }
1995 
1996  return error;
1997  }
1998 
1999  void OptionParsingStarting(ExecutionContext *execution_context) override {
2000  m_language = lldb::eLanguageTypeUnknown;
2001  }
2002 
2003  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2004  return llvm::makeArrayRef(g_type_category_disable_options);
2005  }
2006 
2007  // Instance variables to hold the values for command options.
2008 
2009  lldb::LanguageType m_language;
2010  };
2011 
2012  CommandOptions m_options;
2013 
2014  Options *GetOptions() override { return &m_options; }
2015 
2016 public:
2017  CommandObjectTypeCategoryDisable(CommandInterpreter &interpreter)
2018  : CommandObjectParsed(interpreter, "type category disable",
2019  "Disable a category as a source of formatters.",
2020  nullptr) {
2021  CommandArgumentEntry type_arg;
2022  CommandArgumentData type_style_arg;
2023 
2024  type_style_arg.arg_type = eArgTypeName;
2025  type_style_arg.arg_repetition = eArgRepeatPlus;
2026 
2027  type_arg.push_back(type_style_arg);
2028 
2029  m_arguments.push_back(type_arg);
2030  }
2031 
2032  ~CommandObjectTypeCategoryDisable() override = default;
2033 
2034  void
2036  OptionElementVector &opt_element_vector) override {
2039  CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
2040  }
2041 
2042 protected:
2043  bool DoExecute(Args &command, CommandReturnObject &result) override {
2044  const size_t argc = command.GetArgumentCount();
2045 
2046  if (argc < 1 && m_options.m_language == lldb::eLanguageTypeUnknown) {
2047  result.AppendErrorWithFormat("%s takes arguments and/or a language",
2048  m_cmd_name.c_str());
2049  return false;
2050  }
2051 
2052  if (argc == 1 && strcmp(command.GetArgumentAtIndex(0), "*") == 0) {
2054  } else if (argc > 0) {
2055  // the order is not relevant here
2056  for (int i = argc - 1; i >= 0; i--) {
2057  const char *typeA = command.GetArgumentAtIndex(i);
2058  ConstString typeCS(typeA);
2059 
2060  if (!typeCS) {
2061  result.AppendError("empty category name not allowed");
2062  return false;
2063  }
2065  }
2066  }
2067 
2068  if (m_options.m_language != lldb::eLanguageTypeUnknown)
2069  DataVisualization::Categories::Disable(m_options.m_language);
2070 
2072  return result.Succeeded();
2073  }
2074 };
2075 
2076 // CommandObjectTypeCategoryList
2077 
2078 class CommandObjectTypeCategoryList : public CommandObjectParsed {
2079 public:
2080  CommandObjectTypeCategoryList(CommandInterpreter &interpreter)
2081  : CommandObjectParsed(interpreter, "type category list",
2082  "Provide a list of all existing categories.",
2083  nullptr) {
2084  CommandArgumentEntry type_arg;
2085  CommandArgumentData type_style_arg;
2086 
2087  type_style_arg.arg_type = eArgTypeName;
2088  type_style_arg.arg_repetition = eArgRepeatOptional;
2089 
2090  type_arg.push_back(type_style_arg);
2091 
2092  m_arguments.push_back(type_arg);
2093  }
2094 
2095  ~CommandObjectTypeCategoryList() override = default;
2096 
2097  void
2099  OptionElementVector &opt_element_vector) override {
2100  if (request.GetCursorIndex())
2101  return;
2104  CommandCompletions::eTypeCategoryNameCompletion, request, nullptr);
2105  }
2106 
2107 protected:
2108  bool DoExecute(Args &command, CommandReturnObject &result) override {
2109  const size_t argc = command.GetArgumentCount();
2110 
2111  std::unique_ptr<RegularExpression> regex;
2112 
2113  if (argc == 1) {
2114  const char *arg = command.GetArgumentAtIndex(0);
2115  regex = std::make_unique<RegularExpression>(arg);
2116  if (!regex->IsValid()) {
2117  result.AppendErrorWithFormat(
2118  "syntax error in category regular expression '%s'", arg);
2119  return false;
2120  }
2121  } else if (argc != 0) {
2122  result.AppendErrorWithFormat("%s takes 0 or one arg.\n",
2123  m_cmd_name.c_str());
2124  return false;
2125  }
2126 
2128  [&regex, &result](const lldb::TypeCategoryImplSP &category_sp) -> bool {
2129  if (regex) {
2130  bool escape = true;
2131  if (regex->GetText() == category_sp->GetName()) {
2132  escape = false;
2133  } else if (regex->Execute(category_sp->GetName())) {
2134  escape = false;
2135  }
2136 
2137  if (escape)
2138  return true;
2139  }
2140 
2141  result.GetOutputStream().Printf(
2142  "Category: %s\n", category_sp->GetDescription().c_str());
2143 
2144  return true;
2145  });
2146 
2148  return result.Succeeded();
2149  }
2150 };
2151 
2152 // CommandObjectTypeFilterList
2153 
2154 class CommandObjectTypeFilterList
2155  : public CommandObjectTypeFormatterList<TypeFilterImpl> {
2156 public:
2157  CommandObjectTypeFilterList(CommandInterpreter &interpreter)
2158  : CommandObjectTypeFormatterList(interpreter, "type filter list",
2159  "Show a list of current filters.") {}
2160 };
2161 
2162 #if LLDB_ENABLE_PYTHON
2163 
2164 // CommandObjectTypeSynthList
2165 
2166 class CommandObjectTypeSynthList
2167  : public CommandObjectTypeFormatterList<SyntheticChildren> {
2168 public:
2169  CommandObjectTypeSynthList(CommandInterpreter &interpreter)
2171  interpreter, "type synthetic list",
2172  "Show a list of current synthetic providers.") {}
2173 };
2174 
2175 #endif
2176 
2177 // CommandObjectTypeFilterDelete
2178 
2179 class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete {
2180 public:
2181  CommandObjectTypeFilterDelete(CommandInterpreter &interpreter)
2183  interpreter,
2185  "type filter delete", "Delete an existing filter for a type.") {}
2186 
2187  ~CommandObjectTypeFilterDelete() override = default;
2188 };
2189 
2190 #if LLDB_ENABLE_PYTHON
2191 
2192 // CommandObjectTypeSynthDelete
2193 
2194 class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete {
2195 public:
2196  CommandObjectTypeSynthDelete(CommandInterpreter &interpreter)
2198  interpreter,
2200  "type synthetic delete",
2201  "Delete an existing synthetic provider for a type.") {}
2202 
2203  ~CommandObjectTypeSynthDelete() override = default;
2204 };
2205 
2206 #endif
2207 
2208 // CommandObjectTypeFilterClear
2209 
2210 class CommandObjectTypeFilterClear : public CommandObjectTypeFormatterClear {
2211 public:
2212  CommandObjectTypeFilterClear(CommandInterpreter &interpreter)
2214  interpreter,
2216  "type filter clear", "Delete all existing filter.") {}
2217 };
2218 
2219 #if LLDB_ENABLE_PYTHON
2220 // CommandObjectTypeSynthClear
2221 
2222 class CommandObjectTypeSynthClear : public CommandObjectTypeFormatterClear {
2223 public:
2224  CommandObjectTypeSynthClear(CommandInterpreter &interpreter)
2226  interpreter,
2228  "type synthetic clear",
2229  "Delete all existing synthetic providers.") {}
2230 };
2231 
2233  Args &command, CommandReturnObject &result) {
2234  auto options = std::make_unique<SynthAddOptions>(
2237 
2238  for (auto &entry : command.entries()) {
2239  if (entry.ref().empty()) {
2240  result.AppendError("empty typenames not allowed");
2241  return false;
2242  }
2243 
2244  options->m_target_types << std::string(entry.ref());
2245  }
2246 
2248  " ", // Prompt
2249  *this, // IOHandlerDelegate
2250  options.release()); // Baton for the "io_handler" that will be passed back
2251  // into our IOHandlerDelegate functions
2253  return result.Succeeded();
2254 }
2255 
2257  Args &command, CommandReturnObject &result) {
2258  const size_t argc = command.GetArgumentCount();
2259 
2260  if (argc < 1) {
2261  result.AppendErrorWithFormat("%s takes one or more args.\n",
2262  m_cmd_name.c_str());
2263  return false;
2264  }
2265 
2266  if (m_options.m_class_name.empty() && !m_options.m_input_python) {
2267  result.AppendErrorWithFormat("%s needs either a Python class name or -P to "
2268  "directly input Python code.\n",
2269  m_cmd_name.c_str());
2270  return false;
2271  }
2272 
2273  SyntheticChildrenSP entry;
2274 
2277  .SetCascades(m_options.m_cascade)
2280  m_options.m_class_name.c_str());
2281 
2282  entry.reset(impl);
2283 
2285 
2286  if (interpreter &&
2287  !interpreter->CheckObjectExists(impl->GetPythonClassName()))
2288  result.AppendWarning("The provided class does not exist - please define it "
2289  "before attempting to use this synthetic provider");
2290 
2291  // now I have a valid provider, let's add it to every type
2292 
2293  lldb::TypeCategoryImplSP category;
2294  DataVisualization::Categories::GetCategory(
2295  ConstString(m_options.m_category.c_str()), category);
2296 
2297  Status error;
2298 
2299  for (auto &arg_entry : command.entries()) {
2300  if (arg_entry.ref().empty()) {
2301  result.AppendError("empty typenames not allowed");
2302  return false;
2303  }
2304 
2305  ConstString typeCS(arg_entry.ref());
2306  if (!AddSynth(typeCS, entry,
2308  m_options.m_category, &error)) {
2309  result.AppendError(error.AsCString());
2310  return false;
2311  }
2312  }
2313 
2315  return result.Succeeded();
2316 }
2317 
2319  CommandInterpreter &interpreter)
2320  : CommandObjectParsed(interpreter, "type synthetic add",
2321  "Add a new synthetic provider for a type.", nullptr),
2322  IOHandlerDelegateMultiline("DONE"), m_options() {
2323  CommandArgumentEntry type_arg;
2324  CommandArgumentData type_style_arg;
2325 
2326  type_style_arg.arg_type = eArgTypeName;
2327  type_style_arg.arg_repetition = eArgRepeatPlus;
2328 
2329  type_arg.push_back(type_style_arg);
2330 
2331  m_arguments.push_back(type_arg);
2332 }
2333 
2335  SyntheticChildrenSP entry,
2336  SynthFormatType type,
2337  std::string category_name,
2338  Status *error) {
2339  lldb::TypeCategoryImplSP category;
2340  DataVisualization::Categories::GetCategory(ConstString(category_name.c_str()),
2341  category);
2342 
2343  if (type == eRegularSynth) {
2344  if (FixArrayTypeNameWithRegex(type_name))
2345  type = eRegexSynth;
2346  }
2347 
2348  if (category->AnyMatches(
2350  false)) {
2351  if (error)
2352  error->SetErrorStringWithFormat("cannot add synthetic for type %s when "
2353  "filter is defined in same category!",
2354  type_name.AsCString());
2355  return false;
2356  }
2357 
2358  if (type == eRegexSynth) {
2359  RegularExpression typeRX(type_name.GetStringRef());
2360  if (!typeRX.IsValid()) {
2361  if (error)
2362  error->SetErrorString(
2363  "regex format error (maybe this is not really a regex?)");
2364  return false;
2365  }
2366 
2367  category->GetRegexTypeSyntheticsContainer()->Delete(type_name);
2368  category->GetRegexTypeSyntheticsContainer()->Add(std::move(typeRX), entry);
2369 
2370  return true;
2371  } else {
2372  category->GetTypeSyntheticsContainer()->Add(std::move(type_name), entry);
2373  return true;
2374  }
2375 }
2376 
2377 #endif
2378 #define LLDB_OPTIONS_type_filter_add
2379 #include "CommandOptions.inc"
2380 
2381 class CommandObjectTypeFilterAdd : public CommandObjectParsed {
2382 private:
2383  class CommandOptions : public Options {
2384  typedef std::vector<std::string> option_vector;
2385 
2386  public:
2387  CommandOptions() = default;
2388 
2389  ~CommandOptions() override = default;
2390 
2391  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
2392  ExecutionContext *execution_context) override {
2393  Status error;
2394  const int short_option = m_getopt_table[option_idx].val;
2395  bool success;
2396 
2397  switch (short_option) {
2398  case 'C':
2399  m_cascade = OptionArgParser::ToBoolean(option_arg, true, &success);
2400  if (!success)
2401  error.SetErrorStringWithFormat("invalid value for cascade: %s",
2402  option_arg.str().c_str());
2403  break;
2404  case 'c':
2405  m_expr_paths.push_back(std::string(option_arg));
2406  has_child_list = true;
2407  break;
2408  case 'p':
2409  m_skip_pointers = true;
2410  break;
2411  case 'r':
2412  m_skip_references = true;
2413  break;
2414  case 'w':
2415  m_category = std::string(option_arg);
2416  break;
2417  case 'x':
2418  m_regex = true;
2419  break;
2420  default:
2421  llvm_unreachable("Unimplemented option");
2422  }
2423 
2424  return error;
2425  }
2426 
2427  void OptionParsingStarting(ExecutionContext *execution_context) override {
2428  m_cascade = true;
2429  m_skip_pointers = false;
2430  m_skip_references = false;
2431  m_category = "default";
2432  m_expr_paths.clear();
2433  has_child_list = false;
2434  m_regex = false;
2435  }
2436 
2437  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2438  return llvm::makeArrayRef(g_type_filter_add_options);
2439  }
2440 
2441  // Instance variables to hold the values for command options.
2442 
2443  bool m_cascade;
2444  bool m_skip_references;
2445  bool m_skip_pointers;
2446  bool m_input_python;
2447  option_vector m_expr_paths;
2448  std::string m_category;
2449  bool has_child_list;
2450  bool m_regex;
2451 
2452  typedef option_vector::iterator ExpressionPathsIterator;
2453  };
2454 
2455  CommandOptions m_options;
2456 
2457  Options *GetOptions() override { return &m_options; }
2458 
2459  enum FilterFormatType { eRegularFilter, eRegexFilter };
2460 
2461  bool AddFilter(ConstString type_name, TypeFilterImplSP entry,
2462  FilterFormatType type, std::string category_name,
2463  Status *error) {
2464  lldb::TypeCategoryImplSP category;
2466  ConstString(category_name.c_str()), category);
2467 
2468  if (type == eRegularFilter) {
2469  if (FixArrayTypeNameWithRegex(type_name))
2470  type = eRegexFilter;
2471  }
2472 
2473  if (category->AnyMatches(
2475  false)) {
2476  if (error)
2477  error->SetErrorStringWithFormat("cannot add filter for type %s when "
2478  "synthetic is defined in same "
2479  "category!",
2480  type_name.AsCString());
2481  return false;
2482  }
2483 
2484  if (type == eRegexFilter) {
2485  RegularExpression typeRX(type_name.GetStringRef());
2486  if (!typeRX.IsValid()) {
2487  if (error)
2488  error->SetErrorString(
2489  "regex format error (maybe this is not really a regex?)");
2490  return false;
2491  }
2492 
2493  category->GetRegexTypeFiltersContainer()->Delete(type_name);
2494  category->GetRegexTypeFiltersContainer()->Add(std::move(typeRX), entry);
2495 
2496  return true;
2497  } else {
2498  category->GetTypeFiltersContainer()->Add(std::move(type_name), entry);
2499  return true;
2500  }
2501  }
2502 
2503 public:
2504  CommandObjectTypeFilterAdd(CommandInterpreter &interpreter)
2505  : CommandObjectParsed(interpreter, "type filter add",
2506  "Add a new filter for a type.", nullptr) {
2507  CommandArgumentEntry type_arg;
2508  CommandArgumentData type_style_arg;
2509 
2510  type_style_arg.arg_type = eArgTypeName;
2511  type_style_arg.arg_repetition = eArgRepeatPlus;
2512 
2513  type_arg.push_back(type_style_arg);
2514 
2515  m_arguments.push_back(type_arg);
2516 
2517  SetHelpLong(
2518  R"(
2519 The following examples of 'type filter add' refer to this code snippet for context:
2520 
2521  class Foo {
2522  int a;
2523  int b;
2524  int c;
2525  int d;
2526  int e;
2527  int f;
2528  int g;
2529  int h;
2530  int i;
2531  }
2532  Foo my_foo;
2533 
2534 Adding a simple filter:
2535 
2536 (lldb) type filter add --child a --child g Foo
2537 (lldb) frame variable my_foo
2538 
2539 )"
2540  "Produces output where only a and g are displayed. Other children of my_foo \
2541 (b, c, d, e, f, h and i) are available by asking for them explicitly:"
2542  R"(
2543 
2544 (lldb) frame variable my_foo.b my_foo.c my_foo.i
2545 
2546 )"
2547  "The formatting option --raw on frame variable bypasses the filter, showing \
2548 all children of my_foo as if no filter was defined:"
2549  R"(
2550 
2551 (lldb) frame variable my_foo --raw)");
2552  }
2553 
2554  ~CommandObjectTypeFilterAdd() override = default;
2555 
2556 protected:
2557  bool DoExecute(Args &command, CommandReturnObject &result) override {
2558  const size_t argc = command.GetArgumentCount();
2559 
2560  if (argc < 1) {
2561  result.AppendErrorWithFormat("%s takes one or more args.\n",
2562  m_cmd_name.c_str());
2563  return false;
2564  }
2565 
2566  if (m_options.m_expr_paths.empty()) {
2567  result.AppendErrorWithFormat("%s needs one or more children.\n",
2568  m_cmd_name.c_str());
2569  return false;
2570  }
2571 
2572  TypeFilterImplSP entry(new TypeFilterImpl(
2574  .SetCascades(m_options.m_cascade)
2575  .SetSkipPointers(m_options.m_skip_pointers)
2576  .SetSkipReferences(m_options.m_skip_references)));
2577 
2578  // go through the expression paths
2579  CommandOptions::ExpressionPathsIterator begin,
2580  end = m_options.m_expr_paths.end();
2581 
2582  for (begin = m_options.m_expr_paths.begin(); begin != end; begin++)
2583  entry->AddExpressionPath(*begin);
2584 
2585  // now I have a valid provider, let's add it to every type
2586 
2587  lldb::TypeCategoryImplSP category;
2589  ConstString(m_options.m_category.c_str()), category);
2590 
2591  Status error;
2592 
2593  WarnOnPotentialUnquotedUnsignedType(command, result);
2594 
2595  for (auto &arg_entry : command.entries()) {
2596  if (arg_entry.ref().empty()) {
2597  result.AppendError("empty typenames not allowed");
2598  return false;
2599  }
2600 
2601  ConstString typeCS(arg_entry.ref());
2602  if (!AddFilter(typeCS, entry,
2603  m_options.m_regex ? eRegexFilter : eRegularFilter,
2604  m_options.m_category, &error)) {
2605  result.AppendError(error.AsCString());
2606  return false;
2607  }
2608  }
2609 
2611  return result.Succeeded();
2612  }
2613 };
2614 
2615 // "type lookup"
2616 #define LLDB_OPTIONS_type_lookup
2617 #include "CommandOptions.inc"
2618 
2619 class CommandObjectTypeLookup : public CommandObjectRaw {
2620 protected:
2621  // this function is allowed to do a more aggressive job at guessing languages
2622  // than the expression parser is comfortable with - so leave the original
2623  // call alone and add one that is specific to type lookup
2624  lldb::LanguageType GuessLanguage(StackFrame *frame) {
2626 
2627  if (!frame)
2628  return lang_type;
2629 
2630  lang_type = frame->GuessLanguage();
2631  if (lang_type != lldb::eLanguageTypeUnknown)
2632  return lang_type;
2633 
2634  Symbol *s = frame->GetSymbolContext(eSymbolContextSymbol).symbol;
2635  if (s)
2636  lang_type = s->GetMangled().GuessLanguage();
2637 
2638  return lang_type;
2639  }
2640 
2641  class CommandOptions : public OptionGroup {
2642  public:
2643  CommandOptions() = default;
2644 
2645  ~CommandOptions() override = default;
2646 
2647  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
2648  return llvm::makeArrayRef(g_type_lookup_options);
2649  }
2650 
2651  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
2652  ExecutionContext *execution_context) override {
2653  Status error;
2654 
2655  const int short_option = g_type_lookup_options[option_idx].short_option;
2656 
2657  switch (short_option) {
2658  case 'h':
2659  m_show_help = true;
2660  break;
2661 
2662  case 'l':
2663  m_language = Language::GetLanguageTypeFromString(option_value);
2664  break;
2665 
2666  default:
2667  llvm_unreachable("Unimplemented option");
2668  }
2669 
2670  return error;
2671  }
2672 
2673  void OptionParsingStarting(ExecutionContext *execution_context) override {
2674  m_show_help = false;
2675  m_language = eLanguageTypeUnknown;
2676  }
2677 
2678  // Options table: Required for subclasses of Options.
2679 
2680  bool m_show_help = false;
2682  };
2683 
2684  OptionGroupOptions m_option_group;
2685  CommandOptions m_command_options;
2686 
2687 public:
2688  CommandObjectTypeLookup(CommandInterpreter &interpreter)
2689  : CommandObjectRaw(interpreter, "type lookup",
2690  "Lookup types and declarations in the current target, "
2691  "following language-specific naming conventions.",
2692  "type lookup <type-specifier>",
2693  eCommandRequiresTarget) {
2694  m_option_group.Append(&m_command_options);
2695  m_option_group.Finalize();
2696  }
2697 
2698  ~CommandObjectTypeLookup() override = default;
2699 
2700  Options *GetOptions() override { return &m_option_group; }
2701 
2702  llvm::StringRef GetHelpLong() override {
2703  if (!m_cmd_help_long.empty())
2704  return m_cmd_help_long;
2705 
2706  StreamString stream;
2707  Language::ForEach([&](Language *lang) {
2708  if (const char *help = lang->GetLanguageSpecificTypeLookupHelp())
2709  stream.Printf("%s\n", help);
2710  return true;
2711  });
2712 
2713  m_cmd_help_long = std::string(stream.GetString());
2714  return m_cmd_help_long;
2715  }
2716 
2717  bool DoExecute(llvm::StringRef raw_command_line,
2718  CommandReturnObject &result) override {
2719  if (raw_command_line.empty()) {
2720  result.AppendError(
2721  "type lookup cannot be invoked without a type name as argument");
2722  return false;
2723  }
2724 
2725  auto exe_ctx = GetCommandInterpreter().GetExecutionContext();
2726  m_option_group.NotifyOptionParsingStarting(&exe_ctx);
2727 
2728  OptionsWithRaw args(raw_command_line);
2729  const char *name_of_type = args.GetRawPart().c_str();
2730 
2731  if (args.HasArgs())
2732  if (!ParseOptionsAndNotify(args.GetArgs(), result, m_option_group,
2733  exe_ctx))
2734  return false;
2735 
2736  ExecutionContextScope *best_scope = exe_ctx.GetBestExecutionContextScope();
2737 
2738  bool any_found = false;
2739 
2740  std::vector<Language *> languages;
2741 
2742  bool is_global_search = false;
2743  LanguageType guessed_language = lldb::eLanguageTypeUnknown;
2744 
2745  if ((is_global_search =
2746  (m_command_options.m_language == eLanguageTypeUnknown))) {
2747  Language::ForEach([&](Language *lang) {
2748  languages.push_back(lang);
2749  return true;
2750  });
2751  } else {
2752  languages.push_back(Language::FindPlugin(m_command_options.m_language));
2753  }
2754 
2755  // This is not the most efficient way to do this, but we support very few
2756  // languages so the cost of the sort is going to be dwarfed by the actual
2757  // lookup anyway
2758  if (StackFrame *frame = m_exe_ctx.GetFramePtr()) {
2759  guessed_language = GuessLanguage(frame);
2760  if (guessed_language != eLanguageTypeUnknown) {
2761  llvm::sort(
2762  languages.begin(), languages.end(),
2763  [guessed_language](Language *lang1, Language *lang2) -> bool {
2764  if (!lang1 || !lang2)
2765  return false;
2766  LanguageType lt1 = lang1->GetLanguageType();
2767  LanguageType lt2 = lang2->GetLanguageType();
2768  if (lt1 == guessed_language)
2769  return true; // make the selected frame's language come first
2770  if (lt2 == guessed_language)
2771  return false; // make the selected frame's language come first
2772  return (lt1 < lt2); // normal comparison otherwise
2773  });
2774  }
2775  }
2776 
2777  bool is_first_language = true;
2778 
2779  for (Language *language : languages) {
2780  if (!language)
2781  continue;
2782 
2783  if (auto scavenger = language->GetTypeScavenger()) {
2784  Language::TypeScavenger::ResultSet search_results;
2785  if (scavenger->Find(best_scope, name_of_type, search_results) > 0) {
2786  for (const auto &search_result : search_results) {
2787  if (search_result && search_result->IsValid()) {
2788  any_found = true;
2789  search_result->DumpToStream(result.GetOutputStream(),
2790  this->m_command_options.m_show_help);
2791  }
2792  }
2793  }
2794  }
2795  // this is "type lookup SomeName" and we did find a match, so get out
2796  if (any_found && is_global_search)
2797  break;
2798  else if (is_first_language && is_global_search &&
2799  guessed_language != lldb::eLanguageTypeUnknown) {
2800  is_first_language = false;
2801  result.GetOutputStream().Printf(
2802  "no type was found in the current language %s matching '%s'; "
2803  "performing a global search across all languages\n",
2804  Language::GetNameForLanguageType(guessed_language), name_of_type);
2805  }
2806  }
2807 
2808  if (!any_found)
2809  result.AppendMessageWithFormat("no type was found matching '%s'\n",
2810  name_of_type);
2811 
2814  return true;
2815  }
2816 };
2817 
2818 template <typename FormatterType>
2819 class CommandObjectFormatterInfo : public CommandObjectRaw {
2820 public:
2821  typedef std::function<typename FormatterType::SharedPointer(ValueObject &)>
2822  DiscoveryFunction;
2823  CommandObjectFormatterInfo(CommandInterpreter &interpreter,
2824  const char *formatter_name,
2825  DiscoveryFunction discovery_func)
2826  : CommandObjectRaw(interpreter, "", "", "", eCommandRequiresFrame),
2827  m_formatter_name(formatter_name ? formatter_name : ""),
2828  m_discovery_function(discovery_func) {
2829  StreamString name;
2830  name.Printf("type %s info", formatter_name);
2831  SetCommandName(name.GetString());
2832  StreamString help;
2833  help.Printf("This command evaluates the provided expression and shows "
2834  "which %s is applied to the resulting value (if any).",
2835  formatter_name);
2836  SetHelp(help.GetString());
2837  StreamString syntax;
2838  syntax.Printf("type %s info <expr>", formatter_name);
2839  SetSyntax(syntax.GetString());
2840  }
2841 
2842  ~CommandObjectFormatterInfo() override = default;
2843 
2844 protected:
2845  bool DoExecute(llvm::StringRef command,
2846  CommandReturnObject &result) override {
2847  TargetSP target_sp = GetDebugger().GetSelectedTarget();
2848  Thread *thread = GetDefaultThread();
2849  if (!thread) {
2850  result.AppendError("no default thread");
2851  return false;
2852  }
2853 
2854  StackFrameSP frame_sp = thread->GetSelectedFrame();
2855  ValueObjectSP result_valobj_sp;
2856  EvaluateExpressionOptions options;
2857  lldb::ExpressionResults expr_result = target_sp->EvaluateExpression(
2858  command, frame_sp.get(), result_valobj_sp, options);
2859  if (expr_result == eExpressionCompleted && result_valobj_sp) {
2860  result_valobj_sp =
2861  result_valobj_sp->GetQualifiedRepresentationIfAvailable(
2862  target_sp->GetPreferDynamicValue(),
2863  target_sp->GetEnableSyntheticValue());
2864  typename FormatterType::SharedPointer formatter_sp =
2865  m_discovery_function(*result_valobj_sp);
2866  if (formatter_sp) {
2867  std::string description(formatter_sp->GetDescription());
2868  result.GetOutputStream()
2869  << m_formatter_name << " applied to ("
2870  << result_valobj_sp->GetDisplayTypeName().AsCString("<unknown>")
2871  << ") " << command << " is: " << description << "\n";
2873  } else {
2874  result.GetOutputStream()
2875  << "no " << m_formatter_name << " applies to ("
2876  << result_valobj_sp->GetDisplayTypeName().AsCString("<unknown>")
2877  << ") " << command << "\n";
2879  }
2880  return true;
2881  } else {
2882  result.AppendError("failed to evaluate expression");
2883  return false;
2884  }
2885  }
2886 
2887 private:
2888  std::string m_formatter_name;
2889  DiscoveryFunction m_discovery_function;
2890 };
2891 
2892 class CommandObjectTypeFormat : public CommandObjectMultiword {
2893 public:
2894  CommandObjectTypeFormat(CommandInterpreter &interpreter)
2896  interpreter, "type format",
2897  "Commands for customizing value display formats.",
2898  "type format [<sub-command-options>] ") {
2900  "add", CommandObjectSP(new CommandObjectTypeFormatAdd(interpreter)));
2901  LoadSubCommand("clear", CommandObjectSP(
2902  new CommandObjectTypeFormatClear(interpreter)));
2903  LoadSubCommand("delete", CommandObjectSP(new CommandObjectTypeFormatDelete(
2904  interpreter)));
2906  "list", CommandObjectSP(new CommandObjectTypeFormatList(interpreter)));
2908  "info", CommandObjectSP(new CommandObjectFormatterInfo<TypeFormatImpl>(
2909  interpreter, "format",
2911  return valobj.GetValueFormat();
2912  })));
2913  }
2914 
2915  ~CommandObjectTypeFormat() override = default;
2916 };
2917 
2918 #if LLDB_ENABLE_PYTHON
2919 
2920 class CommandObjectTypeSynth : public CommandObjectMultiword {
2921 public:
2922  CommandObjectTypeSynth(CommandInterpreter &interpreter)
2924  interpreter, "type synthetic",
2925  "Commands for operating on synthetic type representations.",
2926  "type synthetic [<sub-command-options>] ") {
2927  LoadSubCommand("add",
2928  CommandObjectSP(new CommandObjectTypeSynthAdd(interpreter)));
2930  "clear", CommandObjectSP(new CommandObjectTypeSynthClear(interpreter)));
2931  LoadSubCommand("delete", CommandObjectSP(new CommandObjectTypeSynthDelete(
2932  interpreter)));
2934  "list", CommandObjectSP(new CommandObjectTypeSynthList(interpreter)));
2936  "info",
2937  CommandObjectSP(new CommandObjectFormatterInfo<SyntheticChildren>(
2938  interpreter, "synthetic",
2940  return valobj.GetSyntheticChildren();
2941  })));
2942  }
2943 
2944  ~CommandObjectTypeSynth() override = default;
2945 };
2946 
2947 #endif
2948 
2949 class CommandObjectTypeFilter : public CommandObjectMultiword {
2950 public:
2951  CommandObjectTypeFilter(CommandInterpreter &interpreter)
2952  : CommandObjectMultiword(interpreter, "type filter",
2953  "Commands for operating on type filters.",
2954  "type filter [<sub-command-options>] ") {
2956  "add", CommandObjectSP(new CommandObjectTypeFilterAdd(interpreter)));
2957  LoadSubCommand("clear", CommandObjectSP(
2958  new CommandObjectTypeFilterClear(interpreter)));
2959  LoadSubCommand("delete", CommandObjectSP(new CommandObjectTypeFilterDelete(
2960  interpreter)));
2962  "list", CommandObjectSP(new CommandObjectTypeFilterList(interpreter)));
2963  }
2964 
2965  ~CommandObjectTypeFilter() override = default;
2966 };
2967 
2968 class CommandObjectTypeCategory : public CommandObjectMultiword {
2969 public:
2970  CommandObjectTypeCategory(CommandInterpreter &interpreter)
2971  : CommandObjectMultiword(interpreter, "type category",
2972  "Commands for operating on type categories.",
2973  "type category [<sub-command-options>] ") {
2975  "define",
2976  CommandObjectSP(new CommandObjectTypeCategoryDefine(interpreter)));
2978  "enable",
2979  CommandObjectSP(new CommandObjectTypeCategoryEnable(interpreter)));
2981  "disable",
2982  CommandObjectSP(new CommandObjectTypeCategoryDisable(interpreter)));
2984  "delete",
2985  CommandObjectSP(new CommandObjectTypeCategoryDelete(interpreter)));
2986  LoadSubCommand("list", CommandObjectSP(
2987  new CommandObjectTypeCategoryList(interpreter)));
2988  }
2989 
2990  ~CommandObjectTypeCategory() override = default;
2991 };
2992 
2993 class CommandObjectTypeSummary : public CommandObjectMultiword {
2994 public:
2995  CommandObjectTypeSummary(CommandInterpreter &interpreter)
2997  interpreter, "type summary",
2998  "Commands for editing variable summary display options.",
2999  "type summary [<sub-command-options>] ") {
3001  "add", CommandObjectSP(new CommandObjectTypeSummaryAdd(interpreter)));
3002  LoadSubCommand("clear", CommandObjectSP(new CommandObjectTypeSummaryClear(
3003  interpreter)));
3004  LoadSubCommand("delete", CommandObjectSP(new CommandObjectTypeSummaryDelete(
3005  interpreter)));
3007  "list", CommandObjectSP(new CommandObjectTypeSummaryList(interpreter)));
3009  "info", CommandObjectSP(new CommandObjectFormatterInfo<TypeSummaryImpl>(
3010  interpreter, "summary",
3012  return valobj.GetSummaryFormat();
3013  })));
3014  }
3015 
3016  ~CommandObjectTypeSummary() override = default;
3017 };
3018 
3019 // CommandObjectType
3020 
3021 CommandObjectType::CommandObjectType(CommandInterpreter &interpreter)
3022  : CommandObjectMultiword(interpreter, "type",
3023  "Commands for operating on the type system.",
3024  "type [<sub-command-options>]") {
3025  LoadSubCommand("category",
3026  CommandObjectSP(new CommandObjectTypeCategory(interpreter)));
3027  LoadSubCommand("filter",
3028  CommandObjectSP(new CommandObjectTypeFilter(interpreter)));
3029  LoadSubCommand("format",
3030  CommandObjectSP(new CommandObjectTypeFormat(interpreter)));
3031  LoadSubCommand("summary",
3032  CommandObjectSP(new CommandObjectTypeSummary(interpreter)));
3033 #if LLDB_ENABLE_PYTHON
3034  LoadSubCommand("synthetic",
3035  CommandObjectSP(new CommandObjectTypeSynth(interpreter)));
3036 #endif
3037  LoadSubCommand("lookup",
3038  CommandObjectSP(new CommandObjectTypeLookup(interpreter)));
3039 }
3040 
3041 CommandObjectType::~CommandObjectType() = default;
3042 
lldb_private::SyntheticChildren::Flags
Definition: TypeSynthetic.h:134
CommandObjectTypeFormatterList::FormatterSpecificList
virtual bool FormatterSpecificList(CommandReturnObject &result)
Definition: CommandObjectType.cpp:1054
RegularExpression.h
lldb_private::DataVisualization::Categories::Disable
static void Disable(ConstString category)
Definition: DataVisualization.cpp:122
lldb_private::eArgRepeatOptional
@ eArgRepeatOptional
Definition: lldb-private-enumerations.h:96
lldb_private::CommandObjectParsed
Definition: CommandObject.h:389
lldb_private::ScriptedSyntheticChildren
Definition: TypeSynthetic.h:387
CommandObjectTypeSummaryAdd::CommandOptions::CommandOptions
CommandOptions(CommandInterpreter &interpreter)
Definition: CommandObjectType.cpp:107
CommandObjectTypeFormatAdd::m_command_options
CommandOptions m_command_options
Definition: CommandObjectType.cpp:567
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
CommandObjectTypeSynthAdd::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectType.cpp:370
CommandObjectTypeSummaryAdd::CommandObjectTypeSummaryAdd
CommandObjectTypeSummaryAdd(CommandInterpreter &interpreter)
Definition: CommandObjectType.cpp:1446
CommandObjectTypeFormatAdd::CommandOptions::m_category
std::string m_category
Definition: CommandObjectType.cpp:561
lldb_private::SyntheticChildren::Flags::SetSkipReferences
Flags & SetSkipReferences(bool value=true)
Definition: TypeSynthetic.h:189
OptionGroupFormat.h
CommandObjectTypeFormatterList::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectType.cpp:996
CommandObjectTypeSummaryAdd::CommandOptions::m_format_string
std::string m_format_string
Definition: CommandObjectType.cpp:124
lldb_private::RegularExpression
Definition: RegularExpression.h:18
CommandObjectTypeSynthAdd::CommandOptions::m_input_python
bool m_input_python
Definition: CommandObjectType.cpp:354
ScriptAddOptions::m_name
ConstString m_name
Definition: CommandObjectType.cpp:52
ScriptAddOptions::m_target_types
StringList m_target_types
Definition: CommandObjectType.cpp:50
CommandObjectTypeSynthAdd::m_options
CommandOptions m_options
Definition: CommandObjectType.cpp:361
lldb_private::eArgRepeatPlain
@ eArgRepeatPlain
Definition: lldb-private-enumerations.h:95
lldb::Format
Format
Display format definitions.
Definition: lldb-enumerations.h:155
IOHandler.h
CommandObjectTypeSummaryAdd::GetOptions
Options * GetOptions() override
Definition: CommandObjectType.cpp:134
CommandObjectTypeFormatterClear::m_options
CommandOptions m_options
Definition: CommandObjectType.cpp:908
lldb_private::Symbol
Definition: Symbol.h:20
lldb_private::TypeMatcher
Class for matching type names.
Definition: FormattersContainer.h:41
CommandObjectTypeFormatterList::CommandOptions::m_category_regex
OptionValueString m_category_regex
Definition: CommandObjectType.cpp:1028
lldb_private::Options::NotifyOptionParsingStarting
void NotifyOptionParsingStarting(ExecutionContext *execution_context)
Definition: Options.cpp:33
CommandObjectTypeFormatterClear::m_formatter_kind_mask
uint32_t m_formatter_kind_mask
Definition: CommandObjectType.cpp:909
lldb_private::eFormatCategoryItemSummary
@ eFormatCategoryItemSummary
Definition: lldb-private-enumerations.h:131
lldb_private::DataVisualization::Categories::GetCategory
static bool GetCategory(ConstString category, lldb::TypeCategoryImplSP &entry, bool allow_create=true)
Definition: DataVisualization.cpp:76
CommandObjectTypeFormatDelete
Definition: CommandObjectType.cpp:957
lldb::ExpressionResults
ExpressionResults
The results of expression evaluation.
Definition: lldb-enumerations.h:270
lldb_private::OptionValueBoolean
Definition: OptionValueBoolean.h:16
lldb_private::TypeSummaryImpl::Flags
Definition: TypeSummary.h:53
CommandObjectTypeSummaryAdd::CommandOptions::m_name
ConstString m_name
Definition: CommandObjectType.cpp:125
CommandObjectTypeSynthAdd::CommandOptions::m_regex
bool m_regex
Definition: CommandObjectType.cpp:358
lldb_private::CommandObject::GetHelpLong
virtual llvm::StringRef GetHelpLong()
Definition: CommandObject.cpp:57
CommandObjectTypeFormatList
Definition: CommandObjectType.cpp:1166
CommandObjectTypeFormatAdd::CommandOptions::m_cascade
bool m_cascade
Definition: CommandObjectType.cpp:557
ScriptAddOptions::m_flags
TypeSummaryImpl::Flags m_flags
Definition: CommandObjectType.cpp:49
lldb_private::ScriptInterpreter::CheckObjectExists
virtual bool CheckObjectExists(const char *name)
Definition: ScriptInterpreter.h:535
CommandObjectTypeSummaryAdd
Definition: CommandObjectType.cpp:102
CommandObjectTypeSynthAdd::SynthFormatType
SynthFormatType
Definition: CommandObjectType.cpp:482
CommandObjectTypeFormatClear::CommandObjectTypeFormatClear
CommandObjectTypeFormatClear(CommandInterpreter &interpreter)
Definition: CommandObjectType.cpp:973
CommandObjectTypeFormatterClear::GetOptions
Options * GetOptions() override
Definition: CommandObjectType.cpp:911
CommandObjectTypeFormatterDelete::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectType.cpp:814
SynthAddOptions::m_target_types
StringList m_target_types
Definition: CommandObjectType.cpp:68
lldb_private::OptionGroupOptions
Definition: Options.h:255
lldb_private::eFormatCategoryItemSynth
@ eFormatCategoryItemSynth
Definition: lldb-private-enumerations.h:135
CommandObjectTypeSynthAdd::AddSynth
static bool AddSynth(ConstString type_name, lldb::SyntheticChildrenSP entry, SynthFormatType type, std::string category_name, Status *error)
lldb_private::CommandObject::CommandArgumentData
Used to build individual command argument lists.
Definition: CommandObject.h:91
CommandObjectTypeFormatterDelete
Definition: CommandObjectType.cpp:707
lldb_private::OptionGroup
Definition: Options.h:233
lldb_private::EvaluateExpressionOptions
Definition: Target.h:275
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::Language::TypeScavenger::ResultSet
std::set< std::unique_ptr< Result > > ResultSet
Definition: Language.h:43
lldb_private::TypeFilterImpl
Definition: TypeSynthetic.h:277
CommandObjectTypeFormatterList::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectType.cpp:1022
SynthAddOptions::SharedPointer
std::shared_ptr< SynthAddOptions > SharedPointer
Definition: CommandObjectType.cpp:75
CommandObjectTypeFormatterDelete::CommandOptions
Definition: CommandObjectType.cpp:709
lldb_private::ConstString::SetCString
void SetCString(const char *cstr)
Set the C string value.
Definition: ConstString.cpp:301
OptionArgParser.h
lldb_private::eFormatCategoryItemFilter
@ eFormatCategoryItemFilter
Definition: lldb-private-enumerations.h:133
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:193
lldb_private::StringList::SplitIntoLines
size_t SplitIntoLines(const std::string &lines)
Definition: StringList.cpp:152
StackFrame.h
lldb_private::CommandObject::SetHelpLong
virtual void SetHelpLong(llvm::StringRef str)
Definition: CommandObject.cpp:92
lldb_private::CommandObject::CommandArgumentData::arg_repetition
ArgumentRepetitionType arg_repetition
Definition: CommandObject.h:93
lldb_private::eFormatCategoryItemRegexFilter
@ eFormatCategoryItemRegexFilter
Definition: lldb-private-enumerations.h:134
CommandObjectTypeFormatterClear::CommandOptions
Definition: CommandObjectType.cpp:874
SynthAddOptions::SynthAddOptions
SynthAddOptions(bool sptr, bool sref, bool casc, bool regx, std::string catg)
Definition: CommandObjectType.cpp:71
SynthAddOptions::m_cascade
bool m_cascade
Definition: CommandObjectType.cpp:66
CommandObjectTypeFormatAdd::CommandOptions::m_regex
bool m_regex
Definition: CommandObjectType.cpp:560
CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectType.cpp:1174
CommandObjectTypeFormatAdd::CommandOptions::m_skip_pointers
bool m_skip_pointers
Definition: CommandObjectType.cpp:559
lldb_private::Args
Definition: Args.h:33
Language.h
lldb_private::CommandReturnObject::Succeeded
bool Succeeded() const
Definition: CommandReturnObject.cpp:131
lldb_private::CommandObject::SetHelp
virtual void SetHelp(llvm::StringRef str)
Definition: CommandObject.cpp:88
CommandObjectTypeSynthAdd
Definition: CommandObjectType.cpp:285
lldb_private::eArgRepeatPlus
@ eArgRepeatPlus
Definition: lldb-private-enumerations.h:97
lldb_private::CommandInterpreter::GetPythonCommandsFromIOHandler
void GetPythonCommandsFromIOHandler(const char *prompt, IOHandlerDelegate &delegate, void *baton=nullptr)
lldb_private::CommandObject::ParseOptionsAndNotify
bool ParseOptionsAndNotify(Args &args, CommandReturnObject &result, OptionGroupOptions &group_options, ExecutionContext &exe_ctx)
Definition: CommandObject.cpp:343
CommandReturnObject.h
CommandObjectTypeSummaryAdd::IOHandlerInputComplete
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
Definition: CommandObjectType.cpp:162
Debugger.h
CommandObjectTypeSummaryAdd::IOHandlerActivated
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
Definition: CommandObjectType.cpp:147
lldb_private::Debugger::GetScriptInterpreter
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, llvm::Optional< lldb::ScriptLanguage > language={})
Definition: Debugger.cpp:1496
CommandObjectTypeSynthAdd::CommandObjectTypeSynthAdd
CommandObjectTypeSynthAdd(CommandInterpreter &interpreter)
CommandObjectTypeSynthAdd::CommandOptions::handwrite_python
bool handwrite_python
Definition: CommandObjectType.cpp:357
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
CommandObjectTypeFormatAdd::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectType.cpp:506
CommandObjectTypeSynthAdd::CommandOptions::m_skip_pointers
bool m_skip_pointers
Definition: CommandObjectType.cpp:352
lldb_private::StringList::GetSize
size_t GetSize() const
Definition: StringList.cpp:74
CommandObjectTypeFormatterDelete::m_formatter_kind_mask
uint32_t m_formatter_kind_mask
Definition: CommandObjectType.cpp:755
lldb_private::DataVisualization::Categories::Enable
static void Enable(ConstString category, TypeCategoryMap::Position=TypeCategoryMap::Default)
Definition: DataVisualization.cpp:109
lldb::eReturnStatusSuccessFinishNoResult
@ eReturnStatusSuccessFinishNoResult
Definition: lldb-enumerations.h:260
CommandObjectTypeFormatAdd::CommandOptions
Definition: CommandObjectType.cpp:500
CommandObjectTypeFormatAdd::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectType.cpp:510
CommandObjectTypeFormatterList::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectType.cpp:1017
Target.h
lldb_private::CommandObject::m_arguments
std::vector< CommandArgumentEntry > m_arguments
Definition: CommandObject.h:376
lldb_private::Language::GetLanguageSpecificTypeLookupHelp
virtual const char * GetLanguageSpecificTypeLookupHelp()
Definition: Language.cpp:374
ScriptAddOptions::m_category
std::string m_category
Definition: CommandObjectType.cpp:53
lldb_private::CommandObjectMultiword
Definition: CommandObjectMultiword.h:19
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
Options.h
lldb_private::SymbolContext::symbol
Symbol * symbol
The Symbol for a given query.
Definition: SymbolContext.h:323
lldb_private::ValueObject::GetSummaryFormat
lldb::TypeSummaryImplSP GetSummaryFormat()
Definition: ValueObject.h:717
ScriptAddOptions::ScriptAddOptions
ScriptAddOptions(const TypeSummaryImpl::Flags &flags, bool regx, ConstString name, std::string catg)
Definition: CommandObjectType.cpp:55
lldb_private::TypeFormatImpl::Flags::SetSkipReferences
Flags & SetSkipReferences(bool value=true)
Definition: TypeFormat.h:81
lldb_private::OptionValueLanguage
Definition: OptionValueLanguage.h:18
CommandObjectTypeFormatterClear::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectType.cpp:928
lldb_private::Options
Definition: Options.h:57
CommandObjectTypeFormatterClear
Definition: CommandObjectType.cpp:872
CommandObjectTypeSynthAdd::IOHandlerActivated
void IOHandlerActivated(IOHandler &io_handler, bool interactive) override
Definition: CommandObjectType.cpp:385
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:202
lldb_private::ExecutionContextScope
Definition: ExecutionContextScope.h:32
CommandObjectTypeFormatAdd::m_option_group
OptionGroupOptions m_option_group
Definition: CommandObjectType.cpp:565
ScriptAddOptions::SharedPointer
std::shared_ptr< ScriptAddOptions > SharedPointer
Definition: CommandObjectType.cpp:59
lldb_private::Thread
Definition: Thread.h:61
lldb_private::CommandObjectMultiword::LoadSubCommand
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
Definition: CommandObjectMultiword.cpp:80
OptionValueLanguage.h
LLDB_OPT_SET_1
#define LLDB_OPT_SET_1
Definition: lldb-defines.h:102
lldb_private::CommandReturnObject::SetStatus
void SetStatus(lldb::ReturnStatus status)
Definition: CommandReturnObject.cpp:127
lldb_private::OptionGroupFormat
Definition: OptionGroupFormat.h:24
CommandObjectTypeFormatterList::CommandOptions::m_category_language
OptionValueLanguage m_category_language
Definition: CommandObjectType.cpp:1029
lldb_private::CommandCompletions::InvokeCommonCompletionCallbacks
static bool InvokeCommonCompletionCallbacks(CommandInterpreter &interpreter, uint32_t completion_mask, lldb_private::CompletionRequest &request, SearchFilter *searcher)
Definition: CommandCompletions.cpp:51
CommandObjectTypeFormatterDelete::CommandObjectTypeFormatterDelete
CommandObjectTypeFormatterDelete(CommandInterpreter &interpreter, uint32_t formatter_kind_mask, const char *name, const char *help)
Definition: CommandObjectType.cpp:760
lldb::eExpressionCompleted
@ eExpressionCompleted
Definition: lldb-enumerations.h:271
CommandObjectTypeSummaryAdd::Execute_ScriptSummary
bool Execute_ScriptSummary(Args &command, CommandReturnObject &result)
CommandObjectTypeSummaryAdd::CommandOptions::m_python_function
std::string m_python_function
Definition: CommandObjectType.cpp:127
CommandObjectTypeFormatterList::CommandOptions::CommandOptions
CommandOptions()
Definition: CommandObjectType.cpp:989
lldb_private::OptionGroupFormat::GetFormat
lldb::Format GetFormat() const
Definition: OptionGroupFormat.h:50
lldb_private::CommandReturnObject::GetOutputStream
Stream & GetOutputStream()
Definition: CommandReturnObject.h:46
lldb_private::CommandObject::SetCommandName
void SetCommandName(llvm::StringRef name)
Definition: CommandObject.cpp:84
CommandObjectTypeFormatAdd::CommandObjectTypeFormatAdd
CommandObjectTypeFormatAdd(CommandInterpreter &interpreter)
Definition: CommandObjectType.cpp:572
lldb_private::StringList
Definition: StringList.h:26
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::ValueObject::GetValueFormat
lldb::TypeFormatImplSP GetValueFormat()
Definition: ValueObject.h:732
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::CommandObject::HandleArgumentCompletion
virtual void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector)
The input array contains a parsed version of the line.
Definition: CommandObject.h:248
CommandObjectTypeSummaryAdd::eNamedSummary
@ eNamedSummary
Definition: CommandObjectType.cpp:141
lldb_private::IOHandler
Definition: IOHandler.h:46
lldb_private::Args::entries
llvm::ArrayRef< ArgEntry > entries() const
Definition: Args.h:130
CommandObjectTypeSynthAdd::eRegularSynth
@ eRegularSynth
Definition: CommandObjectType.cpp:482
WarnOnPotentialUnquotedUnsignedType
static bool WarnOnPotentialUnquotedUnsignedType(Args &command, CommandReturnObject &result)
Definition: CommandObjectType.cpp:78
lldb_private::OptionGroupOptions::Finalize
void Finalize()
Definition: Options.cpp:784
lldb_private::CommandObject::GetOptions
virtual Options * GetOptions()
Definition: CommandObject.cpp:100
CommandObjectTypeFormatterList::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectType.cpp:1067
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb_private::eFormatCategoryItemRegexValue
@ eFormatCategoryItemRegexValue
Definition: lldb-private-enumerations.h:138
CommandObjectTypeFormatterList::ShouldListItem
static bool ShouldListItem(llvm::StringRef s, RegularExpression *regex)
Definition: CommandObjectType.cpp:1058
CommandObjectTypeFormatterDelete::CommandOptions::m_category
std::string m_category
Definition: CommandObjectType.cpp:750
CommandObjectTypeSummaryAdd::AddSummary
static bool AddSummary(ConstString type_name, lldb::TypeSummaryImplSP entry, SummaryFormatType type, std::string category, Status *error=nullptr)
CommandObjectTypeSummaryAdd::m_options
CommandOptions m_options
Definition: CommandObjectType.cpp:132
lldb_private::CommandObject::m_interpreter
CommandInterpreter & m_interpreter
Definition: CommandObject.h:368
lldb_private::OptionValueString
Definition: OptionValueString.h:20
lldb_private::CommandObject::GetDefaultThread
Thread * GetDefaultThread()
Definition: CommandObject.cpp:697
SynthAddOptions::m_category
std::string m_category
Definition: CommandObjectType.cpp:69
CommandObjectTypeFormatterClear::FormatterSpecificDeletion
virtual void FormatterSpecificDeletion()
Definition: CommandObjectType.cpp:926
CommandObjectTypeSummaryAdd::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectType.cpp:116
lldb_private::CommandObject::CommandArgumentData::arg_type
lldb::CommandArgumentType arg_type
Definition: CommandObject.h:92
lldb_private::OptionElementVector
std::vector< OptionArgElement > OptionElementVector
Definition: Options.h:42
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
StringList.h
CommandObjectTypeSummaryAdd::Execute_StringSummary
bool Execute_StringSummary(Args &command, CommandReturnObject &result)
Definition: CommandObjectType.cpp:1374
OptionValueString.h
CommandObjectTypeSummaryAdd::CommandOptions
Definition: CommandObjectType.cpp:105
Thread.h
lldb_private::Symbol::GetMangled
Mangled & GetMangled()
Definition: Symbol.h:121
SynthAddOptions::m_skip_pointers
bool m_skip_pointers
Definition: CommandObjectType.cpp:64
lldb_private::CommandObjectRaw
Definition: CommandObject.h:406
ScriptAddOptions
Definition: CommandObjectType.cpp:47
CommandObjectTypeFormatterClear::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectType.cpp:896
lldb_private::SyntheticChildren::SharedPointer
std::shared_ptr< SyntheticChildren > SharedPointer
Definition: TypeSynthetic.h:264
lldb_private::ScriptInterpreter::GenerateTypeSynthClass
virtual bool GenerateTypeSynthClass(StringList &input, std::string &output, const void *name_token=nullptr)
Definition: ScriptInterpreter.h:215
CommandObjectTypeSummaryAdd::SummaryFormatType
SummaryFormatType
Definition: CommandObjectType.cpp:141
CommandObjectTypeFormatterList::FormatterSharedPointer
FormatterType::SharedPointer FormatterSharedPointer
Definition: CommandObjectType.cpp:985
CommandObjectTypeFormatterDelete::HandleArgumentCompletion
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The input array contains a parsed version of the line.
Definition: CommandObjectType.cpp:779
Symbol.h
lldb_private::StringList::CopyList
std::string CopyList(const char *item_preamble=nullptr, const char *items_sep="\n") const
Definition: StringList.cpp:198
lldb_private::CommandObjectRaw::DoExecute
virtual bool DoExecute(llvm::StringRef command, CommandReturnObject &result)=0
CommandObjectTypeFormatterDelete::CommandOptions::m_delete_all
bool m_delete_all
Definition: CommandObjectType.cpp:749
ScriptAddOptions::m_regex
bool m_regex
Definition: CommandObjectType.cpp:51
lldb_private::Status
Definition: Status.h:44
g_synth_addreader_instructions
static const char * g_synth_addreader_instructions
Definition: CommandObjectType.cpp:271
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
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
DataVisualization.h
CommandObjectTypeSynthAdd::CommandOptions::is_class_based
bool is_class_based
Definition: CommandObjectType.cpp:356
CommandObjectTypeFormatterList::CommandObjectTypeFormatterList
CommandObjectTypeFormatterList(CommandInterpreter &interpreter, const char *name, const char *help)
Definition: CommandObjectType.cpp:1037
CommandObjectTypeFormatAdd::m_format_options
OptionGroupFormat m_format_options
Definition: CommandObjectType.cpp:566
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:26
uint32_t
lldb_private::ValueObject::GetSyntheticChildren
lldb::SyntheticChildrenSP GetSyntheticChildren()
Definition: ValueObject.h:744
CommandObjectTypeSynthAdd::Execute_PythonClass
bool Execute_PythonClass(Args &command, CommandReturnObject &result)
lldb_private::TypeFormatImpl::Flags
Definition: TypeFormat.h:26
lldb_private::CommandObject::m_cmd_name
std::string m_cmd_name
Definition: CommandObject.h:371
CommandObject.h
lldb::eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishResult
Definition: lldb-enumerations.h:261
lldb_private::Language
Definition: Language.h:29
CommandObjectTypeFormatterDelete::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectType.cpp:737
CommandObjectTypeFormatterClear::CommandObjectTypeFormatterClear
CommandObjectTypeFormatterClear(CommandInterpreter &interpreter, uint32_t formatter_kind_mask, const char *name, const char *help)
Definition: CommandObjectType.cpp:914
CommandObjectTypeFormatAdd::CommandOptions::m_custom_type_name
std::string m_custom_type_name
Definition: CommandObjectType.cpp:562
lldb_private::CommandReturnObject::AppendWarning
void void AppendWarning(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:94
CommandObjectTypeSynthAdd::eRegexSynth
@ eRegexSynth
Definition: CommandObjectType.cpp:482
lldb_private::ScriptedSyntheticChildren::GetPythonClassName
const char * GetPythonClassName()
Definition: TypeSynthetic.h:401
CommandObjectTypeFormatterList::m_options
CommandOptions m_options
Definition: CommandObjectType.cpp:1032
lldb::eArgTypeName
@ eArgTypeName
Definition: lldb-enumerations.h:551
lldb_private::CommandReturnObject::AppendMessageWithFormat
void AppendMessageWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:64
lldb_private::StackFrame::GuessLanguage
lldb::LanguageType GuessLanguage()
Definition: StackFrame.cpp:1207
lldb_private::eFormatCategoryItemRegexSynth
@ eFormatCategoryItemRegexSynth
Definition: lldb-private-enumerations.h:136
CommandObjectTypeSummaryAdd::CommandOptions::m_category
std::string m_category
Definition: CommandObjectType.cpp:129
CommandObjectTypeSummaryAdd::eRegexSummary
@ eRegexSummary
Definition: CommandObjectType.cpp:141
CommandObjectTypeSummaryAdd::CommandOptions::m_python_script
std::string m_python_script
Definition: CommandObjectType.cpp:126
lldb_private::formatters::AddFilter
void AddFilter(TypeCategoryImpl::SharedPointer category_sp, std::vector< std::string > children, const char *description, ConstString type_name, ScriptedSyntheticChildren::Flags flags, bool regex=false)
Definition: FormattersHelpers.cpp:104
FixArrayTypeNameWithRegex
static bool FixArrayTypeNameWithRegex(ConstString &type_name)
Definition: CommandObjectType.cpp:1507
CommandObjectTypeSynthAdd::CommandOptions
Definition: CommandObjectType.cpp:288
CommandObjectTypeFormatterDelete::FormatterSpecificDeletion
virtual bool FormatterSpecificDeletion(ConstString typeCS)
Definition: CommandObjectType.cpp:812
CommandObjectTypeFormatterList::GetOptions
Options * GetOptions() override
Definition: CommandObjectType.cpp:1034
CommandObjectTypeFormatClear
Definition: CommandObjectType.cpp:971
CommandObjectTypeSummaryAdd::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectType.cpp:1491
lldb_private::CommandReturnObject::AppendWarningWithFormat
void AppendWarningWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:76
lldb_private::IOHandler::GetUserData
void * GetUserData()
Definition: IOHandler.h:139
lldb_private::Thread::GetSelectedFrame
lldb::StackFrameSP GetSelectedFrame()
Definition: Thread.cpp:266
CommandObjectTypeFormatAdd::CommandOptions::m_skip_references
bool m_skip_references
Definition: CommandObjectType.cpp:558
lldb_private::CommandObject::SetSyntax
void SetSyntax(llvm::StringRef str)
Definition: CommandObject.cpp:96
if
if(APPLE AND LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY) remove_module_flags() endif() macro(add_host_subdirectory group) list(APPEND HOST_SOURCES $
Definition: Host/CMakeLists.txt:1
CommandObjectTypeFormatterDelete::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectType.cpp:743
lldb_private::TypeSummaryImpl::SharedPointer
std::shared_ptr< TypeSummaryImpl > SharedPointer
Definition: TypeSummary.h:263
CommandObjectTypeFormatAdd::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
Definition: CommandObjectType.cpp:519
CommandObjectTypeSynthAdd::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectType.cpp:344
lldb_private::OptionsWithRaw
Definition: Args.h:319
CommandObjectTypeSynthAdd::CommandOptions::m_cascade
bool m_cascade
Definition: CommandObjectType.cpp:350
CommandObjectTypeFormatAdd
Definition: CommandObjectType.cpp:498
lldb_private::DataVisualization::Categories::ForEach
static void ForEach(TypeCategoryMap::ForEachCallback callback)
Definition: DataVisualization.cpp:156
lldb_private::DataVisualization::Categories::EnableStar
static void EnableStar()
Definition: DataVisualization.cpp:148
CommandObjectTypeFormatterDelete::GetOptions
Options * GetOptions() override
Definition: CommandObjectType.cpp:757
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
CommandObjectTypeFormatterDelete::m_options
CommandOptions m_options
Definition: CommandObjectType.cpp:754
CommandObjectTypeFormatterList
Definition: CommandObjectType.cpp:984
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:126
CommandObjectTypeFormatAdd::GetOptions
Options * GetOptions() override
Definition: CommandObjectType.cpp:569
CommandObjectTypeFormatterList::CommandOptions
Definition: CommandObjectType.cpp:987
lldb_private::IOHandler::SetIsDone
void SetIsDone(bool b)
Definition: IOHandler.h:90
lldb_private::CommandObject::GetCommandInterpreter
CommandInterpreter & GetCommandInterpreter()
Definition: CommandObject.h:122
CommandObjectTypeFormatterDelete::CommandOptions::m_language
lldb::LanguageType m_language
Definition: CommandObjectType.cpp:751
lldb_private::CommandObject::m_cmd_help_long
std::string m_cmd_help_long
Definition: CommandObject.h:373
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
CommandObjectTypeSynthAdd::GetOptions
Options * GetOptions() override
Definition: CommandObjectType.cpp:363
CommandObjectTypeFormatterClear::CommandOptions::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectType.cpp:900
lldb_private::CommandReturnObject::AppendErrorWithFormat
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:46
OptionParser.h
lldb_private::OptionGroupOptions::Append
void Append(OptionGroup *group)
Append options from a OptionGroup class.
Definition: Options.cpp:755
lldb_private::CompletionRequest::GetCursorIndex
size_t GetCursorIndex() const
Definition: CompletionRequest.h:156
CommandObjectTypeSynthAdd::CommandOptions::m_class_name
std::string m_class_name
Definition: CommandObjectType.cpp:353
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
CommandObjectTypeSynthAdd::IOHandlerInputComplete
void IOHandlerInputComplete(IOHandler &io_handler, std::string &data) override
Called when a line or lines have been retrieved.
Definition: CommandObjectType.cpp:393
lldb_private::Debugger::GetSelectedTarget
lldb::TargetSP GetSelectedTarget()
Definition: Debugger.h:190
lldb_private::ScriptInterpreter::GenerateTypeScriptFunction
virtual bool GenerateTypeScriptFunction(const char *oneliner, std::string &output, const void *name_token=nullptr)
Definition: ScriptInterpreter.h:198
lldb_private::TypeCategoryImpl::ForEachCallbacks
Definition: TypeCategory.h:86
CommandObjectTypeFormatterDelete::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectType.cpp:715
lldb_private::SyntheticChildren::Flags::SetSkipPointers
Flags & SetSkipPointers(bool value=true)
Definition: TypeSynthetic.h:176
lldb_private::CommandObjectParsed::DoExecute
virtual bool DoExecute(Args &command, CommandReturnObject &result)=0
CommandObjectTypeFormatterClear::CommandOptions::m_delete_all
bool m_delete_all
Definition: CommandObjectType.cpp:905
lldb_private::RegularExpression::Execute
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
Definition: RegularExpression.cpp:23
lldb_private::eFormatCategoryItemRegexSummary
@ eFormatCategoryItemRegexSummary
Definition: lldb-private-enumerations.h:132
CommandInterpreter.h
lldb_private::CommandInterpreter::GetExecutionContext
ExecutionContext GetExecutionContext() const
ConstString.h
lldb_private::Args::empty
bool empty() const
Definition: Args.h:120
CommandObjectTypeSummaryAdd::CommandOptions::m_is_add_script
bool m_is_add_script
Definition: CommandObjectType.cpp:128
CommandOptionArgumentTable.h
lldb_private::eFormatCategoryItemValue
@ eFormatCategoryItemValue
Definition: lldb-private-enumerations.h:137
lldb_private::TypeFormatImpl::Flags::SetCascades
Flags & SetCascades(bool value=true)
Definition: TypeFormat.h:55
lldb_private::StringSummaryFormat
Definition: TypeSummary.h:278
lldb_private::TypeFormatImpl::SharedPointer
std::shared_ptr< TypeFormatImpl > SharedPointer
Definition: TypeFormat.h:112
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::DataVisualization::Categories::DisableStar
static void DisableStar()
Definition: DataVisualization.cpp:152
OptionValueBoolean.h
CommandObjectTypeFormatterClear::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectType.cpp:880
CommandObjectTypeFormatList::CommandObjectTypeFormatList
CommandObjectTypeFormatList(CommandInterpreter &interpreter)
Definition: CommandObjectType.cpp:1169
CHECK_FORMATTER_KIND_MASK
#define CHECK_FORMATTER_KIND_MASK(VAL)
Definition: CommandObjectType.cpp:41
lldb_private::TypeCategoryImpl::ForEachCallbacks::SetExact
std::enable_if< std::is_same< U, T >::value, ForEachCallbacks & >::type SetExact(FormatContainer::ExactMatchForEachCallback callback)
Definition: TypeCategory.h:93
lldb_private::Language::ForEach
static void ForEach(std::function< bool(Language *)> callback)
Definition: Language.cpp:100
lldb_private::RegularExpression::GetText
llvm::StringRef GetText() const
Access the regular expression text.
Definition: RegularExpression.cpp:33
SynthAddOptions
Definition: CommandObjectType.cpp:62
lldb_private::CommandObject::CommandArgumentEntry
std::vector< CommandArgumentData > CommandArgumentEntry
Definition: CommandObject.h:106
CommandObjectTypeSynthAdd::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectType.cpp:333
lldb_private::CommandReturnObject::AppendError
void void AppendError(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:100
lldb_private::TypeFormatImpl::Flags::SetSkipPointers
Flags & SetSkipPointers(bool value=true)
Definition: TypeFormat.h:68
lldb_private::StackFrame
Definition: StackFrame.h:40
CommandObjectTypeSynthAdd::Execute_HandwritePython
bool Execute_HandwritePython(Args &command, CommandReturnObject &result)
lldb_private::Args::GetArgumentCount
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:118
CommandObjectTypeSynthAdd::CommandOptions::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
Definition: CommandObjectType.cpp:294
lldb
Definition: SBAddress.h:15
CommandObjectTypeFormatDelete::CommandObjectTypeFormatDelete
CommandObjectTypeFormatDelete(CommandInterpreter &interpreter)
Definition: CommandObjectType.cpp:959
CommandObjectTypeSynthAdd::CommandOptions::m_skip_references
bool m_skip_references
Definition: CommandObjectType.cpp:351
lldb_private::TypeMatcher::GetMatchString
ConstString GetMatchString() const
Returns the underlying match string for this TypeMatcher.
Definition: FormattersContainer.h:88
lldb_private::formatters::AddSummary
void AddSummary(TypeCategoryImpl::SharedPointer category_sp, lldb::TypeSummaryImplSP summary_sp, ConstString type_name, bool regex=false)
lldb_private::IOHandler::GetOutputStreamFileSP
lldb::StreamFileSP GetOutputStreamFileSP()
Definition: IOHandler.cpp:109
SynthAddOptions::m_skip_references
bool m_skip_references
Definition: CommandObjectType.cpp:65
lldb_private::StackFrame::GetSymbolContext
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:299
CommandObjectTypeSummaryAdd::eRegularSummary
@ eRegularSummary
Definition: CommandObjectType.cpp:141
CommandObjectTypeSummaryAdd::CommandOptions::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectType.cpp:1239
SynthAddOptions::m_regex
bool m_regex
Definition: CommandObjectType.cpp:67
lldb_private::IOHandlerDelegateMultiline
Definition: IOHandler.h:300
lldb_private::IOHandler::GetErrorStreamFileSP
lldb::StreamFileSP GetErrorStreamFileSP()
Definition: IOHandler.cpp:111
CommandObjectTypeSynthAdd::CommandOptions::m_category
std::string m_category
Definition: CommandObjectType.cpp:355
CommandObjectTypeSummaryAdd::CommandOptions::m_flags
TypeSummaryImpl::Flags m_flags
Definition: CommandObjectType.cpp:122
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
lldb::eFormatInvalid
@ eFormatInvalid
Definition: lldb-enumerations.h:157
lldb_private::CommandObject::GetDebugger
Debugger & GetDebugger()
Definition: CommandObject.cpp:53
CommandObjectType.h