diff options
Diffstat (limited to 'tools/perf/util/trace-event-info.c')
-rw-r--r-- | tools/perf/util/trace-event-info.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index 831052d4b4fb..cace35595530 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c | |||
@@ -33,11 +33,11 @@ | |||
33 | #include <ctype.h> | 33 | #include <ctype.h> |
34 | #include <errno.h> | 34 | #include <errno.h> |
35 | #include <stdbool.h> | 35 | #include <stdbool.h> |
36 | #include <linux/kernel.h> | ||
36 | 37 | ||
37 | #include "../perf.h" | 38 | #include "../perf.h" |
38 | #include "trace-event.h" | 39 | #include "trace-event.h" |
39 | 40 | ||
40 | |||
41 | #define VERSION "0.5" | 41 | #define VERSION "0.5" |
42 | 42 | ||
43 | #define _STR(x) #x | 43 | #define _STR(x) #x |
@@ -483,23 +483,31 @@ static struct tracepoint_path * | |||
483 | get_tracepoints_path(struct perf_event_attr *pattrs, int nb_events) | 483 | get_tracepoints_path(struct perf_event_attr *pattrs, int nb_events) |
484 | { | 484 | { |
485 | struct tracepoint_path path, *ppath = &path; | 485 | struct tracepoint_path path, *ppath = &path; |
486 | int i; | 486 | int i, nr_tracepoints = 0; |
487 | 487 | ||
488 | for (i = 0; i < nb_events; i++) { | 488 | for (i = 0; i < nb_events; i++) { |
489 | if (pattrs[i].type != PERF_TYPE_TRACEPOINT) | 489 | if (pattrs[i].type != PERF_TYPE_TRACEPOINT) |
490 | continue; | 490 | continue; |
491 | ++nr_tracepoints; | ||
491 | ppath->next = tracepoint_id_to_path(pattrs[i].config); | 492 | ppath->next = tracepoint_id_to_path(pattrs[i].config); |
492 | if (!ppath->next) | 493 | if (!ppath->next) |
493 | die("%s\n", "No memory to alloc tracepoints list"); | 494 | die("%s\n", "No memory to alloc tracepoints list"); |
494 | ppath = ppath->next; | 495 | ppath = ppath->next; |
495 | } | 496 | } |
496 | 497 | ||
497 | return path.next; | 498 | return nr_tracepoints > 0 ? path.next : NULL; |
498 | } | 499 | } |
499 | void read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events) | 500 | |
501 | int read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events) | ||
500 | { | 502 | { |
501 | char buf[BUFSIZ]; | 503 | char buf[BUFSIZ]; |
502 | struct tracepoint_path *tps; | 504 | struct tracepoint_path *tps = get_tracepoints_path(pattrs, nb_events); |
505 | |||
506 | /* | ||
507 | * What? No tracepoints? No sense writing anything here, bail out. | ||
508 | */ | ||
509 | if (tps == NULL) | ||
510 | return -1; | ||
503 | 511 | ||
504 | output_fd = fd; | 512 | output_fd = fd; |
505 | 513 | ||
@@ -528,11 +536,11 @@ void read_tracing_data(int fd, struct perf_event_attr *pattrs, int nb_events) | |||
528 | page_size = getpagesize(); | 536 | page_size = getpagesize(); |
529 | write_or_die(&page_size, 4); | 537 | write_or_die(&page_size, 4); |
530 | 538 | ||
531 | tps = get_tracepoints_path(pattrs, nb_events); | ||
532 | |||
533 | read_header_files(); | 539 | read_header_files(); |
534 | read_ftrace_files(tps); | 540 | read_ftrace_files(tps); |
535 | read_event_files(tps); | 541 | read_event_files(tps); |
536 | read_proc_kallsyms(); | 542 | read_proc_kallsyms(); |
537 | read_ftrace_printk(); | 543 | read_ftrace_printk(); |
544 | |||
545 | return 0; | ||
538 | } | 546 | } |