diff options
Diffstat (limited to 'tools/art')
| -rw-r--r-- | tools/art | 47 |
1 files changed, 40 insertions, 7 deletions
@@ -1,5 +1,3 @@ -#!/bin/bash -# # Copyright (C) 2011 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +# This script is used on host and device. It uses a common subset +# shell dialect that should work on the host (e.g. bash), and +# Android (e.g. mksh). + function follow_links() { if [ z"$BASH_SOURCE" != z ]; then file="$BASH_SOURCE" @@ -28,7 +30,8 @@ function follow_links() { } function find_libdir() { - if [ "$(readlink "$ANDROID_ROOT/bin/$DALVIKVM")" = "dalvikvm64" ]; then + # Use realpath instead of readlink because Android does not have a readlink. + if [ "$(realpath "$ANDROID_ROOT/bin/$DALVIKVM")" = "$(realpath "$ANDROID_ROOT/bin/dalvikvm64")" ]; then echo "lib64" else echo "lib" @@ -53,6 +56,12 @@ while true; do elif [ "$1" = "--64" ]; then DALVIKVM=dalvikvm64 shift + elif [ "$1" = "--perf" ]; then + PERF="record" + shift + elif [ "$1" = "--perf-report" ]; then + PERF="report" + shift elif expr "$1" : "--" >/dev/null 2>&1; then echo "unknown option: $1" 1>&2 exit 1 @@ -64,18 +73,42 @@ done PROG_NAME="$(follow_links)" PROG_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)" ANDROID_ROOT=$PROG_DIR/.. -ANDROID_DATA=$PWD/android-data$$ LIBDIR=$(find_libdir) LD_LIBRARY_PATH=$ANDROID_ROOT/$LIBDIR -mkdir -p $ANDROID_DATA/dalvik-cache/{arm,arm64,x86,x86_64} +DELETE_ANDROID_DATA=false +# If ANDROID_DATA is the system ANDROID_DATA or is not set, use our own, +# and ensure we delete it at the end. +if [ "$ANDROID_DATA" = "/data" ] || [ "$ANDROID_DATA" = "" ]; then + ANDROID_DATA=$PWD/android-data$$ + mkdir -p $ANDROID_DATA/dalvik-cache/{arm,arm64,x86,x86_64} + DELETE_ANDROID_DATA=true +fi + +if [ z"$PERF" != z ]; then + invoke_with="perf record -o $ANDROID_DATA/perf.data -e cycles:u $invoke_with" +fi + ANDROID_DATA=$ANDROID_DATA \ ANDROID_ROOT=$ANDROID_ROOT \ LD_LIBRARY_PATH=$LD_LIBRARY_PATH \ $invoke_with $ANDROID_ROOT/bin/$DALVIKVM $lib \ -XXlib:$LIBART \ -Ximage:$ANDROID_ROOT/framework/core.art \ - "$@" + -Xcompiler-option --include-debug-symbols \ + "$@" + EXIT_STATUS=$? -rm -rf $ANDROID_DATA + +if [ z"$PERF" != z ]; then + if [ z"$PERF" = zreport ]; then + perf report -i $ANDROID_DATA/perf.data + fi + echo "Perf data saved in: $ANDROID_DATA/perf.data" +else + if [ "$DELETE_ANDROID_DATA" = "true" ]; then + rm -rf $ANDROID_DATA + fi +fi + exit $EXIT_STATUS |
