def grepTrace(self, traceName, expression, eventRange = None, fullText = True, context = 1, outputTrace = None):
    """
    Search for events matching a regular expression.
    
    @param traceName:     Trace to examine.
    @param expression:    Regular expression to search for.
    @param eventRange:    Event range to examine.
    @param fullText:      Search full trace text instead of only event names.
    @param context:       Number of events to list around matches.
    @param outputTrace:   Name of trace to save matched events to.
    """

    if not traceName in self.analyzer.traces:
      self.analyzer.fail("Trace not found: %s" % traceName)
    
    trace = self.analyzer.traces[traceName]

    try:
      exporter = [e for e in self.analyzer.exportPlugins if e.formatName == "text"][0]
    except IndexError:
      self.analyzer.fail("No text format exporter found.")

    if outputTrace:
      newTrace = copy.copy(trace)
      newTrace.events = []
      self.analyzer.traces[outputTrace] = newTrace
    else:
      newTrace = None

    tempTrace = copy.copy(trace)
    def eventToText(event):
      out              = StringIO.StringIO()
      tempTrace.events = [event]
      exporter.saveTrace(tempTrace, out, truncateValues = True, includeSensorData = False)
      return out.getvalue()

    firstEvent, lastEvent = self.analyzer.parseEventRange(trace, eventRange)
    fullText   = self.analyzer.parseBoolean(fullText)
    expression = re.compile(expression)
    task       = Task.startTask("grep", "Searching", len(trace.events[firstEvent:lastEvent]))

    for event in trace.events[firstEvent:lastEvent]:
      task.step()
      if fullText:
        text = eventToText(event)
      else:
        text = event.name

      if expression.search(text):
        if newTrace:
          newTrace.events.append(event)
        else:
          if not fullText:
            text = eventToText(event)
          self.reportInfo(text)
dataset/ETHPy150Open skyostil/tracy/src/analyzer/plugins/core/CorePlugin.py/CoreInteractivePlugin.grepTrace/original