当前位置: 首页>>代码示例>>Java>>正文


Java DefinitionStmt类代码示例

本文整理汇总了Java中soot.jimple.DefinitionStmt的典型用法代码示例。如果您正苦于以下问题:Java DefinitionStmt类的具体用法?Java DefinitionStmt怎么用?Java DefinitionStmt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefinitionStmt类属于soot.jimple包,在下文中一共展示了DefinitionStmt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: internalTransform

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
@Override
protected void internalTransform(Body body, String phaseName, Map<String, String> options) {
	// Do not instrument methods in framework classes
	if (!canInstrumentMethod(body.getMethod()))
		return;
	
	instrumentInfoAboutNonAPICall(body);
	
	//important to use snapshotIterator here
	Iterator<Unit> iterator = body.getUnits().snapshotIterator();
	while(iterator.hasNext()){
		Unit unit = iterator.next();
		if(unit instanceof ReturnStmt || unit instanceof ReturnVoidStmt)
			instrumentInfoAboutReturnStmt(body, unit);
		else if(unit instanceof DefinitionStmt || unit instanceof InvokeStmt)
			instrumentInfoAboutNonApiCaller(body, unit);
		else if(unit instanceof IfStmt)
			instrumentEachBranchAccess(body, (IfStmt)unit);
	}				
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:21,代码来源:PathExecutionTransformer.java

示例2: removeUnit

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
public static void removeUnit(Body b, Unit u) {
    LocalGenerator lg = new LocalGenerator(b);
    if (u instanceof DefinitionStmt) {
        DefinitionStmt def = (DefinitionStmt) u;
        Type t = def.getRightOp().getType();
        if (!(t instanceof PrimType)) {
            Local l_obj = lg.generateLocal(RefType.v("java.lang.Object"));
            Local l_type = lg.generateLocal(t);
            Unit u1 = Jimple.v().newAssignStmt(l_obj,
                    Jimple.v().newNewExpr(RefType.v("java.lang.Object")));
            Unit u2 = Jimple.v().newAssignStmt(l_type, Jimple.v().newCastExpr(l_obj, t));
            def.getRightOpBox().setValue(l_type);
            b.getUnits().insertBefore(u1, u);
            b.getUnits().insertBefore(u2, u);
            return;
        }
    }
    b.getUnits().remove(u);
}
 
开发者ID:Alexandre-Bartel,项目名称:permission-map,代码行数:20,代码来源:Util.java

示例3: handleAssign

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
void handleAssign(DefinitionStmt stmt) {
	Value lval = stmt.getLeftOp();
	Value rval = stmt.getRightOp();
	Variable rvar;
	if (lval instanceof Local) {
		rvar = getLocalVariable((Local)lval);
	} else {
		rvar = jt.makeVariable(rval);
	}
	et.translateExpr(rvar, stmt.getRightOpBox());
	if (lval instanceof ArrayRef) {
		notSupported("We do not support arrays");
	} else if (lval instanceof FieldRef) {
		notSupported("We do not support field references");
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:17,代码来源:StmtTranslator.java

示例4: handleRefTypeAssignment

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
private void handleRefTypeAssignment(DefinitionStmt assignStmt,
		AnalysisInfo rhsInfo, AnalysisInfo out) {
	Value left = assignStmt.getLeftOp();
	Value right = assignStmt.getRightOp();
	
	//unbox casted value
	if(right instanceof JCastExpr) {
		JCastExpr castExpr = (JCastExpr) right;
		right = castExpr.getOp();
	}
	
	// An assignment invalidates any assumptions of null/non-null for lhs
	// We COULD be more accurate by assigning those assumptions to the rhs prior to this statement
	rhsInfo.put(right,BOTTOM);
	
	//assign from rhs to lhs
	out.put(left,rhsInfo.get(right));
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:19,代码来源:NullnessAssumptionAnalysis.java

示例5: flowThrough

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
protected void flowThrough(HashMap<Local,Set<NewExpr>> in, Unit unit,
		HashMap<Local,Set<NewExpr>> out)
{
    Stmt    s   = (Stmt)    unit;

    out.clear();
    out.putAll(in);

    if (s instanceof DefinitionStmt) {
        DefinitionStmt ds = (DefinitionStmt) s;
        Value lhs = ds.getLeftOp();
        Value rhs = ds.getRightOp();
        if (lhs instanceof Local) {
            HashSet<NewExpr> lv = new HashSet<NewExpr>();
            out.put((Local) lhs, lv);
            if (rhs instanceof NewExpr) {
                lv.add((NewExpr) rhs);
            } else if (rhs instanceof Local) {
                lv.addAll(in.get(rhs));
            } else lv.add(UNKNOWN);
        }
    }
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:24,代码来源:LocalMustNotAliasAnalysis.java

示例6: inASTMethodNode

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
public void inASTMethodNode(ASTMethodNode node){
	Stmt s = ofInterest.get_Stmt();
	//check this is a definition
	if(! (s instanceof DefinitionStmt )){
		possible=false;
		return;
	}
		
	Value defined = ((DefinitionStmt)s).getLeftOp();
	if(!(defined instanceof Local)){
		possible=false;
		return;
	}
	
	//check that this is a local defined in this method
	//its a sanity check
	List declaredLocals = node.getDeclaredLocals();
	if(!declaredLocals.contains(defined)){
		possible=false;
		return;
	}
	definedLocal = (Local)defined;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:24,代码来源:InitializationDeclarationShortcut.java

示例7: convertVarStoreInsn

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
private void convertVarStoreInsn(VarInsnNode insn) {
	int op = insn.getOpcode();
	boolean dword = op == LSTORE || op == DSTORE;
	StackFrame frame = getFrame(insn);
	Operand opr = dword ? popDual() : pop();
	Local local = getLocal(insn.var);
	if (!units.containsKey(insn)) {
		DefinitionStmt as = Jimple.v().newAssignStmt(local, opr.stackOrValue());
		opr.addBox(as.getRightOpBox());
		frame.boxes(as.getRightOpBox());
		frame.in(opr);
		setUnit(insn, as);
	} else {
		frame.mergeIn(opr);
	}
	assignReadOps(local);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:18,代码来源:AsmMethodSource.java

示例8: convertLabel

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
private void convertLabel(LabelNode ln) {
	if (!trapHandlers.containsKey(ln))
		return;
	StackFrame frame = getFrame(ln);
	Operand[] out = frame.out();
	Operand opr;
	if (out == null) {
		CaughtExceptionRef ref = Jimple.v().newCaughtExceptionRef();
		Local stack = newStackLocal();
		DefinitionStmt as = Jimple.v().newIdentityStmt(stack, ref);
		opr = new Operand(ln, ref);
		opr.stack = stack;
		frame.out(opr);
		setUnit(ln, as);
	} else {
		opr = out[0];
	}
	push(opr);
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:20,代码来源:AsmMethodSource.java

示例9: checkAccessStmt

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
private void checkAccessStmt(Stmt sootStmt, SootMethod currentMethod)
{
	if(sootStmt.containsFieldRef())
	{
		SootField accessField = sootStmt.getFieldRef().getField();
   		boolean isWrite = (((DefinitionStmt)sootStmt).getLeftOp() instanceof FieldRef);
   		boolean isStatic = (sootStmt.getFieldRef() instanceof StaticFieldRef);
   		Value object = isStatic ? NullConstant.v() : ((InstanceFieldRef)sootStmt.getFieldRef()).getBase();
   		
   		String methodSig = currentMethod.getSignature();
   		
   		List<Value> currentLocks = new ArrayList<Value>(lockStack);
   		
   		System.out.println(isWrite+" access on "+isStatic+" field "+accessField+" of "+object+" in "+methodSig+" with "+currentLocks.size()+" locks");
   		
   		if(!variableAccesses.containsKey(methodSig))
   		{
   			variableAccesses.put(methodSig, new HashSet<VariableAccess>());
   		}
   		variableAccesses.get(currentMethod.getSignature()).add(
   				new VariableAccess(accessField, sootStmt, currentMethod, isWrite, isStatic, currentLocks));
	}
}
 
开发者ID:k4v,项目名称:Sus,代码行数:24,代码来源:BodyAnalysis.java

示例10: getIntConstantsFromLocal

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
void getIntConstantsFromLocal(SimpleLocalDefs sld, Local l, Unit u, List<String> whats) throws IOException {
	Iterator<Unit> iter = sld.getDefsOfAt(l, u).iterator();
	while (iter.hasNext()) {
		Unit def = iter.next();
		if (! (def instanceof DefinitionStmt)) continue;
		DefinitionStmt assign = (DefinitionStmt) def;
		Value rightOp = assign.getRightOp();
		if (rightOp instanceof IntConstant) {
			whats.add(rightOp.toString());
		} else if (rightOp instanceof ParameterRef){
			whats.add(rightOp.toString());
		} else if (rightOp instanceof Local) {
			getIntConstantsFromLocal(sld, (Local)rightOp, def, whats);
			print("getIntConstantsFromLocal -> local");
		} else {
			print("???"+def.toString());
		}
	}
}
 
开发者ID:USC-NSL,项目名称:SIF,代码行数:20,代码来源:FindMessage.java

示例11: propagateCallToReturnFlow

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
@Override
public KillGenInfo propagateCallToReturnFlow(Trackable trackable, Stmt callSite) {
	if (!(callSite instanceof DefinitionStmt))
		return identity();

	Taint taint = (Taint) trackable;
	DefinitionStmt defStmt = (DefinitionStmt) callSite;
	if (!defStmt.getLeftOp().equals(taint.value))
		return identity();

	if (defStmt.getLeftOp() instanceof Local) {
		return kill();
	} else {
		// if the stmt defines a local then we know that this value we
		// definitely overwritten;
		// if it does not define a local (but, say, a FieldRef) then the
		// value *may* have been
		// overwritten; hence we need to track the source, too
		return identity();
	}
}
 
开发者ID:johanneslerch,项目名称:FlowTwist,代码行数:22,代码来源:DefaultTaintPropagator.java

示例12: applySanitizer

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
/***** API calls *****/

	// Sanitizer for user study. Kill the parameter and its aliases
	private boolean applySanitizer(Unit call, FlowAbstraction source) {

		// Call itself
		Stmt stmt = (Stmt) call;
		final String target = stmt.getInvokeExpr().getMethod().getSignature();
		final List<Value> args = stmt.getInvokeExpr().getArgs();

		if (!target.equals("<sanitizers.Sanitizer: void sanitize(java.lang.Object)>"))
			return false;

		if (killforSanit(call, args.get(0), source))
			return true;

		// Case of valueOf for primitive types
		// a = Integer.valueOf(b); and sanit(a) -> must also treat aliases of b
		List<Unit> predecessors = icfg.getPredsOf(call);
		for (Unit predecessor : predecessors) {
			if (predecessor instanceof DefinitionStmt) {
				DefinitionStmt def = (DefinitionStmt) predecessor;
				if (def.getLeftOp().equals(args.get(0)) && def.getRightOp() instanceof StaticInvokeExpr) {
					InvokeExpr expr = (StaticInvokeExpr) def.getRightOp();
					final SootMethod method = expr.getMethod();
					if (method.getName().equals("valueOf") && expr.getArgCount() == 1
							&& method.getDeclaringClass().getType().equals(method.getReturnType())
							&& isPrimitiveType(method.getReturnType())) {
						if (killforSanit(predecessor, expr.getArg(0), source))
							return true;
					}
				}
			}
		}
		return false;
	}
 
开发者ID:secure-software-engineering,项目名称:cheetah,代码行数:37,代码来源:AnalysisTask.java

示例13: methodIsAndroidStub

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
/**
 * Checks whether the given method is a library stub method
 * @param method The method to check
 * @return True if the given method is an Android library stub, false
 * otherwise
 */
private boolean methodIsAndroidStub(SootMethod method) {		
	if (!(Options.v().src_prec() == Options.src_prec_apk
			&& method.getDeclaringClass().isLibraryClass()
			&& SystemClassHandler.isClassInSystemPackage(
					method.getDeclaringClass().getName())))
		return false;
	
	// Check whether there is only a single throw statement
	for (Unit u : method.getActiveBody().getUnits()) {
		if (u instanceof DefinitionStmt) {
			DefinitionStmt defStmt = (DefinitionStmt) u;
			if (!(defStmt.getRightOp() instanceof ThisRef)
					&& !(defStmt.getRightOp() instanceof ParameterRef)
					&& !(defStmt.getRightOp() instanceof NewExpr))
				return false;
		}
		else if (u instanceof InvokeStmt) {
			InvokeStmt stmt = (InvokeStmt) u;
			
			// Check for exception constructor invocations
			SootMethod callee = stmt.getInvokeExpr().getMethod();
			if (!callee.getSubSignature().equals("void <init>(java.lang.String)"))
				// Check for super class constructor invocation
				if (!(method.getDeclaringClass().hasSuperclass()
						&& callee.getDeclaringClass() == method.getDeclaringClass().getSuperclass()
						&& callee.getName().equals("<init>")))
					return false;
		}
		else if (!(u instanceof ThrowStmt))
			return false;
	}
	return true;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:40,代码来源:InterproceduralConstantValuePropagator.java

示例14: getSourceInfo

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
@Override
public SourceInfo getSourceInfo(Stmt sCallSite, InterproceduralCFG<Unit, SootMethod> cfg) {
	if (sCallSite.containsInvokeExpr()
			&& sCallSite instanceof DefinitionStmt
			&& sCallSite.getInvokeExpr().getMethod().getName().equals("getSecret")) {
		AccessPath ap = new AccessPath(((DefinitionStmt) sCallSite).getLeftOp(), true);
		return new SourceInfo(ap);
	}
	return null;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:11,代码来源:SourceSinkTests.java

示例15: handleRefTypeAssignment

import soot.jimple.DefinitionStmt; //导入依赖的package包/类
private void handleRefTypeAssignment(DefinitionStmt assignStmt, AnalysisInfo out) {
	Value left = assignStmt.getLeftOp();
	Value right = assignStmt.getRightOp();
	
	//unbox casted value
	if(right instanceof JCastExpr) {
		JCastExpr castExpr = (JCastExpr) right;
		right = castExpr.getOp();
	}
	
	//if we have a definition (assignment) statement to a ref-like type, handle it,
	if ( isAlwaysNonNull(right)
	|| right instanceof NewExpr || right instanceof NewArrayExpr
	|| right instanceof NewMultiArrayExpr || right instanceof ThisRef
	|| right instanceof StringConstant || right instanceof ClassConstant
	|| right instanceof CaughtExceptionRef) {
		//if we assign new... or @this, the result is non-null
		out.put(left,NON_NULL);
	} else if(right==NullConstant.v()) {
		//if we assign null, well, it's null
		out.put(left, NULL);
	} else if(left instanceof Local && right instanceof Local) {
		out.put(left, out.get(right));
	} else {
		out.put(left, TOP);
	}
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:28,代码来源:NullnessAnalysis.java


注:本文中的soot.jimple.DefinitionStmt类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。