本文整理汇总了Java中soot.jimple.toolkits.callgraph.CallGraph类的典型用法代码示例。如果您正苦于以下问题:Java CallGraph类的具体用法?Java CallGraph怎么用?Java CallGraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CallGraph类属于soot.jimple.toolkits.callgraph包,在下文中一共展示了CallGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: myDebug
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
private static void myDebug(String message) {
logger.info("start debug... " + message);
{
CallGraph cg = Scene.v().getCallGraph();
Iterator<Edge> edges = cg
.edgesOutOf(Scene
.v()
.getMethod(
"<android.accounts.IAccountAuthenticatorResponse$Stub$Proxy: void onError(int,java.lang.String)>"));
while (edges.hasNext()) {
Edge e = edges.next();
logger.info("edge: " + e);
}
}
logger.info("end debug... " + message);
}
示例2: initIFDS
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
private void initIFDS() {
Scene.v().setCallGraph(new CallGraph());
this.jumpFunctions = new JumpFunctions<Unit, FlowAbstraction, IFDSSolver.BinaryDomain>(IFDSSolver.getAllTop());
this.endSum = HashBasedTable.create();
this.inc = HashBasedTable.create();
this.icfg = new JitIcfg(new ArrayList<SootMethod>()) {
@Override
public Set<SootMethod> getCalleesOfCallAt(Unit u) {
if (currentTask != null)
return currentTask.calleesOfCallAt(u);
else // Empty by default (same behaviour as L1)
return new HashSet<SootMethod>();
}
};
this.reporter.setIFDS(icfg, jumpFunctions);
}
示例3: searchPermissions
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
public static void searchPermissions(CallGraph cg, Map<SootMethod, Set<String>> methodToPermissionSet) {
ForwardSearch.methodToPermissionSet = methodToPermissionSet;
// Set<SootMethod> checkGEOnePermn = new HashSet<SootMethod>(); // methods which check at least one permission
// for (SootMethod sm: methodToPermissionSet.keySet()) {
// if (methodToPermissionSet.get(sm).size() == 0)
// continue;
// checkGEOnePermn.add(sm);
// alreadyComputed.add(sm);
// System.out.println("already computed: "+ sm);
// }
SootMethod main = Scene.v().getMainMethod();
Stack<SootMethod> stack = new Stack<SootMethod>();
stack.push(main);
search(cg, main, stack, 0);
computeEntryPointPermissions();
}
示例4: getDependencies
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
public static Set<Class> getDependencies(Scene scene, CallGraph callGraph, Class<?> clazz) {
Set<Class> dependencies = Sets.newHashSet();
SootClass sootClass = scene.getSootClass(clazz.getName());
for(SootMethod method: sootClass.getMethods())
if(!method.isPhantom())
callGraph.edgesInto(method).forEachRemaining(edge -> {
try {
dependencies.add(Class.forName(edge.getSrc().method().getDeclaringClass().getName()));
} catch (ClassNotFoundException e) {
log.info(String.format("Class not found: %s", edge.getSrc().method().getDeclaringClass().getName()));
}
});
return dependencies;
}
示例5: findTargetMethods
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
private List<SootMethod> findTargetMethods(Unit unit, CallGraph cg, boolean canBeNullList, boolean canBeNative){
List<SootMethod> target = new ArrayList<SootMethod>();
Iterator<Edge> it = cg.edgesOutOf(unit);
while (it.hasNext()){
Edge edge = it.next();
SootMethod targetMethod = edge.tgt();
if (targetMethod.isNative() && !canBeNative )
continue;
if (edge.kind() == Kind.CLINIT )
continue;
target.add(targetMethod);
}
if (target.size() < 1 && !canBeNullList){
throw new RuntimeException("No target method for: "+unit);
}
return target;
}
示例6: RecAnalysis
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
/**
* Do a recursion analysis. We even look at recursive thread generations.
* @param cba The callback resolver for thread calls.
* @param cg The callgraph.
*/
RecAnalysis(CallbackResolver cba, CallGraph cg) {
int size = 0;
Scene scene = Scene.v();
allMethods = new HashSet <SootMethod>();
for (SootClass cl : (Collection <SootClass>) scene.getClasses()) {
for (SootMethod m : (Collection <SootMethod>) cl.getMethods()) {
size++;
allMethods.add(m);
}
}
graph = new CGraph(size,cg,cba);
tarjAnalysis = new Tarjan <SootMethod>(graph);
}
示例7: executeTarjan
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
public List<List<SootMethod>> executeTarjan(CallGraph graph){
scc.clear();
index = 0;
stack.clear();
SootMethod mainMethod = Scene.v().getMethod("<MainClass: void main(java.lang.String[])>");
tarjan(mainMethod, graph);
return scc;
}
示例8: main
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
public static void main(String[] args) {
List<String> argsList = new ArrayList<String>(Arrays.asList(args));
argsList.addAll(Arrays.asList(new String[]{
"-w",
"-main-class",
"testers.CallGraphs",//main-class
"testers.CallGraphs",//argument classes
"testers.A" //
}));
PackManager.v().getPack("wjtp").add(new Transform("wjtp.myTrans", new SceneTransformer() {
@Override
protected void internalTransform(String phaseName, Map options) {
CHATransformer.v().transform();
SootClass a = Scene.v().getSootClass("testers.A");
SootMethod src = Scene.v().getMainClass().getMethodByName("doStuff");
CallGraph cg = Scene.v().getCallGraph();
Iterator<MethodOrMethodContext> targets = new Targets(cg.edgesOutOf(src));
while (targets.hasNext()) {
SootMethod tgt = (SootMethod)targets.next();
System.out.println(src + " may call " + tgt);
}
}
}));
args = argsList.toArray(new String[0]);
soot.Main.main(args);
}
示例9: getCallGraph
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
public CallGraph getCallGraph()
{
if(!hasCallGraph()) {
throw new RuntimeException( "No call graph present in Scene. Maybe you want Whole Program mode (-w)." );
}
return activeCallGraph;
}
示例10: countCallEdgesForCallsite
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
public static int countCallEdgesForCallsite(Stmt callsite, boolean stopForMutiple)
{
CallGraph cg = Scene.v().getCallGraph();
int count = 0;
for ( Iterator<Edge> it = cg.edgesOutOf(callsite);
it.hasNext(); ) {
it.next();
++count;
if ( stopForMutiple && count > 1) break;
}
return count;
}
示例11: getInvokeInfoFlowSummary
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
protected HashMutableDirectedGraph<EquivalentValue> getInvokeInfoFlowSummary(
InvokeExpr ie, Stmt is, SootMethod context)
{
// get the data flow graph for each possible target of ie,
// then combine them conservatively and return the result.
HashMutableDirectedGraph<EquivalentValue> ret = null;
SootMethodRef methodRef = ie.getMethodRef();
String subSig = methodRef.resolve().getSubSignature();
CallGraph cg = Scene.v().getCallGraph();
for(Iterator<Edge> edges = cg.edgesOutOf(is); edges.hasNext();)
{
Edge e = edges.next();
SootMethod target = e.getTgt().method();
// Verify that this target is an implementation of the method we intend to call,
// and not just a class initializer or other unintended control flow.
if(target.getSubSignature().equals(subSig))
{
HashMutableDirectedGraph<EquivalentValue> ifs = getMethodInfoFlowSummary(
target, context.getDeclaringClass().isApplicationClass());
if(ret == null)
ret = ifs;
else
{
for(EquivalentValue node : ifs.getNodes())
{
if(!ret.containsNode(node))
ret.addNode(node);
for(EquivalentValue succ : ifs.getSuccsOf(node))
ret.addEdge(node, succ);
}
}
}
}
return ret;
// return getMethodInfoFlowSummary(methodRef.resolve(), context.getDeclaringClass().isApplicationClass());
}
示例12: MultiRunStatementsFinder
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
public MultiRunStatementsFinder(UnitGraph g, SootMethod sm, Set<SootMethod> multiCalledMethods, CallGraph cg)
{
super(g);
nodeToIndex = new HashMap<Object, Integer>();
// System.out.println("===entering MultiObjectAllocSites==");
doAnalysis();
//testMultiObjSites(sm);
findMultiCalledMethodsIntra(multiCalledMethods, cg);
// testMultiObjSites(sm);
}
示例13: byMCalledS0
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
private void byMCalledS0(PegCallGraph pcg) {
Iterator it = pcg.iterator();
while (it.hasNext()){
SootMethod sm = (SootMethod)it.next();
UnitGraph graph = new CompleteUnitGraph(sm.getActiveBody());
CallGraph callGraph = Scene.v().getCallGraph();
MultiRunStatementsFinder finder = new MultiRunStatementsFinder(graph, sm, multiCalledMethods, callGraph);
FlowSet fs = finder.getMultiRunStatements();
}
}
示例14: getTransientDependencies
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
public static Set<Class> getTransientDependencies(Scene scene, CallGraph callGraph, Class<?> clazz) {
Queue<Class> pendingClasses = ArrayUtilities.newArrayDeque(clazz);
Set<Class> classes = Sets.newHashSet();
while(!pendingClasses.isEmpty()) {
Set<Class> newClasses = getDependencies(scene, callGraph, pendingClasses.poll())
.stream()
.filter(c -> !classes.contains(c))
.collect(Collectors.toSet());
classes.addAll(newClasses);
pendingClasses.addAll(newClasses);
}
return classes;
}
示例15: handleInvokeExpr
import soot.jimple.toolkits.callgraph.CallGraph; //导入依赖的package包/类
private void handleInvokeExpr(InvokeExpr ie, Stmt is)
{
// if(is.toString().contains("hashCode"))
// System.out.println();
CallGraph cg = Scene.v().getCallGraph();
for(Iterator<Edge> edges = cg.edgesOutOf(is); edges.hasNext();)
{
Edge e = edges.next();
SootMethod target = e.getTgt().method();
//if(method.getDeclaringClass().isApplicationClass())
if(!Util.skipPackage(target.getDeclaringClass().getPackageName()))
{
//SootMethodRef methodRef = ie.getMethodRef();
//String subSig = methodRef.resolve().getSubSignature();//MAY NOT BE SOUND
// Verify that this target is an implementation of the method we intend to call,
// and not just a class initializer or other unintended control flow.
//if(target.getSubSignature().equals(subSig))
{
analyze(target);
}
}
}
}