aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/scripting-engines/trace-event-perl.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2012-08-21 05:27:00 -0400
committerIngo Molnar <mingo@kernel.org>2012-08-21 05:27:00 -0400
commitbcada3d4b8c96b8792c2306f363992ca5ab9da42 (patch)
treee420679a5db6ea4e1694eef57f9abb6acac8d4d3 /tools/perf/util/scripting-engines/trace-event-perl.c
parent26198c21d1b286a084fe5d514a30bc7e6c712a34 (diff)
parent000078bc3ee69efb1124b8478c7527389a826074 (diff)
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: * Fix include order for bison/flex-generated C files, from Ben Hutchings * Build fixes and documentation corrections from David Ahern * Group parsing support, from Jiri Olsa * UI/gtk refactorings and improvements from Namhyung Kim * NULL deref fix for perf script, from Namhyung Kim * Assorted cleanups from Robert Richter * Let O= makes handle relative paths, from Steven Rostedt * perf script python fixes, from Feng Tang. * Improve 'perf lock' error message when the needed tracepoints are not present, from David Ahern. * Initial bash completion support, from Frederic Weisbecker * Allow building without libelf, from Namhyung Kim. * Support DWARF CFI based unwind to have callchains when %bp based unwinding is not possible, from Jiri Olsa. * Symbol resolution fixes, while fixing support PPC64 files with an .opt ELF section was the end goal, several fixes for code that handles all architectures and cleanups are included, from Cody Schafer. * Add a description for the JIT interface, from Andi Kleen. * Assorted fixes for Documentation and build in 32 bit, from Robert Richter * Add support for non-tracepoint events in perf script python, from Feng Tang * Cache the libtraceevent event_format associated to each evsel early, so that we avoid relookups, i.e. calling pevent_find_event repeatedly when processing tracepoint events. [ This is to reduce the surface contact with libtraceevents and make clear what is that the perf tools needs from that lib: so far parsing the common and per event fields. ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/scripting-engines/trace-event-perl.c')
-rw-r--r--tools/perf/util/scripting-engines/trace-event-perl.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/tools/perf/util/scripting-engines/trace-event-perl.c b/tools/perf/util/scripting-engines/trace-event-perl.c
index 02dfa19a467f..d28001016fb5 100644
--- a/tools/perf/util/scripting-engines/trace-event-perl.c
+++ b/tools/perf/util/scripting-engines/trace-event-perl.c
@@ -237,16 +237,16 @@ static void define_event_symbols(struct event_format *event,
237 define_event_symbols(event, ev_name, args->next); 237 define_event_symbols(event, ev_name, args->next);
238} 238}
239 239
240static inline 240static inline struct event_format *find_cache_event(struct perf_evsel *evsel)
241struct event_format *find_cache_event(struct pevent *pevent, int type)
242{ 241{
243 static char ev_name[256]; 242 static char ev_name[256];
244 struct event_format *event; 243 struct event_format *event;
244 int type = evsel->attr.config;
245 245
246 if (events[type]) 246 if (events[type])
247 return events[type]; 247 return events[type];
248 248
249 events[type] = event = pevent_find_event(pevent, type); 249 events[type] = event = evsel->tp_format;
250 if (!event) 250 if (!event)
251 return NULL; 251 return NULL;
252 252
@@ -258,22 +258,21 @@ struct event_format *find_cache_event(struct pevent *pevent, int type)
258} 258}
259 259
260static void perl_process_tracepoint(union perf_event *perf_event __unused, 260static void perl_process_tracepoint(union perf_event *perf_event __unused,
261 struct pevent *pevent,
262 struct perf_sample *sample, 261 struct perf_sample *sample,
263 struct perf_evsel *evsel, 262 struct perf_evsel *evsel,
264 struct machine *machine __unused, 263 struct machine *machine __unused,
265 struct thread *thread) 264 struct addr_location *al)
266{ 265{
267 struct format_field *field; 266 struct format_field *field;
268 static char handler[256]; 267 static char handler[256];
269 unsigned long long val; 268 unsigned long long val;
270 unsigned long s, ns; 269 unsigned long s, ns;
271 struct event_format *event; 270 struct event_format *event;
272 int type;
273 int pid; 271 int pid;
274 int cpu = sample->cpu; 272 int cpu = sample->cpu;
275 void *data = sample->raw_data; 273 void *data = sample->raw_data;
276 unsigned long long nsecs = sample->time; 274 unsigned long long nsecs = sample->time;
275 struct thread *thread = al->thread;
277 char *comm = thread->comm; 276 char *comm = thread->comm;
278 277
279 dSP; 278 dSP;
@@ -281,13 +280,11 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused,
281 if (evsel->attr.type != PERF_TYPE_TRACEPOINT) 280 if (evsel->attr.type != PERF_TYPE_TRACEPOINT)
282 return; 281 return;
283 282
284 type = trace_parse_common_type(pevent, data); 283 event = find_cache_event(evsel);
285
286 event = find_cache_event(pevent, type);
287 if (!event) 284 if (!event)
288 die("ug! no event found for type %d", type); 285 die("ug! no event found for type %d", evsel->attr.config);
289 286
290 pid = trace_parse_common_pid(pevent, data); 287 pid = raw_field_value(event, "common_pid", data);
291 288
292 sprintf(handler, "%s::%s", event->system, event->name); 289 sprintf(handler, "%s::%s", event->system, event->name);
293 290
@@ -320,7 +317,7 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused,
320 offset = field->offset; 317 offset = field->offset;
321 XPUSHs(sv_2mortal(newSVpv((char *)data + offset, 0))); 318 XPUSHs(sv_2mortal(newSVpv((char *)data + offset, 0)));
322 } else { /* FIELD_IS_NUMERIC */ 319 } else { /* FIELD_IS_NUMERIC */
323 val = read_size(pevent, data + field->offset, 320 val = read_size(event, data + field->offset,
324 field->size); 321 field->size);
325 if (field->flags & FIELD_IS_SIGNED) { 322 if (field->flags & FIELD_IS_SIGNED) {
326 XPUSHs(sv_2mortal(newSViv(val))); 323 XPUSHs(sv_2mortal(newSViv(val)));
@@ -349,11 +346,11 @@ static void perl_process_tracepoint(union perf_event *perf_event __unused,
349 LEAVE; 346 LEAVE;
350} 347}
351 348
352static void perl_process_event_generic(union perf_event *pevent __unused, 349static void perl_process_event_generic(union perf_event *event,
353 struct perf_sample *sample, 350 struct perf_sample *sample,
354 struct perf_evsel *evsel __unused, 351 struct perf_evsel *evsel,
355 struct machine *machine __unused, 352 struct machine *machine __unused,
356 struct thread *thread __unused) 353 struct addr_location *al __unused)
357{ 354{
358 dSP; 355 dSP;
359 356
@@ -363,7 +360,7 @@ static void perl_process_event_generic(union perf_event *pevent __unused,
363 ENTER; 360 ENTER;
364 SAVETMPS; 361 SAVETMPS;
365 PUSHMARK(SP); 362 PUSHMARK(SP);
366 XPUSHs(sv_2mortal(newSVpvn((const char *)pevent, pevent->header.size))); 363 XPUSHs(sv_2mortal(newSVpvn((const char *)event, event->header.size)));
367 XPUSHs(sv_2mortal(newSVpvn((const char *)&evsel->attr, sizeof(evsel->attr)))); 364 XPUSHs(sv_2mortal(newSVpvn((const char *)&evsel->attr, sizeof(evsel->attr))));
368 XPUSHs(sv_2mortal(newSVpvn((const char *)sample, sizeof(*sample)))); 365 XPUSHs(sv_2mortal(newSVpvn((const char *)sample, sizeof(*sample))));
369 XPUSHs(sv_2mortal(newSVpvn((const char *)sample->raw_data, sample->raw_size))); 366 XPUSHs(sv_2mortal(newSVpvn((const char *)sample->raw_data, sample->raw_size)));
@@ -376,14 +373,13 @@ static void perl_process_event_generic(union perf_event *pevent __unused,
376} 373}
377 374
378static void perl_process_event(union perf_event *event, 375static void perl_process_event(union perf_event *event,
379 struct pevent *pevent,
380 struct perf_sample *sample, 376 struct perf_sample *sample,
381 struct perf_evsel *evsel, 377 struct perf_evsel *evsel,
382 struct machine *machine, 378 struct machine *machine,
383 struct thread *thread) 379 struct addr_location *al)
384{ 380{
385 perl_process_tracepoint(event, pevent, sample, evsel, machine, thread); 381 perl_process_tracepoint(event, sample, evsel, machine, al);
386 perl_process_event_generic(event, sample, evsel, machine, thread); 382 perl_process_event_generic(event, sample, evsel, machine, al);
387} 383}
388 384
389static void run_start_sub(void) 385static void run_start_sub(void)