/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
Line | Count | Source |
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_DATAFORMATTERS_VALUEOBJECTPRINTER_H |
11 | | #define LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H |
12 | | |
13 | | #include "lldb/lldb-private.h" |
14 | | #include "lldb/lldb-public.h" |
15 | | |
16 | | #include "lldb/Utility/Flags.h" |
17 | | |
18 | | #include "lldb/DataFormatters/DumpValueObjectOptions.h" |
19 | | #include "lldb/Symbol/CompilerType.h" |
20 | | |
21 | | namespace lldb_private { |
22 | | |
23 | | class ValueObjectPrinter { |
24 | | public: |
25 | | ValueObjectPrinter(ValueObject *valobj, Stream *s); |
26 | | |
27 | | ValueObjectPrinter(ValueObject *valobj, Stream *s, |
28 | | const DumpValueObjectOptions &options); |
29 | | |
30 | 38.0k | ~ValueObjectPrinter() = default; |
31 | | |
32 | | bool PrintValueObject(); |
33 | | |
34 | | protected: |
35 | | typedef std::set<uint64_t> InstancePointersSet; |
36 | | typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP; |
37 | | |
38 | | InstancePointersSetSP m_printed_instance_pointers; |
39 | | |
40 | | // only this class (and subclasses, if any) should ever be concerned with the |
41 | | // depth mechanism |
42 | | ValueObjectPrinter(ValueObject *valobj, Stream *s, |
43 | | const DumpValueObjectOptions &options, |
44 | | const DumpValueObjectOptions::PointerDepth &ptr_depth, |
45 | | uint32_t curr_depth, |
46 | | InstancePointersSetSP printed_instance_pointers); |
47 | | |
48 | | // we should actually be using delegating constructors here but some versions |
49 | | // of GCC still have trouble with those |
50 | | void Init(ValueObject *valobj, Stream *s, |
51 | | const DumpValueObjectOptions &options, |
52 | | const DumpValueObjectOptions::PointerDepth &ptr_depth, |
53 | | uint32_t curr_depth, |
54 | | InstancePointersSetSP printed_instance_pointers); |
55 | | |
56 | | bool GetMostSpecializedValue(); |
57 | | |
58 | | const char *GetDescriptionForDisplay(); |
59 | | |
60 | | const char *GetRootNameForDisplay(); |
61 | | |
62 | | bool ShouldPrintValueObject(); |
63 | | |
64 | | bool IsNil(); |
65 | | |
66 | | bool IsUninitialized(); |
67 | | |
68 | | bool IsPtr(); |
69 | | |
70 | | bool IsRef(); |
71 | | |
72 | | bool IsInstancePointer(); |
73 | | |
74 | | bool IsAggregate(); |
75 | | |
76 | | bool PrintLocationIfNeeded(); |
77 | | |
78 | | void PrintDecl(); |
79 | | |
80 | | bool CheckScopeIfNeeded(); |
81 | | |
82 | | bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed); |
83 | | |
84 | | TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true); |
85 | | |
86 | | void GetValueSummaryError(std::string &value, std::string &summary, |
87 | | std::string &error); |
88 | | |
89 | | bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed); |
90 | | |
91 | | bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed); |
92 | | |
93 | | bool |
94 | | ShouldPrintChildren(DumpValueObjectOptions::PointerDepth &curr_ptr_depth); |
95 | | |
96 | | bool ShouldExpandEmptyAggregates(); |
97 | | |
98 | | ValueObject *GetValueObjectForChildrenGeneration(); |
99 | | |
100 | | void PrintChildrenPreamble(bool value_printed, bool summary_printed); |
101 | | |
102 | | void PrintChildrenPostamble(bool print_dotdotdot); |
103 | | |
104 | | lldb::ValueObjectSP GenerateChild(ValueObject *synth_valobj, size_t idx); |
105 | | |
106 | | void PrintChild(lldb::ValueObjectSP child_sp, |
107 | | const DumpValueObjectOptions::PointerDepth &curr_ptr_depth); |
108 | | |
109 | | uint32_t GetMaxNumChildrenToPrint(bool &print_dotdotdot); |
110 | | |
111 | | void |
112 | | PrintChildren(bool value_printed, bool summary_printed, |
113 | | const DumpValueObjectOptions::PointerDepth &curr_ptr_depth); |
114 | | |
115 | | void PrintChildrenIfNeeded(bool value_printed, bool summary_printed); |
116 | | |
117 | | bool PrintChildrenOneLiner(bool hide_names); |
118 | | |
119 | | bool HasReachedMaximumDepth(); |
120 | | |
121 | | private: |
122 | | bool ShouldShowName() const; |
123 | | |
124 | | ValueObject *m_orig_valobj; |
125 | | ValueObject *m_valobj; |
126 | | Stream *m_stream; |
127 | | DumpValueObjectOptions m_options; |
128 | | Flags m_type_flags; |
129 | | CompilerType m_compiler_type; |
130 | | DumpValueObjectOptions::PointerDepth m_ptr_depth; |
131 | | uint32_t m_curr_depth; |
132 | | LazyBool m_should_print; |
133 | | LazyBool m_is_nil; |
134 | | LazyBool m_is_uninit; |
135 | | LazyBool m_is_ptr; |
136 | | LazyBool m_is_ref; |
137 | | LazyBool m_is_aggregate; |
138 | | LazyBool m_is_instance_ptr; |
139 | | std::pair<TypeSummaryImpl *, bool> m_summary_formatter; |
140 | | std::string m_value; |
141 | | std::string m_summary; |
142 | | std::string m_error; |
143 | | bool m_val_summary_ok; |
144 | | |
145 | | friend struct StringSummaryFormat; |
146 | | |
147 | | ValueObjectPrinter(const ValueObjectPrinter &) = delete; |
148 | | const ValueObjectPrinter &operator=(const ValueObjectPrinter &) = delete; |
149 | | }; |
150 | | |
151 | | } // namespace lldb_private |
152 | | |
153 | | #endif // LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H |