]> Zhao Yanbai Git Server - minix.git/commitdiff
a script to decode stack traces.
authorBen Gras <ben@minix3.org>
Wed, 21 Mar 2007 09:33:39 +0000 (09:33 +0000)
committerBen Gras <ben@minix3.org>
Wed, 21 Mar 2007 09:33:39 +0000 (09:33 +0000)
commands/scripts/Makefile
commands/scripts/unstack.sh [new file with mode: 0644]

index 2fee8db0c13179929b318e293caddec9ec787443..4d98a77da778fb087efab738152d71b722bc49ec 100755 (executable)
@@ -48,6 +48,7 @@ usr:  \
        /usr/bin/spell \
        /usr/bin/srccrc \
        /usr/bin/svclog \
+       /usr/bin/unstack \
        /usr/bin/version \
        /usr/bin/whatis \
                /usr/bin/apropos \
@@ -161,6 +162,9 @@ clean:
 /usr/bin/version:      version.sh
        install -m 755 -c -o bin $? $@
 
+/usr/bin/unstack:      unstack.sh
+       install -m 755 -c -o bin $? $@
+
 /usr/bin/whatis:       whatis.sh
        install -m 755 -c -o bin $? $@
 
diff --git a/commands/scripts/unstack.sh b/commands/scripts/unstack.sh
new file mode 100644 (file)
index 0000000..d32cb71
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+if [ $# -lt 1 ]
+then   echo "Usage: $0 <executable> [0x... [0x... ] ]"
+       exit 1
+fi
+
+executable=$1
+shift
+
+while [ $# -gt 0 ]
+do     dec="`printf %d $1`"
+       nm -d -n $executable | grep ' [Tt] ' | awk '
+         {  if($1 > '$dec') { printf "%s+0x%x\n", name, '$dec'-offset; exit }
+            name=$3; offset=$1
+         }'
+       shift
+done