Search in sources :

Example 1 with CCallgraphEdge

use of com.google.security.zynamics.binnavi.disassembly.CCallgraphEdge in project binnavi by google.

the class PostgreSQLCallgraphLoader method loadEdges.

/**
   * Loads the edges of the call graph.
   * 
   * The call graph ID and all call graph nodes must refer to objects stored in the database
   * connected to by the connection argument.
   * 
   * @param connection Connection to the database.
   * @param callgraphId ID of the call graph view to load.
   * @param nodeMap Map between call graph node IDs and call graph view objects.
   * 
   * @return The edged of the loaded call graph.
   * 
   * @throws SQLException Thrown if loading the call graph edges failed.
   */
private static List<ICallgraphEdge> loadEdges(final CConnection connection, final int callgraphId, final Map<Integer, CCallgraphNode> nodeMap) throws SQLException {
    final List<ICallgraphEdge> edges = new ArrayList<ICallgraphEdge>();
    final String edgeQuery = "SELECT source_node_id, target_node_id" + " FROM " + CTableNames.NODES_TABLE + " JOIN " + CTableNames.EDGES_TABLE + " ON " + CTableNames.NODES_TABLE + ".id = " + CTableNames.EDGES_TABLE + ".source_node_id" + " WHERE view_id = " + callgraphId;
    final ResultSet edgeResult = connection.executeQuery(edgeQuery, true);
    try {
        while (edgeResult.next()) {
            final CCallgraphNode source = nodeMap.get(edgeResult.getInt("source_node_id"));
            final CCallgraphNode target = nodeMap.get(edgeResult.getInt("target_node_id"));
            CCallgraphNode.link(source, target);
            edges.add(new CCallgraphEdge(source, target));
        }
    } finally {
        edgeResult.close();
    }
    return edges;
}
Also used : ICallgraphEdge(com.google.security.zynamics.binnavi.disassembly.ICallgraphEdge) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) CCallgraphNode(com.google.security.zynamics.binnavi.disassembly.CCallgraphNode) CCallgraphEdge(com.google.security.zynamics.binnavi.disassembly.CCallgraphEdge)

Aggregations

CCallgraphEdge (com.google.security.zynamics.binnavi.disassembly.CCallgraphEdge)1 CCallgraphNode (com.google.security.zynamics.binnavi.disassembly.CCallgraphNode)1 ICallgraphEdge (com.google.security.zynamics.binnavi.disassembly.ICallgraphEdge)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1