diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2012-05-16 14:03:11 +0800 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2012-05-16 16:12:16 +0800 |
commit | 201486c71651b4750d3cd8b7c4cd9a9c823f2e71 (patch) | |
tree | 6e281f574594c82e97c5cec1f75c8143e28320bc /ndk-gdb | |
parent | f6ca531464add2300f2a0282f2dd206cf6210b72 (diff) | |
download | ndk-201486c71651b4750d3cd8b7c4cd9a9c823f2e71.tar.gz |
Pass flags to all adb in ndk-gdb
Fixed an issue where $ADB_FLAGS isn't consistently passed to call
$ADB_CMD in ndk-gdb
Change-Id: I6d9542f6de8e3802024db4cc4a5348cf8bdcec6c
http://code.google.com/p/android/issues/detail?id=31126
Diffstat (limited to 'ndk-gdb')
-rwxr-xr-x | ndk-gdb | 29 |
1 files changed, 18 insertions, 11 deletions
@@ -317,6 +317,13 @@ log "ADB version found: $ADB_VERSION" log "Using ADB flags: $ADB_FLAGS" +# Run an ADB command with the right ADB flags +# $1+: adb command parameter +adb_cmd () +{ + # NOTE: We escape $ADB_CMD in case the command's path contains spaces. + "$ADB_CMD" $ADB_FLAGS "$@" +} # Used internally by adb_var_shell and adb_var_shell2. # $1: 1 to redirect stderr to $1, 0 otherwise. @@ -333,9 +340,9 @@ _adb_var_shell () # Run the command, while storing the standard output to CMD_OUT # and appending the exit code as the last line. if [ "$REDIRECT_STDERR" != 0 ]; then - "$ADB_CMD" $ADB_FLAGS shell "$@" ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT 2>&1 + adb_cmd shell "$@" ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT 2>&1 else - "$ADB_CMD" $ADB_FLAGS shell "$@" ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT + adb_cmd shell "$@" ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT fi # Get last line in log, which contains the exit code from the command RET=`sed -e '$!d' $CMD_OUT` @@ -374,7 +381,7 @@ adb_var_shell2 () # Out: PID number, or 0 if not running get_pid_of () { - "$ADB_CMD" shell ps | $AWK_CMD -f $AWK_SCRIPTS/extract-pid.awk -v PACKAGE="$1" + adb_cmd shell ps | $AWK_CMD -f $AWK_SCRIPTS/extract-pid.awk -v PACKAGE="$1" } # Check the awk tool @@ -447,7 +454,7 @@ APP_ABIS=`get_build_var APP_ABI` log "ABIs targetted by application: $APP_ABIS" # Check the ADB command, and that we can connect to the device/emulator -ADB_TEST=`"$ADB_CMD" shell ls` +ADB_TEST=`adb_cmd shell ls` if [ $? != 0 ] ; then echo "ERROR: Could not connect to device or emulator!" echo " Please check that an emulator is running or a device is connected" @@ -596,7 +603,7 @@ fi if [ -n "$OPTION_LAUNCH" ] ; then log "Launching activity: $PACKAGE_NAME/$OPTION_LAUNCH" - run "$ADB_CMD" shell am start -n $PACKAGE_NAME/$OPTION_LAUNCH + run adb_cmd shell am start -n $PACKAGE_NAME/$OPTION_LAUNCH if [ $? != 0 ] ; then echo "ERROR: Could not launch specified activity: $OPTION_LAUNCH" echo " Use --launch-list to dump a list of valid values." @@ -604,7 +611,7 @@ if [ -n "$OPTION_LAUNCH" ] ; then fi # Sleep a bit, it sometimes take one second to start properly # Note that we use the 'sleep' command on the device here. - run "$ADB_CMD" shell sleep $DELAY + run adb_cmd shell sleep $DELAY fi # Find the PID of the application being run @@ -634,12 +641,12 @@ if [ "$GDBSERVER_PID" != "0" ]; then exit 1 fi log "Killing existing debugging session" - run "$ADB_CMD" shell kill -9 $GDBSERVER_PID + run adb_cmd shell kill -9 $GDBSERVER_PID fi # Launch gdbserver now DEBUG_SOCKET=debug-socket -run "$ADB_CMD" shell run-as $PACKAGE_NAME lib/gdbserver +$DEBUG_SOCKET --attach $PID & +run adb_cmd shell run-as $PACKAGE_NAME lib/gdbserver +$DEBUG_SOCKET --attach $PID & if [ $? != 0 ] ; then echo "ERROR: Could not launch gdbserver on the device?" exit 1 @@ -648,7 +655,7 @@ log "Launched gdbserver succesfully." # Setup network redirection log "Setup network redirection" -run "$ADB_CMD" forward tcp:$DEBUG_PORT localfilesystem:$DATA_DIR/$DEBUG_SOCKET +run adb_cmd forward tcp:$DEBUG_PORT localfilesystem:$DATA_DIR/$DEBUG_SOCKET if [ $? != 0 ] ; then echo "ERROR: Could not setup network redirection to gdbserver?" echo " Maybe using --port=<port> to use a different TCP port might help?" @@ -657,10 +664,10 @@ fi # Get the app_server binary from the device APP_PROCESS=$APP_OUT/app_process -run "$ADB_CMD" pull /system/bin/app_process `native_path $APP_PROCESS` +run adb_cmd pull /system/bin/app_process `native_path $APP_PROCESS` log "Pulled app_process from device/emulator." -run "$ADB_CMD" pull /system/lib/libc.so `native_path $APP_OUT/libc.so` +run adb_cmd pull /system/lib/libc.so `native_path $APP_OUT/libc.so` log "Pulled libc.so from device/emulator." # Now launch the appropriate gdb client with the right init commands |