Skip to content

Commit ecda6e2

Browse files
koct9itorvalds
authored andcommitted
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) Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Sasha Levin <sashal@kernel.org> Link: http://lkml.kernel.org/r/159282922803.248444.2379229451667913634.stgit@buzz Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f643b9e commit ecda6e2

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎scripts/decode_stacktrace.sh‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
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() {
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 =~ \[\<([^]]+)\>\] ]] ||

0 commit comments

Comments
 (0)