public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Bjorn Andersson <quic_bjorande@quicinc.com>
To: Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-arm-msm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<llvm@lists.linux.dev>,
	Bjorn Andersson <quic_bjorande@quicinc.com>
Subject: [PATCH] scripts/decode_stacktrace.sh: Support LLVM addr2line
Date: Mon, 25 Dec 2023 10:52:57 -0800	[thread overview]
Message-ID: <20231225-decode-stacktrace-llvm-v1-1-abb9aa220cbf@quicinc.com> (raw)

The kernel build system adhere to the LLVM environment variable, to
select building the kernel using clang/llvm. In combination with the
ARCH environment variable the kernel can be cross-compiled without the
user specifying the CROSS_COMPILE variable.

The LLVM environment variable is used to specify the suffix of the llvm
executables (such as LLVM=-12 for llvm-addr2line-12), or to omit the
suffix when set to "1" (e.g. llvm-addr2line).

decode_stacktrace.sh allows invoking a specific addr2line executable by
prefixing the command with CROSS_COMPILE. At best allows the user to
trick decode_stacktrace.sh into invoking llvm-addr2line, and it does not
support specifying an alternative version based on the suffix.

Teach decode_stacktrace.sh about the two cases of the LLVM environment
variable, and use this to determine which addr2line to use. The current
behavior is maintained when the LLVM variable is not set.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
---
 scripts/decode_stacktrace.sh | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
index 564c5632e1a2..adf1d64477a1 100755
--- a/scripts/decode_stacktrace.sh
+++ b/scripts/decode_stacktrace.sh
@@ -16,6 +16,13 @@ elif type c++filt >/dev/null 2>&1 ; then
 	cppfilt_opts=-i
 fi
 
+# Determine which addr2line to use
+case "$LLVM" in
+	""	) addr2line="${CROSS_COMPILE}addr2line";;
+	"1"	) addr2line="llvm-addr2line";;
+	*	) addr2line="llvm-addr2line${LLVM}";;
+esac
+
 if [[ $1 == "-r" ]] ; then
 	vmlinux=""
 	basepath="auto"
@@ -169,7 +176,7 @@ parse_symbol() {
 	if [[ $aarray_support == true && "${cache[$module,$address]+isset}" == "isset" ]]; then
 		local code=${cache[$module,$address]}
 	else
-		local code=$(${CROSS_COMPILE}addr2line -i -e "$objfile" "$address" 2>/dev/null)
+		local code=$(${addr2line} -i -e "$objfile" "$address" 2>/dev/null)
 		if [[ $aarray_support == true ]]; then
 			cache[$module,$address]=$code
 		fi

---
base-commit: 39676dfe52331dba909c617f213fdb21015c8d10
change-id: 20231225-decode-stacktrace-llvm-f260a1614361

Best regards,
-- 
Bjorn Andersson <quic_bjorande@quicinc.com>


             reply	other threads:[~2023-12-25 18:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-25 18:52 Bjorn Andersson [this message]
2023-12-26 16:38 ` [PATCH] scripts/decode_stacktrace.sh: Support LLVM addr2line Nathan Chancellor

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=20231225-decode-stacktrace-llvm-v1-1-abb9aa220cbf@quicinc.com \
    --to=quic_bjorande@quicinc.com \
    --cc=akpm@linux-foundation.org \
    --cc=justinstitt@google.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.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