def update_db(self): if self.results: db_info.create(self.stage, "tracedb") results = [r for r in self.results.itervalues()] print "have %d results" % len(results) print "adding dst entries" for r in results: db_info.get(self.stage).add_range_dsts_entry(r) print '-----------' # db_info.get(self.stage).print_range_dsts_info() db_info.get(self.stage).consolidate_trace_write_table() db_info.get(self.stage).flush_tracedb()
def process(events, log, analyzer, read_header, stage): """Invoke an analyzer on each event in a log.""" if isinstance(events, str): events = _read_events(open(events, 'r')) if isinstance(log, str): log = open(log, 'rb') if read_header: read_trace_header(log) dropped_event = Event.build("Dropped_Event(uint64_t num_events_dropped)") edict = {dropped_event_id: dropped_event} for num, event in enumerate(events): edict[num] = event def build_fn(analyzer, event): if isinstance(event, str): return analyzer.catchall fn = getattr(analyzer, event.name, None) if fn is None: return analyzer.catchall event_argcount = len(event.args) fn_argcount = len(inspect.getargspec(fn)[0]) - 1 if fn_argcount == event_argcount + 1: # Include timestamp as first argument return lambda _, rec: fn(*( (rec[1:2], ) + rec[3:3 + event_argcount])) elif fn_argcount == event_argcount + 2: # Include timestamp and pid return lambda _, rec: fn(*rec[1:3 + event_argcount]) else: # Just arguments, no timestamp or pid return lambda _, rec: fn(*rec[3:3 + event_argcount]) analyzer.begin() fn_cache = {} db_info.create(stage, "tracedb") for rec in read_trace_records(edict, log): event_num = rec[0] event = edict[event_num] if event_num not in fn_cache: fn_cache[event_num] = build_fn(analyzer, event) fn_cache[event_num](event, rec, stage) db_info.get(stage).flush_tracedb()
def f_hook(self, args): for s in self.controller.stage_order: db_info.create(s, "tracedb")