angr/analyses/backward_slice.py
def _construct_control_flow_slice(self, simruns):
        """
        Build a slice of the program without considering the effect of data dependencies.
        This is an incorrect hack, but it should work fine with small programs.

        :param simruns: A list of SimRun targets. You probably wanna get it from the CFG somehow. It must exist in the
                        CFG.
        """

        # TODO: Support context-sensitivity!

        if self._cfg is None:
            l.error('Please build CFG first.')

        cfg = self._cfg.graph
        for simrun in simruns:
            if simrun not in cfg:
                l.error('SimRun instance %s is not in the CFG.', simrun)

        stack = [ ]
        for simrun in simruns:
            stack.append(simrun)

        self.runs_in_slice = networkx.DiGraph()
        self.cfg_nodes_in_slice = networkx.DiGraph()

        self.chosen_statements = { }
        while stack:
            # Pop one out
            block = stack.pop()
            if block.addr not in self.chosen_statements:
                self.chosen_statements[block.addr] = True
                # Get all predecessors of that block
                predecessors = cfg.predecessors(block)
                for pred in predecessors:
                    stack.append(pred)
                    self.cfg_nodes_in_slice.add_edge(pred, block)
                    self.runs_in_slice.add_edge(pred.addr, block.addr)

        Build a slice of the program without considering the effect of data dependencies.
        This is an incorrect hack, but it should work fine with small programs.

        :param simruns: A list of SimRun targets. You probably wanna get it from the CFG somehow. It must exist in the
                        CFG.
        
Build a slice of the program without considering the effect of data dependencies.
This is an incorrect hack, but it should work fine with small programs.
Build a slice of the program without considering the effect of data dependencies . This is an incorrect hack but it should work fine with small programs .
def _construct_control_flow_slice(self, simruns):
        if self._cfg is None:
            l.error('Please build CFG first.')
        cfg = self._cfg.graph
        for simrun in simruns:
            if simrun not in cfg:
                l.error('SimRun instance %s is not in the CFG.', simrun)
        stack = [ ]
        for simrun in simruns:
            stack.append(simrun)
        self.runs_in_slice = networkx.DiGraph()
        self.cfg_nodes_in_slice = networkx.DiGraph()
        self.chosen_statements = { }
        while stack:
            block = stack.pop()
            if block.addr not in self.chosen_statements:
                self.chosen_statements[block.addr] = True
                predecessors = cfg.predecessors(block)
                for pred in predecessors:
                    stack.append(pred)
                    self.cfg_nodes_in_slice.add_edge(pred, block)
                    self.runs_in_slice.add_edge(pred.addr, block.addr)
def _construct_control_flow_slice ( self , simruns ) : if self . _cfg is None : l . error ( 'Please build CFG first.' ) cfg = self . _cfg . graph for simrun in simruns : if simrun not in cfg : l . error ( 'SimRun instance %s is not in the CFG.' , simrun ) stack = [ ] for simrun in simruns : stack . append ( simrun ) self . runs_in_slice = networkx . DiGraph ( ) self . cfg_nodes_in_slice = networkx . DiGraph ( ) self . chosen_statements = { } while stack : block = stack . pop ( ) if block . addr not in self . chosen_statements : self . chosen_statements [ block . addr ] = True predecessors = cfg . predecessors ( block ) for pred in predecessors : stack . append ( pred ) self . cfg_nodes_in_slice . add_edge ( pred , block ) self . runs_in_slice . add_edge ( pred . addr , block . addr )
Build a slice of the program without considering the effect of data dependencies.
Build a slice of the program without considering the effect of data dependencies .
"""
        Build a slice of the program without considering the effect of data dependencies.
        This is an incorrect hack, but it should work fine with small programs.

        :param simruns: A list of SimRun targets. You probably wanna get it from the CFG somehow. It must exist in the
                        CFG.
        """ # TODO: Support context-sensitivity! # Pop one out # Get all predecessors of that block
self
simruns
A list of SimRun targets. You probably wanna get it from the CFG somehow. It must exist in the
CFG.
A list of SimRun targets . You probably wanna get it from the CFG somehow . It must exist in the CFG .