linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Truong <alexandre.truong@arm.com>
To: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Cc: Alexandre Truong <alexandre.truong@arm.com>
Subject: [PATCH v2 2/4] perf tools: add a mechanism to inject stack frames
Date: Fri, 12 Feb 2021 17:03:41 +0000	[thread overview]
Message-ID: <20210212170343.7729-2-alexandre.truong@arm.com> (raw)
In-Reply-To: <20210212170343.7729-1-alexandre.truong@arm.com>

Add a mechanism for platforms to inject stack frames for the leaf
frame caller if there is enough information to determine a frame
is missing from dwarf or other post processing mechanisms.

Signed-off-by: Alexandre Truong <alexandre.truong@arm.com>
---
 tools/perf/util/machine.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index ab8a6b3e801d..7f03ffa016b0 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2671,6 +2671,12 @@ static int find_prev_cpumode(struct ip_callchain *chain, struct thread *thread,
 	return err;
 }
 
+static u64 get_leaf_frame_caller(struct perf_sample *sample __maybe_unused,
+		struct thread *thread __maybe_unused)
+{
+	return 0;
+}
+
 static int thread__resolve_callchain_sample(struct thread *thread,
 					    struct callchain_cursor *cursor,
 					    struct evsel *evsel,
@@ -2687,6 +2693,8 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 	int i, j, err, nr_entries;
 	int skip_idx = -1;
 	int first_call = 0;
+	u64 leaf_frame_caller;
+	int pos;
 
 	if (chain)
 		chain_nr = chain->nr;
@@ -2811,6 +2819,21 @@ static int thread__resolve_callchain_sample(struct thread *thread,
 			continue;
 		}
 
+		pos = callchain_param.order == ORDER_CALLEE ? 2 : chain_nr - 2;
+
+		if (i == pos) {
+			leaf_frame_caller = get_leaf_frame_caller(sample, thread);
+
+			if (leaf_frame_caller && leaf_frame_caller != ip) {
+
+				err = add_callchain_ip(thread, cursor, parent,
+					       root_al, &cpumode, leaf_frame_caller,
+					       false, NULL, NULL, 0);
+				if (err)
+					return (err < 0) ? err : 0;
+			}
+		}
+
 		err = add_callchain_ip(thread, cursor, parent,
 				       root_al, &cpumode, ip,
 				       false, NULL, NULL, 0);
-- 
2.23.0


  reply	other threads:[~2021-02-12 17:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-12 17:03 [PATCH v2 1/4] perf tools: record aarch64 registers automatically Alexandre Truong
2021-02-12 17:03 ` Alexandre Truong [this message]
2021-02-12 17:03 ` [PATCH v2 3/4] perf tools: enable dwarf_callchain_users on aarch64 Alexandre Truong
2021-02-12 17:03 ` [PATCH v2 4/4] perf tools: determine if LR is the return address Alexandre Truong
2021-02-16 10:47   ` Alexandre Truong
  -- strict thread matches above, loose matches on Subject: below --
2021-02-10 13:22 [PATCH v2 1/4] perf tools: record aarch64 registers automatically Alexandre Truong
2021-02-10 13:22 ` [PATCH v2 2/4] perf tools: add a mechanism to inject stack frames Alexandre Truong

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=20210212170343.7729-2-alexandre.truong@arm.com \
    --to=alexandre.truong@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    /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).