Start to improve detect_structure for 2.7 and 2.x

Add debug flag to find_jump_targets to show the structure we found.
When there are control-flow bugs, it's often reflected here.

scanner3.py: make code make more similar to 2.x code
This commit is contained in:
rocky
2016-11-20 02:38:59 -05:00
parent fe36c9e9f6
commit f2a3721d7d
4 changed files with 124 additions and 59 deletions

View File

@@ -428,6 +428,8 @@ class Scanner3(Scanner):
# Containers filled by detect_structure()
self.not_continue = set()
self.return_end_ifs = set()
self.setup_loop_targets = {} # target given setup_loop offset
self.setup_loops = {} # setup_loop offset given target
targets = {}
for offset in self.op_range(0, n):
@@ -585,6 +587,8 @@ class Scanner3(Scanner):
start = offset+3
target = self.get_target(offset)
end = self.restrict_to_parent(target, parent)
self.setup_loop_targets[offset] = target
self.setup_loops[target] = offset
if target != end:
self.fixed_jumps[offset] = end