Skip to content

Commit acfe8fa

Browse files
author
Enrico Granata
committed
Add logging to ValueObjectSyntheticFilter such that one can trace through the creation of synthetic children
llvm-svn: 270770
1 parent 6b4baa5 commit acfe8fa

File tree

1 file changed

+78
-8
lines changed

1 file changed

+78
-8
lines changed

lldb/source/Core/ValueObjectSyntheticFilter.cpp

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// Other libraries and framework includes
1313
// Project includes
1414
#include "lldb/Core/ValueObjectSyntheticFilter.h"
15+
16+
#include "lldb/Core/Log.h"
1517
#include "lldb/Core/ValueObject.h"
1618
#include "lldb/DataFormatters/TypeSynthetic.h"
1719

@@ -65,13 +67,7 @@ ValueObjectSynthetic::ValueObjectSynthetic (ValueObject &parent, lldb::Synthetic
6567
m_might_have_children(eLazyBoolCalculate),
6668
m_provides_value(eLazyBoolCalculate)
6769
{
68-
#ifdef FOOBAR
69-
std::string new_name(parent.GetName().AsCString());
70-
new_name += "$$__synth__";
71-
SetName (ConstString(new_name.c_str()));
72-
#else
7370
SetName(parent.GetName());
74-
#endif
7571
CopyValueData(m_parent);
7672
CreateSynthFilter();
7773
}
@@ -108,14 +104,32 @@ ValueObjectSynthetic::GetDisplayTypeName()
108104
size_t
109105
ValueObjectSynthetic::CalculateNumChildren(uint32_t max)
110106
{
107+
Log* log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS);
108+
111109
UpdateValueIfNeeded();
112110
if (m_synthetic_children_count < UINT32_MAX)
113111
return m_synthetic_children_count <= max ? m_synthetic_children_count : max;
114112

115113
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+
}
117123
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+
}
119133
}
120134

121135
lldb::ValueObjectSP
@@ -159,6 +173,8 @@ ValueObjectSynthetic::CreateSynthFilter ()
159173
bool
160174
ValueObjectSynthetic::UpdateValue ()
161175
{
176+
Log* log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS);
177+
162178
SetValueIsValid (false);
163179
m_error.Clear();
164180

@@ -175,13 +191,20 @@ ValueObjectSynthetic::UpdateValue ()
175191
ConstString new_parent_type_name = m_parent->GetTypeName();
176192
if (new_parent_type_name != m_parent_type_name)
177193
{
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());
178199
m_parent_type_name = new_parent_type_name;
179200
CreateSynthFilter();
180201
}
181202

182203
// let our backend do its update
183204
if (m_synth_filter_ap->Update() == false)
184205
{
206+
if (log)
207+
log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said caches are stale - clearing", GetName().AsCString());
185208
// filter said that cached values are stale
186209
m_children_byindex.Clear();
187210
m_name_toindex.Clear();
@@ -192,18 +215,29 @@ ValueObjectSynthetic::UpdateValue ()
192215
m_synthetic_children_count = UINT32_MAX;
193216
m_might_have_children = eLazyBoolCalculate;
194217
}
218+
else
219+
{
220+
if (log)
221+
log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said caches are still valid", GetName().AsCString());
222+
}
195223

196224
m_provides_value = eLazyBoolCalculate;
197225

198226
lldb::ValueObjectSP synth_val(m_synth_filter_ap->GetSyntheticValue());
199227

200228
if (synth_val && synth_val->CanProvideValue())
201229
{
230+
if (log)
231+
log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said it can provide a value", GetName().AsCString());
232+
202233
m_provides_value = eLazyBoolYes;
203234
CopyValueData(synth_val.get());
204235
}
205236
else
206237
{
238+
if (log)
239+
log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic filter said it will not provide a value", GetName().AsCString());
240+
207241
m_provides_value = eLazyBoolNo;
208242
CopyValueData(m_parent);
209243
}
@@ -215,25 +249,61 @@ ValueObjectSynthetic::UpdateValue ()
215249
lldb::ValueObjectSP
216250
ValueObjectSynthetic::GetChildAtIndex (size_t idx, bool can_create)
217251
{
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+
218259
UpdateValueIfNeeded();
219260

220261
ValueObject *valobj;
221262
if (m_children_byindex.GetValueForKey(idx, valobj) == false)
222263
{
223264
if (can_create && m_synth_filter_ap.get() != nullptr)
224265
{
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+
225271
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+
226279
if (!synth_guy)
227280
return synth_guy;
228281
m_children_byindex.SetValueForKey(idx, synth_guy.get());
229282
synth_guy->SetPreferredDisplayLanguageIfNeeded(GetPreferredDisplayLanguage());
230283
return synth_guy;
231284
}
232285
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+
233294
return lldb::ValueObjectSP();
295+
}
234296
}
235297
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+
236305
return valobj->GetSP();
306+
}
237307
}
238308

239309
lldb::ValueObjectSP

0 commit comments

Comments
 (0)