12
12
// Other libraries and framework includes
13
13
// Project includes
14
14
#include " lldb/Core/ValueObjectSyntheticFilter.h"
15
+
16
+ #include " lldb/Core/Log.h"
15
17
#include " lldb/Core/ValueObject.h"
16
18
#include " lldb/DataFormatters/TypeSynthetic.h"
17
19
@@ -65,13 +67,7 @@ ValueObjectSynthetic::ValueObjectSynthetic (ValueObject &parent, lldb::Synthetic
65
67
m_might_have_children(eLazyBoolCalculate),
66
68
m_provides_value(eLazyBoolCalculate)
67
69
{
68
- #ifdef FOOBAR
69
- std::string new_name (parent.GetName ().AsCString ());
70
- new_name += " $$__synth__" ;
71
- SetName (ConstString (new_name.c_str ()));
72
- #else
73
70
SetName (parent.GetName ());
74
- #endif
75
71
CopyValueData (m_parent);
76
72
CreateSynthFilter ();
77
73
}
@@ -108,14 +104,32 @@ ValueObjectSynthetic::GetDisplayTypeName()
108
104
size_t
109
105
ValueObjectSynthetic::CalculateNumChildren (uint32_t max)
110
106
{
107
+ Log* log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS);
108
+
111
109
UpdateValueIfNeeded ();
112
110
if (m_synthetic_children_count < UINT32_MAX)
113
111
return m_synthetic_children_count <= max ? m_synthetic_children_count : max;
114
112
115
113
if (max < UINT32_MAX)
116
- return m_synth_filter_ap->CalculateNumChildren (max);
114
+ {
115
+ size_t num_children = m_synth_filter_ap->CalculateNumChildren (max);
116
+ if (log)
117
+ log->Printf (" [ValueObjectSynthetic::CalculateNumChildren] for VO of name %s and type %s, the filter returned %zu child values" ,
118
+ GetName ().AsCString (),
119
+ GetTypeName ().AsCString (),
120
+ num_children);
121
+ return num_children;
122
+ }
117
123
else
118
- return (m_synthetic_children_count = m_synth_filter_ap->CalculateNumChildren (max));
124
+ {
125
+ size_t num_children = (m_synthetic_children_count = m_synth_filter_ap->CalculateNumChildren (max));
126
+ if (log)
127
+ log->Printf (" [ValueObjectSynthetic::CalculateNumChildren] for VO of name %s and type %s, the filter returned %zu child values" ,
128
+ GetName ().AsCString (),
129
+ GetTypeName ().AsCString (),
130
+ num_children);
131
+ return num_children;
132
+ }
119
133
}
120
134
121
135
lldb::ValueObjectSP
@@ -159,6 +173,8 @@ ValueObjectSynthetic::CreateSynthFilter ()
159
173
bool
160
174
ValueObjectSynthetic::UpdateValue ()
161
175
{
176
+ Log* log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS);
177
+
162
178
SetValueIsValid (false );
163
179
m_error.Clear ();
164
180
@@ -175,13 +191,20 @@ ValueObjectSynthetic::UpdateValue ()
175
191
ConstString new_parent_type_name = m_parent->GetTypeName ();
176
192
if (new_parent_type_name != m_parent_type_name)
177
193
{
194
+ if (log)
195
+ log->Printf (" [ValueObjectSynthetic::UpdateValue] name=%s, type changed from %s to %s, recomputing synthetic filter" ,
196
+ GetName ().AsCString (),
197
+ m_parent_type_name.AsCString (),
198
+ new_parent_type_name.AsCString ());
178
199
m_parent_type_name = new_parent_type_name;
179
200
CreateSynthFilter ();
180
201
}
181
202
182
203
// let our backend do its update
183
204
if (m_synth_filter_ap->Update () == false )
184
205
{
206
+ if (log)
207
+ log->Printf (" [ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said caches are stale - clearing" , GetName ().AsCString ());
185
208
// filter said that cached values are stale
186
209
m_children_byindex.Clear ();
187
210
m_name_toindex.Clear ();
@@ -192,18 +215,29 @@ ValueObjectSynthetic::UpdateValue ()
192
215
m_synthetic_children_count = UINT32_MAX;
193
216
m_might_have_children = eLazyBoolCalculate;
194
217
}
218
+ else
219
+ {
220
+ if (log)
221
+ log->Printf (" [ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said caches are still valid" , GetName ().AsCString ());
222
+ }
195
223
196
224
m_provides_value = eLazyBoolCalculate;
197
225
198
226
lldb::ValueObjectSP synth_val (m_synth_filter_ap->GetSyntheticValue ());
199
227
200
228
if (synth_val && synth_val->CanProvideValue ())
201
229
{
230
+ if (log)
231
+ log->Printf (" [ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said it can provide a value" , GetName ().AsCString ());
232
+
202
233
m_provides_value = eLazyBoolYes;
203
234
CopyValueData (synth_val.get ());
204
235
}
205
236
else
206
237
{
238
+ if (log)
239
+ log->Printf (" [ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said it will not provide a value" , GetName ().AsCString ());
240
+
207
241
m_provides_value = eLazyBoolNo;
208
242
CopyValueData (m_parent);
209
243
}
@@ -215,25 +249,61 @@ ValueObjectSynthetic::UpdateValue ()
215
249
lldb::ValueObjectSP
216
250
ValueObjectSynthetic::GetChildAtIndex (size_t idx, bool can_create)
217
251
{
252
+ Log* log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_DATAFORMATTERS);
253
+
254
+ if (log)
255
+ log->Printf (" [ValueObjectSynthetic::GetChildAtIndex] name=%s, retrieving child at index %zu" ,
256
+ GetName ().AsCString (),
257
+ idx);
258
+
218
259
UpdateValueIfNeeded ();
219
260
220
261
ValueObject *valobj;
221
262
if (m_children_byindex.GetValueForKey (idx, valobj) == false )
222
263
{
223
264
if (can_create && m_synth_filter_ap.get () != nullptr )
224
265
{
266
+ if (log)
267
+ log->Printf (" [ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index %zu not cached and will be created" ,
268
+ GetName ().AsCString (),
269
+ idx);
270
+
225
271
lldb::ValueObjectSP synth_guy = m_synth_filter_ap->GetChildAtIndex (idx);
272
+
273
+ if (log)
274
+ log->Printf (" [ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index %zu created as %p" ,
275
+ GetName ().AsCString (),
276
+ idx,
277
+ synth_guy.get ());
278
+
226
279
if (!synth_guy)
227
280
return synth_guy;
228
281
m_children_byindex.SetValueForKey (idx, synth_guy.get ());
229
282
synth_guy->SetPreferredDisplayLanguageIfNeeded (GetPreferredDisplayLanguage ());
230
283
return synth_guy;
231
284
}
232
285
else
286
+ {
287
+ if (log)
288
+ log->Printf (" [ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index %zu not cached and cannot be created (can_create = %s, synth_filter = %p)" ,
289
+ GetName ().AsCString (),
290
+ idx,
291
+ can_create ? " yes" : " no" ,
292
+ m_synth_filter_ap.get ());
293
+
233
294
return lldb::ValueObjectSP ();
295
+ }
234
296
}
235
297
else
298
+ {
299
+ if (log)
300
+ log->Printf (" [ValueObjectSynthetic::GetChildAtIndex] name=%s, child at index %zu cached as %p" ,
301
+ GetName ().AsCString (),
302
+ idx,
303
+ valobj);
304
+
236
305
return valobj->GetSP ();
306
+ }
237
307
}
238
308
239
309
lldb::ValueObjectSP
0 commit comments