webkit.py: Really fix the printing of StringImpl now that 8-bit strings are present.
[WebKit-https.git] / Tools / gdb / webkit.py
index 83a3e8af4b3c8c0c64fac028e4c3b7e739ecf681..9236603f4fb0f7d612836aab4d72033180170e13 100644 (file)
@@ -107,11 +107,19 @@ class WTFStringPrinter(StringPrinter):
             return 0
         return self.val['m_impl']['m_ptr']['m_length']
 
+    def is_8bit(self):
+        return self.val['m_impl']['m_ptr']['m_hashAndFlags'] & self.val['m_impl']['m_ptr']['s_hashFlag8BitBuffer']
+
     def to_string(self):
         if self.get_length() == 0:
             return '(null)'
 
-        return ustring_to_string(self.val['m_impl']['m_ptr']['m_data16'],
+        if self.is_8bit():
+            data_member = 'm_data8'
+        else:
+            data_member = 'm_data16'
+
+        return ustring_to_string(self.val['m_impl']['m_ptr'][data_member],
                                  self.get_length())
 
 
@@ -122,11 +130,19 @@ class JSCUStringPrinter(StringPrinter):
             return 0
         return self.val['m_impl']['m_ptr']['m_length']
 
+    def is_8bit(self):
+        return self.val['m_impl']['m_ptr']['m_hashAndFlags'] & self.val['m_impl']['m_ptr']['s_hashFlag8BitBuffer']
+
     def to_string(self):
         if self.get_length() == 0:
             return ''
 
-        return ustring_to_string(self.val['m_impl']['m_ptr']['m_data16'],
+        if self.is_8bit():
+            data_member = 'm_data8'
+        else:
+            data_member = 'm_data16'
+
+        return ustring_to_string(self.val['m_impl']['m_ptr'][data_member],
                                  self.get_length())