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