Native debugging on Galaxy S4

1,057 views
Skip to first unread message

Michael Adams

unread,
Jun 20, 2013, 6:20:49 PM6/20/13
to andro...@googlegroups.com
Hi all,

We just got a Samsung Galaxy S4 (on Verizon, Android 4.2.2) for dev and testing, but I'm having some issues. I just recently got into the NDK scene as part of my job, so I'm going to err on the side of extra detail rather than too little... Notes: we use Eclipse (I'm on Kepler release, build 20130606-0932), I'm on a Mac Book Pro, OS X 10.8.4, I'm using NDK r8d (was told r8e had some issues with our stuff).

So, in our process, we start by launching a debugger for the android application, with a breakpoint set in the onCreate method. Once it stops at the breakpoint, we open a terminal in the project's root, and run "ndk-gdb --verbose --force". Once that command has finished, we go back into eclipse and launch a C/C++ debug configuration.  Again, pretty knew to this, but if I understand what's happening, then the ndk-gdb sets up the gdbserver to accept debugging connections, and the C/C++ debug config points to that gdbserver. Regardless of how correct my understanding of this part is, I HAVE successfully gotten to the point of debugging with my setup, and tested with a few devices (there was a standard guide to follow here for setting it up). So, onto the actual issue...

When I go to run the ndk-gdb command with the S4, it gives the following output:

adamsmac:AndroidSDK mich6984$ ndk-gdb --verbose --force
Android NDK installation path: /Users/mich6984/Development/android-ndk-r8d
Using default adb command: /Users/mich6984/Development/android-sdk/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.31
Using ADB flags:
Using auto-detected project path: .
Found package name: com.esri.androidsdk
ABIs targetted by application: armeabi-v7a
Device API Level: 17
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi-v7a
Using gdb setup init: ./libs/armeabi-v7a/gdb.setup
Using toolchain prefix: /Users/mich6984/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi-v7a
Found debuggable flag: true
Found device gdbserver: /data/data/com.esri.androidsdk/lib/gdbserver
ERROR: Could not extract package's data directory. Are you sure that
       your installed application is debuggable?

As the output shows, debuggable IS set to true, but for some reason that is not acknowledged on the S4. If I follow the exact same process on my personal phone (Motorola Droid 4, 4.2.2), it gives the following output:

adamsmac:AndroidSDK mich6984$ ndk-gdb --verbose --force
Android NDK installation path: /Users/mich6984/Development/android-ndk-r8d
Using default adb command: /Users/mich6984/Development/android-sdk/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.31
Using ADB flags:
Using auto-detected project path: .
Found package name: com.esri.androidsdk
ABIs targetted by application: armeabi-v7a
Device API Level: 17
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi-v7a
Using gdb setup init: ./libs/armeabi-v7a/gdb.setup
Using toolchain prefix: /Users/mich6984/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi-v7a
Found debuggable flag: true
Found device gdbserver: /data/data/com.esri.androidsdk/lib/gdbserver
Found data directory: '/data/data/com.esri.androidsdk'
Found running PID: 24900
Killing existing debugging session
## COMMAND: adb_cmd shell kill -9 24798
Killed
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: adb_cmd shell run-as com.esri.androidsdk lib/gdbserver +debug-socket --attach 24900
## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/com.esri.androidsdk/debug-socket
## COMMAND: adb_cmd pull /system/bin/app_process ./obj/local/armeabi-v7a/app_process
Attached; pid = 24900
Listening on Unix socket debug-socket
2244 KB/s (9560 bytes in 0.004s)
Pulled app_process from device/emulator.
## COMMAND: adb_cmd pull /system/bin/linker ./obj/local/armeabi-v7a/linker
2368 KB/s (42720 bytes in 0.017s)
Pulled linker from device/emulator.
## COMMAND: adb_cmd pull /system/lib/libc.so ./obj/local/armeabi-v7a/libc.so
3233 KB/s (289928 bytes in 0.087s)
Pulled libc.so from device/emulator.
adamsmac:AndroidSDK mich6984$ Remote debugging from host 0.0.0.0
libthread_db:td_ta_new: Probing system for platform bug.
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/24942/task/24942/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/24900/task/24900/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/24900/task/24902/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/24900/task/24905/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/24900/task/24906/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/24900/task/24907/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/24900/task/24908/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/24900/task/24909/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/24900/task/24910/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/24900/task/24911/status
libthread_db:_get_task_permitted_caps: Found CapPerm of 0 in /proc/24900/task/24912/status
libthread_db:td_ta_new: Victory: We can debug theads!
Killing all inferiors

It is also successful with Note 2, Galaxy Tab 2, Galaxy Nexus, and Galaxy S3, among others. ONLY the Galaxy S4 is giving me issues. As it is fairly new, there is very little information to be found on this, and Samsungs tech support was very unhelpful. In my searches someone had suggested that it may need root access, but after rooting it, the same problem remained.

Please let me know if any additional information would be useful.

Michael Adams

unread,
Jul 18, 2013, 12:25:31 PM7/18/13
to andro...@googlegroups.com
Bump. We have still made no headway on this. Samsung's customer service has been pretty close to useless on this.

Radovan Chytracek

unread,
Jul 19, 2013, 4:37:17 AM7/19/13
to andro...@googlegroups.com
Hi,

try to run the command

adb shell run-as com.esri.androidsdk
/data/data/com.esri.androidsdk/lib/gdbserver --remote-debug --debug
:5039 --attach PID

where PID is process ID of your running app.
> --
> 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...@googlegroups.com.
> To post to this group, send email to andro...@googlegroups.com.
> Visit this group at http://groups.google.com/group/android-ndk.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
Reply all
Reply to author
Forward
0 new messages