1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __PERF_SESSION_H
3 #define __PERF_SESSION_H
5 #include "trace-event.h"
10 #include "ordered-events.h"
11 #include "util/compress.h"
12 #include <linux/kernel.h>
13 #include <linux/rbtree.h>
14 #include <linux/perf_event.h>
21 struct itrace_synth_opts;
24 struct perf_header header;
25 struct machines machines;
26 struct evlist *evlist;
27 struct auxtrace *auxtrace;
28 struct itrace_synth_opts *itrace_synth_opts;
29 struct list_head auxtrace_index;
30 struct trace_event tevent;
31 struct perf_record_time_conv time_conv;
36 struct ordered_events ordered_events;
37 struct perf_data *data;
38 struct perf_tool *tool;
39 u64 bytes_transferred;
41 struct zstd_data zstd_data;
42 struct decomp *decomp;
43 struct decomp *decomp_last;
57 struct perf_session *perf_session__new(struct perf_data *data,
58 bool repipe, struct perf_tool *tool);
59 void perf_session__delete(struct perf_session *session);
61 void perf_event_header__bswap(struct perf_event_header *hdr);
63 int perf_session__peek_event(struct perf_session *session, off_t file_offset,
64 void *buf, size_t buf_sz,
65 union perf_event **event_ptr,
66 struct perf_sample *sample);
67 typedef int (*peek_events_cb_t)(struct perf_session *session,
68 union perf_event *event, u64 offset,
70 int perf_session__peek_events(struct perf_session *session, u64 offset,
71 u64 size, peek_events_cb_t cb, void *data);
73 int perf_session__process_events(struct perf_session *session);
75 int perf_session__queue_event(struct perf_session *s, union perf_event *event,
76 u64 timestamp, u64 file_offset);
78 void perf_tool__fill_defaults(struct perf_tool *tool);
80 int perf_session__resolve_callchain(struct perf_session *session,
82 struct thread *thread,
83 struct ip_callchain *chain,
84 struct symbol **parent);
86 bool perf_session__has_traces(struct perf_session *session, const char *msg);
88 void perf_event__attr_swap(struct perf_event_attr *attr);
90 int perf_session__create_kernel_maps(struct perf_session *session);
92 void perf_session__set_id_hdr_size(struct perf_session *session);
95 struct machine *perf_session__find_machine(struct perf_session *session, pid_t pid)
97 return machines__find(&session->machines, pid);
101 struct machine *perf_session__findnew_machine(struct perf_session *session, pid_t pid)
103 return machines__findnew(&session->machines, pid);
106 struct thread *perf_session__findnew(struct perf_session *session, pid_t pid);
107 int perf_session__register_idle_thread(struct perf_session *session);
109 size_t perf_session__fprintf(struct perf_session *session, FILE *fp);
111 size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp);
113 size_t perf_session__fprintf_dsos_buildid(struct perf_session *session, FILE *fp,
114 bool (fn)(struct dso *dso, int parm), int parm);
116 size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp,
119 struct evsel *perf_session__find_first_evtype(struct perf_session *session,
122 int perf_session__cpu_bitmap(struct perf_session *session,
123 const char *cpu_list, unsigned long *cpu_bitmap);
125 void perf_session__fprintf_info(struct perf_session *s, FILE *fp, bool full);
127 struct evsel_str_handler;
129 #define perf_session__set_tracepoints_handlers(session, array) \
130 __evlist__set_tracepoints_handlers(session->evlist, array, ARRAY_SIZE(array))
132 extern volatile int session_done;
134 #define session_done() READ_ONCE(session_done)
136 int perf_session__deliver_synth_event(struct perf_session *session,
137 union perf_event *event,
138 struct perf_sample *sample);
140 int perf_event__process_id_index(struct perf_session *session,
141 union perf_event *event);
143 #endif /* __PERF_SESSION_H */