Chromium Code Reviews| Index: Tools/gdb/webkit.py |
| diff --git a/Tools/gdb/webkit.py b/Tools/gdb/webkit.py |
| index e0219f021de82f74a569eafd13f75f1c6aa440b1..1e764ab4eaa86ea0b1fb3341a47347f6366b6e2a 100644 |
| --- a/Tools/gdb/webkit.py |
| +++ b/Tools/gdb/webkit.py |
| @@ -40,6 +40,14 @@ from __future__ import print_function |
| import gdb |
| import re |
| import struct |
| +import sys |
| + |
| + |
| +def rangeHandler(start, end=0): |
|
hayato
2014/06/05 03:28:39
Th default value, end=0, looks strange to me.
If
Habib Virji
2014/06/05 08:59:57
Done.
|
| + if sys.version < '3': |
|
hayato
2014/06/05 03:28:39
You should use sys.version_info.
Habib Virji
2014/06/05 08:59:57
Done.
|
| + return xrange(start, end) |
| + else: |
| + return list(range(start, end)) |
|
hayato
2014/06/05 03:28:39
This should be range(start, end)
Habib Virji
2014/06/05 08:59:57
Done.
|
| def guess_string_length(ptr): |
| @@ -48,7 +56,7 @@ def guess_string_length(ptr): |
| Returns a tuple of (length, an error message). |
| """ |
| # Try to guess at the length. |
| - for i in xrange(0, 2048): |
| + for i in rangeHandler(0, 2048): |
| try: |
| if int((ptr + i).dereference()) == 0: |
| return i, '' |
| @@ -68,7 +76,7 @@ def ustring_to_string(ptr, length=None): |
| length, error_message = guess_string_length(ptr) |
| else: |
| length = int(length) |
| - char_vals = [int((ptr + i).dereference()) for i in xrange(length)] |
| + char_vals = [int((ptr + i).dereference()) for i in rangeHandler(length)] |
| string = struct.pack('H' * length, *char_vals).decode('utf-16', 'replace').encode('utf-8') |
| return string + error_message |
| @@ -83,7 +91,7 @@ def lstring_to_string(ptr, length=None): |
| length, error_message = guess_string_length(ptr) |
| else: |
| length = int(length) |
| - string = ''.join([chr((ptr + i).dereference()) for i in xrange(length)]) |
| + string = ''.join([chr((ptr + i).dereference()) for i in rangeHandler(length)]) |
| return string + error_message |
| @@ -120,7 +128,7 @@ class WTFCStringPrinter(StringPrinter): |
| # The CString holds a buffer, which is a refptr to a WTF::CStringBuffer. |
| data = self.val['m_buffer']['m_ptr']['m_data'].cast(gdb.lookup_type('char').pointer()) |
| length = self.val['m_buffer']['m_ptr']['m_length'] |
| - return ''.join([chr((data + i).dereference()) for i in xrange(length)]) |
| + return ''.join([chr((data + i).dereference()) for i in rangeHandler(length)]) |
| class WTFStringImplPrinter(StringPrinter): |