Message ID | 20231225-decode-stacktrace-llvm-v1-1-abb9aa220cbf@quicinc.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-11145-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp518058dyb; Mon, 25 Dec 2023 10:53:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEXhA17Qj3TxNsw86AdF52G3EjfXLgMrVrVcKXDmpLM+IL7I2uONh7kEvhJEqWVMykJHdjw X-Received: by 2002:a05:620a:4552:b0:781:2f41:f705 with SMTP id u18-20020a05620a455200b007812f41f705mr10287435qkp.18.1703530403142; Mon, 25 Dec 2023 10:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703530403; cv=none; d=google.com; s=arc-20160816; b=MsFIYb//dohexmv27KGSp9N7r8FVTVKl3WoDM3p1mdJtfRTgBu67i6oC3By9cvf5cU GbbHeX0q3T+mJ6W4kAJtINvXbdo6PGkLRNb/f8NiDY2wAXMwvwDlR3w/uu45paBqaeBP uHzqcZW2qCybE0Y8yTX/RNWfrjHToGQo9VDjpY6sG4ZaV5XmryucMWRGJCWEgNlaM16+ Nm89rfShONAN80vUdDw5KmvUakh3j7UTSkgQujKubhn9KPJpySbDDmK2tQ2L+skQIYfG kFDInuoS5AxyuqvmngIeBYC2gG+kjsKsT1wSOD1QffX7T7BJ/tW8FCTx80SIwmF5+Lcv xmrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=ftpHYL73P0PMwcf3vm6rL6xXEEG/VlZNKCFd75Qx88M=; fh=nZsNNlVTMSscMkQqqsn4+ZETnVEGmXaAVAi3ATq5JIY=; b=YZz145iCvb+QnqDcIwcDV1JO0GCLoZPHKKjTzW4vomFcxYH5RPZRTJqRLvv/za1ix5 AkjF4TiyJ31nUg50IkaRDsVXGNfbYbteu6oPGy/N3drKFKIlCGen59NFlmEnoVkQgROq f0Av/Bn+GezrZk5H8Ddey0A7jctDD2HEkRJUmsTEJ622fppxARlW8usGAIW+v8aUmORa yvpA0RGdzfKAl/or0mDjhUIiDEe+zNdXkOwWpTUNJ0JlliOwe+NN73fZoaNiie3oXcUE P4h+mBPlwQrHVUK5DEVU2RDgNapB9fPzAD1GOqvhmvCs03q7hde0Jxnw6dvg3XOA+PtH 6R3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=AQoXN31n; spf=pass (google.com: domain of linux-kernel+bounces-11145-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11145-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id r14-20020a05620a298e00b0078127006628si8997619qkp.391.2023.12.25.10.53.23 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 10:53:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11145-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=AQoXN31n; spf=pass (google.com: domain of linux-kernel+bounces-11145-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11145-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E021D1C20F90 for <ouuuleilei@gmail.com>; Mon, 25 Dec 2023 18:53:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3102C5380B; Mon, 25 Dec 2023 18:53:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="AQoXN31n" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04F8C52F77; Mon, 25 Dec 2023 18:53:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BPInQnJ010630; Mon, 25 Dec 2023 18:52:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:date:subject:mime-version:content-type :content-transfer-encoding:message-id:to:cc; s=qcppdkim1; bh=ftp HYL73P0PMwcf3vm6rL6xXEEG/VlZNKCFd75Qx88M=; b=AQoXN31nsRXM+bWTSC9 AT/dKG5dko7Cw0WYc3z4om1PipbitdlYYQ0Q/expTtMhUgcrearW3Chk12WKrFFj p3He9K/lOFndAZBDn3zH+xGyE90VaI/mwF5fk6IxSZ12X0/ZqMznZOGg+ONYtpwF C/047i0DsKtx9/s+ACtzGYbP/9NJKIYlQmol809v8z/SVjrFBIEErlbkAEpC2ixX ifUbOF9FHfwxou30ZT7h0CwF6iBEI72qDct6GwFoCBlbTl99YAKFMr9QUPUIXgkH SA2qRIX7ywpsPECo0up7CsK1rrUqRK3NdiBpVI13Mfz4Fg2c5pG5uKEUz27M/f9u daQ== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v5pgvc5cy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 18:52:58 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BPIqwfk022033 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 18:52:58 GMT Received: from [169.254.0.1] (10.49.16.6) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Mon, 25 Dec 2023 10:52:57 -0800 From: Bjorn Andersson <quic_bjorande@quicinc.com> Date: Mon, 25 Dec 2023 10:52:57 -0800 Subject: [PATCH] scripts/decode_stacktrace.sh: Support LLVM addr2line Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20231225-decode-stacktrace-llvm-v1-1-abb9aa220cbf@quicinc.com> X-B4-Tracking: v=1; b=H4sIAIjPiWUC/x2NQQrCQAwAv1JyNtBsdQ9+RTyk2dQurlvZ1CKU/ t3gcQaG2cG0ZTW4djs03bLlpTrQqQOZuT4Uc3KG0IeBQrhgUlmSoq0sz7WxKJayvXAKsWeKdB4 igccjm+LYuMrsef2U4vLddMrf/+12P44fVyVADX0AAAA= 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> X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1703530377; l=2236; i=quic_bjorande@quicinc.com; s=20230915; h=from:subject:message-id; bh=oJebOxoPeoTym3cgqwcxkxFxxmZ7qB8J295Bv1j1YBg=; b=97Upa7nXp3PiuUtOwM3kJionIy4dQgtXEXbbwd+uM7nAkgxJxyOYhxsUf27He321eLdJXgJ7gxYL nBKfsPEdDaPG+ME4g8l0bJE1n6GSYPkNtXYkTqxNnjZsNzI35egZ X-Developer-Key: i=quic_bjorande@quicinc.com; a=ed25519; pk=VkhObtljigy9k0ZUIE1Mvr0Y+E1dgBEH9WoLQnUtbIM= X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 0Q6qqyDAQf7p6PPC7zDFoVfT5vqx8IGS X-Proofpoint-ORIG-GUID: 0Q6qqyDAQf7p6PPC7zDFoVfT5vqx8IGS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1011 suspectscore=0 phishscore=0 adultscore=0 impostorscore=0 mlxlogscore=752 malwarescore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312250149 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786281095956539022 X-GMAIL-MSGID: 1786281095956539022 |
Series |
scripts/decode_stacktrace.sh: Support LLVM addr2line
|
|
Commit Message
Bjorn Andersson
Dec. 25, 2023, 6:52 p.m. UTC
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(-)
---
base-commit: 39676dfe52331dba909c617f213fdb21015c8d10
change-id: 20231225-decode-stacktrace-llvm-f260a1614361
Best regards,
Comments
On Mon, Dec 25, 2023 at 10:52:57AM -0800, Bjorn Andersson wrote: > 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> Hmmm, this is the second patch to decode_stacktrace.sh in the same number of weeks... https://lore.kernel.org/20231215-llvm-decode-stacktrace-v1-1-201cb86f4879@quicinc.com/ Nick pointed out on that one that Carlos's patch from some time ago was even better at using all LLVM tools and requested testing/review on that one. https://lore.kernel.org/20230929034836.403735-1-cmllamas@google.com/ Furthermore, this patch does not handle the LLVM=<prefix>/bin/ syntax that we support, which I personally use all the time. Cheers, Nathan > --- > 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> > >
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