Merge tag 'md-3.6' of git://neil.brown.name/md
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / tools / perf / util / session.h
CommitLineData
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 12struct sample_queue;
a328626b 13struct ip_callchain;
b3165f41 14struct thread;
94c744b6 15
c61e52ee
FW
16struct 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
29struct 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;
c019879b 44 u64 sample_type;
a2854124 45 int sample_size;
94c744b6 46 int fd;
8dc58101 47 bool fd_pipe;
454c407e 48 bool repipe;
9c90a61c
ACM
49 bool sample_id_all;
50 u16 id_hdr_size;
ec913369
ACM
51 int cwdlen;
52 char *cwd;
c61e52ee 53 struct ordered_samples ordered_samples;
002c4fd9 54 char filename[1];
94c744b6
ACM
55};
56
45694aa7 57struct perf_tool;
301a0b02 58
21ef97f0
IM
59struct perf_session *perf_session__new(const char *filename, int mode,
60 bool force, bool repipe,
45694aa7 61 struct perf_tool *tool);
94c744b6
ACM
62void perf_session__delete(struct perf_session *self);
63
ba21594c
ACM
64void perf_event_header__bswap(struct perf_event_header *self);
65
6122e4e4
ACM
66int __perf_session__process_events(struct perf_session *self,
67 u64 data_offset, u64 data_size, u64 size,
45694aa7 68 struct perf_tool *tool);
301a0b02 69int perf_session__process_events(struct perf_session *self,
45694aa7 70 struct perf_tool *tool);
301a0b02 71
246d4ce8 72int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel,
1b3a0e95
FW
73 struct thread *thread,
74 struct ip_callchain *chain,
75 struct symbol **parent);
a328626b 76
b5387528
RAV
77struct branch_info *machine__resolve_bstack(struct machine *self,
78 struct thread *thread,
79 struct branch_stack *bs);
80
d549c769 81bool perf_session__has_traces(struct perf_session *self, const char *msg);
27295592 82
ba21594c 83void mem_bswap_64(void *src, int byte_size);
80c0120a 84void mem_bswap_32(void *src, int byte_size);
eda3913b 85void perf_event__attr_swap(struct perf_event_attr *attr);
ba21594c 86
a1645ce1 87int perf_session__create_kernel_maps(struct perf_session *self);
f9224c5c 88
8dc58101 89void perf_session__update_sample_type(struct perf_session *self);
720a3aeb 90void perf_session__remove_thread(struct perf_session *self, struct thread *th);
8dc58101 91
23346f21
ACM
92static inline
93struct machine *perf_session__find_host_machine(struct perf_session *self)
94{
1f626bc3 95 return &self->host_machine;
23346f21
ACM
96}
97
98static inline
99struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid)
100{
1f626bc3
ACM
101 if (pid == HOST_KERNEL_ID)
102 return &self->host_machine;
23346f21
ACM
103 return machines__find(&self->machines, pid);
104}
105
106static inline
107struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid)
108{
1f626bc3
ACM
109 if (pid == HOST_KERNEL_ID)
110 return &self->host_machine;
23346f21
ACM
111 return machines__findnew(&self->machines, pid);
112}
113
114static inline
115void perf_session__process_machines(struct perf_session *self,
45694aa7 116 struct perf_tool *tool,
23346f21
ACM
117 machine__process_t process)
118{
45694aa7
ACM
119 process(&self->host_machine, tool);
120 return machines__process(&self->machines, process, tool);
23346f21 121}
cbf69680 122
743eb868
ACM
123struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
124size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
125
1f626bc3 126size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp);
cbf69680 127
f869097e
ACM
128size_t perf_session__fprintf_dsos_buildid(struct perf_session *self,
129 FILE *fp, bool with_hits);
c8446b9b 130
e248de33 131size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp);
d0dd74e8
ACM
132
133static inline int perf_session__parse_sample(struct perf_session *session,
8115d60c 134 const union perf_event *event,
8d50e5b4 135 struct perf_sample *sample)
d0dd74e8 136{
8115d60c 137 return perf_event__parse_sample(event, session->sample_type,
a2854124 138 session->sample_size,
936be503
DA
139 session->sample_id_all, sample,
140 session->header.needs_swap);
d0dd74e8
ACM
141}
142
74eec26f
AV
143static inline int perf_session__synthesize_sample(struct perf_session *session,
144 union perf_event *event,
145 const struct perf_sample *sample)
146{
147 return perf_event__synthesize_sample(event, session->sample_type,
148 sample, session->header.needs_swap);
149}
150
9cbdb702
DA
151struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
152 unsigned int type);
153
743eb868 154void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
a9c34a9f
JO
155 struct machine *machine, int print_sym,
156 int print_dso, int print_symoffset);
c0230b2b 157
5d67be97
AB
158int perf_session__cpu_bitmap(struct perf_session *session,
159 const char *cpu_list, unsigned long *cpu_bitmap);
160
fbe96f29 161void perf_session__fprintf_info(struct perf_session *s, FILE *fp, bool full);
da378962
ACM
162
163struct perf_evsel_str_handler;
164
165int __perf_session__set_tracepoints_handlers(struct perf_session *session,
166 const struct perf_evsel_str_handler *assocs,
167 size_t nr_assocs);
168
169#define perf_session__set_tracepoints_handlers(session, array) \
170 __perf_session__set_tracepoints_handlers(session, array, ARRAY_SIZE(array))
94c744b6 171#endif /* __PERF_SESSION_H */