1#!/bin/sh 2# 3# Run the code in test.jar on a host-local virtual machine. The jar should 4# contain a top-level class named Main to run. 5# 6# Options: 7# --quiet -- don't chatter 8# --fast -- use the fast interpreter (the default) 9# --portable -- use the portable interpreter 10# --debug -- wait for debugger to attach 11# --valgrind -- use valgrind 12# --no-verify -- turn off verification (on by default) 13# --no-optimize -- turn off optimization (on by default) 14 15msg() { 16 if [ "$QUIET" = "n" ]; then 17 echo "$@" 18 fi 19} 20 21INTERP="" 22DEBUG="n" 23GDB="n" 24VERIFY="y" 25OPTIMIZE="y" 26VALGRIND="n" 27DEV_MODE="n" 28QUIET="n" 29 30while true; do 31 if [ "x$1" = "x--quiet" ]; then 32 QUIET="y" 33 shift 34 elif [ "x$1" = "x--fast" ]; then 35 INTERP="fast" 36 msg "Using fast interpreter" 37 shift 38 elif [ "x$1" = "x--portable" ]; then 39 INTERP="portable" 40 msg "Using portable interpreter" 41 shift 42 elif [ "x$1" = "x--debug" ]; then 43 DEBUG="y" 44 shift 45 elif [ "x$1" = "x--gdb" ]; then 46 GDB="y" 47 shift 48 elif [ "x$1" = "x--valgrind" ]; then 49 VALGRIND="y" 50 shift 51 elif [ "x$1" = "x--dev" ]; then 52 DEV_MODE="y" 53 shift 54 elif [ "x$1" = "x--no-verify" ]; then 55 VERIFY="n" 56 shift 57 elif [ "x$1" = "x--no-optimize" ]; then 58 OPTIMIZE="n" 59 shift 60 elif [ "x$1" = "x--" ]; then 61 shift 62 break 63 elif expr "x$1" : "x--" >/dev/null 2>&1; then 64 echo "unknown option: $1" 1>&2 65 exit 1 66 else 67 break 68 fi 69done 70 71if [ "x$INTERP" = "x" ]; then 72 INTERP="fast" 73 msg "Using fast interpreter by default" 74fi 75 76if [ "$OPTIMIZE" = "y" ]; then 77 if [ "$VERIFY" = "y" ]; then 78 DEX_OPTIMIZE="-Xdexopt:verified" 79 else 80 DEX_OPTIMIZE="-Xdexopt:all" 81 fi 82 msg "Performing optimizations" 83else 84 DEX_OPTIMIZE="-Xdexopt:none" 85 msg "Skipping optimizations" 86fi 87 88if [ "$VERIFY" = "y" ]; then 89 DEX_VERIFY="" 90 msg "Performing verification" 91else 92 DEX_VERIFY="-Xverify:none" 93 msg "Skipping verification" 94fi 95 96if [ "$VALGRIND" = "y" ]; then 97 msg "Running with valgrind" 98 valgrind_cmd="valgrind" 99 #valgrind_cmd="$valgrind_cmd --leak-check=full" 100else 101 valgrind_cmd="" 102fi 103 104msg "------------------------------" 105 106BASE="$OUT" # from build environment 107DATA_DIR=/tmp 108DEBUG_OPTS="-Xcheck:jni -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" 109 110export ANDROID_PRINTF_LOG=brief 111if [ "$DEV_MODE" = "y" ]; then 112 export ANDROID_LOG_TAGS='*:d' 113else 114 export ANDROID_LOG_TAGS='*:s' 115fi 116export ANDROID_DATA="$DATA_DIR" 117export ANDROID_ROOT="${BASE}/system" 118export LD_LIBRARY_PATH="${BASE}/system/lib" 119export DYLD_LIBRARY_PATH="${BASE}/system/lib" 120 121exe="${BASE}/system/bin/dalvikvm" 122framework="${BASE}/system/framework" 123bpath="${framework}/core.jar:${framework}/ext.jar:${framework}/framework.jar" 124 125if [ "$DEBUG" = "y" ]; then 126 PORT=8000 127 msg "Waiting for debugger to connect on localhost:$PORT" 128 DEX_DEBUG="-agentlib:jdwp=transport=dt_socket,addres=$PORT,server=y,suspend=y" 129fi 130 131if [ "$GDB" = "y" ]; then 132 gdb=gdb 133 gdbargs="--args $exe" 134fi 135 136$valgrind_cmd $gdb $exe $gdbargs "-Xbootclasspath:${bpath}" \ 137 $DEX_VERIFY $DEX_OPTIMIZE $DEX_DEBUG "-Xint:${INTERP}" -ea \ 138 -cp test.jar Main "$@" 139