KVM: Implement perf callbacks for guest sampling
[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
a328626b 11struct ip_callchain;
b3165f41 12struct thread;
94c744b6
ACM
13
14struct perf_session {
15 struct perf_header header;
16 unsigned long size;
ec913369 17 unsigned long mmap_window;
4aa65636 18 struct map_groups kmaps;
b3165f41
ACM
19 struct rb_root threads;
20 struct thread *last_match;
de176489 21 struct map *vmlinux_maps[MAP__NR_TYPES];
f823e441 22 struct events_stats events_stats;
cb8f0939 23 struct rb_root stats_by_id;
f823e441 24 unsigned long event_total[PERF_RECORD_MAX];
31d337c4 25 unsigned long unknown_events;
4e4f06e4 26 struct rb_root hists;
c019879b 27 u64 sample_type;
9de89fe7 28 struct ref_reloc_sym ref_reloc_sym;
94c744b6 29 int fd;
8dc58101 30 bool fd_pipe;
ec913369
ACM
31 int cwdlen;
32 char *cwd;
94c744b6
ACM
33 char filename[0];
34};
35
301a0b02
ACM
36typedef int (*event_op)(event_t *self, struct perf_session *session);
37
38struct perf_event_ops {
55aa640f
ACM
39 event_op sample,
40 mmap,
41 comm,
42 fork,
43 exit,
44 lost,
45 read,
46 throttle,
2c46dbb5 47 unthrottle,
cd19a035 48 attr,
9215545e 49 event_type,
c7929e47
TZ
50 tracing_data,
51 build_id;
301a0b02
ACM
52};
53
75be6cf4 54struct perf_session *perf_session__new(const char *filename, int mode, bool force);
94c744b6
ACM
55void perf_session__delete(struct perf_session *self);
56
ba21594c
ACM
57void perf_event_header__bswap(struct perf_event_header *self);
58
6122e4e4
ACM
59int __perf_session__process_events(struct perf_session *self,
60 u64 data_offset, u64 data_size, u64 size,
61 struct perf_event_ops *ops);
301a0b02 62int perf_session__process_events(struct perf_session *self,
ec913369 63 struct perf_event_ops *event_ops);
301a0b02 64
b3c9ac08
ACM
65struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
66 struct thread *thread,
67 struct ip_callchain *chain,
68 struct symbol **parent);
a328626b 69
d549c769 70bool perf_session__has_traces(struct perf_session *self, const char *msg);
27295592 71
ba21594c
ACM
72int perf_header__read_build_ids(struct perf_header *self, int input,
73 u64 offset, u64 file_size);
301a0b02 74
56b03f3c
ACM
75int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
76 const char *symbol_name,
77 u64 addr);
56b03f3c 78
ba21594c
ACM
79void mem_bswap_64(void *src, int byte_size);
80
9de89fe7
ACM
81static inline int __perf_session__create_kernel_maps(struct perf_session *self,
82 struct dso *kernel)
83{
84 return __map_groups__create_kernel_maps(&self->kmaps,
85 self->vmlinux_maps, kernel);
86}
87
e727ca73
ACM
88static inline int perf_session__create_kernel_maps(struct perf_session *self)
89{
90 return map_groups__create_kernel_maps(&self->kmaps, self->vmlinux_maps);
91}
92
9de89fe7
ACM
93static inline struct map *
94 perf_session__new_module_map(struct perf_session *self,
95 u64 start, const char *filename)
96{
97 return map_groups__new_module(&self->kmaps, start, filename);
98}
f9224c5c 99
8dc58101
TZ
100int do_read(int fd, void *buf, size_t size);
101void perf_session__update_sample_type(struct perf_session *self);
102
f9224c5c 103#ifdef NO_NEWT_SUPPORT
5f4d3f88
ACM
104static inline int perf_session__browse_hists(struct rb_root *hists __used,
105 u64 nr_hists __used,
f9224c5c 106 u64 session_total __used,
533c46c3
ACM
107 const char *helpline __used,
108 const char *input_name __used)
5f4d3f88
ACM
109{
110 return 0;
111}
f9224c5c 112#else
5f4d3f88 113int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
533c46c3
ACM
114 u64 session_total, const char *helpline,
115 const char *input_name);
f9224c5c 116#endif
94c744b6 117#endif /* __PERF_SESSION_H */