Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging native code of HelloJni

Tags:

android-ndk

I have been trying for days to debug into the c code of the sample hello-jni, with no success. I have installed all the requirements and followed many blog posts (repeating the process each time) to try to get this working.

I am using

  • Windows 7 64bit
  • Eclipse Juno with CDT 8.0.2
  • Android NDK r8b
  • Android SDK 20.0.3
  • the latest cygwin with make, gcc-core and gcc-g++ installed (altho I think NDK r8b doesn't need this?)

I have followed this http://developer.android.com/tools/sdk/ndk/index.html to set up and build the apk. It builds and installs fine and I can debug java code if launched as an Android Application

I followed this article about the NDK plugin http://tools.android.com/recent/usingthendkplugin but when launching as an Android Native Application with a breakpoint in the c code, the app launches and runs as normal with no breakpoint being hit and no error messages!

Any help would be greatly appreciated. Thanks!

EDIT:

Here's some errors that appear in the console for half a second before being cleared

warning: while parsing target library list (at line 2): No segment defined for /system/bin/linker

warning: Could not load shared library symbols for 52 libraries, e.g. /system/bin/linker.

Use the "info sharedlibrary" command to see the complete listing.

Do you need "set solib-search-path" or "set sysroot"?

warning: Unable to find dynamic linker breakpoint function.

GDB will be unable to debug shared library initializers and track explicitly loaded dynamic code.

Quit (expect signal SIGINT when the program is resumed)

like image 570
JeffG Avatar asked Oct 06 '22 02:10

JeffG


1 Answers

Turns out the above guides I used were all I needed and everything was working.

The warning messages were just... warnings and so debugging of the native code worked all along. My problem was the native function call where I had my breakpoint was being called immediately - before the gdb could attach. I put the JNI function call into an onClick and found my breakpoint was being hit after all.

I hope the above links and this answer can help someone. Thanks...

like image 56
JeffG Avatar answered Oct 10 '22 01:10

JeffG