def _process_event(self, event: DictEvent) -> None: """Process a single event.""" event_name = get_event_name(event) handler_functions = self._handler_multimap.get(event_name, None) if handler_functions is not None: for handler_function in handler_functions: timestamp = get_field(event, '_timestamp') cpu_id = get_field(event, 'cpu_id') # TODO perhaps validate fields depending on the type of event, # i.e. all UST events should have procname, (v)pid and (v)tid # context info, since analyses might not work otherwise procname = get_field(event, 'procname', raise_if_not_found=False) pid = get_field( event, 'vpid', default=get_field( event, 'pid', raise_if_not_found=False), raise_if_not_found=False) tid = get_field( event, 'vtid', default=get_field( event, 'tid', raise_if_not_found=False), raise_if_not_found=False) metadata = EventMetadata(event_name, timestamp, cpu_id, procname, pid, tid) handler_function(event, metadata)
def get_event_names(events: List[DictEvent]) -> List[str]: """ Get a list of events names from a list of events. :param events: the events of the trace :return: the list of event names """ return [get_event_name(e) for e in events]
def get_events_with_name( self, event_name: str, events: List[DictEvent] = None, ) -> List[DictEvent]: """ Get all events with the given name. :param event_name: the event name :param events: the events to check (or `None` to check all events) :return: the list of events with the given name """ if events is None: events = self._events return [e for e in events if get_event_name(e) == event_name]
def get_event_names( events: List[DictEvent], ) -> Set[str]: """Get set of names from a list of events.""" return {get_event_name(event) for event in events}