Debugging Android NDK in Eclipse - how to stop segfaults / SIGILL, which occur only when entering native code

I set up debugging in Eclipse for native code using the Android NDK (on Windows XP, with Cygwin) to the point where I can set breakpoints in both Java and native code, and the debugger will correctly break them. My problem is that when you go through your own code, I often get segmentation / SIGILL errors that do not occur when continuing through the breakpoint.

  • My application is being debugged as defined in AndroidManifest.xml
  • I changed (NDK) /build/core/build-binary.mk so that it does not remove debugging characters when APP_OPTIM is defined as debug, which is in the Application.mk file in my jni directory
  • I defined LOCAL_CFLAGS := -g -O0 in the Android.mk file, and I also tried each of these flags separately

I read that this problem is related to the generated optimized code, but disabling optimization with -O0 does not affect my problem. I also came across using the NDK_BUILD=1 flag when creating, but the debuggable=true definition in AndroidManifest.xml seems to have the same effect.

I tried this both on the emulator (running 2.3.3) and on the device (running 2.2 - surprisingly there were no problems with the streams that I expected), with similar results (although, if I remember correctly, the failures occurred at different points code).

Does anyone have an idea of ​​the possible fixes / steps that I could try and / or was able to successfully execute my own code without problems?

Thank you very much




Edit: This has never really been resolved, but for those who want to take a look at my guide for debugging NDKs, you can find it.

Edit 2: The answers I received to this question appeared when new versions of NDK appeared, and this question may now be superfluous. My guide can still work, but I haven't used NDK for a while, so I can't vouch for its correctness. I accepted the answer that I have, since all three basically say the same thing, and this was the first to be presented.

+43
android debugging eclipse android-ndk
May 05 '11 at 14:46
source share
3 answers

If this works for armeabi and not for armeabi-v7a, this should be a build issue. Unzip the apk file to the bin directory and verify that the library files in both armeabi and armeabi-v7a are the same.

+2
May 14 '12 at 10:36 PM
source share

One thing I noticed is that armeabi-v7a does not work well for debugging native code on certain devices. Try to build only CSKA and see if this helps.

0
May 12 '12 at 21:24
source share

compile C ++ source files with -march = armv4

In build / core / combo / arm / yourarch.mk put -march = armv4 and then do mm -B showcommands to check if it was used.

Then gdbserver will be able to process it.

0
Mar 28 '13 at 16:04
source share



All Articles