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


Java Stmt.addTag方法代码示例

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


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

示例1: internalTransform

import soot.jimple.Stmt; //导入方法依赖的package包/类
protected void internalTransform(
        Body b, String phaseName, Map opts)
{

   
    MHGDominatorsFinder analysis = new MHGDominatorsFinder(new ExceptionalUnitGraph(b));
    Iterator it = b.getUnits().iterator();
    while (it.hasNext()){
        Stmt s = (Stmt)it.next();
        List dominators = analysis.getDominators(s);
        Iterator dIt = dominators.iterator();
        while (dIt.hasNext()){
            Stmt ds = (Stmt)dIt.next();
            String info = ds+" dominates "+s;
            s.addTag(new LinkTag(info, ds, b.getMethod().getDeclaringClass().getName(), "Dominators"));
        }
    }
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:19,代码来源:DominatorsTagger.java

示例2: internalTransform

import soot.jimple.Stmt; //导入方法依赖的package包/类
@Override
protected void internalTransform(Body b, String phaseName, Map<String, String> options) {		
	// Do not instrument methods in framework classes
	if (!canInstrumentMethod(b.getMethod()))
		return;
	
	// Make a reference to the tracker method
	SootMethodRef ref = Scene.v().makeMethodRef(
			Scene.v().getSootClass(UtilInstrumenter.JAVA_CLASS_FOR_CODE_POSITIONS),
			"setLastExecutedStatement",
			Collections.<Type>singletonList(IntType.v()),
			VoidType.v(),
			true);
	final String methodSig = b.getMethod().getSignature();
	
	// Iterate over all the units and add a unit that sets the current
	// execution pointer
	int curLineNum = 0;
	for (Iterator<Unit> unitIt = b.getUnits().snapshotIterator(); unitIt.hasNext(); ) {
		Unit curUnit = unitIt.next();
		
		// If we're still inside the IdentityStmt block, there's nothing to
		// instrument
		if (curUnit instanceof IdentityStmt ||
				// If this unit was instrumented by another transformer, there's nothing to instrument
				curUnit.hasTag(InstrumentedCodeTag.name))
			continue;
		
		// Get the current code positions
		CodePosition codePos = codePositionManager.getCodePositionForUnit(curUnit,
				methodSig, curLineNum++, ((Stmt) curUnit).getJavaSourceStartLineNumber());
		
		Stmt setCodePosStmt = Jimple.v().newInvokeStmt(
				Jimple.v().newStaticInvokeExpr(ref, IntConstant.v(codePos.getID())));
		setCodePosStmt.addTag(new InstrumentedCodeTag());
		
		b.getUnits().insertAfter(setCodePosStmt, curUnit);
	}
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:40,代码来源:CodePositionTracking.java

示例3: internalTransform

import soot.jimple.Stmt; //导入方法依赖的package包/类
@Override
protected void internalTransform(Body b, String phaseName,
		Map<String, String> options) {
	// Do not instrument methods in framework classes
	if (!canInstrumentMethod(b.getMethod()))
		return;
	
	// Create method references
	final SootMethodRef targetReachedRef = Scene.v().makeMethodRef(
			Scene.v().getSootClass(UtilInstrumenter.JAVA_CLASS_FOR_CODE_POSITIONS),
			"reportTargetReachedSynchronous",
			Collections.<Type>emptyList(),
			VoidType.v(),
			true);
	
	// Iterate over the method and find calls to the target methods
	for (Iterator<Unit> unitIt = b.getUnits().snapshotIterator(); unitIt.hasNext(); ) {
		Stmt stmt = (Stmt) unitIt.next();
		
		if(targetSignatures.contains(stmt)){
			// Notify the server that the target was reached
			Stmt reachedStmt = Jimple.v().newInvokeStmt(
					Jimple.v().newStaticInvokeExpr(targetReachedRef));
			reachedStmt.addTag(new InstrumentedCodeTag());
			b.getUnits().insertBefore(reachedStmt, stmt);
		}
	}
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:29,代码来源:GoalReachedTracking.java

示例4: internalTransform

import soot.jimple.Stmt; //导入方法依赖的package包/类
@Override
protected void internalTransform(String phaseName,
		Map<String, String> options) {
	// Make a reference to the registration method
	SootMethodRef ref = Scene.v().makeMethodRef(
			Scene.v().getSootClass(UtilInstrumenter.JAVA_CLASS_FOR_CRASH_REPORTING),
			"registerExceptionHandler",
			Collections.<Type>emptyList(),
			VoidType.v(),
			true);
	
	for (String sig : methodsToInstrument) {
		try{
			SootMethod sm = Scene.v().grabMethod(sig);
			if(sm == null)
				continue;
			
			for (Iterator<Unit> unitIt = sm.getActiveBody().getUnits()
					.snapshotIterator(); unitIt.hasNext(); ) {
				Unit curUnit = unitIt.next();
				
				// If we're still inside the IdentityStmt block, there's nothing to
				// instrument
				if (curUnit instanceof IdentityStmt)
					continue;
				
				// Put the registration in
				Stmt stmt = Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(ref));
				stmt.addTag(new InstrumentedCodeTag());					
				sm.getActiveBody().getUnits().insertAfter(stmt, curUnit);
				break;
			}
		}catch(Exception ex) {
			ex.printStackTrace();
		}
	}
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:38,代码来源:CrashReporterInjection.java

示例5: checkAndReport

import soot.jimple.Stmt; //导入方法依赖的package包/类
private void checkAndReport(Body b, Stmt curStmt, Value value, int paramIdx) {
	LocalGenerator localGenerator = new LocalGenerator(b);
	RefType stringType = RefType.v("java.lang.String");
	Value lhs = value;
	
	if(lhs instanceof StringConstant)
		return;
	else if(lhs instanceof IntConstant)
		return;
	
	// If this is a CharSequence, we need to convert it into a string
	if (lhs.getType() == RefType.v("java.lang.CharSequence") ||
			lhs.getType() == RefType.v("java.lang.StringBuilder") && lhs instanceof Local) {
		SootMethodRef toStringRef = Scene.v().getMethod("<java.lang.Object: "
				+ "java.lang.String toString()>").makeRef();
		Local stringLocal = localGenerator.generateLocal(stringType);
		Stmt stringAssignStmt = Jimple.v().newAssignStmt(stringLocal,
				Jimple.v().newVirtualInvokeExpr((Local) lhs, toStringRef));
		stringAssignStmt.addTag(new InstrumentedCodeTag());
		
		b.getUnits().insertBefore(stringAssignStmt, curStmt);
		lhs = stringLocal;
	}
	else if (lhs.getType() != IntType.v() && lhs.getType() != stringType)
		return;
	
	//new String() case
	if (value instanceof NewExpr)
		return;
	
	// Depending on the type of the value, we might need an intermediate local
	if (!(lhs instanceof Local)) {
		Local newLhs = localGenerator.generateLocal(lhs.getType());
		AssignStmt assignLocalStmt = Jimple.v().newAssignStmt(newLhs, lhs);
		assignLocalStmt.addTag(new InstrumentedCodeTag());
		b.getUnits().insertBefore(assignLocalStmt, curStmt);
		lhs = newLhs;
	}
	
	// Report the value
	Stmt reportValueStmt;
	if (lhs.getType() == stringType) {
		reportValueStmt = Jimple.v().newInvokeStmt(
				Jimple.v().newStaticInvokeExpr(refString, lhs, IntConstant.v(paramIdx)));
	}
	else if (lhs.getType() == IntType.v()) {
		reportValueStmt = Jimple.v().newInvokeStmt(
				Jimple.v().newStaticInvokeExpr(refInt, lhs, IntConstant.v(paramIdx)));
	}
	else
		return;
	reportValueStmt.addTag(new InstrumentedCodeTag());
	
	b.getUnits().insertBefore(reportValueStmt, curStmt);
}
 
开发者ID:srasthofer,项目名称:FuzzDroid,代码行数:56,代码来源:DynamicValueTransformer.java


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