aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/stdio/hist.c
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2016-03-07 14:44:48 -0500
committerIngo Molnar <mingo@kernel.org>2016-03-08 04:11:20 -0500
commit2dbbe9f26c082be5aa0e8ba5480e7bac43b2c4f0 (patch)
treedccf67f5759a3c9cc30fb66c50c96c2fa677d895 /tools/perf/ui/stdio/hist.c
parenta23f37e864609f0887c1cb77c4d5b62586484a61 (diff)
perf hists: Fix indent for multiple hierarchy sort key
When multiple sort keys are used in a single hierarchy, it should indent using number of hierarchy levels instead of number of sort keys. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1457361308-514-5-git-send-email-namhyung@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/ui/stdio/hist.c')
-rw-r--r--tools/perf/ui/stdio/hist.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 073642a63cc9..543d7137cc0c 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -412,7 +412,7 @@ static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)
412 412
413static int hist_entry__hierarchy_fprintf(struct hist_entry *he, 413static int hist_entry__hierarchy_fprintf(struct hist_entry *he,
414 struct perf_hpp *hpp, 414 struct perf_hpp *hpp,
415 int nr_sort_key, struct hists *hists, 415 struct hists *hists,
416 FILE *fp) 416 FILE *fp)
417{ 417{
418 const char *sep = symbol_conf.field_sep; 418 const char *sep = symbol_conf.field_sep;
@@ -453,7 +453,7 @@ static int hist_entry__hierarchy_fprintf(struct hist_entry *he,
453 453
454 if (!sep) 454 if (!sep)
455 ret = scnprintf(hpp->buf, hpp->size, "%*s", 455 ret = scnprintf(hpp->buf, hpp->size, "%*s",
456 (nr_sort_key - 1) * HIERARCHY_INDENT, ""); 456 (hists->nr_hpp_node - 2) * HIERARCHY_INDENT, "");
457 advance_hpp(hpp, ret); 457 advance_hpp(hpp, ret);
458 458
459 printed += fprintf(fp, "%s", buf); 459 printed += fprintf(fp, "%s", buf);
@@ -504,12 +504,8 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
504 if (size == 0 || size > bfsz) 504 if (size == 0 || size > bfsz)
505 size = hpp.size = bfsz; 505 size = hpp.size = bfsz;
506 506
507 if (symbol_conf.report_hierarchy) { 507 if (symbol_conf.report_hierarchy)
508 int nr_sort = hists->nr_sort_keys; 508 return hist_entry__hierarchy_fprintf(he, &hpp, hists, fp);
509
510 return hist_entry__hierarchy_fprintf(he, &hpp, nr_sort,
511 hists, fp);
512 }
513 509
514 hist_entry__snprintf(he, &hpp); 510 hist_entry__snprintf(he, &hpp);
515 511
@@ -521,29 +517,29 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
521 return ret; 517 return ret;
522} 518}
523 519
524static int print_hierarchy_indent(const char *sep, int nr_sort, 520static int print_hierarchy_indent(const char *sep, int indent,
525 const char *line, FILE *fp) 521 const char *line, FILE *fp)
526{ 522{
527 if (sep != NULL || nr_sort < 1) 523 if (sep != NULL || indent < 2)
528 return 0; 524 return 0;
529 525
530 return fprintf(fp, "%-.*s", (nr_sort - 1) * HIERARCHY_INDENT, line); 526 return fprintf(fp, "%-.*s", (indent - 2) * HIERARCHY_INDENT, line);
531} 527}
532 528
533static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp, 529static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
534 const char *sep, FILE *fp) 530 const char *sep, FILE *fp)
535{ 531{
536 bool first = true; 532 bool first = true;
537 int nr_sort; 533 int indent;
538 int depth; 534 int depth;
539 unsigned width = 0; 535 unsigned width = 0;
540 unsigned header_width = 0; 536 unsigned header_width = 0;
541 struct perf_hpp_fmt *fmt; 537 struct perf_hpp_fmt *fmt;
542 538
543 nr_sort = hists->nr_sort_keys; 539 indent = hists->nr_hpp_node;
544 540
545 /* preserve max indent depth for column headers */ 541 /* preserve max indent depth for column headers */
546 print_hierarchy_indent(sep, nr_sort, spaces, fp); 542 print_hierarchy_indent(sep, indent, spaces, fp);
547 543
548 hists__for_each_format(hists, fmt) { 544 hists__for_each_format(hists, fmt) {
549 if (perf_hpp__is_sort_entry(fmt) || perf_hpp__is_dynamic_entry(fmt)) 545 if (perf_hpp__is_sort_entry(fmt) || perf_hpp__is_dynamic_entry(fmt))
@@ -582,7 +578,7 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
582 fprintf(fp, "\n# "); 578 fprintf(fp, "\n# ");
583 579
584 /* preserve max indent depth for initial dots */ 580 /* preserve max indent depth for initial dots */
585 print_hierarchy_indent(sep, nr_sort, dots, fp); 581 print_hierarchy_indent(sep, indent, dots, fp);
586 582
587 first = true; 583 first = true;
588 hists__for_each_format(hists, fmt) { 584 hists__for_each_format(hists, fmt) {