[Vm-dev] [commit][3011] Add a useful script for linux VM debugging.

commits at squeakvm.org commits at squeakvm.org
Fri Jun 20 18:20:29 UTC 2014


Revision: 3011
Author:   eliot
Date:     2014-06-20 11:20:08 -0700 (Fri, 20 Jun 2014)
Log Message:
-----------
Add a useful script for linux VM debugging.

Added Paths:
-----------
    branches/Cog/scripts/setLD_LIBRARY_PATH

Added: branches/Cog/scripts/setLD_LIBRARY_PATH
===================================================================
--- branches/Cog/scripts/setLD_LIBRARY_PATH	                        (rev 0)
+++ branches/Cog/scripts/setLD_LIBRARY_PATH	2014-06-20 18:20:08 UTC (rev 3011)
@@ -0,0 +1,46 @@
+# Set SQUEAK_PLUGINS and LD_LIBRARY_PATH to include the containing directory
+# of the VM arg. MUST NOT BE EXECUTED IN A SUBSHELL
+BIN="`dirname $1`"
+export SQUEAK_PLUGINS="$BIN"
+echo Make sure you invoke this as . setLD_LIBRARY_PATH
+# At least on linux LD_LIBRARY_PATH's components must be absolute path names
+case "$BIN" in
+/*) PLUGINS="$BIN";;
+*) PLUGINS="`pwd`/$BIN"
+esac
+# On some linuxes there multiple versions of the C library.  If the image uses
+# libc (e.g. through the FFI) then it must use the same version that the VM uses
+# and so it should take precedence over /lib libc.  This is done by setting
+# LD_LIBRARY_PATH appropriately, based on ldd's idea of the libc use by the VM.
+LIBC_SO="`/usr/bin/ldd "$1" | /bin/fgrep /libc. | sed 's/^.*=> \([^ ]*\).*/\1/'`"
+case "$LIBC_SO" in
+/lib/libc*)					SVMLLP="/lib:/usr/lib";;
+/lib32/libc*)				SVMLLP="/lib32:/usr/lib32";;
+/lib64/libc*)				SVMLLP="/lib64:/usr/lib64";;
+/lib/tls/libc*)				SVMLLP="/lib/tls:/lib:/usr/lib/tls:/usr/lib";;
+/lib/i386-linux-gnu/libc*)	\
+	SVMLLP="/lib/i386-linux-gnu:/lib:/usr/lib/i386-linux-gnu:/usr/lib";;
+/lib/i386-linux-gnu/i686/cmov/libc*)	\
+	SVMLLP="/lib/i386-linux-gnu/i686/cmov:/lib:/usr/lib/i386-linux-gnu/i686/cmov:/usr/lib";;
+/lib/386-linux-gnu/i686/cmov/libc*)	\
+	SVMLLP="/lib/386-linux-gnu/i686/cmov:/lib:/usr/lib/386-linux-gnu/i686/cmov:/usr/lib";;
+/lib/tls/i686/cmov/libc*)	\
+	SVMLLP="/lib/tls/i686/cmov:/lib:/usr/lib/tls/i686/cmov:/usr/lib";;
+/lib/tls/i686/nosegneg/libc*)	\
+	SVMLLP="/lib/i686/nosegneg/tls:/lib:/usr/lib/i686/nosegneg/tls:/usr/lib";;
+/lib/arm-linux-gnueabihf/libc*)	\
+	SVMLLP="/lib/arm-linux-gnueabihf:/lib:/usr/lib/arm-linux-gnueabihf:/usr/lib";;
+"")	case `/bin/uname -m || /usr/bin/uname -m` in
+	*64*)	echo "/usr/bin/ldd didn't produce any output and the system is 64 bit.  You may need to (re)install the 32-bit libraries." 1>&2;;
+	*)	echo "/usr/bin/ldd didn't produce any output. Can't infer base LD_LIBRARY_PATH. Aborting." 1>&2
+	esac
+	exit 1;;
+*)	echo "Can't infer base LD_LIBRARY_PATH. Aborting. Try adding a line for $LIBC_SO to $0. Please report your edit to nsvm vm-dev." 1>&2
+	exit 1
+esac
+# prepending is less flexible but safer because it ensures we find the plugins
+# in the same directory as the VM.  We must include at least /lib and /usr/lib
+# if libraries there-in are to be found.  These directories are not implicit.
+export LD_LIBRARY_PATH=$PLUGINS:$SVMLLP
+echo export SQUEAK_PLUGINS="$BIN"
+echo export LD_LIBRARY_PATH=$PLUGINS:$SVMLLP


Property changes on: branches/Cog/scripts/setLD_LIBRARY_PATH
___________________________________________________________________
Added: svn:executable
   + *



More information about the Vm-dev mailing list