Shuffle APIs around a little bit, so that if you pass custom summary options, we don't end up caching the summary hence obtained. You may want to obtain an uncapped summary, but this should not be reflected in the summary we cache. The drawback is that we don't cache as aggressively as we could, but at least you get to have different summaries with different options without having to reset formatters or the SBValue at each step

llvm-svn: 222280
This commit is contained in:
Enrico Granata 2014-11-18 23:36:25 +00:00
parent aa5bb91f5a
commit 49bfafb510
6 changed files with 31 additions and 15 deletions

View File

@ -91,7 +91,8 @@ public:
GetSummary ();
const char *
GetSummary (lldb::SBTypeSummaryOptions& options);
GetSummary (lldb::SBStream& stream,
lldb::SBTypeSummaryOptions& options);
const char *
GetObjectDescription ();

View File

@ -612,8 +612,9 @@ public:
GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
std::string& destination);
const char *
GetSummaryAsCString (const TypeSummaryOptions& options);
bool
GetSummaryAsCString (std::string& destination,
const TypeSummaryOptions& options);
bool
GetSummaryAsCString (TypeSummaryImpl* summary_ptr,

View File

@ -122,7 +122,8 @@ public:
GetSummary ();
const char *
GetSummary (lldb::SBTypeSummaryOptions& options);
GetSummary (lldb::SBStream& stream,
lldb::SBTypeSummaryOptions& options);
const char *
GetObjectDescription ();

View File

@ -642,16 +642,19 @@ SBValue::GetSummary ()
}
const char *
SBValue::GetSummary (lldb::SBTypeSummaryOptions& options)
SBValue::GetSummary (lldb::SBStream& stream,
lldb::SBTypeSummaryOptions& options)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
const char *cstr = NULL;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
{
cstr = value_sp->GetSummaryAsCString(options.ref());
std::string buffer;
if (value_sp->GetSummaryAsCString(buffer,options.ref()) && !buffer.empty())
stream.Printf("%s",buffer.c_str());
}
const char* cstr = stream.GetData();
if (log)
{
if (cstr)

View File

@ -933,24 +933,27 @@ ValueObject::GetSummaryAsCString (TypeSummaryImpl* summary_ptr,
const char *
ValueObject::GetSummaryAsCString ()
{
return GetSummaryAsCString(TypeSummaryOptions());
}
const char *
ValueObject::GetSummaryAsCString (const TypeSummaryOptions& options)
{
if (UpdateValueIfNeeded(true) && m_summary_str.empty())
{
GetSummaryAsCString(GetSummaryFormat().get(),
m_summary_str,
options);
TypeSummaryOptions());
}
if (m_summary_str.empty())
return NULL;
return m_summary_str.c_str();
}
bool
ValueObject::GetSummaryAsCString (std::string& destination,
const TypeSummaryOptions& options)
{
return GetSummaryAsCString(GetSummaryFormat().get(),
destination,
options);
}
bool
ValueObject::IsCStringContainer(bool check_pointer)
{

View File

@ -70,8 +70,15 @@ class LibcxxStringDataFormatterTestCase(TestBase):
TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne");
summaryOptions = lldb.SBTypeSummaryOptions()
summaryOptions.SetCapping(lldb.eTypeSummaryUncapped)
uncappedSummary = TheVeryLongOne.GetSummary(summaryOptions)
uncappedSummaryStream = lldb.SBStream()
TheVeryLongOne.GetSummary(uncappedSummaryStream,summaryOptions)
uncappedSummary = uncappedSummaryStream.GetData()
self.assertTrue(uncappedSummary.find("someText") > 0, "uncappedSummary does not include the full string")
summaryOptions.SetCapping(lldb.eTypeSummaryCapped)
cappedSummaryStream = lldb.SBStream()
TheVeryLongOne.GetSummary(cappedSummaryStream,summaryOptions)
cappedSummary = cappedSummaryStream.GetData()
self.assertTrue(cappedSummary.find("someText") <= 0, "cappedSummary includes the full string")
self.expect("frame variable",
substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"',