Add the ability for the NSString and libc++ std::string formatters to retrieve uncapp...
authorEnrico Granata <egranata@apple.com>
Tue, 18 Nov 2014 22:54:45 +0000 (22:54 +0000)
committerEnrico Granata <egranata@apple.com>
Tue, 18 Nov 2014 22:54:45 +0000 (22:54 +0000)
llvm-svn: 222277

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

index 2010d70..48e27ac 100644 (file)
@@ -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
index 2a8ca2d..6d847fc 100644 (file)
@@ -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::LibcxxWStringSummaryProvider (ValueObject& valobj, Str
 }
 
 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::LibcxxStringSummaryProvider (ValueObject& valobj, Stre
         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::NSStringSummaryProvider (ValueObject& valobj, Stream&
             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::NSStringSummaryProvider (ValueObject& valobj, Stream&
             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::NSStringSummaryProvider (ValueObject& valobj, Stream&
         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::NSStringSummaryProvider (ValueObject& valobj, Stream&
         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::NSStringSummaryProvider (ValueObject& valobj, Stream&
         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::NSStringSummaryProvider (ValueObject& valobj, Stream&
         options.SetPrefixToken('@');
         options.SetStream(&stream);
         options.SetSourceSize(explicit_length);
+        options.SetIgnoreMaxLength(summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryUncapped);
         return ReadStringAndDumpToStream<StringElementType::ASCII>(options);
     }
 }
index 52d03fc..ec1bf55 100644 (file)
@@ -454,8 +454,10 @@ ReadStringAndDumpToStream<StringElementType::ASCII> (ReadStringAndDumpToStreamOp
 
     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));
 
index e906ead..75e0a5c 100644 (file)
@@ -67,6 +67,12 @@ class LibcxxStringDataFormatterTestCase(TestBase):
 
         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"!!!!!"',
index 4a9b4fc..9ee3ae0 100644 (file)
@@ -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("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890someText1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
     S.assign(L"!!!!!"); // Set break point at this line.
     return 0;
-}
\ No newline at end of file
+}