private boolean init(Map<String, AppValue> options) {
    inputFiles = getFiles(options);
    if (inputFiles == null) {
      return false;
    }

    outputFolder = AppUtils.getFolder(options, Options.OutputFolder);
    if (outputFolder == null) {
      LoggingUtils.getLogger().warning("Could not open folder.");
      return false;
    }

    // Get trace unit
    String traceUnitString = AppUtils.getString(options, Options.TraceUnit);
    traceUnitName = EnumUtils.valueOf(TraceUnits.class, traceUnitString);
    if (traceUnitName == null) {
      LoggingUtils.getLogger().warning("Could not get Trace Unit name.");
      return false;
    }

    String systemConfigFilename = AppUtils.getString(options, Options.SystemSetup);
    systemConfigFile = new File(systemConfigFilename);
    if (!systemConfigFile.exists()) {
      LoggingUtils.getLogger()
          .info("MicroBlaze setup file '" + systemConfigFilename + "' not found.");
    }

    return true;
  }
  private void processFile(File inputFile) {
    SystemSetup setup = SystemSetup.buildConfig(systemConfigFile);
    if (setup == null) {
      setup = SystemSetup.getDefaultConfig();
    }

    TraceReader traceReader = (TraceReader) DToolReader.newDToolReader(inputFile, setup);
    if (traceReader == null) {
      LoggingUtils.getLogger().warning("traceReader is null.");
      return;
    }

    UnitBuilder builder = UnitBuilderFactory.newUnitBuilder(traceUnitName, instructionDecoder);
    DottyTraceUnit dotty = new DottyTraceUnit();

    String inst = null;
    // long totalInstructions = 0l;
    while ((inst = traceReader.nextInstruction()) != null) {
      Integer address = traceReader.getAddress();
      builder.nextInstruction(address, inst);
      processTraceUnit(builder, dotty);
    }
    builder.close();
    processTraceUnit(builder, dotty);

    File outputFile = new File(outputFolder, inputFile.getName() + "." + traceUnitName + ".dotty");
    IoUtils.write(outputFile, dotty.generateDot());
  }
Example #3
0
  public void addLoop(CodeSegment loop) {
    if (loop == null) {
      LoggingUtils.getLogger().warning("LoopUnit is null;");
      return;
    }

    if (onlyStoreLoops) {
      // Only write units of the type loop
      if (!loop.isLoop()) {
        return;
      }
    }

    // Check if loop has enough iterations
    if (loop.getIterations() < iterationsThreshold) {
      return;
    }

    // Check if loop was already written
    if (ids.contains(loop.getId())) {
      return;
    }

    ids.add(loop.getId());
    loops.add(loop);
  }
 private void testInstructionNumber(int traceCount, int loopCount) {
   if (traceCount != loopCount) {
     LoggingUtils.getLogger()
         .warning(
             "Trace instruction count ("
                 + traceCount
                 + ") different "
                 + "from loop instruction count ("
                 + loopCount
                 + ").");
   }
 }
  private void addRegisterValuesToLoop(List<CodeSegment> loops, TraceReader traceReader) {
    if (loops == null) {
      return;
    }

    if (loops.isEmpty()) {
      LoggingUtils.getLogger().warning("Loop detector returned empty list?");
      return;
    }

    if (loops.size() > 1) {
      LoggingUtils.getLogger()
          .warning(
              "Loop Detector returned more than one loop. Cannot add "
                  + "the values of the registers reliably in this case.");
    }

    // Get register values
    // Map<RegisterId,Integer> registerValues = traceReader.getRegisters();
    RegisterTable registerValues = traceReader.getRegisters();
    if (registerValues == null) {
      LoggingUtils.getLogger()
          .warning(
              "Implementation of TraceReader '"
                  + traceReader.getClass()
                  + "' does not support reading the values of register.");
      return;
    }

    // There should be only one element in the list at this point,
    // add the values of the registers.
    // System.out.println("Register Values Prime:");
    // System.out.println(registerValues);
    // System.out.println("Loop Before:"+loops.get(0).getRegisterValues());
    loops.get(0).setRegisterValues(registerValues);
    // System.out.println("Loop After:"+loops.get(0).getRegisterValues());

  }
Example #6
0
  /**
   * Instantiates a DToolReader loaded with an Elf file.
   *
   * @param elfFile
   * @param config
   * @return a DToolReader loaded with the given file, or null if the object could not be created
   */
  public static DToolReader newTraceReader(File elfFile, SystemSetup config) {
    String systemConfig = "./Configuration Files/systemconfig.xml";
    String elfFilename = elfFile.getPath();

    SysteM originalSystem = DToolUtils.newSysteM(systemConfig, elfFilename, config);
    if (originalSystem == null) {
      LoggingUtils.getLogger().warning("Could not create SysteM object.");
      return null;
    }
    EasySystem system = new EasySystem(originalSystem);
    DToolReader dtoolReader = new DToolReader(system);

    return dtoolReader;
  }
Example #7
0
  /**
   * @param options
   * @return a list with the selected partitioners
   */
  public static List<LoopDetectors> getPartitioners(Map<String, AppValue> options) {
    List<String> partitioners = AppUtils.getStringList(options, Options.LoopDetectors);

    List<LoopDetectors> parts = new ArrayList<LoopDetectors>();
    for (String partitionerName : partitioners) {
      // Decode name into enum
      LoopDetectors partEnum = EnumUtils.valueOf(LoopDetectors.class, partitionerName);
      if (partEnum == null) {
        LoggingUtils.getLogger().warning("Ignoring partitioner '" + partitionerName + "'");
        continue;
      }
      parts.add(partEnum);
    }

    return parts;
  }