/**
   * Instruments the runtime version of the program.
   *
   * @param mainclass
   */
  public static void transformRuntimeVersion(String mainclass) {
    PackManager.v().getPack("jtp").add(new Transform("jtp.intrumenter", SymbBodyPass.v()));
    setOptions(mainclass, false);

    Scene.v()
        .setSootClassPath(
            System.getProperty("sun.boot.class.path")
                + File.pathSeparator
                + System.getProperty("java.class.path"));

    Scene.v().loadClassAndSupport(runtimeClass);

    try {

      // ** instrument runtime version
      String outpath = getOutputDir();
      String[] args1 = getArgs(mainclass, outpath);

      soot.Main.main(args1);
      System.err.println("***** Runtime version generated *****\n");

      // reset soot parameters
      soot.G.reset();
      bbIdCounter = 0;

    } catch (Exception e) {
      System.err.println(">> Exception: " + e.getMessage());
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  private static void initializeSoot(Clazzes clazzes) {
    soot.G.reset();
    Options.v().set_output_format(Options.output_format_jimple);
    Options.v().set_include_all(true);
    Options.v().set_print_tags_in_output(true);
    Options.v().set_allow_phantom_refs(true);
    Options.v().set_keep_line_number(true);
    Options.v().set_soot_classpath(getSootClasspath(clazzes));

    /*
     * Enable the use-original-names phase to merge local variables and
     * verbose logging for debugging purposes only.
     */
    // Options.v().set_verbose(true);
    // Options.v().setPhaseOption("jb", "use-original-names:true");
    /*
     * Disable the jb.dae phase (DeadAssignmentEliminator) since it removes
     * LDC instructions which would have thrown a NoClassDefFoundError.
     * TODO: Report this to soot as a bug?
     */
    Options.v().setPhaseOption("jb.dae", "enabled:false");
    /*
     * Disable the jb.uce phase (UnreachableCodeEliminator) since it seems
     * to remove try-catch blocks which catches a non-existing Throwable
     * class. This should generate a NoClassDefFoundError at runtime but
     * with the UCE in place no exception is thrown.
     */
    Options.v().setPhaseOption("jb.uce", "enabled:false");

    /*
     * Enable jap.npc (NullPointerChecker) and jap.abc (ArrayBoundsChecker)
     * phases in the annotation pack. The annotation pack is enabled by
     * default but all its phases are disabled by default.
     */
    Options.v().setPhaseOption("jap.npc", "enabled:true");
    Options.v().setPhaseOption("jap.abc", "enabled:true");

    /*
     * Enable the jop (Jimple optimization) pack but disable all phases for
     * now.
     */
    Options.v().setPhaseOption("jop", "enabled:true");
    Options.v().setPhaseOption("jop.cse", "enabled:false");
    Options.v().setPhaseOption("jop.bcm", "enabled:false");
    Options.v().setPhaseOption("jop.lcm", "enabled:false");
    Options.v().setPhaseOption("jop.cp", "enabled:false");
    Options.v().setPhaseOption("jop.cpf", "enabled:false");
    Options.v().setPhaseOption("jop.cbf", "enabled:false");
    Options.v().setPhaseOption("jop.dae", "enabled:false");
    Options.v().setPhaseOption("jop.nce", "enabled:false");
    Options.v().setPhaseOption("jop.uce1", "enabled:false");
    Options.v().setPhaseOption("jop.ubf1", "enabled:false");
    Options.v().setPhaseOption("jop.uce2", "enabled:false");
    Options.v().setPhaseOption("jop.ubf2", "enabled:false");
    Options.v().setPhaseOption("jop.ule", "enabled:false");

    Scene.v().loadNecessaryClasses();
  }
 @Override
 public void execute() throws MojoExecutionException {
   G.reset();
   String classpath = getCompileClasspath();
   getLog().info(String.format("Using transform classpath: %s", classpath));
   Options.v().set_soot_classpath(classpath);
   Options.v().set_process_dir(asList(getProcessDirectory()));
   Options.v().set_output_dir(getOutputDirectory());
   SimulationTransform.main(null);
 }
Ejemplo n.º 4
0
 @BeforeClass
 public static void initializeSoot() throws IOException {
   soot.G.reset();
   Options.v().set_output_format(Options.output_format_jimple);
   Options.v().set_include_all(true);
   Options.v().set_print_tags_in_output(true);
   Options.v().set_allow_phantom_refs(true);
   Options.v()
       .set_soot_classpath(
           System.getProperty("sun.boot.class.path")
               + ":"
               + System.getProperty("java.class.path"));
   Scene.v().loadNecessaryClasses();
 }