Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ndk-gdb from NDK r12 for Windows x64 can't start the debugging on arm64-v8a device #118

Closed
nvidiamfilimonov opened this issue Jun 10, 2016 · 7 comments
Assignees
Milestone

Comments

@nvidiamfilimonov
Copy link

I've tested it on two arm64-v8a devices - one was with Android 6.0 and the other is Nexus 9 running Android N DP2, got the same result for each trial:

c:\wrk\android\android-ndk-samples\native-activity>f:\work\android-ndk-r12\ndk-gdb.cmd -v -t --launch android.app.NativeActivity
ADB command used: 'adb -s HT4AHJT08522'
ADB version: Android Debug Bridge version 1.0.35 Revision fc2a139a55f5-android
Using project directory: c:\wrk\android\android-ndk-samples\native-activity
Found package name: com.example.native_activity
Selected target activity: 'android.app.NativeActivity'
Application ABIs: arm64-v8a, armeabi, armeabi-v7a, mips, mips64, x86, x86_64
Device ABIs: arm64-v8a, armeabi-v7a, armeabi
Selecting ABI: arm64-v8a
Detected pretty printer: none
Found application data directory: /data/data/com.example.native_activity
App gdbserver not found at /data/data/com.example.native_activity/lib/gdbserver, uploading.
Copying gdbserver to /data/data/com.example.native_activity/arm64-gdbserver.
ERROR: Failed to copy gdbserver to /data/data/com.example.native_activity/arm64-gdbserver.

@nvidiamfilimonov
Copy link
Author

That's strange as it's possible to copy the same debugger binary into the package directory by hand:

c:\wrk\android\android-ndk-samples\native-activity>adb shell
flounder:/ $ run-as com.example.native_activity id
uid=10088(u0_a88) gid=10088(u0_a88) groups=10088(u0_a88),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc) context=u:r:untrusted_app:s0:c512,c768 flounder:/ $ run-as com.example.native_activity ls /data/data/com.example.native_activity
cache files
flounder:/ $ ls -lah /data/local/tmp/
total 2.1M
drwxrwx--x 3 shell shell 4.0K 2016-06-10 13:02 .
drwxr-x--x 3 root root 4.0K 2016-04-22 15:21 ..
-rw-rw-rw- 1 shell shell 823K 2016-06-01 23:13 arm64-gdbserver
-rw-rw-rw- 1 shell shell 401K 2016-04-25 16:48 com.example.native_activity
-rw-rw-rw- 1 shell shell 0 2016-04-25 17:29 com.example.native_activity-build-id.txt
flounder:/ $ run-as com.example.native_activity cp /data/local/tmp/arm64-gdbserver /data/data/com.example.native_activity/arm64-gdbserver
flounder:/ $ run-as com.example.native_activity ls -lah /data/data/com.example.native_activity/arm64-gdbserver
-rw-rw-rw- 1 u0_a88 u0_a88 823K 2016-06-10 13:08 /data/data/com.example.native_activity/arm64-gdbserver

@nvidiamfilimonov
Copy link
Author

In fact, ndk-gdb seems to not work at all for me. In case of armeabi-v7a it can deploy and launch gdbserver, but gdb executable can't connect to the gdbserver launched on the target

c:\android-ndk-samples\native-activity>f:\work\android-ndk-r12\ndk-gdb.cmd -v
ADB command used: 'adb -s 015d24a8173c1e12'
ADB version: Android Debug Bridge version 1.0.35 Revision fc2a139a55f5-android
Using project directory: c:\android-ndk-samples\native-activity
Found package name: com.example.native_activity
Attaching to existing application process.
Application ABIs: arm64-v8a, armeabi, armeabi-v7a, mips, mips64, x86, x86_64
Device ABIs: armeabi-v7a, armeabi
Selecting ABI: armeabi-v7a
Detected pretty printer: none
Found application data directory: /data/data/com.example.native_activity
App gdbserver not found at /data/data/com.example.native_activity/lib/gdbserver, uploading.
Uploaded gdbserver to /data/local/tmp/arm-gdbserver
Pulling '/system/bin/linker' to 'c:\android-ndk-samples\native-activity\obj\local\armeabi-v7a\system\bin\linker'
Pulling '/system/lib/libc.so' to 'c:\android-ndk-samples\native-activity\obj\local\armeabi-v7a\system\lib\libc.so'
Pulling '/system/lib/libm.so' to 'c:\android-ndk-samples\native-activity\obj\local\armeabi-v7a\system\lib\libm.so'
Pulling '/system/lib/libdl.so' to 'c:\android-ndk-samples\native-activity\obj\local\armeabi-v7a\system\lib\libdl.so'
Starting gdbserver...
Redirecting gdbserver output to appdata\local\temp\gdbclient.log

Here's gdb output

GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Error: unable to connect to device.
Remote communication error. Target disconnected.: No error.
(gdb)

gdbserver.log contains a single string

run-as: exec failed for /data/local/tmp/arm-gdbserver Error:Permission denied

@enh
Copy link
Contributor

enh commented Jun 10, 2016

run-as: exec failed for /data/local/tmp/arm-gdbserver Error:Permission denied

makes sense given

-rw-rw-rw- 1 shell shell 823K 2016-06-01 23:13 arm64-gdbserver

you'll want to chmod a+x arm64-gdbserver.

@nvidiamfilimonov
Copy link
Author

nvidiamfilimonov commented Jun 10, 2016

@enh I can, but it's makes no sense as the gdbserver that runs under the shell UID can't attach to the package process.
All that should be done in case of non-rooted device is to copy the debug server binary from /data/local/tmp directory to the package data root
Anyways, it's the ndk-gdb script job, and not my duty:)

@DanAlbert DanAlbert added this to the r13 milestone Jun 10, 2016
@jmgao
Copy link
Contributor

jmgao commented Jun 10, 2016

Whoops, ndk-gdb is completely broken (again).
Applying this patch to your ndk-gdb.py should fix it.

@jmgao
Copy link
Contributor

jmgao commented Jun 17, 2016

Fixed in r12b

@jmgao jmgao closed this as completed Jun 17, 2016
miodragdinic pushed a commit to MIPS/ndk that referenced this issue Jan 12, 2017
This was working for me because of a local hack in adb.py in a separate
checkout, which was being brought in via PYTHONPATH. :-(

Bug: android/ndk#118
Change-Id: Idecbe9b1a2e914599f1c062883fe1fd72eb320f0
@xloem
Copy link

xloem commented Feb 15, 2021

I'm experiencing this error message on 21.4.7075529 .

/opt/android/ndk/21.4.7075529/ndk-gdb --verbose --launch
ADB command used: 'adb -s 10.0.0.159:5555'
ADB version: Android Debug Bridge version 1.0.41 Version 30.0.5-6877874 Installed as /opt/android/platform-tools/adb
Using project directory: /shared/src/BrainFlowAndroidTest/app/src/main 
Found package name: com.example.brainflowplot
Selected target activity: 'com.example.brainflowplot.SettingsActivity'
Application ABIs: arm64-v8a, armeabi-v7a, x86, x86_64
Device ABIs: arm64-v8a, armeabi-v7a, armeabi
Selecting ABI: arm64-v8a
Found application data directory: /data/data/com.example.brainflowplot
App gdbserver not found at /data/data/com.example.brainflowplot/lib/gdbserver, uploading.
Copying gdbserver to /data/data/com.example.brainflowplot/arm64-gdbserver.
ERROR: Failed to copy gdbserver to /data/data/com.example.brainflowplot/arm64-gdbserver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@xloem @DanAlbert @jmgao @enh @nvidiamfilimonov and others