21
21
namespace lldb_private {
22
22
23
23
class ValueObjectPrinter {
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.
24
29
public:
25
- ValueObjectPrinter (ValueObject * valobj, Stream *s);
30
+ ValueObjectPrinter (ValueObject & valobj, Stream *s);
26
31
27
- ValueObjectPrinter (ValueObject * valobj, Stream *s,
32
+ ValueObjectPrinter (ValueObject & valobj, Stream *s,
28
33
const DumpValueObjectOptions &options);
29
34
30
35
~ValueObjectPrinter () = default ;
@@ -39,21 +44,37 @@ class ValueObjectPrinter {
39
44
40
45
// only this class (and subclasses, if any) should ever be concerned with the
41
46
// depth mechanism
42
- ValueObjectPrinter (ValueObject * valobj, Stream *s,
47
+ ValueObjectPrinter (ValueObject & valobj, Stream *s,
43
48
const DumpValueObjectOptions &options,
44
49
const DumpValueObjectOptions::PointerDepth &ptr_depth,
45
50
uint32_t curr_depth,
46
51
InstancePointersSetSP printed_instance_pointers);
47
52
48
53
// we should actually be using delegating constructors here but some versions
49
54
// of GCC still have trouble with those
50
- void Init (ValueObject * valobj, Stream *s,
55
+ void Init (ValueObject & valobj, Stream *s,
51
56
const DumpValueObjectOptions &options,
52
57
const DumpValueObjectOptions::PointerDepth &ptr_depth,
53
58
uint32_t curr_depth,
54
59
InstancePointersSetSP printed_instance_pointers);
55
60
56
- bool GetMostSpecializedValue ();
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.
75
+ ValueObject &GetMostSpecializedValue ();
76
+
77
+ void SetupMostSpecializedValue ();
57
78
58
79
const char *GetDescriptionForDisplay ();
59
80
@@ -95,13 +116,13 @@ class ValueObjectPrinter {
95
116
96
117
bool ShouldExpandEmptyAggregates ();
97
118
98
- ValueObject * GetValueObjectForChildrenGeneration ();
119
+ ValueObject & GetValueObjectForChildrenGeneration ();
99
120
100
121
void PrintChildrenPreamble (bool value_printed, bool summary_printed);
101
122
102
123
void PrintChildrenPostamble (bool print_dotdotdot);
103
124
104
- lldb::ValueObjectSP GenerateChild (ValueObject * synth_valobj, size_t idx);
125
+ lldb::ValueObjectSP GenerateChild (ValueObject & synth_valobj, size_t idx);
105
126
106
127
void PrintChild (lldb::ValueObjectSP child_sp,
107
128
const DumpValueObjectOptions::PointerDepth &curr_ptr_depth);
@@ -121,8 +142,10 @@ class ValueObjectPrinter {
121
142
private:
122
143
bool ShouldShowName () const ;
123
144
124
- ValueObject *m_orig_valobj;
125
- ValueObject *m_valobj;
145
+ ValueObject &m_orig_valobj;
146
+ ValueObject *m_cached_valobj; // / Cache the current "most specialized" value.
147
+ // / Don't use this directly, use
148
+ // / GetMostSpecializedValue.
126
149
Stream *m_stream;
127
150
DumpValueObjectOptions m_options;
128
151
Flags m_type_flags;
0 commit comments