[Lldb-commits] [lldb] r222277 - Add the ability for the NSString and libc++ std::string formatters to retrieve uncapped data

Enrico Granata egranata at apple.com
Tue Nov 18 14:54:45 PST 2014


Author: enrico
Date: Tue Nov 18 16:54:45 2014
New Revision: 222277

URL: http://llvm.org/viewvc/llvm-project?rev=222277&view=rev
Log:
Add the ability for the NSString and libc++ std::string formatters to retrieve uncapped data

Modified:
    lldb/trunk/include/lldb/DataFormatters/StringPrinter.h
    lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
    lldb/trunk/source/DataFormatters/StringPrinter.cpp
    lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
    lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp

Modified: lldb/trunk/include/lldb/DataFormatters/StringPrinter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/StringPrinter.h?rev=222277&r1=222276&r2=222277&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/StringPrinter.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/StringPrinter.h Tue Nov 18 16:54:45 2014
@@ -37,7 +37,8 @@ namespace lldb_private {
             m_quote('"'),
             m_source_size(0),
             m_needs_zero_termination(true),
-            m_escape_non_printables(true)
+            m_escape_non_printables(true),
+            m_ignore_max_length(false)
             {
             }
             
@@ -147,6 +148,19 @@ namespace lldb_private {
                 return m_escape_non_printables;
             }
             
+            ReadStringAndDumpToStreamOptions&
+            SetIgnoreMaxLength (bool e)
+            {
+                m_ignore_max_length = e;
+                return *this;
+            }
+            
+            bool
+            GetIgnoreMaxLength () const
+            {
+                return m_ignore_max_length;
+            }
+            
         private:
             uint64_t m_location;
             lldb::ProcessSP m_process_sp;
@@ -156,6 +170,7 @@ namespace lldb_private {
             uint32_t m_source_size;
             bool m_needs_zero_termination;
             bool m_escape_non_printables;
+            bool m_ignore_max_length;
         };
         
         class ReadBufferAndDumpToStreamOptions

Modified: lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp?rev=222277&r1=222276&r2=222277&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp (original)
+++ lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp Tue Nov 18 16:54:45 2014
@@ -11,6 +11,7 @@
 
 #include "lldb/DataFormatters/CXXFormatterFunctions.h"
 #include "lldb/DataFormatters/StringPrinter.h"
+#include "lldb/DataFormatters/TypeSummary.h"
 
 #include "llvm/Support/ConvertUTF.h"
 
@@ -463,7 +464,7 @@ lldb_private::formatters::LibcxxWStringS
 }
 
 bool
-lldb_private::formatters::LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions&)
+lldb_private::formatters::LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options)
 {
     uint64_t size = 0;
     ValueObjectSP location_sp((ValueObject*)nullptr);
@@ -481,7 +482,8 @@ lldb_private::formatters::LibcxxStringSu
         return false;
     
     DataExtractor extractor;
-    size = std::min<decltype(size)>(size, valobj.GetTargetSP()->GetMaximumSizeOfStringSummary());
+    if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped)
+        size = std::min<decltype(size)>(size, valobj.GetTargetSP()->GetMaximumSizeOfStringSummary());
     location_sp->GetPointeeData(extractor, 0, size);
     
     ReadBufferAndDumpToStreamOptions options(valobj);
@@ -745,7 +747,7 @@ GetNSPathStore2Type (Target &target)
 }
 
 bool
-lldb_private::formatters::NSStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& options)
+lldb_private::formatters::NSStringSummaryProvider (ValueObject& valobj, Stream& stream, const TypeSummaryOptions& summary_options)
 {
     ProcessSP process_sp = valobj.GetProcessSP();
     if (!process_sp)
@@ -846,6 +848,7 @@ lldb_private::formatters::NSStringSummar
             options.SetQuote('"');
             options.SetSourceSize(explicit_length);
             options.SetNeedsZeroTermination(false);
+            options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
             return ReadStringAndDumpToStream<StringElementType::UTF16>(options);
         }
         else
