History

scripts/decode_stacktrace.sh: remove find_module recursion and improve error reporting

Patch series "scripts/decode_stacktrace.sh: improve error reporting and usability", v2. This small series improves usability of scripts/decode_stacktrace.sh by improving the usage text and correctly reporting when modules are built without debugging symbols. This patch (of 3): 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 debuginfo 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.

Luca Ceresoli committed 2 years ago

Commit 0f69dc21 parent 38676d91 file · +20 −20Browse files

Showing the changes to scripts/decode_stacktrace.sh (1 of 1 file). Show all

Unified · Split

scripts/decode_stacktrace.sh+20−20
@@ -89,31 +89,32 @@ find_module() { · 88 unmodified lines
89 fi89 fi
90 fi90 fi
91 91
92 if [[ "$modpath" != "" ]] ; then92 if [ -z $release ] ; then
93 for fn in $(find "$modpath" -name "${module//_/[-_]}.ko*") ; do
94 if ${READELF} -WS "$fn" | grep -qwF .debug_line ; then
95 echo $fn
96 return
97 fi
98 done
99 return 1
100 fi
101
102 modpath=$(dirname "$vmlinux")
103 find_module && return
104
105 if [[ $release == "" ]] ; then
106 release=$(gdb -ex 'print init_uts_ns.name.release' -ex 'quit' -quiet -batch "$vmlinux" 2>/dev/null | sed -n 's/\$1 = "\(.*\)".*/\1/p')93 release=$(gdb -ex 'print init_uts_ns.name.release' -ex 'quit' -quiet -batch "$vmlinux" 2>/dev/null | sed -n 's/\$1 = "\(.*\)".*/\1/p')
107 fi94 fi
95 if [ -n "${release}" ] ; then
96 release_dirs="/usr/lib/debug/lib/modules/$release /lib/modules/$release"
97 fi
108 98
109 for dn in {/usr/lib/debug,}/lib/modules/$release ; do99 found_without_debug_info=false
110 if [ -e "$dn" ] ; then100 for dir in "$modpath" "$(dirname "$vmlinux")" ${release_dirs}; do
111 modpath="$dn"101 if [ -n "${dir}" ] && [ -e "${dir}" ]; then
112 find_module && return102 for fn in $(find "$dir" -name "${module//_/[-_]}.ko*") ; do
103 if ${READELF} -WS "$fn" | grep -qwF .debug_line ; then
104 echo $fn
105 return
106 fi
107 found_without_debug_info=true
108 done
113 fi109 fi
114 done110 done
115 111
116 modpath=""112 if [[ ${found_without_debug_info} == true ]]; then
113 echo "WARNING! No debugging info in module ${module}, rebuild with DEBUG_KERNEL and DEBUG_INFO" >&2
114 else
115 echo "WARNING! Cannot find .ko for module ${module}, please pass a valid module path" >&2
116 fi
117
117 return 1118 return 1
118}119}
119 120
@@ -131,7 +132,6 @@ parse_symbol() { · 11 unmodified lines
131 else132 else
132 local objfile=$(find_module)133 local objfile=$(find_module)
133 if [[ $objfile == "" ]] ; then134 if [[ $objfile == "" ]] ; then
134 echo "WARNING! Modules path isn't set, but is needed to parse this symbol" >&2
135 return135 return
136 fi136 fi
137 if [[ $aarray_support == true ]]; then137 if [[ $aarray_support == true ]]; then

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t