Search in sources :

Example 6 with MonitorStmt

use of soot.jimple.MonitorStmt in project soot by Sable.

the class DexPrinter method toInstructions.

private void toInstructions(Collection<Unit> units, StmtVisitor stmtV, Set<Unit> trapReferences) {
    // Collect all constant arguments to monitor instructions and
    // pre-alloocate their registers
    Set<ClassConstant> monitorConsts = new HashSet<ClassConstant>();
    for (Unit u : units) {
        if (u instanceof MonitorStmt) {
            MonitorStmt monitorStmt = (MonitorStmt) u;
            if (monitorStmt.getOp() instanceof ClassConstant) {
                monitorConsts.add((ClassConstant) monitorStmt.getOp());
            }
        }
    }
    boolean monitorAllocsMade = false;
    for (Unit u : units) {
        if (!monitorAllocsMade && !monitorConsts.isEmpty() && !(u instanceof IdentityStmt)) {
            stmtV.preAllocateMonitorConsts(monitorConsts);
            monitorAllocsMade = true;
        }
        stmtV.beginNewStmt((Stmt) u);
        u.apply(stmtV);
    }
    stmtV.finalizeInstructions(trapReferences);
}
Also used : Unit(soot.Unit) MonitorStmt(soot.jimple.MonitorStmt) ClassConstant(soot.jimple.ClassConstant) IdentityStmt(soot.jimple.IdentityStmt) HashSet(java.util.HashSet)

Example 7 with MonitorStmt

use of soot.jimple.MonitorStmt in project soot by Sable.

the class MonitorConverter method convert.

public void convert(DavaBody body) {
    for (AugmentedStmt mas : body.get_MonitorFacts()) {
        MonitorStmt ms = (MonitorStmt) mas.get_Stmt();
        body.addToImportList("soot.dava.toolkits.base.DavaMonitor.DavaMonitor");
        ArrayList arg = new ArrayList();
        arg.add(ms.getOp());
        if (ms instanceof EnterMonitorStmt)
            mas.set_Stmt(new GInvokeStmt(new DVirtualInvokeExpr(new DStaticInvokeExpr(v.makeRef(), new ArrayList()), enter.makeRef(), arg, new HashSet<Object>())));
        else
            mas.set_Stmt(new GInvokeStmt(new DVirtualInvokeExpr(new DStaticInvokeExpr(v.makeRef(), new ArrayList()), exit.makeRef(), arg, new HashSet<Object>())));
    }
}
Also used : DVirtualInvokeExpr(soot.dava.internal.javaRep.DVirtualInvokeExpr) GInvokeStmt(soot.grimp.internal.GInvokeStmt) DStaticInvokeExpr(soot.dava.internal.javaRep.DStaticInvokeExpr) ArrayList(java.util.ArrayList) AugmentedStmt(soot.dava.internal.asg.AugmentedStmt) MonitorStmt(soot.jimple.MonitorStmt) EnterMonitorStmt(soot.jimple.EnterMonitorStmt) EnterMonitorStmt(soot.jimple.EnterMonitorStmt) HashSet(java.util.HashSet)

Aggregations

MonitorStmt (soot.jimple.MonitorStmt)7 DefinitionStmt (soot.jimple.DefinitionStmt)4 Stmt (soot.jimple.Stmt)4 Local (soot.Local)3 Unit (soot.Unit)3 Value (soot.Value)3 ArrayRef (soot.jimple.ArrayRef)3 FieldRef (soot.jimple.FieldRef)3 InstanceInvokeExpr (soot.jimple.InstanceInvokeExpr)3 InvokeExpr (soot.jimple.InvokeExpr)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 RefLikeType (soot.RefLikeType)2 ValueBox (soot.ValueBox)2 AugmentedStmt (soot.dava.internal.asg.AugmentedStmt)2 IdentityStmt (soot.jimple.IdentityStmt)2 InstanceFieldRef (soot.jimple.InstanceFieldRef)2 ThrowStmt (soot.jimple.ThrowStmt)2 HashMap (java.util.HashMap)1