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