diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2013-08-24 19:07:07 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2013-08-24 19:07:07 (GMT) |
commit | 9d95254bb7f65e0afe13547b6741b6bddab8228b (patch) | |
tree | b051dc4fedebcef406dd309c113901841dbc0b51 /Tools/gdb | |
parent | f5e30d8b54cdc07c53ffa741353a83ed3263d7d2 (diff) | |
download | cpython-9d95254bb7f65e0afe13547b6741b6bddab8228b.zip cpython-9d95254bb7f65e0afe13547b6741b6bddab8228b.tar.gz cpython-9d95254bb7f65e0afe13547b6741b6bddab8228b.tar.bz2 |
Issue #18772: fix the gdb plugin after the set implementation changes
Diffstat (limited to 'Tools/gdb')
-rw-r--r-- | Tools/gdb/libpython.py | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py index ef69359..684713f 100644 --- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -922,21 +922,26 @@ class PyFrameObjectPtr(PyObjectPtr): class PySetObjectPtr(PyObjectPtr): _typename = 'PySetObject' + @classmethod + def _dummy_key(self): + return gdb.lookup_global_symbol('_PySet_Dummy').value() + + def __iter__(self): + dummy_ptr = self._dummy_key() + table = self.field('table') + for i in safe_range(self.field('mask') + 1): + setentry = table[i] + key = setentry['key'] + if key != 0 and key != dummy_ptr: + yield PyObjectPtr.from_pyobject_ptr(key) + def proxyval(self, visited): # Guard against infinite loops: if self.as_address() in visited: return ProxyAlreadyVisited('%s(...)' % self.safe_tp_name()) visited.add(self.as_address()) - members = [] - table = self.field('table') - for i in safe_range(self.field('mask')+1): - setentry = table[i] - key = setentry['key'] - if key != 0: - key_proxy = PyObjectPtr.from_pyobject_ptr(key).proxyval(visited) - if key_proxy != '<dummy key>': - members.append(key_proxy) + members = (key.proxyval(visited) for key in self) if self.safe_tp_name() == 'frozenset': return frozenset(members) else: @@ -965,18 +970,11 @@ class PySetObjectPtr(PyObjectPtr): out.write('{') first = True - table = self.field('table') - for i in safe_range(self.field('mask')+1): - setentry = table[i] - key = setentry['key'] - if key != 0: - pyop_key = PyObjectPtr.from_pyobject_ptr(key) - key_proxy = pyop_key.proxyval(visited) # FIXME! - if key_proxy != '<dummy key>': - if not first: - out.write(', ') - first = False - pyop_key.write_repr(out, visited) + for key in self: + if not first: + out.write(', ') + first = False + key.write_repr(out, visited) out.write('}') if tp_name != 'set': |