Today I've tried to debug hello-jni application using ndk-gdb from
android-ndk-r4b. Application run on device and in terminal I got gdb
command line. Well, I type 'info threads' there and got error. This is
known problem with gdbserver in latest NDK (it's built without thread
support). Then, I got prebuilt gdbserver binary from AOSP build system
(http://android.git.kernel.org/?p=platform/prebuilt.git;a=blob_plain;f=android-arm/gdbserver/gdbserver;hb=HEAD)
and put it instead of original one. This new gdbserver has thread
support. Then I ran ndk-gdb again and got strange error:
Attached; pid = 604
Listening on sockaddr socket debug-socket
Cannot attach to process 606: Operation not permitted (1)
Look, here 604 is pid of process started. But what is 606? I didn't
found other process with the same pid. Looks like it fork or smth like.
When I modify ndk-gdb in a way not use run-as feature but run gdbserver
directly, all works fine. Can anyone explain what's wrong with run-as?
And, another question, this approach with direct running gdbserver -
will it work on non-rooted devices? I believe no but I can't check. At
least it works fine on emulator and on both my devices (but they're
rooted already).
--
Dmitry Moskalchuk
So that's it - if I fix threading problem, it completely break debugging
on non-rooted devices; but without fix debugging of multi-threaded
application is not possible at all, on all devices (no matter rooted or
no) and emulator.
I don't have idea how to fix it without breaking debugging on non-rooted
devices. If anybody from Google (David? Dianne?) can respond me on that,
it'll be great.
Dmitry Moskalchuk