@@ -857,7 +860,7 @@ lldb_private::formatters::NSStringSummar
             options.SetPrefixToken('@');
             options.SetSourceSize(explicit_length);
             options.SetNeedsZeroTermination(false);
-            
+            options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
             return ReadStringAndDumpToStream<StringElementType::ASCII>(options);
         }
     }
@@ -893,6 +896,7 @@ lldb_private::formatters::NSStringSummar
         options.SetQuote('"');
         options.SetSourceSize(explicit_length);
         options.SetNeedsZeroTermination(has_explicit_length == false);
+        options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
         return ReadStringAndDumpToStream<StringElementType::UTF16> (options);
     }
     else if (is_special)
@@ -909,6 +913,7 @@ lldb_private::formatters::NSStringSummar
         options.SetQuote('"');
         options.SetSourceSize(explicit_length);
         options.SetNeedsZeroTermination(has_explicit_length == false);
+        options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
         return ReadStringAndDumpToStream<StringElementType::UTF16> (options);
     }
     else if (is_inline)
@@ -922,6 +927,7 @@ lldb_private::formatters::NSStringSummar
         options.SetStream(&stream);
         options.SetPrefixToken('@');
         options.SetSourceSize(explicit_length);
+        options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
         return ReadStringAndDumpToStream<StringElementType::ASCII>(options);
     }
     else
@@ -938,6 +944,7 @@ lldb_private::formatters::NSStringSummar
         options.SetPrefixToken('@');
         options.SetStream(&stream);
         options.SetSourceSize(explicit_length);
+        options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
         return ReadStringAndDumpToStream<StringElementType::ASCII>(options);
     }
 }

Modified: lldb/trunk/source/DataFormatters/StringPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/StringPrinter.cpp?rev=222277&r1=222276&r2=222277&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/StringPrinter.cpp (original)
+++ lldb/trunk/source/DataFormatters/StringPrinter.cpp Tue Nov 18 16:54:45 2014
@@ -454,8 +454,10 @@ ReadStringAndDumpToStream<StringElementT
 
     if (options.GetSourceSize() == 0)
         size = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
-    else
+    else if (!options.GetIgnoreMaxLength())
         size = std::min(options.GetSourceSize(),process_sp->GetTarget().GetMaximumSizeOfStringSummary());
+    else
+        size = options.GetSourceSize();
 
     lldb::DataBufferSP buffer_sp(new DataBufferHeap(size,0));
 

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=222277&r1=222276&r2=222277&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 16:54:45 2014
@@ -67,6 +67,12 @@ class LibcxxStringDataFormatterTestCase(
 
         self.runCmd("n")
 
+        TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne");
+        summaryOptions = lldb.SBTypeSummaryOptions()
+        summaryOptions.SetCapping(lldb.eTypeSummaryUncapped)
+        uncappedSummary = TheVeryLongOne.GetSummary(summaryOptions)
+        self.assertTrue(uncappedSummary.find("someText") > 0, "uncappedSummary does not include the full string")
+
         self.expect("frame variable",
                     substrs = ['(std::__1::wstring) s = L"hello world! מזל טוב!"',
                     '(std::__1::wstring) S = L"!!!!!"',

Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp?rev=222277&r1=222276&r2=222277&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp (original)
+++ lldb/trunk/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp Tue Nov 18 16:54:45 2014
@@ -7,6 +7,7 @@ int main()
     const wchar_t *mazeltov = L"מזל טוב";
     std::string q("hello world");
     std::string Q("quite a long std::strin with lots of info inside it");
+    std::string TheVeryLongOne("12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456!
 789012345
 6789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123!
 456789012
 3456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890someText1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012!
 345678901
 2345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789!
 012345678
 9012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456!
 789012345
 6789012345678901234567890123456789012345678901234567890");
     S.assign(L"!!!!!"); // Set break point at this line.
     return 0;
-}
\ No newline at end of file
+}





More information about the lldb-commits mailing list