<div dir="ltr">Thank you so much for explaining, and JimpleBasedInterproceduralCFG.getMethodOf(Unit u) works!<div><br></div><div><br></div><div>Best Regards,</div><div>R.F.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jul 17, 2015 at 2:24 PM, Johannes Lerch <span dir="ltr">&lt;<a href="mailto:lerch@st.informatik.tu-darmstadt.de" target="_blank">lerch@st.informatik.tu-darmstadt.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hi,<br>
    <br>
    you can ask the ICFG to give you the method as well: <br>
    JimpleBasedInterproceduralCFG.getMethodOf(Unit u)<br>
    <br>
    I guess in the discussion Marc-André was talking about that you
    indeed could traverse the ICFG as you can traverse directed graphs.
    If you do so, this would yield context-insensitive paths.<br>
    <br>
    Example: <br>
    void bar() {<br>
      foo();<br>
      print(&quot;return site of foo()&quot;);<br>
      foo();<br>
      print(&quot;another return site&quot;);<br>
    }<br>
    <br>
    Assume you are at the first call to foo(). You enter foo(). Now, if
    you ask the ICFG where the return statement in foo() might return
    to, you will get print(&quot;return site of foo()&quot;) and print(&quot;another
    return site&quot;). If you continue to traverse to both return sites,
    then only the first path to print(&quot;return site of foo()&quot;) is
    actually a realizable path that may occur at runtime, while the
    second is impossible.<br>
    To know that you should not return to the second return site you
    have to know that you entered foo() via the first call site, i.e.,
    you have to take care of &quot;context&quot;. This is why such an approach
    would be called context-sensitive, while traversing the ICFG as
    simple as traversing a directed graph is context-insensitive.<br>
    <br>
    Regards,<br>
    Johannes<div><div class="h5"><br>
    <br>
    <div>Am 16.07.2015 um 15:52 schrieb R.F.:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      <div dir="ltr">Hi,
        <div><br>
        </div>
        <div>I want to find the caller Stmt and the SootMethod which the
          Stmt belongs to in the callgraph (for example, given that
          SootMethod m1 is invoked by SootMethod m2 with m2&#39;s statement
          s1, now I have m1, and I want to find both m2 and s1). </div>
        <div><br>
        </div>
        <div>I have tried two approaches:</div>
        <div>
          <ol>
            <li><font face="monospace, monospace">JimpleBasedInterproceduralCFG.getCallersOf(SootMethod
                m)</font>, this method returns a collection of Unit, but
              from the returned collection of Unit, I cannot get the
              SootMethod which each Unit belongs to.<br>
            </li>
            <li><font face="monospace, monospace">Scene.v().getCallGraph().edgesInto(SootMethod
                m)</font>, this method returns an iterator of
              SootMethod. To get the Stmt, I need to iterate through all
              the Stmt of each SootMethod and find the one by matching
              stmt.getInvokeExpr().getMethod() with the given SootMethod
              by signature. However, I think simply matching by
              SootMethod&#39;s signature may fail to find the Stmt because
              the given method can be an override method, so their
              signatures will not match.</li>
          </ol>
        </div>
        <div>So, is there a method to find the caller Stmt and
          SootMethod in callgraph accurately even with override and
          overload?</div>
        <div><br>
        </div>
        <div>Moreover, Marc-André Laverdière mentioned
          the JimpleBasedInterproceduralCFG-based method in <a href="https://mailman.cs.mcgill.ca/pipermail/soot-list/2014-July/007043.html" target="_blank">https://mailman.cs.mcgill.ca/pipermail/soot-list/2014-July/007043.html</a>
          with the notion that &quot;as long as you don&#39;t mind
          context-insensitive results&quot;. Can someone tell me what are
          &quot;context-insensitive results&quot;?</div>
        <div><br>
        </div>
        <div>Thank you in advance.</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Best Regards,</div>
        <div>R.F.</div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
Soot-list mailing list
<a href="mailto:Soot-list@CS.McGill.CA" target="_blank">Soot-list@CS.McGill.CA</a>
<a href="https://mailman.CS.McGill.CA/mailman/listinfo/soot-list" target="_blank">https://mailman.CS.McGill.CA/mailman/listinfo/soot-list</a>
</pre>
    </blockquote>
    <br>
  </div>

</blockquote></div><br></div></div>