Skip to content

Commit ef3f1e2

Browse files
committed
Warn if you're trying to use gdbclient without "adb root".
Bug: http://b/22715953 Change-Id: If729fbc89ccd65407e8900bc27df8fa4174dd64e
1 parent 73371e5 commit ef3f1e2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

scripts/gdbclient

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fi
1111
# shell, but not functions (like gettop), so we need to source envsetup in here
1212
# as well.
1313
source $ANDROID_BUILD_TOP/build/envsetup.sh
14+
echo
1415

1516
function adb_get_product_device() {
1617
local candidate=`adb shell getprop ro.hardware | tr -d '\r\n'`
@@ -96,10 +97,15 @@ function gdbclient() {
9697
fi
9798
fi
9899

99-
local EXE=`adb shell readlink /proc/$PID/exe | tr -d '\r\n'`
100+
local ID=`adb shell id -u`
101+
if [ "$ID" != "0" ]; then
102+
echo "Error: gdbclient only works if you've run 'adb root'"
103+
return -4
104+
fi
100105

106+
local EXE=`adb shell readlink /proc/$PID/exe | tr -d '\r\n'`
101107
if [ -z "$EXE" ]; then
102-
echo "Error: no such pid=$PID - is process still alive?"
108+
echo "Error: couldn't find executable for pid $PID --- is the process still alive?"
103109
return -4
104110
fi
105111

0 commit comments

Comments
 (0)