lldb_webkit.py throws exception when generating summary of null StringImpl
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Aug 2014 23:06:09 +0000 (23:06 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Aug 2014 23:06:09 +0000 (23:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129448

Patch by Matt Baker <mattbaker@apple.com> on 2014-08-04
Reviewed by Jer Noble.

Added checks for null StringImpl and 0 byte ReadMemory calls.

* lldb/lldb_webkit.py:
(WTFStringImpl_SummaryProvider):
(ustring_to_string):
(lstring_to_string):
(WTFStringImplProvider.to_string):
(WTFStringImplProvider.is_initialized):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172012 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/lldb/lldb_webkit.py

index 57f66c7..a712bd2 100644 (file)
@@ -1,3 +1,19 @@
+2014-08-04  Matt Baker  <mattbaker@apple.com>
+
+        lldb_webkit.py throws exception when generating summary of null StringImpl
+        https://bugs.webkit.org/show_bug.cgi?id=129448
+
+        Reviewed by Jer Noble.
+
+        Added checks for null StringImpl and 0 byte ReadMemory calls.
+
+        * lldb/lldb_webkit.py:
+        (WTFStringImpl_SummaryProvider):
+        (ustring_to_string):
+        (lstring_to_string):
+        (WTFStringImplProvider.to_string):
+        (WTFStringImplProvider.is_initialized):
+
 2014-08-03  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Do not include JavaScriptCore stress tests in release tarballs
index 6b2b9a9..2267f1f 100644 (file)
@@ -54,6 +54,8 @@ def WTFString_SummaryProvider(valobj, dict):
 
 def WTFStringImpl_SummaryProvider(valobj, dict):
     provider = WTFStringImplProvider(valobj, dict)
+    if not provider.is_initialized():
+        return ""
     return "{ length = %d, is8bit = %d, contents = '%s' }" % (provider.get_length(), provider.is_8bit(), provider.to_string())
 
 
@@ -166,6 +168,9 @@ def ustring_to_string(valobj, error, length=None):
     else:
         length = int(length)
 
+    if length == 0:
+        return ""
+
     pointer = valobj.GetValueAsUnsigned()
     contents = valobj.GetProcess().ReadMemory(pointer, length * 2, lldb.SBError())
 
@@ -183,6 +188,9 @@ def lstring_to_string(valobj, error, length=None):
     else:
         length = int(length)
 
+    if length == 0:
+        return ""
+
     pointer = valobj.GetValueAsUnsigned()
     contents = valobj.GetProcess().ReadMemory(pointer, length, lldb.SBError())
 
@@ -209,6 +217,10 @@ class WTFStringImplProvider:
 
     def to_string(self):
         error = lldb.SBError()
+
+        if not self.is_initialized():
+            return u""
+
         if self.is_8bit():
             return lstring_to_string(self.get_data8(), error, self.get_length())
         return ustring_to_string(self.get_data16(), error, self.get_length())
@@ -218,6 +230,9 @@ class WTFStringImplProvider:
         return bool(self.valobj.GetChildMemberWithName('m_hashAndFlags').GetValueAsUnsigned(0) \
             & 1 << 5)
 
+    def is_initialized(self):
+        return self.valobj.GetValueAsUnsigned() != 0
+
 
 class WTFStringProvider:
     def __init__(self, valobj, dict):