MCPcopy Index your code
hub / github.com/python/cpython / addr2line

Method addr2line

Tools/gdb/libpython.py:728–747  ·  view source on GitHub ↗

Get the line number for a given bytecode offset Analogous to PyCode_Addr2Line; translated from pseudocode in Objects/lnotab_notes.txt

(self, addrq)

Source from the content-addressed store, hash-verified

726 _typename = 'PyCodeObject'
727
728 def addr2line(self, addrq):
729 '''
730 Get the line number for a given bytecode offset
731
732 Analogous to PyCode_Addr2Line; translated from pseudocode in
733 Objects/lnotab_notes.txt
734 '''
735 co_linetable = self.pyop_field('co_linetable').proxyval(set())
736
737 # Initialize lineno to co_firstlineno as per PyCode_Addr2Line
738 # not 0, as lnotab_notes.txt has it:
739 lineno = int_from_int(self.field('co_firstlineno'))
740
741 if addrq < 0:
742 return lineno
743 addr = 0
744 for addr, end_addr, line in parse_location_table(lineno, co_linetable):
745 if addr <= addrq and end_addr > addrq:
746 return line
747 assert False, "Unreachable"
748
749
750def items_from_keys_and_values(keys, values):

Callers 1

current_line_numMethod · 0.80

Calls 6

setFunction · 0.85
int_from_intFunction · 0.85
pyop_fieldMethod · 0.80
fieldMethod · 0.80
parse_location_tableFunction · 0.70
proxyvalMethod · 0.45

Tested by

no test coverage detected