I have set up debugging in Eclipse for native code using the Android NDK (on Windows XP, with Cygwin) to the stage where I can set breakpoints in both Java and native code and the debugger will break at them correctly. My issue is that when stepping through the native code, I will often get segmentation faults/SIGILLs that do not occur when continuing past the breakpoint instead.
APP_OPTIM
is defined as debug, which it is in the Application.mk file in my jni directoryLOCAL_CFLAGS := -g -O0
in the Android.mk file, and I have also tried each of these flags individuallyI have read that this problem is to do with the optimised code generated, but turning optimisation off with -O0
has no impact on my issue. I have also come across using the NDK_BUILD=1
flag when building, but defining debuggable=true
in AndroidManifest.xml apparently has the same effect.
I have tried this both on an emulator (running 2.3.3) and on a device (running 2.2 - which surprisingly didn't have the thread issues I expected), with similar results (although if I remember correctly, the failures happened at different points in code).
Does anyone have any insight into possible fixes/steps I could try, and/or have been able to successfully step through native code with no issues?
Thanks very much
Edit 2: The answers I got to this question came once new versions of the NDK had come out, and this question may now be redundant. My guide may still work, but I haven't been using the NDK for a while so I cannot vouch for its continued correctness. I have accepted the answer I have as all three basically say the same thing, and that was the first one to be submitted.
If it works for armeabi and not for armeabi-v7a, this should be a build issue. Unzip the apk file in the bin directory and check the library files in both the armeabi and armeabi-v7a are the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With