diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/Documentation/Makefile | 2 | ||||
-rw-r--r-- | tools/perf/Documentation/examples.txt (renamed from tools/perf/Documentation/perf-examples.txt) | 0 | ||||
-rw-r--r-- | tools/perf/builtin-annotate.c | 14 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 32 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 17 | ||||
-rw-r--r-- | tools/perf/util/thread.c | 25 | ||||
-rw-r--r-- | tools/perf/util/util.h | 4 |
7 files changed, 79 insertions, 15 deletions
diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile index 5457192e1b41..bdd3b7ecad0a 100644 --- a/tools/perf/Documentation/Makefile +++ b/tools/perf/Documentation/Makefile | |||
@@ -35,7 +35,7 @@ man7dir=$(mandir)/man7 | |||
35 | # DESTDIR= | 35 | # DESTDIR= |
36 | 36 | ||
37 | ASCIIDOC=asciidoc | 37 | ASCIIDOC=asciidoc |
38 | ASCIIDOC_EXTRA = | 38 | ASCIIDOC_EXTRA = --unsafe |
39 | MANPAGE_XSL = manpage-normal.xsl | 39 | MANPAGE_XSL = manpage-normal.xsl |
40 | XMLTO_EXTRA = | 40 | XMLTO_EXTRA = |
41 | INSTALL?=install | 41 | INSTALL?=install |
diff --git a/tools/perf/Documentation/perf-examples.txt b/tools/perf/Documentation/examples.txt index 8eb6c489fb15..8eb6c489fb15 100644 --- a/tools/perf/Documentation/perf-examples.txt +++ b/tools/perf/Documentation/examples.txt | |||
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 96d421f7161d..4c7bc4436236 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -28,6 +28,7 @@ static char const *input_name = "perf.data"; | |||
28 | static char default_sort_order[] = "comm,symbol"; | 28 | static char default_sort_order[] = "comm,symbol"; |
29 | static char *sort_order = default_sort_order; | 29 | static char *sort_order = default_sort_order; |
30 | 30 | ||
31 | static int force; | ||
31 | static int input; | 32 | static int input; |
32 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; | 33 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; |
33 | 34 | ||
@@ -629,6 +630,13 @@ process_fork_event(event_t *event, unsigned long offset, unsigned long head) | |||
629 | (void *)(long)(event->header.size), | 630 | (void *)(long)(event->header.size), |
630 | event->fork.pid, event->fork.ppid); | 631 | event->fork.pid, event->fork.ppid); |
631 | 632 | ||
633 | /* | ||
634 | * A thread clone will have the same PID for both | ||
635 | * parent and child. | ||
636 | */ | ||
637 | if (thread == parent) | ||
638 | return 0; | ||
639 | |||
632 | if (!thread || !parent || thread__fork(thread, parent)) { | 640 | if (!thread || !parent || thread__fork(thread, parent)) { |
633 | dump_printf("problem processing PERF_EVENT_FORK, skipping event.\n"); | 641 | dump_printf("problem processing PERF_EVENT_FORK, skipping event.\n"); |
634 | return -1; | 642 | return -1; |
@@ -976,6 +984,11 @@ static int __cmd_annotate(void) | |||
976 | exit(-1); | 984 | exit(-1); |
977 | } | 985 | } |
978 | 986 | ||
987 | if (!force && input_stat.st_uid && (input_stat.st_uid != geteuid())) { | ||
988 | fprintf(stderr, "file: %s not owned by current user or root\n", input_name); | ||
989 | exit(-1); | ||
990 | } | ||
991 | |||
979 | if (!input_stat.st_size) { | 992 | if (!input_stat.st_size) { |
980 | fprintf(stderr, "zero-sized file, nothing to do!\n"); | 993 | fprintf(stderr, "zero-sized file, nothing to do!\n"); |
981 | exit(0); | 994 | exit(0); |
@@ -1081,6 +1094,7 @@ static const struct option options[] = { | |||
1081 | "input file name"), | 1094 | "input file name"), |
1082 | OPT_STRING('s', "symbol", &sym_hist_filter, "symbol", | 1095 | OPT_STRING('s', "symbol", &sym_hist_filter, "symbol", |
1083 | "symbol to annotate"), | 1096 | "symbol to annotate"), |
1097 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | ||
1084 | OPT_BOOLEAN('v', "verbose", &verbose, | 1098 | OPT_BOOLEAN('v', "verbose", &verbose, |
1085 | "be more verbose (show symbol address, etc)"), | 1099 | "be more verbose (show symbol address, etc)"), |
1086 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 1100 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index ed1fdab3a1f5..cdd46ab11bd5 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -37,6 +37,7 @@ static char *dso_list_str, *comm_list_str, *sym_list_str, | |||
37 | static struct strlist *dso_list, *comm_list, *sym_list; | 37 | static struct strlist *dso_list, *comm_list, *sym_list; |
38 | static char *field_sep; | 38 | static char *field_sep; |
39 | 39 | ||
40 | static int force; | ||
40 | static int input; | 41 | static int input; |
41 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; | 42 | static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; |
42 | 43 | ||
@@ -665,6 +666,27 @@ static void dso__calc_col_width(struct dso *self) | |||
665 | self->slen_calculated = 1; | 666 | self->slen_calculated = 1; |
666 | } | 667 | } |
667 | 668 | ||
669 | static int thread__set_comm_adjust(struct thread *self, const char *comm) | ||
670 | { | ||
671 | int ret = thread__set_comm(self, comm); | ||
672 | |||
673 | if (ret) | ||
674 | return ret; | ||
675 | |||
676 | if (!col_width_list_str && !field_sep && | ||
677 | (!comm_list || strlist__has_entry(comm_list, comm))) { | ||
678 | unsigned int slen = strlen(comm); | ||
679 | |||
680 | if (slen > comms__col_width) { | ||
681 | comms__col_width = slen; | ||
682 | threads__col_width = slen + 6; | ||
683 | } | ||
684 | } | ||
685 | |||
686 | return 0; | ||
687 | } | ||
688 | |||
689 | |||
668 | static struct symbol * | 690 | static struct symbol * |
669 | resolve_symbol(struct thread *thread, struct map **mapp, | 691 | resolve_symbol(struct thread *thread, struct map **mapp, |
670 | struct dso **dsop, u64 *ipp) | 692 | struct dso **dsop, u64 *ipp) |
@@ -1056,7 +1078,7 @@ static void register_idle_thread(void) | |||
1056 | struct thread *thread = threads__findnew(0, &threads, &last_match); | 1078 | struct thread *thread = threads__findnew(0, &threads, &last_match); |
1057 | 1079 | ||
1058 | if (thread == NULL || | 1080 | if (thread == NULL || |
1059 | thread__set_comm(thread, "[idle]")) { | 1081 | thread__set_comm_adjust(thread, "[idle]")) { |
1060 | fprintf(stderr, "problem inserting idle task.\n"); | 1082 | fprintf(stderr, "problem inserting idle task.\n"); |
1061 | exit(-1); | 1083 | exit(-1); |
1062 | } | 1084 | } |
@@ -1226,7 +1248,7 @@ process_comm_event(event_t *event, unsigned long offset, unsigned long head) | |||
1226 | event->comm.comm, event->comm.pid); | 1248 | event->comm.comm, event->comm.pid); |
1227 | 1249 | ||
1228 | if (thread == NULL || | 1250 | if (thread == NULL || |
1229 | thread__set_comm(thread, event->comm.comm)) { | 1251 | thread__set_comm_adjust(thread, event->comm.comm)) { |
1230 | dump_printf("problem processing PERF_EVENT_COMM, skipping event.\n"); | 1252 | dump_printf("problem processing PERF_EVENT_COMM, skipping event.\n"); |
1231 | return -1; | 1253 | return -1; |
1232 | } | 1254 | } |
@@ -1383,6 +1405,11 @@ static int __cmd_report(void) | |||
1383 | exit(-1); | 1405 | exit(-1); |
1384 | } | 1406 | } |
1385 | 1407 | ||
1408 | if (!force && input_stat.st_uid && (input_stat.st_uid != geteuid())) { | ||
1409 | fprintf(stderr, "file: %s not owned by current user or root\n", input_name); | ||
1410 | exit(-1); | ||
1411 | } | ||
1412 | |||
1386 | if (!input_stat.st_size) { | 1413 | if (!input_stat.st_size) { |
1387 | fprintf(stderr, "zero-sized file, nothing to do!\n"); | 1414 | fprintf(stderr, "zero-sized file, nothing to do!\n"); |
1388 | exit(0); | 1415 | exit(0); |
@@ -1594,6 +1621,7 @@ static const struct option options[] = { | |||
1594 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, | 1621 | OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, |
1595 | "dump raw trace in ASCII"), | 1622 | "dump raw trace in ASCII"), |
1596 | OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), | 1623 | OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), |
1624 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | ||
1597 | OPT_BOOLEAN('m', "modules", &modules, | 1625 | OPT_BOOLEAN('m', "modules", &modules, |
1598 | "load module symbols - WARNING: use only with -k and LIVE kernel"), | 1626 | "load module symbols - WARNING: use only with -k and LIVE kernel"), |
1599 | OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples, | 1627 | OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples, |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 62b55ecab2c6..4002ccb36750 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -483,11 +483,16 @@ static void print_sym_table(void) | |||
483 | if (nr_counters == 1) | 483 | if (nr_counters == 1) |
484 | printf(" samples pcnt"); | 484 | printf(" samples pcnt"); |
485 | else | 485 | else |
486 | printf(" weight samples pcnt"); | 486 | printf(" weight samples pcnt"); |
487 | 487 | ||
488 | printf(" RIP kernel function\n" | 488 | if (verbose) |
489 | " ______ _______ _____ ________________ _______________\n\n" | 489 | printf(" RIP "); |
490 | ); | 490 | printf(" kernel function\n"); |
491 | printf(" %s _______ _____", | ||
492 | nr_counters == 1 ? " " : "______"); | ||
493 | if (verbose) | ||
494 | printf(" ________________"); | ||
495 | printf(" _______________\n\n"); | ||
491 | 496 | ||
492 | for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) { | 497 | for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) { |
493 | struct symbol *sym; | 498 | struct symbol *sym; |
@@ -508,7 +513,9 @@ static void print_sym_table(void) | |||
508 | printf("%9.1f %10ld - ", syme->weight, syme->snap_count); | 513 | printf("%9.1f %10ld - ", syme->weight, syme->snap_count); |
509 | 514 | ||
510 | percent_color_fprintf(stdout, "%4.1f%%", pcnt); | 515 | percent_color_fprintf(stdout, "%4.1f%%", pcnt); |
511 | printf(" - %016llx : %s", sym->start, sym->name); | 516 | if (verbose) |
517 | printf(" - %016llx", sym->start); | ||
518 | printf(" : %s", sym->name); | ||
512 | if (sym->module) | 519 | if (sym->module) |
513 | printf("\t[%s]", sym->module->name); | 520 | printf("\t[%s]", sym->module->name); |
514 | printf("\n"); | 521 | printf("\n"); |
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 00c14b98d651..f98032c135c6 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <string.h> | 4 | #include <string.h> |
5 | #include "thread.h" | 5 | #include "thread.h" |
6 | #include "util.h" | 6 | #include "util.h" |
7 | #include "debug.h" | ||
7 | 8 | ||
8 | static struct thread *thread__new(pid_t pid) | 9 | static struct thread *thread__new(pid_t pid) |
9 | { | 10 | { |
@@ -85,9 +86,27 @@ void thread__insert_map(struct thread *self, struct map *map) | |||
85 | 86 | ||
86 | list_for_each_entry_safe(pos, tmp, &self->maps, node) { | 87 | list_for_each_entry_safe(pos, tmp, &self->maps, node) { |
87 | if (map__overlap(pos, map)) { | 88 | if (map__overlap(pos, map)) { |
88 | list_del_init(&pos->node); | 89 | if (verbose >= 2) { |
89 | /* XXX leaks dsos */ | 90 | printf("overlapping maps:\n"); |
90 | free(pos); | 91 | map__fprintf(map, stdout); |
92 | map__fprintf(pos, stdout); | ||
93 | } | ||
94 | |||
95 | if (map->start <= pos->start && map->end > pos->start) | ||
96 | pos->start = map->end; | ||
97 | |||
98 | if (map->end >= pos->end && map->start < pos->end) | ||
99 | pos->end = map->start; | ||
100 | |||
101 | if (verbose >= 2) { | ||
102 | printf("after collision:\n"); | ||
103 | map__fprintf(pos, stdout); | ||
104 | } | ||
105 | |||
106 | if (pos->start >= pos->end) { | ||
107 | list_del_init(&pos->node); | ||
108 | free(pos); | ||
109 | } | ||
91 | } | 110 | } |
92 | } | 111 | } |
93 | 112 | ||
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index c62ef9720c6a..9de2329dd44d 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h | |||
@@ -39,10 +39,6 @@ | |||
39 | /* Approximation of the length of the decimal representation of this type. */ | 39 | /* Approximation of the length of the decimal representation of this type. */ |
40 | #define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) | 40 | #define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) |
41 | 41 | ||
42 | #if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && !defined(_M_UNIX) | ||
43 | #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ | ||
44 | #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ | ||
45 | #endif | ||
46 | #define _ALL_SOURCE 1 | 42 | #define _ALL_SOURCE 1 |
47 | #define _GNU_SOURCE 1 | 43 | #define _GNU_SOURCE 1 |
48 | #define _BSD_SOURCE 1 | 44 | #define _BSD_SOURCE 1 |