diff options
author | Mark Shannon <mark@hotpy.org> | 2020-11-12 09:43:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-12 09:43:29 (GMT) |
commit | 877df851c3ecdb55306840e247596e7b7805a60a (patch) | |
tree | ec00c0af84f9f228d78e23e8c8b38201129f8fae /Tools | |
parent | cda99b4022daa08ac74b0420e9903cce883d91c6 (diff) | |
download | cpython-877df851c3ecdb55306840e247596e7b7805a60a.zip cpython-877df851c3ecdb55306840e247596e7b7805a60a.tar.gz cpython-877df851c3ecdb55306840e247596e7b7805a60a.tar.bz2 |
bpo-42246: Partial implementation of PEP 626. (GH-23113)
* Implement new line number table format, as defined in PEP 626.
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/gdb/libpython.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py index 83a5fa9..e6555dd9 100755 --- a/Tools/gdb/libpython.py +++ b/Tools/gdb/libpython.py @@ -648,19 +648,28 @@ class PyCodeObjectPtr(PyObjectPtr): Analogous to PyCode_Addr2Line; translated from pseudocode in Objects/lnotab_notes.txt ''' - co_lnotab = self.pyop_field('co_lnotab').proxyval(set()) + co_linetable = self.pyop_field('co_linetable').proxyval(set()) # Initialize lineno to co_firstlineno as per PyCode_Addr2Line # not 0, as lnotab_notes.txt has it: lineno = int_from_int(self.field('co_firstlineno')) + if addrq < 0: + return lineno addr = 0 - for addr_incr, line_incr in zip(co_lnotab[::2], co_lnotab[1::2]): + for addr_incr, line_incr in zip(co_linetable[::2], co_linetable[1::2]): + if addr_incr == 255: + break addr += ord(addr_incr) + line_delta = ord(line_incr) + if line_delta == 128: + line_delta = 0 + elif line_delta > 128: + line_delta -= 256 + lineno += line_delta if addr > addrq: return lineno - lineno += ord(line_incr) - return lineno + assert False, "Unreachable" class PyDictObjectPtr(PyObjectPtr): |