LLDB mainline
ValueObjectPrinter.h
Go to the documentation of this file.
1//===-- ValueObjectPrinter.h ------------------------------------*- C++ -*-===//
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#ifndef LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H
10#define LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H
11
12#include "lldb/lldb-private.h"
13#include "lldb/lldb-public.h"
14
15#include "lldb/Utility/Flags.h"
16
19
20namespace lldb_private {
21
23 /// The ValueObjectPrinter is a one-shot printer for ValueObjects. It
24 /// does not retain the ValueObject it is printing, that is the job of
25 /// its caller. It also doesn't attempt to track changes in the
26 /// ValueObject, e.g. changing synthetic child providers or changing
27 /// dynamic versus static versus synthetic settings.
28public:
30
32 const DumpValueObjectOptions &options);
33
35
36 llvm::Error PrintValueObject();
37
38protected:
39 typedef std::set<uint64_t> InstancePointersSet;
40 typedef std::shared_ptr<InstancePointersSet> InstancePointersSetSP;
41
43
44 /// Only this class (and subclasses, if any) should ever be
45 /// concerned with the depth mechanism.
47 const DumpValueObjectOptions &options,
49 uint32_t curr_depth,
50 InstancePointersSetSP printed_instance_pointers);
51
52 /// Ee should actually be using delegating constructors here but
53 /// some versions of GCC still have trouble with those.
54 void Init(ValueObject &valobj, Stream *s,
55 const DumpValueObjectOptions &options,
57 uint32_t curr_depth,
58 InstancePointersSetSP printed_instance_pointers);
59
60 /// Cache the ValueObject we are actually going to print. If this
61 /// ValueObject has a Dynamic type, we return that, if either the original
62 /// ValueObject or its Dynamic type has a Synthetic provider, return that.
63 /// This will never return an empty ValueObject, since we use the ValueObject
64 /// to carry errors.
65 /// Note, this gets called when making the printer object, and uses the
66 /// use dynamic and use synthetic settings of the ValueObject being printed,
67 /// so changes made to these settings won't affect already made
68 /// ValueObjectPrinters. SetupMostSpecializedValue();
69 ///
70 /// Access the cached "most specialized value" - that is the one to use for
71 /// printing the value object's value. However, be sure to use
72 /// GetValueForChildGeneration when you are generating the children of this
73 /// value.
75
77
78 llvm::Expected<std::string> GetDescriptionForDisplay();
79
80 const char *GetRootNameForDisplay();
81
83
84 bool IsNil();
85
86 bool IsUninitialized();
87
88 bool IsPtr();
89
90 bool IsRef();
91
92 bool IsInstancePointer();
93
94 bool IsAggregate();
95
97
98 void PrintDecl();
99
100 bool CheckScopeIfNeeded();
101
102 bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed);
103
104 TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true);
105
106 void GetValueSummaryError(std::string &value, std::string &summary,
107 std::string &error);
108
109 bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed);
110
111 llvm::Error PrintObjectDescriptionIfNeeded(bool value_printed,
112 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 llvm::Error PrintChildrenIfNeeded(bool value_printed, bool summary_printed);
137
138 bool PrintChildrenOneLiner(bool hide_names);
139
141
142private:
143 bool ShouldShowName() const;
144
146 /// Cache the current "most specialized" value. Don't use this
147 /// directly, use 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
llvm::Expected< std::string > GetDescriptionForDisplay()
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.
llvm::Error PrintObjectDescriptionIfNeeded(bool value_printed, bool summary_printed)
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
llvm::Error PrintChildrenIfNeeded(bool value_printed, bool summary_printed)
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)
Ee should actually be using delegating constructors here but some versions of GCC still have trouble ...
void PrintChildren(bool value_printed, bool summary_printed, const DumpValueObjectOptions::PointerDepth &curr_ptr_depth)
bool PrintChildrenOneLiner(bool hide_names)
ValueObject * m_cached_valobj
Cache the current "most specialized" value.
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.
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
Definition: lldb-forward.h:480