perf test: Fix parse events test to follow proper raw event name
[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;
1c02c4d2 36 /*
e248de33
ACM
37 * FIXME: Need to split this up further, we need global
38 * stats + per event stats. 'perf diff' also needs
39 * to properly support multiple events in a single
40 * perf.data file.
1c02c4d2
ACM
41 */
42 struct hists hists;
c019879b 43 u64 sample_type;
a2854124 44 int sample_size;
94c744b6 45 int fd;
8dc58101 46 bool fd_pipe;
454c407e 47 bool repipe;
9c90a61c
ACM
48 bool sample_id_all;
49 u16 id_hdr_size;
ec913369
ACM
50 int cwdlen;
51 char *cwd;
c61e52ee 52 struct ordered_samples ordered_samples;
002c4fd9 53 char filename[1];
94c744b6
ACM
54};
55
45694aa7 56struct perf_tool;
301a0b02 57
21ef97f0
IM
58struct perf_session *perf_session__new(const char *filename, int mode,
59 bool force, bool repipe,
45694aa7 60 struct perf_tool *tool);
94c744b6
ACM
61void perf_session__delete(struct perf_session *self);
62
ba21594c
ACM
63void perf_event_header__bswap(struct perf_event_header *self);
64
6122e4e4
ACM
65int __perf_session__process_events(struct perf_session *self,
66 u64 data_offset, u64 data_size, u64 size,
45694aa7 67 struct perf_tool *tool);
301a0b02 68int perf_session__process_events(struct perf_session *self,
45694aa7 69 struct perf_tool *tool);
301a0b02 70
246d4ce8 71int perf_session__resolve_callchain(struct perf_session *self, struct perf_evsel *evsel,
1b3a0e95
FW
72 struct thread *thread,
73 struct ip_callchain *chain,
74 struct symbol **parent);
a328626b 75
b5387528
RAV
76struct branch_info *machine__resolve_bstack(struct machine *self,
77 struct thread *thread,
78 struct branch_stack *bs);
79
d549c769 80bool perf_session__has_traces(struct perf_session *self, const char *msg);
27295592 81
ba21594c 82void mem_bswap_64(void *src, int byte_size);
80c0120a 83void mem_bswap_32(void *src, int byte_size);
eda3913b 84void perf_event__attr_swap(struct perf_event_attr *attr);
ba21594c 85
a1645ce1 86int perf_session__create_kernel_maps(struct perf_session *self);
f9224c5c 87
8dc58101 88void perf_session__update_sample_type(struct perf_session *self);
720a3aeb 89void perf_session__remove_thread(struct perf_session *self, struct thread *th);
8dc58101 90
23346f21
ACM
91static inline
92struct machine *perf_session__find_host_machine(struct perf_session *self)
93{
1f626bc3 94 return &self->host_machine;
23346f21
ACM
95}
96
97static inline
98struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid)
99{
1f626bc3
ACM
100 if (pid == HOST_KERNEL_ID)
101 return &self->host_machine;
23346f21
ACM
102 return machines__find(&self->machines, pid);
103}
104
105static inline
106struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid)
107{
1f626bc3
ACM
108 if (pid == HOST_KERNEL_ID)
109 return &self->host_machine;
23346f21
ACM
110 return machines__findnew(&self->machines, pid);
111}
112
113static inline
114void perf_session__process_machines(struct perf_session *self,
45694aa7 115 struct perf_tool *tool,
23346f21
ACM
116 machine__process_t process)
117{
45694aa7
ACM
118 process(&self->host_machine, tool);
119 return machines__process(&self->machines, process, tool);
23346f21 120}
cbf69680 121
743eb868
ACM
122struct thread *perf_session__findnew(struct perf_session *self, pid_t pid);
123size_t perf_session__fprintf(struct perf_session *self, FILE *fp);
124
1f626bc3 125size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp);
cbf69680 126
f869097e
ACM
127size_t perf_session__fprintf_dsos_buildid(struct perf_session *self,
128 FILE *fp, bool with_hits);
c8446b9b 129
e248de33 130size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp);
d0dd74e8
ACM
131
132static inline int perf_session__parse_sample(struct perf_session *session,
8115d60c 133 const union perf_event *event,
8d50e5b4 134 struct perf_sample *sample)
d0dd74e8 135{
8115d60c 136 return perf_event__parse_sample(event, session->sample_type,
a2854124 137 session->sample_size,
936be503
DA
138 session->sample_id_all, sample,
139 session->header.needs_swap);
d0dd74e8
ACM
140}
141
74eec26f
AV
142static inline int perf_session__synthesize_sample(struct perf_session *session,
143 union perf_event *event,
144 const struct perf_sample *sample)
145{
146 return perf_event__synthesize_sample(event, session->sample_type,
147 sample, session->header.needs_swap);
148}
149
9cbdb702
DA
150struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
151 unsigned int type);
152
743eb868 153void perf_event__print_ip(union perf_event *event, struct perf_sample *sample,
a9c34a9f
JO
154 struct machine *machine, int print_sym,
155 int print_dso, int print_symoffset);
c0230b2b 156
5d67be97
AB
157int perf_session__cpu_bitmap(struct perf_session *session,
158 const char *cpu_list, unsigned long *cpu_bitmap);
159
fbe96f29 160void perf_session__fprintf_info(struct perf_session *s, FILE *fp, bool full);
94c744b6 161#endif /* __PERF_SESSION_H */
This page took 0.123995 seconds and 5 git commands to generate.