soot.util.queue.QueueReader Java Examples

The following examples show how to use soot.util.queue.QueueReader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Util.java    From SPDS with Eclipse Public License 2.0 6 votes vote down vote up
public static long getICFGEdges() {
    if (icfgEdges > 0)
        return icfgEdges;
    ReachableMethods reachableMethods = Scene.v().getReachableMethods();
    JimpleBasedInterproceduralCFG icfg = new JimpleBasedInterproceduralCFG();
    QueueReader<MethodOrMethodContext> listener = reachableMethods.listener();
    while (listener.hasNext()) {
        MethodOrMethodContext next = listener.next();
        SootMethod method = next.method();
        if (!method.hasActiveBody())
            continue;
        Body activeBody = method.getActiveBody();
        for (Unit u : activeBody.getUnits()) {
            List<Unit> succsOf = icfg.getSuccsOf(u);
            icfgEdges += succsOf.size();
            if (icfg.isCallStmt(u)) {
                icfgEdges += icfg.getCalleesOfCallAt(u).size();
            }
            if (icfg.isExitStmt(u)) {
                icfgEdges += icfg.getCallersOf(method).size();
            }
        }
    }
    return icfgEdges;
}
 
Example #2
Source File: ThrowRiskTf.java    From Decca with MIT License 5 votes vote down vote up
/**
 * when thrown method is reached ,method is risk.
 * 
 * @return
 */
private Set<String> getRiskMthds() {
	Set<String> riskMthds = new HashSet<String>();
	QueueReader<MethodOrMethodContext> entryRchMthds = Scene.v().getReachableMethods().listener();
	while (entryRchMthds.hasNext()) {
		SootMethod method = entryRchMthds.next().method();
		if (thrownMthds.contains(method.getSignature()))
			riskMthds.add(method.getSignature());
	}
	return riskMthds;
}
 
Example #3
Source File: CallGraph.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Removes all outgoing edges that start at the given unit
 * @param u The unit from which to remove all outgoing edges
 * @return True if at least one edge has been removed, otherwise false
 */
public boolean removeAllEdgesOutOf(Unit u) {
	boolean hasRemoved = false;
	for (QueueReader<Edge> edgeRdr = listener(); edgeRdr.hasNext(); ) {
		Edge e = edgeRdr.next();
		if (e.srcUnit() == u) {
			removeEdge(e);
			hasRemoved = true;
		}
	}
	return hasRemoved;
}
 
Example #4
Source File: CallGraph.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Swaps an invocation statement. All edges that previously went from the
 * given statement to some callee now go from the new statement to the same
 * callee. This method is intended to be used when a Jimple statement is
 * replaced, but the replacement does not semantically affect the edges.
 * @param out The old statement
 * @param in The new statement
 * @return True if at least one edge was affected by this operation
 */
public boolean swapEdgesOutOf(Stmt out, Stmt in) {
	boolean hasSwapped = false;
	for (QueueReader<Edge> edgeRdr = listener(); edgeRdr.hasNext(); ) {
		Edge e = edgeRdr.next();
		if (e.srcUnit() == out) {
			removeEdge(e);
			addEdge(new Edge(e.getSrc(), in, e.getTgt()));
			hasSwapped = true;
		}
	}
	return hasSwapped;
}
 
Example #5
Source File: CallGraph.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
public String toString() {
    QueueReader<Edge> reader = listener();
    StringBuffer out = new StringBuffer();
    while(reader.hasNext()) {
        Edge e = (Edge) reader.next();
        out.append( e.toString() + "\n" );
    }
    return out.toString();
}
 
Example #6
Source File: BoomerangPretransformer.java    From SPDS with Eclipse Public License 2.0 5 votes vote down vote up
public void apply() {
    if (applied)
        return;
    ReachableMethods reachableMethods = Scene.v().getReachableMethods();
    QueueReader<MethodOrMethodContext> listener = reachableMethods.listener();
    while (listener.hasNext()) {
        SootMethod method = listener.next().method();
        if (method.hasActiveBody()) {
            internalTransform(method.getActiveBody(), "", new HashMap<>());
        }
    }
    applied = true;
}
 
Example #7
Source File: MatcherTransition.java    From SPDS with Eclipse Public License 2.0 5 votes vote down vote up
public MatcherTransition(State from, String methodMatcher, Parameter param, State to, Type type) {
    super(from, to);
    this.type = type;
    this.param = param;
    ReachableMethods methods = Scene.v().getReachableMethods();
    QueueReader<MethodOrMethodContext> listener = methods.listener();
    while (listener.hasNext()) {
        MethodOrMethodContext next = listener.next();
        SootMethod method = next.method();
        if (Pattern.matches(methodMatcher, method.getSignature())) {
            matchingMethods.add(method);
        }
    }
}
 
Example #8
Source File: CallGraph.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
/** Returns a QueueReader object containing all edges added so far, and
 * which will be informed of any new edges that are later added to
 * the graph. */
public QueueReader<Edge> listener() {
    return reader.clone();
}
 
Example #9
Source File: CallGraph.java    From JAADAS with GNU General Public License v3.0 4 votes vote down vote up
/** Returns a QueueReader object which will contain ONLY NEW edges
 * which will be added to the graph.
 */
public QueueReader<Edge> newListener() {
    return stream.reader();
}
 
Example #10
Source File: PAG.java    From JAADAS with GNU General Public License v3.0 votes vote down vote up
public QueueReader<AllocNode> allocNodeListener() { return newAllocNodes.reader(); } 
Example #11
Source File: PAG.java    From JAADAS with GNU General Public License v3.0 votes vote down vote up
public QueueReader<Node> edgeReader() { return edgeQueue.reader(); }