/**
     * construct a new monitor
     *
     * @param s Simulator
     */
    Monitor(Simulator s) {
      simulator = s;
      program = s.getProgram();
      labelLookup = new HashMap();
      profiles = new LinkedList();

      procedureProbe = new ProcedureProbe();
      sleepCycles = 0;
      sleepProbe = new SleepProbe();
      // find all sleep opcodes in the program
      findSleep();

      // scan all labels and put the in the list
      setupLabels();

      // startup values
      lastChange = 0;
      currentMode = nearestLabel(0);
      // scan each basic block and find the corresponding label, e.g. procedure
      Iterator it = program.getCFG().getSortedBlockIterator();
      int address;
      int size;
      while (it.hasNext()) {
        Block block = (Block) it.next();
        size = block.getSize();
        address = block.getAddress();
        if (size > 0 && program.readInstr(address) != null) {
          labelLookup.put(new Integer(address), nearestLabel(address));
          s.insertProbe(procedureProbe, address);
        }
      }
    }
 /** scan all labels and put them in the list */
 private void setupLabels() {
   Iterator it = program.getSourceMapping().getIterator();
   while (it.hasNext()) {
     SourceMapping.Location tempLoc = (SourceMapping.Location) it.next();
     if (".text".equals(tempLoc.section)) profiles.add(new EnergyProfile(tempLoc));
   }
 }
 /** find all sleep opcodes in the program */
 private void findSleep() {
   int i = 0;
   while (i < program.program_length) {
     LegacyInstr instr = (LegacyInstr) program.readInstr(i);
     if (instr != null) {
       if ("sleep".equals(instr.properties.name)) {
         simulator.insertProbe(sleepProbe, i);
       }
       i += instr.getSize();
     } else i += 1;
   }
 }
Example #4
0
  public Program build() {
    newprogram =
        new Program(
            LegacyArchitecture.INSTANCE,
            programSegment.lowest_address,
            programSegment.highest_address);

    sourceMapping = new SourceMapping(newprogram);
    newprogram.setSourceMapping(sourceMapping);
    for (Item pos : itemList) {
      simplify(pos);
    }

    return newprogram;
  }