use of soot.SootMethod in project soot by Sable.
the class BadFields method handleMethod.
private void handleMethod(SootMethod m) {
if (!m.isConcrete())
return;
for (Iterator<ValueBox> bIt = m.retrieveActiveBody().getUseAndDefBoxes().iterator(); bIt.hasNext(); ) {
final ValueBox b = bIt.next();
Value v = b.getValue();
if (!(v instanceof StaticFieldRef))
continue;
StaticFieldRef sfr = (StaticFieldRef) v;
SootField f = sfr.getField();
if (!f.getDeclaringClass().getName().equals("java.lang.System"))
continue;
if (f.getName().equals("err")) {
logger.debug("" + "Use of System.err in " + m);
}
if (f.getName().equals("out")) {
logger.debug("" + "Use of System.out in " + m);
}
}
for (Iterator<Unit> sIt = m.getActiveBody().getUnits().iterator(); sIt.hasNext(); ) {
final Stmt s = (Stmt) sIt.next();
if (!s.containsInvokeExpr())
continue;
InvokeExpr ie = s.getInvokeExpr();
SootMethod target = ie.getMethod();
if (target.getDeclaringClass().getName().equals("java.lang.System") && target.getName().equals("exit")) {
warn("" + m + " calls System.exit");
}
}
if (m.getName().equals("<clinit>")) {
for (Iterator<Unit> sIt = m.getActiveBody().getUnits().iterator(); sIt.hasNext(); ) {
final Stmt s = (Stmt) sIt.next();
for (Iterator<ValueBox> bIt = s.getUseBoxes().iterator(); bIt.hasNext(); ) {
final ValueBox b = bIt.next();
Value v = b.getValue();
if (v instanceof FieldRef) {
warn(m.getName() + " reads field " + v);
}
}
if (!s.containsInvokeExpr())
continue;
InvokeExpr ie = s.getInvokeExpr();
SootMethod target = ie.getMethod();
calls(target);
}
}
}
use of soot.SootMethod in project soot by Sable.
the class BadFields method internalTransform.
protected void internalTransform(String phaseName, Map<String, String> options) {
lastClass = null;
for (Iterator<SootClass> clIt = Scene.v().getApplicationClasses().iterator(); clIt.hasNext(); ) {
final SootClass cl = clIt.next();
currentClass = cl;
handleClass(cl);
for (Iterator<SootMethod> it = cl.methodIterator(); it.hasNext(); ) {
handleMethod(it.next());
}
}
Scene.v().setCallGraph(Scene.v().internalMakeCallGraph());
}
use of soot.SootMethod in project soot by Sable.
the class CFGViewer method internalTransform.
// particular
// methods to print, this is a map
// from method name to the class
// name declaring the method.
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);
}
}
use of soot.SootMethod in project soot by Sable.
the class JavaTranslator method getTargetsOf.
public List<SootMethod> getTargetsOf(Value v, SootMethod m) {
SootClass rc;
Type t = v.getType();
if (t instanceof ArrayType) {
rc = Scene.v().getSootClass("java.lang.Object");
} else {
rc = ((RefType) v.getType()).getSootClass();
}
List<SootMethod> targets = h.resolveAbstractDispatch(rc, m);
return targets;
}
use of soot.SootMethod in project soot by Sable.
the class JavaTranslator method makeMethods.
void makeMethods() {
Collection<SootClass> app = Scene.v().getApplicationClasses();
for (SootClass ac : app) {
List<SootMethod> sootMethods = ac.getMethods();
for (SootMethod sm : sootMethods) {
List<Variable> vars = new LinkedList<Variable>();
List<Type> params = sm.getParameterTypes();
for (Type pt : params) {
Variable v = makeVariable(pt);
vars.add(v);
}
Variable[] var_array = (Variable[]) vars.toArray(new Variable[0]);
Method m = new Method(sm.getName(), var_array);
methods.add(m);
methodsignaturToMethod.put(sm.getSignature(), m);
}
}
}
Aggregations