smalltalk
changeset 1326 e6197baf42c8
parent 1274 d087caa28ae3
child 1432 1e235b190ee3
--- a/smalltalk	Thu Oct 17 10:21:05 2013 +0200
+++ b/smalltalk	Thu Nov 28 12:34:32 2013 +0100
@@ -27,27 +27,11 @@
 # all other args go to stx & the user classes
 #
 
-if [ "$1" = "--help" ]
-then
-    echo
-    echo "usage: smalltalk [-x prog] [-X dir] [--ldd] [--gdb] stx-args"
-    echo
-    echo "Args to the smalltalk startup shell script:"
-    echo "   -x prog    use prog instead of stx as executable"
-    echo "   -X dir     use stx from dir instead of default (PATH)"
-    echo "   --ldd      show which shared libraries are used"
-    echo "   --gdb      run with gdb-Debugger (type r in debugger to start)"
-    echo "   --cgdb     run with cgdb-Debugger (type r in debugger to start)"
-    echo "   --callgrind  run under callgrind profiler tool"
-    echo "   stx-args   stx arguments as follows."
-    echo
-    echo "STX args:"
-fi
-
 STX=stx
 STX_BINDIR=.
 DEBUGGER=
 
+
 if test -x `dirname $0`/stx; then
     STX_BINDIR=`dirname $0`
     STX=$STX_BINDIR/stx
@@ -58,8 +42,8 @@
 then
     if [ ! -f $STX_LIBDIR/smalltalk.rc ]
     then
-	echo "smalltalk [warning]: ignore wrong STX_LIBDIR setting"
-	STX_LIBDIR=""
+       echo "smalltalk [warning]: ignore wrong STX_LIBDIR setting"
+       STX_LIBDIR=""
     fi
 fi
 
@@ -67,32 +51,32 @@
 # notice: STXLIBDIR is filled in here by install-sh script
 if test -z "$STX_LIBDIR"
 then
