Пример #1
0
  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);
  }
Пример #2
0
  private void initialize(Map<String, String> options) {
    if (drawer == null) {
      drawer = new CFGToDotGraph();
      drawer.setBriefLabels(PhaseOptions.getBoolean(options, briefLabelOptionName));
      drawer.setOnePage(!PhaseOptions.getBoolean(options, multipageOptionName));
      drawer.setUnexceptionalControlFlowAttr("color", "black");
      drawer.setExceptionalControlFlowAttr("color", "red");
      drawer.setExceptionEdgeAttr("color", "lightgray");
      drawer.setShowExceptions(Options.v().show_exception_dests());
      ir = CFGIntermediateRep.getIR(PhaseOptions.getString(options, irOptionName));
      graphtype = CFGGraphType.getGraphType(PhaseOptions.getString(options, graphTypeOptionName));

      AltClassLoader.v().setAltClassPath(PhaseOptions.getString(options, altClassPathOptionName));
      AltClassLoader.v()
          .setAltClasses(
              new String[] {
                "soot.toolkits.graph.ArrayRefBlockGraph",
                "soot.toolkits.graph.Block",
                "soot.toolkits.graph.Block$AllMapTo",
                "soot.toolkits.graph.BlockGraph",
                "soot.toolkits.graph.BriefBlockGraph",
                "soot.toolkits.graph.BriefUnitGraph",
                "soot.toolkits.graph.CompleteBlockGraph",
                "soot.toolkits.graph.CompleteUnitGraph",
                "soot.toolkits.graph.TrapUnitGraph",
                "soot.toolkits.graph.UnitGraph",
                "soot.toolkits.graph.ZonedBlockGraph",
              });
    }
  }
Пример #3
0
 private static void usage() {
   G.v()
       .out
       .println(
           "Usage:\n"
               + "   java soot.util.CFGViewer [soot options] [CFGViewer options] [class[:method]]...\n\n"
               + "   CFGViewer options:\n"
               + "      (When specifying the value for an '=' option, you only\n"
               + "       need to type enough characters to specify the choice\n"
               + "       unambiguously, and case is ignored.)\n"
               + "\n"
               + "       --alt-classpath PATH :\n"
               + "                specifies the classpath from which to load classes\n"
               + "                that implement graph types whose names begin with 'Alt'.\n"
               + "       --graph={"
               + CFGGraphType.help(0, 70, "                ".length())
               + "} :\n"
               + "                show the specified type of graph.\n"
               + "                Defaults to "
               + defaultGraph
               + ".\n"
               + "       --ir={"
               + CFGIntermediateRep.help(0, 70, "                ".length())
               + "} :\n"
               + "                create the CFG from the specified intermediate\n"
               + "                representation. Defaults to "
               + defaultIR
               + ".\n"
               + "       --brief :\n"
               + "                label nodes with the unit or block index,\n"
               + "                instead of the text of their statements.\n"
               + "       --multipages :\n"
               + "                produce dot file output for multiple 8.5x11\" pages.\n"
               + "                By default, a single page is produced.\n"
               + "       --help :\n"
               + "                print this message.\n"
               + "\n"
               + "   Particularly relevant soot options (see \"soot --help\" for details):\n"
               + "       --soot-class-path PATH\n"
               + "       --show-exception-dests\n"
               + "       --throw-analysis {pedantic|unit}\n"
               + "       --omit-excepting-unit-edges\n"
               + "       --trim-cfgs\n");
 }