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 | # (c) 2014, Sasha Levin <sasha.levin@oracle.com> | 3 | # (c) 2014, Sasha Levin <sasha.levin@oracle.com> |
| 4 | #set -x | 4 | #set -x |
| 5 | 5 | ||
| 6 | if [[ $# < 2 ]]; then | 6 | if [[ $# < 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 1 | 9 | exit 1 |
| 10 | fi | 10 | fi |
| 11 | 11 | ||
| 12 | vmlinux=$1 | 12 | vmlinux=$1 |
| 13 | basepath=$2 | 13 | basepath=${2-auto} |
| 14 | modpath=$3 | 14 | modpath=$3 |
| 15 | declare -A cache | 15 | declare -A cache |
| 16 | declare -A modcache | 16 | declare -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 | ||
| 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 | while read line; do | 163 | while read line; do |
| 156 | # Let's see if we have an address in the line | 164 | # Let's see if we have an address in the line |
| 157 | if [[ $line =~ \[\<([^]]+)\>\] ]] || | 165 | if [[ $line =~ \[\<([^]]+)\>\] ]] || |