Add tools to support gdb and simpleperf for android executables.

Change-Id: I6e7f41df094ae037538ebd61e40385d7e2e9eb26
Reviewed-on: https://skia-review.googlesource.com/6615
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Derek Sollenberger 2017-01-05 11:39:04 -05:00 committed by Skia Commit-Bot
parent a9e3266a21
commit 70120c778a
8 changed files with 45 additions and 23 deletions

View File

@ -1380,6 +1380,28 @@ if (skia_enable_tools) {
}
}
if (is_android) {
copy("gdbserver") {
sources = [
"$ndk/$ndk_gdbserver",
]
outputs = [
"$root_out_dir/gdbserver",
]
}
if (ndk_simpleperf != "") {
copy("simpleperf") {
sources = [
"$ndk/$ndk_simpleperf",
"$ndk/simpleperf/simpleperf_report.py",
]
outputs = [
"$root_out_dir/{{source_file_part}}",
]
}
}
}
if (skia_enable_gpu) {
test_app("skslc") {
sources = [

View File

@ -58,6 +58,8 @@ if (is_android) {
ndk_platform = ""
ndk_stdlib = ""
ndk_gccdir = ""
ndk_gdbserver = ""
ndk_simpleperf = ""
if (host_os == "linux") {
ndk_host = "linux-x86_64"
@ -72,31 +74,41 @@ if (is_android) {
ndk_platform = "android-${ndk_api}/arch-arm64"
ndk_stdlib = "arm64-v8a"
ndk_gccdir = ndk_target
ndk_gdbserver = "prebuilt/android-arm64/gdbserver/gdbserver"
ndk_simpleperf = "simpleperf/android/arm64/simpleperf"
} else if (target_cpu == "arm") {
ndk_target = "arm-linux-androideabi"
ndk_platform = "android-${ndk_api}/arch-arm"
ndk_stdlib = "armeabi-v7a"
ndk_gccdir = ndk_target
ndk_gdbserver = "prebuilt/android-arm/gdbserver/gdbserver"
ndk_simpleperf = "simpleperf/android/arm/simpleperf"
} else if (target_cpu == "mips64el") {
ndk_target = "mips64el-linux-android"
ndk_platform = "android-${ndk_api}/arch-mips64"
ndk_stdlib = "mips64"
ndk_gccdir = ndk_target
ndk_gdbserver = "prebuilt/android-mips64/gdbserver/gdbserver"
} else if (target_cpu == "mipsel") {
ndk_target = "mipsel-linux-android"
ndk_platform = "android-${ndk_api}/arch-mips"
ndk_stdlib = "mips"
ndk_gccdir = ndk_target
ndk_gdbserver = "prebuilt/android-mips/gdbserver/gdbserver"
} else if (target_cpu == "x64") {
ndk_target = "x86_64-linux-android"
ndk_platform = "android-${ndk_api}/arch-x86_64"
ndk_stdlib = "x86_64"
ndk_gccdir = ndk_stdlib
ndk_gdbserver = "prebuilt/android-x86_64/gdbserver/gdbserver"
ndk_simpleperf = "simpleperf/android/x86_64/simpleperf"
} else if (target_cpu == "x86") {
ndk_target = "i686-linux-android"
ndk_platform = "android-${ndk_api}/arch-x86"
ndk_stdlib = "x86"
ndk_gccdir = ndk_stdlib
ndk_gdbserver = "prebuilt/android-x86/gdbserver/gdbserver"
ndk_simpleperf = "simpleperf/android/x86/simpleperf"
}
}

View File

@ -7,7 +7,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/utils/android_setup.sh
# setup the gdbserver
$SCRIPT_DIR/android_gdbserver -d ${DEVICE_ID} ${APP_ARGS[@]}
$SCRIPT_DIR/android_gdbserver -C ${SKIA_OUT} ${APP_ARGS[@]}
# quit if gdbserver setup failed
if [[ "$?" != "0" ]]; then

View File

@ -58,7 +58,7 @@ cp "$TARGET_EXE" $GDB_TMP_DIR
adb_push_if_needed "${TARGET_EXE}" /data/local/tmp
echo "Pushing gdbserver..."
adb_push_if_needed $GDBSERVER_DIR/gdbserver/gdbserver /data/local/tmp
adb_push_if_needed $SKIA_OUT/gdbserver /data/local/tmp
echo "Setting up port forward"
$ADB forward "tcp:5039" "tcp:5039"

View File

@ -9,7 +9,7 @@ source $SCRIPT_DIR/utils/setup_adb.sh
# TODO: check to ensure that the app exists on the device and prompt to install
if [[ -n $RESOURCE_PATH ]]; then
adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH
adb_push_if_needed "${SCRIPT_DIR}/../../../resources" $RESOURCE_PATH
fi
activity="org.skia.viewer/org.skia.viewer.ViewerActivity"

View File

@ -12,15 +12,6 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $SCRIPT_DIR/utils/android_setup.sh
source $SCRIPT_DIR/utils/setup_adb.sh
if [ $(uname) == "Linux" ]; then
PERFHOST=$SCRIPT_DIR/linux/perfhost
elif [ $(uname) == "Darwin" ]; then
PERFHOST=$SCRIPT_DIR/mac/perfhost
else
echo "Could not automatically determine OS!"
exit 1;
fi
# grab and remove the perf command from the input args
PERF_CMD=${APP_ARGS[0]}
unset APP_ARGS[0]
@ -42,7 +33,6 @@ perf_setup() {
echo "Copying symbol files"
adb_pull_if_needed /system/lib/libc.so $TMP_SYS_LIB
adb_pull_if_needed /system/lib/libstdc++.so $TMP_SYS_LIB
adb_pull_if_needed /system/lib/libstlport.so $TMP_SYS_LIB
adb_pull_if_needed /system/lib/libGLESv2.so $TMP_SYS_LIB
adb_pull_if_needed /system/lib/libandroid.so $TMP_SYS_LIB
adb_pull_if_needed /system/lib/libm.so $TMP_SYS_LIB
@ -55,6 +45,9 @@ perf_setup() {
exit 1
fi
echo "Pushing simpleperf..."
adb_push_if_needed $SKIA_OUT/simpleperf /data/local/tmp
echo "Pushing app..."
adb_push_if_needed "${SKIA_OUT}/${runVars[0]}" /data/local/tmp
cp "${SKIA_OUT}/${runVars[0]}" $TMP_APP_LOC
@ -73,16 +66,16 @@ perf_record() {
# TO BE READ BY THE REPORTING TOOL
echo "Starting profiler"
APP_PID=$($ADB shell ps | grep ${runVars[0]} | awk '{print $2}')
$ADB shell perf record -p ${APP_PID} sleep 70
$ADB shell /data/local/tmp/simpleperf record -p ${APP_PID} -o /data/local/tmp/perf.data sleep 70
$ADB pull /data/perf.data $PERF_TMP_DIR/perf.data
$ADB pull /data/local/tmp/perf.data $PERF_TMP_DIR/perf.data
exit 0;
}
perf_report() {
adb_pull_if_needed /data/perf.data $PERF_TMP_DIR/perf.data
$PERFHOST report -i $PERF_TMP_DIR/perf.data --symfs=$PERF_TMP_DIR ${runVars[@]}
adb_pull_if_needed /data/local/tmp/perf.data $PERF_TMP_DIR/perf.data
$SKIA_OUT/perfhost_report.py -i $PERF_TMP_DIR/perf.data --symfs=$PERF_TMP_DIR ${runVars[@]}
}
# Clean up

View File

@ -17,7 +17,7 @@ verbose "pushing binaries onto the device..."
adb_push_if_needed "${SKIA_OUT}/${APP_ARGS[0]}" /data/local/tmp
if [[ -n $RESOURCE_PATH ]]; then
verbose "pushing resources onto the device..."
adb_push_if_needed "${SKIA_SRC_DIR}/resources" $RESOURCE_PATH
adb_push_if_needed "${SCRIPT_DIR}/../../../resources" $RESOURCE_PATH
fi
if [ $LOGCAT ]; then

View File

@ -62,11 +62,6 @@ if [ -z "$ANDROID_SDK_ROOT" ]; then
fi
fi
if [ -z "$ANDROID_HOME" ]; then
echo "ANDROID_HOME not set so we are setting it to a default value of ANDROID_SDK_ROOT"
exportVar ANDROID_HOME $ANDROID_SDK_ROOT
fi
if [ -z "$ANDROID_NDK_ROOT" ]; then
if [ -d "${ANDROID_SDK_ROOT}/ndk-bundle" ]; then
exportVar ANDROID_NDK_ROOT ${ANDROID_SDK_ROOT}/ndk-bundle