]>
Commit | Line | Data |
---|---|---|
94c744b6 ACM |
1 | #ifndef __PERF_SESSION_H |
2 | #define __PERF_SESSION_H | |
3 | ||
1c02c4d2 | 4 | #include "hist.h" |
301a0b02 | 5 | #include "event.h" |
94c744b6 | 6 | #include "header.h" |
9de89fe7 | 7 | #include "symbol.h" |
4aa65636 | 8 | #include "thread.h" |
b3165f41 | 9 | #include <linux/rbtree.h> |
f823e441 | 10 | #include "../../../include/linux/perf_event.h" |
b3165f41 | 11 | |
c61e52ee | 12 | struct sample_queue; |
a328626b | 13 | struct ip_callchain; |
b3165f41 | 14 | struct thread; |
94c744b6 | 15 | |
c61e52ee FW |
16 | struct ordered_samples { |
17 | u64 last_flush; | |
d6b17beb FW |
18 | u64 next_flush; |
19 | u64 max_timestamp; | |
a1225dec | 20 | struct list_head samples; |
020bb75a | 21 | struct list_head sample_cache; |
5c891f38 TG |
22 | struct list_head to_free; |
23 | struct sample_queue *sample_buffer; | |
a1225dec | 24 | struct sample_queue *last_sample; |
5c891f38 | 25 | int sample_buffer_idx; |
88660563 | 26 | unsigned int nr_samples; |
c61e52ee FW |
27 | }; |
28 | ||
94c744b6 ACM |
29 | struct perf_session { |
30 | struct perf_header header; | |
31 | unsigned long size; | |
ec913369 | 32 | unsigned long mmap_window; |
1f626bc3 | 33 | struct machine host_machine; |
23346f21 | 34 | struct rb_root machines; |
e248de33 | 35 | struct perf_evlist *evlist; |
da378962 | 36 | struct pevent *pevent; |
1c02c4d2 | 37 | /* |
e248de33 ACM |
38 | * FIXME: Need to split this up further, we need global |
39 | * stats + per event stats. 'perf diff' also needs | |
40 | * to properly support multiple events in a single | |
41 | * perf.data file. | |
1c02c4d2 ACM |
42 | */ |
43 | struct hists hists; | |
94c744b6 | 44 | int fd; |
8dc58101 | 45 | bool fd_pipe; |
454c407e | 46 | bool repipe; |
ec913369 ACM |
47 | int cwdlen; |
48 | char *cwd; | |
c61e52ee | 49 | struct ordered_samples ordered_samples; |
002c4fd9 | 50 | char filename[1]; |
94c744b6 ACM |
51 | }; |
52 | ||
45694aa7 | 53 | struct perf_tool; |
301a0b02 | 54 | |
21ef97f0 IM |
55 | struct perf_session *perf_session__new(const char *filename, int mode, |
56 | bool force, bool repipe, | |
45694aa7 | 57 | struct perf_tool *tool); |
94c744b6 ACM |
58 | void perf_session__delete(struct perf_session *self); |
59 | ||
ba21594c ACM |
60 | void perf_event_header__bswap(struct perf_event_header *self); |
61 | ||
6122e4e4 ACM |
62 | int __perf_session__process_events(struct perf_session *self, |
63 | u64 data_offset, u64 data_size, u64 size, | |
45694aa7 | 64 | struct perf_tool *tool); |
301a0b02 | 65 | int perf_session__process_events(struct perf_session *self, |
45694aa7 | 66 | struct perf_tool *tool); |
301a0b02 | 67 | |
246d4ce8 | 68 | int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel, |
1b3a0e95 FW |
69 | struct thread *thread, |
70 | struct ip_callchain *chain, | |
71 | struct symbol **parent); | |
a328626b | 72 | |
b5387528 RAV |
73 | struct branch_info *machine__resolve_bstack(struct machine *self, |
74 | struct thread *thread, | |
75 | struct branch_stack *bs); | |
76 | ||
d549c769 | 77 | bool perf_session__has_traces(struct perf_session *self, const char *msg); |
27295592 | 78 | |
ba21594c | 79 | void mem_bswap_64(void *src, int byte_size); |
80c0120a | 80 | void mem_bswap_32(void *src, int byte_size); |
eda3913b | 81 | void perf_event__attr_swap(struct perf_event_attr *attr); |
ba21594c | 82 | |
a1645ce1 | 83 | int perf_session__create_kernel_maps(struct perf_session *self); |
f9224c5c | 84 | |
7b56cce2 | 85 | void perf_session__set_id_hdr_size(struct perf_session *session); |
720a3aeb | 86 | void perf_session__remove_thread(struct perf_session *self, struct thread *th); |
8dc58101 | 87 | |
23346f21 ACM |
88 | static inline |
89 | struct machine *perf_session__find_host_machine(struct perf_session *self) | |
90 | { | |
1f626bc3 | 91 | return &self->host_machine; |
23346f21 ACM |
92 | } |
93 | ||
94 | static inline | |
95 | struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid) | |
96 | { | |
1f626bc3 ACM |
97 | if (pid == HOST_KERNEL_ID) |
98 | return &self->host_machine; | |
23346f21 ACM |
99 | return machines__find(&self->machines, pid); |
100 | } | |
101 | ||
102 | static inline | |
103 | struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid) | |
104 | { | |
1f626bc3 ACM |
105 | if (pid == HOST_KERNEL_ID) |
106 | return &self->host_machine; | |
23346f21 ACM |
107 | return machines__findnew(&self->machines, pid); |
108 | } | |
109 | ||
110 | static inline | |
111 | void perf_session__process_machines(struct perf_session *self, | |
45694aa7 | 112 | struct perf_tool *tool, |
23346f21 ACM |
113 | machine__process_t process) |
114 | { | |
45694aa7 ACM |
115 | process(&self->host_machine, tool); |
116 | return machines__process(&self->machines, process, tool); | |
23346f21 | 117 | } |
cbf69680 | 118 | |
743eb868 ACM |
119 | struct thread *perf_session__findnew(struct perf_session *self, pid_t pid); |
120 | size_t perf_session__fprintf(struct perf_session *self, FILE *fp); | |
121 | ||
1f626bc3 | 122 | size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp); |
cbf69680 | 123 | |
f869097e ACM |
124 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, |
125 | FILE *fp, bool with_hits); | |
c8446b9b | 126 | |
e248de33 | 127 | size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp); |
d0dd74e8 | 128 | |
bde09467 ACM |
129 | int perf_session__parse_sample(struct perf_session *session, |
130 | const union perf_event *event, | |
131 | struct perf_sample *sample); | |
d0dd74e8 | 132 | |
7f3be652 ACM |
133 | int perf_session__synthesize_sample(struct perf_session *session, |
134 | union perf_event *event, | |
135 | const struct perf_sample *sample); | |
74eec26f | 136 | |
9cbdb702 DA |
137 | struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session, |
138 | unsigned int type); | |
139 | ||
743eb868 | 140 | void perf_event__print_ip(union perf_event *event, struct perf_sample *sample, |
a9c34a9f JO |
141 | struct machine *machine, int print_sym, |
142 | int print_dso, int print_symoffset); | |
c0230b2b | 143 | |
5d67be97 AB |
144 | int perf_session__cpu_bitmap(struct perf_session *session, |
145 | const char *cpu_list, unsigned long *cpu_bitmap); | |
146 | ||
fbe96f29 | 147 | void perf_session__fprintf_info(struct perf_session *s, FILE *fp, bool full); |
da378962 ACM |
148 | |
149 | struct perf_evsel_str_handler; | |
150 | ||
151 | int __perf_session__set_tracepoints_handlers(struct perf_session *session, | |
152 | const struct perf_evsel_str_handler *assocs, | |
153 | size_t nr_assocs); | |
154 | ||
155 | #define perf_session__set_tracepoints_handlers(session, array) \ | |
156 | __perf_session__set_tracepoints_handlers(session, array, ARRAY_SIZE(array)) | |
94c744b6 | 157 | #endif /* __PERF_SESSION_H */ |