-	bindir=`dirname $0`
-	case "$bindir" in
-	    /* )
-		;;
-	    .* )
-		bindir=`( cd $bindir; pwd ) 2> /dev/null`
-		;;
-	esac
-	if [ -d ${bindir}/../lib ]
-	then
-	    STX_LIBDIR=`cd ${bindir}/../lib ; pwd`
-	fi
+    bindir=`dirname $0`
+    case "$bindir" in
+        /* )
+        ;;
+        .* )
+        bindir=`( cd $bindir; pwd ) 2> /dev/null`
+        ;;
+    esac
+    if [ -d ${bindir}/../lib ]
+    then
+        STX_LIBDIR=`cd ${bindir}/../lib ; pwd`
+    fi
 fi
 
 if [ -z "$STX_LIBDIR" ]
 then
     if [ -d ../lib ]
     then
-	STX_LIBDIR=`cd ../lib ; pwd`
+        STX_LIBDIR=`cd ../lib ; pwd`
     fi
 fi
 if [ ! -d "$STX_LIBDIR" ]
 then
     if [ -d ../lib ]
     then
-	STX_LIBDIR=`cd ../lib ; pwd`
+        STX_LIBDIR=`cd ../lib ; pwd`
     fi
 fi
 
@@ -100,35 +84,37 @@
 then
     if [ -d ../packages ]
     then
-	STX_PACKAGEDIR=`cd .. ; pwd`
+        STX_PACKAGEDIR=`cd .. ; pwd`
     else
-	if [ -d $STX_LIBDIR/../packages ]
-	then
-	    STX_PACKAGEDIR=`cd $STX_LIBDIR/../packages ; pwd`
-	else
-	    if [ -f $STX_BINDIR/smalltalk.rc ]
-	    then
-		STX_PACKAGEDIR=`cd $STX_BINDIR/../../.. ; pwd`
-	    fi
-	fi
+        if [ -d $STX_LIBDIR/../packages ]
+        then
+            STX_PACKAGEDIR=`cd $STX_LIBDIR/../packages ; pwd`
+        else
+            if [ -f $STX_BINDIR/smalltalk.rc ]
+            then
+                STX_PACKAGEDIR=`cd $STX_BINDIR/../../.. ; pwd`
+            fi
+        fi
     fi
 fi
 
+
+
 if test -z "$STX_TOPDIR"
 then
     if [ -f ../lib/smalltalk.rc ]
     then
-	STX_TOPDIR=`cd .. ; pwd`
+        STX_TOPDIR=`cd .. ; pwd`
     else
-	if [ -f $STX_LIBDIR/../lib/smalltalk.rc ]
-	then
-	    STX_TOPDIR=`cd $STX_LIBDIR/.. ; pwd`
-	else
-	    if [ -f $STX_BINDIR/smalltalk.rc ]
-	    then
-		STX_TOPDIR=`cd $STX_BINDIR/../.. ; pwd`
-	    fi
-	fi
+       if [ -f $STX_LIBDIR/../lib/smalltalk.rc ]
+       then
+           STX_TOPDIR=`cd $STX_LIBDIR/.. ; pwd`
+       else
+           if [ -f $STX_BINDIR/smalltalk.rc ]
+           then
+              STX_TOPDIR=`cd $STX_BINDIR/../.. ; pwd`
+           fi
+       fi
     fi
 fi
 
@@ -140,6 +126,26 @@
 
 # echo STX is $STX
 
+
+if [ "$1" = "--help" ]
+then    
+    echo "
+usage: smalltalk [-x prog] [-X dir] [--ldd] [--gdb] 
+
+args to startup script:
+   -x prog ................ use prog instead of stx as executable
+   -X dir ................. use stx from dir instead of default (PATH)
+   --ldd .................. show which shared libraries are used
+   --gdb .................. run with gdb-Debugger (type r in debugger to start)
+   --cgdb ................. run with cgdb-Debugger (type r in debugger to start)
+   --callgrind ............ run under callgrind profiler tool
+   --stap SCRIPT .......... run given systemtap script, passing stx command as 
+                            stap -c 'stx ...' Systemtap may not be compiled in.
+"
+    exec $STX --help
+    exit 0
+fi
+
 if [ "$1" = "-x" ]
 then
     shift
@@ -172,6 +178,21 @@
     DEBUGGER="valgrind --tool=callgrind --instr-atstart=no"
 fi
 
+if [ "$1" = "--stap" ]
+then
+    shift
+    if [ -z "$1" ]; then 
+        echo "--stap requires systemtap script to run"
+        exit 1
+    fi
+    if [ ! -r "$1" ]; then
+        echo "$1 is not a readable systemtap script"
+        echo "--stap requires systemtap script to run"
+        exit 1
+    fi
+    STAPSCRIPT=$1
+    shift
+fi
 
 
 if [ "$1" = "--ldd" ]
@@ -188,28 +209,28 @@
 then
     if [ "$LD_LIBRARY_PATH" != "" ]
     then
-	LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/openwin/lib:/usr/local/lib/smalltalk/lib
+    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/openwin/lib:/usr/local/lib/smalltalk/lib
     else
-	LD_LIBRARY_PATH=/usr/openwin/lib:/usr/local/lib/smalltalk/lib
+    LD_LIBRARY_PATH=/usr/openwin/lib:/usr/local/lib/smalltalk/lib
     fi
     if [ "$SHLIB_PATH" != "" ]
     then
-	SHLIB_PATH=$SHLIB_PATH:/usr/openwin/lib:/usr/local/lib/smalltalk/lib
+    SHLIB_PATH=$SHLIB_PATH:/usr/openwin/lib:/usr/local/lib/smalltalk/lib
     else
-	SHLIB_PATH=/usr/openwin/lib:/usr/local/lib/smalltalk/lib
+    SHLIB_PATH=/usr/openwin/lib:/usr/local/lib/smalltalk/lib
     fi
 else
     if [ "$LD_LIBRARY_PATH" != "" ]
     then
-	LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/smalltalk/lib
+    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/smalltalk/lib
     else
-	LD_LIBRARY_PATH=/usr/local/lib/smalltalk/lib
+    LD_LIBRARY_PATH=/usr/local/lib/smalltalk/lib
     fi
     if [ "$SHLIB_PATH" != "" ]
     then
-	SHLIB_PATH=$SHLIB_PATH:/usr/local/lib/smalltalk/lib
+    SHLIB_PATH=$SHLIB_PATH:/usr/local/lib/smalltalk/lib
     else
-	SHLIB_PATH=/usr/local/lib/smalltalk/lib
+    SHLIB_PATH=/usr/local/lib/smalltalk/lib
     fi
 fi
 
@@ -223,8 +244,8 @@
 then
     if [ "$STX_LIBDIR" != "/usr/local/smalltalk" ]
     then
-	LD_LIBRARY_PATH=$STX_LIBDIR:$STX_LIBDIR/lib:$LD_LIBRARY_PATH
-	SHLIB_PATH=$STX_LIBDIR:$STX_LIBDIR/lib:$SHLIB_PATH
+    LD_LIBRARY_PATH=$STX_LIBDIR:$STX_LIBDIR/lib:$LD_LIBRARY_PATH
+    SHLIB_PATH=$STX_LIBDIR:$STX_LIBDIR/lib:$SHLIB_PATH
     fi
 else
     STX_LIBDIR=$STX_BINDIR
@@ -238,8 +259,8 @@
 then
     if [ "$STX_BINDIR" != "/usr/local/bin" ]
     then
-	LD_LIBRARY_PATH=$STX_BINDIR:$LD_LIBRARY_PATH
-	SHLIB_PATH=$STX_BINDIR:$SHLIB_PATH
+    LD_LIBRARY_PATH=$STX_BINDIR:$LD_LIBRARY_PATH
+    SHLIB_PATH=$STX_BINDIR:$SHLIB_PATH
     fi
 fi
 
@@ -254,9 +275,9 @@
 #
 case $0 in
     ./*)
-	PATH=.:$PATH
-	export PATH
-	;;
+    PATH=.:$PATH
+    export PATH
+    ;;
 esac
 
 #
@@ -313,4 +334,16 @@
 export PATH
 # echo PATH is $PATH
 # echo DISPLAY is $DISPLAY
+
+
+
+if [ ! -z "$STAPSCRIPT" ]; then
+    echo "$STX_TOPDIR/stx/hacking/tapset"
+    CMD="$STX $@"
+    echo "$CMD"
+    exec stap --unprivileged $STAPSCRIPT -I "$STX_TOPDIR/hacking/tapset" -c "$CMD"
+fi
+
+
+
 exec $DEBUGGER $STX ${1+"$@"}