local CPU_ABI=`adb shell getprop ro.product.cpu.abilist | sed s/.$//`
# TODO: we assume these are available via $PATH
if[[$CPU_ABI=~ (^|,)arm64 ]];then
GDB=arm-linux-androideabi-gdb
GDB64=aarch64-linux-android-gdb
elif[[$CPU_ABI=~ (^|,)arm ]];then
GDB=arm-linux-androideabi-gdb
elif[[$CPU_ABI=~ (^|,)x86_64 ]];then
GDB=x86_64-linux-android-gdb
elif[[$CPU_ABI=~ (^|,)x86 ]];then
GDB=x86_64-linux-android-gdb
elif[[$CPU_ABI=~ (^|,)mips64 ]];then
GDB=mipsel-linux-android-gdb
GDB64=mips64el-linux-android-gdb
elif[[$CPU_ABI=~ (^|,)mips ]];then
GDB=mipsel-linux-android-gdb
else
echo"Error: unrecognized cpu.abilist: $CPU_ABI"
return-6
fi
# TODO: check if tracing process is gdbserver and not some random strace...
if["$(adb_get_traced_by $PID)"-eq 0 ];then
# start gdbserver
echo"Starting gdbserver..."
# TODO: check if adb is already listening $PORT
# to avoid unnecessary calls
echo". adb forward for port=$PORT..."
adb forward tcp:$PORT tcp:$PORT
echo". starting gdbserver to attach to pid=$PID..."
adb shell gdbserver$USE64BIT :$PORT--attach$PID &
echo". give it couple of seconds to start..."
sleep 2
echo". done"
else
echo"It looks like gdbserver is already attached to $PID (process is traced), trying to connect to it using local port=$PORT"
adb forward tcp:$PORT tcp:$PORT
fi
local OUT_SO_SYMBOLS=$SYMBOLS_DIR/system/lib$USE64BIT
local TAPAS_OUT_SO_SYMBOLS=$TAPAS_SYMBOLS_DIR/system/lib$USE64BIT
local OUT_VENDOR_SO_SYMBOLS=$SYMBOLS_DIR/vendor/lib$USE64BIT
local ART_CMD=""
local SOLIB_SYSROOT=$SYMBOLS_DIR
local SOLIB_SEARCHPATH=$OUT_SO_SYMBOLS:$OUT_SO_SYMBOLS/hw:$OUT_SO_SYMBOLS/ssl/engines:$OUT_SO_SYMBOLS/drm:$OUT_SO_SYMBOLS/egl:$OUT_SO_SYMBOLS/soundfx:$OUT_VENDOR_SO_SYMBOLS:$OUT_VENDOR_SO_SYMBOLS/hw:$OUT_VENDOR_SO_SYMBOLS/egl