示例#1
0
    def __call__(self, sample):
        if not sample.cpu in self.earliest_trace_per_cpu:
            self.earliest_trace_per_cpu[sample.cpu] = sample

        self.last_time = max(self.last_time, sample.time)

        matcher = self.matcher_by_name.get(sample.name, None)
        if not matcher:
            matcher = self.convention_matcher

        is_entry = matcher.is_entry_or_exit(sample)
        if is_entry == None:
            return

        id = (matcher, matcher.get_correlation_id(sample))
        if is_entry:
            if id in self.open_samples:
                old = self.open_samples[id]
                if self.earliest_trace_per_cpu[sample.cpu] > old:
                    pass
                else:
                    raise Exception('Nested entry:\n%s\n%s\n' %
                                    (str(old), str(sample)))
            self.open_samples[id] = sample
        else:
            entry_trace = self.open_samples.pop(id, None)
            if not entry_trace:
                return
            if entry_trace.cpu != sample.cpu and self.earliest_trace_per_cpu[
                    sample.cpu] > entry_trace:
                return
            duration = sample.time - entry_trace.time
            return trace.TimedTrace(entry_trace, duration)
示例#2
0
文件: trace.py 项目: janikokkonen/osv
    def __call__(self, t):
        self.block_tracepoints(t.tp)

        name = t.name
        ended = get_name_of_ended_func(name)
        if ended:
            if ended in self.open_functions[t.thread]:
                timed = self.open_functions[t.thread].pop(ended)
                timed.duration = t.time - timed.trace.time
                return timed
        elif t.tp in self.block_tracepoints:
            if name in self.open_functions[t.thread]:
                raise Exception("Nested traces not supported: " + name)
            self.open_functions[t.thread][name] = trace.TimedTrace(t)
示例#3
0
 def finish(self):
     for sample in self.open_samples.values():
         duration = self.last_time - sample.time
         yield trace.TimedTrace(sample, duration)