From nobody Sun Dec 14 19:11:01 2025 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 1F5AD13F42A for ; Fri, 23 Aug 2024 08:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724401682; cv=none; b=T61PWwnObpwAMx2Q5++4MyFY3e/okCdsgQTcF8ZGEMhCw3C5zS9Rtwe7tCKgqRLYslw8i9A8vEqN1Urr1U38xnSVKfErpe4+w6XYYZ2R2AsfKc/ajEw9FtH+S9odU4MU28kBhEBohxTY4JurllTD28m6rPYcK1crwnROjvg6b4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724401682; c=relaxed/simple; bh=YWhSEjEbsm7333DuMdJ8QQbDQ8u2mmDpgmnCidre4OM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=KH96iyQzPiAGMlQcfS5lAAOK9Emoxp+G0x/86o1SZOraQZ+YZcPzCXcgJMNA1kedxWmHM/MmauDHRrDjf4UaQVcFxAJ3RWfG4Htc5A9qOB+qwD8gZPWOMpu9JI2Blyy/6Wfm0RZBZIMVzwvBJ5hZamt1K/O0PVE62paaliYnxIg= 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=Zv9tS2IB; arc=none smtp.client-ip=217.70.183.195 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="Zv9tS2IB" Received: by mail.gandi.net (Postfix) with ESMTPSA id E647060008; Fri, 23 Aug 2024 08:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1724401678; 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=yU2z5WhSAQTqB93fjY3ukGXftN14kQ1DQjtcB3aeejE=; b=Zv9tS2IBuibnzIlSVaxJy3jyJk/YYFe/X9VJh9EKKg3lUVuH6ukTR5uaowHusB6WA/sGyG 9MCYGBVhfNMjD25wo0kBBItr/4PELRW+Z7mQ7oFK08XMrG07I2pbDDNlIAC4DP/H1zrA/P TKPrEUnql2KmQu9UMK7Y+tTtKRctqQoWzJdMEdSSpoBPGF99Pyggnc7bgbYhB51sT53rej 84DdZWUPDWpfiKfntkuskNf3FX9r1mMWHiIe9YoFhprulhWuPHoLMUcqjqUsv5W4FoboIn J0tni6rXydwNrbOr0Sv0JfP6Ks1b3ntAsaPm+kMHe6YPymLlKrTYAYb0dWOJKA== From: Luca Ceresoli Date: Fri, 23 Aug 2024 10:27:42 +0200 Subject: [PATCH RESEND v2 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: <20240823-decode_stacktrace-find_module-improvements-v2-1-d7a57d35558b@bootlin.com> References: <20240823-decode_stacktrace-find_module-improvements-v2-0-d7a57d35558b@bootlin.com> In-Reply-To: <20240823-decode_stacktrace-find_module-improvements-v2-0-d7a57d35558b@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 , Andrew Morton X-Mailer: b4 0.14.1 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 identically 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. Reviewed-by: Stephen Boyd Signed-off-by: Luca Ceresoli --- 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 Dec 14 19:11:01 2025 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 0A866140397 for ; Fri, 23 Aug 2024 08:28:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724401682; cv=none; b=f+JmnXqu9O4jAqx6HzxB+M9H9Z3TSd2OdIqoNu3ZfKE1eRCJ/GTs10PiqTneoPwGEmrN/NclTOS3nQ2iMCzYwOCHUZU6CTxMf/9iO8J+zphMu9FtsYS1McJ7u9pk1ifALfaSt9q3VYKpFQD6qwrY64wCN/F/0Jc+GsUc0fbcJCg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724401682; c=relaxed/simple; bh=WWkRZNcU1ZOfKgeuPdomK3ItRurd92AN6Edqxlu76Rg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=AWbdaPcQPBUU8VR2ajjx0Cp/UFV3NKeCREkSCBBl3FVZVxp1wxOx69H9ouuUprrMx1NRVS8WfNypNQ3lNZoUNyWOQoDXU0gDgB5+PqbvE8BHeUZdLE6+zQMvaYzLPs8W9fepX6PNkhc0WvJwaW/1cdbqUkXE+UK+CW6GISYZk94= 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=JepBKPNg; arc=none smtp.client-ip=217.70.183.195 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="JepBKPNg" Received: by mail.gandi.net (Postfix) with ESMTPSA id A87AF60004; Fri, 23 Aug 2024 08:27:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1724401679; 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=tnhTHq3+chm+k9TwdAZbwwShRi/4O5m2qm/IN/fZxRo=; b=JepBKPNgfIGjCRu8n1FAqc703zIKml9VqQO3rFQ6cTKWQQZzVik8GdiUFAv4cW7fswOa4P kTVR70P6OBq1YWXZMq0OSObTdgUd6gsKEbbDY7zHiym8G0QYwfStsiKuz8iW0ngKUWncF5 Qs1xgEK3lgmVLmpeq887QLU8suo10O5lANgnPnc3/BTreQrvVUsOtb1fQrTmkMniswwESL nZ0WmZAMj3Gh5cMfdRJocRFO6kx434M01cLzG4Tx9cU1pc1XZfxaCr1uE6cYy7ZFT8mkkM rL0hlmUANxsw6xD8V0SdPUdf7Fmdc3r0R10YH9xZmbuEBgP/2DHYftkKf9+Vvw== From: Luca Ceresoli Date: Fri, 23 Aug 2024 10:27:43 +0200 Subject: [PATCH RESEND v2 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: <20240823-decode_stacktrace-find_module-improvements-v2-2-d7a57d35558b@bootlin.com> References: <20240823-decode_stacktrace-find_module-improvements-v2-0-d7a57d35558b@bootlin.com> In-Reply-To: <20240823-decode_stacktrace-find_module-improvements-v2-0-d7a57d35558b@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 , Andrew Morton X-Mailer: b4 0.14.1 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 Reviewed-by: Stephen Boyd Signed-off-by: Luca Ceresoli --- 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 Dec 14 19:11:01 2025 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) (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 E7B301428E8 for ; Fri, 23 Aug 2024 08:28:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724401683; cv=none; b=AKNzXH0wk0f9mlyOPgQDrPE6Yke2nhi6LydyQ7cd9JFoxYOAF5rRU0xKbIJNmkP77Jp5EJv9polQHBlWuUT4xGg9QJN8nmeLy1Rjoyj2JU0h0/n4cXl5syvETDiv5h4fp3ruLo4Mf+m6ndBAmgwotFhP+XozUUHliBLqjrGWpiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724401683; c=relaxed/simple; bh=yrptH+DQbXiAHa8Z83G/22BB8xjASWlh1dPOd3PH4Dw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=VdYjYE2K83LWIAVsnCSCkztahwruoel4hhOzuTGiQCUFnekI/QKXrRwr4Eypn2lqsGczqMRF+coDPEOqsCOBZvs+Cg7zBZDAd9xuMMndv7ht2aNqJl2CUBJ2r/Ud5UxKNGAh76imLo6XoU8z2ehN2bMSqxbu/Tegv5+/HMKJG2E= 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=nkM8VrHE; arc=none smtp.client-ip=217.70.183.195 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="nkM8VrHE" Received: by mail.gandi.net (Postfix) with ESMTPSA id 66B296000B; Fri, 23 Aug 2024 08:27:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1724401680; 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=HckJMNZywGJU3Fu+i/HC7yiULXqjL8S2dKNsB+4J6zU=; b=nkM8VrHEq2VoPSgWrJ5aB8Jv7XcDHl4CD48svLlqUI+Yb1fSXgDGatGOIGEFOaZQG6JBsk GZFXIiREd+Tov6Fgdmwc3ToK8FRppG6Czu1ZZeibR5Ttwh7p0dY3gCUNUcrdbnVjlWlZdI 5xZa9VNxfPtUD5up4/6EVrofb9wAmRb6OWTGne/si1MANRZdoyxlPwyvw0lyVixt1X7MYQ +hNIodKAusYKd4a70T+wk4Q/NpzIeNNPAtbyj5ZdN7ZejfblNTwU4IpTVG+iBXlLzKybbZ bUBhQM+YordWM1Tx1UZUG80JT52FnGOuIQLtVlxWAS24xI0/z3hi+lqhGpYryQ== From: Luca Ceresoli Date: Fri, 23 Aug 2024 10:27:44 +0200 Subject: [PATCH RESEND v2 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: <20240823-decode_stacktrace-find_module-improvements-v2-3-d7a57d35558b@bootlin.com> References: <20240823-decode_stacktrace-find_module-improvements-v2-0-d7a57d35558b@bootlin.com> In-Reply-To: <20240823-decode_stacktrace-find_module-improvements-v2-0-d7a57d35558b@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 , Andrew Morton X-Mailer: b4 0.14.1 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. Reviewed-by: Stephen Boyd Signed-off-by: Luca Ceresoli --- 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