/** * Prints out the method corresponding to b Body, (declaration and body), in the textual format * corresponding to the IR used to encode b body. * * @param out a PrintWriter instance to print to. */ public void printTo(Body b, PrintWriter out) { b.validate(); boolean isPrecise = !useAbbreviations(); String decl = b.getMethod().getDeclaration(); out.println(" " + decl); // incJimpleLnNum(); // only print tags if not printing attributes in a file if (!addJimpleLn()) { /*for( Iterator tIt = b.getMethod().getTags().iterator(); tIt.hasNext(); ) { final Tag t = (Tag) tIt.next(); out.println(t); incJimpleLnNum(); }*/ } if (addJimpleLn()) { setJimpleLnNum(addJimpleLnTags(getJimpleLnNum(), b.getMethod())); // G.v().out.println("added jimple ln tag for method: "+b.getMethod().toString()+" // "+b.getMethod().getDeclaringClass().getName()); } out.println(" {"); incJimpleLnNum(); UnitGraph unitGraph = new soot.toolkits.graph.BriefUnitGraph(b); LabeledUnitPrinter up; if (isPrecise) up = new NormalUnitPrinter(b); else up = new BriefUnitPrinter(b); if (addJimpleLn()) { up.setPositionTagger(new AttributesUnitPrinter(getJimpleLnNum())); } printLocalsInBody(b, up); printStatementsInBody(b, out, up, unitGraph); out.println(" }"); incJimpleLnNum(); }
/** * Performs the work that is required to construct any sort of <tt>UnitGraph</tt>. * * @param body The body of the method for which to construct a control flow graph. */ protected UnitGraph(Body body) { this.body = body; unitChain = body.getUnits(); method = body.getMethod(); if (Options.v().verbose()) G.v() .out .println( "[" + method.getName() + "] Constructing " + this.getClass().getName() + "..."); }
protected void internalTransform(Body b, String phaseName, Map<String, String> options) { initialize(options); SootMethod meth = b.getMethod(); if ((methodsToPrint == null) || (meth.getDeclaringClass().getName() == methodsToPrint.get(meth.getName()))) { Body body = ir.getBody((JimpleBody) b); print_cfg(body); } }
protected void print_cfg(Body body) { DirectedGraph<Unit> graph = graphtype.buildGraph(body); DotGraph canvas = graphtype.drawGraph(drawer, graph, body); String methodname = body.getMethod().getSubSignature(); String filename = soot.SourceLocator.v().getOutputDir(); if (filename.length() > 0) { filename = filename + java.io.File.separator; } filename = filename + methodname.replace(java.io.File.separatorChar, '.') + DotGraph.DOT_EXTENSION; G.v().out.println("Generate dot file in " + filename); canvas.plot(filename); }