diff options
author | Steven Rostedt <rostedt@goodmis.org> | 2009-08-17 10:18:05 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-17 10:32:38 -0400 |
commit | 520509436417901f30106e021e037c75dfe5386c (patch) | |
tree | 7433a9dac06d557801bf85260f53b68431295aac /tools/perf/util/trace-event.h | |
parent | 8f28827a162fd1e8da4e96bed69b06d2606e8322 (diff) |
perf tools: Add trace event debugfs IO handler
Add util/trace-event-info.c which handles ftrace file IO from
debugfs and provides general helpers to fetch/save ftrace
events informations.
This file is a rename of the trace-cmd.c file from the
trace-cmd tools, written by Steven Rostedt and Josh Triplett,
originated from the git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
This is a perf tools integration.
For now, ftrace events information is saved in a separate file
than the standard perf.data
[fweisbec@gmail.com: various changes for perf tools integration]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: "Luis Claudio R. Goncalves" <lclaudio@uudg.org>
Cc: Clark Williams <williams@redhat.com>
Cc: Jon Masters <jonathan@jonmasters.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Cc: Zhaolei <zhaolei@cn.fujitsu.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: "Frank Ch. Eigler" <fche@redhat.com>
Cc: Roland McGrath <roland@redhat.com>
Cc: Jason Baron <jbaron@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Jiaying Zhang <jiayingz@google.com>
Cc: Anton Blanchard <anton@samba.org>
LKML-Reference: <1250518688-7207-1-git-send-email-fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/trace-event.h')
-rw-r--r-- | tools/perf/util/trace-event.h | 238 |
1 files changed, 238 insertions, 0 deletions
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h new file mode 100644 index 000000000000..3ddb8947be8a --- /dev/null +++ b/tools/perf/util/trace-event.h | |||
@@ -0,0 +1,238 @@ | |||
1 | #ifndef _PARSE_EVENTS_H | ||
2 | #define _PARSE_EVENTS_H | ||
3 | |||
4 | |||
5 | #define __unused __attribute__((unused)) | ||
6 | |||
7 | |||
8 | #ifndef PAGE_MASK | ||
9 | #define PAGE_MASK (page_size - 1) | ||
10 | #endif | ||
11 | |||
12 | enum { | ||
13 | RINGBUF_TYPE_PADDING = 29, | ||
14 | RINGBUF_TYPE_TIME_EXTEND = 30, | ||
15 | RINGBUF_TYPE_TIME_STAMP = 31, | ||
16 | }; | ||
17 | |||
18 | #ifndef TS_SHIFT | ||
19 | #define TS_SHIFT 27 | ||
20 | #endif | ||
21 | |||
22 | #define NSECS_PER_SEC 1000000000ULL | ||
23 | #define NSECS_PER_USEC 1000ULL | ||
24 | |||
25 | enum format_flags { | ||
26 | FIELD_IS_ARRAY = 1, | ||
27 | FIELD_IS_POINTER = 2, | ||
28 | }; | ||
29 | |||
30 | struct format_field { | ||
31 | struct format_field *next; | ||
32 | char *type; | ||
33 | char *name; | ||
34 | int offset; | ||
35 | int size; | ||
36 | unsigned long flags; | ||
37 | }; | ||
38 | |||
39 | struct format { | ||
40 | int nr_common; | ||
41 | int nr_fields; | ||
42 | struct format_field *common_fields; | ||
43 | struct format_field *fields; | ||
44 | }; | ||
45 | |||
46 | struct print_arg_atom { | ||
47 | char *atom; | ||
48 | }; | ||
49 | |||
50 | struct print_arg_string { | ||
51 | char *string; | ||
52 | }; | ||
53 | |||
54 | struct print_arg_field { | ||
55 | char *name; | ||
56 | struct format_field *field; | ||
57 | }; | ||
58 | |||
59 | struct print_flag_sym { | ||
60 | struct print_flag_sym *next; | ||
61 | char *value; | ||
62 | char *str; | ||
63 | }; | ||
64 | |||
65 | struct print_arg_typecast { | ||
66 | char *type; | ||
67 | struct print_arg *item; | ||
68 | }; | ||
69 | |||
70 | struct print_arg_flags { | ||
71 | struct print_arg *field; | ||
72 | char *delim; | ||
73 | struct print_flag_sym *flags; | ||
74 | }; | ||
75 | |||
76 | struct print_arg_symbol { | ||
77 | struct print_arg *field; | ||
78 | struct print_flag_sym *symbols; | ||
79 | }; | ||
80 | |||
81 | struct print_arg; | ||
82 | |||
83 | struct print_arg_op { | ||
84 | char *op; | ||
85 | int prio; | ||
86 | struct print_arg *left; | ||
87 | struct print_arg *right; | ||
88 | }; | ||
89 | |||
90 | struct print_arg_func { | ||
91 | char *name; | ||
92 | struct print_arg *args; | ||
93 | }; | ||
94 | |||
95 | enum print_arg_type { | ||
96 | PRINT_NULL, | ||
97 | PRINT_ATOM, | ||
98 | PRINT_FIELD, | ||
99 | PRINT_FLAGS, | ||
100 | PRINT_SYMBOL, | ||
101 | PRINT_TYPE, | ||
102 | PRINT_STRING, | ||
103 | PRINT_OP, | ||
104 | }; | ||
105 | |||
106 | struct print_arg { | ||
107 | struct print_arg *next; | ||
108 | enum print_arg_type type; | ||
109 | union { | ||
110 | struct print_arg_atom atom; | ||
111 | struct print_arg_field field; | ||
112 | struct print_arg_typecast typecast; | ||
113 | struct print_arg_flags flags; | ||
114 | struct print_arg_symbol symbol; | ||
115 | struct print_arg_func func; | ||
116 | struct print_arg_string string; | ||
117 | struct print_arg_op op; | ||
118 | }; | ||
119 | }; | ||
120 | |||
121 | struct print_fmt { | ||
122 | char *format; | ||
123 | struct print_arg *args; | ||
124 | }; | ||
125 | |||
126 | struct event { | ||
127 | struct event *next; | ||
128 | char *name; | ||
129 | int id; | ||
130 | int flags; | ||
131 | struct format format; | ||
132 | struct print_fmt print_fmt; | ||
133 | }; | ||
134 | |||
135 | enum { | ||
136 | EVENT_FL_ISFTRACE = 1, | ||
137 | EVENT_FL_ISPRINT = 2, | ||
138 | EVENT_FL_ISBPRINT = 4, | ||
139 | EVENT_FL_ISFUNC = 8, | ||
140 | EVENT_FL_ISFUNCENT = 16, | ||
141 | EVENT_FL_ISFUNCRET = 32, | ||
142 | }; | ||
143 | |||
144 | struct record { | ||
145 | unsigned long long ts; | ||
146 | int size; | ||
147 | void *data; | ||
148 | }; | ||
149 | |||
150 | struct record *trace_peek_data(int cpu); | ||
151 | struct record *trace_read_data(int cpu); | ||
152 | |||
153 | void parse_set_info(int nr_cpus, int long_sz); | ||
154 | |||
155 | void trace_report(void); | ||
156 | |||
157 | void *malloc_or_die(unsigned int size); | ||
158 | |||
159 | void parse_cmdlines(char *file, int size); | ||
160 | void parse_proc_kallsyms(char *file, unsigned int size); | ||
161 | void parse_ftrace_printk(char *file, unsigned int size); | ||
162 | |||
163 | void print_funcs(void); | ||
164 | void print_printk(void); | ||
165 | |||
166 | int parse_ftrace_file(char *buf, unsigned long size); | ||
167 | int parse_event_file(char *buf, unsigned long size, char *system); | ||
168 | void print_event(int cpu, void *data, int size, unsigned long long nsecs, | ||
169 | char *comm); | ||
170 | |||
171 | extern int file_bigendian; | ||
172 | extern int host_bigendian; | ||
173 | |||
174 | int bigendian(void); | ||
175 | |||
176 | static inline unsigned short __data2host2(unsigned short data) | ||
177 | { | ||
178 | unsigned short swap; | ||
179 | |||
180 | if (host_bigendian == file_bigendian) | ||
181 | return data; | ||
182 | |||
183 | swap = ((data & 0xffULL) << 8) | | ||
184 | ((data & (0xffULL << 8)) >> 8); | ||
185 | |||
186 | return swap; | ||
187 | } | ||
188 | |||
189 | static inline unsigned int __data2host4(unsigned int data) | ||
190 | { | ||
191 | unsigned int swap; | ||
192 | |||
193 | if (host_bigendian == file_bigendian) | ||
194 | return data; | ||
195 | |||
196 | swap = ((data & 0xffULL) << 24) | | ||
197 | ((data & (0xffULL << 8)) << 8) | | ||
198 | ((data & (0xffULL << 16)) >> 8) | | ||
199 | ((data & (0xffULL << 24)) >> 24); | ||
200 | |||
201 | return swap; | ||
202 | } | ||
203 | |||
204 | static inline unsigned long long __data2host8(unsigned long long data) | ||
205 | { | ||
206 | unsigned long long swap; | ||
207 | |||
208 | if (host_bigendian == file_bigendian) | ||
209 | return data; | ||
210 | |||
211 | swap = ((data & 0xffULL) << 56) | | ||
212 | ((data & (0xffULL << 8)) << 40) | | ||
213 | ((data & (0xffULL << 16)) << 24) | | ||
214 | ((data & (0xffULL << 24)) << 8) | | ||
215 | ((data & (0xffULL << 32)) >> 8) | | ||
216 | ((data & (0xffULL << 40)) >> 24) | | ||
217 | ((data & (0xffULL << 48)) >> 40) | | ||
218 | ((data & (0xffULL << 56)) >> 56); | ||
219 | |||
220 | return swap; | ||
221 | } | ||
222 | |||
223 | #define data2host2(ptr) __data2host2(*(unsigned short *)ptr) | ||
224 | #define data2host4(ptr) __data2host4(*(unsigned int *)ptr) | ||
225 | #define data2host8(ptr) __data2host8(*(unsigned long long *)ptr) | ||
226 | |||
227 | extern int header_page_ts_offset; | ||
228 | extern int header_page_ts_size; | ||
229 | extern int header_page_size_offset; | ||
230 | extern int header_page_size_size; | ||
231 | extern int header_page_data_offset; | ||
232 | extern int header_page_data_size; | ||
233 | |||
234 | int parse_header_page(char *buf, unsigned long size); | ||
235 | |||
236 | void read_tracing_data(void); | ||
237 | |||
238 | #endif /* _PARSE_EVENTS_H */ | ||