本文整理汇总了Java中soot.toolkits.scalar.SimpleLocalDefs类的典型用法代码示例。如果您正苦于以下问题:Java SimpleLocalDefs类的具体用法?Java SimpleLocalDefs怎么用?Java SimpleLocalDefs使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleLocalDefs类属于soot.toolkits.scalar包,在下文中一共展示了SimpleLocalDefs类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIntConstantsFromLocal
import soot.toolkits.scalar.SimpleLocalDefs; //导入依赖的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());
}
}
}
示例2: findConditionalStatementForBooleanUnit
import soot.toolkits.scalar.SimpleLocalDefs; //导入依赖的package包/类
private static IfStmt findConditionalStatementForBooleanUnit(IInfoflowCFG cfg, Unit booleanUnit) {
Stack<Unit> worklist = new Stack<Unit>();
Set<Unit> processedUnits = new HashSet<Unit>();
worklist.add(booleanUnit);
while(!worklist.isEmpty()) {
Unit currentUnit = worklist.pop();
//in case of a loop or recursion
if(processedUnits.contains(currentUnit))
continue;
processedUnits.add(currentUnit);
//skip our own instrumented code
if(currentUnit.hasTag(InstrumentedCodeTag.name))
continue;
//we reached the condition
if(currentUnit instanceof IfStmt) {
return (IfStmt)currentUnit;
}
SootMethod methodOfBooleanUnit = cfg.getMethodOf(booleanUnit);
DirectedGraph<Unit> graph = cfg.getOrCreateUnitGraph(methodOfBooleanUnit);
//Comment: Steven said it should always be a UnitGraph + he will implement a more convenient way in the near future :-)
UnitGraph unitGraph = (UnitGraph)graph;
SimpleLocalDefs defs = new SimpleLocalDefs(unitGraph);
SimpleLocalUses uses = new SimpleLocalUses(unitGraph, defs);
List<UnitValueBoxPair> usesOfCurrentUnit = uses.getUsesOf(booleanUnit);
for(UnitValueBoxPair valueBoxPair : usesOfCurrentUnit)
worklist.add(valueBoxPair.getUnit());
}
return null;
}
示例3: getStringConstantsFromLocal
import soot.toolkits.scalar.SimpleLocalDefs; //导入依赖的package包/类
void getStringConstantsFromLocal(SimpleLocalDefs sld, Local l, Unit u, HashMap<String,String> perms) 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 StringConstant) {
int i=0;
boolean found = false;
while(i<numPerm && !found) {
if (rightOp.toString().equals("\""+permissions[i]+"\"")) {
found = true;
if (u instanceof DefinitionStmt && !isKnownCheck(u.toString())) {
perms.put(permissions[i], "NOTDIRECTUSE");
} else {
perms.put(permissions[i], "");
}
}
i++;
}
} else if (rightOp instanceof Local) {
getStringConstantsFromLocal(sld, (Local)rightOp, def, perms);
} else {
//irrelevant types
}
}
}
示例4: LocalAnalysis
import soot.toolkits.scalar.SimpleLocalDefs; //导入依赖的package包/类
/**
* Constructed for a given method.
* @param jb the Jimple body of the method
*/
public LocalAnalysis(JimpleBody jb) {
CompleteUnitGraph ug = new CompleteUnitGraph(jb);
unitGraph = ug;
defs = new SimpleLocalDefs(ug);
uses = new SimpleLocalUses(ug,defs);
}
示例5: FindPermissionStringWithFlow
import soot.toolkits.scalar.SimpleLocalDefs; //导入依赖的package包/类
/**
* @param args
* @throws IOException
*/
public FindPermissionStringWithFlow(SootClass mclass) throws IOException {
out = new BufferedWriter(new FileWriter(FILE));
List<SootMethod> methods = mclass.getMethods();
Iterator<SootMethod> iter = methods.iterator();
loadPermissions();
// loop through methods
while (iter.hasNext()) {
SootMethod m = iter.next();
if (! m.isConcrete()) continue;
try {
Body b = m.retrieveActiveBody();
Iterator<Unit> iter_u = b.getUnits().iterator();
SimpleLocalDefs sld = new SimpleLocalDefs(new ExceptionalUnitGraph(b));
while (iter_u.hasNext()) {
Unit u = iter_u.next();
Iterator<ValueBox> iter_vb = u.getUseBoxes().iterator();
while (iter_vb.hasNext()) {
Value v = iter_vb.next().getValue();
if (v instanceof StringConstant) {
int i=0;
boolean found = false;
while(i<numPerm && !found) {
if (v.toString().equals("\""+permissions[i]+"\"")) {
found = true;
if (u instanceof DefinitionStmt && !isKnownCheck(u.toString())) {
print("PER:"+permissions[i]+"METHOD:"+m.toString()+"STMT:"+u.toString()+"NOTDIRECTUSE");
} else {
print("PER:"+permissions[i]+"METHOD:"+m.toString()+"STMT:"+u.toString());
}
}
i++;
}
} else if (v instanceof Local) {
HashMap<String,String> localperms = new HashMap<String,String>();
getStringConstantsFromLocal(sld, (Local) v, u, localperms);
Iterator<String> iter_perms = localperms.keySet().iterator();
while (iter_perms.hasNext()) {
String perm = iter_perms.next();
print("PER:"+perm+"METHOD:"+m.toString()+"STMT:"+u.toString()+localperms.get(perm));
}
}
}
}
} catch (RuntimeException e) {
System.err.println(m.toString()+" "+e.getMessage());
}
}
out.close();
}