我在windows上安了cygwin,然后下了ndk。
按ndk网站上的用法,写了一个hello.c,然后放在<ndk>\hello\jni里面。
写了一个Android.mk
然后我在hello目录下面用../ndk-build NDK_DEBUG=1
之后生成了一个hello在hello/libs/armeabi.
我用adb push这hello文件到emulator上。
adb forward tcp:5039 tcp:5039
adb shell中启动gdbserver tcp:5039 hello
在host的cygwin中,arm-eabi-gdb
输入target remote :5039
显示连接到了remote的gdbserver,但是定断点和list时都提示:
No symbol table is loaded. Use the "file" command.
请问这是什么原因?
我如果在hello目录下输入..\ndk-gdb,提示:
ERROR: Launch this script from an application project directory, or use --project=<path>.
到底如何调试呢?谢谢高手指点迷津啊!非常感谢!
------解决方案--------------------
得下班了,你先看看用ddd调试的一个脚本:
function dddclient()
{
local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT)
local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED)
local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)
local OUT_EXE_SYMBOLS=$(get_abs_build_var TARGET_OUT_EXECUTABLES_UNSTRIPPED)
local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS)
#export PATH=~/project/edream2.1/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin:${PATH}
echo $OUT_ROOT
echo $OUT_SYMBOLS
echo $OUT_SO_SYMBOLS
echo $OUT_EXE_SYMBOLS
echo $PREBUILTS
echo $PATH
if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then
local EXE="$1"
if [ "$EXE" ] ; then
EXE=$1
else
EXE="app_process"
fi
local PORT="$2"
if [ "$PORT" ] ; then
PORT=$2
else
PORT=":5678"
fi
local PID
local PROG="$3"
if [ "$PROG" ] ; then
PID=`pid $3`
else
PID=`pid $EXE`
fi
adb forward "tcp$PORT" "tcp$PORT"
adb shell gdbserver $PORT --attach $PID &
sleep 2
echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS"
echo >>"$OUT_ROOT/gdbclient.cmds" "set solib-search-path $OUT_SO_SYMBOLS"
echo >>"$OUT_ROOT/gdbclient.cmds" "symbol-file $OUT_EXE_SYMBOLS/$EXE"
echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT"
echo >>"$OUT_ROOT/gdbclient.cmds" ""
ddd --debugger "$PREBUILTS/toolchain/arm-eabi-4.4.0/bin/arm-eabi-gdb" -x "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE"
else
echo "Unable to determine build system output dir."
fi
}