]>
Commit | Line | Data |
---|---|---|
94c744b6 ACM |
1 | #ifndef __PERF_SESSION_H |
2 | #define __PERF_SESSION_H | |
3 | ||
301a0b02 | 4 | #include "event.h" |
94c744b6 | 5 | #include "header.h" |
9de89fe7 | 6 | #include "symbol.h" |
4aa65636 | 7 | #include "thread.h" |
b3165f41 | 8 | #include <linux/rbtree.h> |
f823e441 | 9 | #include "../../../include/linux/perf_event.h" |
b3165f41 | 10 | |
c61e52ee | 11 | struct sample_queue; |
a328626b | 12 | struct ip_callchain; |
b3165f41 | 13 | struct thread; |
94c744b6 | 14 | |
c61e52ee FW |
15 | struct ordered_samples { |
16 | u64 last_flush; | |
d6b17beb FW |
17 | u64 next_flush; |
18 | u64 max_timestamp; | |
c61e52ee FW |
19 | struct list_head samples_head; |
20 | struct sample_queue *last_inserted; | |
21 | }; | |
22 | ||
94c744b6 ACM |
23 | struct perf_session { |
24 | struct perf_header header; | |
25 | unsigned long size; | |
ec913369 | 26 | unsigned long mmap_window; |
b3165f41 ACM |
27 | struct rb_root threads; |
28 | struct thread *last_match; | |
1f626bc3 | 29 | struct machine host_machine; |
23346f21 | 30 | struct rb_root machines; |
f823e441 | 31 | struct events_stats events_stats; |
cb8f0939 | 32 | struct rb_root stats_by_id; |
f823e441 | 33 | unsigned long event_total[PERF_RECORD_MAX]; |
31d337c4 | 34 | unsigned long unknown_events; |
4e4f06e4 | 35 | struct rb_root hists; |
c019879b | 36 | u64 sample_type; |
94c744b6 | 37 | int fd; |
8dc58101 | 38 | bool fd_pipe; |
454c407e | 39 | bool repipe; |
ec913369 ACM |
40 | int cwdlen; |
41 | char *cwd; | |
c61e52ee | 42 | struct ordered_samples ordered_samples; |
94c744b6 ACM |
43 | char filename[0]; |
44 | }; | |
45 | ||
d6b17beb FW |
46 | struct perf_event_ops; |
47 | ||
301a0b02 | 48 | typedef int (*event_op)(event_t *self, struct perf_session *session); |
d6b17beb FW |
49 | typedef int (*event_op2)(event_t *self, struct perf_session *session, |
50 | struct perf_event_ops *ops); | |
301a0b02 ACM |
51 | |
52 | struct perf_event_ops { | |
d6b17beb FW |
53 | event_op sample, |
54 | mmap, | |
55 | comm, | |
56 | fork, | |
57 | exit, | |
58 | lost, | |
59 | read, | |
60 | throttle, | |
61 | unthrottle, | |
62 | attr, | |
63 | event_type, | |
64 | tracing_data, | |
65 | build_id; | |
66 | event_op2 finished_round; | |
67 | bool ordered_samples; | |
301a0b02 ACM |
68 | }; |
69 | ||
454c407e | 70 | struct perf_session *perf_session__new(const char *filename, int mode, bool force, bool repipe); |
94c744b6 ACM |
71 | void perf_session__delete(struct perf_session *self); |
72 | ||
ba21594c ACM |
73 | void perf_event_header__bswap(struct perf_event_header *self); |
74 | ||
6122e4e4 ACM |
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); | |
301a0b02 | 78 | int perf_session__process_events(struct perf_session *self, |
ec913369 | 79 | struct perf_event_ops *event_ops); |
301a0b02 | 80 | |
b3c9ac08 ACM |
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); | |
a328626b | 85 | |
d549c769 | 86 | bool perf_session__has_traces(struct perf_session *self, const char *msg); |
27295592 | 87 | |
a1645ce1 | 88 | int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps, |
56b03f3c ACM |
89 | const char *symbol_name, |
90 | u64 addr); | |
56b03f3c | 91 | |
ba21594c ACM |
92 | void mem_bswap_64(void *src, int byte_size); |
93 | ||
a1645ce1 | 94 | int perf_session__create_kernel_maps(struct perf_session *self); |
f9224c5c | 95 | |
8dc58101 TZ |
96 | int do_read(int fd, void *buf, size_t size); |
97 | void perf_session__update_sample_type(struct perf_session *self); | |
98 | ||
f9224c5c | 99 | #ifdef NO_NEWT_SUPPORT |
5f4d3f88 ACM |
100 | static inline int perf_session__browse_hists(struct rb_root *hists __used, |
101 | u64 nr_hists __used, | |
f9224c5c | 102 | u64 session_total __used, |
533c46c3 ACM |
103 | const char *helpline __used, |
104 | const char *input_name __used) | |
5f4d3f88 ACM |
105 | { |
106 | return 0; | |
107 | } | |
f9224c5c | 108 | #else |
5f4d3f88 | 109 | int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists, |
533c46c3 ACM |
110 | u64 session_total, const char *helpline, |
111 | const char *input_name); | |
f9224c5c | 112 | #endif |
23346f21 ACM |
113 | |
114 | static inline | |
115 | struct machine *perf_session__find_host_machine(struct perf_session *self) | |
116 | { | |
1f626bc3 | 117 | return &self->host_machine; |
23346f21 ACM |
118 | } |
119 | ||
120 | static inline | |
121 | struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid) | |
122 | { | |
1f626bc3 ACM |
123 | if (pid == HOST_KERNEL_ID) |
124 | return &self->host_machine; | |
23346f21 ACM |
125 | return machines__find(&self->machines, pid); |
126 | } | |
127 | ||
128 | static inline | |
129 | struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid) | |
130 | { | |
1f626bc3 ACM |
131 | if (pid == HOST_KERNEL_ID) |
132 | return &self->host_machine; | |
23346f21 ACM |
133 | return machines__findnew(&self->machines, pid); |
134 | } | |
135 | ||
136 | static inline | |
137 | void perf_session__process_machines(struct perf_session *self, | |
138 | machine__process_t process) | |
139 | { | |
1f626bc3 | 140 | process(&self->host_machine, self); |
23346f21 ACM |
141 | return machines__process(&self->machines, process, self); |
142 | } | |
cbf69680 | 143 | |
1f626bc3 | 144 | size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp); |
cbf69680 ACM |
145 | |
146 | static inline | |
147 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp, | |
148 | bool with_hits) | |
149 | { | |
150 | return machines__fprintf_dsos_buildid(&self->machines, fp, with_hits); | |
151 | } | |
94c744b6 | 152 | #endif /* __PERF_SESSION_H */ |