Example #1
0
  public static final Result getJoanaSDG(Config cfg, final IProgressMonitor progress)
      throws IllegalArgumentException, CancelException, PDGFormatException, IOException,
          WalaException, InvalidClassFileException {
    final Date start = initSDGcomputation(cfg);

    final Result jresult = getOrigSDG(cfg, progress);

    edu.kit.joana.ifc.sdg.graph.SDG joanaSdg =
        JoanaStyleSDG.createJoanaSDG(
            jresult.jsdg, cfg.addControlFlow, cfg.nonTermination, cfg.useSummaryOpt, progress);

    if (progress.isCanceled()) {
      throw CancelException.make("Operation aborted.");
    }

    // as long as we can not cope with nodes that do not belong to the control flow we do this...
    JoanaCFGSanitizer.sanitizeCFG(joanaSdg);

    //        assert assertVerify(joanaSdg, !cfg.useWalaSdg, cfg.addControlFlow);

    final Date beforeThreadAllocation = new Date();

    final MHPAnalysis mhp;

    if (cfg.computeInterference) {
      progress.beginTask("Creating cSDG from SDG " + cfg.outputSDGfile, -1);

      progress.subTask("Running Thread Allocation Analysis");
      Log.info("Running Thread Allocation Analysis");

      mhp = CSDGPreprocessor.runMHP(joanaSdg, progress);

      Log.info("Thread Allocation done.");
      progress.done();
    } else {
      mhp = null;
    }

    if (progress.isCanceled()) {
      throw CancelException.make("Operation aborted.");
    }

    final Date beforeSummaryEdge = new Date();

    if (cfg.computeSummaryEdges) {
      progress.subTask("Compute Summary Edges");
      Log.info("Compute Summary Edges");
      SummaryEdgeComputation.compute(joanaSdg, progress);

      Log.info("Summary Edges done.");
      progress.done();
    }

    if (progress.isCanceled()) {
      throw CancelException.make("Operation aborted.");
    }

    final Date end = new Date();

    long start2end = end.getTime() - start.getTime();
    long summary2end = end.getTime() - beforeSummaryEdge.getTime();
    long start2thread = beforeThreadAllocation.getTime() - start.getTime();
    long threadAlloc = beforeSummaryEdge.getTime() - beforeThreadAllocation.getTime();

    Log.info("Start 2 End: " + start2end / 1000 + "s (" + start2end + "ms)");
    Log.info("Create: " + start2thread / 1000 + "s (" + start2thread + "ms)");
    Log.info(
        "Summary: "
            + summary2end / 1000
            + "s ("
            + summary2end
            + "ms)"
            + (cfg.computeSummaryEdges ? "" : " [deactivated]"));
    Log.info(
        "Thread: "
            + threadAlloc / 1000
            + "s ("
            + threadAlloc
            + "ms)"
            + (cfg.computeInterference ? "" : " [deactivated]"));

    return new Result(joanaSdg, jresult.jsdg, jresult.cg, jresult.pts, mhp);
  }
Example #2
0
  private static edu.kit.joana.ifc.sdg.graph.SDG createSDG(
      CallGraphResult cgResult, AnalysisOptions opt, IMethod method, boolean ignoreExceptions)
      throws CancelException, PDGFormatException, WalaException {
    DemandRefinementPointsTo demandPts = null;
    //		if (cfg.useDemandPts) {
    //		    MemoryAccessMap mam = new PABasedMemoryAccessMap(cg, builder.getPointerAnalysis());
    //			demandPts = new DemandRefinementPointsTo(cg,
    //				new ThisFilteringHeapModel(builder,cha), mam, cha, options,
    //			        getStateMachineFactory());
    //		}

    IPointerAnalysis pts = new PointsToWrapper(demandPts, cgResult.pts);
    IProgressMonitor progress = NullProgressMonitor.INSTANCE;
    // new VerboseProgressMonitor(System.out);
    IKey2Origin k2o = null;
    edu.kit.joana.deprecated.jsdg.SDGFactory.Config cfg =
        new edu.kit.joana.deprecated.jsdg.SDGFactory.Config();
    cfg.computeSummaryEdges = true;
    cfg.useSummaryOpt = false;
    cfg.addControlFlow = true;
    cfg.computeInterference = false;
    cfg.ignoreExceptions = ignoreExceptions;
    cfg.optimizeExceptions = false; // !ignoreExceptions;
    cfg.nonTermination = false;

    cfg.immutables =
        new String[] {
          "java.lang.String",
          "java.lang.Integer",
          "java.lang.Float",
          "java.lang.Double",
          "java.lang.Boolean",
          "java.lang.Character"
        };

    edu.kit.joana.deprecated.jsdg.sdg.SDG jSDG =
        edu.kit.joana.deprecated.jsdg.sdg.SDG.create(
            method, cgResult.cg, cgResult.cache, k2o, pts, cfg, progress);

    edu.kit.joana.ifc.sdg.graph.SDG sdg =
        JoanaStyleSDG.createJoanaSDG(
            jSDG, cfg.addControlFlow, cfg.nonTermination, cfg.useSummaryOpt, progress);

    RemoveLibraryClinits.removeLibraryClinits(sdg);
    StaticFieldMerge.mergeStaticFields(sdg);

    final Logger log = Log.getLogger(Log.L_WALA_CORE_DEBUG);

    if (cfg.computeSummaryEdges) {
      progress.subTask("Compute Summary Edges");
      log.outln("Compute Summary Edges");
      SummaryEdgeComputation.compute(sdg, progress);

      log.outln("Summary Edges done.");
      progress.done();
    }

    SummarizeDependencies.transformToSummary(sdg, method);

    return sdg;
  }