[Soot-list] 回复:AW: Incomplete CallGraph

qpj 412832527 at qq.com
Fri Jul 11 12:27:20 EDT 2014


Hi Steven,‍
Thank you for reply. I checked Scene.v().getReachableMethods().contains(myMethod) and found the result is false.‍
Actually my analysis code is about Android's Listener.
Class A{
public void onCreate(){
         listView.setOnClickListener(new onClickListener(
                 public onClick(View v){
                          showDocument()
                 }));
}
public void showDocument(){
//To Do
}
}
Does it mean Scene cannot reach to onClick()? If yes, do you have any idea of getting the source method of showDocument()? ‍


Best regards,
Xiangxing




------------------ 原始邮件 ------------------
发件人: "Steven Arzt";<Steven.Arzt at cased.de>;
发送时间: 2014年7月11日(星期五) 晚上11:20
收件人: "qpj"<412832527 at qq.com>; "'soot-list'"<soot-list at sable.mcgill.ca>; 

主题: AW: [Soot-list] Incomplete CallGraph




Hi Xiangxing,

 

Please check whether the method containing the calls for which you do not find any callees in the callgraph is itself marked as reachable. If a method a() calls a method b(), you only get a corresponding call graph edge if a() is reachable in the first place. The check is easy: Scene.v().getReachableMethods().contains(myMethod).

 

If this is ok, then make sure that there is a constructor call for base object on which you invoke the method. Take the following example:

 

A a = new A();

a.foo();

 

In this case, there will be a call edge to A.foo(). But if you take the following example and assume that the factory method “makeA” is a phantom method for which we do not have a body, there will not be a callgraph edge:

 

A a = makeA();

a.foo();

 

Best regards,

  Steven

 

Von: soot-list-bounces at CS.McGill.CA [mailto:soot-list-bounces at CS.McGill.CA] Im Auftrag von qpj
Gesendet: Freitag, 11. Juli 2014 17:13
An: soot-list
Betreff: [Soot-list] Incomplete CallGraph

 

Hi All,


When I use 


Iterator<MethodOrMethodContext> targets = new Targets(cg.edgesOutOf(sm));


I found sm do not have any targets if sm is a method came from a class whose name contains $(like cz.romario.opensudoku.gui.FileListActivity$2).


                                   


My code:


for(SootClass sootClass:Scene.v().getClasses()){


            if(sootClass.getName().startsWith("cz.romario.opensudoku.gui.FileListActivity")){                                               


                        innList.add(sootClass);


            }          


}


for(SootClass sc:innList){


            for(SootMethod sm:sc.getMethods()){


                        Iterator<MethodOrMethodContext> targets = new Targets(cg.edgesOutOf(sm));


                        System.out.println(sm+":");


                        while(targets.hasNext())


                              System.out.println(targets.next());


            }


}‍



My result:


<cz.romario.opensudoku.gui.FileListActivity: void onCreate(android.os.Bundle)>:


targetMethod:<java.io.File: void <clinit>()>


targetMethod:<java.lang.StringBuilder: java.lang.String toString()>


targetMethod:<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>


targetMethod:<java.lang.StringBuilder: java.lang.StringBuilder append(java.lang.String)>


targetMethod:<java.lang.StringBuilder: void <init>(java.lang.String)>


targetMethod:<java.util.Date: void <init>(long)>


targetMethod:<java.io.File: long lastModified()>


targetMethod:<java.io.File: java.lang.String getName()>‍



 


<cz.romario.opensudoku.gui.FileListActivity$2: void <init>(cz.romario.opensudoku.gui.FileListActivity)>:


targetMethod:<java.lang.Object: void <init>()>


<cz.romario.opensudoku.gui.FileListActivity$2: boolean accept(java.io.File)>:


no targets.


 


<cz.romario.opensudoku.gui.FileListActivity$3: void <init>(cz.romario.opensudoku.gui.FileListActivity)>:


targetMethod:<java.lang.Object: void <init>()>


<cz.romario.opensudoku.gui.FileListActivity$3: void onClick(android.content.DialogInterface,int)>:


no targets.


 


As you can see:


1. In cz.romario.opensudoku.gui.FileListActivity, I can get all targets of onCreate(). ‍



2. In cz.romario.opensudoku.gui.FileListActivity$2 and ‍cz.romario.opensudoku.gui.FileListActivity$3, I cannot get any targets from accept() and onClick().‍


Do any one meet with this problem before? 


Best Regard.


 


Xiangxing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.CS.McGill.CA/pipermail/soot-list/attachments/20140712/0cf3780b/attachment.html 


More information about the Soot-list mailing list