Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools stdio: Display multiple header lines

Display multiple header lines in stdio output , if it's configured
within struct perf_hpp_list::nr_header_lines.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1470583710-1649-5-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
f3705b06 69705b35

+25 -9
+25 -9
tools/perf/ui/stdio/hist.c
··· 639 639 return print_hierarchy_header(hists, hpp, symbol_conf.field_sep, fp); 640 640 } 641 641 642 - static int 643 - hists__fprintf_standard_headers(struct hists *hists, 644 - struct perf_hpp *hpp, 645 - FILE *fp) 642 + static void fprintf_line(struct hists *hists, struct perf_hpp *hpp, 643 + int line, FILE *fp) 646 644 { 647 645 struct perf_hpp_fmt *fmt; 648 - unsigned int width; 649 646 const char *sep = symbol_conf.field_sep; 650 647 bool first = true; 651 648 ··· 655 658 else 656 659 first = false; 657 660 658 - fmt->header(fmt, hpp, hists, 0); 661 + fmt->header(fmt, hpp, hists, line); 659 662 fprintf(fp, "%s", hpp->buf); 660 663 } 664 + } 661 665 662 - fprintf(fp, "\n"); 666 + static int 667 + hists__fprintf_standard_headers(struct hists *hists, 668 + struct perf_hpp *hpp, 669 + FILE *fp) 670 + { 671 + struct perf_hpp_list *hpp_list = hists->hpp_list; 672 + struct perf_hpp_fmt *fmt; 673 + unsigned int width; 674 + const char *sep = symbol_conf.field_sep; 675 + bool first = true; 676 + int line; 677 + 678 + for (line = 0; line < hpp_list->nr_header_lines; line++) { 679 + /* first # is displayed one level up */ 680 + if (line) 681 + fprintf(fp, "# "); 682 + fprintf_line(hists, hpp, line, fp); 683 + fprintf(fp, "\n"); 684 + } 663 685 664 686 if (sep) 665 - return 1; 687 + return hpp_list->nr_header_lines; 666 688 667 689 first = true; 668 690 ··· 705 689 706 690 fprintf(fp, "\n"); 707 691 fprintf(fp, "#\n"); 708 - return 3; 692 + return hpp_list->nr_header_lines + 2; 709 693 } 710 694 711 695 static int hists__fprintf_headers(struct hists *hists, FILE *fp)