From: Luca Ceresoli <luca.ceresoli@bootlin.com>
To: "Konstantin Khlebnikov" <koct9i@gmail.com>,
"Stephen Boyd" <swboyd@chromium.org>,
"Sasha Levin" <sashal@kernel.org>,
"Alexis Lothoré" <alexis.lothore@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
linux-kernel@vger.kernel.org,
"Luca Ceresoli" <luca.ceresoli@bootlin.com>
Subject: [PATCH 1/3] scripts/decode_stacktrace.sh: remove find_module recursion and improve error reporting
Date: Mon, 11 Mar 2024 16:24:54 +0100 [thread overview]
Message-ID: <20240311-decode_stacktrace-find_module-improvements-v1-1-8bea42b421aa@bootlin.com> (raw)
In-Reply-To: <20240311-decode_stacktrace-find_module-improvements-v1-0-8bea42b421aa@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 <luca.ceresoli@bootlin.com>
---
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
- if [[ "$modpath" != "" ]] ; 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=$(dirname "$vmlinux")
- find_module && return
-
- if [[ $release == "" ]] ; then
+ if [ -z $release ] ; then
release=$(gdb -ex 'print init_uts_ns.name.release' -ex 'quit' -quiet -batch "$vmlinux" 2>/dev/null | sed -n 's/\$1 = "\(.*\)".*/\1/p')
fi
+ if [ -n "${release}" ] ; then
+ release_dirs="/usr/lib/debug/lib/modules/$release /lib/modules/$release"
+ fi
- for dn in {/usr/lib/debug,}/lib/modules/$release ; do
- if [ -e "$dn" ] ; then
- modpath="$dn"
- find_module && return
+ found_without_debug_info=false
+ 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=true
+ done
fi
done
- modpath=""
+ if [[ ${found_without_debug_info} == 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
}
@@ -130,7 +131,6 @@ parse_symbol() {
else
local objfile=$(find_module)
if [[ $objfile == "" ]] ; then
- echo "WARNING! Modules path isn't set, but is needed to parse this symbol" >&2
return
fi
if [[ $aarray_support == true ]]; then
--
2.34.1
next prev parent reply other threads:[~2024-03-11 15:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-11 15:24 [PATCH 0/3] scripts/decode_stacktrace.sh: improve error reporting and usability Luca Ceresoli
2024-03-11 15:24 ` Luca Ceresoli [this message]
2024-05-08 21:35 ` [PATCH 1/3] scripts/decode_stacktrace.sh: remove find_module recursion and improve error reporting Stephen Boyd
2024-05-09 8:16 ` Luca Ceresoli
2024-03-11 15:24 ` [PATCH 2/3] scripts/decode_stacktrace.sh: clarify command line Luca Ceresoli
2024-05-08 21:37 ` Stephen Boyd
2024-03-11 15:24 ` [PATCH 3/3] scripts/decode_stacktrace.sh: add '-h' flag Luca Ceresoli
2024-05-08 21:38 ` Stephen Boyd
2024-04-22 9:42 ` [PATCH 0/3] scripts/decode_stacktrace.sh: improve error reporting and usability Luca Ceresoli
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=20240311-decode_stacktrace-find_module-improvements-v1-1-8bea42b421aa@bootlin.com \
--to=luca.ceresoli@bootlin.com \
--cc=alexis.lothore@bootlin.com \
--cc=koct9i@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=swboyd@chromium.org \
--cc=thomas.petazzoni@bootlin.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