diff options
Diffstat (limited to 'tools/perf/util/trace-event-info.c')
| -rw-r--r-- | tools/perf/util/trace-event-info.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index af4b0573b37f..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,27 +483,33 @@ 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(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 = open(output_file, O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE, 0644); | 512 | output_fd = fd; |
| 505 | if (output_fd < 0) | ||
| 506 | die("creating file '%s'", output_file); | ||
| 507 | 513 | ||
| 508 | buf[0] = 23; | 514 | buf[0] = 23; |
| 509 | buf[1] = 8; | 515 | buf[1] = 8; |
| @@ -530,11 +536,11 @@ void read_tracing_data(struct perf_event_attr *pattrs, int nb_events) | |||
| 530 | page_size = getpagesize(); | 536 | page_size = getpagesize(); |
| 531 | write_or_die(&page_size, 4); | 537 | write_or_die(&page_size, 4); |
| 532 | 538 | ||
| 533 | tps = get_tracepoints_path(pattrs, nb_events); | ||
| 534 | |||
| 535 | read_header_files(); | 539 | read_header_files(); |
| 536 | read_ftrace_files(tps); | 540 | read_ftrace_files(tps); |
| 537 | read_event_files(tps); | 541 | read_event_files(tps); |
| 538 | read_proc_kallsyms(); | 542 | read_proc_kallsyms(); |
| 539 | read_ftrace_printk(); | 543 | read_ftrace_printk(); |
| 544 | |||
| 545 | return 0; | ||
| 540 | } | 546 | } |
