diff options
Diffstat (limited to 'tools/perf/util/trace-event-info.c')
-rw-r--r-- | tools/perf/util/trace-event-info.c | 96 |
1 files changed, 25 insertions, 71 deletions
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c index 3917eb9a8479..f3c9e551bd35 100644 --- a/tools/perf/util/trace-event-info.c +++ b/tools/perf/util/trace-event-info.c | |||
@@ -46,65 +46,6 @@ | |||
46 | static int output_fd; | 46 | static int output_fd; |
47 | 47 | ||
48 | 48 | ||
49 | static const char *find_debugfs(void) | ||
50 | { | ||
51 | const char *path = perf_debugfs_mount(NULL); | ||
52 | |||
53 | if (!path) | ||
54 | pr_debug("Your kernel does not support the debugfs filesystem"); | ||
55 | |||
56 | return path; | ||
57 | } | ||
58 | |||
59 | /* | ||
60 | * Finds the path to the debugfs/tracing | ||
61 | * Allocates the string and stores it. | ||
62 | */ | ||
63 | static const char *find_tracing_dir(void) | ||
64 | { | ||
65 | static char *tracing; | ||
66 | static int tracing_found; | ||
67 | const char *debugfs; | ||
68 | |||
69 | if (tracing_found) | ||
70 | return tracing; | ||
71 | |||
72 | debugfs = find_debugfs(); | ||
73 | if (!debugfs) | ||
74 | return NULL; | ||
75 | |||
76 | tracing = malloc(strlen(debugfs) + 9); | ||
77 | if (!tracing) | ||
78 | return NULL; | ||
79 | |||
80 | sprintf(tracing, "%s/tracing", debugfs); | ||
81 | |||
82 | tracing_found = 1; | ||
83 | return tracing; | ||
84 | } | ||
85 | |||
86 | static char *get_tracing_file(const char *name) | ||
87 | { | ||
88 | const char *tracing; | ||
89 | char *file; | ||
90 | |||
91 | tracing = find_tracing_dir(); | ||
92 | if (!tracing) | ||
93 | return NULL; | ||
94 | |||
95 | file = malloc(strlen(tracing) + strlen(name) + 2); | ||
96 | if (!file) | ||
97 | return NULL; | ||
98 | |||
99 | sprintf(file, "%s/%s", tracing, name); | ||
100 | return file; | ||
101 | } | ||
102 | |||
103 | static void put_tracing_file(char *file) | ||
104 | { | ||
105 | free(file); | ||
106 | } | ||
107 | |||
108 | int bigendian(void) | 49 | int bigendian(void) |
109 | { | 50 | { |
110 | unsigned char str[] = { 0x1, 0x2, 0x3, 0x4, 0x0, 0x0, 0x0, 0x0}; | 51 | unsigned char str[] = { 0x1, 0x2, 0x3, 0x4, 0x0, 0x0, 0x0, 0x0}; |
@@ -160,7 +101,7 @@ out: | |||
160 | return err; | 101 | return err; |
161 | } | 102 | } |
162 | 103 | ||
163 | static int read_header_files(void) | 104 | static int record_header_files(void) |
164 | { | 105 | { |
165 | char *path; | 106 | char *path; |
166 | struct stat st; | 107 | struct stat st; |
@@ -299,7 +240,7 @@ out: | |||
299 | return err; | 240 | return err; |
300 | } | 241 | } |
301 | 242 | ||
302 | static int read_ftrace_files(struct tracepoint_path *tps) | 243 | static int record_ftrace_files(struct tracepoint_path *tps) |
303 | { | 244 | { |
304 | char *path; | 245 | char *path; |
305 | int ret; | 246 | int ret; |
@@ -328,7 +269,7 @@ static bool system_in_tp_list(char *sys, struct tracepoint_path *tps) | |||
328 | return false; | 269 | return false; |
329 | } | 270 | } |
330 | 271 | ||
331 | static int read_event_files(struct tracepoint_path *tps) | 272 | static int record_event_files(struct tracepoint_path *tps) |
332 | { | 273 | { |
333 | struct dirent *dent; | 274 | struct dirent *dent; |
334 | struct stat st; | 275 | struct stat st; |
@@ -403,7 +344,7 @@ out: | |||
403 | return err; | 344 | return err; |
404 | } | 345 | } |
405 | 346 | ||
406 | static int read_proc_kallsyms(void) | 347 | static int record_proc_kallsyms(void) |
407 | { | 348 | { |
408 | unsigned int size; | 349 | unsigned int size; |
409 | const char *path = "/proc/kallsyms"; | 350 | const char *path = "/proc/kallsyms"; |
@@ -421,7 +362,7 @@ static int read_proc_kallsyms(void) | |||
421 | return record_file(path, 4); | 362 | return record_file(path, 4); |
422 | } | 363 | } |
423 | 364 | ||
424 | static int read_ftrace_printk(void) | 365 | static int record_ftrace_printk(void) |
425 | { | 366 | { |
426 | unsigned int size; | 367 | unsigned int size; |
427 | char *path; | 368 | char *path; |
@@ -473,12 +414,27 @@ get_tracepoints_path(struct list_head *pattrs) | |||
473 | if (pos->attr.type != PERF_TYPE_TRACEPOINT) | 414 | if (pos->attr.type != PERF_TYPE_TRACEPOINT) |
474 | continue; | 415 | continue; |
475 | ++nr_tracepoints; | 416 | ++nr_tracepoints; |
417 | |||
418 | if (pos->name) { | ||
419 | ppath->next = tracepoint_name_to_path(pos->name); | ||
420 | if (ppath->next) | ||
421 | goto next; | ||
422 | |||
423 | if (strchr(pos->name, ':') == NULL) | ||
424 | goto try_id; | ||
425 | |||
426 | goto error; | ||
427 | } | ||
428 | |||
429 | try_id: | ||
476 | ppath->next = tracepoint_id_to_path(pos->attr.config); | 430 | ppath->next = tracepoint_id_to_path(pos->attr.config); |
477 | if (!ppath->next) { | 431 | if (!ppath->next) { |
432 | error: | ||
478 | pr_debug("No memory to alloc tracepoints list\n"); | 433 | pr_debug("No memory to alloc tracepoints list\n"); |
479 | put_tracepoints_path(&path); | 434 | put_tracepoints_path(&path); |
480 | return NULL; | 435 | return NULL; |
481 | } | 436 | } |
437 | next: | ||
482 | ppath = ppath->next; | 438 | ppath = ppath->next; |
483 | } | 439 | } |
484 | 440 | ||
@@ -520,8 +476,6 @@ static int tracing_data_header(void) | |||
520 | else | 476 | else |
521 | buf[0] = 0; | 477 | buf[0] = 0; |
522 | 478 | ||
523 | read_trace_init(buf[0], buf[0]); | ||
524 | |||
525 | if (write(output_fd, buf, 1) != 1) | 479 | if (write(output_fd, buf, 1) != 1) |
526 | return -1; | 480 | return -1; |
527 | 481 | ||
@@ -583,19 +537,19 @@ struct tracing_data *tracing_data_get(struct list_head *pattrs, | |||
583 | err = tracing_data_header(); | 537 | err = tracing_data_header(); |
584 | if (err) | 538 | if (err) |
585 | goto out; | 539 | goto out; |
586 | err = read_header_files(); | 540 | err = record_header_files(); |
587 | if (err) | 541 | if (err) |
588 | goto out; | 542 | goto out; |
589 | err = read_ftrace_files(tps); | 543 | err = record_ftrace_files(tps); |
590 | if (err) | 544 | if (err) |
591 | goto out; | 545 | goto out; |
592 | err = read_event_files(tps); | 546 | err = record_event_files(tps); |
593 | if (err) | 547 | if (err) |
594 | goto out; | 548 | goto out; |
595 | err = read_proc_kallsyms(); | 549 | err = record_proc_kallsyms(); |
596 | if (err) | 550 | if (err) |
597 | goto out; | 551 | goto out; |
598 | err = read_ftrace_printk(); | 552 | err = record_ftrace_printk(); |
599 | 553 | ||
600 | out: | 554 | out: |
601 | /* | 555 | /* |