xref: /linux/tools/perf/util/session.h (revision 5499b45190237ca90dd2ac86395cf464fe1f4cc7)
1 #ifndef __PERF_SESSION_H
2 #define __PERF_SESSION_H
3 
4 #include "event.h"
5 #include "header.h"
6 #include "symbol.h"
7 #include "thread.h"
8 #include <linux/rbtree.h>
9 #include "../../../include/linux/perf_event.h"
10 
11 struct ip_callchain;
12 struct thread;
13 
14 struct perf_session {
15 	struct perf_header	header;
16 	unsigned long		size;
17 	unsigned long		mmap_window;
18 	struct map_groups	kmaps;
19 	struct rb_root		threads;
20 	struct thread		*last_match;
21 	struct map		*vmlinux_maps[MAP__NR_TYPES];
22 	struct events_stats	events_stats;
23 	unsigned long		event_total[PERF_RECORD_MAX];
24 	unsigned long		unknown_events;
25 	struct rb_root		hists;
26 	u64			sample_type;
27 	struct ref_reloc_sym	ref_reloc_sym;
28 	int			fd;
29 	int			cwdlen;
30 	char			*cwd;
31 	char filename[0];
32 };
33 
34 typedef int (*event_op)(event_t *self, struct perf_session *session);
35 
36 struct perf_event_ops {
37 	event_op sample,
38 		 mmap,
39 		 comm,
40 		 fork,
41 		 exit,
42 		 lost,
43 		 read,
44 		 throttle,
45 		 unthrottle;
46 };
47 
48 struct perf_session *perf_session__new(const char *filename, int mode, bool force);
49 void perf_session__delete(struct perf_session *self);
50 
51 void perf_event_header__bswap(struct perf_event_header *self);
52 
53 int __perf_session__process_events(struct perf_session *self,
54 				   u64 data_offset, u64 data_size, u64 size,
55 				   struct perf_event_ops *ops);
56 int perf_session__process_events(struct perf_session *self,
57 				 struct perf_event_ops *event_ops);
58 
59 struct symbol **perf_session__resolve_callchain(struct perf_session *self,
60 						struct thread *thread,
61 						struct ip_callchain *chain,
62 						struct symbol **parent);
63 
64 bool perf_session__has_traces(struct perf_session *self, const char *msg);
65 
66 int perf_header__read_build_ids(struct perf_header *self, int input,
67 				u64 offset, u64 file_size);
68 
69 int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
70 					     const char *symbol_name,
71 					     u64 addr);
72 
73 void mem_bswap_64(void *src, int byte_size);
74 
75 static inline int __perf_session__create_kernel_maps(struct perf_session *self,
76 						struct dso *kernel)
77 {
78 	return __map_groups__create_kernel_maps(&self->kmaps,
79 						self->vmlinux_maps, kernel);
80 }
81 
82 static inline struct map *
83 	perf_session__new_module_map(struct perf_session *self,
84 				     u64 start, const char *filename)
85 {
86 	return map_groups__new_module(&self->kmaps, start, filename);
87 }
88 #endif /* __PERF_SESSION_H */
89