+static int trace__replay(struct trace *trace)
+{
+ const struct perf_evsel_str_handler handlers[] = {
+ { "raw_syscalls:sys_enter", trace__sys_enter, },
+ { "raw_syscalls:sys_exit", trace__sys_exit, },
+ };
+
+ struct perf_session *session;
+ int err = -1;
+
+ trace->tool.sample = trace__process_sample;
+ trace->tool.mmap = perf_event__process_mmap;
+ trace->tool.comm = perf_event__process_comm;
+ trace->tool.exit = perf_event__process_exit;
+ trace->tool.fork = perf_event__process_fork;
+ trace->tool.attr = perf_event__process_attr;
+ trace->tool.tracing_data = perf_event__process_tracing_data;
+ trace->tool.build_id = perf_event__process_build_id;
+
+ trace->tool.ordered_samples = true;
+ trace->tool.ordering_requires_timestamps = true;
+
+ /* add tid to output */
+ trace->multiple_threads = true;
+
+ if (symbol__init() < 0)
+ return -1;
+
+ session = perf_session__new(input_name, O_RDONLY, 0, false,
+ &trace->tool);
+ if (session == NULL)
+ return -ENOMEM;
+
+ err = perf_session__set_tracepoints_handlers(session, handlers);
+ if (err)
+ goto out;
+
+ if (!perf_session__has_tp(session, "raw_syscalls:sys_enter")) {
+ pr_err("Data file does not have raw_syscalls:sys_enter events\n");
+ goto out;
+ }
+
+ if (!perf_session__has_tp(session, "raw_syscalls:sys_exit")) {
+ pr_err("Data file does not have raw_syscalls:sys_exit events\n");
+ goto out;
+ }
+
+ setup_pager();
+
+ err = perf_session__process_events(session, &trace->tool);
+ if (err)
+ pr_err("Failed to process events, error %d", err);
+
+out:
+ perf_session__delete(session);
+
+ return err;
+}
+