aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/session.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/session.h')
-rw-r--r--tools/perf/util/session.h126
1 files changed, 92 insertions, 34 deletions
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 5c33417eebb3..e7fce486ebe2 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -1,6 +1,7 @@
1#ifndef __PERF_SESSION_H 1#ifndef __PERF_SESSION_H
2#define __PERF_SESSION_H 2#define __PERF_SESSION_H
3 3
4#include "hist.h"
4#include "event.h" 5#include "event.h"
5#include "header.h" 6#include "header.h"
6#include "symbol.h" 7#include "symbol.h"
@@ -8,45 +9,69 @@
8#include <linux/rbtree.h> 9#include <linux/rbtree.h>
9#include "../../../include/linux/perf_event.h" 10#include "../../../include/linux/perf_event.h"
10 11
12struct sample_queue;
11struct ip_callchain; 13struct ip_callchain;
12struct thread; 14struct thread;
13 15
16struct ordered_samples {
17 u64 last_flush;
18 u64 next_flush;
19 u64 max_timestamp;
20 struct list_head samples_head;
21 struct sample_queue *last_inserted;
22};
23
14struct perf_session { 24struct perf_session {
15 struct perf_header header; 25 struct perf_header header;
16 unsigned long size; 26 unsigned long size;
17 unsigned long mmap_window; 27 unsigned long mmap_window;
18 struct map_groups kmaps;
19 struct rb_root threads; 28 struct rb_root threads;
20 struct thread *last_match; 29 struct thread *last_match;
21 struct map *vmlinux_maps[MAP__NR_TYPES]; 30 struct machine host_machine;
22 struct events_stats events_stats; 31 struct rb_root machines;
23 struct rb_root stats_by_id; 32 struct rb_root hists_tree;
24 unsigned long event_total[PERF_RECORD_MAX]; 33 /*
25 unsigned long unknown_events; 34 * FIXME: should point to the first entry in hists_tree and
26 struct rb_root hists; 35 * be a hists instance. Right now its only 'report'
36 * that is using ->hists_tree while all the rest use
37 * ->hists.
38 */
39 struct hists hists;
27 u64 sample_type; 40 u64 sample_type;
28 struct ref_reloc_sym ref_reloc_sym;
29 int fd; 41 int fd;
42 bool fd_pipe;
43 bool repipe;
30 int cwdlen; 44 int cwdlen;
31 char *cwd; 45 char *cwd;
46 struct ordered_samples ordered_samples;
32 char filename[0]; 47 char filename[0];
33}; 48};
34 49
50struct perf_event_ops;
51
35typedef int (*event_op)(event_t *self, struct perf_session *session); 52typedef int (*event_op)(event_t *self, struct perf_session *session);
53typedef int (*event_op2)(event_t *self, struct perf_session *session,
54 struct perf_event_ops *ops);
36 55
37struct perf_event_ops { 56struct perf_event_ops {
38 event_op sample, 57 event_op sample,
39 mmap, 58 mmap,
40 comm, 59 comm,
41 fork, 60 fork,
42 exit, 61 exit,
43 lost, 62 lost,
44 read, 63 read,
45 throttle, 64 throttle,
46 unthrottle; 65 unthrottle,
66 attr,
67 event_type,
68 tracing_data,
69 build_id;
70 event_op2 finished_round;
71 bool ordered_samples;
47}; 72};
48 73
49struct perf_session *perf_session__new(const char *filename, int mode, bool force); 74struct perf_session *perf_session__new(const char *filename, int mode, bool force, bool repipe);
50void perf_session__delete(struct perf_session *self); 75void perf_session__delete(struct perf_session *self);
51 76
52void perf_event_header__bswap(struct perf_event_header *self); 77void perf_event_header__bswap(struct perf_event_header *self);
@@ -57,33 +82,66 @@ int __perf_session__process_events(struct perf_session *self,
57int perf_session__process_events(struct perf_session *self, 82int perf_session__process_events(struct perf_session *self,
58 struct perf_event_ops *event_ops); 83 struct perf_event_ops *event_ops);
59 84
60struct symbol **perf_session__resolve_callchain(struct perf_session *self, 85struct map_symbol *perf_session__resolve_callchain(struct perf_session *self,
61 struct thread *thread, 86 struct thread *thread,
62 struct ip_callchain *chain, 87 struct ip_callchain *chain,
63 struct symbol **parent); 88 struct symbol **parent);
64 89
65bool perf_session__has_traces(struct perf_session *self, const char *msg); 90bool perf_session__has_traces(struct perf_session *self, const char *msg);
66 91
67int perf_header__read_build_ids(struct perf_header *self, int input, 92int perf_session__set_kallsyms_ref_reloc_sym(struct map **maps,
68 u64 offset, u64 file_size);
69
70int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
71 const char *symbol_name, 93 const char *symbol_name,
72 u64 addr); 94 u64 addr);
73 95
74void mem_bswap_64(void *src, int byte_size); 96void mem_bswap_64(void *src, int byte_size);
75 97
76static inline int __perf_session__create_kernel_maps(struct perf_session *self, 98int perf_session__create_kernel_maps(struct perf_session *self);
77 struct dso *kernel) 99
100int do_read(int fd, void *buf, size_t size);
101void perf_session__update_sample_type(struct perf_session *self);
102
103static inline
104struct machine *perf_session__find_host_machine(struct perf_session *self)
105{
106 return &self->host_machine;
107}
108
109static inline
110struct machine *perf_session__find_machine(struct perf_session *self, pid_t pid)
111{
112 if (pid == HOST_KERNEL_ID)
113 return &self->host_machine;
114 return machines__find(&self->machines, pid);
115}
116
117static inline
118struct machine *perf_session__findnew_machine(struct perf_session *self, pid_t pid)
119{
120 if (pid == HOST_KERNEL_ID)
121 return &self->host_machine;
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 process(&self->host_machine, self);
130 return machines__process(&self->machines, process, self);
131}
132
133size_t perf_session__fprintf_dsos(struct perf_session *self, FILE *fp);
134
135static inline
136size_t perf_session__fprintf_dsos_buildid(struct perf_session *self, FILE *fp,
137 bool with_hits)
78{ 138{
79 return __map_groups__create_kernel_maps(&self->kmaps, 139 return machines__fprintf_dsos_buildid(&self->machines, fp, with_hits);
80 self->vmlinux_maps, kernel);
81} 140}
82 141
83static inline struct map * 142static inline
84 perf_session__new_module_map(struct perf_session *self, 143size_t perf_session__fprintf_nr_events(struct perf_session *self, FILE *fp)
85 u64 start, const char *filename)
86{ 144{
87 return map_groups__new_module(&self->kmaps, start, filename); 145 return hists__fprintf_nr_events(&self->hists, fp);
88} 146}
89#endif /* __PERF_SESSION_H */ 147#endif /* __PERF_SESSION_H */