Failed to reach breakpoint in ndk-gdb on Android

Development environment:
NDK: r7
SDK and tools: r15
AVD: GB2.3.3, API level 10

I wrote a test application in which a thread will run in native. I saved a breakpoint in the stream. (In fact, when I tried to use the Galaxy S2, I received the error message: β€œStream debugging is not supported on this platform.” Therefore, I created AVD 2.3.3 Level 10).

After that I got an error like this

#0 0xafd0c51c in epoll_wait () from /Volumes/SecureCode/webos/rta/android/obj/local/armeabi/libc.so #1 0xa81216a6 in ?? () 

I googled and found this Solution (link here).

I followed the guide lines there

 $ adb pull /system/lib lib $ ndk-gdb ... (gdb) set solib-search-path lib 

But after that also I can’t get to the breakpoint. I am still obsessed with this poll_wait () and not moving forward.

 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) 

Who would like to focus on the main part of how

 (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) 

So, from the last error, I understand that it takes into account the absolute address 0x1a64. It does not take into account the relative address (run-time address), so it cannot get to the breakpoint. as well as getting stuck in epoll_wait () without moving further.

Someone please help me, how can I proceed further?

Thanks and respect,
SSuman185

+6
source share
1 answer

You can try debugging in Eclipse using the DS-5 CE plugin. You can find the installation and configuration tutorial here http://forums.arm.com/index.php?/topic/15575-arm-ds-5-tutorial-for-android/ (the last message is how to make it work on SGS2 )

I know this is not the exact answer to your question, but if you need NDK debugging in SGS2, you can try it as well for Eclipse and not for gdb command line (but who could ever debug command line debugging instead of debugging in the IDE?)

PS. DS-5 CE is the first NDK debugging tool that worked for me with SGS2 (it is not perfect - perhaps due to bugs / limitations in SGS2 - but at least it works).

+1
source

Source: https://habr.com/ru/post/902845/


All Articles