forked from OSchip/llvm-project
Route the preferred-display-language mechanism to the ValueObjectPrinter and actually fill in a few gaps for dynamic and synthetic values to be able to adopt this in useful ways
llvm-svn: 249507
This commit is contained in:
parent
d54f7fb8eb
commit
73e8c4d09c
lldb
include/lldb
Core
DataFormatters
source
Commands
Core
DataFormatters
test/functionalities/data-formatter/data-formatter-objc
|
@ -1242,6 +1242,9 @@ protected:
|
|||
bool
|
||||
IsChecksumEmpty ();
|
||||
|
||||
void
|
||||
SetPreferredDisplayLanguageIfNeeded (lldb::LanguageType);
|
||||
|
||||
private:
|
||||
//------------------------------------------------------------------
|
||||
// For ValueObject only
|
||||
|
|
|
@ -105,6 +105,12 @@ public:
|
|||
virtual TypeImpl
|
||||
GetTypeImpl ();
|
||||
|
||||
virtual lldb::LanguageType
|
||||
GetPreferredDisplayLanguage ();
|
||||
|
||||
void
|
||||
SetPreferredDisplayLanguage (lldb::LanguageType);
|
||||
|
||||
virtual bool
|
||||
GetDeclaration (Declaration &decl);
|
||||
|
||||
|
|
|
@ -152,6 +152,12 @@ public:
|
|||
virtual void
|
||||
SetFormat (lldb::Format format);
|
||||
|
||||
virtual lldb::LanguageType
|
||||
GetPreferredDisplayLanguage ();
|
||||
|
||||
void
|
||||
SetPreferredDisplayLanguage (lldb::LanguageType);
|
||||
|
||||
virtual bool
|
||||
GetDeclaration (Declaration &decl);
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ struct DumpValueObjectOptions
|
|||
lldb::Format m_format = lldb::eFormatDefault;
|
||||
lldb::TypeSummaryImplSP m_summary_sp;
|
||||
std::string m_root_valobj_name;
|
||||
lldb::LanguageType m_varformat_language = lldb::eLanguageTypeUnknown;
|
||||
PointerDepth m_max_ptr_depth;
|
||||
bool m_use_synthetic : 1;
|
||||
bool m_scope_already_checked : 1;
|
||||
|
@ -252,6 +253,13 @@ struct DumpValueObjectOptions
|
|||
return *this;
|
||||
}
|
||||
|
||||
DumpValueObjectOptions&
|
||||
SetVariableFormatDisplayLanguage (lldb::LanguageType lang = lldb::eLanguageTypeUnknown)
|
||||
{
|
||||
m_varformat_language = lang;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DumpValueObjectOptions&
|
||||
SetRunValidator (bool run = true)
|
||||
{
|
||||
|
|
|
@ -335,6 +335,7 @@ CommandObjectExpression::EvaluateExpression
|
|||
result_valobj_sp->SetFormat (format);
|
||||
|
||||
DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(m_command_options.m_verbosity,format));
|
||||
options.SetVariableFormatDisplayLanguage(result_valobj_sp->GetPreferredDisplayLanguage());
|
||||
|
||||
result_valobj_sp->Dump(*output_stream,options);
|
||||
|
||||
|
|
|
@ -500,6 +500,7 @@ protected:
|
|||
}
|
||||
|
||||
options.SetFormat(format);
|
||||
options.SetVariableFormatDisplayLanguage(valobj_sp->GetPreferredDisplayLanguage());
|
||||
|
||||
Stream &output_stream = result.GetOutputStream();
|
||||
options.SetRootValueObjectName(valobj_sp->GetParent() ? name_cstr : NULL);
|
||||
|
@ -586,6 +587,7 @@ protected:
|
|||
}
|
||||
|
||||
options.SetFormat(format);
|
||||
options.SetVariableFormatDisplayLanguage(valobj_sp->GetPreferredDisplayLanguage());
|
||||
options.SetRootValueObjectName(name_cstr);
|
||||
valobj_sp->Dump(result.GetOutputStream(),options);
|
||||
}
|
||||
|
|
|
@ -4259,6 +4259,13 @@ ValueObject::SetPreferredDisplayLanguage (lldb::LanguageType lt)
|
|||
m_preferred_display_language = lt;
|
||||
}
|
||||
|
||||
void
|
||||
ValueObject::SetPreferredDisplayLanguageIfNeeded (lldb::LanguageType lt)
|
||||
{
|
||||
if (m_preferred_display_language == lldb::eLanguageTypeUnknown)
|
||||
SetPreferredDisplayLanguage(lt);
|
||||
}
|
||||
|
||||
bool
|
||||
ValueObject::CanProvideValue ()
|
||||
{
|
||||
|
|
|
@ -374,5 +374,7 @@ ValueObjectConstResult::Cast (const CompilerType &compiler_type)
|
|||
lldb::LanguageType
|
||||
ValueObjectConstResult::GetPreferredDisplayLanguage ()
|
||||
{
|
||||
return lldb::eLanguageTypeUnknown;
|
||||
if (m_preferred_display_language != lldb::eLanguageTypeUnknown)
|
||||
return m_preferred_display_language;
|
||||
return GetCompilerTypeImpl().GetMinimumLanguage();
|
||||
}
|
||||
|
|
|
@ -391,6 +391,27 @@ ValueObjectDynamicValue::SetData (DataExtractor &data, Error &error)
|
|||
return ret_val;
|
||||
}
|
||||
|
||||
void
|
||||
ValueObjectDynamicValue::SetPreferredDisplayLanguage (lldb::LanguageType lang)
|
||||
{
|
||||
this->ValueObject::SetPreferredDisplayLanguage(lang);
|
||||
if (m_parent)
|
||||
m_parent->SetPreferredDisplayLanguage(lang);
|
||||
}
|
||||
|
||||
lldb::LanguageType
|
||||
ValueObjectDynamicValue::GetPreferredDisplayLanguage ()
|
||||
{
|
||||
if (m_preferred_display_language == lldb::eLanguageTypeUnknown)
|
||||
{
|
||||
if (m_parent)
|
||||
return m_parent->GetPreferredDisplayLanguage();
|
||||
return lldb::eLanguageTypeUnknown;
|
||||
}
|
||||
else
|
||||
return m_preferred_display_language;
|
||||
}
|
||||
|
||||
bool
|
||||
ValueObjectDynamicValue::GetDeclaration (Declaration &decl)
|
||||
{
|
||||
|
|
|
@ -223,6 +223,7 @@ ValueObjectSynthetic::GetChildAtIndex (size_t idx, bool can_create)
|
|||
if (!synth_guy)
|
||||
return synth_guy;
|
||||
m_children_byindex.SetValueForKey(idx, synth_guy.get());
|
||||
synth_guy->SetPreferredDisplayLanguageIfNeeded(GetPreferredDisplayLanguage());
|
||||
return synth_guy;
|
||||
}
|
||||
else
|
||||
|
@ -315,6 +316,27 @@ ValueObjectSynthetic::SetFormat (lldb::Format format)
|
|||
this->ClearUserVisibleData(eClearUserVisibleDataItemsAll);
|
||||
}
|
||||
|
||||
void
|
||||
ValueObjectSynthetic::SetPreferredDisplayLanguage (lldb::LanguageType lang)
|
||||
{
|
||||
this->ValueObject::SetPreferredDisplayLanguage(lang);
|
||||
if (m_parent)
|
||||
m_parent->SetPreferredDisplayLanguage(lang);
|
||||
}
|
||||
|
||||
lldb::LanguageType
|
||||
ValueObjectSynthetic::GetPreferredDisplayLanguage ()
|
||||
{
|
||||
if (m_preferred_display_language == lldb::eLanguageTypeUnknown)
|
||||
{
|
||||
if (m_parent)
|
||||
return m_parent->GetPreferredDisplayLanguage();
|
||||
return lldb::eLanguageTypeUnknown;
|
||||
}
|
||||
else
|
||||
return m_preferred_display_language;
|
||||
}
|
||||
|
||||
bool
|
||||
ValueObjectSynthetic::GetDeclaration (Declaration &decl)
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ DumpValueObjectOptions()
|
|||
{
|
||||
m_use_dynamic = valobj.GetDynamicValueType();
|
||||
m_use_synthetic = valobj.IsSynthetic();
|
||||
m_varformat_language = valobj.GetPreferredDisplayLanguage();
|
||||
}
|
||||
|
||||
ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
|
||||
|
@ -354,10 +355,10 @@ ValueObjectPrinter::GetValueSummaryError (std::string& value,
|
|||
{
|
||||
TypeSummaryImpl* entry = GetSummaryFormatter();
|
||||
if (entry)
|
||||
m_valobj->GetSummaryAsCString(entry, summary);
|
||||
m_valobj->GetSummaryAsCString(entry, summary, options.m_varformat_language);
|
||||
else
|
||||
{
|
||||
const char* sum_cstr = m_valobj->GetSummaryAsCString();
|
||||
const char* sum_cstr = m_valobj->GetSummaryAsCString(options.m_varformat_language);
|
||||
if (sum_cstr)
|
||||
summary.assign(sum_cstr);
|
||||
}
|
||||
|
|
|
@ -387,7 +387,6 @@ class ObjCDataFormatterTestCase(TestBase):
|
|||
self.addTearDownHook(cleanup)
|
||||
|
||||
# check formatters for common Objective-C types
|
||||
self.runCmd("log timers enable")
|
||||
expect_strings = ['(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds',
|
||||
'(CFRange) cf_range = location=4 length=4',
|
||||
'(NSPoint) ns_point = (x = 4, y = 4)',
|
||||
|
@ -414,7 +413,6 @@ class ObjCDataFormatterTestCase(TestBase):
|
|||
|
||||
self.expect("frame variable",
|
||||
substrs = expect_strings)
|
||||
self.runCmd('log timers dump')
|
||||
|
||||
|
||||
def kvo_data_formatter_commands(self):
|
||||
|
|
Loading…
Reference in New Issue