diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-06-27 12:08:42 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-06-27 12:08:42 -0400 |
commit | da3789628f88684d3f0fb4e6a6bc086c395ac3cb (patch) | |
tree | f1573d6b2c8fa4e46f47c5558135a0a56d4397ef /tools/perf/util/scripting-engines/trace-event-perl.c | |
parent | 7a25b2d32b9cb0b813d56ee6109acf90f3c9f1e5 (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/scripting-engines/trace-event-perl.c')
-rw-r--r-- | tools/perf/util/scripting-engines/trace-event-perl.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c index 4c1b3d72a1d2..b3620fe12763 100644 --- a/tools/perf/util/scripting-engines/trace-event-perl.c +++ b/tools/perf/util/scripting-engines/trace-event-perl.c | |||
@@ -233,7 +233,8 @@ static void define_event_symbols(struct event_format *event, | |||
233 | define_event_symbols(event, ev_name, args->next); | 233 | define_event_symbols(event, ev_name, args->next); |
234 | } | 234 | } |
235 | 235 | ||
236 | static inline struct event_format *find_cache_event(int type) | 236 | static inline |
237 | struct event_format *find_cache_event(struct pevent *pevent, int type) | ||
237 | { | 238 | { |
238 | static char ev_name[256]; | 239 | static char ev_name[256]; |
239 | struct event_format *event; | 240 | struct event_format *event; |
@@ -241,7 +242,7 @@ static inline struct event_format *find_cache_event(int type) | |||
241 | if (events[type]) | 242 | if (events[type]) |
242 | return events[type]; | 243 | return events[type]; |
243 | 244 | ||
244 | events[type] = event = trace_find_event(type); | 245 | events[type] = event = pevent_find_event(pevent, type); |
245 | if (!event) | 246 | if (!event) |
246 | return NULL; | 247 | return NULL; |
247 | 248 | ||
@@ -252,7 +253,8 @@ static inline struct event_format *find_cache_event(int type) | |||
252 | return event; | 253 | return event; |
253 | } | 254 | } |
254 | 255 | ||
255 | static void perl_process_tracepoint(union perf_event *pevent __unused, | 256 | static void perl_process_tracepoint(union perf_event *perf_event __unused, |
257 | struct pevent *pevent, | ||
256 | struct perf_sample *sample, | 258 | struct perf_sample *sample, |
257 | struct perf_evsel *evsel, | 259 | struct perf_evsel *evsel, |
258 | struct machine *machine __unused, | 260 | struct machine *machine __unused, |
@@ -275,13 +277,13 @@ static void perl_process_tracepoint(union perf_event *pevent __unused, | |||
275 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) | 277 | if (evsel->attr.type != PERF_TYPE_TRACEPOINT) |
276 | return; | 278 | return; |
277 | 279 | ||
278 | type = trace_parse_common_type(data); | 280 | type = trace_parse_common_type(pevent, data); |
279 | 281 | ||
280 | event = find_cache_event(type); | 282 | event = find_cache_event(pevent, type); |
281 | if (!event) | 283 | if (!event) |
282 | die("ug! no event found for type %d", type); | 284 | die("ug! no event found for type %d", type); |
283 | 285 | ||
284 | pid = trace_parse_common_pid(data); | 286 | pid = trace_parse_common_pid(pevent, data); |
285 | 287 | ||
286 | sprintf(handler, "%s::%s", event->system, event->name); | 288 | sprintf(handler, "%s::%s", event->system, event->name); |
287 | 289 | ||
@@ -314,7 +316,8 @@ static void perl_process_tracepoint(union perf_event *pevent __unused, | |||
314 | offset = field->offset; | 316 | offset = field->offset; |
315 | XPUSHs(sv_2mortal(newSVpv((char *)data + offset, 0))); | 317 | XPUSHs(sv_2mortal(newSVpv((char *)data + offset, 0))); |
316 | } else { /* FIELD_IS_NUMERIC */ | 318 | } else { /* FIELD_IS_NUMERIC */ |
317 | val = read_size(data + field->offset, field->size); | 319 | val = read_size(pevent, data + field->offset, |
320 | field->size); | ||
318 | if (field->flags & FIELD_IS_SIGNED) { | 321 | if (field->flags & FIELD_IS_SIGNED) { |
319 | XPUSHs(sv_2mortal(newSViv(val))); | 322 | XPUSHs(sv_2mortal(newSViv(val))); |
320 | } else { | 323 | } else { |
@@ -368,14 +371,15 @@ static void perl_process_event_generic(union perf_event *pevent __unused, | |||
368 | LEAVE; | 371 | LEAVE; |
369 | } | 372 | } |
370 | 373 | ||
371 | static void perl_process_event(union perf_event *pevent, | 374 | static void perl_process_event(union perf_event *event, |
375 | struct pevent *pevent, | ||
372 | struct perf_sample *sample, | 376 | struct perf_sample *sample, |
373 | struct perf_evsel *evsel, | 377 | struct perf_evsel *evsel, |
374 | struct machine *machine, | 378 | struct machine *machine, |
375 | struct thread *thread) | 379 | struct thread *thread) |
376 | { | 380 | { |
377 | perl_process_tracepoint(pevent, sample, evsel, machine, thread); | 381 | perl_process_tracepoint(event, pevent, sample, evsel, machine, thread); |
378 | perl_process_event_generic(pevent, sample, evsel, machine, thread); | 382 | perl_process_event_generic(event, sample, evsel, machine, thread); |
379 | } | 383 | } |
380 | 384 | ||
381 | static void run_start_sub(void) | 385 | static void run_start_sub(void) |
@@ -448,7 +452,7 @@ static int perl_stop_script(void) | |||
448 | return 0; | 452 | return 0; |
449 | } | 453 | } |
450 | 454 | ||
451 | static int perl_generate_script(const char *outfile) | 455 | static int perl_generate_script(struct pevent *pevent, const char *outfile) |
452 | { | 456 | { |
453 | struct event_format *event = NULL; | 457 | struct event_format *event = NULL; |
454 | struct format_field *f; | 458 | struct format_field *f; |
@@ -495,7 +499,7 @@ static int perl_generate_script(const char *outfile) | |||
495 | fprintf(ofp, "sub trace_begin\n{\n\t# optional\n}\n\n"); | 499 | fprintf(ofp, "sub trace_begin\n{\n\t# optional\n}\n\n"); |
496 | fprintf(ofp, "sub trace_end\n{\n\t# optional\n}\n\n"); | 500 | fprintf(ofp, "sub trace_end\n{\n\t# optional\n}\n\n"); |
497 | 501 | ||
498 | while ((event = trace_find_next_event(event))) { | 502 | while ((event = trace_find_next_event(pevent, event))) { |
499 | fprintf(ofp, "sub %s::%s\n{\n", event->system, event->name); | 503 | fprintf(ofp, "sub %s::%s\n{\n", event->system, event->name); |
500 | fprintf(ofp, "\tmy ("); | 504 | fprintf(ofp, "\tmy ("); |
501 | 505 | ||