aboutsummaryrefslogtreecommitdiff
path: root/ndk-gdb
diff options
context:
space:
mode:
authorAndrew Hsieh <andrewhsieh@google.com>2013-11-19 00:11:23 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2013-11-19 00:11:24 +0000
commit05cf6bc7c308c62376dd53795809d1ad1c89f3d0 (patch)
tree549a1a2b572fc886f0a5ebb2c9409f7ed0a12a0d /ndk-gdb
parent514623f19077e137821f7c5c92cbddbd090b2d23 (diff)
parent65f49a5ffedff3e05aab3332a907b25d7721ecac (diff)
downloadndk-05cf6bc7c308c62376dd53795809d1ad1c89f3d0.tar.gz
Merge "Debugging for unknown arch."
Diffstat (limited to 'ndk-gdb')
-rwxr-xr-xndk-gdb38
1 files changed, 31 insertions, 7 deletions
diff --git a/ndk-gdb b/ndk-gdb
index 91a6b0e75..e25caaddc 100755
--- a/ndk-gdb
+++ b/ndk-gdb
@@ -35,6 +35,8 @@ case $PROGDIR in
;;
esac
+NDK_BUILDTOOLS_PATH=$PROGDIR/build/tools
+. $PROGDIR/build/tools/prebuilt-common.sh
. $PROGDIR/build/tools/ndk-common.sh
force_32bit_binaries
@@ -79,6 +81,8 @@ AWK_CMD=${AWK_CMD:-$(find_program awk)}
DEBUG_PORT=5039
JDB_PORT=65534
+UNKNOWN_ABI=$(find_ndk_unknown_archs)
+
# Delay in seconds between launching the activity and attaching gdbserver on it.
# This is needed because there is no way to know when the activity has really
# started, and sometimes this takes a few seconds.
@@ -544,13 +548,18 @@ CPU_ABIS=$(echo $CPU_ABIS | tr ',' ' ')
log "Device CPU ABIs: $CPU_ABIS"
APP_ABIS=$APP_ABIS" "
-for CPU_ABI in $CPU_ABIS; do
- if [ "$APP_ABIS" != "${APP_ABIS%$CPU_ABI *}" ] ; then
- COMPAT_ABI=$CPU_ABI
- break
- fi
-done
+adb_var_shell BCFILES run-as $PACKAGE_NAME /system/bin/sh -c "ls lib/*.bc"
+if [ $? == 0 ]; then
+ COMPAT_ABI="$UNKNOWN_ABI"
+else
+ for CPU_ABI in $CPU_ABIS; do
+ if [ "$APP_ABIS" != "${APP_ABIS%$CPU_ABI *}" ] ; then
+ COMPAT_ABI=$CPU_ABI
+ break
+ fi
+ done
+fi
if [ "$COMPAT_ABI" = none ] ; then
echo "ERROR: The device does not support the application's targetted CPU ABIs!"
echo " Device supports: $CPU_ABIS"
@@ -563,7 +572,13 @@ log "Compatible device ABI: $COMPAT_ABI"
GDBSETUP_INIT=`get_build_var_for_abi NDK_APP_GDBSETUP $COMPAT_ABI`
log "Using gdb setup init: $GDBSETUP_INIT"
-TOOLCHAIN_PREFIX=`get_build_var_for_abi TOOLCHAIN_PREFIX $COMPAT_ABI`
+# Find the prefix for gdb-client
+if [ "$COMPAT_ABI" != "$UNKNOWN_ABI" ]; then
+ TOOLCHAIN_PREFIX=`get_build_var_for_abi TOOLCHAIN_PREFIX $COMPAT_ABI`
+else
+ TOOLCHAIN_ABI=$(echo $CPU_ABIS | awk '{print $NF}')
+ TOOLCHAIN_PREFIX=`get_build_var_for_abi TOOLCHAIN_PREFIX $TOOLCHAIN_ABI`
+fi
log "Using toolchain prefix: $TOOLCHAIN_PREFIX"
APP_OUT=`get_build_var_for_abi TARGET_OUT $COMPAT_ABI`
@@ -749,6 +764,15 @@ if [ "$OPTION_START" = "yes" ] || [ -n "$OPTION_LAUNCH" ] ; then
fi
fi
+# If we are debugging UNKNOWN_ABI, download compiled *.so from device.
+#
+if [ $COMPAT_ABI == $UNKNOWN_ABI ]; then
+ for bc in $BCFILES; do
+ log "Pulled $(basename $bc .bc).so from device/emulator."
+ adb pull $DATA_DIR/lib/$(basename $bc .bc).so $PROJECT/obj/local/$UNKNOWN_ABI/
+ done
+fi
+
# Now launch the appropriate gdb client with the right init commands
#
GDBCLIENT=${TOOLCHAIN_PREFIX}gdb