发展环境:
NDK:r7
SDK&工具:r15
AVD:GB2.3.3,API等级10
我编写了一个测试应用程序,其中的线程将在本机中启动。我在线程中保留了一个断点。 (当我尝试使用Galaxy S2时,我遇到了错误,“此平台不支持线程调试”。所以我创建了AVD 2.3.3等级10)。
在此之后我收到了这样的错误
#0 0xafd0c51c in epoll_wait () from /Volumes/SecureCode/webos/rta/android/obj/local/armeabi/libc.so
#1 0xa81216a6 in ?? ()
我用谷歌搜索了Solution (Link Here).
我按照那里的指导线
$ adb pull /system/lib lib
$ ndk-gdb
...
(gdb) set solib-search-path lib
但在此之后我也无法达到突破点。我仍然陷入这个poll_wait()而不是前进。
D:\EclipseTestWorkspace\CallbackJava>sh
sh-4.1$ ndk-gdb --force --start --verbose
Android NDK installation path: /cygdrive/c/Android/android-ndk
Using default adb command: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/cygdrive/c/Android/android-sdk-windows/platform-tools/adb'
Using auto-detected project path: .
Found package name: com.callback
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABI: armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.callback/lib/gdbserver
Using gdb setup init: ./libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/c/Android/android-ndk/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/com.callback'
Found first launchable activity: .CallbackJavaActivity
Launching activity: com.callback/.CallbackJavaActivity
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb shell am start -n com.callback/.CallbackJavaActivity
Starting: Intent { cmp=com.callback/.CallbackJavaActivity }
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb shell sleep 2
Found running PID: 352
Launched gdbserver succesfully.
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb shell run-as com.callback lib/gdbserver +debug-socket --attach 352
Setup network redirection
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb forward tcp:5039 localfilesystem:/data/data/com.callback/debug-socket
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb pull /system/bin/app_process obj/local/armeabi/app_process
Attached; pid = 352
Listening on sockaddr socket debug-socket
19 KB/s (5660 bytes in 0.281s)
Pulled app_process from device/emulator.
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb pull /system/lib/libc.so obj/local/armeabi/libc.so
80 KB/s (273868 bytes in 3.325s)
Pulled libc.so from device/emulator.
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i586-mingw32msvc --target=arm-elf-linux".
(no debugging symbols found)
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
----- So many similar errors -----
Error while mapping shared library sections:
gralloc.default.so: No such file or directory.
(no debugging symbols found)
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint
0xafd0c51c in epoll_wait () from D:/EclipseTestWorkspace/CallbackJava/obj/local/armeabi/libc.so
(gdb) set solib-search-path lib
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
Error while mapping shared library sections:
gralloc.default.so: No such file or directory.
Symbol file not found for /system/bin/linker
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so...(no debugging symbols found)...done.
Loaded symbols for D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
----- So many similar errors -----
Loaded symbols for D:\EclipseTestWorkspace\CallbackJava/lib/libwebcore.so
Symbol file not found for gralloc.default.so
(gdb) file ./libs/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./libs/armeabi/libcallbacks.so...(no debugging symbols found)...done.
(gdb) file ./obj/local/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./obj/local/armeabi/libcallbacks.so...done.
(gdb) break callbacks_java.cpp:appcallback_register
Breakpoint 1 at 0x1a64: file D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp, line 419.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00001a64 in appcallback_register at D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp:419
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x1a64: Input/output error.
(gdb)
我想把重点放在主要部分
(gdb) file ./libs/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./libs/armeabi/libcallbacks.so...(no debugging symbols found)...done.
(gdb) file ./obj/local/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./obj/local/armeabi/libcallbacks.so...done.
(gdb) break callbacks_java.cpp:appcallback_register
Breakpoint 1 at 0x1a64: file D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp, line 419.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00001a64 in appcallback_register at D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp:419
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x1a64: Input/output error.
(gdb)
所以从上一个错误我理解的是它考虑绝对地址0x1a64。它不考虑相对地址(运行时地址),因此无法达到断点。而且它也陷入了epoll_wait(),而不是进一步发展。
有人请帮助我如何进一步处理?
谢谢&问候,
SSuman185
答案 0 :(得分:1)
您可以尝试使用DS-5 CE插件在Eclipse中进行调试。教程如何安装和设置,你可以在这里找到http://forums.arm.com/index.php?/topic/15575-arm-ds-5-tutorial-for-android/(最后一篇文章是如何让它在SGS2上运行)。
我知道这不是你问题的准确答案,但如果你需要在SGS2上进行NDK调试,你可能想尝试一下,也就是Eclipse,而不是命令行gdb(但谁更喜欢命令行调试)而不是在IDE中调试??)
PS。 DS-5 CE是第一个使用SGS2工作的NDK调试工具(它不完美 - 可能是因为SGS2中的错误/限制 - 但至少有效)。