Re: gdb and armeabi-v7a

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: gdb and armeabi-v7a

foo64
Still can't get this working using Eclipse & Cygwin, with NDK 8c and native C++ entry point (NativeActivity). I followed this tutorial ( http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debugging/ ) replacing 'armeabi' with armeabi-v7a' and using gdb.setup instead of gdb2.setup

I did find a bug in ndk-gdb that I had to work around, and is worth noting.

I set "APP_ABI = armeabi-v7a" in my Application.mk. ndk-build allows you to set NDK_APPLICATION_MK=(path to another Application.mk), however when ndk-gdb queries APP_ABI out of your Application.mk (line 475), it does *not* take into account NDK_APPLICATION_MK and falls back to jni/Application.mk, and when that doesn't exist falls back to $(NDK)/build/core/default-application.mk. The net result is it fails to query APP_ABI from the right Application.mk and defaults to 'armeabi' which is wrong (should be 'armeabi-v7a')

My workaround is to add jni/Application.mk and set APP_ABI=armeabi-v7a in there. That takes care of the ndk-gdb step. Based on my understanding of the NDK scripts/makefiles, I consider it a bug that ndk-gdb doesn't pass along arguments when querying with get_build_var( ). It should accept NDK_APPLICATION_MK=(whatever)

So now I've got gdbserver launching properly. I'm setting a breakpoint inside this while loop:

