linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
To: linux-perf-users@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
	"Steven Rostedt (VMware)" <rostedt@goodmis.org>,
	Andi Kleen <ak@linux.intel.com>,
	"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>,
	linux-kernel@vger.kernel.org,
	Milian Wolff <milian.wolff@kdab.com>,
	Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
Subject: [PATCHv2 2/2] perf evsel: add inline functions to sample callchain output
Date: Wed, 20 Feb 2019 11:59:13 +0100	[thread overview]
Message-ID: <20190220105913.1321-1-jonas.rabenstein@studium.uni-erlangen.de> (raw)
In-Reply-To: <20190220001116.3b3yyndjjmqs3hmm@studium.uni-erlangen.de>

Whenever a callchain shall be printed search for each address whether
inline information is available and add those symbols to the output
if symbol_conf.inline_name is enabled.

Signed-off-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
---
v2:
 - fix handling of static binaries

 tools/perf/util/evsel_fprintf.c | 55 +++++++++++++++++++++++++++++----
 1 file changed, 49 insertions(+), 6 deletions(-)

diff --git a/tools/perf/util/evsel_fprintf.c b/tools/perf/util/evsel_fprintf.c
index c710f687ddf4..a8d6465af1aa 100644
--- a/tools/perf/util/evsel_fprintf.c
+++ b/tools/perf/util/evsel_fprintf.c
@@ -168,6 +168,52 @@ static int __fprintf_callchain_link(u64 ip, struct map *map, struct symbol *symb
 	return printed;
 }
 
+static int __fprintf_callchain(struct callchain_cursor_node *node, bool first,
+			       int left_alignment, unsigned int print_opts,
+			       FILE *fp)
+{
+	int printed = 0;
+	struct inline_node *inline_node;
+	struct inline_list *ilist;
+	u64 addr;
+
+	if (!symbol_conf.inline_name)
+		goto no_inline;
+
+	if (!node->map || !node->map->dso)
+		goto no_inline;
+
+	addr = node->map->map_ip(node->map, node->ip);
+	addr = map__rip_2objdump(node->map, addr);
+
+	inline_node = inlines__tree_find(&node->map->dso->inlined_nodes,
+					 addr);
+	if (!inline_node) {
+		inline_node = dso__parse_addr_inlines(node->map->dso,
+						      addr, node->sym);
+		if (!inline_node)
+			goto no_inline;
+		inlines__tree_insert(&node->map->dso->inlined_nodes,
+				     inline_node);
+	}
+
+	list_for_each_entry(ilist, &inline_node->val, list) {
+		printed += __fprintf_callchain_link(node->ip, node->map,
+						    ilist->symbol,
+						    ilist->srcline,
+						    first, left_alignment,
+						    print_opts, fp);
+		first = (first && printed == 0);
+	}
+
+	return printed;
+
+no_inline:
+	return __fprintf_callchain_link(node->ip, node->map, node->sym,
+					NULL, first, left_alignment,
+					print_opts, fp);
+}
+
 int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
 			      unsigned int print_opts, struct callchain_cursor *cursor,
 			      FILE *fp)
@@ -183,12 +229,9 @@ int sample__fprintf_callchain(struct perf_sample *sample, int left_alignment,
 			if (!node)
 				break;
 
-
-			printed += __fprintf_callchain_link(node->ip, node->map,
-							    node->sym, NULL,
-							    (printed == 0),
-							    left_alignment,
-							    print_opts, fp);
+			printed += __fprintf_callchain(node, (printed == 0),
+						       left_alignment,
+						       print_opts, fp);
 
 			/* Add srccode here too? */
 			if (symbol_conf.bt_stop_list &&
-- 
2.19.2


  reply	other threads:[~2019-02-20 10:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19 18:38 [PATCH 0/2] perf evsel: add support for inlined function in callchains Jonas Rabenstein
2019-02-19 18:38 ` [PATCH 1/2] perf evsel: split sample__fprintf_callchain in output and iteration Jonas Rabenstein
2019-02-19 18:38 ` [PATCH 2/2] perf evsel: add inline functions to sample callchain output Jonas Rabenstein
2019-02-20  0:11   ` Jonas Rabenstein
2019-02-20 10:59     ` Jonas Rabenstein [this message]
2019-02-19 19:38 ` [PATCH 0/2] perf evsel: add support for inlined function in callchains Arnaldo Carvalho de Melo
2019-02-20 14:34 ` Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190220105913.1321-1-jonas.rabenstein@studium.uni-erlangen.de \
    --to=jonas.rabenstein@studium.uni-erlangen.de \
    --cc=acme@kernel.org \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=milian.wolff@kdab.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tz.stoyanov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).