aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-diff.c2
-rw-r--r--tools/perf/builtin-report.c2
-rw-r--r--tools/perf/util/hist.c33
-rw-r--r--tools/perf/util/hist.h7
4 files changed, 33 insertions, 11 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index e8219990f8b8..b39f3a1ee7dc 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -162,7 +162,7 @@ static int __cmd_diff(void)
162 162
163 hists__match(&session[0]->hists, &session[1]->hists); 163 hists__match(&session[0]->hists, &session[1]->hists);
164 hists__fprintf(&session[1]->hists, &session[0]->hists, 164 hists__fprintf(&session[1]->hists, &session[0]->hists,
165 show_displacement, stdout); 165 show_displacement, true, 0, 0, stdout);
166out_delete: 166out_delete:
167 for (i = 0; i < 2; ++i) 167 for (i = 0; i < 2; ++i)
168 perf_session__delete(session[i]); 168 perf_session__delete(session[i]);
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 3d58334909a5..b125742e5cfd 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -232,7 +232,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
232 const char *evname = event_name(pos); 232 const char *evname = event_name(pos);
233 233
234 hists__fprintf_nr_sample_events(hists, evname, stdout); 234 hists__fprintf_nr_sample_events(hists, evname, stdout);
235 hists__fprintf(hists, NULL, false, stdout); 235 hists__fprintf(hists, NULL, false, true, 0, 0, stdout);
236 fprintf(stdout, "\n\n"); 236 fprintf(stdout, "\n\n");
237 } 237 }
238 238
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index dd277897ff0b..24cca0a7ffa3 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -710,12 +710,16 @@ int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size,
710 return ret; 710 return ret;
711} 711}
712 712
713int hist_entry__fprintf(struct hist_entry *self, struct hists *hists, 713int hist_entry__fprintf(struct hist_entry *he, size_t size, struct hists *hists,
714 struct hists *pair_hists, bool show_displacement, 714 struct hists *pair_hists, bool show_displacement,
715 long displacement, FILE *fp, u64 session_total) 715 long displacement, FILE *fp, u64 session_total)
716{ 716{
717 char bf[512]; 717 char bf[512];
718 hist_entry__snprintf(self, bf, sizeof(bf), hists, pair_hists, 718
719 if (size == 0 || size > sizeof(bf))
720 size = sizeof(bf);
721
722 hist_entry__snprintf(he, bf, size, hists, pair_hists,
719 show_displacement, displacement, 723 show_displacement, displacement,
720 true, session_total); 724 true, session_total);
721 return fprintf(fp, "%s\n", bf); 725 return fprintf(fp, "%s\n", bf);
@@ -739,7 +743,8 @@ static size_t hist_entry__fprintf_callchain(struct hist_entry *self,
739} 743}
740 744
741size_t hists__fprintf(struct hists *hists, struct hists *pair, 745size_t hists__fprintf(struct hists *hists, struct hists *pair,
742 bool show_displacement, FILE *fp) 746 bool show_displacement, bool show_header, int max_rows,
747 int max_cols, FILE *fp)
743{ 748{
744 struct sort_entry *se; 749 struct sort_entry *se;
745 struct rb_node *nd; 750 struct rb_node *nd;
@@ -749,9 +754,13 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
749 unsigned int width; 754 unsigned int width;
750 const char *sep = symbol_conf.field_sep; 755 const char *sep = symbol_conf.field_sep;
751 const char *col_width = symbol_conf.col_width_list_str; 756 const char *col_width = symbol_conf.col_width_list_str;
757 int nr_rows = 0;
752 758
753 init_rem_hits(); 759 init_rem_hits();
754 760
761 if (!show_header)
762 goto print_entries;
763
755 fprintf(fp, "# %s", pair ? "Baseline" : "Overhead"); 764 fprintf(fp, "# %s", pair ? "Baseline" : "Overhead");
756 765
757 if (symbol_conf.show_nr_samples) { 766 if (symbol_conf.show_nr_samples) {
@@ -814,7 +823,10 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
814 width = hists__col_len(hists, se->se_width_idx); 823 width = hists__col_len(hists, se->se_width_idx);
815 fprintf(fp, " %*s", width, se->se_header); 824 fprintf(fp, " %*s", width, se->se_header);
816 } 825 }
826
817 fprintf(fp, "\n"); 827 fprintf(fp, "\n");
828 if (max_rows && ++nr_rows >= max_rows)
829 goto out;
818 830
819 if (sep) 831 if (sep)
820 goto print_entries; 832 goto print_entries;
@@ -841,7 +853,13 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
841 fprintf(fp, "."); 853 fprintf(fp, ".");
842 } 854 }
843 855
844 fprintf(fp, "\n#\n"); 856 fprintf(fp, "\n");
857 if (max_rows && ++nr_rows >= max_rows)
858 goto out;
859
860 fprintf(fp, "#\n");
861 if (max_rows && ++nr_rows >= max_rows)
862 goto out;
845 863
846print_entries: 864print_entries:
847 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { 865 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
@@ -858,19 +876,22 @@ print_entries:
858 displacement = 0; 876 displacement = 0;
859 ++position; 877 ++position;
860 } 878 }
861 ret += hist_entry__fprintf(h, hists, pair, show_displacement, 879 ret += hist_entry__fprintf(h, max_cols, hists, pair, show_displacement,
862 displacement, fp, hists->stats.total_period); 880 displacement, fp, hists->stats.total_period);
863 881
864 if (symbol_conf.use_callchain) 882 if (symbol_conf.use_callchain)
865 ret += hist_entry__fprintf_callchain(h, hists, fp, 883 ret += hist_entry__fprintf_callchain(h, hists, fp,
866 hists->stats.total_period); 884 hists->stats.total_period);
885 if (max_rows && ++nr_rows >= max_rows)
886 goto out;
887
867 if (h->ms.map == NULL && verbose > 1) { 888 if (h->ms.map == NULL && verbose > 1) {
868 __map_groups__fprintf_maps(&h->thread->mg, 889 __map_groups__fprintf_maps(&h->thread->mg,
869 MAP__FUNCTION, verbose, fp); 890 MAP__FUNCTION, verbose, fp);
870 fprintf(fp, "%.10s end\n", graph_dotted_line); 891 fprintf(fp, "%.10s end\n", graph_dotted_line);
871 } 892 }
872 } 893 }
873 894out:
874 free(rem_sq_bracket); 895 free(rem_sq_bracket);
875 896
876 return ret; 897 return ret;
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 3beb97c4d822..861ffc31db96 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -57,9 +57,9 @@ struct hist_entry *__hists__add_entry(struct hists *self,
57 struct symbol *parent, u64 period); 57 struct symbol *parent, u64 period);
58extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *); 58extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *);
59extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *); 59extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *);
60int hist_entry__fprintf(struct hist_entry *self, struct hists *hists, 60int hist_entry__fprintf(struct hist_entry *he, size_t size, struct hists *hists,
61 struct hists *pair_hists, bool show_displacement, 61 struct hists *pair_hists, bool show_displacement,
62 long displacement, FILE *fp, u64 total); 62 long displacement, FILE *fp, u64 session_total);
63int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size, 63int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size,
64 struct hists *hists, struct hists *pair_hists, 64 struct hists *hists, struct hists *pair_hists,
65 bool show_displacement, long displacement, 65 bool show_displacement, long displacement,
@@ -73,7 +73,8 @@ void hists__inc_nr_events(struct hists *self, u32 type);
73size_t hists__fprintf_nr_events(struct hists *self, FILE *fp); 73size_t hists__fprintf_nr_events(struct hists *self, FILE *fp);
74 74
75size_t hists__fprintf(struct hists *self, struct hists *pair, 75size_t hists__fprintf(struct hists *self, struct hists *pair,
76 bool show_displacement, FILE *fp); 76 bool show_displacement, bool show_header,
77 int max_rows, int max_cols, FILE *fp);
77 78
78int hist_entry__inc_addr_samples(struct hist_entry *self, int evidx, u64 addr); 79int hist_entry__inc_addr_samples(struct hist_entry *self, int evidx, u64 addr);
79int hist_entry__annotate(struct hist_entry *self, size_t privsize); 80int hist_entry__annotate(struct hist_entry *self, size_t privsize);