示例#1
0
 def getEventDescription(self, event):
   # Create a textual representation an event
   args = []
   func = self.library.functions[event.name]
   
   for name, value in event.values.items():
     if not name: continue
     value = StringUtils.ellipsis(StringUtils.decorateValue(self.library, func, name, value))
     args.append((name, value))
   return "%s(%s)" % (event.name, ", ".join(["%s = %s" % (k, v) for k, v in args]))
示例#2
0
    def getEventDescription(self, event):
        # Create a textual representation an event
        args = []
        func = self.library.functions[event.name]

        for name, value in event.values.items():
            if not name: continue
            value = StringUtils.ellipsis(
                StringUtils.decorateValue(self.library, func, name, value))
            args.append((name, value))
        return "%s(%s)" % (event.name, ", ".join(
            ["%s = %s" % (k, v) for k, v in args]))
示例#3
0
文件: TextFormat.py 项目: se210/tracy
  def saveTrace(self, trace, traceFile, truncateValues = True, includeSensorData = False):
    try:
      library = self.analyzer.project.targets["code"].library
    except (AttributeError, KeyError):
      library = None

    task              = Task.startTask("text-export", "Formatting text", len(trace.events))
    truncateValues    = self.analyzer.parseBoolean(truncateValues)
    includeSensorData = self.analyzer.parseBoolean(includeSensorData)
    maxValueLength    = 1024 * 1024
    
    # Describe instrumentation sensors
    if includeSensorData:
      for name, sensor in sorted(trace.sensors.items()):
        print >>traceFile, "%010d %010d @inst %s: %s" % (0, 0, name, sensor.description)
    
    for event in trace.events:
      try:
        function = self.analyzer.lookupFunction(event)
      except:
        function = None
        
      # Print out any associated instrumentation data
      if includeSensorData:
        for key, value in sorted(event.sensorData.items()):
          if value:
            print >>traceFile, "%010d %010d @inst %s = %s" % (event.seq, event.time, key, value)
      
      # Print out any modified arrays that are not actual parameters for the event.
      for array in event.modifiedArrays:
        for value in event.values.values():
          if isinstance(value, Trace.Array) and value.id == array.id:
            break
        else:
          if truncateValues:
            text = StringUtils.ellipsis(array, maxLength = maxValueLength)
          else:
            text = array
          print >>traceFile, "%010d %010d @array 0x%x = %s" % (event.seq, event.time, array.id, text)
          
      args = []

      # Print out the parameters
      for name, value in event.values.items():
        if not name:
          continue
          
        if function and library:
          value = StringUtils.decorateValue(library, function, name, value)
          if truncateValues:
            value = StringUtils.ellipsis(value, maxLength = maxValueLength)
          
        args += ["%s=%s" % (name, value)]

      print >>traceFile, "%010d %010d %s (%s)" % (event.seq, event.time, event.name, ", ".join(args)),
          
      if None in event.values:
        print >>traceFile, "-> %s" % event.values[None], "+%d" % event.duration
      else:
        print >>traceFile, "+%d" % event.duration
      task.step()
示例#4
0
文件: TextFormat.py 项目: se210/tracy
    def saveTrace(self,
                  trace,
                  traceFile,
                  truncateValues=True,
                  includeSensorData=False):
        try:
            library = self.analyzer.project.targets["code"].library
        except (AttributeError, KeyError):
            library = None

        task = Task.startTask("text-export", "Formatting text",
                              len(trace.events))
        truncateValues = self.analyzer.parseBoolean(truncateValues)
        includeSensorData = self.analyzer.parseBoolean(includeSensorData)
        maxValueLength = 1024 * 1024

        # Describe instrumentation sensors
        if includeSensorData:
            for name, sensor in sorted(trace.sensors.items()):
                print >> traceFile, "%010d %010d @inst %s: %s" % (
                    0, 0, name, sensor.description)

        for event in trace.events:
            try:
                function = self.analyzer.lookupFunction(event)
            except:
                function = None

            # Print out any associated instrumentation data
            if includeSensorData:
                for key, value in sorted(event.sensorData.items()):
                    if value:
                        print >> traceFile, "%010d %010d @inst %s = %s" % (
                            event.seq, event.time, key, value)

            # Print out any modified arrays that are not actual parameters for the event.
            for array in event.modifiedArrays:
                for value in event.values.values():
                    if isinstance(value, Trace.Array) and value.id == array.id:
                        break
                else:
                    if truncateValues:
                        text = StringUtils.ellipsis(array,
                                                    maxLength=maxValueLength)
                    else:
                        text = array
                    print >> traceFile, "%010d %010d @array 0x%x = %s" % (
                        event.seq, event.time, array.id, text)

            args = []

            # Print out the parameters
            for name, value in event.values.items():
                if not name:
                    continue

                if function and library:
                    value = StringUtils.decorateValue(library, function, name,
                                                      value)
                    if truncateValues:
                        value = StringUtils.ellipsis(value,
                                                     maxLength=maxValueLength)

                args += ["%s=%s" % (name, value)]

            print >> traceFile, "%010d %010d %s (%s)" % (
                event.seq, event.time, event.name, ", ".join(args)),

            if None in event.values:
                print >> traceFile, "-> %s" % event.values[
                    None], "+%d" % event.duration
            else:
                print >> traceFile, "+%d" % event.duration
            task.step()