aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/trace-event-parse.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2012-06-27 12:08:42 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-06-27 12:08:42 -0400
commitda3789628f88684d3f0fb4e6a6bc086c395ac3cb (patch)
treef1573d6b2c8fa4e46f47c5558135a0a56d4397ef /tools/perf/util/trace-event-parse.c
parent7a25b2d32b9cb0b813d56ee6109acf90f3c9f1e5 (diff)
perf tools: Stop using a global trace events description list
The pevent thing is per perf.data file, so I made it stop being static and become a perf_session member, so tools processing perf.data files use perf_session and _there_ we read the trace events description into session->pevent and then change everywhere to stop using that single global pevent variable and use the per session one. Note that it _doesn't_ fall backs to trace__event_id, as we're not interested at all in what is present in the /sys/kernel/debug/tracing/events in the workstation doing the analysis, just in what is in the perf.data file. This patch also introduces perf_session__set_tracepoints_handlers that is the perf perf.data/session way to associate handlers to tracepoint events by resolving their IDs using the events descriptions stored in a perf.data file. Make 'perf sched' use it. Reported-by: Dmitry Antipov <dmitry.antipov@linaro.org> Tested-by: Dmitry Antipov <dmitry.antipov@linaro.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: linaro-dev@lists.linaro.org Cc: patches@linaro.org Link: http://lkml.kernel.org/r/20120625232016.GA28525@infradead.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/trace-event-parse.c')
-rw-r--r--tools/perf/util/trace-event-parse.c58
1 files changed, 26 insertions, 32 deletions
diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index df2fddbf0cd2..a51bd86f4d09 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -32,29 +32,25 @@ int header_page_size_size;
32int header_page_ts_size; 32int header_page_ts_size;
33int header_page_data_offset; 33int header_page_data_offset;
34 34
35struct pevent *perf_pevent;
36static struct pevent *pevent;
37
38bool latency_format; 35bool latency_format;
39 36
40int read_trace_init(int file_bigendian, int host_bigendian) 37struct pevent *read_trace_init(int file_bigendian, int host_bigendian)
41{ 38{
42 if (pevent) 39 struct pevent *pevent = pevent_alloc();
43 return 0;
44
45 perf_pevent = pevent_alloc();
46 pevent = perf_pevent;
47 40
48 pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT); 41 if (pevent != NULL) {
49 pevent_set_file_bigendian(pevent, file_bigendian); 42 pevent_set_flag(pevent, PEVENT_NSEC_OUTPUT);
50 pevent_set_host_bigendian(pevent, host_bigendian); 43 pevent_set_file_bigendian(pevent, file_bigendian);
44 pevent_set_host_bigendian(pevent, host_bigendian);
45 }
51 46
52 return 0; 47 return pevent;
53} 48}
54 49
55static int get_common_field(struct scripting_context *context, 50static int get_common_field(struct scripting_context *context,
56 int *offset, int *size, const char *type) 51 int *offset, int *size, const char *type)
57{ 52{
53 struct pevent *pevent = context->pevent;
58 struct event_format *event; 54 struct event_format *event;
59 struct format_field *field; 55 struct format_field *field;
60 56
@@ -150,7 +146,7 @@ void *raw_field_ptr(struct event_format *event, const char *name, void *data)
150 return data + field->offset; 146 return data + field->offset;
151} 147}
152 148
153int trace_parse_common_type(void *data) 149int trace_parse_common_type(struct pevent *pevent, void *data)
154{ 150{
155 struct pevent_record record; 151 struct pevent_record record;
156 152
@@ -158,7 +154,7 @@ int trace_parse_common_type(void *data)
158 return pevent_data_type(pevent, &record); 154 return pevent_data_type(pevent, &record);
159} 155}
160 156
161int trace_parse_common_pid(void *data) 157int trace_parse_common_pid(struct pevent *pevent, void *data)
162{ 158{
163 struct pevent_record record; 159 struct pevent_record record;
164 160
@@ -166,27 +162,21 @@ int trace_parse_common_pid(void *data)
166 return pevent_data_pid(pevent, &record); 162 return pevent_data_pid(pevent, &record);
167} 163}
168 164
169unsigned long long read_size(void *ptr, int size) 165unsigned long long read_size(struct pevent *pevent, void *ptr, int size)
170{ 166{
171 return pevent_read_number(pevent, ptr, size); 167 return pevent_read_number(pevent, ptr, size);
172} 168}
173 169
174struct event_format *trace_find_event(int type) 170void print_trace_event(struct pevent *pevent, int cpu, void *data, int size)
175{
176 return pevent_find_event(pevent, type);
177}
178
179
180void print_trace_event(int cpu, void *data, int size)
181{ 171{
182 struct event_format *event; 172 struct event_format *event;
183 struct pevent_record record; 173 struct pevent_record record;
184 struct trace_seq s; 174 struct trace_seq s;
185 int type; 175 int type;
186 176
187 type = trace_parse_common_type(data); 177 type = trace_parse_common_type(pevent, data);
188 178
189 event = trace_find_event(type); 179 event = pevent_find_event(pevent, type);
190 if (!event) { 180 if (!event) {
191 warning("ug! no event found for type %d", type); 181 warning("ug! no event found for type %d", type);
192 return; 182 return;
@@ -203,8 +193,8 @@ void print_trace_event(int cpu, void *data, int size)
203 printf("\n"); 193 printf("\n");
204} 194}
205 195
206void print_event(int cpu, void *data, int size, unsigned long long nsecs, 196void print_event(struct pevent *pevent, int cpu, void *data, int size,
207 char *comm) 197 unsigned long long nsecs, char *comm)
208{ 198{
209 struct pevent_record record; 199 struct pevent_record record;
210 struct trace_seq s; 200 struct trace_seq s;
@@ -227,7 +217,8 @@ void print_event(int cpu, void *data, int size, unsigned long long nsecs,
227 printf("\n"); 217 printf("\n");
228} 218}
229 219
230void parse_proc_kallsyms(char *file, unsigned int size __unused) 220void parse_proc_kallsyms(struct pevent *pevent,
221 char *file, unsigned int size __unused)
231{ 222{
232 unsigned long long addr; 223 unsigned long long addr;
233 char *func; 224 char *func;
@@ -258,7 +249,8 @@ void parse_proc_kallsyms(char *file, unsigned int size __unused)
258 } 249 }
259} 250}
260 251
261void parse_ftrace_printk(char *file, unsigned int size __unused) 252void parse_ftrace_printk(struct pevent *pevent,
253 char *file, unsigned int size __unused)
262{ 254{
263 unsigned long long addr; 255 unsigned long long addr;
264 char *printk; 256 char *printk;
@@ -282,17 +274,19 @@ void parse_ftrace_printk(char *file, unsigned int size __unused)
282 } 274 }
283} 275}
284 276
285int parse_ftrace_file(char *buf, unsigned long size) 277int parse_ftrace_file(struct pevent *pevent, char *buf, unsigned long size)
286{ 278{
287 return pevent_parse_event(pevent, buf, size, "ftrace"); 279 return pevent_parse_event(pevent, buf, size, "ftrace");
288} 280}
289 281
290int parse_event_file(char *buf, unsigned long size, char *sys) 282int parse_event_file(struct pevent *pevent,
283 char *buf, unsigned long size, char *sys)
291{ 284{
292 return pevent_parse_event(pevent, buf, size, sys); 285 return pevent_parse_event(pevent, buf, size, sys);
293} 286}
294 287
295struct event_format *trace_find_next_event(struct event_format *event) 288struct event_format *trace_find_next_event(struct pevent *pevent,
289 struct event_format *event)
296{ 290{
297 static int idx; 291 static int idx;
298 292