Java Code Examples for soot.jimple.InstanceInvokeExpr#getBase()

The following examples show how to use soot.jimple.InstanceInvokeExpr#getBase() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeomPointsTo.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Obtain the set of possible call targets at given @param callsite.
 */
private void getCallTargets(IVarAbstraction pn, SootMethod src,
		Stmt callsite, ChunkedQueue<SootMethod> targetsQueue)
{
	InstanceInvokeExpr iie = (InstanceInvokeExpr)callsite.getInvokeExpr();
	Local receiver = (Local)iie.getBase();
	NumberedString subSig = iie.getMethodRef().getSubSignature();
	
	// We first build the set of possible call targets
	for (AllocNode an : pn.get_all_points_to_objects()) {
		Type type = an.getType();
		if (type == null) continue;

		VirtualCalls.v().resolve(type, 
				receiver.getType(), subSig, src,
				targetsQueue);
	}
}
 
Example 2
Source File: TypeStateMachineWeightFunctions.java    From SPDS with Eclipse Public License 2.0 6 votes vote down vote up
protected Collection<Val> generateAtConstructor(SootMethod m, Unit unit, Collection<SootMethod> calledMethod,
        MatcherTransition initialTrans) {
    boolean matches = false;
    for (SootMethod method : calledMethod) {
        if (initialTrans.matches(method)) {
            matches = true;
        }
    }
    if (!matches)
        return Collections.emptySet();
    if (unit instanceof Stmt) {
        Stmt stmt = (Stmt) unit;
        if (stmt.containsInvokeExpr())
            if (stmt.getInvokeExpr() instanceof InstanceInvokeExpr) {
                InstanceInvokeExpr iie = (InstanceInvokeExpr) stmt.getInvokeExpr();
                if (iie.getBase() instanceof Local) {
                    Local l = (Local) iie.getBase();
                    Set<Val> out = new HashSet<>();
                    out.add(new Val(l, m));
                    return out;
                }
            }
    }
    return Collections.emptySet();
}
 
Example 3
Source File: NullnessAssumptionAnalysis.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private void handleInvokeExpr(InvokeExpr invokeExpr,AnalysisInfo out) {
		if(invokeExpr instanceof InstanceInvokeExpr) {
			InstanceInvokeExpr instanceInvokeExpr = (InstanceInvokeExpr) invokeExpr;
			//here we know that the receiver must point to an object
			Value base = instanceInvokeExpr.getBase();
			out.put(base,NON_NULL);
		}
		//but the returned object might point to everything
//		out.put(invokeExpr, TOP);
	}
 
Example 4
Source File: NullnessAnalysis.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private void handleInvokeExpr(InvokeExpr invokeExpr,AnalysisInfo out) {
	if(invokeExpr instanceof InstanceInvokeExpr) {
		InstanceInvokeExpr instanceInvokeExpr = (InstanceInvokeExpr) invokeExpr;
		//here we know that the receiver must point to an object
		Value base = instanceInvokeExpr.getBase();
		out.put(base,NON_NULL);
	}
}
 
Example 5
Source File: OnTheFlyJimpleBasedICFG.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Set<SootMethod> load(Unit u) throws Exception {
	Stmt stmt = (Stmt)u;
	InvokeExpr ie = stmt.getInvokeExpr();
	FastHierarchy fastHierarchy = Scene.v().getFastHierarchy();
	//FIXME Handle Thread.start etc.
	if(ie instanceof InstanceInvokeExpr) {
		if(ie instanceof SpecialInvokeExpr) {
			//special
			return Collections.singleton(ie.getMethod());
		} else {
			//virtual and interface
			InstanceInvokeExpr iie = (InstanceInvokeExpr) ie;
			Local base = (Local) iie.getBase();
			RefType concreteType = bodyToLMNAA.getUnchecked(unitToOwner.get(u)).concreteType(base, stmt);
			if(concreteType!=null) {
				//the base variable definitely points to a single concrete type 
				SootMethod singleTargetMethod = fastHierarchy.resolveConcreteDispatch(concreteType.getSootClass(), iie.getMethod());
				return Collections.singleton(singleTargetMethod);
			} else {
				SootClass baseTypeClass;
				if(base.getType() instanceof RefType) {
					RefType refType = (RefType) base.getType();
					baseTypeClass = refType.getSootClass();
				} else if(base.getType() instanceof ArrayType) {
					baseTypeClass = Scene.v().getSootClass("java.lang.Object");
				} else if(base.getType() instanceof NullType) {
					//if the base is definitely null then there is no call target
					return Collections.emptySet();
				} else {
					throw new InternalError("Unexpected base type:"+base.getType());
				}
				return fastHierarchy.resolveAbstractDispatch(baseTypeClass, iie.getMethod());
			}
		}
	} else {
		//static
		return Collections.singleton(ie.getMethod());
	}
}
 
Example 6
Source File: ExprVisitor.java    From JAADAS with GNU General Public License v3.0 5 votes vote down vote up
private List<Register> getInstanceInvokeArgumentRegs(InstanceInvokeExpr iie) {
	constantV.setOrigStmt(origStmt);
	List<Register> argumentRegs = getInvokeArgumentRegs(iie);
	// always add reference to callee as first parameter (instance != static)
	Value callee = iie.getBase();
	Register calleeRegister = regAlloc.asLocal(callee);
	argumentRegs.add(0, calleeRegister);
	return argumentRegs;
}
 
Example 7
Source File: TypeStateMachineWeightFunctions.java    From SPDS with Eclipse Public License 2.0 5 votes vote down vote up
protected Collection<WeightedForwardQuery<TransitionFunction>> generateThisAtAnyCallSitesOf(SootMethod m, Unit unit,
        Collection<SootMethod> invokesMethod) {
    if (unit instanceof Stmt) {
        if (((Stmt) unit).containsInvokeExpr() && ((Stmt) unit).getInvokeExpr() instanceof InstanceInvokeExpr) {
            InstanceInvokeExpr iie = (InstanceInvokeExpr) ((Stmt) unit).getInvokeExpr();
            if (invokesMethod.contains(iie.getMethod())) {
                Local thisLocal = (Local) iie.getBase();
                return Collections.singleton(new WeightedForwardQuery<>(new Statement((Stmt) unit, m),
                        new AllocVal(thisLocal, m, iie, new Statement((Stmt) unit, m)), initialTransition()));
            }
        }
    }

    return Collections.emptySet();
}