diff options
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r-- | tools/perf/builtin-top.c | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 7de28ce9ca26..62b55ecab2c6 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include "util/parse-options.h" | 27 | #include "util/parse-options.h" |
28 | #include "util/parse-events.h" | 28 | #include "util/parse-events.h" |
29 | 29 | ||
30 | #include "util/debug.h" | ||
31 | |||
30 | #include <assert.h> | 32 | #include <assert.h> |
31 | #include <fcntl.h> | 33 | #include <fcntl.h> |
32 | 34 | ||
@@ -68,8 +70,6 @@ static int group = 0; | |||
68 | static unsigned int page_size; | 70 | static unsigned int page_size; |
69 | static unsigned int mmap_pages = 16; | 71 | static unsigned int mmap_pages = 16; |
70 | static int freq = 0; | 72 | static int freq = 0; |
71 | static int verbose = 0; | ||
72 | static char *vmlinux = NULL; | ||
73 | 73 | ||
74 | static int delay_secs = 2; | 74 | static int delay_secs = 2; |
75 | static int zero; | 75 | static int zero; |
@@ -122,7 +122,8 @@ static void parse_source(struct sym_entry *syme) | |||
122 | struct module *module; | 122 | struct module *module; |
123 | struct section *section = NULL; | 123 | struct section *section = NULL; |
124 | FILE *file; | 124 | FILE *file; |
125 | char command[PATH_MAX*2], *path = vmlinux; | 125 | char command[PATH_MAX*2]; |
126 | const char *path = vmlinux_name; | ||
126 | u64 start, end, len; | 127 | u64 start, end, len; |
127 | 128 | ||
128 | if (!syme) | 129 | if (!syme) |
@@ -338,8 +339,6 @@ static void show_details(struct sym_entry *syme) | |||
338 | printf("%d lines not displayed, maybe increase display entries [e]\n", more); | 339 | printf("%d lines not displayed, maybe increase display entries [e]\n", more); |
339 | } | 340 | } |
340 | 341 | ||
341 | struct dso *kernel_dso; | ||
342 | |||
343 | /* | 342 | /* |
344 | * Symbols will be added here in record_ip and will get out | 343 | * Symbols will be added here in record_ip and will get out |
345 | * after decayed. | 344 | * after decayed. |
@@ -491,10 +490,12 @@ static void print_sym_table(void) | |||
491 | ); | 490 | ); |
492 | 491 | ||
493 | for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) { | 492 | for (nd = rb_first(&tmp); nd; nd = rb_next(nd)) { |
494 | struct sym_entry *syme = rb_entry(nd, struct sym_entry, rb_node); | 493 | struct symbol *sym; |
495 | struct symbol *sym = (struct symbol *)(syme + 1); | ||
496 | double pcnt; | 494 | double pcnt; |
497 | 495 | ||
496 | syme = rb_entry(nd, struct sym_entry, rb_node); | ||
497 | sym = (struct symbol *)(syme + 1); | ||
498 | |||
498 | if (++printed > print_entries || (int)syme->snap_count < count_filter) | 499 | if (++printed > print_entries || (int)syme->snap_count < count_filter) |
499 | continue; | 500 | continue; |
500 | 501 | ||
@@ -613,7 +614,7 @@ static void print_mapped_keys(void) | |||
613 | 614 | ||
614 | fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter); | 615 | fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter); |
615 | 616 | ||
616 | if (vmlinux) { | 617 | if (vmlinux_name) { |
617 | fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter); | 618 | fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter); |
618 | fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL"); | 619 | fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL"); |
619 | fprintf(stdout, "\t[S] stop annotation.\n"); | 620 | fprintf(stdout, "\t[S] stop annotation.\n"); |
@@ -642,7 +643,9 @@ static int key_mapped(int c) | |||
642 | case 'F': | 643 | case 'F': |
643 | case 's': | 644 | case 's': |
644 | case 'S': | 645 | case 'S': |
645 | return vmlinux ? 1 : 0; | 646 | return vmlinux_name ? 1 : 0; |
647 | default: | ||
648 | break; | ||
646 | } | 649 | } |
647 | 650 | ||
648 | return 0; | 651 | return 0; |
@@ -728,6 +731,8 @@ static void handle_keypress(int c) | |||
728 | case 'z': | 731 | case 'z': |
729 | zero = ~zero; | 732 | zero = ~zero; |
730 | break; | 733 | break; |
734 | default: | ||
735 | break; | ||
731 | } | 736 | } |
732 | } | 737 | } |
733 | 738 | ||
@@ -816,13 +821,13 @@ static int parse_symbols(void) | |||
816 | { | 821 | { |
817 | struct rb_node *node; | 822 | struct rb_node *node; |
818 | struct symbol *sym; | 823 | struct symbol *sym; |
819 | int modules = vmlinux ? 1 : 0; | 824 | int use_modules = vmlinux_name ? 1 : 0; |
820 | 825 | ||
821 | kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry)); | 826 | kernel_dso = dso__new("[kernel]", sizeof(struct sym_entry)); |
822 | if (kernel_dso == NULL) | 827 | if (kernel_dso == NULL) |
823 | return -1; | 828 | return -1; |
824 | 829 | ||
825 | if (dso__load_kernel(kernel_dso, vmlinux, symbol_filter, verbose, modules) <= 0) | 830 | if (dso__load_kernel(kernel_dso, vmlinux_name, symbol_filter, verbose, use_modules) <= 0) |
826 | goto out_delete_dso; | 831 | goto out_delete_dso; |
827 | 832 | ||
828 | node = rb_first(&kernel_dso->syms); | 833 | node = rb_first(&kernel_dso->syms); |
@@ -937,26 +942,6 @@ static void mmap_read_counter(struct mmap_data *md) | |||
937 | last_read = this_read; | 942 | last_read = this_read; |
938 | 943 | ||
939 | for (; old != head;) { | 944 | for (; old != head;) { |
940 | struct ip_event { | ||
941 | struct perf_event_header header; | ||
942 | u64 ip; | ||
943 | u32 pid, target_pid; | ||
944 | }; | ||
945 | struct mmap_event { | ||
946 | struct perf_event_header header; | ||
947 | u32 pid, target_pid; | ||
948 | u64 start; | ||
949 | u64 len; | ||
950 | u64 pgoff; | ||
951 | char filename[PATH_MAX]; | ||
952 | }; | ||
953 | |||
954 | typedef union event_union { | ||
955 | struct perf_event_header header; | ||
956 | struct ip_event ip; | ||
957 | struct mmap_event mmap; | ||
958 | } event_t; | ||
959 | |||
960 | event_t *event = (event_t *)&data[old & md->mask]; | 945 | event_t *event = (event_t *)&data[old & md->mask]; |
961 | 946 | ||
962 | event_t event_copy; | 947 | event_t event_copy; |
@@ -1138,7 +1123,7 @@ static const struct option options[] = { | |||
1138 | "system-wide collection from all CPUs"), | 1123 | "system-wide collection from all CPUs"), |
1139 | OPT_INTEGER('C', "CPU", &profile_cpu, | 1124 | OPT_INTEGER('C', "CPU", &profile_cpu, |
1140 | "CPU to profile on"), | 1125 | "CPU to profile on"), |
1141 | OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"), | 1126 | OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), |
1142 | OPT_INTEGER('m', "mmap-pages", &mmap_pages, | 1127 | OPT_INTEGER('m', "mmap-pages", &mmap_pages, |
1143 | "number of mmap data pages"), | 1128 | "number of mmap data pages"), |
1144 | OPT_INTEGER('r', "realtime", &realtime_prio, | 1129 | OPT_INTEGER('r', "realtime", &realtime_prio, |