def paths(self, baddr: str, maxtime: Optional[int] = None) -> List[MIPSCfgPath]: """Returns a path from function entry to blockaddr baddr.""" g = UG.DirectedGraph(list(self.blocks.keys()), self.edges) g.find_paths(self.function.faddr, baddr, maxtime=maxtime) return [MIPSCfgPath(self, p) for p in g.paths]
def restrict_nodes(self, sink): nodes = self.fn.cfg.blocks edges = self.fn.cfg.edges # adjacency list n -> [ n ] if not sink in nodes: print('Sink ' + sink + ' not found in nodes') self.pathnodes = nodes return g = UG.DirectedGraph(nodes, edges) g.find_paths(self.fn.faddr, sink) for p in g.paths: print('Path: ' + str(p)) self.pathnodes = self.pathnodes.union(p) if len(self.pathnodes) == 0: self.pathnodes = nodes
def restrict_nodes(self, sink: str) -> None: nodes = self.fn.cfg.blocks edges = self.fn.cfg.edges # adjacency list n -> [ n ] if sink not in nodes: print('Sink ' + sink + ' not found in nodes') self.pathnodes = set(nodes.keys()) return g = UG.DirectedGraph(list(nodes.keys()), edges) g.find_paths(self.fn.faddr, sink) for p in g.paths: print('Path: ' + str(p)) self.pathnodes = self.pathnodes.union(p) if len(self.pathnodes) == 0: self.pathnodes = set(nodes.keys())
def restrict_paths(self, segments): nodes = self.fn.cfg.blocks edges = self.fn.cfg.edges for b in segments: if not b in nodes: print('Segment ' + b + ' not found in nodes') self.pathnodes = nodes return segments = [self.fn.faddr] + segments g = UG.DirectedGraph(nodes, edges) for i in range(len(segments) - 1): src = segments[i] dst = segments[i + 1] g.find_paths(src, dst) for p in g.paths: print('Path: ' + str(p)) self.pathnodes = self.pathnodes.union(p) if len(self.pathnodes) == 0: self.pathnodes = nodes
def restrict_nodes(self): nodes = set([]) edges = {} for n in self.callgraph: nodes.add(n) for d in self.callgraph[n]: nodes.add(d) edges.setdefault(n, []) edges[n].append(d) if self.startaddr is None: self.pathnodes = nodes return g = UG.DirectedGraph(nodes, edges) if len(self.sinks) > 0: g.find_paths(self.startaddr, self.sinks[0]) for p in g.paths: print('Path: ' + str(p)) self.pathnodes = self.pathnodes.union(p) if len(self.pathnodes) == 0: self.pathnodes = nodes else: self.pathnodes = nodes
def get_paths(self, baddr, maxtime=None): """Returns a path from function entry to blockaddr baddr.""" g = UG.DirectedGraph(self.blocks.keys(), self.edges) g.find_paths(self.mipsfunction.faddr, baddr, maxtime=maxtime) return [MIPSCfgPath(self, p) for p in g.paths]
def get_reverse_paths(self, src): self.reverse_edges() g = UG.DirectedGraph(self.nodes, self.revedges) g.find_paths(src) return g.paths
def get_paths(self, src, dst): g = UG.DirectedGraph(self.nodes, self.edges) g.find_paths(src, dst) return g.paths