ndk-gdb的问题 - gdb.setup,putpkt,运行PID

时间:2012-04-23 00:10:20

标签: android android-ndk gdb sigsegv

我已经使用ndk-build构建了一个本地库,并在Android.mk中将其标记为可调试。如果我进入cygwin shell并运行

cd (PROJDIR)
ndk-gdb --start --verbose

我得到以下内容:

Android NDK installation path: /cygdrive/c/Android/android-ndk-r7b
Using default adb command: /cygdrive/c/Android/android-sdk/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using ADB flags: 
Using auto-detected project path: .
Found package name: tiny.test2
ABIs targetted by application: armeabi
Device API Level: 15
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/tiny.test2/lib/gdbserver
Using gdb setup init: ./libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/c/Android/android-ndk-r7b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi
Found data directory: '/data/data/tiny.test2'
Found first launchable activity: .Test2Activity
Launching activity: tiny.test2/.Test2Activity
## COMMAND: /cygdrive/c/Android/android-sdk/platform-tools/adb shell am start -n tiny.test2/.Test2Activity
Starting: Intent { cmp=tiny.test2/.Test2Activity }

## COMMAND: /cygdrive/c/Android/android-sdk/platform-tools/adb shell sleep 2
Found running PID: 0
ERROR: Could not extract PID of application on device/emulator.
       Weird, this probably means one of these:

         - The installed package does not match your current manifest.
         - The application process was terminated.

       Try using the --verbose option and look at its output for details.

它没有到达gdb提示进行调试。我尝试在第一次C ++函数调用之前在Eclipse中使用.java文件中的断点启动它,然后在运行ndk-gdb的java断点处启动它,并且它成功找到运行PID 1977,通过端口5039连接到设备,并从设备中提取libc.so,但随后获得了Error while mapping shared library sections: libxxxx.so: No such file or directory的赃物。 info sharedLibrary中找不到符号。

我已根据其他问题的建议将LOCAL_CFLAGS := -g -ggdb -O0添加到Android.mk,并从$(NDK_PATH)/build/core/build-binary.mk删除了从.so文件中删除附加内容的行。

如果有人知道这些错误的可能原因,请帮助。

由于

编辑:ndk-gdb告诉我'这个GDB配置为“--host-i586-mingw32msvc --target = arm-elf-linux”'紧接'(未找到调试符号)'

这意味着什么吗?

EDIT2:从gdb运行share会返回所有.so文件的Symbol file not found列表。这看起来像我没有正确生成符号文件,或者它们没有包含在搜索路径中。它们应该放在哪里?

EDIT3:原来我错过了ndk-gdb doc中的重要一行 -

   "The GDB prompt will be preceded by a long list of error messages,
   where gdb complains that it cannot find various system libraries
   (e.g. libc.so, libstdc++.so, liblog.so, libcutils.so, etc...)

   This is normal, because there are no symbol/debug versions of
   these libraries corresponding to your target device on your
   development machine. You can safely ignore these messages."

这并不能解决问题,但有助于了解这些不是错误。

1 个答案:

答案 0 :(得分:0)

你有env ANDROID_NDK_ROOT吗?必须像Windows下的/ cygdrive / c / Android / android-ndk-r7 *。 尝试添加DNK_DEBUG = 1来编译.. 像:ndk-build DNK_DEBUG = 1 -B V = 1

另外,请确保你在libs / $(Target-ABI)/

下有gdbserver和gdb.set 希望可以帮到你。