I want to debug a native library loaded by JNI on Android. I have set up the debugging environment to debug native code running on Bluestacks.

I got gdbserver installed on rooted Bluestacks, running in Windows environment, and I have gdb obtained from Adroid NDK on my Windows box.

I found out though that I am not able to debug ARM native code running on Bluestacks as the OS is running in i686 architecture and ARM is very likely emulated somehow by Bluestacks engine.

I can get a connection from gdb to gdbserver running on i686, but I can't set the architecture to arm (set architecture arm) afterwards and the debugger wants to operate with i686 registers.

Is there any way to actually set up gdb and gdbserver to switch to ARM architecture while the android is compiled for i686 arch and it does run on i686 which is my Windows box? I heard about gdb-multiarch, but I'm not sure if it is what I need. I tried gdb 7.6 from MinGW package, but it also didn't help.

  • I've been thinking and actually I have no idea how armeabi-v7a library can run on a x86 android. There must be a x86 version of the library in apk that I am missing or else it doesn't make any sense. – blackd0t May 11 '15 at 22:46
  • Bluestacks includes an ARM emulator, just like the emulators that come with the Android SDK do. So you don't need an i686 .so to run the app. However, it runs the kernel and some of the standard libraries natively, that's why it's so much faster than the SDK emulators. However, i very much doubt their emulator implements the ptrace call, which would be neccesary for gdb to attach. I'm afraid you'll need a real device with a real ARM processor to debug native code. – Guntram Blohm May 12 '15 at 13:06
  • Thanks Guntram! Yeah, I've been poking at this issue for the past 24 hours and I've found out, on the internet, the only way to debug ARM is on an ARM device. Guess I will have a good excuse to buy an android tablet now. I assume all android tablets run on ARM architecture rather than x86? – blackd0t May 12 '15 at 16:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.