[Soot-list] Call graphs: Only one edge per call
Khilan Gudka
khilan at doc.ic.ac.uk
Thu Sep 24 09:07:54 EDT 2009
Dear Michael,
I'm not sure if Soot allows you to do that directly, however, you
could obtain the most general type (of all possible callee types)
using the RefType.merge( ) method. Soot has a number of classes that
represent types whose class hierarchy is rooted at the soot.Type
class. RefType is used for class types.
The following code may do the trick:
Scene sc = Scene.v();
CallGraph cg = sc.getCallGraph();
Type t = null;
for (Iterator<Edge> edgesIt=cg.edgesOutOf(u);
edgesIt.hasNext();) {
Edge e = edgesIt.next();
SootMethod cm = (SootMethod)e.getTgt();
SootClass cc = cm.getDeclaringClass();
RefType rt = cc.getType();
t = (t == null) ? rt : t.merge(rt, sc);
}
// t is the most general type of all callees
Hope that helps
--
Khilan Gudka
PhD Student
Department of Computing
Imperial College London
http://www.doc.ic.ac.uk/~khilan/
On 24 Sep 2009, at 13:42, Michael Pradel wrote:
> Hi,
>
> I'm creating call graphs with the SPARK points-to analysis in its
> default settings. In the resulting graphs, one MethodOrMethodContext
> often has several outgoing edges for one actual call, one for each
> type
> that the callee could have.
> For example, consider class A that defines method x(), which is
> overridden in A's subclass B, and a method m():
>
> void m(A a) {
> a.x();
> }
>
> A call graph node for m() may have two outgoing edges, one to A.x()
> and
> one to B.x().
> Does Soot provide a way to merge these edges into one, e.g. to the
> most
> general type, in this case A.x()?
>
> Many thanks!
> Michael
>
> --
> michael at binaervarianz.de
> GPG Fingerprint 2069 ED1D 7A80 E35E F4C9 43CF D4E0 57FC 7B97 6D4F
>
>
> <signature.asc><ATT00002.txt>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20090924/333c0aec/attachment.html
More information about the Soot-list
mailing list