diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-03-10 03:43:52 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-03-14 17:08:40 -0400 |
commit | 94a0793ddf7fa9890006a8dc203b985e7b120785 (patch) | |
tree | 720b78163960b35bb0d2eed1254a39cd6fefe8b4 /tools | |
parent | 52a3cb8cfca16db73cf825cb94325cf54da8304f (diff) |
perf ui hists: Pass evsel to hpp->header/width functions explicitly
Those functions need evsel to investigate event group and it's passed
via hpp->ptr. However as it can be missed easily so it's better to
pass it via an argument IMHO.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1394437440-11609-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-diff.c | 7 | ||||
-rw-r--r-- | tools/perf/ui/gtk/hists.c | 3 | ||||
-rw-r--r-- | tools/perf/ui/hist.c | 24 | ||||
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 5 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 6 |
5 files changed, 21 insertions, 24 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index a77e31246c00..204fffe22532 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -952,8 +952,8 @@ static int hpp__entry_global(struct perf_hpp_fmt *_fmt, struct perf_hpp *hpp, | |||
952 | dfmt->header_width, buf); | 952 | dfmt->header_width, buf); |
953 | } | 953 | } |
954 | 954 | ||
955 | static int hpp__header(struct perf_hpp_fmt *fmt, | 955 | static int hpp__header(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, |
956 | struct perf_hpp *hpp) | 956 | struct perf_evsel *evsel __maybe_unused) |
957 | { | 957 | { |
958 | struct diff_hpp_fmt *dfmt = | 958 | struct diff_hpp_fmt *dfmt = |
959 | container_of(fmt, struct diff_hpp_fmt, fmt); | 959 | container_of(fmt, struct diff_hpp_fmt, fmt); |
@@ -963,7 +963,8 @@ static int hpp__header(struct perf_hpp_fmt *fmt, | |||
963 | } | 963 | } |
964 | 964 | ||
965 | static int hpp__width(struct perf_hpp_fmt *fmt, | 965 | static int hpp__width(struct perf_hpp_fmt *fmt, |
966 | struct perf_hpp *hpp __maybe_unused) | 966 | struct perf_hpp *hpp __maybe_unused, |
967 | struct perf_evsel *evsel __maybe_unused) | ||
967 | { | 968 | { |
968 | struct diff_hpp_fmt *dfmt = | 969 | struct diff_hpp_fmt *dfmt = |
969 | container_of(fmt, struct diff_hpp_fmt, fmt); | 970 | container_of(fmt, struct diff_hpp_fmt, fmt); |
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index 7912dab6e5fb..e395ef9b0ae0 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c | |||
@@ -165,7 +165,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, | |||
165 | struct perf_hpp hpp = { | 165 | struct perf_hpp hpp = { |
166 | .buf = s, | 166 | .buf = s, |
167 | .size = sizeof(s), | 167 | .size = sizeof(s), |
168 | .ptr = hists_to_evsel(hists), | ||
169 | }; | 168 | }; |
170 | 169 | ||
171 | nr_cols = 0; | 170 | nr_cols = 0; |
@@ -192,7 +191,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, | |||
192 | col_idx = 0; | 191 | col_idx = 0; |
193 | 192 | ||
194 | perf_hpp__for_each_format(fmt) { | 193 | perf_hpp__for_each_format(fmt) { |
195 | fmt->header(fmt, &hpp); | 194 | fmt->header(fmt, &hpp, hists_to_evsel(hists)); |
196 | 195 | ||
197 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), | 196 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), |
198 | -1, ltrim(s), | 197 | -1, ltrim(s), |
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index ac39313a3f0c..0f403b83e9d1 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -118,29 +118,27 @@ int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he, | |||
118 | 118 | ||
119 | #define __HPP_HEADER_FN(_type, _str, _min_width, _unit_width) \ | 119 | #define __HPP_HEADER_FN(_type, _str, _min_width, _unit_width) \ |
120 | static int hpp__header_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ | 120 | static int hpp__header_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ |
121 | struct perf_hpp *hpp) \ | 121 | struct perf_hpp *hpp, \ |
122 | struct perf_evsel *evsel) \ | ||
122 | { \ | 123 | { \ |
123 | int len = _min_width; \ | 124 | int len = _min_width; \ |
124 | \ | 125 | \ |
125 | if (symbol_conf.event_group) { \ | 126 | if (symbol_conf.event_group) \ |
126 | struct perf_evsel *evsel = hpp->ptr; \ | ||
127 | \ | ||
128 | len = max(len, evsel->nr_members * _unit_width); \ | 127 | len = max(len, evsel->nr_members * _unit_width); \ |
129 | } \ | 128 | \ |
130 | return scnprintf(hpp->buf, hpp->size, "%*s", len, _str); \ | 129 | return scnprintf(hpp->buf, hpp->size, "%*s", len, _str); \ |
131 | } | 130 | } |
132 | 131 | ||
133 | #define __HPP_WIDTH_FN(_type, _min_width, _unit_width) \ | 132 | #define __HPP_WIDTH_FN(_type, _min_width, _unit_width) \ |
134 | static int hpp__width_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ | 133 | static int hpp__width_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \ |
135 | struct perf_hpp *hpp __maybe_unused) \ | 134 | struct perf_hpp *hpp __maybe_unused, \ |
135 | struct perf_evsel *evsel) \ | ||
136 | { \ | 136 | { \ |
137 | int len = _min_width; \ | 137 | int len = _min_width; \ |
138 | \ | 138 | \ |
139 | if (symbol_conf.event_group) { \ | 139 | if (symbol_conf.event_group) \ |
140 | struct perf_evsel *evsel = hpp->ptr; \ | ||
141 | \ | ||
142 | len = max(len, evsel->nr_members * _unit_width); \ | 140 | len = max(len, evsel->nr_members * _unit_width); \ |
143 | } \ | 141 | \ |
144 | return len; \ | 142 | return len; \ |
145 | } | 143 | } |
146 | 144 | ||
@@ -329,15 +327,13 @@ unsigned int hists__sort_list_width(struct hists *hists) | |||
329 | struct perf_hpp_fmt *fmt; | 327 | struct perf_hpp_fmt *fmt; |
330 | struct sort_entry *se; | 328 | struct sort_entry *se; |
331 | int i = 0, ret = 0; | 329 | int i = 0, ret = 0; |
332 | struct perf_hpp dummy_hpp = { | 330 | struct perf_hpp dummy_hpp; |
333 | .ptr = hists_to_evsel(hists), | ||
334 | }; | ||
335 | 331 | ||
336 | perf_hpp__for_each_format(fmt) { | 332 | perf_hpp__for_each_format(fmt) { |
337 | if (i) | 333 | if (i) |
338 | ret += 2; | 334 | ret += 2; |
339 | 335 | ||
340 | ret += fmt->width(fmt, &dummy_hpp); | 336 | ret += fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists)); |
341 | } | 337 | } |
342 | 338 | ||
343 | list_for_each_entry(se, &hist_entry__sort_list, list) | 339 | list_for_each_entry(se, &hist_entry__sort_list, list) |
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 9bad89228472..d59893edf031 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -379,7 +379,6 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | |||
379 | struct perf_hpp dummy_hpp = { | 379 | struct perf_hpp dummy_hpp = { |
380 | .buf = bf, | 380 | .buf = bf, |
381 | .size = sizeof(bf), | 381 | .size = sizeof(bf), |
382 | .ptr = hists_to_evsel(hists), | ||
383 | }; | 382 | }; |
384 | bool first = true; | 383 | bool first = true; |
385 | size_t linesz; | 384 | size_t linesz; |
@@ -398,7 +397,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | |||
398 | else | 397 | else |
399 | first = false; | 398 | first = false; |
400 | 399 | ||
401 | fmt->header(fmt, &dummy_hpp); | 400 | fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists)); |
402 | fprintf(fp, "%s", bf); | 401 | fprintf(fp, "%s", bf); |
403 | } | 402 | } |
404 | 403 | ||
@@ -443,7 +442,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | |||
443 | else | 442 | else |
444 | first = false; | 443 | first = false; |
445 | 444 | ||
446 | width = fmt->width(fmt, &dummy_hpp); | 445 | width = fmt->width(fmt, &dummy_hpp, hists_to_evsel(hists)); |
447 | for (i = 0; i < width; i++) | 446 | for (i = 0; i < width; i++) |
448 | fprintf(fp, "."); | 447 | fprintf(fp, "."); |
449 | } | 448 | } |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 9e1cada45bb8..0c76bf972736 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -132,8 +132,10 @@ struct perf_hpp { | |||
132 | }; | 132 | }; |
133 | 133 | ||
134 | struct perf_hpp_fmt { | 134 | struct perf_hpp_fmt { |
135 | int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp); | 135 | int (*header)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, |
136 | int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp); | 136 | struct perf_evsel *evsel); |
137 | int (*width)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, | ||
138 | struct perf_evsel *evsel); | ||
137 | int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, | 139 | int (*color)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, |
138 | struct hist_entry *he); | 140 | struct hist_entry *he); |
139 | int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, | 141 | int (*entry)(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, |