Java 类soot.jimple.EnterMonitorStmt 实例源码

项目:JAADAS    文件:SynchronizedMethodTransformer.java   
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {
    if (!b.getMethod().isSynchronized() || b.getMethod().isStatic())
        return;

    Iterator<Unit> it = b.getUnits().snapshotIterator();
    while (it.hasNext()) {
        Unit u = it.next();
        if (u instanceof IdentityStmt)
            continue;

        // This the first real statement. If it is not a MonitorEnter
        // instruction, we generate one
        if (!(u instanceof EnterMonitorStmt)) {
            b.getUnits().insertBeforeNoRedirect(Jimple.v().newEnterMonitorStmt(b.getThisLocal()), u);

            // We also need to leave the monitor when the method terminates
            UnitGraph graph = new ExceptionalUnitGraph(b);
            for (Unit tail : graph.getTails())
                b.getUnits().insertBefore(Jimple.v().newExitMonitorStmt(b.getThisLocal()), tail);
        }
        break;
    }
}
项目:Sus    文件:BodyAnalysis.java   
private void checkSynchronizationStmt(Stmt sootStmt)
{
    if(sootStmt instanceof EnterMonitorStmt)
    {
        EnterMonitorStmt enterMonitorStmt = (EnterMonitorStmt)sootStmt;
        lockStack.add(0, enterMonitorStmt.getOp());
        expSecondExitMonitor = false;
    }
    else if(sootStmt instanceof ExitMonitorStmt)
    {
        if(!expSecondExitMonitor)
        {
            lockStack.remove(0);
            expSecondExitMonitor = true;
        } else
        {
            expSecondExitMonitor = false;
        }
    }
}
项目:JAADAS    文件:ConstraintCollector.java   
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
    if (uses) {
        if (stmt.getOp() instanceof Local) {
            TypeVariable op = resolver.typeVariable((Local) stmt.getOp());

            op.addParent(resolver.typeVariable(RefType.v("java.lang.Object")));
        }
    }
}
项目:JAADAS    文件:TrapTransformer.java   
public Set<Unit> getUnitsWithMonitor(UnitGraph ug) {
    Set<Unit> unitsWithMonitor = new HashSet<Unit>();

    for (Unit head : ug.getHeads()) {
        List<Unit> workList = new ArrayList<Unit>();
        workList.add(head);
        Set<Unit> doneSet = new HashSet<Unit>();

        while (!workList.isEmpty()) {
            Unit curUnit = workList.remove(0);
            if (!doneSet.add(curUnit))
                continue;

            workList.addAll(ug.getSuccsOf(curUnit));

            // If this is an "entermonitor" construct,
            // we're in a monitor from now on
            if (curUnit instanceof EnterMonitorStmt)
                unitsWithMonitor.add(curUnit);
            // If we leave a monitor, we're out now
            else if (curUnit instanceof ExitMonitorStmt)
                continue;
            else {
                for (Unit pred : ug.getPredsOf(curUnit))
                    if (unitsWithMonitor.contains(pred))
                        unitsWithMonitor.add(curUnit);
            }
        }
    }

    // Get rid of the entermonitor statements themselves
    for (Iterator<Unit> it = unitsWithMonitor.iterator(); it.hasNext(); )
        if (it.next() instanceof EnterMonitorStmt)
            it.remove();

    return unitsWithMonitor;
}
项目:bixie    文件:SootStmtSwitch.java   
@Override
public void caseEnterMonitorStmt(EnterMonitorStmt arg0) {
    injectLabelStatements(arg0);        
    arg0.getOp().apply(this.valueswitch);
    this.valueswitch.getExpression();

    this.inMonitor = true;
    // TODO: this is a very aggressive hack
    // to avoid false positives that we encountered in Tomcat.
    // For example: if (A) synchronized() { if (A) ...
    // havoc everything.
    this.boogieStatements.add(TranslationHelpers.havocEverything(this.getProcInfo(), this.valueswitch));

}
项目:jar2bpl    文件:SootStmtSwitch.java   
@Override
public void caseEnterMonitorStmt(EnterMonitorStmt arg0) {
    injectLabelStatements(arg0);        
    arg0.getOp().apply(this.valueswitch);
    this.valueswitch.getExpression();

    this.inMonitor = true;
    // TODO: this is a very aggressive hack
    // to avoid false positives that we encountered in Tomcat.
    // For example: if (A) synchronized() { if (A) ...
    // havoc everything.
    this.boogieStatements.add(TranslationHelpers.havocEverything(this.getProcInfo(), this.valueswitch));

}
项目:bladedroid    文件:Util.java   
public static void insertAfterIdentityStmt(PatchingChain<Unit> units,
        Chain<Unit> toInsert) {
    Unit point = null;
    Iterator<Unit> unitIt = units.snapshotIterator();
    boolean foundIdentityStmt = false;
    while (unitIt.hasNext())
    {
        Unit unit = unitIt.next();
        if (!(unit instanceof IdentityStmt) && !(unit instanceof EnterMonitorStmt))
        {
            point = units.getPredOf(unit);
            break;
        }
        else
        {
            foundIdentityStmt = true;
        }
    }
    if (point == null && foundIdentityStmt)
    {
        point = units.getLast();
    }
    else if (point == null && !foundIdentityStmt)
    {
        units.insertBefore(toInsert, units.getFirst());
    }
    units.insertAfter(toInsert, point);
}
项目:gluon    文件:MonitorAnalysis.java   
private void analyzeUnit(SootMethod method, Unit unit, UnitGraph cfg,
                         StackNode<EnterMonitorStmt> stack)
{
    if (visited.contains(unit))
        return; /* Unit already taken care of */

    visited.add(unit);

    if (unit instanceof EnterMonitorStmt)
        stack=new StackNode<EnterMonitorStmt>(stack,(EnterMonitorStmt)unit);
    else if (unit instanceof ExitMonitorStmt
             && stack != null)
    {
        EnterMonitorStmt enter;

        enter=stack.element();

        if (!exitMon.containsKey(enter))
            exitMon.put(enter,new ArrayList<ExitMonitorStmt>(8));

        exitMon.get(enter).add((ExitMonitorStmt)unit);

        stack=stack.parent();
    }

    for (Unit succ: cfg.getSuccsOf(unit))
        analyzeUnit(method,succ,cfg,stack);
}
项目:FuzzDroid    文件:JimpleStmtVisitorImpl.java   
@Override
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
    throw new RuntimeException("todo");

}
项目:JAADAS    文件:StmtTemplatePrinter.java   
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
    String varName = printValueAssignment(stmt.getOp(), "monitor");

    printStmt(stmt,varName);
}
项目:JAADAS    文件:UseChecker.java   
public void caseEnterMonitorStmt(EnterMonitorStmt stmt)
{
    stmt.setOp(this.uv.visit(
        stmt.getOp(), RefType.v("java.lang.Object"), stmt));
}
项目:JAADAS    文件:ConstraintChecker.java   
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
}
项目:JAADAS    文件:ConstraintCollector.java   
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
}
项目:JAADAS    文件:StmtVisitor.java   
@Override
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
       addInsn(buildMonitorInsn(stmt, Opcode.MONITOR_ENTER), stmt);
}
项目:JAADAS    文件:UnitThrowAnalysis.java   
@Override
public void caseEnterMonitorStmt(EnterMonitorStmt s) {
    result = result.add(mgr.NULL_POINTER_EXCEPTION);
    result = result.add(mightThrow(s.getOp()));
}
项目:jgs    文件:SecurityConstraintStmtSwitch.java   
@Override
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
    throwNotImplementedException(stmt.getClass(), stmt.toString());
}
项目:jgs    文件:AnnotationStmtSwitch.java   
@Override
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
    logger.fine("\n > > > Enter monitor statement identified < < <");
    valueSwitch.callingStmt = stmt;
    throw new NotSupportedStmtException("EnterMonitorStmt");
}
项目:jgs    文件:AnnotationStmtSwitch.java   
@Override
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
    logger.fine("\n > > > Enter monitor statement identified < < <");
    throw new NotSupportedStmtException("EnterMonitorStmt");
}
项目:gluon    文件:BehaviorAnalysis.java   
private void analyzeUnitEnterMonitor(SootMethod method, UnitGraph cfg,
                                     EnterMonitorStmt unit)
{
    PBNonTerminal synchNonTerm=new PBNonTerminal(alias(unit)+"@",method);
项目:gluon    文件:MonitorAnalysis.java   
public MonitorAnalysis(Scene s)
{
    scene=s;
    visited=null;
    exitMon=new HashMap<EnterMonitorStmt,Collection<ExitMonitorStmt>>();
}
项目:gluon    文件:MonitorAnalysis.java   
public Collection<ExitMonitorStmt> getExitMonitor(EnterMonitorStmt enterMon)
{
    assert exitMon.containsKey(enterMon);

    return exitMon.get(enterMon);
}
项目:jgs    文件:SecurityLevelStmtSwitch.java   
/**
 * Method, which should process the given statement of type
 * {@link EnterMonitorStmt}, but is not implemented in the current version
 * of this method. If method will be called an exception is thrown.
 * 
 * @param stmt
 *            Statement that should be processed to check for security
 *            violations.
 * @see soot.jimple.StmtSwitch#caseEnterMonitorStmt(soot.jimple.EnterMonitorStmt)
 * @throws UnimplementedSwitchException
 *             Method throws always this exception, because the method is
 *             not implemented.
 */
@Override
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
    throw new SwitchException(getMsg("exception.analysis.switch.not_implemented",
                                     stmt.toString(),
                                     getSourceLine(),
                                     stmt.getClass().getSimpleName(),
                                     this.getClass().getSimpleName()));
}
项目:jgs    文件:AnnotationStmtSwitch.java   
/**
 * DOC
 * 
 * @see soot.jimple.StmtSwitch#caseEnterMonitorStmt(soot.jimple.EnterMonitorStmt)
 */
@Override
public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
    stmt.getOp().apply(valueSwitch);
}