Skip to content

Commit b463955

Browse files
author
Philip Guo
committed
use new super_dis module instead of ast_extents
1 parent e67c8e7 commit b463955

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

‎v3/pg_logger.py‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -875,14 +875,18 @@ def create_encoded_stack_entry(cur_frame):
875875
# optional column numbers for greater precision
876876
# (only relevant in Py2crazy, a hacked CPython that supports column numbers)
877877
if self.crazy_mode:
878-
# -1 is an invalid column number
879-
if frame.f_colno >= 0:
880-
trace_entry['column'] = frame.f_colno
881-
lc = (trace_entry['line'], trace_entry['column'])
882-
if lc in self.extent_map:
883-
expr_start_col, expr_width = self.extent_map[lc]
884-
trace_entry['expr_start_col'] = expr_start_col
885-
trace_entry['expr_width'] = expr_width
878+
# at the very least, grab the column number
879+
trace_entry['column'] = frame.f_colno
880+
881+
# now try to find start_col and extent
882+
# (-1 is an invalid instruction index)
883+
if frame.f_lasti >= 0:
884+
key = (frame.f_lineno, frame.f_colno,frame.f_lasti)
885+
if key in self.bytecode_map:
886+
v = self.bytecode_map[key]
887+
trace_entry['expr_start_col'] = v.start_col
888+
trace_entry['expr_width'] = v.extent
889+
trace_entry['opcode'] = v.opcode
886890

887891

888892
# TODO: refactor into a non-global
@@ -948,13 +952,13 @@ def _runscript(self, script_str):
948952

949953
# populate an extent map to get more accurate ranges from code
950954
if self.crazy_mode:
951-
# in Py2crazy standard library as Python-2.7.5/Lib/ast_extents.py
952-
import ast_extents
955+
# in Py2crazy standard library as Python-2.7.5/Lib/super_dis.py
956+
import super_dis
953957
try:
954-
self.extent_map = ast_extents.create_extent_map(self.executed_script)
958+
self.bytecode_map = super_dis.get_bytecode_map(self.executed_script)
955959
except:
956960
# failure oblivious
957-
self.extent_map = {}
961+
self.bytecode_map = {}
958962

959963

960964
# When bdb sets tracing, a number of call and line events happens

0 commit comments

Comments
 (0)