Esempio n. 1
0
    def verifyTrace(self, traceName):
        """
    Verify that a trace is compatible with the loaded project

    @param traceName:  Trace name
    """
        if not traceName in self.analyzer.traces:
            self.analyzer.fail("Trace not found: %s" % traceName)

        trace = self.analyzer.traces[traceName]
        TraceOperations.verify(self, self.analyzer.project, trace)
Esempio n. 2
0
  def verifyTrace(self, traceName):
    """
    Verify that a trace is compatible with the loaded project

    @param traceName:  Trace name
    """
    if not traceName in self.analyzer.traces:
      self.analyzer.fail("Trace not found: %s" % traceName)
    
    trace = self.analyzer.traces[traceName]
    TraceOperations.verify(self, self.analyzer.project, trace)
Esempio n. 3
0
    def loadTrace(self, fileName, traceName=None, format=None):
        """
    Open a trace file.

    @param fileName:   Trace file to open
    @param traceName:  Resulting trace name
    @param format:     Force a specific format to be used instead of autodetection.
    """
        trace = Trace.Trace()

        for importer in self.analyzer.importPlugins:
            if format is not None and importer.formatName == format:
                break
            if importer.recognizeTraceFile(fileName):
                break
        else:
            if format is not None:
                self.analyzer.fail(
                    "No such format. Available formats: %s." % (", ".join(
                        [i.formatName for i in self.analyzer.importPlugins])))
            self.analyzer.fail("Trace file format not recognized.")

        try:
            f = open(fileName, "rb")
            traces = importer.loadTrace(f)
            f.close()

            # Some decoders can load multiple trace files from one source
            if not isinstance(traces, list):
                traces = [traces]

            for trace in traces:
                traceName = traceName or "t%d" % len(self.analyzer.traces)
                self.analyzer.traces[traceName] = trace
                self.analyzer.traceFiles[traceName] = fileName
                if not TraceOperations.verify(self, self.analyzer.project,
                                              trace):
                    self.reportWarning(
                        "The loaded project probably does not match the trace file."
                    )

                self.reportInfo("Loaded trace from '%s' as %s." %
                                (fileName, traceName))
                traceName = None
            return traces[0]
        except IOError, e:
            self.analyzer.fail(e)
Esempio n. 4
0
  def loadTrace(self, fileName, traceName = None, format = None):
    """
    Open a trace file.

    @param fileName:   Trace file to open
    @param traceName:  Resulting trace name
    @param format:     Force a specific format to be used instead of autodetection.
    """
    trace     = Trace.Trace()

    for importer in self.analyzer.importPlugins:
      if format is not None and importer.formatName == format:
        break
      if importer.recognizeTraceFile(fileName):
        break
    else:
      if format is not None:
        self.analyzer.fail("No such format. Available formats: %s." % (", ".join([i.formatName for i in self.analyzer.importPlugins])))
      self.analyzer.fail("Trace file format not recognized.")

    try:
      f = open(fileName, "rb")
      traces = importer.loadTrace(f)
      f.close()

      # Some decoders can load multiple trace files from one source
      if not isinstance(traces, list):
          traces = [traces]
     
      for trace in traces:
          traceName = traceName or "t%d" % len(self.analyzer.traces)
          self.analyzer.traces[traceName]     = trace
          self.analyzer.traceFiles[traceName] = fileName
          if not TraceOperations.verify(self, self.analyzer.project, trace):
            self.reportWarning("The loaded project probably does not match the trace file.")
          
          self.reportInfo("Loaded trace from '%s' as %s." % (fileName, traceName))
          traceName = None
      return traces[0]
    except IOError, e:
      self.analyzer.fail(e)