From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932860AbcK2G6D (ORCPT ); Tue, 29 Nov 2016 01:58:03 -0500 Received: from mga09.intel.com ([134.134.136.24]:21845 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755965AbcK2G5D (ORCPT ); Tue, 29 Nov 2016 01:57:03 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,715,1473145200"; d="scan'208";a="36784794" From: Jin Yao To: acme@kernel.org, jolsa@kernel.org Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@linux.intel.com Subject: [PATCH v1 3/4] perf report: Show inline stack in stdio mode Date: Tue, 29 Nov 2016 22:55:43 +0800 Message-Id: <1480431344-1644-4-git-send-email-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480431344-1644-1-git-send-email-yao.jin@linux.intel.com> References: <1480431344-1644-1-git-send-email-yao.jin@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the address belongs to an inlined function, the source information back to the first non-inlined function will be printed. For example: 0.05% test2 test2 [.] main | ---/home/jinyao/perf-dev/test/test2.c:27 (inline) /home/jinyao/perf-dev/test/test2.c:35 (inline) /home/jinyao/perf-dev/test/test2.c:45 (inline) /home/jinyao/perf-dev/test/test2.c:61 (inline) The tag "inline" indicates these items are the entries in inline stack. Signed-off-by: Jin Yao --- tools/perf/ui/stdio/hist.c | 56 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 668f4ae..e74eda0 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -400,6 +400,53 @@ static size_t hist_entry_callchain__fprintf(struct hist_entry *he, return 0; } +static size_t hist_entry_inline__fprintf(struct hist_entry *he, + int left_margin, + FILE *fp) +{ + struct dso *dso; + struct inline_node *node; + struct inline_list *ilist; + int ret = 0, i = 0; + + if (he->ms.map == NULL) + return 0; + + dso = he->ms.map->dso; + if (dso == NULL) + return 0; + + if (dso->kernel != DSO_TYPE_USER) + return 0; + + node = get_inline_node(dso, map__rip_2objdump(he->ms.map, he->ip)); + if (node == NULL) + return 0; + + ret += callchain__fprintf_left_margin(fp, left_margin); + ret += fprintf(fp, "|\n"); + ret += callchain__fprintf_left_margin(fp, left_margin); + ret += fprintf(fp, "---"); + left_margin += 3; + + list_for_each_entry(ilist, &node->val, list) { + if (ilist->filename != NULL) { + if (i++ > 0) + ret = callchain__fprintf_left_margin(fp, + left_margin); + ret += fprintf(fp, "%s:%d (inline)", + ilist->filename, ilist->line_nr); + ret += fprintf(fp, "\n"); + } + } + + if (i > 0) + ret += fprintf(fp, "\n"); + + free_inline_node(node); + return ret; +} + int __hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp, struct perf_hpp_list *hpp_list) { @@ -529,6 +576,7 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, bool use_callchain) { int ret; + int callchain_ret = 0; struct perf_hpp hpp = { .buf = bf, .size = size, @@ -547,7 +595,13 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, ret = fprintf(fp, "%s\n", bf); if (use_callchain) - ret += hist_entry_callchain__fprintf(he, total_period, 0, fp); + callchain_ret = hist_entry_callchain__fprintf(he, total_period, + 0, fp); + + if ((callchain_ret == 0) && symbol_conf.show_inline) + ret += hist_entry_inline__fprintf(he, 0, fp); + else + ret += callchain_ret; return ret; } -- 2.7.4