Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753145AbbKWQPS (ORCPT ); Mon, 23 Nov 2015 11:15:18 -0500 Received: from terminus.zytor.com ([198.137.202.10]:44104 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752819AbbKWQPN (ORCPT ); Mon, 23 Nov 2015 11:15:13 -0500 Date: Mon, 23 Nov 2015 08:14:45 -0800 From: tip-bot for Namhyung Kim Message-ID: Cc: dsahern@gmail.com, a.p.zijlstra@chello.nl, kan.liang@intel.com, brendan.d.gregg@gmail.com, mingo@kernel.org, tglx@linutronix.de, andi@firstfloor.org, fweisbec@gmail.com, hpa@zytor.com, jolsa@redhat.com, linux-kernel@vger.kernel.org, namhyung@kernel.org, acme@redhat.com Reply-To: dsahern@gmail.com, a.p.zijlstra@chello.nl, tglx@linutronix.de, mingo@kernel.org, kan.liang@intel.com, brendan.d.gregg@gmail.com, andi@firstfloor.org, fweisbec@gmail.com, linux-kernel@vger.kernel.org, jolsa@redhat.com, hpa@zytor.com, namhyung@kernel.org, acme@redhat.com In-Reply-To: <1447047946-1691-7-git-send-email-namhyung@kernel.org> References: <1447047946-1691-7-git-send-email-namhyung@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf hists browser: Factor out hist_browser__show_callchain_list() Git-Commit-ID: 18bb838129b08fb0009b1ba1dc2f748a9537ee89 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4059 Lines: 132 Commit-ID: 18bb838129b08fb0009b1ba1dc2f748a9537ee89 Gitweb: http://git.kernel.org/tip/18bb838129b08fb0009b1ba1dc2f748a9537ee89 Author: Namhyung Kim AuthorDate: Mon, 9 Nov 2015 14:45:42 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 19 Nov 2015 13:19:24 -0300 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 Cc: Andi Kleen Cc: Brendan Gregg Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Kan Liang Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1447047946-1691-7-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/hists.c | 72 ++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 0b18857..0746d41 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 #define LEVEL_OFFSET_STEP 3 +static int hist_browser__show_callchain_list(struct hist_browser *browser, + struct callchain_node *node, + struct callchain_list *chain, + unsigned short row, u64 total, + bool need_percent, int offset, + print_callchain_entry_fn print, + struct callchain_print_arg *arg) +{ + char bf[1024], *alloc_str; + const char *str; + + if (arg->row_offset != 0) { + arg->row_offset--; + return 0; + } + + alloc_str = NULL; + str = callchain_list__sym_name(chain, bf, sizeof(bf), + browser->show_dso); + + if (need_percent) { + char buf[64]; + + callchain_node__scnprintf_value(node, buf, sizeof(buf), + total); + + if (asprintf(&alloc_str, "%s %s", buf, str) < 0) + str = "Not enough memory!"; + else + str = alloc_str; + } + + print(browser, chain, str, offset, row, arg); + + free(alloc_str); + return 1; +} + static int hist_browser__show_callchain(struct hist_browser *browser, struct rb_root *root, int level, unsigned short row, u64 total, @@ -598,8 +636,6 @@ static int hist_browser__show_callchain(struct hist_browser *browser, int extra_offset = 0; list_for_each_entry(chain, &child->val, list) { - char bf[1024], *alloc_str; - const char *str; bool was_first = first; if (first) @@ -608,34 +644,16 @@ static int hist_browser__show_callchain(struct hist_browser *browser, extra_offset = LEVEL_OFFSET_STEP; folded_sign = callchain_list__folded(chain); - if (arg->row_offset != 0) { - arg->row_offset--; - goto do_next; - } - alloc_str = NULL; - str = callchain_list__sym_name(chain, bf, sizeof(bf), - browser->show_dso); + row += hist_browser__show_callchain_list(browser, child, + chain, row, total, + was_first && need_percent, + offset + extra_offset, + print, arg); - if (was_first && need_percent) { - char buf[64]; - - callchain_node__scnprintf_value(child, buf, sizeof(buf), - total); - - if (asprintf(&alloc_str, "%s %s", buf, str) < 0) - str = "Not enough memory!"; - else - str = alloc_str; - } - - print(browser, chain, str, offset + extra_offset, row, arg); - - free(alloc_str); - - if (is_output_full(browser, ++row)) + if (is_output_full(browser, row)) goto out; -do_next: + if (folded_sign == '+') break; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/