void android_main( android_app* state )
{
    int stop = 0;
    int x = 5;
    while( stop == 0 )
    {
        x++;
    }

... but gdb crashes when connecting!

Here's the gdbserver output:

Android NDK installation path: /cygdrive/e/uppercut/sdks/android-ndk
Using default adb command: /cygdrive/e/uppercut/sdks/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.example.radgame
ABIs targetted by application: armeabi-v7a
Device API Level: 15
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi-v7a
Using gdb setup init: ./libs/armeabi-v7a/gdb.setup
Using toolchain prefix: /cygdrive/e/uppercut/sdks/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi-v7a
Found debuggable flag: true
Found device gdbserver: /data/data/com.example.radgame/lib/gdbserver
Found data directory: '/data/data/com.example.radgame'
Found running PID: 3218
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: adb_cmd shell run-as com.example.radgame lib/gdbserver +debug-socket --attach 3218
## COMMAND: adb_cmd forward tcp:5039 localfilesystem:/data/data/com.example.radgame/debug-socket
Attached; pid = 3218
Listening on Unix socket debug-socket
## COMMAND: adb_cmd pull /system/bin/app_process obj/local/armeabi-v7a/app_process
3204 KB/s (9848 bytes in 0.003s)
Pulled app_process from device/emulator.
## COMMAND: adb_cmd pull /system/bin/linker obj/local/armeabi-v7a/linker
7732 KB/s (39592 bytes in 0.005s)
Pulled linker from device/emulator.
## COMMAND: adb_cmd pull /system/lib/libc.so obj/local/armeabi-v7a/libc.so
6994 KB/s (286536 bytes in 0.040s)
Pulled libc.so from device/emulator.
<waits while gdb connects...>
Remote debugging from host 0.0.0.0
libthread_db:td_ta_new: Probing system for platform bug.
<lots of repetitive lines...>
libthread_db:td_ta_new: Victory: We can debug theads!
readchar: Got EOF
Remote side has terminated connection.  GDBserver will reopen the connection.
Listening on Unix socket debug-socket


Here's the gdb output:

Reading symbols from E:\uppercut\prototype\build\code\androidp4\radgame\obj\local\armeabi-v7a\app_process...done.

WARNING: no debugging symbols found in E:\uppercut\prototype\build\code\androidp4\radgame\obj\local\armeabi-v7a\app_process.
Either the binary was compiled without debugging information
or the debugging information was removed (e.g., with strip or strip -g).
Debugger capabilities will be very limited.
For further information: http://wiki/Main/GdbFaq#No_debugging_symbols_found

89-gdb-set confirm off
(gdb)
89^done
(gdb)
90-gdb-set width 0
90^done
(gdb)
91-gdb-set height 0
91^done
(gdb)
92-interpreter-exec console echo
92^done
(gdb)
93-gdb-show prompt
93^done,value="(gdb) "
(gdb)
94-gdb-set target-async 0
94^done
(gdb)
95-gdb-set auto-solib-add on
95^done
(gdb)
96-gdb-set stop-on-solib-events 0
96^done
(gdb)
97-gdb-set stop-on-solib-events 1
97^done
(gdb)
98-target-select remote localhost:5039
=thread-group-started,id="i1",pid="42000"
=thread-created,id="1",group-id="i1"
&"warning: while parsing target library list (at line 2): No segment defined for com.example.radgame\n"
warning: while parsing target library list (at line 2): No segment defined for com.example.radgame
=library-loaded,id="/system/bin/linker",target-name="/system/bin/linker",host-name="E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame/./obj/local/armeabi-v7a/linker",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libc.so",target-name="libc.so",host-name="E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame/./obj/local/armeabi-v7a/libc.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstdc++.so",target-name="libstdc++.so",host-name="libstdc++.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libm.so",target-name="libm.so",host-name="libm.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="liblog.so",target-name="liblog.so",host-name="liblog.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libcutils.so",target-name="libcutils.so",host-name="libcutils.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libz.so",target-name="libz.so",host-name="libz.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libtime_genoff.so",target-name="libtime_genoff.so",host-name="libtime_genoff.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libutils.so",target-name="libutils.so",host-name="libutils.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libbinder.so",target-name="libbinder.so",host-name="libbinder.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libexpat.so",target-name="libexpat.so",host-name="libexpat.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libcrypto.so",target-name="libcrypto.so",host-name="libcrypto.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libgabi++.so",target-name="libgabi++.so",host-name="libgabi++.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libicuuc.so",target-name="libicuuc.so",host-name="libicuuc.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libicui18n.so",target-name="libicui18n.so",host-name="libicui18n.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libssl.so",target-name="libssl.so",host-name="libssl.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstlport.so",target-name="libstlport.so",host-name="libstlport.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libnativehelper.so",target-name="libnativehelper.so",host-name="libnativehelper.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libnetutils.so",target-name="libnetutils.so",host-name="libnetutils.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libGLESv2_dbg.so",target-name="libGLESv2_dbg.so",host-name="libGLESv2_dbg.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libEGL.so",target-name="libEGL.so",host-name="libEGL.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libwpa_client.so",target-name="libwpa_client.so",host-name="libwpa_client.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libhardware_legacy.so",target-name="libhardware_legacy.so",host-name="libhardware_legacy.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libpixelflinger.so",target-name="libpixelflinger.so",host-name="libpixelflinger.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libhardware.so",target-name="libhardware.so",host-name="libhardware.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libemoji.so",target-name="libemoji.so",host-name="libemoji.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libjpeg.so",target-name="libjpeg.so",host-name="libjpeg.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsecnativefeature.so",target-name="libsecnativefeature.so",host-name="libsecnativefeature.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libharfbuzz.so",target-name="libharfbuzz.so",host-name="libharfbuzz.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libquramimagecodec.so",target-name="libquramimagecodec.so",host-name="libquramimagecodec.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libskia.so",target-name="libskia.so",host-name="libskia.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libui.so",target-name="libui.so",host-name="libui.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libGLESv2.so",target-name="libGLESv2.so",host-name="libGLESv2.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmemalloc.so",target-name="libmemalloc.so",host-name="libmemalloc.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libQcomUI.so",target-name="libQcomUI.so",host-name="libQcomUI.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libremotedesktop_client.so",target-name="libremotedesktop_client.so",host-name="libremotedesktop_client.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libgui.so",target-name="libgui.so",host-name="libgui.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libcamera_client.so",target-name="libcamera_client.so",host-name="libcamera_client.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsqlite.so",target-name="libsqlite.so",host-name="libsqlite.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libqc-opt.so",target-name="libqc-opt.so",host-name="libqc-opt.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libdvm.so",target-name="libdvm.so",host-name="libdvm.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libGLESv1_CM.so",target-name="libGLESv1_CM.so",host-name="libGLESv1_CM.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libETC1.so",target-name="libETC1.so",host-name="libETC1.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsisodrm.so",target-name="libsisodrm.so",host-name="libsisodrm.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsonivox.so",target-name="libsonivox.so",host-name="libsonivox.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright_foundation.so",target-name="libstagefright_foundation.so",host-name="libstagefright_foundation.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmedia.so",target-name="libmedia.so",host-name="libmedia.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libQmageDecoder.so",target-name="libQmageDecoder.so",host-name="libQmageDecoder.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libnfc_ndef.so",target-name="libnfc_ndef.so",host-name="libnfc_ndef.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libusbhost.so",target-name="libusbhost.so",host-name="libusbhost.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libhwui.so",target-name="libhwui.so",host-name="libhwui.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libtilerenderer.so",target-name="libtilerenderer.so",host-name="libtilerenderer.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libbluedroid.so",target-name="libbluedroid.so",host-name="libbluedroid.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libdbus.so",target-name="libdbus.so",host-name="libdbus.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libandroid_runtime.so",target-name="libandroid_runtime.so",host-name="libandroid_runtime.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libvorbisidec.so",target-name="libvorbisidec.so",host-name="libvorbisidec.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright_yuv.so",target-name="libstagefright_yuv.so",host-name="libstagefright_yuv.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libdrmframework.so",target-name="libdrmframework.so",host-name="libdrmframework.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libpowermanager.so",target-name="libpowermanager.so",host-name="libpowermanager.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libdiag.so",target-name="libdiag.so",host-name="libdiag.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libaudcal.so",target-name="libaudcal.so",host-name="libaudcal.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libacdbloader.so",target-name="libacdbloader.so",host-name="libacdbloader.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libalsa-intf.so",target-name="libalsa-intf.so",host-name="libalsa-intf.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libchromium_net.so",target-name="libchromium_net.so",host-name="libchromium_net.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright_amrnb_common.so",target-name="libstagefright_amrnb_common.so",host-name="libstagefright_amrnb_common.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright_enc_common.so",target-name="libstagefright_enc_common.so",host-name="libstagefright_enc_common.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright_avc_common.so",target-name="libstagefright_avc_common.so",host-name="libstagefright_avc_common.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsavscmn.so",target-name="libsavscmn.so",host-name="libsavscmn.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsavsff.so",target-name="libsavsff.so",host-name="libsavsff.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libsurfaceflinger_client.so",target-name="libsurfaceflinger_client.so",host-name="libsurfaceflinger_client.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libtvoutinterface.so",target-name="libtvoutinterface.so",host-name="libtvoutinterface.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libtvoutservice.so",target-name="libtvoutservice.so",host-name="libtvoutservice.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmm-abl-oem.so",target-name="libmm-abl-oem.so",host-name="libmm-abl-oem.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmm-abl.so",target-name="libmm-abl.so",host-name="libmm-abl.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libstagefright.so",target-name="libstagefright.so",host-name="libstagefright.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmtp.so",target-name="libmtp.so",host-name="libmtp.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libexif.so",target-name="libexif.so",host-name="libexif.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libmedia_jni.so",target-name="libmedia_jni.so",host-name="libmedia_jni.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libbcc.so",target-name="libbcc.so",host-name="libbcc.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libbcinfo.so",target-name="libbcinfo.so",host-name="libbcinfo.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libRS.so",target-name="libRS.so",host-name="libRS.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="librs_jni.so",target-name="librs_jni.so",host-name="librs_jni.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libandroid.so",target-name="libandroid.so",host-name="libandroid.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libv8.so",target-name="libv8.so",host-name="libv8.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libwebcore.so",target-name="libwebcore.so",host-name="libwebcore.so",symbols-loaded="0",thread-group="i1"
=library-loaded,id="libradgame.so",target-name="libradgame.so",host-name="E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame/./obj/local/armeabi-v7a/libradgame.so",symbols-loaded="0",thread-group="i1"
&"warning: Could not load shared library symbols for 83 libraries, e.g. libstdc++.so.\nUse the \"info sharedlibrary\" command to see the complete listing.\nDo you need \"set solib-search-path\" or \"set sysroot\"?"
&"\n"
warning: Could not load shared library symbols for 83 libraries, e.g. libstdc++.so.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
&"warning: Breakpoint address adjusted from 0xb00056f5 to 0xb00056f4.\n"
warning: Breakpoint address adjusted from 0xb00056f5 to 0xb00056f4.
*stopped,frame={addr="0x4004d738",func="__futex_syscall3",args=[],from="E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame/./obj/local/armeabi-v7a/libc.so"},thread-id="1",stopped-threads="all",core="0"
98^connected
(gdb)
99 info proc
&"info proc\n"
&"Undefined info command: \"proc\".  Try \"help info\".\n"
99^error,msg="Undefined info command: \"proc\".  Try \"help info\"."
(gdb)
100-environment-cd E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame
100^done
(gdb)
101 info program
&"info program\n"
~"Debugging a target over a serial line.\n"
~"Program stopped at 0x4004d738.\n"
~"It stopped with signal SIGTRAP, Trace/breakpoint trap.\n"
~"Type \"info stack\" or \"info registers\" for more information.\n"
101^done
(gdb)
102 info threads
&"info threads\n"
=thread-created,id="2",group-id="i1"
~"[New Thread 3219]\n"
=thread-created,id="3",group-id="i1"
~"[New Thread 3223]\n"
=thread-created,id="4",group-id="i1"
~"[New Thread 3224]\n"
=thread-created,id="5",group-id="i1"
~"[New Thread 3225]\n"
=thread-created,id="6",group-id="i1"
~"[New Thread 3226]\n"
=thread-created,id="7",group-id="i1"
~"[New Thread 3229]\n"
=thread-created,id="8",group-id="i1"
~"[New Thread 3230]\n"
=thread-created,id="9",group-id="i1"
~"[New Thread 3231]\n"
=thread-created,id="10",group-id="i1"
~"[New Thread 3233]\n"
=thread-created,id="11",group-id="i1"
~"[New Thread 3317]\n"
=thread-created,id="12",group-id="i1"
~"[New Thread 3320]\n"
~"  Id   Target Id         Frame \n"
~"  12   Thread 3320       0x4004c7fc in __ioctl () from E:\\uppercut\\prototype\\build\\code\\androidp4\\radgame/./obj/local/armeabi-v7a/libc.so\n"

I have had debugging working before with gdb, with a Java entry point and 'armeabi'. After switching to C++ entry point (android_main) and 'armeabi-v7a', gdb crashes. I don't know if either is related...

On Monday, November 26, 2012 4:01:15 PM UTC-8, Brian Segall wrote:
Is anyone able to debug using gdb, after switching to armeabi-v7a? It worked fine before. So far I'm just wondering if it's an NDK/gdb issue, or my issue.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/C3sd5pRTszcJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.