2009-07-16

Android gdbclient

http://gist.github.com/147523

pidは毎回変わるけど引数3番目なので使いやすくしてみました。
cupcakeだと/system/binにgdbserverいますよね。source build/envsetup.shしといて、
gdbclient 888
とかで該当pidに接続できます。

http://blogger.splhack.org/2009/01/android-dev-phone-1-12.html のほぼ自動化。

diff --git a/envsetup.sh b/envsetup.sh
index f8f20ab..c54c1d5 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -704,26 +704,26 @@ function gdbclient()
local OUT_EXE_SYMBOLS=$(get_abs_build_var TARGET_OUT_EXECUTABLES_UNSTRIPPED)
local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS)
if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then
- local EXE="$1"
+ local EXE="$2"
if [ "$EXE" ] ; then
- EXE=$1
+ EXE=$2
else
EXE="app_process"
fi

- local PORT="$2"
+ local PORT="$3"
if [ "$PORT" ] ; then
- PORT=$2
+ PORT=$3
else
PORT=":5039"
fi

local PID
- local PROG="$3"
+ local PROG="$1"
if [ "$PROG" ] ; then
- PID=`pid $3`
+ PID=$1
adb forward "tcp$PORT" "tcp$PORT"
- adb shell gdbserver $PORT --attach $PID &
+ adb shell su -c gdbserver $PORT --attach $PID &
sleep 2
else
echo ""