1 #ifndef __PERF_SESSION_H
2 #define __PERF_SESSION_H
8 #include <linux/rbtree.h>
9 #include "../../../include/linux/perf_event.h"
15 struct ordered_samples {
19 struct list_head samples_head;
20 struct sample_queue *last_inserted;
24 struct perf_header header;
26 unsigned long mmap_window;
27 struct rb_root threads;
28 struct thread *last_match;
29 struct machine host_machine;
30 struct rb_root machines;
31 struct events_stats events_stats;
32 struct rb_root stats_by_id;
33 unsigned long event_total[PERF_RECORD_MAX];
34 unsigned long unknown_events;
42 struct ordered_samples ordered_samples;
46 struct perf_event_ops;
48 typedef int (*event_op)(event_t *self, struct perf_session *session);
49 typedef int (*event_op2)(event_t *self, struct perf_session *session,
50 struct perf_event_ops *ops);
52 struct perf_event_ops {
66 event_op2 finished_round;
70 struct perf_session *perf_session__new(const char *filename, int mode, bool force, bool repipe);
71 void perf_session__delete(struct perf_session *self);
73 void perf_event_header__bswap(struct perf_event_header *self);
75 int __perf_session__process_events(struct perf_session *self,
76 u64 data_offset, u64 data_size, u64 size,
77 struct perf_event_ops *ops);
78 int perf_session__process_events(struct perf_session *self,
79 struct perf_event_ops *event_ops);
81 struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
82 struct thread *thread,
83 struct ip_callchain *chain,
84 struct symbol **parent);
86 bool perf_session__has_traces(struct perf_session *self, const char *msg);
88 int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps,
89 const char *symbol_name,
92 void mem_bswap_64(void *src, int byte_size);
94 int perf_session__create_kernel_maps(struct perf_session *self);
96 int do_read(int fd, void *buf, size_t size);
97 void perf_session__update_sample_type(struct perf_session *self);
99 #ifdef NO_NEWT_SUPPORT
100 static inline int perf_session__browse_hists(struct rb_root *hists __used,
102 u64 session_total __used,
103 const char *helpline __used,
104 const char *input_name __used)
109 int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
110 u64 session_total, const char *helpline,
111 const char *input_name);
115 struct machine *perf_session__find_host_machine(struct perf_session *self)
117 return &self->host_machine;
121 struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid)
123 if (pid == HOST_KERNEL_ID)
124 return &self->host_machine;
125 return machines__find(&self->machines, pid);
129 struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid)
131 if (pid == HOST_KERNEL_ID)
132 return &self->host_machine;
133 return machines__findnew(&self->machines, pid);
137 void perf_session__process_machines(struct perf_session *self,
138 machine__process_t process)
140 process(&self->host_machine, self);
141 return machines__process(&self->machines, process, self);
144 size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp);
147 size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp,
150 return machines__fprintf_dsos_buildid(&self->machines, fp, with_hits);
152 #endif /* __PERF_SESSION_H */