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)
Showing the changes to scripts/decode_stacktrace.sh (1 of 1 file). Show all
Unified · Split
| @@ -3,14 +3,14 @@ · 2 unmodified lines | ||
| 3 | 3 | # (c) 2014, Sasha Levin <sasha.levin@oracle.com> |
| 4 | 4 | #set -x |
| 5 | 5 | |
| 6 | −if [[ $# < 2 ]]; then | |
| 6 | +if [[ $# < 1 ]]; then | |
| 7 | 7 | echo "Usage:" |
| 8 | − echo " $0 [vmlinux] [base path] [modules path]" | |
| 8 | + echo " $0 <vmlinux> [base path] [modules path]" | |
| 9 | 9 | exit 1 |
| 10 | 10 | fi |
| 11 | 11 | |
| 12 | 12 | vmlinux=$1 |
| 13 | −basepath=$2 | |
| 13 | +basepath=${2-auto} | |
| 14 | 14 | modpath=$3 |
| 15 | 15 | declare -A cache |
| 16 | 16 | declare -A modcache |
| @@ -152,6 +152,14 @@ handle_line() { · 135 unmodified lines | ||
| 152 | 152 | echo "${words[@]}" "$symbol $module" |
| 153 | 153 | } |
| 154 | 154 | |
| 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 | + | |
| 155 | 163 | while read line; do |
| 156 | 164 | # Let's see if we have an address in the line |
| 157 | 165 | if [[ $line =~ \[\<([^]]+)\>\] ]] || |