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