Can ndk-gdb connect to Android devices under macOS Sierra and Win10?

518 views
Skip to first unread message

beinan li

unread,
Jul 17, 2017, 10:53:59 AM7/17/17
to android-ndk

I'm running NDK r12b on a Huawei Honor phone running Android 6.0.1, with USB debugging enabled.


Trying to ndk-gdb on any Android device will always give me:

Error: unable to connect to device.
Remote connection closed

A little before this I also see:

warning: Selected architecture aarch64 is not compatible with reported target architecture arm
warning: Architecture rejected target-supplied description

Note that I had to use sudo like this:

sudo ndk-gdb --force --verbose --launch

otherwise under gdb I would get

Unable to find Mach task port for process-id 44415: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))

Then under gdb, running the executable with run give me:

(gdb) run
Starting program:  /path/to/my/ndk-project-root/obj/local/arm64-v8a/system/bin/app_process64
During startup program terminated with signal SIG113, Real-time event 113.

From this one: gdb on macOS Sierra 10.12.4

I gathered that gdb has issues with macOS Sierra. Am I hitting the same issue with ndk-gdb?


Then I tried on Win10 and got pretty much the same result.

I also verified that the permission of /data/local/tmp/arm64-gdbserver is 777.


At this point I'm clueless. Please help.




Dan Albert

unread,
Jul 17, 2017, 1:28:13 PM7/17/17
to android-ndk, Josh Gao
+jmgao

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+unsubscribe@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/0406ba3a-8fc0-45e2-af67-9ea10a5c1486%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Josh Gao

unread,
Jul 17, 2017, 3:50:30 PM7/17/17
to Dan Albert, android-ndk
Try updating your ndk?

beinan li

unread,
Jul 17, 2017, 7:55:07 PM7/17/17
to android-ndk, dana...@google.com
btw, for my work, unfortunately I have to stay with r12b. So I cannot upgrade just yet.
Try updating your ndk?

+jmgao

To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.

beinan li

unread,
Jul 17, 2017, 7:55:07 PM7/17/17
to android-ndk, dana...@google.com
Progress:

Found that it's not a macOS issue.

So it turns out that the issue is two-fold:

  1. The real problem is the "unable to connect to device" one, caused by the fact that the OEM locked the debug capability. It has to be rooted to be able to connect with ndk-gdb. The same applies to debugging on Windows too. So this is unrelated to macOS. The sudo command is useless and irrelevant.
  2. The architecture warning was due to the fact that I forgot to deploy the new build (from a different version of my app) to the phone, so that the app already-installed on the phone was outdated. After another deployment through ant debug install, the warning is now gone.
Now a new problem unfolded:

After I got into gdb and
symbol-file <my.so>

to get the debug symbols, I hit another wall trying to hit the breakpoint:

(gdb) b MyClass::MyMethod
Breakpoint 1 at 0x158354: file /path/to/MyClass.cpp, line 45.
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x158354


Command aborted.
(gdb)


Any clues?

Also, I see that LLVM is now bundled with Android Studio. 

Is it that ndk-gdb will be deprecated, or, has already been?




On Monday, July 17, 2017 at 3:50:30 PM UTC-4, Josh Gao wrote:
Try updating your ndk?

+jmgao

To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages