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
3# (c) 2014, Sasha Levin <sasha.levin@oracle.com>3# (c) 2014, Sasha Levin <sasha.levin@oracle.com>
4#set -x4#set -x
5 5
6if [[ $# < 2 ]]; then6if [[ $# < 1 ]]; then
7 echo "Usage:"7 echo "Usage:"
8 echo " $0 [vmlinux] [base path] [modules path]"8 echo " $0 <vmlinux> [base path] [modules path]"
9 exit 19 exit 1
10fi10fi
11 11
12vmlinux=$112vmlinux=$1
13basepath=$213basepath=${2-auto}
14modpath=$314modpath=$3
15declare -A cache15declare -A cache
16declare -A modcache16declare -A modcache
@@ -152,6 +152,14 @@ handle_line() { · 135 unmodified lines
152 echo "${words[@]}" "$symbol $module"152 echo "${words[@]}" "$symbol $module"
153}153}
154 154
155if [[ $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:*)}
161fi
162
155while read line; do163while read line; do
156 # Let's see if we have an address in the line164 # Let's see if we have an address in the line
157 if [[ $line =~ \[\<([^]]+)\>\] ]] ||165 if [[ $line =~ \[\<([^]]+)\>\] ]] ||