@Override public SootMethod getMethodOf(Unit u) { assert unitToOwner.containsKey(u) : "Statement " + u + " not in unit-to-owner mapping"; Body b = unitToOwner.get(u); return b == null ? null : b.getMethod(); }
public LockableReferenceAnalysis(UnitGraph g) { super(g); graph = g; method = g.getBody().getMethod(); contributingRWSet = null; tn = null; begin = null; lostObjects = false; refToBase = new HashMap<Ref, EquivalentValue>(); refToIndex = new HashMap<Ref, EquivalentValue>(); // analysis is done on-demand, not now }
protected void internalTransform(Body body, String phaseName, Map<String, String> options) { soot.jbco.Main.methods2JLocals.put(body.getMethod(), new ArrayList<Local>(body.getLocals())); } }
/** Return unit containing the \@this-assignment **/ public Unit getThisUnit() { for (Unit u : getUnits()) { if (u instanceof IdentityStmt && ((IdentityStmt) u).getRightOp() instanceof ThisRef) { return u; } } throw new RuntimeException("couldn't find this-assignment!" + " in " + getMethod()); }
@Override public void caseReturnStmt(ReturnStmt stmt) { usedAsFloatingPoint = stmt.getOp() == l && isFloatingPointLike(body.getMethod().getReturnType()); doBreak = true; return; } });
@Override public void validate(Body body, List<ValidationException> exception) { for (Local l : body.getLocals()) { if (l.getType() instanceof VoidType) { exception.add(new ValidationException(l, "Local " + l + " in " + body.getMethod() + " defined with void type")); } } }
/** * performs critical edge-removing. */ protected void internalTransform(Body b, String phaseName, Map<String, String> options) { if (Options.v().verbose()) { logger.debug("[" + b.getMethod().getName() + "] Removing Critical Edges..."); } removeCriticalEdges(b); if (Options.v().verbose()) { logger.debug("[" + b.getMethod().getName() + "] Removing Critical Edges done."); } }
@Override public void caseReturnStmt(ReturnStmt stmt) { usedAsObject = stmt.getOp() == l && isObject(body.getMethod().getReturnType()); if (usedAsObject) { doBreak = true; } return; }
@Override public void caseReturnStmt(ReturnStmt stmt) { usedAsObject = stmt.getOp() == l && isObject(body.getMethod().getReturnType()); doBreak = true; return; }
private void validateLocal(Body body, ValueBox vb, List<ValidationException> exception) { Value value; if ((value = vb.getValue()) instanceof Local) { if (!body.getLocals().contains(value)) { exception.add(new ValidationException(value, "Local not in chain : " + value + " in " + body.getMethod())); } } }
private void printStatementsInBody(Body body, java.io.PrintWriter out) { if (Options.v().verbose()) { System.out.println("Printing " + body.getMethod().getName()); } Chain<Unit> units = ((DavaBody) body).getUnits(); if (units.size() != 1) { throw new RuntimeException("DavaBody AST doesn't have single root."); } UnitPrinter up = new DavaUnitPrinter((DavaBody) body); ((ASTNode) units.getFirst()).toString(up); out.print(up.toString()); }
@Override /** Verifies that the UnitBoxes of this Body all point to a Unit contained within this body. */ public void validate(Body body, List<ValidationException> exception) { for (UnitBox ub : body.getAllUnitBoxes()) { if (!body.getUnits().contains(ub.getUnit())) { throw new RuntimeException( "Unitbox points outside unitChain! to unit : " + ub.getUnit() + " in " + body.getMethod()); } } }
@Override public void caseReturnStmt(ReturnStmt stmt) { // add constraint DalvikTyper.v().setType(stmt.getOpBox(), b.getMethod().getReturnType(), true); }
protected void internalTransform(Body b, String phaseName, Map<String, String> options) { initialize(options); SootMethod meth = b.getMethod(); if ((methodsToPrint == null) || (meth.getDeclaringClass().getName() == methodsToPrint.get(meth.getName()))) { Body body = ir.getBody((JimpleBody) b); print_cfg(body); } }
protected Object newInitialFlow() { ArraySparseSet set = new ArraySparseSet(); CallGraph cg = Scene.v().getCallGraph(); Iterator mIt = cg.edgesOutOf(g.getBody().getMethod()); while (mIt.hasNext()) { Edge edge = (Edge) mIt.next(); if (edge.isClinit()) { set.add(edge.tgt()); } } return set; } }
@Override public void caseReturnStmt(ReturnStmt stmt) { if (stmt.getOp() instanceof UntypedConstant) { UntypedConstant uc = (UntypedConstant) stmt.getOp(); Type type = b.getMethod().getReturnType(); stmt.setOp(uc.defineType(type)); } }
@Override public void caseReturnStmt(ReturnStmt stmt) { if (stmt.getOp() instanceof UntypedConstant) { UntypedConstant uc = (UntypedConstant) stmt.getOp(); Type type = b.getMethod().getReturnType(); stmt.setOp(uc.defineType(type)); } }
@Override public void caseReturnStmt(ReturnStmt stmt) { if (stmt.getOp() instanceof IntConstant && isObject(body.getMethod().getReturnType())) { IntConstant iconst = (IntConstant) stmt.getOp(); assert iconst.value == 0; stmt.setOp(nullConstant); } }
public void handleNewAnalysis(Transform t, Body b) { // here save current phase name and only send if actual data flow analysis exists if (PhaseOptions.getBoolean(PhaseOptions.v().getPhaseOptions(t.getPhaseName()), "enabled")) { String name = t.getPhaseName() + " for method: " + b.getMethod().getName(); currentPhaseName(name); currentPhaseEnabled(true); doneCurrent(false); } else { currentPhaseEnabled(false); setInteractThisAnalysis(false); } }
protected void checkThrow(Body b, ThrowStmt ts) { if (isThrowDeclared(b, ((RefType) ts.getOp().getType()).getSootClass()) || isThrowFromCompiler(ts) || isExceptionCaught(b, ts, (RefType) ts.getOp().getType())) { return; } if (reporter != null) { reporter.reportError(new ExceptionCheckerError(b.getMethod(), ((RefType) ts.getOp().getType()).getSootClass(), ts, (SourceLnPosTag) ts.getOpBox().getTag("SourceLnPosTag"))); } }