[Lldb-commits] [lldb] r222280 - 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
Enrico Granata
egranata at apple.com
Tue Nov 18 15:36:25 PST 2014
Author: enrico
Date: Tue Nov 18 17:36:25 2014
New Revision: 222280
URL: http://llvm.org/viewvc/llvm-project?rev=222280&view=rev
Log:
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
Modified:
lldb/trunk/include/lldb/API/SBValue.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/scripts/Python/interface/SBValue.i
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=222280&r1=222279&r2=222280&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Tue Nov 18 17:36:25 2014
@@ -91,7 +91,8 @@ public:
GetSummary ();
const char *
- GetSummary (lldb::SBTypeSummaryOptions& options);
+ GetSummary (lldb::SBStream& stream,
+ lldb::SBTypeSummaryOptions& options);
const char *
GetObjectDescription ();
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=222280&r1=222279&r2=222280&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Tue Nov 18 17:36:25 2014
@@ -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,
Modified: lldb/trunk/scripts/Python/interface/SBValue.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=222280&r1=222279&r2=222280&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValue.i (original)
+++ lldb/trunk/scripts/Python/interface/SBValue.i Tue Nov 18 17:36:25 2014
@@ -122,7 +122,8 @@ public:
GetSummary ();
const char *
- GetSummary (lldb::SBTypeSummaryOptions& options);
+ GetSummary (lldb::SBStream& stream,
+ lldb::SBTypeSummaryOptions& options);
const char *
GetObjectDescription ();
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=222280&r1=222279&r2=222280&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Tue Nov 18 17:36:25 2014
@@ -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)
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=222280&r1=222279&r2=222280&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Tue Nov 18 17:36:25 2014
@@ -934,17 +934,11 @@ ValueObject::GetSummaryAsCString (TypeSu
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;
@@ -952,6 +946,15 @@ ValueObject::GetSummaryAsCString (const
}
bool
+ValueObject::GetSummaryAsCString (std::string& destination,
+ const TypeSummaryOptions& options)
+{
+ return GetSummaryAsCString(GetSummaryFormat().get(),
+ destination,
+ options);
+}
+
+bool
ValueObject::IsCStringContainer(bool check_pointer)
{
ClangASTType pointee_or_element_clang_type;
Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py?rev=222280&r1=222279&r2=222280&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py Tue Nov 18 17:36:25 2014
@@ -70,8 +70,15 @@ class LibcxxStringDataFormatterTestCase(
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! ××× ×××!"',
More information about the lldb-commits
mailing list