|
10 | 10 |
|
11 | 11 | import gdb
|
12 | 12 | import re
|
| 13 | +import sys |
13 | 14 | import debugger_pretty_printers_common as rustpp
|
14 | 15 |
|
| 16 | +# We want a version of `range` which doesn't allocate an intermediate list, |
| 17 | +# specifically it should use a lazy iterator. In Python 2 this was `xrange`, but |
| 18 | +# if we're running with Python 3 then we need to use `range` instead. |
| 19 | +if sys.version_info.major >= 3: |
| 20 | + xrange = range |
| 21 | + |
15 | 22 | #===============================================================================
|
16 | 23 | # GDB Pretty Printing Module for Rust
|
17 | 24 | #===============================================================================
|
@@ -215,7 +222,7 @@ def children(self):
|
215 | 222 | assert data_ptr.type.get_dwarf_type_kind() == rustpp.DWARF_TYPE_CODE_PTR
|
216 | 223 | raw_ptr = data_ptr.get_wrapped_value()
|
217 | 224 |
|
218 |
| - for index in range(0, length): |
| 225 | + for index in xrange(0, length): |
219 | 226 | yield (str(index), (raw_ptr + index).dereference())
|
220 | 227 |
|
221 | 228 |
|
@@ -244,7 +251,7 @@ def to_string(self):
|
244 | 251 | def children(self):
|
245 | 252 | (length, data_ptr, cap) = rustpp.extract_length_ptr_and_cap_from_std_vec(self.__val)
|
246 | 253 | gdb_ptr = data_ptr.get_wrapped_value()
|
247 |
| - for index in range(0, length): |
| 254 | + for index in xrange(0, length): |
248 | 255 | yield (str(index), (gdb_ptr + index).dereference())
|
249 | 256 |
|
250 | 257 |
|
|
0 commit comments