[prev in list] [next in list] [prev in thread] [next in thread] 

List:       soot-list
Subject:    [Soot-list] Inter-procedural control flow graph containing resolved application method calls
From:       Amruta Gokhale <amrutag () cs ! rutgers ! edu>
Date:       2013-11-18 21:35:47
Message-ID: 528A8833.8060909 () cs ! rutgers ! edu
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi,

I am trying to build an inter-procedural control flow graph (CFG). In 
the generated CFG, I would like to have the following: if there is an 
invocation to a method and the method has been defined inside the 
application itself, then that method call should be resolved statically. 
This should be done in a recursive manner, until no more resolutions are 
possible. For example, if you have the following code where doStuff() 
calls foo(), foo() calls bar() and bar() calls println(), then the 
ultimate control flow graph for doStuff() should only have the call to 
println().

My current code resolves the method calls, but does it only once. For 
example, consider the following code:

package testers;

public class CallGraphs
{
         public static void main(String[] args) {
         }

         public static void doStuff() {
                 new A().foo();
         }
}

class A
{
         public void foo() {
                 bar();
         }

         public void bar() {
                 System.out.println("This is bar()");
         }
}

In my current implementation, all I do is to get the CFG of the program 
in whole program mode. Specifically, I call the method 
BriefBlockGraph(src.getActiveBody()) where "src" is a "SootMethod" 
defined in the class. (some additional information: I have implemented 
this in "wjop.smb" (static method binder) phase of "wjop" pack. I used 
it, since the tutorial mentions that it "replaces virtual invocations 
with invocations of a static copy of the single called implementation". 
Also, I use the following options: -w -p cg all-reachable:true -p wjop 
enabled:true )

So, using my implementation, if we walk down the CFG of method doStuff() 
to produce the method invocations as a string, the output looks like this:

specialinvoke $r0.<testers.A: void <init>()>()
virtualinvoke r2.<testers.A: void bar()>()

But what I want instead is this:

specialinvoke $r0.<testers.A: void <init>()>()
virtualinvoke $r2.<java.io.PrintStream: void 
println(java.lang.String)>("This is bar()")

i.e., I want to have all the method calls resolved in this invocation 
chain: doStuff() -> foo() -> bar() -> println() and have only the Java 
API methods be present in the CFG. I believe this is possible but not 
sure about the way forward.

(a) Is it that I have to invoke the same transformation multiple times 
until all method calls get resolved? If so, can somebody illustrate via 
say pseudo-code?
(b) Or is it that there is another pack/phase available in Soot to do this?

I would appreciate any help.

Thanks!
Amruta

[Attachment #5 (text/html)]

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-text-html" lang="x-western"> <big><big> </big></big>
      <div class="moz-text-flowed" style="font-size: 12px;"
        lang="x-western"><big><big>Hi, <br>
            <br>
            I am trying to build an inter-procedural control flow graph
            (CFG). In the generated CFG, I would like to have the
            following: if there is an invocation to a method and the
            method has been defined inside the application itself, then
            that method call should be resolved statically. This should
            be done in a recursive manner, until no more resolutions are
            possible. For example, if you have the following code where
            doStuff() calls foo(), foo() calls bar() and bar() calls
            println(), then the ultimate control flow graph for
            doStuff() should only have the call to println(). <br>
            <br>
            My current code resolves the method calls, but does it only
            once. For example, consider the following code: <br>
            <br>
            package testers; <br>
            <br>
            public class CallGraphs <br>
            { <br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static void \
main(String[] args) { <br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>
            <br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static void doStuff() { \
                <br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
new A().foo(); <br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>
            } <br>
            <br>
            class A <br>
            { <br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void foo() { <br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
bar(); <br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br>
            <br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void bar() { <br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
System.out.println("This is bar()"); <br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
} <br>  } <br>
            <br>
            In my current implementation, all I do is to get the CFG of
            the program in whole program mode. Specifically, I call the
            method BriefBlockGraph(src.getActiveBody()) where "src" is a
            "SootMethod" defined in the class. (some additional
            information: I have implemented this in "wjop.smb" (static
            method binder) phase of "wjop" pack. I used it, since the
            tutorial mentions that it "replaces virtual invocations with
            invocations of a static copy of the single called
            implementation". Also, I use the following options: -w -p cg
            all-reachable:true -p wjop enabled:true ) <br>
            <br>
            So, using my implementation, if we walk down the CFG of
            method doStuff() to produce the method invocations as a
            string, the output looks like this: <br>
            <br>
            specialinvoke $r0.&lt;testers.A: void &lt;init&gt;()&gt;() <br>
            virtualinvoke r2.&lt;testers.A: void bar()&gt;() <br>
            <br>
            But what I want instead is this: <br>
            <br>
            specialinvoke $r0.&lt;testers.A: void &lt;init&gt;()&gt;() <br>
            virtualinvoke $r2.&lt;java.io.PrintStream: void
            println(java.lang.String)&gt;("This is bar()") <br>
            <br>
            i.e., I want to have all the method calls resolved in this
            invocation chain: doStuff() -&gt; foo() -&gt; bar() -&gt;
            println() and have only the Java API methods be present in
            the CFG. I believe this is possible but not sure about the
            way forward. <br>
            <br>
            (a) Is it that I have to invoke the same transformation
            multiple times until all method calls get resolved? If so,
            can somebody illustrate via say pseudo-code? <br>
            (b) Or is it that there is another pack/phase available in
            Soot to do this? <br>
            <br>
            I would appreciate any help. <br>
            <br>
            Thanks! <br>
            Amruta <br>
          </big></big></div>
      <big><big> </big></big> </div>
  </body>
</html>



_______________________________________________
Soot-list mailing list
Soot-list@sable.mcgill.ca
http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic