android - How to Debug native code using ndk-gdb -


this getting after running ndk-gdb according many tutorials when links (gdb) server have type continue after how debug code there after. in case displays continuing , remain this. have further totally clueless.

arathore@chd-arathore-and /cygdrive/d/all_work/all_arathore/all_workspace_practice/ndkfoo $ /cygdrive/d/all_required_stuff/android/android-ndk-r8e/ndk-gdb --verbose --adb=/cygdrive/d/all_required_stuff/android/android-sdk-windows/platform-tools/adb.exe android ndk installation path: /cygdrive/d/all_required_stuff/android/android-ndk-r8e using specific adb command: /cygdrive/d/all_required_stuff/android/android-sdk-windows/platform-tools/adb.exe adb version found: android debug bridge version 1.0.31 using adb flags: using auto-detected project path: . found package name: com.example.ndkfoo /cygdrive/d/all_required_stuff/android/android-ndk-r8e/build/core/add-application.mk:128: android ndk: warning: app_platform android-14 larger android:minsdkversion 8 in /cygdrive/d/all_work/all_arathore/all_workspace_practice/ndkfoo/androidmanifest.xml abis targetted application: armeabi device api level: 17 device cpu abis: armeabi-v7a armeabi compatible device abi: armeabi /cygdrive/d/all_required_stuff/android/android-ndk-r8e/build/core/add-application.mk:128: android ndk: warning: app_platform android-14 larger android:minsdkversion 8 in /cygdrive/d/all_work/all_arathore/all_workspace_practice/ndkfoo/androidmanifest.xml using gdb setup init: /cygdrive/d/all_work/all_arathore/all_workspace_practice/ndkfoo/libs/armeabi/gdb.setup /cygdrive/d/all_required_stuff/android/android-ndk-r8e/build/core/add-application.mk:128: android ndk: warning: app_platform android-14 larger android:minsdkversion 8 in /cygdrive/d/all_work/all_arathore/all_workspace_practice/ndkfoo/androidmanifest.xml using toolchain prefix: /cygdrive/d/all_required_stuff/android/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi- /cygdrive/d/all_required_stuff/android/android-ndk-r8e/build/core/add-application.mk:128: android ndk: warning: app_platform android-14 larger android:minsdkversion 8 in /cygdrive/d/all_work/all_arathore/all_workspace_practice/ndkfoo/androidmanifest.xml using app out directory: ./obj/local/armeabi found debuggable flag: true found device gdbserver: /data/data/com.example.ndkfoo/lib/gdbserver found data directory: '/data/data/com.example.ndkfoo' found running pid: 1106 launched gdbserver succesfully. setup network redirection ## command: adb_cmd shell run-as com.example.ndkfoo lib/gdbserver +debug-socket --attach 1106 ## command: adb_cmd forward tcp:5039 localfilesystem:/data/data/com.example.ndkfoo/debug-socket ## command: adb_cmd pull /system/bin/app_process obj/local/armeabi/app_process attached; pid = 1106 listening on unix socket debug-socket 99 kb/s (9592 bytes in 0.093s) pulled app_process device/emulator. ## command: adb_cmd pull /system/bin/linker obj/local/armeabi/linker 54 kb/s (63240 bytes in 1.140s) pulled linker device/emulator. ## command: adb_cmd pull /system/lib/libc.so obj/local/armeabi/libc.so 75 kb/s (297604 bytes in 3.828s) pulled libc.so device/emulator. gnu gdb (gdb) 7.3.1-gg2 copyright (c) 2011 free software foundation, inc. license gplv3+: gnu gpl version 3 or later <http://gnu.org/licenses/gpl.html> free software: free change , redistribute it. there no warranty, extent permitted law.  type "show copying" , "show warranty" details. gdb configured "--host=i586-pc-mingw32msvc --target=arm-linux-android". bug reporting instructions, please see: <http://source.android.com/source/report-bugs.html>. remote debugging host 0.0.0.0 libthread_db:td_ta_new: probing system platform bug. libthread_db:_get_task_permitted_caps: found capperm of 0 in /proc/1147/task/1147/status libthread_db:_get_task_permitted_caps: found capperm of 0 in /proc/1106/task/1106/status libthread_db:_get_task_permitted_caps: found capperm of 0 in /proc/1106/task/1109/status libthread_db:_get_task_permitted_caps: found capperm of 0 in /proc/1106/task/1111/status libthread_db:_get_task_permitted_caps: found capperm of 0 in /proc/1106/task/1112/status libthread_db:_get_task_permitted_caps: found capperm of 0 in /proc/1106/task/1113/status libthread_db:_get_task_permitted_caps: found capperm of 0 in /proc/1106/task/1114/status libthread_db:_get_task_permitted_caps: found capperm of 0 in /proc/1106/task/1115/status libthread_db:_get_task_permitted_caps: found capperm of 0 in /proc/1106/task/1116/status libthread_db:_get_task_permitted_caps: found capperm of 0 in /proc/1106/task/1117/status libthread_db:_get_task_permitted_caps: found capperm of 0 in /proc/1106/task/1118/status libthread_db:td_ta_new: victory: can debug theads! 0x40037ebc in epoll_wait () d:/all_work/all_arathore/all_workspace_practice/ndkfoo/obj/local/armeabi/libc.so warning: not load shared library symbols 72 libraries, e.g. libstdc++.so. use "info sharedlibrary" command see complete listing. need "set solib-search-path" or "set sysroot"? warning: breakpoint address adjusted 0x40005a53 0x40005a52. (gdb) continue continuing. 

how debug?

according ndk-docs

you can set breakpoints 'b <location>' , resume execution 'c' (for 'continue'). see gdb manual list of commands. 

how make happen.

the commands same in gdb. basic primer:

  • set breakpoint entering b <function name> or b <file>:<line number>
  • step functions typing s
  • go next line typing n
  • continue execution c
  • print variable or expression value print <exp>
  • repeat last typed command hitting enter

you can find more comprehensive gdb tutorials online. have gdb cheatsheet printed out , posted on wall. should enough started.


Comments