diff options
author | Khalid Zubair <kzubair@cyngn.com> | 2016-06-14 17:36:35 -0700 |
---|---|---|
committer | Khalid Zubair <kzubair@cyngn.com> | 2016-06-15 11:09:09 -0700 |
commit | 87654bc0a08a4da5813c719a65087120068d5341 (patch) | |
tree | b69e9feff0850ffb49635535159b5c140f27b72f | |
parent | 0a521f6d93206567c14bbacdc13819bf4baf82d3 (diff) | |
download | android_development-cm-13.0.tar.gz android_development-cm-13.0.tar.bz2 android_development-cm-13.0.zip |
gdbclient: fix gdbclient <processname> invocationHEADreplicant-6.0-0004-transitionreplicant-6.0-0004-rc6replicant-6.0-0004-rc5-transitionreplicant-6.0-0004-rc5replicant-6.0-0004-rc4replicant-6.0-0004-rc3replicant-6.0-0004-rc2replicant-6.0-0004-rc1replicant-6.0-0004replicant-6.0-0003replicant-6.0-0002replicant-6.0-0001stable/cm-13.0-ZNH5Ycm-13.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 8ff9ae9c6..c2f1363c6 100755 --- a/scripts/gdbclient +++ b/scripts/gdbclient @@ -90,17 +90,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 EXE=`adb shell readlink /proc/$PID/exe | tr -d '\r\n'` |