/** Returns the signature of this method. */ @Override public String toString() { return getSignature(); }
@Override public String getSignature() { return SootMethod.getSignature(declaringClass, name, parameterTypes, returnType); }
public String toString() { return "[" + m.getSignature() + " : R]"; } }
public String toString() { return "[" + m.getSignature() + " : P" + param + "]"; } }
public NativeMethodNotSupportedException(SootMethod method) { String message = "The following native method is not supported: \n " + method.getSignature(); this.msg = message; }
public String toString() { return "[" + m.getSignature() + " : " + l.toString() + "[ ]"; } }
public String toString() { return "[" + m.getSignature() + " : " + l.toString() + "]"; } }
public static String getSignature(SootClass cl, String name, List<Type> params, Type returnType) { return getSignature(cl, getSubSignatureImpl(name, params, returnType)); }
/** * Returns the Soot signature of this method. Used to refer to methods unambiguously. */ public String getSignature() { if (sig == null) { synchronized (this) { if (sig == null) { sig = getSignature(getDeclaringClass(), getSubSignature()); } } } return sig; }
protected void internalTransform(Body b, String phaseName, Map<String, String> options) { System.out.println("Printing Line Numbers for: " + b.getMethod().getSignature()); PatchingChain<Unit> units = b.getUnits(); // get the method code Iterator<Unit> it = units.iterator(); while (it.hasNext()) { // for each jimple statement or baf instruction Unit u = (Unit) it.next(); if (u.hasTag("LineNumberTag")) { // see if a LineNumberTag exists (it will if you use -keep-line-number) LineNumberTag tag = (LineNumberTag) u.getTag(("LineNumberTag")); System.out.println(u + " has Line Number: " + tag.getLineNumber()); // print out the unit and line number } else { System.out.println(u + " has no Line Number"); } } System.out.println("\n"); } }
@Override public Collection<SootMethod> load(Unit u) throws Exception { ArrayList<SootMethod> res = null; // only retain callers that are explicit call sites or // Thread.start() Iterator<Edge> edgeIter = new EdgeFilter().wrap(cg.edgesOutOf(u)); while (edgeIter.hasNext()) { Edge edge = edgeIter.next(); SootMethod m = edge.getTgt().method(); if (includePhantomCallees || m.hasActiveBody()) { if (res == null) { res = new ArrayList<SootMethod>(); } res.add(m); } else if (IDESolver.DEBUG) { logger.error(String.format("Method %s is referenced but has no body!", m.getSignature(), new Exception())); } } if (res != null) { res.trimToSize(); return res; } else { return Collections.emptySet(); } } };
private boolean isRenamingAllowed(SootMethod method) { if (soot.jbco.Main.getWeight(MethodRenamer.name, method.getSignature()) == 0) { return false; } final String subSignature = method.getSubSignature(); if (MAIN_METHOD_SUB_SIGNATURE.equals(subSignature) && method.isPublic() && method.isStatic()) { if (isVerbose()) { logger.info("Skipping renaming \"{}\" method as it is main one.", subSignature); } return false; // skip the main method } if (method.getName().equals(SootMethod.constructorName) || method.getName().equals(SootMethod.staticInitializerName)) { if (isVerbose()) { logger.info("Skipping renaming \"{}\" method as it is constructor or static initializer.", subSignature); } return false; // skip constructors/initializers } return true; }
public Body getBody(SootMethod m, String phaseName) { JimpleBody jb = (JimpleBody) mJimpleAST.getBody(m); if (jb == null) { throw new RuntimeException("Could not load body for method " + m.getSignature()); } if (Options.v().verbose()) { logger.debug("[" + m.getName() + "] Retrieving JimpleBody from AST..."); } PackManager.v().getPack("jb").apply(jb); return jb; } }
protected void internalTransform(Body b, String phaseName, Map<String, String> options) { // if (b.getMethod().getSignature().indexOf("run")<0) return; System.out.println("\n" + b.getMethod().getSignature()); if (stack) { Map<Unit, Stack<Type>> stacks = null; Map<Local, Local> b2j = soot.jbco.Main.methods2Baf2JLocals.get(b.getMethod()); try { if (b2j == null) { stacks = StackTypeHeightCalculator.calculateStackHeights(b); } else { stacks = StackTypeHeightCalculator.calculateStackHeights(b, b2j); } StackTypeHeightCalculator.printStack(b.getUnits(), stacks, true); } catch (Exception exc) { System.out.println("\n**************Exception calculating height " + exc + ", printing plain bytecode now\n\n"); soot.jbco.util.Debugger.printUnits(b, " FINAL"); } } else { soot.jbco.util.Debugger.printUnits(b, " FINAL"); } System.out.println(); } }
/** * Checks whether after each new-instruction a constructor call follows. */ @Override public void validate(Body body, List<ValidationException> exceptions) { UnitGraph g = new BriefUnitGraph(body); for (Unit u : body.getUnits()) { if (u instanceof AssignStmt) { AssignStmt assign = (AssignStmt) u; // First seek for a JNewExpr. if (assign.getRightOp() instanceof NewExpr) { if (!(assign.getLeftOp().getType() instanceof RefType)) { exceptions.add(new ValidationException(u, "A new-expression must be used on reference type locals", String.format("Body of method %s contains a new-expression, which is assigned to a non-reference local", body.getMethod().getSignature()))); return; } // We search for a JSpecialInvokeExpr on the local. LinkedHashSet<Local> locals = new LinkedHashSet<Local>(); locals.add((Local) assign.getLeftOp()); checkForInitializerOnPath(g, assign, exceptions); } } } }
/** * Checks whether all Caught-Exception-References are associated to traps. */ @Override public void validate(Body body, List<ValidationException> exceptions) { Set<Unit> caughtUnits = new HashSet<Unit>(); for (Trap trap : body.getTraps()) { caughtUnits.add(trap.getHandlerUnit()); if (!(trap.getHandlerUnit() instanceof IdentityStmt)) { exceptions.add(new ValidationException(trap, "Trap handler does not start with caught " + "exception reference")); } else { IdentityStmt is = (IdentityStmt) trap.getHandlerUnit(); if (!(is.getRightOp() instanceof CaughtExceptionRef)) { exceptions.add(new ValidationException(trap, "Trap handler does not start with caught " + "exception reference")); } } } for (Unit u : body.getUnits()) { if (u instanceof IdentityStmt) { IdentityStmt id = (IdentityStmt) u; if (id.getRightOp() instanceof CaughtExceptionRef) { if (!caughtUnits.contains(id)) { exceptions.add(new ValidationException(id, "Could not find a corresponding trap using this statement as handler", "Body of method " + body.getMethod().getSignature() + " contains a caught exception reference," + "but not a corresponding trap using this statement as handler")); } } } } }
"Body of method " + body.getMethod().getSignature() + " does not contain a return statement"));
"Could not find body for " + m.getSignature() + " in " + m.getDeclaringClass().getName());
protected void internalTransform(Body b, String phaseName, Map<String, String> options) { if (b.getMethod().getName().indexOf("<clinit>") >= 0) { return; } int weight = soot.jbco.Main.getWeight(phaseName, b.getMethod().getSignature()); if (weight == 0) { return; } PatchingChain<Unit> units = b.getUnits(); Iterator<Unit> iter = units.snapshotIterator(); while (iter.hasNext()) { Unit u = (Unit) iter.next(); if (u instanceof PushInst) { SootField f = CollectConstants.constantsToFields.get(((PushInst) u).getConstant()); if (f != null && Rand.getInt(10) <= weight) { Unit get = Baf.v().newStaticGetInst(f.makeRef()); units.insertBefore(get, u); BodyBuilder.updateTraps(get, u, b.getTraps()); units.remove(u); updated++; } } } } }
SootMethod tempm = ((StaticInvokeExpr) iexpr).getMethod(); if (tempm.getSignature().equals("<java.lang.System: void exit(int)>")) { units.insertBefore(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(report.makeRef())), stmt);