Java 类soot.jimple.internal.JIdentityStmt 实例源码

项目:petablox    文件:DomP.java   
@Override
public String toFIString(Unit u) {       
    StringBuilder sb = new StringBuilder();
    boolean printId = Utils.buildBoolProperty("petablox.printrel.printID", false);
    if (printId) sb.append("(" + indexOf(u) + ")");
    String type;
    if(u instanceof JAssignStmt)
        type = "Assign";
    else if(u instanceof JBreakpointStmt)
        type = "Breakpoint";
    else if(u instanceof JGotoStmt)
        type = "Goto";
    else if(u instanceof JIfStmt) 
        type = "If";
    else if(u instanceof JIdentityStmt) 
        type = "Identity";
    else if(u instanceof JInvokeStmt) 
        type = "Invoke";
    else if(u instanceof JLookupSwitchStmt) 
        type = "LookupSwitch";
    else if(u instanceof JNopStmt)
        type = "Nop";
    else if(u instanceof JRetStmt) 
        type = "Return";
    else if(u instanceof JTableSwitchStmt) 
        type = "TablelSwitch";
    else if(u instanceof JThrowStmt) 
        type = "Throw";
    else
        type = "Other";
    sb.append(type);
    sb.append(": " + SootUtilities.getMethod(u).getName() + "@" + SootUtilities.getMethod(u).getDeclaringClass().getName());
    return sb.toString();
}
项目:androcov    文件:Instrumenter.java   
public static void instrument() {
        Util.LOGGER.info("Start instrumenting...");

        Scene.v().loadNecessaryClasses();
        final SootClass helperClass = Scene.v().getSootClass("xyz.ylimit.androcov.CoverageHelper");
        final SootMethod helperMethod = helperClass.getMethodByName("reach");

        PackManager.v().getPack("jtp").add(new Transform("jtp.androcov", new BodyTransformer() {
            @Override
            protected void internalTransform(final Body b, String phaseName, @SuppressWarnings("rawtypes") Map options) {
                final PatchingChain units = b.getUnits();
                // important to use snapshotIterator here
                if (b.getMethod().getDeclaringClass() == helperClass) return;
                String methodSig = b.getMethod().getSignature();
                allMethods.add(methodSig);

                // perform instrumentation here
                for(Iterator iter = units.snapshotIterator(); iter.hasNext();) {
                    final Unit u = (Unit) iter.next();
//                    // insert before return statements
//                    if (u instanceof ReturnStmt || u instanceof RetStmt || u instanceof ReturnVoidStmt) {
//                        InvokeStmt logStatement = Jimple.v().newInvokeStmt(
//                                Jimple.v().newStaticInvokeExpr(helperMethod.makeRef(), StringConstant.v(methodSig)));
//                        units.insertBefore(logStatement, u);
//                    }
                    // insert before the first non-identity statement
                    if (!(u instanceof JIdentityStmt)) {
                        InvokeStmt logStatement = Jimple.v().newInvokeStmt(
                                Jimple.v().newStaticInvokeExpr(helperMethod.makeRef(), StringConstant.v(methodSig)));
                        units.insertBefore(logStatement, u);
                        break;
                    }
                }
                b.validate();
            }
        }));
        PackManager.v().runPacks();
        PackManager.v().writeOutput();
        if (new File(Config.outputAPKPath).exists()) {
            Util.LOGGER.info("finish instrumenting");
            Util.signAPK(Config.outputAPKPath);
            Util.LOGGER.info("finish signing");
            Util.LOGGER.info("instrumented apk: " + Config.outputAPKPath);
        }
        else {
            Util.LOGGER.warning("error instrumenting");
        }
    }
项目:petablox    文件:VisitorHandler.java   
private void visitIdendityInsts(JIdentityStmt s) {
    if (identityVisitors != null) {
        for (IIdentityInstVisitor v : identityVisitors)
            v.visit(s);
    }
}
项目:petablox    文件:RelIdentityInst.java   
public void visit(JIdentityStmt s) {
    add(s, s.getLeftOp(), s.getRightOp());
}
项目:petablox    文件:IIdentityInstVisitor.java   
public void visit(JIdentityStmt s);