aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Derek Sollenberger <djsollen@google.com>2017-01-05 11:39:04 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-05 17:16:01 +0000
commit70120c778abc42ce754fb8178aa49bf8ce95a5c3 (patch)
treeb153190cccc0358a6bdd8c1170681a5bd9d6ae98
parenta9e3266a214768ccfd2f1ee041ffe6153bdc04e6 (diff)
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>
-rw-r--r--BUILD.gn22
-rw-r--r--gn/BUILDCONFIG.gn12
-rwxr-xr-xplatform_tools/android/bin/android_gdb_native2
-rwxr-xr-xplatform_tools/android/bin/android_gdbserver2
-rwxr-xr-xplatform_tools/android/bin/android_launch_app2
-rwxr-xr-xplatform_tools/android/bin/android_perf21
-rwxr-xr-xplatform_tools/android/bin/android_run_skia2
-rwxr-xr-xplatform_tools/android/bin/utils/android_setup.sh5
8 files changed, 45 insertions, 23 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 05c1e8e398..681a7882e3 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -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 = [
diff --git a/gn/BUILDCONFIG.gn b/gn/BUILDCONFIG.gn
index a03ea82a43..23e5288f1a 100644
--- a/gn/BUILDCONFIG.gn
+++ b/gn/BUILDCONFIG.gn
@@ -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"
}
}
diff --git a/platform_tools/android/bin/android_gdb_native b/platform_tools/android/bin/android_gdb_native
index da513cbf79..9d7fa1902c 100755
--- a/platform_tools/android/bin/android_gdb_native
+++ b/platform_tools/android/bin/android_gdb_native
@@ -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
diff --git a/platform_tools/android/bin/android_gdbserver b/platform_tools/android/bin/android_gdbserver
index 432ab7c82b..12d055af44 100755
--- a/platform_tools/android/bin/android_gdbserver
+++ b/platform_tools/android/bin/android_gdbserver
@@ -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"
diff --git a/platform_tools/android/bin/android_launch_app b/platform_tools/android/bin/android_launch_app
index 46cd4b11c3..0da80ba954 100755
--- a/platform_tools/android/bin/android_launch_app
+++ b/platform_tools/android/bin/android_launch_app
@@ -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"
diff --git a/platform_tools/android/bin/android_perf b/platform_tools/android/bin/android_perf
index cf51074788..0d1d5e2e39 100755
--- a/platform_tools/android/bin/android_perf
+++ b/platform_tools/android/bin/android_perf
@@ -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
diff --git a/platform_tools/android/bin/android_run_skia b/platform_tools/android/bin/android_run_skia
index 659b690e2e..5a643df498 100755
--- a/platform_tools/android/bin/android_run_skia
+++ b/platform_tools/android/bin/android_run_skia
@@ -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
diff --git a/platform_tools/android/bin/utils/android_setup.sh b/platform_tools/android/bin/utils/android_setup.sh
index a63fcafe65..4d6dba3b8c 100755
--- a/platform_tools/android/bin/utils/android_setup.sh
+++ b/platform_tools/android/bin/utils/android_setup.sh
@@ -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