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_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
20
21namespace lldb_private {
22
24 /// The ValueObjectPrinter is a one-shot printer for ValueObjects. It
25 /// does not retain the ValueObject it is printing, that is the job of
26 /// its caller. It also doesn't attempt to track changes in the
27 /// ValueObject, e.g. changing synthetic child providers or changing
28 /// dynamic vrs. static vrs. synthetic settings.
29public:
31
33 const DumpValueObjectOptions &options);
34
36
37 bool PrintValueObject();
38
39protected:
40 typedef std::set<uint64_t> InstancePointersSet;
41 typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
42
44
45 // only this class (and subclasses, if any) should ever be concerned with the
46 // depth mechanism
48 const DumpValueObjectOptions &options,
50 uint32_t curr_depth,
51 InstancePointersSetSP printed_instance_pointers);
52
53 // we should actually be using delegating constructors here but some versions
54 // of GCC still have trouble with those
55 void Init(ValueObject &valobj, Stream *s,
56 const DumpValueObjectOptions &options,
58 uint32_t curr_depth,
59 InstancePointersSetSP printed_instance_pointers);
60
61 /// Cache the ValueObject we are actually going to print. If this
62 /// ValueObject has a Dynamic type, we return that, if either the original
63 /// ValueObject or its Dynamic type has a Synthetic provider, return that.
64 /// This will never return an empty ValueObject, since we use the ValueObject
65 /// to carry errors.
66 /// Note, this gets called when making the printer object, and uses the
67 /// use dynamic and use synthetic settings of the ValueObject being printed,
68 /// so changes made to these settings won't affect already made
69 /// ValueObjectPrinters. SetupMostSpecializedValue();
70
71 /// Access the cached "most specialized value" - that is the one to use for
72 /// printing the value object's value. However, be sure to use
73 /// GetValueForChildGeneration when you are generating the children of this
74 /// value.
76
78
79 const char *GetDescriptionForDisplay();
80
81 const char *GetRootNameForDisplay();
82
84
85 bool IsNil();
86
87 bool IsUninitialized();
88
89 bool IsPtr();
90
91 bool IsRef();
92
93 bool IsInstancePointer();
94
95 bool IsAggregate();
96
98
99 void PrintDecl();
100
101 bool CheckScopeIfNeeded();
102
103 bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed);
104
105 TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true);
106
107 void GetValueSummaryError(std::string &value, std::string &summary,
108 std::string &error);
109
110 bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed);
111
112 bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed);
113
114 bool
116
118
120
121 void PrintChildrenPreamble(bool value_printed, bool summary_printed);
122
123 void PrintChildrenPostamble(bool print_dotdotdot);
124
125 lldb::ValueObjectSP GenerateChild(ValueObject &synth_valobj, size_t idx);
126
127 void PrintChild(lldb::ValueObjectSP child_sp,
128 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
129
130 llvm::Expected<uint32_t> GetMaxNumChildrenToPrint(bool &print_dotdotdot);
131
132 void
133 PrintChildren(bool value_printed, bool summary_printed,
134 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
135
136 void PrintChildrenIfNeeded(bool value_printed, bool summary_printed);
137
138 bool PrintChildrenOneLiner(bool hide_names);
139
141
142private:
143 bool ShouldShowName() const;
144
146 ValueObject *m_cached_valobj; /// Cache the current "most specialized" value.
147 /// Don't use this directly, use
148 /// GetMostSpecializedValue.
154 uint32_t m_curr_depth;
162 std::pair<TypeSummaryImpl *, bool> m_summary_formatter;
163 std::string m_value;
164 std::string m_summary;
165 std::string m_error;
167
168 friend struct StringSummaryFormat;
169
172};
173
174} // namespace lldb_private
175
176#endif // LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H
static llvm::raw_ostream & error(Stream &strm)
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
A class to manage flags.
Definition: Flags.h:22
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
bool PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed)
void PrintChildrenPreamble(bool value_printed, bool summary_printed)
std::shared_ptr< InstancePointersSet > InstancePointersSetSP
std::pair< TypeSummaryImpl *, bool > m_summary_formatter
void PrintChild(lldb::ValueObjectSP child_sp, const DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
TypeSummaryImpl * GetSummaryFormatter(bool null_if_omitted=true)
ValueObject & GetMostSpecializedValue()
Cache the ValueObject we are actually going to print.
void PrintChildrenIfNeeded(bool value_printed, bool summary_printed)
Stream * m_stream
Cache the current "most specialized" value.
bool ShouldPrintChildren(DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
const ValueObjectPrinter & operator=(const ValueObjectPrinter &)=delete
DumpValueObjectOptions::PointerDepth m_ptr_depth
void PrintChildrenPostamble(bool print_dotdotdot)
ValueObjectPrinter(const ValueObjectPrinter &)=delete
lldb::ValueObjectSP GenerateChild(ValueObject &synth_valobj, size_t idx)
InstancePointersSetSP m_printed_instance_pointers
void Init(ValueObject &valobj, Stream *s, const DumpValueObjectOptions &options, const DumpValueObjectOptions::PointerDepth &ptr_depth, uint32_t curr_depth, InstancePointersSetSP printed_instance_pointers)
void PrintChildren(bool value_printed, bool summary_printed, const DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
bool PrintChildrenOneLiner(bool hide_names)
std::set< uint64_t > InstancePointersSet
void GetValueSummaryError(std::string &value, std::string &summary, std::string &error)
bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed)
llvm::Expected< uint32_t > GetMaxNumChildrenToPrint(bool &print_dotdotdot)
bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed)
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:472