diff options
author | Khalid Zubair <kzubair@cyngn.com> | 2016-06-14 17:36:35 -0700 |
---|---|---|
committer | Chirayu Desai <chirayudesai1@gmail.com> | 2016-08-28 00:04:47 +0530 |
commit | 9656b2c345cf06e736c7c2668ada8ce50eab178d (patch) | |
tree | 1ed1485fdf383994fd499bcdbdde416f1c9409fd | |
parent | d4317adac31557aa05ec24e96e5fdcf59bafc04b (diff) | |
download | android_development-9656b2c345cf06e736c7c2668ada8ce50eab178d.tar.gz android_development-9656b2c345cf06e736c7c2668ada8ce50eab178d.tar.bz2 android_development-9656b2c345cf06e736c7c2668ada8ce50eab178d.zip |
gdbclient: fix gdbclient <processname> invocationcm-14.0
- `pid` was being run on the host system and not the target.
- toybox does not have `pid`, use `pidof` instead.
- throw an error if more than one pid is matched
Change-Id: I049484013df804e7f0901ec8e4b872bacd839daa
-rwxr-xr-x | scripts/gdbclient | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/scripts/gdbclient b/scripts/gdbclient index 3d62dd405..e4fbfffe1 100755 --- a/scripts/gdbclient +++ b/scripts/gdbclient @@ -89,17 +89,20 @@ function gdbclient() { fi # let's figure out which executable we are about to debug - # check if user specified a name -> resolve to pid if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then PROCESS_NAME=$PID - PID=$(pid --exact $PROCESS_NAME) - if [ -z "$PID" ]; then + PIDS=( $(adb shell "pidof $PROCESS_NAME 2> /dev/null" | tr -d '\r\n') ) + if [[ ${#PIDS[@]} == 0 ]]; then echo "Error: couldn't resolve pid by process name: $PROCESS_NAME" return -4 - else - echo "Resolved pid for $PROCESS_NAME is $PID" + elif [[ ${#PIDS[@]} != 1 ]]; then + echo "Error: more than one 1 PID resolved by process name: $PROCESS_NAME" + echo " PIDs -> ${PIDS[@]}" + return -5 fi + PID="${PIDS[0]}" + echo "Resolved pid for $PROCESS_NAME is [$PID]" fi local ID=`adb shell id -u` |