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

gdb debug couldn't be connected on targetSdkVersion 24. #224

Closed
pm1100tm opened this issue Oct 19, 2016 · 8 comments
Closed

gdb debug couldn't be connected on targetSdkVersion 24. #224

pm1100tm opened this issue Oct 19, 2016 · 8 comments
Assignees
Labels
Milestone

Comments

@pm1100tm
Copy link

I find that gdb debug could not be connected on targetSdkVersion 24.
It works on targetSdkVersion 23.
Used sample: https://github.com/googlesamples/android-ndk >> hello-gl2
Is there any workaround?

[Reproduction]

  1. Prepare for ant-build: In Terminal >> android update project -p . --target android-24
  2. Edit AndroidManifest.xml:
  3. Edit jni/Application.mk( Optional ) APP_ABI := all -> APP_ABI := armeabi-v7a
  4. ndk-build NDK_DEBUG=1
  5. ant debug >> created bin/GL2JNIActivity-debug.apk
  6. Install the apk file to Android7.0 device.
  7. Start gdb In Terminal.

[result]
Error: unable to connect to device.
Remote connection closed.

[My environment]
Android SDK (targetSdkVersion=24)
Android NDK r12b, r13
ant 1.9.4
Nexus 6P ( Android 7.0 )

@DanAlbert
Copy link
Member

  1. Start gdb In Terminal.

Does this mean you're not using ndk-gdb?

@pm1100tm
Copy link
Author

I was using ndk-gdb like this: ndk-gdb --launch --verbose --nowait

@DanAlbert DanAlbert added gdb and removed needs-info labels Oct 19, 2016
@DanAlbert DanAlbert added this to the r14 milestone Oct 19, 2016
@pm1100tm
Copy link
Author

pm1100tm commented Oct 19, 2016

Sorry for repro step 2:
***Edit AndroidManifest.xml
android:name="GL2JNIActivity" >> "com.android.gl2jni.GL2JNIActivity"
and set this:

@jmgao
Copy link
Contributor

jmgao commented Oct 20, 2016

Can you post the full output from ndk-gdb.py?

@jmgao
Copy link
Contributor

jmgao commented Oct 20, 2016

Looks like this is a permissions issue, the default permission for /data/data/<pkgname> is rwxr-x--x on 23, and rwx------ on 24. (This was a bit annoying to reproduce, because the permissions are only set on a fresh install, not an upgrade).

You can work around this with adb shell run-as <pkgname> chmod a+x /data/data/<pkgname>, until we release an update of ndk-gdb.py that does that automatically.

@pm1100tm
Copy link
Author

Reproduction Output:

***targetSdkVersion 24 (unable to connect to device)
$ ndk-gdb --launch --verbose --nowait
ADB command used: 'adb -s HT4C5JT00648'
ADB version: Android Debug Bridge version 1.0.36 Revision 84e3321d5db3-android
Using project directory: /Users/wondu/Desktop/Case/ndkmd/hello-gl2
Found package name: com.android.gl2jni
Selected target activity: 'com.android.gl2jni.GL2JNIActivity'
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.android.gl2jni
App gdbserver not found at /data/data/com.android.gl2jni/lib/gdbserver, uploading.
Copying gdbserver to /data/data/com.android.gl2jni/arm64-gdbserver.
Uploaded gdbserver to /data/data/com.android.gl2jni/arm64-gdbserver
Launching activity com.android.gl2jni/com.android.gl2jni.GL2JNIActivity...
Sleeping for 0.25 seconds.
Pulling '/system/bin/app_process64' to '/Users/wondu/Desktop/Case/ndkmd/hello-gl2/obj/local/arm64-v8a /system/bin/app_process64'
Pulling '/system/bin/linker64' to '/Users/wondu/Desktop/Case/ndkmd/hello-gl2/obj/local/arm64-v8a /system/bin/linker64'
Pulling '/system/lib64/libc.so' to '/Users/wondu/Desktop/Case/ndkmd/hello-gl2/obj/local/arm64-v8a /system/lib64/libc.so'
Pulling '/system/lib64/libm.so' to '/Users/wondu/Desktop/Case/ndkmd/hello-gl2/obj/local/arm64-v8a /system/lib64/libm.so'
Pulling '/system/lib64/libdl.so' to '/Users/wondu/Desktop/Case/ndkmd/hello-gl2/obj/local/arm64-v8a /system/lib64/libdl.so'
Starting gdbserver...
Redirecting gdbserver output to /var/folders/v0/sw2r7mtd30z8h95v1grbshbm00_q0q/T/gdbclient.log
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-apple-darwin14.5.0".
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 connection closed

