aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2013-01-31 17:31:11 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-07-12 12:53:57 -0400
commit2c5d4b4a087c448d7818b89294c98d4977dfe76c (patch)
tree78a9c1ae951002fe5861684a8e539cdb4fc4e4a4 /tools/perf/ui
parentb21484f1a1f300d422cfe5d4f8f50015e22cea24 (diff)
perf tools: Add struct perf_hpp_fmt into hpp callbacks
Adding 'struct perf_hpp_fmt' into hpp callbacks, so commands can access their private data. It'll be handy for diff command in future to be able to access file related data for each column. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/n/tip-7vy2m18574b1bicoljn8e9lw@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r--tools/perf/ui/browsers/hists.c10
-rw-r--r--tools/perf/ui/gtk/hists.c9
-rw-r--r--tools/perf/ui/hist.c79
-rw-r--r--tools/perf/ui/stdio/hist.c4
4 files changed, 65 insertions, 37 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 06e892f1f8ca..2cb39164a1cd 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -685,8 +685,10 @@ static u64 __hpp_get_##_field(struct hist_entry *he) \
685 return he->stat._field; \ 685 return he->stat._field; \
686} \ 686} \
687 \ 687 \
688static int hist_browser__hpp_color_##_type(struct perf_hpp *hpp, \ 688static int \
689 struct hist_entry *he) \ 689hist_browser__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused,\
690 struct perf_hpp *hpp, \
691 struct hist_entry *he) \
690{ \ 692{ \
691 return __hpp__color_fmt(hpp, he, __hpp_get_##_field, _cb); \ 693 return __hpp__color_fmt(hpp, he, __hpp_get_##_field, _cb); \
692} 694}
@@ -762,9 +764,9 @@ static int hist_browser__show_entry(struct hist_browser *browser,
762 first = false; 764 first = false;
763 765
764 if (fmt->color) { 766 if (fmt->color) {
765 width -= fmt->color(&hpp, entry); 767 width -= fmt->color(fmt, &hpp, entry);
766 } else { 768 } else {
767 width -= fmt->entry(&hpp, entry); 769 width -= fmt->entry(fmt, &hpp, entry);
768 slsmg_printf("%s", s); 770 slsmg_printf("%s", s);
769 } 771 }
770 } 772 }
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
index 32549035f50d..cb2ed1980147 100644
--- a/tools/perf/ui/gtk/hists.c
+++ b/tools/perf/ui/gtk/hists.c
@@ -91,7 +91,8 @@ static u64 he_get_##_field(struct hist_entry *he) \
91 return he->stat._field; \ 91 return he->stat._field; \
92} \ 92} \
93 \ 93 \
94static int perf_gtk__hpp_color_##_type(struct perf_hpp *hpp, \ 94static int perf_gtk__hpp_color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \
95 struct perf_hpp *hpp, \
95 struct hist_entry *he) \ 96 struct hist_entry *he) \
96{ \ 97{ \
97 return __hpp__color_fmt(hpp, he, he_get_##_field); \ 98 return __hpp__color_fmt(hpp, he, he_get_##_field); \
@@ -244,7 +245,7 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
244 col_idx = 0; 245 col_idx = 0;
245 246
246 perf_hpp__for_each_format(fmt) { 247 perf_hpp__for_each_format(fmt) {
247 fmt->header(&hpp); 248 fmt->header(fmt, &hpp);
248 249
249 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), 250 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),
250 -1, ltrim(s), 251 -1, ltrim(s),
@@ -296,9 +297,9 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists,
296 297
297 perf_hpp__for_each_format(fmt) { 298 perf_hpp__for_each_format(fmt) {
298 if (fmt->color) 299 if (fmt->color)
299 fmt->color(&hpp, h); 300 fmt->color(fmt, &hpp, h);
300 else 301 else
301 fmt->entry(&hpp, h); 302 fmt->entry(fmt, &hpp, h);
302 303
303 gtk_tree_store_set(store, &iter, col_idx++, s, -1); 304 gtk_tree_store_set(store, &iter, col_idx++, s, -1);
304 } 305 }
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 4bf91b09d62d..5440d56d884a 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -1,4 +1,5 @@
1#include <math.h> 1#include <math.h>
2#include <linux/compiler.h>
2 3
3#include "../util/hist.h" 4#include "../util/hist.h"
4#include "../util/util.h" 5#include "../util/util.h"
@@ -79,7 +80,8 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
79} 80}
80 81
81#define __HPP_HEADER_FN(_type, _str, _min_width, _unit_width) \ 82#define __HPP_HEADER_FN(_type, _str, _min_width, _unit_width) \
82static int hpp__header_##_type(struct perf_hpp *hpp) \ 83static int hpp__header_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \
84 struct perf_hpp *hpp) \
83{ \ 85{ \
84 int len = _min_width; \ 86 int len = _min_width; \
85 \ 87 \
@@ -92,7 +94,8 @@ static int hpp__header_##_type(struct perf_hpp *hpp) \
92} 94}
93 95
94#define __HPP_WIDTH_FN(_type, _min_width, _unit_width) \ 96#define __HPP_WIDTH_FN(_type, _min_width, _unit_width) \
95static int hpp__width_##_type(struct perf_hpp *hpp __maybe_unused) \ 97static int hpp__width_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \
98 struct perf_hpp *hpp __maybe_unused) \
96{ \ 99{ \
97 int len = _min_width; \ 100 int len = _min_width; \
98 \ 101 \
@@ -110,14 +113,16 @@ static u64 he_get_##_field(struct hist_entry *he) \
110 return he->stat._field; \ 113 return he->stat._field; \
111} \ 114} \
112 \ 115 \
113static int hpp__color_##_type(struct perf_hpp *hpp, struct hist_entry *he) \ 116static int hpp__color_##_type(struct perf_hpp_fmt *fmt __maybe_unused, \
117 struct perf_hpp *hpp, struct hist_entry *he) \
114{ \ 118{ \
115 return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \ 119 return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \
116 (hpp_snprint_fn)percent_color_snprintf, true); \ 120 (hpp_snprint_fn)percent_color_snprintf, true); \
117} 121}
118 122
119#define __HPP_ENTRY_PERCENT_FN(_type, _field) \ 123#define __HPP_ENTRY_PERCENT_FN(_type, _field) \
120static int hpp__entry_##_type(struct perf_hpp *hpp, struct hist_entry *he) \ 124static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused, \
125 struct perf_hpp *hpp, struct hist_entry *he) \
121{ \ 126{ \
122 const char *fmt = symbol_conf.field_sep ? " %.2f" : " %6.2f%%"; \ 127 const char *fmt = symbol_conf.field_sep ? " %.2f" : " %6.2f%%"; \
123 return __hpp__fmt(hpp, he, he_get_##_field, fmt, \ 128 return __hpp__fmt(hpp, he, he_get_##_field, fmt, \
@@ -130,7 +135,8 @@ static u64 he_get_raw_##_field(struct hist_entry *he) \
130 return he->stat._field; \ 135 return he->stat._field; \
131} \ 136} \
132 \ 137 \
133static int hpp__entry_##_type(struct perf_hpp *hpp, struct hist_entry *he) \ 138static int hpp__entry_##_type(struct perf_hpp_fmt *_fmt __maybe_unused, \
139 struct perf_hpp *hpp, struct hist_entry *he) \
134{ \ 140{ \
135 const char *fmt = symbol_conf.field_sep ? " %"PRIu64 : " %11"PRIu64; \ 141 const char *fmt = symbol_conf.field_sep ? " %"PRIu64 : " %11"PRIu64; \
136 return __hpp__fmt(hpp, he, he_get_raw_##_field, fmt, scnprintf, false); \ 142 return __hpp__fmt(hpp, he, he_get_raw_##_field, fmt, scnprintf, false); \
@@ -158,12 +164,14 @@ HPP_RAW_FNS(samples, "Samples", nr_events, 12, 12)
158HPP_RAW_FNS(period, "Period", period, 12, 12) 164HPP_RAW_FNS(period, "Period", period, 12, 12)
159 165
160 166
161static int hpp__header_baseline(struct perf_hpp *hpp) 167static int hpp__header_baseline(struct perf_hpp_fmt *fmt __maybe_unused,
168 struct perf_hpp *hpp)
162{ 169{
163 return scnprintf(hpp->buf, hpp->size, "Baseline"); 170 return scnprintf(hpp->buf, hpp->size, "Baseline");
164} 171}
165 172
166static int hpp__width_baseline(struct perf_hpp *hpp __maybe_unused) 173static int hpp__width_baseline(struct perf_hpp_fmt *fmt __maybe_unused,
174 struct perf_hpp *hpp __maybe_unused)
167{ 175{
168 return 8; 176 return 8;
169} 177}
@@ -184,7 +192,8 @@ static double baseline_percent(struct hist_entry *he)
184 return percent; 192 return percent;
185} 193}
186 194
187static int hpp__color_baseline(struct perf_hpp *hpp, struct hist_entry *he) 195static int hpp__color_baseline(struct perf_hpp_fmt *fmt __maybe_unused,
196 struct perf_hpp *hpp, struct hist_entry *he)
188{ 197{
189 double percent = baseline_percent(he); 198 double percent = baseline_percent(he);
190 199
@@ -194,7 +203,8 @@ static int hpp__color_baseline(struct perf_hpp *hpp, struct hist_entry *he)
194 return scnprintf(hpp->buf, hpp->size, " "); 203 return scnprintf(hpp->buf, hpp->size, " ");
195} 204}
196 205
197static int hpp__entry_baseline(struct perf_hpp *hpp, struct hist_entry *he) 206static int hpp__entry_baseline(struct perf_hpp_fmt *_fmt __maybe_unused,
207 struct perf_hpp *hpp, struct hist_entry *he)
198{ 208{
199 double percent = baseline_percent(he); 209 double percent = baseline_percent(he);
200 const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%"; 210 const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%";
@@ -205,19 +215,22 @@ static int hpp__entry_baseline(struct perf_hpp *hpp, struct hist_entry *he)
205 return scnprintf(hpp->buf, hpp->size, " "); 215 return scnprintf(hpp->buf, hpp->size, " ");
206} 216}
207 217
208static int hpp__header_period_baseline(struct perf_hpp *hpp) 218static int hpp__header_period_baseline(struct perf_hpp_fmt *_fmt __maybe_unused,
219 struct perf_hpp *hpp)
209{ 220{
210 const char *fmt = symbol_conf.field_sep ? "%s" : "%12s"; 221 const char *fmt = symbol_conf.field_sep ? "%s" : "%12s";
211 222
212 return scnprintf(hpp->buf, hpp->size, fmt, "Period Base"); 223 return scnprintf(hpp->buf, hpp->size, fmt, "Period Base");
213} 224}
214 225
215static int hpp__width_period_baseline(struct perf_hpp *hpp __maybe_unused) 226static int hpp__width_period_baseline(struct perf_hpp_fmt *fmt __maybe_unused,
227 struct perf_hpp *hpp __maybe_unused)
216{ 228{
217 return 12; 229 return 12;
218} 230}
219 231
220static int hpp__entry_period_baseline(struct perf_hpp *hpp, struct hist_entry *he) 232static int hpp__entry_period_baseline(struct perf_hpp_fmt *_fmt __maybe_unused,
233 struct perf_hpp *hpp, struct hist_entry *he)
221{ 234{
222 struct hist_entry *pair = hist_entry__next_pair(he); 235 struct hist_entry *pair = hist_entry__next_pair(he);
223 u64 period = pair ? pair->stat.period : 0; 236 u64 period = pair ? pair->stat.period : 0;
@@ -226,19 +239,22 @@ static int hpp__entry_period_baseline(struct perf_hpp *hpp, struct hist_entry *h
226 return scnprintf(hpp->buf, hpp->size, fmt, period); 239 return scnprintf(hpp->buf, hpp->size, fmt, period);
227} 240}
228 241
229static int hpp__header_delta(struct perf_hpp *hpp) 242static int hpp__header_delta(struct perf_hpp_fmt *_fmt __maybe_unused,
243 struct perf_hpp *hpp)
230{ 244{
231 const char *fmt = symbol_conf.field_sep ? "%s" : "%7s"; 245 const char *fmt = symbol_conf.field_sep ? "%s" : "%7s";
232 246
233 return scnprintf(hpp->buf, hpp->size, fmt, "Delta"); 247 return scnprintf(hpp->buf, hpp->size, fmt, "Delta");
234} 248}
235 249
236static int hpp__width_delta(struct perf_hpp *hpp __maybe_unused) 250static int hpp__width_delta(struct perf_hpp_fmt *fmt __maybe_unused,
251 struct perf_hpp *hpp __maybe_unused)
237{ 252{
238 return 7; 253 return 7;
239} 254}
240 255
241static int hpp__entry_delta(struct perf_hpp *hpp, struct hist_entry *he) 256static int hpp__entry_delta(struct perf_hpp_fmt *_fmt __maybe_unused,
257 struct perf_hpp *hpp, struct hist_entry *he)
242{ 258{
243 struct hist_entry *pair = hist_entry__next_pair(he); 259 struct hist_entry *pair = hist_entry__next_pair(he);
244 const char *fmt = symbol_conf.field_sep ? "%s" : "%7.7s"; 260 const char *fmt = symbol_conf.field_sep ? "%s" : "%7.7s";
@@ -259,19 +275,22 @@ static int hpp__entry_delta(struct perf_hpp *hpp, struct hist_entry *he)
259 return scnprintf(hpp->buf, hpp->size, fmt, buf); 275 return scnprintf(hpp->buf, hpp->size, fmt, buf);
260} 276}
261 277
262static int hpp__header_ratio(struct perf_hpp *hpp) 278static int hpp__header_ratio(struct perf_hpp_fmt *_fmt __maybe_unused,
279 struct perf_hpp *hpp)
263{ 280{
264 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s"; 281 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s";
265 282
266 return scnprintf(hpp->buf, hpp->size, fmt, "Ratio"); 283 return scnprintf(hpp->buf, hpp->size, fmt, "Ratio");
267} 284}
268 285
269static int hpp__width_ratio(struct perf_hpp *hpp __maybe_unused) 286static int hpp__width_ratio(struct perf_hpp_fmt *fmt __maybe_unused,
287 struct perf_hpp *hpp __maybe_unused)
270{ 288{
271 return 14; 289 return 14;
272} 290}
273 291
274static int hpp__entry_ratio(struct perf_hpp *hpp, struct hist_entry *he) 292static int hpp__entry_ratio(struct perf_hpp_fmt *_fmt __maybe_unused,
293 struct perf_hpp *hpp, struct hist_entry *he)
275{ 294{
276 struct hist_entry *pair = hist_entry__next_pair(he); 295 struct hist_entry *pair = hist_entry__next_pair(he);
277 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s"; 296 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s";
@@ -291,19 +310,22 @@ static int hpp__entry_ratio(struct perf_hpp *hpp, struct hist_entry *he)
291 return scnprintf(hpp->buf, hpp->size, fmt, buf); 310 return scnprintf(hpp->buf, hpp->size, fmt, buf);
292} 311}
293 312
294static int hpp__header_wdiff(struct perf_hpp *hpp) 313static int hpp__header_wdiff(struct perf_hpp_fmt *_fmt __maybe_unused,
314 struct perf_hpp *hpp)
295{ 315{
296 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s"; 316 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s";
297 317
298 return scnprintf(hpp->buf, hpp->size, fmt, "Weighted diff"); 318 return scnprintf(hpp->buf, hpp->size, fmt, "Weighted diff");
299} 319}
300 320
301static int hpp__width_wdiff(struct perf_hpp *hpp __maybe_unused) 321static int hpp__width_wdiff(struct perf_hpp_fmt *fmt __maybe_unused,
322 struct perf_hpp *hpp __maybe_unused)
302{ 323{
303 return 14; 324 return 14;
304} 325}
305 326
306static int hpp__entry_wdiff(struct perf_hpp *hpp, struct hist_entry *he) 327static int hpp__entry_wdiff(struct perf_hpp_fmt *_fmt __maybe_unused,
328 struct perf_hpp *hpp, struct hist_entry *he)
307{ 329{
308 struct hist_entry *pair = hist_entry__next_pair(he); 330 struct hist_entry *pair = hist_entry__next_pair(he);
309 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s"; 331 const char *fmt = symbol_conf.field_sep ? "%s" : "%14s";
@@ -323,19 +345,22 @@ static int hpp__entry_wdiff(struct perf_hpp *hpp, struct hist_entry *he)
323 return scnprintf(hpp->buf, hpp->size, fmt, buf); 345 return scnprintf(hpp->buf, hpp->size, fmt, buf);
324} 346}
325 347
326static int hpp__header_formula(struct perf_hpp *hpp) 348static int hpp__header_formula(struct perf_hpp_fmt *_fmt __maybe_unused,
349 struct perf_hpp *hpp)
327{ 350{
328 const char *fmt = symbol_conf.field_sep ? "%s" : "%70s"; 351 const char *fmt = symbol_conf.field_sep ? "%s" : "%70s";
329 352
330 return scnprintf(hpp->buf, hpp->size, fmt, "Formula"); 353 return scnprintf(hpp->buf, hpp->size, fmt, "Formula");
331} 354}
332 355
333static int hpp__width_formula(struct perf_hpp *hpp __maybe_unused) 356static int hpp__width_formula(struct perf_hpp_fmt *fmt __maybe_unused,
357 struct perf_hpp *hpp __maybe_unused)
334{ 358{
335 return 70; 359 return 70;
336} 360}
337 361
338static int hpp__entry_formula(struct perf_hpp *hpp, struct hist_entry *he) 362static int hpp__entry_formula(struct perf_hpp_fmt *_fmt __maybe_unused,
363 struct perf_hpp *hpp, struct hist_entry *he)
339{ 364{
340 struct hist_entry *pair = hist_entry__next_pair(he); 365 struct hist_entry *pair = hist_entry__next_pair(he);
341 const char *fmt = symbol_conf.field_sep ? "%s" : "%-70s"; 366 const char *fmt = symbol_conf.field_sep ? "%s" : "%-70s";
@@ -454,9 +479,9 @@ int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he,
454 first = false; 479 first = false;
455 480
456 if (color && fmt->color) 481 if (color && fmt->color)
457 ret = fmt->color(hpp, he); 482 ret = fmt->color(fmt, hpp, he);
458 else 483 else
459 ret = fmt->entry(hpp, he); 484 ret = fmt->entry(fmt, hpp, he);
460 485
461 advance_hpp(hpp, ret); 486 advance_hpp(hpp, ret);
462 } 487 }
@@ -499,7 +524,7 @@ unsigned int hists__sort_list_width(struct hists *hists)
499 if (i) 524 if (i)
500 ret += 2; 525 ret += 2;
501 526
502 ret += fmt->width(&dummy_hpp); 527 ret += fmt->width(fmt, &dummy_hpp);
503 } 528 }
504 529
505 list_for_each_entry(se, &hist_entry__sort_list, list) 530 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 ae7a75432249..ee703720649d 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -365,7 +365,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
365 else 365 else
366 first = false; 366 first = false;
367 367
368 fmt->header(&dummy_hpp); 368 fmt->header(fmt, &dummy_hpp);
369 fprintf(fp, "%s", bf); 369 fprintf(fp, "%s", bf);
370 } 370 }
371 371
@@ -410,7 +410,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
410 else 410 else
411 first = false; 411 first = false;
412 412
413 width = fmt->width(&dummy_hpp); 413 width = fmt->width(fmt, &dummy_hpp);
414 for (i = 0; i < width; i++) 414 for (i = 0; i < width; i++)
415 fprintf(fp, "."); 415 fprintf(fp, ".");
416 } 416 }