views:

108

answers:

2

Hi all,

I'm trying to debug an application build with the NDK on a Motorola Droid. I'm following the instructions here and I've had success in the past on an emulator (I have root access obviously) but when I try to start

gdbserver :5039 --attach 1082

through the adb shell, I get a gdbserver:permission denied. Obviously as this is a stock Droid, I don't have root access. Is that necessary? Am I just missing something?

Thanks in advance!

Edit I have confirmed that this command works on the emulator. Can this be done on a nonrooted device?

Edit 2 I have also confirmed the same Permission Denied errors on an EVO 4G.

Edit 3 I have also discovered that a production device (eg. EVO 4G or Droid) will not give me a "not found" error. For instance, when I typed something random like ljs at the shell, I get ljs: permission denied. The error is the same if the command exists and I can't access it (sudo - presumably) or if the command does not exist (ljs).

A: 

I see no reference to 'localhost' as per

gdbserver :5039 --attach pid

in the link you've given - that is on the handset....have you forwarded the port

adb forward tcp:5039 tcp:5039

from the workstation?

Also:

If you can't find either special version of gdb, run find prebuilt -name 
arm-eabi-gdb in your source tree to find and run the latest version

Have you tried using 'arm-eabi-gdb' instead, by replacing the above gdb with the explicit version....?

tommieb75
I removed the `localhost` with no luck. I haven't tried any of the versions of gdb on my host because I haven't been able to start the server on the device.
Chris Thompson
A: 

If you're using the r4 NDK, you shouldn't have to do a lot of this. Instead:

  1. Add android:debuggable="true" in your ApplicationManifest.xml's application node
  2. For any native (built with NDK) libraries, repeat #1 before building them (you should note a extra bit of information when building where ndk-build is copying a gdbserver and gdb.setup files)
  3. Fire up $NDK_ROOT/ndk-gdb with your desired options (e.g.: I commonly break in Eclipse before hitting native code then attach using the -E option)
NuSkooler