***targetSdkVersion 23 (able to connect to device)
$ ndk-gdb --launch --verbose --nowait
ADB command used: 'adb -s HT4C5JT00648'
ADB version: Android Debug Bridge version 1.0.36 Revision 84e3321d5db3-android
Using project directory: /Users/wondu/Desktop/Case/ndkmd/hello-gl2
Found package name: com.android.gl2jni
Selected target activity: 'com.android.gl2jni.GL2JNIActivity'
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.android.gl2jni
App gdbserver not found at /data/data/com.android.gl2jni/lib/gdbserver, uploading.
Copying gdbserver to /data/data/com.android.gl2jni/arm64-gdbserver.
Uploaded gdbserver to /data/data/com.android.gl2jni/arm64-gdbserver
Launching activity com.android.gl2jni/com.android.gl2jni.GL2JNIActivity...
Sleeping for 0.25 seconds.
Pulling '/system/bin/app_process64' to '/Users/wondu/Desktop/Case/ndkmd/hello-gl2/obj/local/arm64-v8a /system/bin/app_process64'
Pulling '/system/bin/linker64' to '/Users/wondu/Desktop/Case/ndkmd/hello-gl2/obj/local/arm64-v8a /system/bin/linker64'
Pulling '/system/lib64/libc.so' to '/Users/wondu/Desktop/Case/ndkmd/hello-gl2/obj/local/arm64-v8a /system/lib64/libc.so'
Pulling '/system/lib64/libm.so' to '/Users/wondu/Desktop/Case/ndkmd/hello-gl2/obj/local/arm64-v8a /system/lib64/libm.so'
Pulling '/system/lib64/libdl.so' to '/Users/wondu/Desktop/Case/ndkmd/hello-gl2/obj/local/arm64-v8a /system/lib64/libdl.so'
Starting gdbserver...
Redirecting gdbserver output to /var/folders/v0/sw2r7mtd30z8h95v1grbshbm00_q0q/T/gdbclient.log
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-apple-darwin14.5.0".
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".
warning: Could not load shared library symbols for 149 libraries, e.g. /system/lib64/libcutils.so.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
0x0000007add81325c in __epoll_pwait () from /Users/wondu/Desktop/Case/ndkmd/hello-gl2/obj/local/arm64-v8a /system/lib64/libc.so
(gdb)

I will try to the workaround you suggested. Thanks.

@pm1100tm
Copy link
Author

It works to me after tried to do the workaround jmgao suggested.
"adb shell run-as chmod a+x /data/data/"
ndk-gdb connect to device.

@jmgao
Copy link
Contributor

jmgao commented Oct 21, 2016

@jmgao jmgao closed this as completed Oct 21, 2016
miodragdinic pushed a commit to MIPS/ndk that referenced this issue Apr 17, 2018
Applications with a minSdkVersion of 24 or greater have their data
directory permissions set to rwx------ (compared to rwxr-x--- for
previous versions). This prevents adbd from forwarding connections to
gdbserver. Resolve this by running `run-as <pkg> chmod a+x` on devices
running 24 or greater.

Bug: http://b/32292522
Bug: android/ndk#224
Change-Id: I697a040e8b069dfda9169441c100520ba5e6c686
Test: chmod 700 /data/data/<pkgname>, ndk-gdb.py starts working
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants