示例#1
0
  public static void main(String[] args) {
    TraceReader reader = null;
    boolean regression = false;

    // ping the usage server

    String revision = getRevision();
    if (revision != null) {
      new SdkStatsService().ping(PING_NAME, revision);
    }

    // Process command line arguments
    int argc = 0;
    int len = args.length;
    while (argc < len) {
      String arg = args[argc];
      if (arg.charAt(0) != '-') {
        break;
      }
      if (arg.equals("-r")) {
        regression = true;
      } else {
        break;
      }
      argc++;
    }
    if (argc != len - 1) {
      System.out.printf("Usage: java %s [-r] trace%n", MainWindow.class.getName());
      System.out.printf("  -r   regression only%n");
      return;
    }

    String traceName = args[len - 1];
    File file = new File(traceName);
    if (file.exists() && file.isDirectory()) {
      System.out.printf("Qemu trace files not supported yet.\n");
      System.exit(1);
      // reader = new QtraceReader(traceName);
    } else {
      // If the filename as given doesn't exist...
      if (!file.exists()) {
        // Try appending .trace.
        if (new File(traceName + ".trace").exists()) {
          traceName = traceName + ".trace";
          // Next, see if it is the old two-file trace.
        } else if (new File(traceName + ".data").exists()
            && new File(traceName + ".key").exists()) {
          try {
            traceName = makeTempTraceFile(traceName);
          } catch (IOException e) {
            System.err.printf("cannot convert old trace file '%s'\n", traceName);
            System.exit(1);
          }
          // Otherwise, give up.
        } else {
          System.err.printf("trace file '%s' not found\n", traceName);
          System.exit(1);
        }
      }

      try {
        reader = new DmTraceReader(traceName, regression);
      } catch (IOException e) {
        System.err.printf("Failed to read the trace file");
        e.printStackTrace();
        System.exit(1);
        return;
      }
    }

    reader.getTraceUnits().setTimeScale(TraceUnits.TimeScale.MilliSeconds);

    Display.setAppName("Traceview");
    new MainWindow(traceName, reader).run();
  }