use of soot.util.NumberedString in project soot by Sable.
the class GeomPointsTo method getCallTargets.
/**
* 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);
}
}
use of soot.util.NumberedString in project soot by Sable.
the class SootClass method getMethodUnsafe.
/*
* Returns the method of this class with the given subsignature. If no method
* with the given subsignature can be found, null is returned.
*/
public SootMethod getMethodUnsafe(String subsignature) {
checkLevel(SIGNATURES);
NumberedString numberedString = Scene.v().getSubSigNumberer().find(subsignature);
return numberedString == null ? null : getMethodUnsafe(numberedString);
}
use of soot.util.NumberedString in project soot by Sable.
the class VirtualCalls method resolveLibrarySignature.
protected void resolveLibrarySignature(Type declaredType, Type sigType, NumberedString subSig, SootMethod container, ChunkedQueue<SootMethod> targets, boolean appOnly, RefType base) {
FastHierarchy fastHierachy = Scene.v().getOrMakeFastHierarchy();
assert (declaredType instanceof RefType);
Pair<Type, NumberedString> pair = new Pair<Type, NumberedString>(base, subSig);
{
Set<Pair<Type, NumberedString>> types = baseToPossibleSubTypes.get(pair);
// just retrieve the previous result.
if (types != null) {
for (Pair<Type, NumberedString> tuple : types) {
Type st = tuple.getO1();
if (!fastHierachy.canStoreType(st, declaredType)) {
resolve(st, st, sigType, subSig, container, targets, appOnly);
} else {
resolve(st, declaredType, sigType, subSig, container, targets, appOnly);
}
}
return;
}
}
Set<Pair<Type, NumberedString>> types = new HashSet<Pair<Type, NumberedString>>();
// get return type; method name; parameter types
String[] split = subSig.getString().replaceAll("(.*) (.*)\\((.*)\\)", "$1;$2;$3").split(";");
Type declaredReturnType = Scene.v().getType(split[0]);
String declaredName = split[1];
List<Type> declaredParamTypes = new ArrayList<Type>();
// separate the parameter types
if (split.length == 3) {
for (String type : split[2].split(",")) {
declaredParamTypes.add(Scene.v().getType(type));
}
}
Chain<SootClass> classes = Scene.v().getClasses();
for (SootClass sc : classes) {
for (SootMethod sm : sc.getMethods()) {
if (sm.isConcrete() || sm.isNative()) {
// method name has to match
if (!sm.getName().equals(declaredName))
continue;
// type or a sub type of it
if (!fastHierachy.canStoreType(sm.getReturnType(), declaredReturnType))
continue;
List<Type> paramTypes = sm.getParameterTypes();
// ones (same type or super type).
if (declaredParamTypes.size() != paramTypes.size())
continue;
boolean check = true;
for (int i = 0; i < paramTypes.size(); i++) {
if (!fastHierachy.canStoreType(declaredParamTypes.get(i), paramTypes.get(i))) {
check = false;
break;
}
}
if (check) {
Type st = sc.getType();
if (!fastHierachy.canStoreType(st, declaredType)) {
// therefore not used in library client
if (!sc.isFinal()) {
NumberedString newSubSig = sm.getNumberedSubSignature();
resolve(st, st, sigType, newSubSig, container, targets, appOnly);
types.add(new Pair<Type, NumberedString>(st, newSubSig));
}
} else {
resolve(st, declaredType, sigType, subSig, container, targets, appOnly);
types.add(new Pair<Type, NumberedString>(st, subSig));
}
}
}
}
}
baseToPossibleSubTypes.putAll(pair, types);
}
use of soot.util.NumberedString in project soot by Sable.
the class OnFlyCallGraphBuilder method findReceivers.
private void findReceivers(SootMethod m, Body b) {
for (final Unit u : b.getUnits()) {
final Stmt s = (Stmt) u;
if (s.containsInvokeExpr()) {
InvokeExpr ie = s.getInvokeExpr();
if (ie instanceof InstanceInvokeExpr) {
InstanceInvokeExpr iie = (InstanceInvokeExpr) ie;
Local receiver = (Local) iie.getBase();
NumberedString subSig = iie.getMethodRef().getSubSignature();
addVirtualCallSite(s, m, receiver, iie, subSig, Edge.ieToKind(iie));
if (subSig == sigStart) {
addVirtualCallSite(s, m, receiver, iie, sigRun, Kind.THREAD);
} else if (subSig == sigExecutorExecute || subSig == sigHandlerPost || subSig == sigHandlerPostAtFrontOfQueue || subSig == sigHandlerPostAtTime || subSig == sigHandlerPostAtTimeWithToken || subSig == sigHandlerPostDelayed) {
if (iie.getArgCount() > 0) {
Value runnable = iie.getArg(0);
if (runnable instanceof Local)
addVirtualCallSite(s, m, (Local) runnable, iie, sigRun, Kind.EXECUTOR);
}
} else if (subSig == sigHandlerSendEmptyMessage || subSig == sigHandlerSendEmptyMessageAtTime || subSig == sigHandlerSendEmptyMessageDelayed || subSig == sigHandlerSendMessage || subSig == sigHandlerSendMessageAtFrontOfQueue || subSig == sigHandlerSendMessageAtTime || subSig == sigHandlerSendMessageDelayed) {
addVirtualCallSite(s, m, receiver, iie, sigHandlerHandleMessage, Kind.HANDLER);
} else if (subSig == sigExecute) {
addVirtualCallSite(s, m, receiver, iie, sigDoInBackground, Kind.ASYNCTASK);
}
} else if (ie instanceof DynamicInvokeExpr) {
if (options.verbose())
logger.debug("" + "WARNING: InvokeDynamic to " + ie + " not resolved during call-graph construction.");
} else {
SootMethod tgt = ie.getMethod();
if (tgt != null) {
addEdge(m, s, tgt);
String signature = tgt.getSignature();
if (signature.equals("<java.security.AccessController: java.lang.Object doPrivileged(java.security.PrivilegedAction)>") || signature.equals("<java.security.AccessController: java.lang.Object doPrivileged(java.security.PrivilegedExceptionAction)>") || signature.equals("<java.security.AccessController: java.lang.Object doPrivileged(java.security.PrivilegedAction,java.security.AccessControlContext)>") || signature.equals("<java.security.AccessController: java.lang.Object doPrivileged(java.security.PrivilegedExceptionAction,java.security.AccessControlContext)>")) {
Local receiver = (Local) ie.getArg(0);
addVirtualCallSite(s, m, receiver, null, sigObjRun, Kind.PRIVILEGED);
}
} else {
if (!Options.v().ignore_resolution_errors()) {
throw new InternalError("Unresolved target " + ie.getMethod() + ". Resolution error should have occured earlier.");
}
}
}
}
}
}
use of soot.util.NumberedString in project soot by Sable.
the class SootClass method declaresMethod.
/**
* Does this class declare a method with the given subsignature?
*/
public boolean declaresMethod(String subsignature) {
checkLevel(SIGNATURES);
NumberedString numberedString = Scene.v().getSubSigNumberer().find(subsignature);
return numberedString == null ? false : declaresMethod(numberedString);
}
Aggregations