]>
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; | |
c61e52ee FW |
20 | struct list_head samples_head; |
21 | struct sample_queue *last_inserted; | |
22 | }; | |
23 | ||
94c744b6 ACM |
24 | struct perf_session { |
25 | struct perf_header header; | |
26 | unsigned long size; | |
ec913369 | 27 | unsigned long mmap_window; |
b3165f41 ACM |
28 | struct rb_root threads; |
29 | struct thread *last_match; | |
1f626bc3 | 30 | struct machine host_machine; |
23346f21 | 31 | struct rb_root machines; |
1c02c4d2 | 32 | struct rb_root hists_tree; |
1c02c4d2 ACM |
33 | /* |
34 | * FIXME: should point to the first entry in hists_tree and | |
35 | * be a hists instance. Right now its only 'report' | |
36 | * that is using ->hists_tree while all the rest use | |
37 | * ->hists. | |
38 | */ | |
39 | struct hists hists; | |
c019879b | 40 | u64 sample_type; |
94c744b6 | 41 | int fd; |
8dc58101 | 42 | bool fd_pipe; |
454c407e | 43 | bool repipe; |
ec913369 ACM |
44 | int cwdlen; |
45 | char *cwd; | |
c61e52ee | 46 | struct ordered_samples ordered_samples; |
94c744b6 ACM |
47 | char filename[0]; |
48 | }; | |
49 | ||
d6b17beb FW |
50 | struct perf_event_ops; |
51 | ||
301a0b02 | 52 | typedef int (*event_op)(event_t *self, struct perf_session *session); |
d6b17beb FW |
53 | typedef int (*event_op2)(event_t *self, struct perf_session *session, |
54 | struct perf_event_ops *ops); | |
301a0b02 ACM |
55 | |
56 | struct perf_event_ops { | |
d6b17beb FW |
57 | event_op sample, |
58 | mmap, | |
59 | comm, | |
60 | fork, | |
61 | exit, | |
62 | lost, | |
63 | read, | |
64 | throttle, | |
65 | unthrottle, | |
66 | attr, | |
67 | event_type, | |
68 | tracing_data, | |
69 | build_id; | |
70 | event_op2 finished_round; | |
71 | bool ordered_samples; | |
301a0b02 ACM |
72 | }; |
73 | ||
454c407e | 74 | struct perf_session *perf_session__new(const char *filename, int mode, bool force, bool repipe); |
94c744b6 ACM |
75 | void perf_session__delete(struct perf_session *self); |
76 | ||
ba21594c ACM |
77 | void perf_event_header__bswap(struct perf_event_header *self); |
78 | ||
6122e4e4 ACM |
79 | int __perf_session__process_events(struct perf_session *self, |
80 | u64 data_offset, u64 data_size, u64 size, | |
81 | struct perf_event_ops *ops); | |
301a0b02 | 82 | int perf_session__process_events(struct perf_session *self, |
ec913369 | 83 | struct perf_event_ops *event_ops); |
301a0b02 | 84 | |
b3c9ac08 ACM |
85 | struct map_symbol *perf_session__resolve_callchain(struct perf_session *self, |
86 | struct thread *thread, | |
87 | struct ip_callchain *chain, | |
88 | struct symbol **parent); | |
a328626b | 89 | |
d549c769 | 90 | bool perf_session__has_traces(struct perf_session *self, const char *msg); |
27295592 | 91 | |
a1645ce1 | 92 | int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps, |
56b03f3c ACM |
93 | const char *symbol_name, |
94 | u64 addr); | |
56b03f3c | 95 | |
ba21594c ACM |
96 | void mem_bswap_64(void *src, int byte_size); |
97 | ||
a1645ce1 | 98 | int perf_session__create_kernel_maps(struct perf_session *self); |
f9224c5c | 99 | |
8dc58101 TZ |
100 | int do_read(int fd, void *buf, size_t size); |
101 | void perf_session__update_sample_type(struct perf_session *self); | |
102 | ||
23346f21 ACM |
103 | static inline |
104 | struct machine *perf_session__find_host_machine(struct perf_session *self) | |
105 | { | |
1f626bc3 | 106 | return &self->host_machine; |
23346f21 ACM |
107 | } |
108 | ||
109 | static inline | |
110 | struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid) | |
111 | { | |
1f626bc3 ACM |
112 | if (pid == HOST_KERNEL_ID) |
113 | return &self->host_machine; | |
23346f21 ACM |
114 | return machines__find(&self->machines, pid); |
115 | } | |
116 | ||
117 | static inline | |
118 | struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid) | |
119 | { | |
1f626bc3 ACM |
120 | if (pid == HOST_KERNEL_ID) |
121 | return &self->host_machine; | |
23346f21 ACM |
122 | return machines__findnew(&self->machines, pid); |
123 | } | |
124 | ||
125 | static inline | |
126 | void perf_session__process_machines(struct perf_session *self, | |
127 | machine__process_t process) | |
128 | { | |
1f626bc3 | 129 | process(&self->host_machine, self); |
23346f21 ACM |
130 | return machines__process(&self->machines, process, self); |
131 | } | |
cbf69680 | 132 | |
1f626bc3 | 133 | size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp); |
cbf69680 ACM |
134 | |
135 | static inline | |
136 | size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp, | |
137 | bool with_hits) | |
138 | { | |
139 | return machines__fprintf_dsos_buildid(&self->machines, fp, with_hits); | |
140 | } | |
c8446b9b ACM |
141 | |
142 | static inline | |
143 | size_t perf_session__fprintf_nr_events(struct perf_session *self, FILE *fp) | |
144 | { | |
145 | return hists__fprintf_nr_events(&self->hists, fp); | |
146 | } | |
94c744b6 | 147 | #endif /* __PERF_SESSION_H */ |