diff options
author | Namhyung Kim <namhyung@kernel.org> | 2015-11-09 00:45:42 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-11-19 11:19:24 -0500 |
commit | 18bb838129b08fb0009b1ba1dc2f748a9537ee89 (patch) | |
tree | 965d670ae08a383ce267022981a6da22af54e372 | |
parent | f2af008695e0b54a58b76caecd52af7e6c97fb29 (diff) |
perf hists browser: Factor out hist_browser__show_callchain_list()
This function is to print a single callchain list entry. As this
function will be used by other function, factor out to a separate
function.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1447047946-1691-7-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 72 |
1 files changed, 45 insertions, 27 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 0b18857a36e8..0746d41d9efe 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -574,6 +574,44 @@ static bool hist_browser__check_dump_full(struct hist_browser *browser __maybe_u | |||
574 | 574 | ||
575 | #define LEVEL_OFFSET_STEP 3 | 575 | #define LEVEL_OFFSET_STEP 3 |
576 | 576 | ||
577 | static int hist_browser__show_callchain_list(struct hist_browser *browser, | ||
578 | struct callchain_node *node, | ||
579 | struct callchain_list *chain, | ||
580 | unsigned short row, u64 total, | ||
581 | bool need_percent, int offset, | ||
582 | print_callchain_entry_fn print, | ||
583 | struct callchain_print_arg *arg) | ||
584 | { | ||
585 | char bf[1024], *alloc_str; | ||
586 | const char *str; | ||
587 | |||
588 | if (arg->row_offset != 0) { | ||
589 | arg->row_offset--; | ||
590 | return 0; | ||
591 | } | ||
592 | |||
593 | alloc_str = NULL; | ||
594 | str = callchain_list__sym_name(chain, bf, sizeof(bf), | ||
595 | browser->show_dso); | ||
596 | |||
597 | if (need_percent) { | ||
598 | char buf[64]; | ||
599 | |||
600 | callchain_node__scnprintf_value(node, buf, sizeof(buf), | ||
601 | total); | ||
602 | |||
603 | if (asprintf(&alloc_str, "%s %s", buf, str) < 0) | ||
604 | str = "Not enough memory!"; | ||
605 | else | ||
606 | str = alloc_str; | ||
607 | } | ||
608 | |||
609 | print(browser, chain, str, offset, row, arg); | ||
610 | |||
611 | free(alloc_str); | ||
612 | return 1; | ||
613 | } | ||
614 | |||
577 | static int hist_browser__show_callchain(struct hist_browser *browser, | 615 | static int hist_browser__show_callchain(struct hist_browser *browser, |
578 | struct rb_root *root, int level, | 616 | struct rb_root *root, int level, |
579 | unsigned short row, u64 total, | 617 | unsigned short row, u64 total, |
@@ -598,8 +636,6 @@ static int hist_browser__show_callchain(struct hist_browser *browser, | |||
598 | int extra_offset = 0; | 636 | int extra_offset = 0; |
599 | 637 | ||
600 | list_for_each_entry(chain, &child->val, list) { | 638 | list_for_each_entry(chain, &child->val, list) { |
601 | char bf[1024], *alloc_str; | ||
602 | const char *str; | ||
603 | bool was_first = first; | 639 | bool was_first = first; |
604 | 640 | ||
605 | if (first) | 641 | if (first) |
@@ -608,34 +644,16 @@ static int hist_browser__show_callchain(struct hist_browser *browser, | |||
608 | extra_offset = LEVEL_OFFSET_STEP; | 644 | extra_offset = LEVEL_OFFSET_STEP; |
609 | 645 | ||
610 | folded_sign = callchain_list__folded(chain); | 646 | folded_sign = callchain_list__folded(chain); |
611 | if (arg->row_offset != 0) { | ||
612 | arg->row_offset--; | ||
613 | goto do_next; | ||
614 | } | ||
615 | 647 | ||
616 | alloc_str = NULL; | 648 | row += hist_browser__show_callchain_list(browser, child, |
617 | str = callchain_list__sym_name(chain, bf, sizeof(bf), | 649 | chain, row, total, |
618 | browser->show_dso); | 650 | was_first && need_percent, |
651 | offset + extra_offset, | ||
652 | print, arg); | ||
619 | 653 | ||
620 | if (was_first && need_percent) { | 654 | if (is_output_full(browser, row)) |
621 | char buf[64]; | ||
622 | |||
623 | callchain_node__scnprintf_value(child, buf, sizeof(buf), | ||
624 | total); | ||
625 | |||
626 | if (asprintf(&alloc_str, "%s %s", buf, str) < 0) | ||
627 | str = "Not enough memory!"; | ||
628 | else | ||
629 | str = alloc_str; | ||
630 | } | ||
631 | |||
632 | print(browser, chain, str, offset + extra_offset, row, arg); | ||
633 | |||
634 | free(alloc_str); | ||
635 | |||
636 | if (is_output_full(browser, ++row)) | ||
637 | goto out; | 655 | goto out; |
638 | do_next: | 656 | |
639 | if (folded_sign == '+') | 657 | if (folded_sign == '+') |
640 | break; | 658 | break; |
641 | } | 659 | } |