@@ -0,0 +1,2482 @@
+package petablox.analyses.alias;%0A%0Aimport java.io.PrintWriter;%0Aimport java.util.Set;%0A%0Aimport soot.SootClass;%0Aimport soot.SootMethod;%0Aimport soot.Unit;%0Aimport petablox.analyses.method.DomM;%0Aimport petablox.program.Program;%0Aimport petablox.project.Petablox;%0Aimport petablox.project.ClassicProject;%0Aimport petablox.project.OutDirUtils;%0Aimport petablox.project.analyses.JavaAnalysis;%0Aimport petablox.util.tuple.object.Pair;%0Aimport petablox.util.soot.SootUtilities;%0A%0A/**%0A * Converting a context-sensitive call graph to a dot-graph.%0A * %0A * @author Mayur Naik (mhn@cs.stanford.edu) %0A *  -- Original context insensitive code%0A * @author Sulekha Kulkarni (sulekha.kulkarni@gmail.com) %0A *  -- Modified to be sensitive%0A * @author Christian Kalhauge (kalhauge@cs.ucla.edu) %0A *  -- Modified to work with Petablox and Soot%0A */%0A@Petablox(name=%22cscg2dot-java%22)%0Apublic class CSCG2DotGraphAnalysis extends JavaAnalysis %7B%0A%09    private DomM domM;%0A%09    private DomC domC;%0A%09    %0A%09    public void run() %7B%0A%09        ClassicProject project = ClassicProject.g();%0A%09        CSCGAnalysis analysis = (CSCGAnalysis) project.runTask(%22cscg-java%22);%0A%09        ICSCG cscg = analysis.getCallGraph();%0A%09        domM = (DomM) project.getTrgt(%22M%22);%0A%09        domC = (DomC) project.getTrgt(%22C%22);%0A%0A%09        PrintWriter out = OutDirUtils.newPrintWriter(%22cscg.dot%22);%0A%09        out.println(%22digraph G %7B%22);%0A%09        for (Pair%3CCtxt,SootMethod%3E p1 : cscg.getNodes()) %7B%0A%09        %09Ctxt c1 = p1.val0;%0A%09        %09SootMethod m1 = p1.val1;%0A%09            String id1 = id(m1, c1);%0A%09            out.println(%22%5Ct%22 + id1 + %22 %5Blabel=%5C%22%22 + str(m1) + %22%5C%22%5D;%22);%0A%09            for (Pair%3CCtxt, SootMethod%3E p2 : cscg.getSuccs(p1)) %7B%0A%09            %09Ctxt c2 = p2.val0;%0A%09%09        %09SootMethod m2 = p2.val1;%0A%09                String id2 = id(m2, c2);%0A%09                Set%3CUnit%3E labels = cscg.getLabels(p1, p2);%0A%09                for (Unit q : labels) %7B%0A                        String el = SootUtilities.toJavaLocStr(q); %0A%09                    out.println(%22%5Ct%22 + id1 + %22 -%3E %22 + id2 + %22 %5Blabel=%5C%22%22 + el + %22%5C%22%5D;%22);%0A%09                %7D%0A%09            %7D%0A%09        %7D%0A%09        out.println(%22%7D%22);%0A%09        out.close();%0A%0A%09        analysis.free();%0A%09    %7D%0A%09    private String id(SootMethod m, Ctxt c) %7B%0A%09        return %22m%22 + domM.indexOf(m) + %22:%22 + domC.indexOf(c);%0A%09    %7D%0A%0A        private static String str(SootMethod m) %7B%0A            SootClass c = m.getDeclaringClass();%0A            String desc = m.getSignature().toString();%0A            return c.getName() + %22.%22 + desc;%0A        %7D%0A%7D%0A

Add CSCG to Dot analysis