Take the 2-minute tour ×

I am trying to debug a mixed code on Android (Java/C/C++). My target device is Vizio 1008. The code runs on the emulator and I can debug it from Eclipse using GDB. However, I cannot do this on the real device.

After days of struggling with this I localized the problem:

When GDBSERVER starts on the device (successfully), it immediately quits with the message: "Unknown register d0 requested". Therefore, no debugging session is possible. I also tried DS-5 debugger from ARM. GDBSERVER stays connected, but exits on the connection attempt from the remote debugger. I tried GDBSERVER debug output, but it does not provide any useful info.

Even more strange, I tried any version of GDBSERVER I could get, and all of them behave like this. However, I found GDBSERVER from one of old versions of Google NDK (3 or 4 versions back). And this version WORKS!!! But, the debugger (on the host) dies very soon (segmentation fault), even I know that program is OK.

I looked at GDBSERVER source code, and, as it looks like, this error relates to the startup sequence, when GDBSERVER inspects the hardware. Probably, it relates to floating point co-processor, but I am not sure, as this error message is pretty generic.

If it matters, I am devloping on Windows using Google NDK. The code is 99% C/C++ with Java shell and a few functions implemented in Java (threaded HTTP calls). Again, the application works on the device and can be debugged (both Java and C/C++) on the emulator. I also can debug Java portion on the device.

Does anybogy know what it could be? And how to fix that? Is it Vizio?

Thank you in advance.

share|improve this question

1 Answer 1

Sounds similar to a problem i encountered trying to do native debugging. The problem was that the arm processor used in the device supported both the vfp/neon instruction set as well as the iwmmx instruction set and appearantly gdbserver assumes the two are mutually exclusive. To fix you'll need to mess with the gdbserver source unfortunately. Following is a fix from link. You'll need to edit the file linux-arm-low.c in the gdbserver source tree:

static void
arm_arch_setup (void)
  arm_hwcap = 0;
  if (arm_get_hwcap (&arm_hwcap) == 0)
    init_registers_arm ();

/* gdbserver assumes that only one of VFP or IWMMXT is available, which may
 not be true.  In that case, gdbserver fails at run-time with "Unknown
 register d0 requested".  For now, pretend IWMMXT is missing when both are
 available. */
if ((arm_hwcap & HWCAP_VFP) && (arm_hwcap & HWCAP_IWMMXT))
  arm_hwcap &= ~HWCAP_IWMMXT;

The exact location of where you have to change the code depends on the gdb(server) version though. I know for a fact it is slightly different in the case of gdb 7.7. After you changed it this way you should build it with gcc from the ndk, so it gets linked against bionic and stuff. I do not have exact instructions for that, because I didn't do it myself. I should stress that this is ultimately more of a workaround than a proper fix. I do not know how gdbserver patched this way behaves when running code that actually contains iwmmx instructions. At least you'll probably not be able to get register dumps of iwmmx registers.

share|improve this answer

Your Answer


