History

scripts/decode_stacktrace.sh: guess basepath if not specified

Guess path to kernel sources using known location of symbol "kernel_init". Make basepath argument optional. Before: $ echo 'vfs_open+0x0/0x0' | ./scripts/decode_stacktrace.sh vmlinux "" vfs_open (home/khlebnikov/src/linux/fs/open.c:912) After: $ echo 'vfs_open+0x0/0x0' | ./scripts/decode_stacktrace.sh vmlinux vfs_open (fs/open.c:912)

Konstantin Khlebnikov committed 6 years ago

Commit ecda6e21 parent f643b9e1 file · +11 −3Browse files

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

Unified · Split

scripts/decode_stacktrace.sh+11−3
@@ -3,14 +3,14 @@ · 2 unmodified lines
33 # (c) 2014, Sasha Levin <sasha.levin@oracle.com>
44 #set -x
55
6−if [[ $# < 2 ]]; then
6+if [[ $# < 1 ]]; then
77 echo "Usage:"
8− echo " $0 [vmlinux] [base path] [modules path]"
8+ echo " $0 <vmlinux> [base path] [modules path]"
99 exit 1
1010 fi
1111
1212 vmlinux=$1
13−basepath=$2
13+basepath=${2-auto}
1414 modpath=$3
1515 declare -A cache
1616 declare -A modcache
@@ -152,6 +152,14 @@ handle_line() { · 135 unmodified lines
152152 echo "${words[@]}" "$symbol $module"
153153 }
154154
155+if [[ $basepath == "auto" ]] ; then
156+ module=""
157+ symbol="kernel_init+0x0/0x0"
158+ parse_symbol
159+ basepath=${symbol#kernel_init (}
160+ basepath=${basepath%/init/main.c:*)}
161+fi
162+
155163 while read line; do
156164 # Let's see if we have an address in the line
157165 if [[ $line =~ \[\<([^]]+)\>\] ]] ||