aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/stdio
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2014-03-03 02:16:20 -0500
committerJiri Olsa <jolsa@kernel.org>2014-05-21 05:45:34 -0400
commit26d8b338271a17a8a9b78000ebaec8b4645f5476 (patch)
tree41d1a6c7e3204c005df6a8983ccc519d47a55258 /tools/perf/ui/stdio
parent043ca389a3181565b5c19d43a55eae111977d13d (diff)
perf tools: Consolidate output field handling to hpp format routines
Until now the hpp and sort functions do similar jobs different ways. Since the sort functions converted/wrapped to hpp formats it can do the job in a uniform way. The perf_hpp__sort_list has a list of hpp formats to sort entries and the perf_hpp__list has a list of hpp formats to print output result. To have a backward compatibility, it automatically adds 'overhead' field in front of sort list. And then all of fields in sort list added to the output list (if it's not already there). Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Ingo Molnar <mingo@kernel.org> Link: http://lkml.kernel.org/n/tip-7g3h86woz2sckg3h1lj42ygj@git.kernel.org Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Diffstat (limited to 'tools/perf/ui/stdio')
-rw-r--r--tools/perf/ui/stdio/hist.c55
1 files changed, 17 insertions, 38 deletions
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 9eccf7f4f367..49e2e4a7346a 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -306,8 +306,7 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he,
306 return hist_entry_callchain__fprintf(he, total_period, left_margin, fp); 306 return hist_entry_callchain__fprintf(he, total_period, left_margin, fp);
307} 307}
308 308
309static int hist_entry__period_snprintf(struct perf_hpp *hpp, 309static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)
310 struct hist_entry *he)
311{ 310{
312 const char *sep = symbol_conf.field_sep; 311 const char *sep = symbol_conf.field_sep;
313 struct perf_hpp_fmt *fmt; 312 struct perf_hpp_fmt *fmt;
@@ -353,8 +352,7 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
353 if (size == 0 || size > bfsz) 352 if (size == 0 || size > bfsz)
354 size = hpp.size = bfsz; 353 size = hpp.size = bfsz;
355 354
356 ret = hist_entry__period_snprintf(&hpp, he); 355 hist_entry__snprintf(he, &hpp);
357 hist_entry__sort_snprintf(he, bf + ret, size - ret, hists);
358 356
359 ret = fprintf(fp, "%s\n", bf); 357 ret = fprintf(fp, "%s\n", bf);
360 358
@@ -386,28 +384,9 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
386 384
387 init_rem_hits(); 385 init_rem_hits();
388 386
389 if (!show_header)
390 goto print_entries;
391
392 fprintf(fp, "# ");
393
394 perf_hpp__for_each_format(fmt) {
395 if (!first)
396 fprintf(fp, "%s", sep ?: " ");
397 else
398 first = false;
399
400 fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
401 fprintf(fp, "%s", bf);
402 }
403
404 list_for_each_entry(se, &hist_entry__sort_list, list) { 387 list_for_each_entry(se, &hist_entry__sort_list, list) {
405 if (se->elide) 388 if (se->elide)
406 continue; 389 continue;
407 if (sep) {
408 fprintf(fp, "%c%s", *sep, se->se_header);
409 continue;
410 }
411 width = strlen(se->se_header); 390 width = strlen(se->se_header);
412 if (symbol_conf.col_width_list_str) { 391 if (symbol_conf.col_width_list_str) {
413 if (col_width) { 392 if (col_width) {
@@ -420,7 +399,21 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
420 } 399 }
421 if (!hists__new_col_len(hists, se->se_width_idx, width)) 400 if (!hists__new_col_len(hists, se->se_width_idx, width))
422 width = hists__col_len(hists, se->se_width_idx); 401 width = hists__col_len(hists, se->se_width_idx);
423 fprintf(fp, " %*s", width, se->se_header); 402 }
403
404 if (!show_header)
405 goto print_entries;
406
407 fprintf(fp, "# ");
408
409 perf_hpp__for_each_format(fmt) {
410 if (!first)
411 fprintf(fp, "%s", sep ?: " ");
412 else
413 first = false;
414
415 fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
416 fprintf(fp, "%s", bf);
424 } 417 }
425 418
426 fprintf(fp, "\n"); 419 fprintf(fp, "\n");
@@ -447,20 +440,6 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
447 fprintf(fp, "."); 440 fprintf(fp, ".");
448 } 441 }
449 442
450 list_for_each_entry(se, &hist_entry__sort_list, list) {
451 unsigned int i;
452
453 if (se->elide)
454 continue;
455
456 fprintf(fp, " ");
457 width = hists__col_len(hists, se->se_width_idx);
458 if (width == 0)
459 width = strlen(se->se_header);
460 for (i = 0; i < width; i++)
461 fprintf(fp, ".");
462 }
463
464 fprintf(fp, "\n"); 443 fprintf(fp, "\n");
465 if (max_rows && ++nr_rows >= max_rows) 444 if (max_rows && ++nr_rows >= max_rows)
466 goto out; 445 goto out;