forked from openkylin/platform_build
Improve gdbclient pid handling
Improves attaching to multi-process applications, connecting to the root process if child process not specified instead of passing bad data to gdbserver Also logs error instead of passing bad data to gdbserver if pid undetermined Change-Id: I68ad62645c4f0a7a24aef02c84e3b5b84e14461e
This commit is contained in:
parent
60a34ed501
commit
20c136a151
25
envsetup.sh
25
envsetup.sh
|
@ -776,13 +776,24 @@ function gdbclient()
|
||||||
PORT=":5039"
|
PORT=":5039"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local PID
|
local PID="$3"
|
||||||
local PROG="$3"
|
if [ "$PID" ] ; then
|
||||||
if [ "$PROG" ] ; then
|
if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
|
||||||
if [[ "$PROG" =~ ^[0-9]+$ ]] ; then
|
|
||||||
PID="$3"
|
|
||||||
else
|
|
||||||
PID=`pid $3`
|
PID=`pid $3`
|
||||||
|
if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
|
||||||
|
# that likely didn't work because of returning multiple processes
|
||||||
|
# try again, filtering by root processes (don't contain colon)
|
||||||
|
PID=`adb shell ps | grep $3 | grep -v ":" | awk '{print $2}'`
|
||||||
|
if [[ ! "$PID" =~ ^[0-9]+$ ]]
|
||||||
|
then
|
||||||
|
echo "Couldn't resolve '$3' to single PID"
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "WARNING: multiple processes matching '$3' observed, using root process"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
adb forward "tcp$PORT" "tcp$PORT"
|
adb forward "tcp$PORT" "tcp$PORT"
|
||||||
adb shell gdbserver $PORT --attach $PID &
|
adb shell gdbserver $PORT --attach $PID &
|
||||||
|
@ -792,7 +803,7 @@ function gdbclient()
|
||||||
echo "If you haven't done so already, do this first on the device:"
|
echo "If you haven't done so already, do this first on the device:"
|
||||||
echo " gdbserver $PORT /system/bin/$EXE"
|
echo " gdbserver $PORT /system/bin/$EXE"
|
||||||
echo " or"
|
echo " or"
|
||||||
echo " gdbserver $PORT --attach $PID"
|
echo " gdbserver $PORT --attach <PID>"
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue