[Soot-list] Is there a way to get the object whose method is being called?

Clarissa Grixti clarissa_14_4 at hotmail.com
Tue Mar 20 02:41:18 EDT 2012





Hey,
Yes Cheng you were right, the method was in fact static and when I removed it, it works fine. The thing is when I get the Value, I can see that it is of the right type, however I could not cast it to the correct object type. I tried to clone it and the type it returns ins JimpleLocal and when I try to cast that I'm getting a classcast exception. Does anyone know how to be able to cast it into an object of the correct type please?
thanks and regards,

Date: Mon, 19 Mar 2012 22:26:24 +0800
Subject: Re: [Soot-list] Is there a way to get the object whose method is being called?
From: cheng.zhang.stap at gmail.com
To: clarissa_14_4 at hotmail.com
CC: eric.bodden at ec-spride.de; soot-list at sable.mcgill.ca

Hi,
Sorry, I have no idea about the main problem either...
But for the class cast exception, I guess the method callClarissa wants to process is a static invocation, instead of an instance invocation, 
so the expression is of type:  soot.jimple.internal.JStaticInvokeExpr
Perhaps it would be better to read a bit about Jimple specs before doing it:http://www.sable.mcgill.ca/publications/techreports/sable-tr-1998-4.ps

Best,Cheng
On Mon, Mar 19, 2012 at 6:29 PM, Clarissa Grixti <clarissa_14_4 at hotmail.com> wrote:





Hey eric,
When you said  the call statement of the call edge, did you mean that you need the edge containing the statement in the source part?So for example I have the flow : 

doStuff -> label. setText 
and so the variable that I need is label. However setText does not point to any other methods, and so no edge will result from there. Now I tried the following code (this will be called after I call the CHATransformer):

 public static void method1() {        SootMethod src = Scene.v().getMainClass().getMethodByName("doStuff");        CallGraph cg = Scene.v().getCallGraph();

        Iterator<Edge> edges = cg.edgesOutOf(src);        while (edges.hasNext()) {            Edge e = edges.next();
            Stmt stmt = e.srcStmt();
            InvokeExpr ie = stmt.getInvokeExpr();                        InstanceInvokeExpr iie = (InstanceInvokeExpr)ie;
            Value v = iie.getBase();
            System.out.println("TYPE: " + v.getType().toString());        }            }

Stmt can only be retrieved from that method, and I'm assuming that in this case, since the egde will is from doStuff to some other method, than the statement in stmt will be that of doStuff. But if setText does not point to a method, how will I be able to get the srcStmt?

In addition when I tried to cast the invoke expression, im getting the following exception:  Exception in thread "main" java.lang.ClassCastException: soot.jimple.internal.JStaticInvokeExpr cannot be cast to soot.jimple.InstanceInvokeExpr. should it be casted in some other way?

Thanks for the help and regards


> From: eric.bodden at ec-spride.de
> Date: Sun, 18 Mar 2012 16:02:33 +0100

> Subject: Re: [Soot-list] Is there a way to get the object whose method is being called?
> To: clarissa_14_4 at hotmail.com
> CC: soot-list at sable.mcgill.ca

> 
> Hi Clarissa.
> 
> As Zheng wrote, you cannot determine the object. But possible what you
> actually mean is the variable holding that object at runtime. In this
> case you can get a handle to this variable as follows:

> 
> 1.) extract the call statement from the call edge
> 2.) on this stmt perform stmt.getInvokeExpr() to extract the invoke expression
> 3.) cast this invoke expression to an InstanceInvokeExpr on which you

> can then call getBase()
> 4.) getBase() returns a value, which you should be able to cast to a
> local variable
> 
> Cheers,
> Eric
> 
> On 18 March 2012 15:09, Clarissa Grixti <clarissa_14_4 at hotmail.com> wrote:

> > Hey all,
> >
> >  I am creating a call graph for my system in order to be able to get the
> > target nodes for a particular method. Is there a way to be able to identify
> > the object whose method is being called? I did manage to get the declaring

> > class for the method, but what I need is the actual object calling a
> > specific method.
> >
> > Thanks and regards
> >
> > _______________________________________________

> > Soot-list mailing list
> > Soot-list at sable.mcgill.ca
> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list

> >
> 
> 
> 
> -- 
> Eric Bodden, Ph.D., http://bodden.de/
> Head of Secure Software Engineering Group at EC SPRIDE
> Principal Investigator in Secure Services at CASED

> Tel: +49 6151 16-75422    Fax: +49 6151 16-72051
> Room 3.2.14, Mornewegstr. 30, 64293 Darmstadt
 		 	   		  

_______________________________________________

Soot-list mailing list

Soot-list at sable.mcgill.ca

http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list




 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20120320/f0b54f9d/attachment.html 


More information about the Soot-list mailing list