diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/util/event.c | 34 | ||||
| -rw-r--r-- | tools/perf/util/hist.c | 115 | ||||
| -rw-r--r-- | tools/perf/util/hist.h | 27 | ||||
| -rw-r--r-- | tools/perf/util/newt.c | 9 | ||||
| -rw-r--r-- | tools/perf/util/sort.c | 17 | ||||
| -rw-r--r-- | tools/perf/util/sort.h | 6 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 9 | ||||
| -rw-r--r-- | tools/perf/util/symbol.h | 2 |
8 files changed, 140 insertions, 79 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index d7f21d71eb69..121339f4360d 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
| @@ -340,30 +340,29 @@ int event__synthesize_kernel_mmap(event__handler_t process, | |||
| 340 | return process(&ev, session); | 340 | return process(&ev, session); |
| 341 | } | 341 | } |
| 342 | 342 | ||
| 343 | static void thread__comm_adjust(struct thread *self) | 343 | static void thread__comm_adjust(struct thread *self, struct hists *hists) |
| 344 | { | 344 | { |
| 345 | char *comm = self->comm; | 345 | char *comm = self->comm; |
| 346 | 346 | ||
| 347 | if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep && | 347 | if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep && |
| 348 | (!symbol_conf.comm_list || | 348 | (!symbol_conf.comm_list || |
| 349 | strlist__has_entry(symbol_conf.comm_list, comm))) { | 349 | strlist__has_entry(symbol_conf.comm_list, comm))) { |
| 350 | unsigned int slen = strlen(comm); | 350 | u16 slen = strlen(comm); |
| 351 | 351 | ||
| 352 | if (slen > comms__col_width) { | 352 | if (hists__new_col_len(hists, HISTC_COMM, slen)) |
| 353 | comms__col_width = slen; | 353 | hists__set_col_len(hists, HISTC_THREAD, slen + 6); |
| 354 | threads__col_width = slen + 6; | ||
| 355 | } | ||
| 356 | } | 354 | } |
| 357 | } | 355 | } |
| 358 | 356 | ||
| 359 | static int thread__set_comm_adjust(struct thread *self, const char *comm) | 357 | static int thread__set_comm_adjust(struct thread *self, const char *comm, |
| 358 | struct hists *hists) | ||
| 360 | { | 359 | { |
| 361 | int ret = thread__set_comm(self, comm); | 360 | int ret = thread__set_comm(self, comm); |
| 362 | 361 | ||
| 363 | if (ret) | 362 | if (ret) |
| 364 | return ret; | 363 | return ret; |
| 365 | 364 | ||
| 366 | thread__comm_adjust(self); | 365 | thread__comm_adjust(self, hists); |
| 367 | 366 | ||
| 368 | return 0; | 367 | return 0; |
| 369 | } | 368 | } |
| @@ -374,7 +373,8 @@ int event__process_comm(event_t *self, struct perf_session *session) | |||
| 374 | 373 | ||
| 375 | dump_printf(": %s:%d\n", self->comm.comm, self->comm.tid); | 374 | dump_printf(": %s:%d\n", self->comm.comm, self->comm.tid); |
| 376 | 375 | ||
| 377 | if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm)) { | 376 | if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm, |
| 377 | &session->hists)) { | ||
| 378 | dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); | 378 | dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); |
| 379 | return -1; | 379 | return -1; |
| 380 | } | 380 | } |
| @@ -641,16 +641,13 @@ void thread__find_addr_location(struct thread *self, | |||
| 641 | al->sym = NULL; | 641 | al->sym = NULL; |
| 642 | } | 642 | } |
| 643 | 643 | ||
| 644 | static void dso__calc_col_width(struct dso *self) | 644 | static void dso__calc_col_width(struct dso *self, struct hists *hists) |
| 645 | { | 645 | { |
| 646 | if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep && | 646 | if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep && |
| 647 | (!symbol_conf.dso_list || | 647 | (!symbol_conf.dso_list || |
| 648 | strlist__has_entry(symbol_conf.dso_list, self->name))) { | 648 | strlist__has_entry(symbol_conf.dso_list, self->name))) { |
| 649 | u16 slen = self->short_name_len; | 649 | u16 slen = dso__name_len(self); |
| 650 | if (verbose) | 650 | hists__new_col_len(hists, HISTC_DSO, slen); |
| 651 | slen = self->long_name_len; | ||
| 652 | if (dsos__col_width < slen) | ||
| 653 | dsos__col_width = slen; | ||
| 654 | } | 651 | } |
| 655 | 652 | ||
| 656 | self->slen_calculated = 1; | 653 | self->slen_calculated = 1; |
| @@ -729,16 +726,17 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session, | |||
| 729 | * sampled. | 726 | * sampled. |
| 730 | */ | 727 | */ |
| 731 | if (!sort_dso.elide && !al->map->dso->slen_calculated) | 728 | if (!sort_dso.elide && !al->map->dso->slen_calculated) |
| 732 | dso__calc_col_width(al->map->dso); | 729 | dso__calc_col_width(al->map->dso, &session->hists); |
| 733 | 730 | ||
| 734 | al->sym = map__find_symbol(al->map, al->addr, filter); | 731 | al->sym = map__find_symbol(al->map, al->addr, filter); |
| 735 | } else { | 732 | } else { |
| 736 | const unsigned int unresolved_col_width = BITS_PER_LONG / 4; | 733 | const unsigned int unresolved_col_width = BITS_PER_LONG / 4; |
| 737 | 734 | ||
| 738 | if (dsos__col_width < unresolved_col_width && | 735 | if (hists__col_len(&session->hists, HISTC_DSO) < unresolved_col_width && |
| 739 | !symbol_conf.col_width_list_str && !symbol_conf.field_sep && | 736 | !symbol_conf.col_width_list_str && !symbol_conf.field_sep && |
| 740 | !symbol_conf.dso_list) | 737 | !symbol_conf.dso_list) |
| 741 | dsos__col_width = unresolved_col_width; | 738 | hists__set_col_len(&session->hists, HISTC_DSO, |
| 739 | unresolved_col_width); | ||
| 742 | } | 740 | } |
| 743 | 741 | ||
| 744 | if (symbol_conf.sym_list && al->sym && | 742 | if (symbol_conf.sym_list && al->sym && |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index d998d1d706eb..0bc67900352c 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
| @@ -16,6 +16,50 @@ struct callchain_param callchain_param = { | |||
| 16 | .min_percent = 0.5 | 16 | .min_percent = 0.5 |
| 17 | }; | 17 | }; |
| 18 | 18 | ||
| 19 | u16 hists__col_len(struct hists *self, enum hist_column col) | ||
| 20 | { | ||
| 21 | return self->col_len[col]; | ||
| 22 | } | ||
| 23 | |||
| 24 | void hists__set_col_len(struct hists *self, enum hist_column col, u16 len) | ||
| 25 | { | ||
| 26 | self->col_len[col] = len; | ||
| 27 | } | ||
| 28 | |||
| 29 | bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len) | ||
| 30 | { | ||
| 31 | if (len > hists__col_len(self, col)) { | ||
| 32 | hists__set_col_len(self, col, len); | ||
| 33 | return true; | ||
| 34 | } | ||
| 35 | return false; | ||
| 36 | } | ||
| 37 | |||
| 38 | static void hists__reset_col_len(struct hists *self) | ||
| 39 | { | ||
| 40 | enum hist_column col; | ||
| 41 | |||
| 42 | for (col = 0; col < HISTC_NR_COLS; ++col) | ||
| 43 | hists__set_col_len(self, col, 0); | ||
| 44 | } | ||
| 45 | |||
| 46 | static void hists__calc_col_len(struct hists *self, struct hist_entry *h) | ||
| 47 | { | ||
| 48 | u16 len; | ||
| 49 | |||
| 50 | if (h->ms.sym) | ||
| 51 | hists__new_col_len(self, HISTC_SYMBOL, h->ms.sym->namelen); | ||
| 52 | |||
| 53 | len = thread__comm_len(h->thread); | ||
| 54 | if (hists__new_col_len(self, HISTC_COMM, len)) | ||
| 55 | hists__set_col_len(self, HISTC_THREAD, len + 6); | ||
| 56 | |||
| 57 | if (h->ms.map) { | ||
| 58 | len = dso__name_len(h->ms.map->dso); | ||
| 59 | hists__new_col_len(self, HISTC_DSO, len); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 19 | static void hist_entry__add_cpumode_period(struct hist_entry *self, | 63 | static void hist_entry__add_cpumode_period(struct hist_entry *self, |
| 20 | unsigned int cpumode, u64 period) | 64 | unsigned int cpumode, u64 period) |
| 21 | { | 65 | { |
| @@ -56,13 +100,12 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template) | |||
| 56 | return self; | 100 | return self; |
| 57 | } | 101 | } |
| 58 | 102 | ||
| 59 | static void hists__inc_nr_entries(struct hists *self, struct hist_entry *entry) | 103 | static void hists__inc_nr_entries(struct hists *self, struct hist_entry *h) |
| 60 | { | 104 | { |
| 61 | if (entry->filtered) | 105 | if (!h->filtered) { |
| 62 | return; | 106 | hists__calc_col_len(self, h); |
| 63 | if (entry->ms.sym && self->max_sym_namelen < entry->ms.sym->namelen) | 107 | ++self->nr_entries; |
| 64 | self->max_sym_namelen = entry->ms.sym->namelen; | 108 | } |
| 65 | ++self->nr_entries; | ||
| 66 | } | 109 | } |
| 67 | 110 | ||
| 68 | static u8 symbol__parent_filter(const struct symbol *parent) | 111 | static u8 symbol__parent_filter(const struct symbol *parent) |
| @@ -208,7 +251,7 @@ void hists__collapse_resort(struct hists *self) | |||
| 208 | tmp = RB_ROOT; | 251 | tmp = RB_ROOT; |
| 209 | next = rb_first(&self->entries); | 252 | next = rb_first(&self->entries); |
| 210 | self->nr_entries = 0; | 253 | self->nr_entries = 0; |
| 211 | self->max_sym_namelen = 0; | 254 | hists__reset_col_len(self); |
| 212 | 255 | ||
| 213 | while (next) { | 256 | while (next) { |
| 214 | n = rb_entry(next, struct hist_entry, rb_node); | 257 | n = rb_entry(next, struct hist_entry, rb_node); |
| @@ -265,7 +308,7 @@ void hists__output_resort(struct hists *self) | |||
| 265 | next = rb_first(&self->entries); | 308 | next = rb_first(&self->entries); |
| 266 | 309 | ||
| 267 | self->nr_entries = 0; | 310 | self->nr_entries = 0; |
| 268 | self->max_sym_namelen = 0; | 311 | hists__reset_col_len(self); |
| 269 | 312 | ||
| 270 | while (next) { | 313 | while (next) { |
| 271 | n = rb_entry(next, struct hist_entry, rb_node); | 314 | n = rb_entry(next, struct hist_entry, rb_node); |
| @@ -532,8 +575,9 @@ static size_t hist_entry_callchain__fprintf(FILE *fp, struct hist_entry *self, | |||
| 532 | } | 575 | } |
| 533 | 576 | ||
| 534 | int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size, | 577 | int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size, |
| 535 | struct hists *pair_hists, bool show_displacement, | 578 | struct hists *hists, struct hists *pair_hists, |
| 536 | long displacement, bool color, u64 session_total) | 579 | bool show_displacement, long displacement, |
| 580 | bool color, u64 session_total) | ||
| 537 | { | 581 | { |
| 538 | struct sort_entry *se; | 582 | struct sort_entry *se; |
| 539 | u64 period, total, period_sys, period_us, period_guest_sys, period_guest_us; | 583 | u64 period, total, period_sys, period_us, period_guest_sys, period_guest_us; |
| @@ -637,24 +681,25 @@ int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size, | |||
| 637 | 681 | ||
| 638 | ret += snprintf(s + ret, size - ret, "%s", sep ?: " "); | 682 | ret += snprintf(s + ret, size - ret, "%s", sep ?: " "); |
| 639 | ret += se->se_snprintf(self, s + ret, size - ret, | 683 | ret += se->se_snprintf(self, s + ret, size - ret, |
| 640 | se->se_width ? *se->se_width : 0); | 684 | hists__col_len(hists, se->se_width_idx)); |
| 641 | } | 685 | } |
| 642 | 686 | ||
| 643 | return ret; | 687 | return ret; |
| 644 | } | 688 | } |
| 645 | 689 | ||
| 646 | int hist_entry__fprintf(struct hist_entry *self, struct hists *pair_hists, | 690 | int hist_entry__fprintf(struct hist_entry *self, struct hists *hists, |
| 647 | bool show_displacement, long displacement, FILE *fp, | 691 | struct hists *pair_hists, bool show_displacement, |
| 648 | u64 session_total) | 692 | long displacement, FILE *fp, u64 session_total) |
| 649 | { | 693 | { |
| 650 | char bf[512]; | 694 | char bf[512]; |
| 651 | hist_entry__snprintf(self, bf, sizeof(bf), pair_hists, | 695 | hist_entry__snprintf(self, bf, sizeof(bf), hists, pair_hists, |
| 652 | show_displacement, displacement, | 696 | show_displacement, displacement, |
| 653 | true, session_total); | 697 | true, session_total); |
| 654 | return fprintf(fp, "%s\n", bf); | 698 | return fprintf(fp, "%s\n", bf); |
| 655 | } | 699 | } |
| 656 | 700 | ||
| 657 | static size_t hist_entry__fprintf_callchain(struct hist_entry *self, FILE *fp, | 701 | static size_t hist_entry__fprintf_callchain(struct hist_entry *self, |
| 702 | struct hists *hists, FILE *fp, | ||
| 658 | u64 session_total) | 703 | u64 session_total) |
| 659 | { | 704 | { |
| 660 | int left_margin = 0; | 705 | int left_margin = 0; |
| @@ -662,7 +707,7 @@ static size_t hist_entry__fprintf_callchain(struct hist_entry *self, FILE *fp, | |||
| 662 | if (sort__first_dimension == SORT_COMM) { | 707 | if (sort__first_dimension == SORT_COMM) { |
| 663 | struct sort_entry *se = list_first_entry(&hist_entry__sort_list, | 708 | struct sort_entry *se = list_first_entry(&hist_entry__sort_list, |
| 664 | typeof(*se), list); | 709 | typeof(*se), list); |
| 665 | left_margin = se->se_width ? *se->se_width : 0; | 710 | left_margin = hists__col_len(hists, se->se_width_idx); |
| 666 | left_margin -= thread__comm_len(self->thread); | 711 | left_margin -= thread__comm_len(self->thread); |
| 667 | } | 712 | } |
| 668 | 713 | ||
| @@ -733,17 +778,17 @@ size_t hists__fprintf(struct hists *self, struct hists *pair, | |||
| 733 | continue; | 778 | continue; |
| 734 | } | 779 | } |
| 735 | width = strlen(se->se_header); | 780 | width = strlen(se->se_header); |
| 736 | if (se->se_width) { | 781 | if (symbol_conf.col_width_list_str) { |
| 737 | if (symbol_conf.col_width_list_str) { | 782 | if (col_width) { |
| 738 | if (col_width) { | 783 | hists__set_col_len(self, se->se_width_idx, |
| 739 | *se->se_width = atoi(col_width); | 784 | atoi(col_width)); |
| 740 | col_width = strchr(col_width, ','); | 785 | col_width = strchr(col_width, ','); |
| 741 | if (col_width) | 786 | if (col_width) |
| 742 | ++col_width; | 787 | ++col_width; |
| 743 | } | ||
| 744 | } | 788 | } |
| 745 | width = *se->se_width = max(*se->se_width, width); | ||
| 746 | } | 789 | } |
| 790 | if (!hists__new_col_len(self, se->se_width_idx, width)) | ||
| 791 | width = hists__col_len(self, se->se_width_idx); | ||
| 747 | fprintf(fp, " %*s", width, se->se_header); | 792 | fprintf(fp, " %*s", width, se->se_header); |
| 748 | } | 793 | } |
| 749 | fprintf(fp, "\n"); | 794 | fprintf(fp, "\n"); |
| @@ -766,9 +811,8 @@ size_t hists__fprintf(struct hists *self, struct hists *pair, | |||
| 766 | continue; | 811 | continue; |
| 767 | 812 | ||
| 768 | fprintf(fp, " "); | 813 | fprintf(fp, " "); |
| 769 | if (se->se_width) | 814 | width = hists__col_len(self, se->se_width_idx); |
| 770 | width = *se->se_width; | 815 | if (width == 0) |
| 771 | else | ||
| 772 | width = strlen(se->se_header); | 816 | width = strlen(se->se_header); |
| 773 | for (i = 0; i < width; i++) | 817 | for (i = 0; i < width; i++) |
| 774 | fprintf(fp, "."); | 818 | fprintf(fp, "."); |
| @@ -788,12 +832,12 @@ print_entries: | |||
| 788 | displacement = 0; | 832 | displacement = 0; |
| 789 | ++position; | 833 | ++position; |
| 790 | } | 834 | } |
| 791 | ret += hist_entry__fprintf(h, pair, show_displacement, | 835 | ret += hist_entry__fprintf(h, self, pair, show_displacement, |
| 792 | displacement, fp, self->stats.total_period); | 836 | displacement, fp, self->stats.total_period); |
| 793 | 837 | ||
| 794 | if (symbol_conf.use_callchain) | 838 | if (symbol_conf.use_callchain) |
| 795 | ret += hist_entry__fprintf_callchain(h, fp, self->stats.total_period); | 839 | ret += hist_entry__fprintf_callchain(h, self, fp, |
| 796 | 840 | self->stats.total_period); | |
| 797 | if (h->ms.map == NULL && verbose > 1) { | 841 | if (h->ms.map == NULL && verbose > 1) { |
| 798 | __map_groups__fprintf_maps(&h->thread->mg, | 842 | __map_groups__fprintf_maps(&h->thread->mg, |
| 799 | MAP__FUNCTION, verbose, fp); | 843 | MAP__FUNCTION, verbose, fp); |
| @@ -817,8 +861,7 @@ static void hists__remove_entry_filter(struct hists *self, struct hist_entry *h, | |||
| 817 | self->stats.total_period += h->period; | 861 | self->stats.total_period += h->period; |
| 818 | self->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events; | 862 | self->stats.nr_events[PERF_RECORD_SAMPLE] += h->nr_events; |
| 819 | 863 | ||
| 820 | if (h->ms.sym && self->max_sym_namelen < h->ms.sym->namelen) | 864 | hists__calc_col_len(self, h); |
| 821 | self->max_sym_namelen = h->ms.sym->namelen; | ||
| 822 | } | 865 | } |
| 823 | 866 | ||
| 824 | void hists__filter_by_dso(struct hists *self, const struct dso *dso) | 867 | void hists__filter_by_dso(struct hists *self, const struct dso *dso) |
| @@ -827,7 +870,7 @@ void hists__filter_by_dso(struct hists *self, const struct dso *dso) | |||
| 827 | 870 | ||
| 828 | self->nr_entries = self->stats.total_period = 0; | 871 | self->nr_entries = self->stats.total_period = 0; |
| 829 | self->stats.nr_events[PERF_RECORD_SAMPLE] = 0; | 872 | self->stats.nr_events[PERF_RECORD_SAMPLE] = 0; |
| 830 | self->max_sym_namelen = 0; | 873 | hists__reset_col_len(self); |
| 831 | 874 | ||
| 832 | for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { | 875 | for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { |
| 833 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 876 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
| @@ -850,7 +893,7 @@ void hists__filter_by_thread(struct hists *self, const struct thread *thread) | |||
| 850 | 893 | ||
| 851 | self->nr_entries = self->stats.total_period = 0; | 894 | self->nr_entries = self->stats.total_period = 0; |
| 852 | self->stats.nr_events[PERF_RECORD_SAMPLE] = 0; | 895 | self->stats.nr_events[PERF_RECORD_SAMPLE] = 0; |
| 853 | self->max_sym_namelen = 0; | 896 | hists__reset_col_len(self); |
| 854 | 897 | ||
| 855 | for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { | 898 | for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { |
| 856 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 899 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 83fa33a7b38b..92962b2f579b 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
| @@ -56,6 +56,16 @@ struct events_stats { | |||
| 56 | u32 nr_unknown_events; | 56 | u32 nr_unknown_events; |
| 57 | }; | 57 | }; |
| 58 | 58 | ||
| 59 | enum hist_column { | ||
| 60 | HISTC_SYMBOL, | ||
| 61 | HISTC_DSO, | ||
| 62 | HISTC_THREAD, | ||
| 63 | HISTC_COMM, | ||
| 64 | HISTC_PARENT, | ||
| 65 | HISTC_CPU, | ||
| 66 | HISTC_NR_COLS, /* Last entry */ | ||
| 67 | }; | ||
| 68 | |||
| 59 | struct hists { | 69 | struct hists { |
| 60 | struct rb_node rb_node; | 70 | struct rb_node rb_node; |
| 61 | struct rb_root entries; | 71 | struct rb_root entries; |
| @@ -64,7 +74,7 @@ struct hists { | |||
| 64 | u64 config; | 74 | u64 config; |
| 65 | u64 event_stream; | 75 | u64 event_stream; |
| 66 | u32 type; | 76 | u32 type; |
| 67 | u32 max_sym_namelen; | 77 | u16 col_len[HISTC_NR_COLS]; |
| 68 | }; | 78 | }; |
| 69 | 79 | ||
| 70 | struct hist_entry *__hists__add_entry(struct hists *self, | 80 | struct hist_entry *__hists__add_entry(struct hists *self, |
| @@ -72,12 +82,13 @@ struct hist_entry *__hists__add_entry(struct hists *self, | |||
| 72 | struct symbol *parent, u64 period); | 82 | struct symbol *parent, u64 period); |
| 73 | extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *); | 83 | extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *); |
| 74 | extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *); | 84 | extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *); |
| 75 | int hist_entry__fprintf(struct hist_entry *self, struct hists *pair_hists, | 85 | int hist_entry__fprintf(struct hist_entry *self, struct hists *hists, |
| 76 | bool show_displacement, long displacement, FILE *fp, | 86 | struct hists *pair_hists, bool show_displacement, |
| 77 | u64 total); | 87 | long displacement, FILE *fp, u64 total); |
| 78 | int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size, | 88 | int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size, |
| 79 | struct hists *pair_hists, bool show_displacement, | 89 | struct hists *hists, struct hists *pair_hists, |
| 80 | long displacement, bool color, u64 total); | 90 | bool show_displacement, long displacement, |
| 91 | bool color, u64 total); | ||
| 81 | void hist_entry__free(struct hist_entry *); | 92 | void hist_entry__free(struct hist_entry *); |
| 82 | 93 | ||
| 83 | void hists__output_resort(struct hists *self); | 94 | void hists__output_resort(struct hists *self); |
| @@ -95,6 +106,10 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head); | |||
| 95 | void hists__filter_by_dso(struct hists *self, const struct dso *dso); | 106 | void hists__filter_by_dso(struct hists *self, const struct dso *dso); |
| 96 | void hists__filter_by_thread(struct hists *self, const struct thread *thread); | 107 | void hists__filter_by_thread(struct hists *self, const struct thread *thread); |
| 97 | 108 | ||
| 109 | u16 hists__col_len(struct hists *self, enum hist_column col); | ||
| 110 | void hists__set_col_len(struct hists *self, enum hist_column col, u16 len); | ||
| 111 | bool hists__new_col_len(struct hists *self, enum hist_column col, u16 len); | ||
| 112 | |||
| 98 | #ifdef NO_NEWT_SUPPORT | 113 | #ifdef NO_NEWT_SUPPORT |
| 99 | static inline int hists__browse(struct hists *self __used, | 114 | static inline int hists__browse(struct hists *self __used, |
| 100 | const char *helpline __used, | 115 | const char *helpline __used, |
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c index 7979003adeaf..ab6eb368cbf5 100644 --- a/tools/perf/util/newt.c +++ b/tools/perf/util/newt.c | |||
| @@ -692,7 +692,8 @@ static void hist_entry__append_callchain_browser(struct hist_entry *self, | |||
| 692 | } | 692 | } |
| 693 | 693 | ||
| 694 | static size_t hist_entry__append_browser(struct hist_entry *self, | 694 | static size_t hist_entry__append_browser(struct hist_entry *self, |
| 695 | newtComponent tree, u64 total) | 695 | newtComponent tree, |
| 696 | struct hists *hists) | ||
| 696 | { | 697 | { |
| 697 | char s[256]; | 698 | char s[256]; |
| 698 | size_t ret; | 699 | size_t ret; |
| @@ -700,8 +701,8 @@ static size_t hist_entry__append_browser(struct hist_entry *self, | |||
| 700 | if (symbol_conf.exclude_other && !self->parent) | 701 | if (symbol_conf.exclude_other && !self->parent) |
| 701 | return 0; | 702 | return 0; |
| 702 | 703 | ||
| 703 | ret = hist_entry__snprintf(self, s, sizeof(s), NULL, | 704 | ret = hist_entry__snprintf(self, s, sizeof(s), hists, NULL, |
| 704 | false, 0, false, total); | 705 | false, 0, false, hists->stats.total_period); |
| 705 | if (symbol_conf.use_callchain) { | 706 | if (symbol_conf.use_callchain) { |
| 706 | int indexes[2]; | 707 | int indexes[2]; |
| 707 | 708 | ||
| @@ -842,7 +843,7 @@ static int hist_browser__populate(struct hist_browser *self, struct hists *hists | |||
| 842 | if (h->filtered) | 843 | if (h->filtered) |
| 843 | continue; | 844 | continue; |
| 844 | 845 | ||
| 845 | len = hist_entry__append_browser(h, self->tree, hists->stats.total_period); | 846 | len = hist_entry__append_browser(h, self->tree, hists); |
| 846 | if (len > max_len) | 847 | if (len > max_len) |
| 847 | max_len = len; | 848 | max_len = len; |
| 848 | if (symbol_conf.use_callchain) | 849 | if (symbol_conf.use_callchain) |
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c index c27b4b03fbc1..1c61a4f4aa8a 100644 --- a/tools/perf/util/sort.c +++ b/tools/perf/util/sort.c | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #include "sort.h" | 1 | #include "sort.h" |
| 2 | #include "hist.h" | ||
| 2 | 3 | ||
| 3 | regex_t parent_regex; | 4 | regex_t parent_regex; |
| 4 | const char default_parent_pattern[] = "^sys_|^do_page_fault"; | 5 | const char default_parent_pattern[] = "^sys_|^do_page_fault"; |
| @@ -10,11 +11,6 @@ int sort__has_parent = 0; | |||
| 10 | 11 | ||
| 11 | enum sort_type sort__first_dimension; | 12 | enum sort_type sort__first_dimension; |
| 12 | 13 | ||
| 13 | unsigned int dsos__col_width; | ||
| 14 | unsigned int comms__col_width; | ||
| 15 | unsigned int threads__col_width; | ||
| 16 | unsigned int cpus__col_width; | ||
| 17 | static unsigned int parent_symbol__col_width; | ||
| 18 | char * field_sep; | 14 | char * field_sep; |
| 19 | 15 | ||
| 20 | LIST_HEAD(hist_entry__sort_list); | 16 | LIST_HEAD(hist_entry__sort_list); |
| @@ -36,7 +32,7 @@ struct sort_entry sort_thread = { | |||
| 36 | .se_header = "Command: Pid", | 32 | .se_header = "Command: Pid", |
| 37 | .se_cmp = sort__thread_cmp, | 33 | .se_cmp = sort__thread_cmp, |
| 38 | .se_snprintf = hist_entry__thread_snprintf, | 34 | .se_snprintf = hist_entry__thread_snprintf, |
| 39 | .se_width = &threads__col_width, | 35 | .se_width_idx = HISTC_THREAD, |
| 40 | }; | 36 | }; |
| 41 | 37 | ||
| 42 | struct sort_entry sort_comm = { | 38 | struct sort_entry sort_comm = { |
| @@ -44,34 +40,35 @@ struct sort_entry sort_comm = { | |||
| 44 | .se_cmp = sort__comm_cmp, | 40 | .se_cmp = sort__comm_cmp, |
| 45 | .se_collapse = sort__comm_collapse, | 41 | .se_collapse = sort__comm_collapse, |
| 46 | .se_snprintf = hist_entry__comm_snprintf, | 42 | .se_snprintf = hist_entry__comm_snprintf, |
| 47 | .se_width = &comms__col_width, | 43 | .se_width_idx = HISTC_COMM, |
| 48 | }; | 44 | }; |
| 49 | 45 | ||
| 50 | struct sort_entry sort_dso = { | 46 | struct sort_entry sort_dso = { |
| 51 | .se_header = "Shared Object", | 47 | .se_header = "Shared Object", |
| 52 | .se_cmp = sort__dso_cmp, | 48 | .se_cmp = sort__dso_cmp, |
| 53 | .se_snprintf = hist_entry__dso_snprintf, | 49 | .se_snprintf = hist_entry__dso_snprintf, |
| 54 | .se_width = &dsos__col_width, | 50 | .se_width_idx = HISTC_DSO, |
| 55 | }; | 51 | }; |
| 56 | 52 | ||
| 57 | struct sort_entry sort_sym = { | 53 | struct sort_entry sort_sym = { |
| 58 | .se_header = "Symbol", | 54 | .se_header = "Symbol", |
| 59 | .se_cmp = sort__sym_cmp, | 55 | .se_cmp = sort__sym_cmp, |
| 60 | .se_snprintf = hist_entry__sym_snprintf, | 56 | .se_snprintf = hist_entry__sym_snprintf, |
| 57 | .se_width_idx = HISTC_SYMBOL, | ||
| 61 | }; | 58 | }; |
| 62 | 59 | ||
| 63 | struct sort_entry sort_parent = { | 60 | struct sort_entry sort_parent = { |
| 64 | .se_header = "Parent symbol", | 61 | .se_header = "Parent symbol", |
| 65 | .se_cmp = sort__parent_cmp, | 62 | .se_cmp = sort__parent_cmp, |
| 66 | .se_snprintf = hist_entry__parent_snprintf, | 63 | .se_snprintf = hist_entry__parent_snprintf, |
| 67 | .se_width = &parent_symbol__col_width, | 64 | .se_width_idx = HISTC_PARENT, |
| 68 | }; | 65 | }; |
| 69 | 66 | ||
| 70 | struct sort_entry sort_cpu = { | 67 | struct sort_entry sort_cpu = { |
| 71 | .se_header = "CPU", | 68 | .se_header = "CPU", |
| 72 | .se_cmp = sort__cpu_cmp, | 69 | .se_cmp = sort__cpu_cmp, |
| 73 | .se_snprintf = hist_entry__cpu_snprintf, | 70 | .se_snprintf = hist_entry__cpu_snprintf, |
| 74 | .se_width = &cpus__col_width, | 71 | .se_width_idx = HISTC_CPU, |
| 75 | }; | 72 | }; |
| 76 | 73 | ||
| 77 | struct sort_dimension { | 74 | struct sort_dimension { |
diff --git a/tools/perf/util/sort.h b/tools/perf/util/sort.h index 560c855417e4..03a1722e6d02 100644 --- a/tools/perf/util/sort.h +++ b/tools/perf/util/sort.h | |||
| @@ -36,10 +36,6 @@ extern struct sort_entry sort_comm; | |||
| 36 | extern struct sort_entry sort_dso; | 36 | extern struct sort_entry sort_dso; |
| 37 | extern struct sort_entry sort_sym; | 37 | extern struct sort_entry sort_sym; |
| 38 | extern struct sort_entry sort_parent; | 38 | extern struct sort_entry sort_parent; |
| 39 | extern unsigned int dsos__col_width; | ||
| 40 | extern unsigned int comms__col_width; | ||
| 41 | extern unsigned int threads__col_width; | ||
| 42 | extern unsigned int cpus__col_width; | ||
| 43 | extern enum sort_type sort__first_dimension; | 39 | extern enum sort_type sort__first_dimension; |
| 44 | 40 | ||
| 45 | struct hist_entry { | 41 | struct hist_entry { |
| @@ -87,7 +83,7 @@ struct sort_entry { | |||
| 87 | int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); | 83 | int64_t (*se_collapse)(struct hist_entry *, struct hist_entry *); |
| 88 | int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size, | 84 | int (*se_snprintf)(struct hist_entry *self, char *bf, size_t size, |
| 89 | unsigned int width); | 85 | unsigned int width); |
| 90 | unsigned int *se_width; | 86 | u8 se_width_idx; |
| 91 | bool elide; | 87 | bool elide; |
| 92 | }; | 88 | }; |
| 93 | 89 | ||
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 971d0a05d6b4..bc6e7e8c480d 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <fcntl.h> | 12 | #include <fcntl.h> |
| 13 | #include <unistd.h> | 13 | #include <unistd.h> |
| 14 | #include "build-id.h" | 14 | #include "build-id.h" |
| 15 | #include "debug.h" | ||
| 15 | #include "symbol.h" | 16 | #include "symbol.h" |
| 16 | #include "strlist.h" | 17 | #include "strlist.h" |
| 17 | 18 | ||
| @@ -40,6 +41,14 @@ struct symbol_conf symbol_conf = { | |||
| 40 | .try_vmlinux_path = true, | 41 | .try_vmlinux_path = true, |
| 41 | }; | 42 | }; |
| 42 | 43 | ||
| 44 | int dso__name_len(const struct dso *self) | ||
| 45 | { | ||
| 46 | if (verbose) | ||
| 47 | return self->long_name_len; | ||
| 48 | |||
| 49 | return self->short_name_len; | ||
| 50 | } | ||
| 51 | |||
| 43 | bool dso__loaded(const struct dso *self, enum map_type type) | 52 | bool dso__loaded(const struct dso *self, enum map_type type) |
| 44 | { | 53 | { |
| 45 | return self->loaded & (1 << type); | 54 | return self->loaded & (1 << type); |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 80e569bbdecc..d436ee3d3a73 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
| @@ -146,6 +146,8 @@ struct dso *dso__new(const char *name); | |||
| 146 | struct dso *dso__new_kernel(const char *name); | 146 | struct dso *dso__new_kernel(const char *name); |
| 147 | void dso__delete(struct dso *self); | 147 | void dso__delete(struct dso *self); |
| 148 | 148 | ||
| 149 | int dso__name_len(const struct dso *self); | ||
| 150 | |||
| 149 | bool dso__loaded(const struct dso *self, enum map_type type); | 151 | bool dso__loaded(const struct dso *self, enum map_type type); |
| 150 | bool dso__sorted_by_name(const struct dso *self, enum map_type type); | 152 | bool dso__sorted_by_name(const struct dso *self, enum map_type type); |
| 151 | 153 | ||
