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 const char *GetRootNameForDisplay();
79
81
82 bool IsNil();
83
84 bool IsUninitialized();
85
86 bool IsPtr();
87
88 bool IsRef();
89
90 bool IsInstancePointer();
91
92 bool IsAggregate();
93
95
96 void PrintDecl();
97
98 bool CheckScopeIfNeeded();
99
100 bool ShouldPrintEmptyBrackets(bool value_printed, bool summary_printed);
101
102 TypeSummaryImpl *GetSummaryFormatter(bool null_if_omitted = true);
103
104 void GetValueSummaryError(std::string &value, std::string &summary,
105 std::string &error);
106
107 bool PrintValueAndSummaryIfNeeded(bool &value_printed, bool &summary_printed);
108
109 void PrintObjectDescriptionIfNeeded(std::optional<std::string> object_desc);
110
111 bool
113
115
117
118 void PrintChildrenPreamble(bool value_printed, bool summary_printed);
119
120 void PrintChildrenPostamble(bool print_dotdotdot);
121
122 lldb::ValueObjectSP GenerateChild(ValueObject &synth_valobj, size_t idx);
123
124 void PrintChild(lldb::ValueObjectSP child_sp,
125 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
126
127 llvm::Expected<uint32_t> GetMaxNumChildrenToPrint(bool &print_dotdotdot);
128
129 void
130 PrintChildren(bool value_printed, bool summary_printed,
131 const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
132
133 llvm::Error PrintChildrenIfNeeded(bool value_printed, bool summary_printed);
134
135 bool PrintChildrenOneLiner(bool hide_names);
136
138
139private:
140 bool ShouldShowName() const;
142
144 /// Cache the current "most specialized" value. Don't use this
145 /// directly, use GetMostSpecializedValue.
152 uint32_t m_curr_depth;
160 std::pair<TypeSummaryImpl *, bool> m_summary_formatter;
161 std::string m_value;
162 std::string m_summary;
163 std::string m_error;
165
166 friend struct StringSummaryFormat;
167
170};
171
172} // namespace lldb_private
173
174#endif // LLDB_DATAFORMATTERS_VALUEOBJECTPRINTER_H
static llvm::raw_ostream & error(Stream &strm)
Generic representation of a type in a programming language.
A class to manage flags.
Definition Flags.h:22
A stream class that can stream formatted output to a file.
Definition Stream.h:28
void PrintChildrenPreamble(bool value_printed, bool summary_printed)
std::shared_ptr< InstancePointersSet > InstancePointersSetSP
ValueObjectPrinter(ValueObject &valobj, Stream *s)
The ValueObjectPrinter is a one-shot printer for ValueObjects.
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.
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)
void PrintObjectDescriptionIfNeeded(std::optional< std::string > object_desc)
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