From nobody Sun Feb 8 03:57:36 2026 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 EE52F47768 for ; Mon, 11 Mar 2024 15:25:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710170704; cv=none; b=cLjbRE9AaGllthY7yvSPpfC/Mfb5hFB7Q2ENX2U3yLq+1H5TGAQBeSxRfMo7tTcv0rBc3EmV+Euxc1S6F1x7ov4cgB2GJh05NuUUeiMtM8wy/NweJHwTCmf6bsEYAJMKydKYlEdTUn+v8YC0ByWxbsTPD6C7P83QhvmKZK69sY4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710170704; c=relaxed/simple; bh=8m5tTULbRwygGhNOxOOxCgJVXvWrvtn3dJnD+l/vKU8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=KKK6POALkaHpKCDWye5RTQMkbuqlTdfqyoXxmQBR/h5NjnjUPe74Kc78nwYEFyZPLDB+EBqTiE48ZTVZVtFHuc4ISR/l90ziMFgkIPseoXG4NL4LX2jG9S3hvz45yIVr+obSw6r877RQXEp6K43+ncpuFajOin36JEGf65jZEG4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=B7WJ2CQK; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="B7WJ2CQK" Received: by mail.gandi.net (Postfix) with ESMTPSA id C198E2000A; Mon, 11 Mar 2024 15:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710170700; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E8OZ8zCko77xC4qzd41Shrz3MxT07LVdca6HBrBBo7k=; b=B7WJ2CQKIvaWYTlfpseGUN0MkUZPO5kNbOkUQyKyEJ/E/M6djvVpMmeB8p/XOAo5wAwzhv XZmwSHQLIGc97bGXpX4a6W32Eh12ZCM1idi4qffiv6iiS8OCMbWEMEfIkKpcPkBlXbYllL iFQIJy5rtQBIp8grJY17dYpsIleKpmpkW5GI7o6aIEmWGbmEOjJNjFBONvNB6J8eDW/2PG ZOwbfIemkY54rvY98u/LqKoHTe8h/Yo89pIWuDUoiCxVcOv0Ahi96xVv7mm4EZ0Jv0kAO2 JL6o/ZD0UagqlC+ak+pv9sl2FJQJ7BnkiCEzgDNrP71FWIGiCO3OuTLLSsJs1A== From: Luca Ceresoli Date: Mon, 11 Mar 2024 16:24:54 +0100 Subject: [PATCH 1/3] scripts/decode_stacktrace.sh: remove find_module recursion and improve error reporting Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240311-decode_stacktrace-find_module-improvements-v1-1-8bea42b421aa@bootlin.com> References: <20240311-decode_stacktrace-find_module-improvements-v1-0-8bea42b421aa@bootlin.com> In-Reply-To: <20240311-decode_stacktrace-find_module-improvements-v1-0-8bea42b421aa@bootlin.com> To: Konstantin Khlebnikov , Stephen Boyd , Sasha Levin , =?utf-8?q?Alexis_Lothor=C3=A9?= , Thomas Petazzoni , linux-kernel@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.13.0 X-GND-Sasl: luca.ceresoli@bootlin.com The find_module() function can fail for two reasons: * the module was not found * the module was found but without debugging info In both cases the user is reported the same error: WARNING! Modules path isn't set, but is needed to parse this symbol This is misleading in case the modules path is set correctly. find_module() is currently implemented as a recursive function based on global variables in order to check up to 4 different paths. This is not straightforward to read and even less to modify. Besides, the debuginfod code at the beginning of find_module() is executed identlcally every time the function is entered, i.e. up to 4 times per each module search due to recursion. To be able to improve error reporting, first rewrite the find_module() function to remove recursion. The new version of the function iterates over all the same (up to 4) paths as before and for each of them does the same checks as before. At the end of the iteration it is now able to print an appropriate error message, so that has been moved from the caller into find_module(). Finally, when the module is found but without debugging info, mention the two Kconfig variables one needs to set in order to have the needed debugging symbols. Signed-off-by: Luca Ceresoli Reviewed-by: Stephen Boyd --- scripts/decode_stacktrace.sh | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index fa5be6f57b00..7f3fb5e82707 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -88,31 +88,32 @@ find_module() { fi fi =20 - if [[ "$modpath" !=3D "" ]] ; then - for fn in $(find "$modpath" -name "${module//_/[-_]}.ko*") ; do - if ${READELF} -WS "$fn" | grep -qwF .debug_line ; then - echo $fn - return - fi - done - return 1 - fi - - modpath=3D$(dirname "$vmlinux") - find_module && return - - if [[ $release =3D=3D "" ]] ; then + if [ -z $release ] ; then release=3D$(gdb -ex 'print init_uts_ns.name.release' -ex 'quit' -quiet -= batch "$vmlinux" 2>/dev/null | sed -n 's/\$1 =3D "\(.*\)".*/\1/p') fi + if [ -n "${release}" ] ; then + release_dirs=3D"/usr/lib/debug/lib/modules/$release /lib/modules/$releas= e" + fi =20 - for dn in {/usr/lib/debug,}/lib/modules/$release ; do - if [ -e "$dn" ] ; then - modpath=3D"$dn" - find_module && return + found_without_debug_info=3Dfalse + for dir in "$modpath" "$(dirname "$vmlinux")" ${release_dirs}; do + if [ -n "${dir}" ] && [ -e "${dir}" ]; then + for fn in $(find "$dir" -name "${module//_/[-_]}.ko*") ; do + if ${READELF} -WS "$fn" | grep -qwF .debug_line ; then + echo $fn + return + fi + found_without_debug_info=3Dtrue + done fi done =20 - modpath=3D"" + if [[ ${found_without_debug_info} =3D=3D true ]]; then + echo "WARNING! No debugging info in module ${module}, rebuild with DEBUG= _KERNEL and DEBUG_INFO" >&2 + else + echo "WARNING! Cannot find .ko for module ${module}, please pass a valid= module path" >&2 + fi + return 1 } =20 @@ -130,7 +131,6 @@ parse_symbol() { else local objfile=3D$(find_module) if [[ $objfile =3D=3D "" ]] ; then - echo "WARNING! Modules path isn't set, but is needed to parse this symb= ol" >&2 return fi if [[ $aarray_support =3D=3D true ]]; then --=20 2.34.1 From nobody Sun Feb 8 03:57:36 2026 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 9B33A4776A for ; Mon, 11 Mar 2024 15:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710170704; cv=none; b=QTKTZzCiCfV3TLxFpnFi5dzVPWBnSPsHwYP5cBHbAtoqA2EKMIJPQh4kJr+HiuPMGIi2AIxaYLQMb84cibZaCn+Pez39LvFHjGa9oRD/UqhClgoEtXkeI153mwosgEbePufKtg/dM6LUbH7o6Xd16cmkJMIcmrHwKgwakkoisOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710170704; c=relaxed/simple; bh=ymon1yWwqDlaJM8D70vqVA6CJA9akSWJQ9LrnxPlsu4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=nFk/FkHYxXTcKT3RHwbV4upL/hWSGN1mQqH6znaLZepWRO7MIFidgFSpfxuZjfmmYM3wXoYKJPruEUooig/YmFqEiBdKSwF7QBsywPO+RAAK/tOpwOtmPqICmmh5QET/TuCGJrfEy/zXvzOtPlJp7mzoTi/J4dM8qSA0EpGAha4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=RJaOLTQ2; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="RJaOLTQ2" Received: by mail.gandi.net (Postfix) with ESMTPSA id 792F42000F; Mon, 11 Mar 2024 15:25:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710170701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=843mOsM8xt7PPp6LR0HKYOK9c5hdfvsD2Mx0jZBABLA=; b=RJaOLTQ2KLsSgdVeR6Oku1thjhwDnN8FThYbo5Bf2ydCfwXqMqpSti10OneeKpav9pFgpK hloZD73tdqIOkdk7OrwdQZJJNLhP8RjpoT2BBlBI/Nzp2WE6SApi29B/l/TIdOjrL++FOV PSbQS3TBddXj805rqZHPZC9w1VxjnWOMmljwXvkUCeNjXFPsHh1kLgRm9v7I0FW6HJj/Rx RROv0Frokx4KmKkGq9LOIQ+Swk+bxMuUh6+VB/jNjykLRZr5H6D/j/xoa5DTU5TeGXiiLi HULGW+BY6QWNhd8zizCIn0pSFaLuGNz1UzdJ6rzlnbRJ6m1CypfKsUW49nlc2g== From: Luca Ceresoli Date: Mon, 11 Mar 2024 16:24:55 +0100 Subject: [PATCH 2/3] scripts/decode_stacktrace.sh: clarify command line Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240311-decode_stacktrace-find_module-improvements-v1-2-8bea42b421aa@bootlin.com> References: <20240311-decode_stacktrace-find_module-improvements-v1-0-8bea42b421aa@bootlin.com> In-Reply-To: <20240311-decode_stacktrace-find_module-improvements-v1-0-8bea42b421aa@bootlin.com> To: Konstantin Khlebnikov , Stephen Boyd , Sasha Levin , =?utf-8?q?Alexis_Lothor=C3=A9?= , Thomas Petazzoni , linux-kernel@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.13.0 X-GND-Sasl: luca.ceresoli@bootlin.com The syntax as expressed by usage() is not entirely correct: "" cannot be passed without "|auto". Additionally human reading of this syntax can be subject to misunderstanding due the mixture of '|' and '[]'. Improve readability in various ways: * rewrite using two lines for the two allowed usages * add square brackets around "" as it is optional when using debuginfod-find * move "" to inside the square brackets of the 2nd positional parameter * use underscores instead of spaces in <...> strings Signed-off-by: Luca Ceresoli Reviewed-by: Stephen Boyd --- scripts/decode_stacktrace.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index 7f3fb5e82707..b56e79060e9f 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -5,7 +5,8 @@ =20 usage() { echo "Usage:" - echo " $0 -r | [|auto] []" + echo " $0 -r " + echo " $0 [ [|auto []]]" } =20 # Try to find a Rust demangler --=20 2.34.1 From nobody Sun Feb 8 03:57:36 2026 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 47E1347796 for ; Mon, 11 Mar 2024 15:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710170705; cv=none; b=uIuqps91yjrWSBflvk0UjCX858+D4Yx7MobgukX35wtL5CxSCQFk1O1HhzRb6wyV20F6I73iV/9/bsj7pR1JURqqvibbUWqThuGczzoYojS0AOIxiXJwrWYVzIbSB0shF4hlJTgMIM7VJY3y7/gUGYE2m6BuAsHD9v2hJqWXKcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710170705; c=relaxed/simple; bh=cCHkeAEUWjV0vuh+yfaK6MzpjAQN3B4EWJ1HtNvhjr4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=oakiQRfgAe/udkKnY4XTty+KJaL5c1A7O9bZ8JUSWHI0cGEDlvW0n8fEyxaFkIw0P/dBM4G9B2WliEfxb0CnN1ywH+NSOX1N2oCezrfyZQNVY5vVvQrE5mRhH9Z/BCPM0lxxArJYCDvdC0P8K/9Temer8eotYqSN6r2b4snJLYU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=OEcv+PhY; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="OEcv+PhY" Received: by mail.gandi.net (Postfix) with ESMTPSA id 2BB6F20012; Mon, 11 Mar 2024 15:25:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1710170701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bHLMM6VOo42thQAgvftidBXfGDSJiFdOugL44M1CGn0=; b=OEcv+PhYpbpMG8EzgmI7H8jCQjKaYUvG0gs3XwcKmTvJSgqllCI8oFyOrXsDFX3PjB62Li r/+dtsZC4gz71xlDqJA6JhR8XnX8yrNVTO7Xc6UFU2Ja+cZXDVJnQhd7r/JDUgje4U4w+t A6rIYwpjMZnM0VIBCbH0Lb2HXfqxRA85MXtk9+o3B268v8czRQzIxvqYfOVieSYNBecKkY VOZNGBg6eS53YvAePOc2SWT//SpENUx6KQquaMtHPHcp6F7iDfy16a9GoS7vvqXeiy4dvq kK24sGiPq5NEzjFLcsJlndy4dkuHU8go4vtt3RA1Hh3xGu4Sj+iwUc9B74Vb+g== From: Luca Ceresoli Date: Mon, 11 Mar 2024 16:24:56 +0100 Subject: [PATCH 3/3] scripts/decode_stacktrace.sh: add '-h' flag Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240311-decode_stacktrace-find_module-improvements-v1-3-8bea42b421aa@bootlin.com> References: <20240311-decode_stacktrace-find_module-improvements-v1-0-8bea42b421aa@bootlin.com> In-Reply-To: <20240311-decode_stacktrace-find_module-improvements-v1-0-8bea42b421aa@bootlin.com> To: Konstantin Khlebnikov , Stephen Boyd , Sasha Levin , =?utf-8?q?Alexis_Lothor=C3=A9?= , Thomas Petazzoni , linux-kernel@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.13.0 X-GND-Sasl: luca.ceresoli@bootlin.com When no parameters are passed, the usage instructions are presented only when debuginfod-find is not found. This makes sense because with debuginfod none of the positional parameters are needed. However it means that users having debuginfod-find installed will have no chance of reading the usage text without opening the file. Many programs have a '-h' flag to get the usage, so add such a flag. Invoking 'scripts/decode_stacktrace.sh -h' will now show the usage text and exit. Signed-off-by: Luca Ceresoli Reviewed-by: Stephen Boyd --- scripts/decode_stacktrace.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh index b56e79060e9f..e8c9976062d0 100755 --- a/scripts/decode_stacktrace.sh +++ b/scripts/decode_stacktrace.sh @@ -7,6 +7,7 @@ usage() { echo "Usage:" echo " $0 -r " echo " $0 [ [|auto []]]" + echo " $0 -h" } =20 # Try to find a Rust demangler @@ -32,7 +33,10 @@ fi READELF=3D${UTIL_PREFIX}readelf${UTIL_SUFFIX} ADDR2LINE=3D${UTIL_PREFIX}addr2line${UTIL_SUFFIX} =20 -if [[ $1 =3D=3D "-r" ]] ; then +if [[ $1 =3D=3D "-h" ]] ; then + usage + exit 0 +elif [[ $1 =3D=3D "-r" ]] ; then vmlinux=3D"" basepath=3D"auto" modpath=3D"" --=20 2.34.1