ValueObjectPrinter.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //===-- ValueObjectPrinter.h ---------------------------------------*- C++
  2. //-*-===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H
  10. #define LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H
  11. #include "lldb/lldb-private.h"
  12. #include "lldb/lldb-public.h"
  13. #include "lldb/Utility/Flags.h"
  14. #include "lldb/DataFormatters/DumpValueObjectOptions.h"
  15. #include "lldb/Symbol/CompilerType.h"
  16. namespace lldb_private {
  17. class ValueObjectPrinter {
  18. public:
  19. ValueObjectPrinter(ValueObject *valobj, Stream *s);
  20. ValueObjectPrinter(ValueObject *valobj, Stream *s,
  21. const DumpValueObjectOptions &options);
  22. ~ValueObjectPrinter() {}
  23. bool PrintValueObject();
  24. protected:
  25. typedef std::set<uint64_t> InstancePointersSet;
  26. typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
  27. InstancePointersSetSP m_printed_instance_pointers;
  28. // only this class (and subclasses, if any) should ever be concerned with the
  29. // depth mechanism
  30. ValueObjectPrinter(ValueObject *valobj, Stream *s,
  31. const DumpValueObjectOptions &options,
  32. const DumpValueObjectOptions::PointerDepth &ptr_depth,
  33. uint32_t curr_depth,
  34. InstancePointersSetSP printed_instance_pointers);
  35. // we should actually be using delegating constructors here but some versions
  36. // of GCC still have trouble with those
  37. void Init(ValueObject *valobj, Stream *s,
  38. const DumpValueObjectOptions &options,
  39. const DumpValueObjectOptions::PointerDepth &ptr_depth,
  40. uint32_t curr_depth,
  41. InstancePointersSetSP printed_instance_pointers);
  42. bool GetMostSpecializedValue();
  43. const char *GetDescriptionForDisplay();
  44. const char *GetRootNameForDisplay();
  45. bool ShouldPrintValueObject();
  46. bool IsNil();
  47. bool IsUninitialized();
  48. bool IsPtr();
  49. bool IsRef();
  50. bool IsInstancePointer();
  51. bool IsAggregate();
  52. bool PrintLocationIfNeeded();
  53. void PrintDecl();
  54. bool CheckScopeIfNeeded();
  55. bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed);
  56. TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true);
  57. void GetValueSummaryError(std::string &value, std::string &summary,
  58. std::string &error);
  59. bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed);
  60. bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed);
  61. bool
  62. ShouldPrintChildren(bool is_failed_description,
  63. DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
  64. bool ShouldExpandEmptyAggregates();
  65. ValueObject *GetValueObjectForChildrenGeneration();
  66. void PrintChildrenPreamble();
  67. void PrintChildrenPostamble(bool print_dotdotdot);
  68. lldb::ValueObjectSP GenerateChild(ValueObject *synth_valobj, size_t idx);
  69. void PrintChild(lldb::ValueObjectSP child_sp,
  70. const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
  71. uint32_t GetMaxNumChildrenToPrint(bool &print_dotdotdot);
  72. void
  73. PrintChildren(bool value_printed, bool summary_printed,
  74. const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
  75. void PrintChildrenIfNeeded(bool value_printed, bool summary_printed);
  76. bool PrintChildrenOneLiner(bool hide_names);
  77. private:
  78. ValueObject *m_orig_valobj;
  79. ValueObject *m_valobj;
  80. Stream *m_stream;
  81. DumpValueObjectOptions m_options;
  82. Flags m_type_flags;
  83. CompilerType m_compiler_type;
  84. DumpValueObjectOptions::PointerDepth m_ptr_depth;
  85. uint32_t m_curr_depth;
  86. LazyBool m_should_print;
  87. LazyBool m_is_nil;
  88. LazyBool m_is_uninit;
  89. LazyBool m_is_ptr;
  90. LazyBool m_is_ref;
  91. LazyBool m_is_aggregate;
  92. LazyBool m_is_instance_ptr;
  93. std::pair<TypeSummaryImpl *, bool> m_summary_formatter;
  94. std::string m_value;
  95. std::string m_summary;
  96. std::string m_error;
  97. bool m_val_summary_ok;
  98. friend struct StringSummaryFormat;
  99. ValueObjectPrinter(const ValueObjectPrinter &) = delete;
  100. const ValueObjectPrinter &operator=(const ValueObjectPrinter &) = delete;
  101. };
  102. } // namespace lldb_private
  103. #endif // LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H