(self, return_target_sources=None)
return cfg
Create a DiGraph out of the existing edge map.
        :param return_target_sources: Used for making up those missing returns
        :returns: A networkx.DiGraph() object
Create a DiGraph out of the existing edge map.
        :param return_target_sources: Used for making up those missing returns
        :returns: A networkx.DiGraph() object
Create a DiGraph out of the existing edge map . : param return_target_sources : Used for making up those missing returns : returns : A networkx . DiGraph () object
def _create_graph(self, return_target_sources=None):
        """
        Create a DiGraph out of the existing edge map.
        :param return_target_sources: Used for making up those missing returns
        :returns: A networkx.DiGraph() object
        """
        if return_target_sources is None:
            # We set it to a defaultdict in order to be consistent with the
            # actual parameter.
            return_target_sources = defaultdict(list)

        cfg = networkx.DiGraph()
        # The corner case: add a node to the graph if there is only one block
        if len(self._nodes) == 1:
            cfg.add_node(self._nodes[next(iter(self._nodes.keys()))])

        # Adding edges
        for tpl, targets in self._exit_targets.items():
            basic_block = self._nodes[tpl] # Cannot fail :)
            for ex, jumpkind in targets:
                if ex in self._nodes:
                    target_bbl = self._nodes[ex]
                    cfg.add_edge(basic_block, target_bbl, jumpkind=jumpkind)

                    # Add edges for possibly missing returns
                    if basic_block.addr in return_target_sources:
                        for src_irsb_key in \
                                return_target_sources[basic_block.addr]:
                            cfg.add_edge(self._nodes[src_irsb_key],
                                               basic_block, jumpkind="Ijk_Ret")
                else:
                    # Debugging output
                    def addr_formalize(addr):
                        if addr is None:
                            return "None"
                        else:
                            return "%#08x" % addr

                    s = "(["
                    for addr in ex[:-1]:
                        s += addr_formalize(addr) + ", "
                    s += "] %s)" % addr_formalize(ex[-1])
                    l.warning("Key %s does not exist.", s)

        return cfg
def _create_graph ( self , return_target_sources = None ) : if return_target_sources is None : # We set it to a defaultdict in order to be consistent with the # actual parameter. return_target_sources = defaultdict ( list ) cfg = networkx . DiGraph ( ) # The corner case: add a node to the graph if there is only one block if len ( self . _nodes ) == 1 : cfg . add_node ( self . _nodes [ next ( iter ( self . _nodes . keys ( ) ) ) ] ) # Adding edges for tpl , targets in self . _exit_targets . items ( ) : basic_block = self . _nodes [ tpl ] # Cannot fail :) for ex , jumpkind in targets : if ex in self . _nodes : target_bbl = self . _nodes [ ex ] cfg . add_edge ( basic_block , target_bbl , jumpkind = jumpkind ) # Add edges for possibly missing returns if basic_block . addr in return_target_sources : for src_irsb_key in return_target_sources [ basic_block . addr ] : cfg . add_edge ( self . _nodes [ src_irsb_key ] , basic_block , jumpkind = "Ijk_Ret" ) else : # Debugging output def addr_formalize ( addr ) : if addr is None : return "None" else : return "%#08x" % addr s = "([" for addr in ex [ : - 1 ] : s += addr_formalize ( addr ) + ", " s += "] %s)" % addr_formalize ( ex [ - 1 ] ) l . warning ( "Key %s does not exist." , s ) return cfg