soot.toolkits.graph.DirectedGraph Java Examples
The following examples show how to use
soot.toolkits.graph.DirectedGraph.
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: SimpleLocalDefs.java From JAADAS with GNU General Public License v3.0 | 6 votes |
SimpleLocalDefs(DirectedGraph<Unit> graph, Local[] locals, boolean omitSSA) { if (Options.v().time()) Timers.v().defsTimer.start(); final int N = locals.length; // reassign local numbers int[] oldNumbers = new int[N]; for (int i = 0; i < N; i++) { oldNumbers[i] = locals[i].getNumber(); locals[i].setNumber(i); } init(graph, locals, omitSSA); // restore local numbering for (int i = 0; i < N; i++) { locals[i].setNumber(oldNumbers[i]); } if (Options.v().time()) Timers.v().defsTimer.end(); }
Example #2
Source File: SimpleVeryBusyExpressions.java From JAADAS with GNU General Public License v3.0 | 6 votes |
public SimpleVeryBusyExpressions(DirectedGraph<Unit> graph) { SimpleVeryBusyAnalysis analysis = new SimpleVeryBusyAnalysis(graph); unitToExpressionsAfter = new HashMap<Unit, List<AbstractBinopExpr>>(graph.size() * 2 + 1, 0.7f); unitToExpressionsBefore = new HashMap<Unit, List<AbstractBinopExpr>>(graph.size() * 2 + 1, 0.7f); for (Unit s : graph) { FlowSet set = (FlowSet) analysis.getFlowBefore(s); unitToExpressionsBefore.put(s, Collections.unmodifiableList(set.toList())); set = (FlowSet) analysis.getFlowAfter(s); unitToExpressionsAfter.put(s, Collections.unmodifiableList(set.toList())); } }
Example #3
Source File: SimpleVeryBusyExpressions.java From JAADAS with GNU General Public License v3.0 | 6 votes |
public SimpleVeryBusyAnalysis(DirectedGraph<Unit> g) { // First obligation super(g); // NOTE: Would have expected to get the same results using a // regular ArraySparseSet, perhaps containing duplicates of // equivalent expressions. But that was not the case, results // are incorrect if using ArraySparseSet. This is because // we use intersection instead to merge sets, // and the ArraySparseSet.intersection implementation uses the method // contains to determine whether both sets contain the same element. // The contains method only compares references for equality. // (i.e. only if both sets contain the same reference is it included // in the intersecting set) emptySet = new ValueArraySparseSet(); // NOTE: It's possible to build up the kill and gen sets of each of // the nodes in the graph in advance. But in order to do so we // would have to build the universe set first. This requires an // extra pass through the unit graph, so we generate the kill and // gen sets lazily instead. // Second obligation doAnalysis(); }
Example #4
Source File: UnreachableCodeEliminator.java From JAADAS with GNU General Public License v3.0 | 6 votes |
private <T> Set<T> reachable(T first, DirectedGraph<T> g) { if ( first == null || g == null ) { return Collections.<T>emptySet(); } Set<T> visited = new HashSet<T>(g.size()); Deque<T> q = new ArrayDeque<T>(); q.addFirst(first); do { T t = q.removeFirst(); if ( visited.add(t) ) { q.addAll(g.getSuccsOf(t)); } } while (!q.isEmpty()); return visited; }
Example #5
Source File: ObservableDynamicICFG.java From SPDS with Eclipse Public License 2.0 | 5 votes |
@Override public List<Unit> getSuccsOf(Unit unit) { Body body = unitToOwner.get(unit); if (body == null) return Collections.emptyList(); DirectedGraph<Unit> unitGraph = getOrCreateUnitGraph(body); return unitGraph.getSuccsOf(unit); }
Example #6
Source File: CFGViewer.java From JAADAS with GNU General Public License v3.0 | 5 votes |
protected void print_cfg(Body body) { DirectedGraph<Unit> graph = graphtype.buildGraph(body); DotGraph canvas = graphtype.drawGraph(drawer, graph, body); String methodname = body.getMethod().getSubSignature(); String classname = body.getMethod().getDeclaringClass().getName().replaceAll("\\$", "\\."); String filename = soot.SourceLocator.v().getOutputDir(); if (filename.length() > 0) { filename = filename + java.io.File.separator; } filename = filename + classname + " " + methodname.replace(java.io.File.separatorChar, '.') + DotGraph.DOT_EXTENSION; G.v().out.println("Generate dot file in " + filename); canvas.plot(filename); }
Example #7
Source File: PhaseDumper.java From JAADAS with GNU General Public License v3.0 | 5 votes |
/** * Asks the <code>PhaseDumper</code> to dump the passed {@link * DirectedGraph} if the current phase is being dumped. * * @param g the graph to dump. * * @param body the {@link Body} represented by <code>g</code>. */ public void dumpGraph(DirectedGraph g, Body b) { if (alreadyDumping) { return; } try { alreadyDumping = true; String phaseName = phaseStack.currentPhase(); if (isCFGDumpingPhase(phaseName)) { try { String outputFile = nextGraphFileName(b, phaseName + "-" + getClassIdent(g) + "-"); DotGraph dotGraph = new CFGToDotGraph().drawCFG(g, b); dotGraph.plot(outputFile); } catch (java.io.IOException e) { // Don't abort execution because of an I/O error, but // report the error. G.v().out.println("PhaseDumper.dumpBody() caught: " + e.toString()); e.printStackTrace(G.v().out); } } } finally { alreadyDumping = false; } }
Example #8
Source File: AbstractJimpleBasedICFG.java From JAADAS with GNU General Public License v3.0 | 5 votes |
@Override public Collection<Unit> getEndPointsOf(SootMethod m) { if(m.hasActiveBody()) { Body body = m.getActiveBody(); DirectedGraph<Unit> unitGraph = getOrCreateUnitGraph(body); return unitGraph.getTails(); } return Collections.emptySet(); }
Example #9
Source File: AbstractJimpleBasedICFG.java From JAADAS with GNU General Public License v3.0 | 5 votes |
@Override public Collection<Unit> getStartPointsOf(SootMethod m) { if(m.hasActiveBody()) { Body body = m.getActiveBody(); DirectedGraph<Unit> unitGraph = getOrCreateUnitGraph(body); return unitGraph.getHeads(); } return Collections.emptySet(); }
Example #10
Source File: SimpleLocalDefs.java From JAADAS with GNU General Public License v3.0 | 5 votes |
FlowAssignment(DirectedGraph<Unit> graph, Local[] locals, List<Unit>[] unitList, int units, boolean omitSSA) { super(graph); final int N = locals.length; this.locals = new HashMap<Local, Integer>((N*3)/2+7); this.unitList = unitList; universe = new Unit[units]; indexOfUnit = new HashMap<Unit, Integer>(units); localRange = new int[N + 1]; for (int j = 0, i = 0; i < N; localRange[++i] = j) { if (unitList[i].isEmpty()) continue; this.locals.put(locals[i], i); if (unitList[i].size() >= 2) { for (Unit u : unitList[i]) { indexOfUnit.put(u, j); universe[j++] = u; } } else if (omitSSA) { universe[j++] = unitList[i].get(0); } } assert localRange[N] == units; doAnalysis(); indexOfUnit.clear(); indexOfUnit = null; }
Example #11
Source File: AbstractFlowAnalysis.java From JAADAS with GNU General Public License v3.0 | 5 votes |
/** Constructs a flow analysis on the given <code>DirectedGraph</code>. */ public AbstractFlowAnalysis(DirectedGraph<N> graph) { unitToBeforeFlow = new IdentityHashMap<N,A>(graph.size() * 2 + 1); this.graph = graph; if (Options.v().interactive_mode()){ InteractionHandler.v().handleCfgEvent(graph); } }
Example #12
Source File: ObservableDynamicICFG.java From SPDS with Eclipse Public License 2.0 | 5 votes |
@Override public Collection<Unit> getStartPointsOf(SootMethod sootMethod) { if (sootMethod.hasActiveBody()) { Body body = sootMethod.getActiveBody(); DirectedGraph<Unit> unitGraph = getOrCreateUnitGraph(body); return unitGraph.getHeads(); } return Collections.emptySet(); }
Example #13
Source File: AbstractJimpleBasedICFG.java From JAADAS with GNU General Public License v3.0 | 5 votes |
@Override public List<Unit> getSuccsOf(Unit u) { Body body = unitToOwner.get(u); if (body == null) return Collections.emptyList(); DirectedGraph<Unit> unitGraph = getOrCreateUnitGraph(body); return unitGraph.getSuccsOf(u); }
Example #14
Source File: ContextSensitiveJimpleRepresentation.java From vasco with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns an {@link ExceptionalUnitGraph} for a given method. */ @Override public DirectedGraph<Unit> getControlFlowGraph(MethodOrMethodContext momc) { if (cfgCache.containsKey(momc.method()) == false) { cfgCache.put(momc.method(), new ExceptionalUnitGraph(momc.method().getActiveBody())); } return cfgCache.get(momc.method()); }
Example #15
Source File: LocalMustNotAliasAnalysis.java From JAADAS with GNU General Public License v3.0 | 5 votes |
public LocalMustNotAliasAnalysis(DirectedGraph<Unit> directedGraph, Body b) { super(directedGraph); locals = new HashSet<Local>(); locals.addAll(b.getLocals()); for (Local l : b.getLocals()) { if (l.getType() instanceof RefLikeType) locals.add(l); } doAnalysis(); }
Example #16
Source File: DefaultJimpleRepresentation.java From vasco with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns an {@link ExceptionalUnitGraph} for a given method. */ @Override public DirectedGraph<Unit> getControlFlowGraph(SootMethod method) { if (cfgCache.containsKey(method) == false) { cfgCache.put(method, new ExceptionalUnitGraph(method.getActiveBody())); } return cfgCache.get(method); }
Example #17
Source File: ObservableDynamicICFG.java From SPDS with Eclipse Public License 2.0 | 5 votes |
@Override public Collection<Unit> getEndPointsOf(SootMethod sootMethod) { if (sootMethod.hasActiveBody()) { Body body = sootMethod.getActiveBody(); DirectedGraph<Unit> unitGraph = getOrCreateUnitGraph(body); return unitGraph.getTails(); } return Collections.emptySet(); }
Example #18
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DotGraph drawGraph(CFGToDotGraph drawer, DirectedGraph g, Body b) { return drawer.drawCFG(g, b); }
Example #19
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DirectedGraph buildGraph(Body b) { return new ArrayRefBlockGraph(b); }
Example #20
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DotGraph drawGraph(CFGToDotGraph drawer, DirectedGraph g, Body b) { return drawer.drawCFG(g, b); }
Example #21
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DotGraph drawGraph(CFGToDotGraph drawer, DirectedGraph g, Body b) { return drawer.drawCFG(g, b); }
Example #22
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DotGraph drawGraph(CFGToDotGraph drawer, DirectedGraph g, Body b) { return drawer.drawCFG(g, b); }
Example #23
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DotGraph drawGraph(CFGToDotGraph drawer, DirectedGraph g, Body b) { return drawer.drawCFG(g, b); }
Example #24
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DirectedGraph buildGraph(Body b) { return new CompleteBlockGraph(b); }
Example #25
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DotGraph drawGraph(CFGToDotGraph drawer, DirectedGraph g, Body b) { return drawer.drawCFG((ExceptionalBlockGraph) g); }
Example #26
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DirectedGraph buildGraph(Body b) { return new ExceptionalBlockGraph(b); }
Example #27
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DotGraph drawGraph(CFGToDotGraph drawer, DirectedGraph g, Body b) { return drawer.drawCFG(g, b); }
Example #28
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DotGraph drawGraph(CFGToDotGraph drawer, DirectedGraph g, Body b) { return drawer.drawCFG(g, b); }
Example #29
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DirectedGraph buildGraph(Body b) { return new ClassicCompleteUnitGraph(b); }
Example #30
Source File: CFGGraphType.java From JAADAS with GNU General Public License v3.0 | 4 votes |
public DotGraph drawGraph(CFGToDotGraph drawer, DirectedGraph g, Body b) { return drawer.drawCFG(g, b); }