xref: /openbmc/linux/tools/perf/util/session.h (revision 4e4f06e4)
1 #ifndef __PERF_SESSION_H
2 #define __PERF_SESSION_H
3 
4 #include "event.h"
5 #include "header.h"
6 #include "thread.h"
7 #include <linux/rbtree.h>
8 
9 struct thread;
10 struct symbol_conf;
11 
12 struct perf_session {
13 	struct perf_header	header;
14 	unsigned long		size;
15 	unsigned long		mmap_window;
16 	struct map_groups	kmaps;
17 	struct rb_root		threads;
18 	struct thread		*last_match;
19 	struct rb_root		hists;
20 	int			fd;
21 	int			cwdlen;
22 	char			*cwd;
23 	bool			use_modules;
24 	bool			use_callchain;
25 	char filename[0];
26 };
27 
28 typedef int (*event_op)(event_t *self, struct perf_session *session);
29 
30 struct perf_event_ops {
31 	event_op	process_sample_event;
32 	event_op	process_mmap_event;
33 	event_op	process_comm_event;
34 	event_op	process_fork_event;
35 	event_op	process_exit_event;
36 	event_op	process_lost_event;
37 	event_op	process_read_event;
38 	event_op	process_throttle_event;
39 	event_op	process_unthrottle_event;
40 	int		(*sample_type_check)(u64 sample_type,
41 					     struct perf_session *session);
42 	unsigned long	total_unknown;
43 	bool		full_paths;
44 };
45 
46 struct perf_session *perf_session__new(const char *filename, int mode,
47 				       bool force, struct symbol_conf *conf);
48 void perf_session__delete(struct perf_session *self);
49 
50 int perf_session__process_events(struct perf_session *self,
51 				 struct perf_event_ops *event_ops);
52 
53 int perf_header__read_build_ids(int input, u64 offset, u64 file_size);
54 
55 #endif /* __PERF_SESSION_H */
56