Merge "Fix gdbclient to work with emulator builds"

This commit is contained in:
Elliott Hughes
2015-07-09 15:48:54 +00:00
committed by Gerrit Code Review

View File

@@ -12,6 +12,15 @@ fi
# as well. # as well.
source $ANDROID_BUILD_TOP/build/envsetup.sh source $ANDROID_BUILD_TOP/build/envsetup.sh
function adb_get_product_device() {
local candidate=`adb shell getprop ro.hardware | tr -d '\r\n'`
if [[ "$candidate" =~ ^(goldfish|ranchu)$ ]]; then
# Emulator builds use product.device for OUT folder
candidate=`adb shell getprop ro.product.device | tr -d '\r\n'`
fi
echo $candidate
}
# returns 0 when process is not traced # returns 0 when process is not traced
function adb_get_traced_by() { function adb_get_traced_by() {
echo `adb shell cat /proc/$1/status | grep -e "^TracerPid:" | sed "s/^TracerPid:\t//" | tr -d '\r\n'` echo `adb shell cat /proc/$1/status | grep -e "^TracerPid:" | sed "s/^TracerPid:\t//" | tr -d '\r\n'`
@@ -37,7 +46,7 @@ function gdbclient() {
echo "Usage: gdbclient <pid|processname> [port number]" echo "Usage: gdbclient <pid|processname> [port number]"
return -1 return -1
fi fi
local DEVICE=`adb shell getprop ro.hardware | tr -d '\r\n'` local DEVICE=$(adb_get_product_device)
if [ -z "$DEVICE" ]; then if [ -z "$DEVICE" ]; then
echo "Error: Unable to get device name. Please check if device is connected and ANDROID_SERIAL is set." echo "Error: Unable to get device name. Please check if device is connected and ANDROID_SERIAL is set."