Add vogar-like --invoke-with to 'art', and fix a bug valgrind finds.

Also add -d to run aexecd.

Change-Id: I38fefd9ad2e08b42039cb2a09351b4e6e30a9c5c
diff --git a/src/jni_internal.cc b/src/jni_internal.cc
index b08d12a..94e67a4 100644
--- a/src/jni_internal.cc
+++ b/src/jni_internal.cc
@@ -2324,7 +2324,6 @@
   } else {
     JavaVMExt* raw_vm = reinterpret_cast<JavaVMExt*>(vm);
     delete raw_vm->runtime;
-    raw_vm->runtime = NULL;
     return JNI_OK;
   }
 }
diff --git a/tools/art b/tools/art
index 8033c51..67bbad0 100755
--- a/tools/art
+++ b/tools/art
@@ -14,11 +14,30 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+aexec=aexec
+invoke_with=
+
+while true; do
+  if [ "$1" = "--invoke-with" ]; then
+    shift
+    invoke_with="$1"
+    shift
+  elif [ "$1" = "-d" ]; then
+    aexec="aexecd"
+    shift
+  elif expr "$1" : "--" >/dev/null 2>&1; then
+    echo "unknown option: $1" 1>&2
+    exit 1
+  else
+    break
+  fi
+done
+
 mkdir -p /tmp/android-data/art-cache
 ANDROID_DATA=/tmp/android-data \
 ANDROID_ROOT=$ANDROID_BUILD_TOP/out/host/linux-x86 \
 LD_LIBRARY_PATH=$ANDROID_BUILD_TOP/out/host/linux-x86/lib \
-$ANDROID_BUILD_TOP/out/host/linux-x86/bin/aexec \
+$invoke_with $ANDROID_BUILD_TOP/out/host/linux-x86/bin/$aexec \
 -Xbootclasspath\
 :$ANDROID_BUILD_TOP/out/host/linux-x86/framework/core-hostdex.jar\
 :$ANDROID_BUILD_TOP/out/host/linux-x86/framework/core-junit-hostdex.jar\