diff options
| author | Rusty Wagner <rusty@vector35.com> | 2017-06-27 22:44:07 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2017-06-27 22:44:07 -0400 |
| commit | 5352b89b827c4f33fadbb21be19222eb2b714cc4 (patch) | |
| tree | da453e497860a69af149b64b2b23ba750bd56007 /python | |
| parent | cca0fe6ea60eb7f6b35cc433a6fff96cc65b3ff8 (diff) | |
Compute back edges in the core
Diffstat (limited to 'python')
| -rw-r--r-- | python/basicblock.py | 12 | ||||
| -rw-r--r-- | python/function.py | 10 |
2 files changed, 7 insertions, 15 deletions
diff --git a/python/basicblock.py b/python/basicblock.py index 3dc5b050..7858cc60 100644 --- a/python/basicblock.py +++ b/python/basicblock.py @@ -29,10 +29,11 @@ import function class BasicBlockEdge(object): - def __init__(self, branch_type, source, target): + def __init__(self, branch_type, source, target, back_edge): self.type = branch_type self.source = source self.target = target + self.back_edge = back_edge def __repr__(self): if self.type == BranchType.UnresolvedBranch: @@ -42,11 +43,6 @@ class BasicBlockEdge(object): else: return "<%s: %#x>" % (BranchType(self.type).name, self.target.start) - @property - def back_edge(self): - """Whether the edge is a back edge (end of a loop)""" - return self.target in self.source.dominators - class BasicBlock(object): def __init__(self, view, handle): @@ -114,7 +110,7 @@ class BasicBlock(object): target = BasicBlock(self.view, core.BNNewBasicBlockReference(edges[i].target)) else: target = None - result.append(BasicBlockEdge(branch_type, self, target)) + result.append(BasicBlockEdge(branch_type, self, target, edges[i].backEdge)) core.BNFreeBasicBlockEdgeList(edges, count.value) return result @@ -130,7 +126,7 @@ class BasicBlock(object): target = BasicBlock(self.view, core.BNNewBasicBlockReference(edges[i].target)) else: target = None - result.append(BasicBlockEdge(branch_type, self, target)) + result.append(BasicBlockEdge(branch_type, self, target, edges[i].backEdge)) core.BNFreeBasicBlockEdgeList(edges, count.value) return result diff --git a/python/function.py b/python/function.py index 34511cfa..8beebe66 100644 --- a/python/function.py +++ b/python/function.py @@ -948,20 +948,16 @@ class DisassemblyTextLine(object): class FunctionGraphEdge(object): - def __init__(self, branch_type, source, target, points): + def __init__(self, branch_type, source, target, points, back_edge): self.type = BranchType(branch_type) self.source = source self.target = target self.points = points + self.back_edge = back_edge def __repr__(self): return "<%s: %s>" % (self.type.name, repr(self.target)) - @property - def back_edge(self): - """Whether the edge is a back edge (end of a loop)""" - return self.target in self.source.basic_block.dominators - class FunctionGraphBlock(object): def __init__(self, handle): @@ -1074,7 +1070,7 @@ class FunctionGraphBlock(object): points = [] for j in xrange(0, edges[i].pointCount): points.append((edges[i].points[j].x, edges[i].points[j].y)) - result.append(FunctionGraphEdge(branch_type, self, target, points)) + result.append(FunctionGraphEdge(branch_type, self, target, points, edges[i].backEdge)) core.BNFreeFunctionGraphBlockOutgoingEdgeList(edges, count.value) return result |
