diff options
Diffstat (limited to 'tools/perf/builtin-annotate.c')
-rw-r--r-- | tools/perf/builtin-annotate.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 5f9eefecc574..5e17de984dc8 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -31,6 +31,7 @@ static char *vmlinux = "vmlinux"; | |||
31 | static char default_sort_order[] = "comm,symbol"; | 31 | static char default_sort_order[] = "comm,symbol"; |
32 | static char *sort_order = default_sort_order; | 32 | static char *sort_order = default_sort_order; |
33 | 33 | ||
34 | static int force; | ||
34 | static int input; | 35 | static int input; |
35 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; | 36 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; |
36 | 37 | ||
@@ -74,20 +75,12 @@ struct fork_event { | |||
74 | u32 pid, ppid; | 75 | u32 pid, ppid; |
75 | }; | 76 | }; |
76 | 77 | ||
77 | struct period_event { | ||
78 | struct perf_event_header header; | ||
79 | u64 time; | ||
80 | u64 id; | ||
81 | u64 sample_period; | ||
82 | }; | ||
83 | |||
84 | typedef union event_union { | 78 | typedef union event_union { |
85 | struct perf_event_header header; | 79 | struct perf_event_header header; |
86 | struct ip_event ip; | 80 | struct ip_event ip; |
87 | struct mmap_event mmap; | 81 | struct mmap_event mmap; |
88 | struct comm_event comm; | 82 | struct comm_event comm; |
89 | struct fork_event fork; | 83 | struct fork_event fork; |
90 | struct period_event period; | ||
91 | } event_t; | 84 | } event_t; |
92 | 85 | ||
93 | 86 | ||
@@ -988,6 +981,13 @@ process_fork_event(event_t *event, unsigned long offset, unsigned long head) | |||
988 | (void *)(long)(event->header.size), | 981 | (void *)(long)(event->header.size), |
989 | event->fork.pid, event->fork.ppid); | 982 | event->fork.pid, event->fork.ppid); |
990 | 983 | ||
984 | /* | ||
985 | * A thread clone will have the same PID for both | ||
986 | * parent and child. | ||
987 | */ | ||
988 | if (thread == parent) | ||
989 | return 0; | ||
990 | |||
991 | if (!thread || !parent || thread__fork(thread, parent)) { | 991 | if (!thread || !parent || thread__fork(thread, parent)) { |
992 | dprintf("problem processing PERF_EVENT_FORK, skipping event.\n"); | 992 | dprintf("problem processing PERF_EVENT_FORK, skipping event.\n"); |
993 | return -1; | 993 | return -1; |
@@ -998,19 +998,6 @@ process_fork_event(event_t *event, unsigned long offset, unsigned long head) | |||
998 | } | 998 | } |
999 | 999 | ||
1000 | static int | 1000 | static int |
1001 | process_period_event(event_t *event, unsigned long offset, unsigned long head) | ||
1002 | { | ||
1003 | dprintf("%p [%p]: PERF_EVENT_PERIOD: time:%Ld, id:%Ld: period:%Ld\n", | ||
1004 | (void *)(offset + head), | ||
1005 | (void *)(long)(event->header.size), | ||
1006 | event->period.time, | ||
1007 | event->period.id, | ||
1008 | event->period.sample_period); | ||
1009 | |||
1010 | return 0; | ||
1011 | } | ||
1012 | |||
1013 | static int | ||
1014 | process_event(event_t *event, unsigned long offset, unsigned long head) | 1001 | process_event(event_t *event, unsigned long offset, unsigned long head) |
1015 | { | 1002 | { |
1016 | switch (event->header.type) { | 1003 | switch (event->header.type) { |
@@ -1025,9 +1012,6 @@ process_event(event_t *event, unsigned long offset, unsigned long head) | |||
1025 | 1012 | ||
1026 | case PERF_EVENT_FORK: | 1013 | case PERF_EVENT_FORK: |
1027 | return process_fork_event(event, offset, head); | 1014 | return process_fork_event(event, offset, head); |
1028 | |||
1029 | case PERF_EVENT_PERIOD: | ||
1030 | return process_period_event(event, offset, head); | ||
1031 | /* | 1015 | /* |
1032 | * We dont process them right now but they are fine: | 1016 | * We dont process them right now but they are fine: |
1033 | */ | 1017 | */ |
@@ -1351,6 +1335,11 @@ static int __cmd_annotate(void) | |||
1351 | exit(-1); | 1335 | exit(-1); |
1352 | } | 1336 | } |
1353 | 1337 | ||
1338 | if (!force && (stat.st_uid != geteuid())) { | ||
1339 | fprintf(stderr, "file: %s not owned by current user\n", input_name); | ||
1340 | exit(-1); | ||
1341 | } | ||
1342 | |||
1354 | if (!stat.st_size) { | 1343 | if (!stat.st_size) { |
1355 | fprintf(stderr, "zero-sized file, nothing to do!\n"); | 1344 | fprintf(stderr, "zero-sized file, nothing to do!\n"); |
1356 | exit(0); | 1345 | exit(0); |
@@ -1456,6 +1445,7 @@ static const struct option options[] = { | |||
1456 | "input file name"), | 1445 | "input file name"), |
1457 | OPT_STRING('s', "symbol", &sym_hist_filter, "symbol", | 1446 | OPT_STRING('s', "symbol", &sym_hist_filter, "symbol", |
1458 | "symbol to annotate"), | 1447 | "symbol to annotate"), |
1448 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | ||
1459 | OPT_BOOLEAN('v', "verbose", &verbose, | 1449 | OPT_BOOLEAN('v', "verbose", &verbose, |
1460 | "be more verbose (show symbol address, etc)"), | 1450 | "be more verbose (show symbol address, etc)"), |
1461 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 1451 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |