From 4efdec68b0bc229e5e793f15bc0e00d7ed3ea7c8 Mon Sep 17 00:00:00 2001 From: Nikola Veljkovic Date: Thu, 9 Jul 2015 11:24:10 +0200 Subject: [PATCH] Fix gdbclient to work with emulator builds gdbclient got broken by: https://android-review.googlesource.com/156974 To fix, check for special case when device is actually an emulator, and set the $DEVICE variable accordingly. Change-Id: I85d0d520ae1e2ea022aa3e2d08a10cd0b1cb491f --- scripts/gdbclient | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/gdbclient b/scripts/gdbclient index c17059084..2394e1814 100755 --- a/scripts/gdbclient +++ b/scripts/gdbclient @@ -12,6 +12,15 @@ fi # as well. 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 function adb_get_traced_by() { 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 [port number]" return -1 fi - local DEVICE=`adb shell getprop ro.hardware | tr -d '\r\n'` + local DEVICE=$(adb_get_product_device) if [ -z "$DEVICE" ]; then echo "Error: Unable to get device name. Please check if device is connected and ANDROID_SERIAL is set."