2013-06-27 13:43:04 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# android_gdbserver: Pushes gdbserver. Starts debugging environment.
|
|
|
|
|
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2016-12-01 19:37:41 +00:00
|
|
|
source $SCRIPT_DIR/utils/android_setup.sh
|
2013-08-12 12:30:04 +00:00
|
|
|
source $SCRIPT_DIR/utils/setup_adb.sh
|
|
|
|
|
2014-04-24 18:36:36 +00:00
|
|
|
APP_NAME=${APP_ARGS[0]}
|
2013-06-27 13:43:04 +00:00
|
|
|
|
2016-12-01 19:37:41 +00:00
|
|
|
TARGET_EXE="${SKIA_OUT}/${APP_NAME}"
|
|
|
|
if [ ! -f "$TARGET_EXE" ]
|
2013-08-12 12:30:04 +00:00
|
|
|
then
|
2016-12-01 19:37:41 +00:00
|
|
|
echo "Unable to find ${TARGET_EXE}."
|
2013-08-12 12:30:04 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2013-06-27 13:43:04 +00:00
|
|
|
|
2017-01-06 18:13:50 +00:00
|
|
|
IS_64_BIT="false"
|
2020-04-21 18:44:44 +00:00
|
|
|
GN_TARGET_CPU=$(gn args --list=target_cpu $SKIA_OUT \
|
|
|
|
| grep "Current value = " \
|
|
|
|
| sed -e s/"Current value = "// -e s/\"//g -e s/" "//g)
|
|
|
|
if [[ $GN_TARGET_CPU == *64* ]]; then
|
2017-01-06 18:13:50 +00:00
|
|
|
IS_64_BIT="true"
|
|
|
|
fi
|
|
|
|
|
2013-06-27 13:43:04 +00:00
|
|
|
# We need the debug symbols from these files
|
2015-07-10 18:05:10 +00:00
|
|
|
GDB_TMP_DIR=$SKIA_OUT/android_gdb_tmp
|
2014-05-01 15:34:28 +00:00
|
|
|
mkdir -p $GDB_TMP_DIR
|
2013-08-12 12:30:04 +00:00
|
|
|
|
2013-06-27 13:43:04 +00:00
|
|
|
echo "Copying symbol files"
|
2016-12-01 19:37:41 +00:00
|
|
|
if [[ $IS_64_BIT == "true" ]]; then
|
2014-07-16 20:21:15 +00:00
|
|
|
SYSTEM_LIBRARY_PATH=/system/lib64
|
2016-12-01 19:37:41 +00:00
|
|
|
echo "64 bit!"
|
2014-07-16 20:21:15 +00:00
|
|
|
else
|
|
|
|
SYSTEM_LIBRARY_PATH=/system/lib
|
|
|
|
fi
|
2014-04-29 19:04:21 +00:00
|
|
|
for library_file in \
|
|
|
|
libc.so \
|
2014-11-12 19:52:23 +00:00
|
|
|
libc++.so \
|
2014-04-29 19:04:21 +00:00
|
|
|
libstdc++.so \
|
|
|
|
libm.so \
|
|
|
|
liblog.so \
|
|
|
|
libz.so \
|
2014-07-17 15:18:23 +00:00
|
|
|
libsigchain.so \
|
|
|
|
libcutils.so \
|
|
|
|
libunwind.so \
|
|
|
|
libbacktrace.so \
|
2014-04-29 19:04:21 +00:00
|
|
|
libutils.so \
|
|
|
|
libEGL.so \
|
|
|
|
libGLESv2.so \
|
|
|
|
; do
|
2019-09-13 20:21:07 +00:00
|
|
|
ANDROID_LS=`$ADB $DEVICE_SERIAL shell -x ls -ld ${SYSTEM_LIBRARY_PATH}/${library_file}`
|
2014-07-17 15:18:23 +00:00
|
|
|
if [ "${ANDROID_LS:0:1}" == "-" ]; then
|
|
|
|
adb_pull_if_needed "${SYSTEM_LIBRARY_PATH}/${library_file}" $GDB_TMP_DIR
|
|
|
|
fi
|
2014-04-29 19:04:21 +00:00
|
|
|
done
|
|
|
|
|
2017-01-06 18:13:50 +00:00
|
|
|
if [[ $IS_64_BIT == "true" ]]; then
|
2014-07-17 15:18:23 +00:00
|
|
|
adb_pull_if_needed /system/bin/linker64 $GDB_TMP_DIR
|
|
|
|
else
|
|
|
|
adb_pull_if_needed /system/bin/linker $GDB_TMP_DIR
|
|
|
|
fi
|
2013-06-27 13:43:04 +00:00
|
|
|
|
2013-08-12 12:30:04 +00:00
|
|
|
echo "Pushing app..."
|
2016-12-01 19:37:41 +00:00
|
|
|
cp "$TARGET_EXE" $GDB_TMP_DIR
|
|
|
|
adb_push_if_needed "${TARGET_EXE}" /data/local/tmp
|
2013-06-27 13:43:04 +00:00
|
|
|
|
|
|
|
echo "Pushing gdbserver..."
|
2017-01-05 16:39:04 +00:00
|
|
|
adb_push_if_needed $SKIA_OUT/gdbserver /data/local/tmp
|
2013-06-27 13:43:04 +00:00
|
|
|
|
|
|
|
echo "Setting up port forward"
|
|
|
|
$ADB forward "tcp:5039" "tcp:5039"
|
|
|
|
|
2013-08-12 12:30:04 +00:00
|
|
|
# Kill all previous instances of gdbserver and the app to rid all port overriding errors.
|
2013-06-27 13:43:04 +00:00
|
|
|
echo "Killing any running Skia processes."
|
2016-03-17 17:45:47 +00:00
|
|
|
set +e
|
|
|
|
$ADB shell ps | grep gdbserver | awk '{print $2}' | xargs $ADB shell kill 2> /dev/null
|
|
|
|
$ADB shell ps | grep ${APP_NAME} | awk '{print $2}' | xargs $ADB shell kill 2> /dev/null
|
|
|
|
set -e
|
2013-06-27 13:43:04 +00:00
|
|
|
|
|
|
|
# Starting up gdbserver in android shell
|
2014-04-24 18:36:36 +00:00
|
|
|
echo "Starting gdbserver with command: ${APP_ARGS[@]}"
|
2016-12-01 19:37:41 +00:00
|
|
|
$ADB shell /data/local/tmp/gdbserver :5039 /data/local/tmp/${APP_ARGS[@]} &
|