perf: Introduce a new "round of buffers read" pseudo event
[linux-2.6-block.git] / tools / perf / util / session.h
CommitLineData
94c744b6
ACM
1#ifndef __PERF_SESSION_H
2#define __PERF_SESSION_H
3
301a0b02 4#include "event.h"
94c744b6 5#include "header.h"
9de89fe7 6#include "symbol.h"
4aa65636 7#include "thread.h"
b3165f41 8#include <linux/rbtree.h>
f823e441 9#include "../../../include/linux/perf_event.h"
b3165f41 10
c61e52ee 11struct sample_queue;
a328626b 12struct ip_callchain;
b3165f41 13struct thread;
94c744b6 14
c61e52ee
FW
15struct ordered_samples {
16 u64 last_flush;
17 u64 flush_limit;
18 struct list_head samples_head;
19 struct sample_queue *last_inserted;
20};
21
94c744b6
ACM
22struct perf_session {
23 struct perf_header header;
24 unsigned long size;
ec913369 25 unsigned long mmap_window;
b3165f41
ACM
26 struct rb_root threads;
27 struct thread *last_match;
23346f21 28 struct rb_root machines;
f823e441 29 struct events_stats events_stats;
cb8f0939 30 struct rb_root stats_by_id;
f823e441 31 unsigned long event_total[PERF_RECORD_MAX];
31d337c4 32 unsigned long unknown_events;
4e4f06e4 33 struct rb_root hists;
c019879b 34 u64 sample_type;
94c744b6 35 int fd;
8dc58101 36 bool fd_pipe;
454c407e 37 bool repipe;
ec913369
ACM
38 int cwdlen;
39 char *cwd;
c61e52ee 40 struct ordered_samples ordered_samples;
94c744b6
ACM
41 char filename[0];
42};
43
301a0b02
ACM
44typedef int (*event_op)(event_t *self, struct perf_session *session);
45
46struct perf_event_ops {
55aa640f
ACM
47 event_op sample,
48 mmap,
49 comm,
50 fork,
51 exit,
52 lost,
53 read,
54 throttle,
2c46dbb5 55 unthrottle,
cd19a035 56 attr,
9215545e 57 event_type,
c7929e47
TZ
58 tracing_data,
59 build_id;
c61e52ee 60 bool ordered_samples;
301a0b02
ACM
61};
62
454c407e 63struct perf_session *perf_session__new(const char *filename, int mode, bool force, bool repipe);
94c744b6
ACM
64void perf_session__delete(struct perf_session *self);
65
ba21594c
ACM
66void perf_event_header__bswap(struct perf_event_header *self);
67
6122e4e4
ACM
68int __perf_session__process_events(struct perf_session *self,
69 u64 data_offset, u64 data_size, u64 size,
70 struct perf_event_ops *ops);
301a0b02 71int perf_session__process_events(struct perf_session *self,
ec913369 72 struct perf_event_ops *event_ops);
301a0b02 73
b3c9ac08
ACM
74struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
75 struct thread *thread,
76 struct ip_callchain *chain,
77 struct symbol **parent);
a328626b 78
d549c769 79bool perf_session__has_traces(struct perf_session *self, const char *msg);
27295592 80
a1645ce1 81int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps,
56b03f3c
ACM
82 const char *symbol_name,
83 u64 addr);
56b03f3c 84
ba21594c
ACM
85void mem_bswap_64(void *src, int byte_size);
86
a1645ce1 87int perf_session__create_kernel_maps(struct perf_session *self);
f9224c5c 88
8dc58101
TZ
89int do_read(int fd, void *buf, size_t size);
90void perf_session__update_sample_type(struct perf_session *self);
91
f9224c5c 92#ifdef NO_NEWT_SUPPORT
5f4d3f88
ACM
93static inline int perf_session__browse_hists(struct rb_root *hists __used,
94 u64 nr_hists __used,
f9224c5c 95 u64 session_total __used,
533c46c3
ACM
96 const char *helpline __used,
97 const char *input_name __used)
5f4d3f88
ACM
98{
99 return 0;
100}
f9224c5c 101#else
5f4d3f88 102int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
533c46c3
ACM
103 u64 session_total, const char *helpline,
104 const char *input_name);
f9224c5c 105#endif
23346f21
ACM
106
107static inline
108struct machine *perf_session__find_host_machine(struct perf_session *self)
109{
110 return machines__find_host(&self->machines);
111}
112
113static inline
114struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid)
115{
116 return machines__find(&self->machines, pid);
117}
118
119static inline
120struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid)
121{
122 return machines__findnew(&self->machines, pid);
123}
124
125static inline
126void perf_session__process_machines(struct perf_session *self,
127 machine__process_t process)
128{
129 return machines__process(&self->machines, process, self);
130}
cbf69680
ACM
131
132static inline
133size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp)
134{
135 return machines__fprintf_dsos(&self->machines, fp);
136}
137
138static inline
139size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp,
140 bool with_hits)
141{
142 return machines__fprintf_dsos_buildid(&self->machines, fp, with_hits);
143}
94c744b6 144#endif /* __PERF_SESSION_H */