def _create_events(event_names: Set[str], ) -> List[lttng.Event]: """ Create events list from names. :param event_names: a set of names to create events for :return: the list of events """ events_list = [] for event_name in event_names: e = lttng.Event() e.name = event_name e.type = lttng.EVENT_TRACEPOINT e.loglevel_type = lttng.EVENT_LOGLEVEL_ALL events_list.append(e) return events_list
def lttng_start(events=["*"], domain_type=lttng.DOMAIN_UST): if lttng.session_daemon_alive() == 0: daemon_cmd = "lttng-sessiond --background" daemon_cmd += " --pidfile " + sessiond_pidfile subprocess.check_call(daemon_cmd, shell=True, stdout=sessiond_logfile, stderr=sessiond_logfile) lttng.destroy(session_name) ret = lttng.create_snapshot(session_name, trace_path) if ret < 0: raise RuntimeError("LTTng: " + lttng.strerror(ret)) domain = lttng.Domain() domain.type = domain_type channel = lttng.Channel() channel.name = "channel0" lttng.channel_set_default_attr(domain, channel.attr) han = lttng.Handle(session_name, domain) if han is None: raise RuntimeError("LTTng: failed to create handle") ret = lttng.enable_channel(han, channel) if ret < 0: raise RuntimeError("LTTng: " + lttng.strerror(ret)) for name in events: event = lttng.Event() event.name = name event.type = lttng.EVENT_TRACEPOINT event.loglevel = lttng.EVENT_LOGLEVEL_ALL ret = lttng.enable_event(han, event, channel.name) if ret < 0: raise RuntimeError("LTTng: " + lttng.strerror(ret)) ret = lttng.start(session_name) if ret < 0: raise RuntimeError("LTTng: " + lttng.strerror(ret))
# Creating a new session and handle ret = lttng.create(ses_name, trace_path) if ret < 0: raise LTTngError(lttng.strerror(ret)) domain = lttng.Domain() domain.type = lttng.DOMAIN_KERNEL han = None han = lttng.Handle(ses_name, domain) if han is None: raise LTTngError("Handle not created") # Enabling all events event = lttng.Event() event.type = lttng.EVENT_ALL event.loglevel_type = lttng.EVENT_LOGLEVEL_ALL ret = lttng.enable_event(han, event, None) if ret < 0: raise LTTngError(lttng.strerror(ret)) # Start, wait, stop ret = lttng.start(ses_name) if ret < 0: raise LTTngError(lttng.strerror(ret)) print("Tracing...") time.sleep(2) print("Stopped.") ret = lttng.stop(ses_name) if ret < 0:
def make_event(nm): ev = lttng.Event() ev.name = nm ev.type = lttng.EVENT_TRACEPOINT ev.loglevel = lttng.EVENT_LOGLEVEL_ALL return ev