LLDB  mainline
ValueObjectPrinter.h
Go to the documentation of this file.
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 
10 #ifndef lldb_ValueObjectPrinter_h_
11 #define lldb_ValueObjectPrinter_h_
12 
13 
14 #include "lldb/lldb-private.h"
15 #include "lldb/lldb-public.h"
16 
17 #include "lldb/Utility/Flags.h"
18 
21 
22 namespace lldb_private {
23 
25 public:
27 
29  const DumpValueObjectOptions &options);
30 
32 
33  bool PrintValueObject();
34 
35 protected:
36  typedef std::set<uint64_t> InstancePointersSet;
37  typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
38 
39  InstancePointersSetSP m_printed_instance_pointers;
40 
41  // only this class (and subclasses, if any) should ever be concerned with the
42  // depth mechanism
44  const DumpValueObjectOptions &options,
45  const DumpValueObjectOptions::PointerDepth &ptr_depth,
46  uint32_t curr_depth,
47  InstancePointersSetSP printed_instance_pointers);
48 
49  // we should actually be using delegating constructors here but some versions
50  // of GCC still have trouble with those
51  void Init(ValueObject *valobj, Stream *s,
52  const DumpValueObjectOptions &options,
53  const DumpValueObjectOptions::PointerDepth &ptr_depth,
54  uint32_t curr_depth,
55  InstancePointersSetSP printed_instance_pointers);
56 
58 
59  const char *GetDescriptionForDisplay();
60 
61  const char *GetRootNameForDisplay(const char *if_fail = nullptr);
62 
64 
65  bool ShouldPrintValidation();
66 
67  bool IsNil();
68 
69  bool IsUninitialized();
70 
71  bool IsPtr();
72 
73  bool IsRef();
74 
75  bool IsInstancePointer();
76 
77  bool IsAggregate();
78 
80 
82 
83  bool PrintLocationIfNeeded();
84 
85  void PrintDecl();
86 
87  bool CheckScopeIfNeeded();
88 
89  bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed);
90 
91  TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true);
92 
93  void GetValueSummaryError(std::string &value, std::string &summary,
94  std::string &error);
95 
96  bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed);
97 
98  bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed);
99 
100  bool
101  ShouldPrintChildren(bool is_failed_description,
102  DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
103 
105 
107 
108  void PrintChildrenPreamble();
109 
110  void PrintChildrenPostamble(bool print_dotdotdot);
111 
112  lldb::ValueObjectSP GenerateChild(ValueObject *synth_valobj, size_t idx);
113 
114  void PrintChild(lldb::ValueObjectSP child_sp,
115  const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
116 
117  uint32_t GetMaxNumChildrenToPrint(bool &print_dotdotdot);
118 
119  void
120  PrintChildren(bool value_printed, bool summary_printed,
121  const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
122 
123  void PrintChildrenIfNeeded(bool value_printed, bool summary_printed);
124 
125  bool PrintChildrenOneLiner(bool hide_names);
126 
127 private:
128  ValueObject *m_orig_valobj;
129  ValueObject *m_valobj;
130  Stream *m_stream;
131  DumpValueObjectOptions m_options;
132  Flags m_type_flags;
133  CompilerType m_compiler_type;
135  uint32_t m_curr_depth;
136  LazyBool m_should_print;
137  LazyBool m_is_nil;
138  LazyBool m_is_uninit;
139  LazyBool m_is_ptr;
140  LazyBool m_is_ref;
141  LazyBool m_is_aggregate;
142  LazyBool m_is_instance_ptr;
143  std::pair<TypeSummaryImpl *, bool> m_summary_formatter;
144  std::string m_value;
145  std::string m_summary;
146  std::string m_error;
147  bool m_val_summary_ok;
148  std::pair<TypeValidatorResult, std::string> m_validation;
149 
150  friend struct StringSummaryFormat;
151 
152  DISALLOW_COPY_AND_ASSIGN(ValueObjectPrinter);
153 };
154 
155 } // namespace lldb_private
156 
157 #endif // lldb_ValueObjectPrinter_h_
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
void PrintChildrenIfNeeded(bool value_printed, bool summary_printed)
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
void PrintChild(lldb::ValueObjectSP child_sp, const DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
const char * GetRootNameForDisplay(const char *if_fail=nullptr)
std::shared_ptr< InstancePointersSet > InstancePointersSetSP
ValueObjectPrinter(ValueObject *valobj, Stream *s)
bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed)
bool ShouldPrintChildren(bool is_failed_description, DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
lldb::ValueObjectSP GenerateChild(ValueObject *synth_valobj, size_t idx)
void Init(ValueObject *valobj, Stream *s, const DumpValueObjectOptions &options, const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth, InstancePointersSetSP printed_instance_pointers)
void GetValueSummaryError(std::string &value, std::string &summary, std::string &error)
std::set< uint64_t > InstancePointersSet
InstancePointersSetSP m_printed_instance_pointers
bool PrintChildrenOneLiner(bool hide_names)
A class to manage flags.
Definition: Flags.h:22
bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed)
bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed)
uint32_t GetMaxNumChildrenToPrint(bool &print_dotdotdot)
void PrintChildrenPostamble(bool print_dotdotdot)
void PrintChildren(bool value_printed, bool summary_printed, const DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
TypeSummaryImpl * GetSummaryFormatter(bool null_if_omitted=true)