ndk-gdb malfunction in ndk7

1,001 views
Skip to first unread message

mrzerg

unread,
Nov 23, 2011, 7:42:55 AM11/23/11
to android-ndk
Hello:
Today I upgrade my project from ndk-r5b to ndk7, and found ndk-gdb
is not right.

the problem is I cant' set breakpoint like:
> (gdb) b demo2.cpp:305
> No line 305 in file "jni/demo2.cpp".
but use function name is OK:
> (gdb) b appOnTouch(int, int, int)
> Breakpoint 1 at 0x809f9474: file D:/android/android-ndk-r7/sources/cxx-stl/stlport/stlport/stl/_alloc.h, line 158.
it's the same line demo2.cpp:305 and appOnTouch(). and the gdb
reply direct this breakpoint to wrong sourcefile (stl/_alloc.h)
further I try bt, the function name is right and the sourcefile is
wrong
>(gdb) bt
>#0 0x809f9474 in appOnTouch (action=40960, x=31386632, y=1)
> at D:/android/android-ndk-r7/sources/cxx-stl/stlport/stlport/stl/_alloc.h:158
>#1 0x809f9360 in Java_com_tencent_game_qqrestaurant_DemoGLSurfaceView_nativeOnTouch (action=0, >x=423, y=165)
> at D:/android/android-ndk-r7/sources/cxx-stl/stlport/stlport/stl/_alloc.h:158

and 'list' show the wrong source file and 'next' don't work.

I'm using a nexus one device running Android 2.3, not rooted.
before In ndk r5b it's all OK except some thread issue. the stl I use
is APP_STL := stlport_static

I'm attaching the whole ndk-gdb log here:
---------------------------------------------------------------------------------------------------

F:\restaurant\trunk\Client\Project\Android>D:\DEV\cygwin\bin\bash.exe
--login -c "cd /cygdrive/f/restaurant/trunk/Client/Project/A
ndroid/ && $NDK/ndk-gdb --verbose --exec=gdb_init.txt"
Android NDK installation path: /cygdrive/d/android/android-ndk-r7
Using default adb command: /cygdrive/d/android/android-sdk-windows/
platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.26
Using final ADB command: '/cygdrive/d/android/android-sdk-windows/
platform-tools/adb'
Using auto-detected project path: .
Found package name: com.tencent.game.qqrestaurant
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABIs: armeabi-v7a armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.tencent.game.qqrestaurant/lib/
gdbserver
Using gdb setup init: ./libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/d/android/android-ndk-r7/toolchains/
arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-a
ndroideabi-
Using app out directory: ./obj/local/armeabi
Found data directory: '/data/data/com.tencent.game.qqrestaurant'
Found running PID: 22960
Launched gdbserver succesfully.
Setup network redirection
## COMMAND: /cygdrive/d/android/android-sdk-windows/platform-tools/adb
forward tcp:5039 localfilesystem:/data/data/com.tencent.gam
e.qqrestaurant/debug-socket
## COMMAND: /cygdrive/d/android/android-sdk-windows/platform-tools/adb
shell run-as com.tencent.game.qqrestaurant lib/gdbserver +d
ebug-socket --attach 22960
Attached; pid = 22960
Listening on sockaddr socket debug-socket
## COMMAND: /cygdrive/d/android/android-sdk-windows/platform-tools/adb
pull /system/bin/app_process obj/local/armeabi/app_process
398 KB/s (5720 bytes in 0.014s)
Pulled app_process from device/emulator.
## COMMAND: /cygdrive/d/android/android-sdk-windows/platform-tools/adb
pull /system/lib/libc.so obj/local/armeabi/libc.so
1407 KB/s (273880 bytes in 0.190s)
Pulled libc.so from device/emulator.
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for
details.
This GDB was configured as "--host=i586-mingw32msvc --target=arm-elf-
linux".
(no debugging symbols found)
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
Error while mapping shared library sections:
libstdc++.so: No such file or directory.
Error while mapping shared library sections:
libm.so: No such file or directory.
Error while mapping shared library sections:
liblog.so: No such file or directory.
Error while mapping shared library sections:
libcutils.so: No such file or directory.
Error while mapping shared library sections:
libz.so: No such file or directory.
Error while mapping shared library sections:
libutils.so: No such file or directory.
Error while mapping shared library sections:
libbinder.so: No such file or directory.
Error while mapping shared library sections:
libexpat.so: No such file or directory.
Error while mapping shared library sections:
libcrypto.so: No such file or directory.
Error while mapping shared library sections:
libicuuc.so: No such file or directory.
Error while mapping shared library sections:
libicui18n.so: No such file or directory.
Error while mapping shared library sections:
libsqlite.so: No such file or directory.
Error while mapping shared library sections:
libssl.so: No such file or directory.
Error while mapping shared library sections:
libnativehelper.so: No such file or directory.
Error while mapping shared library sections:
libnetutils.so: No such file or directory.
Error while mapping shared library sections:
libEGL.so: No such file or directory.
Error while mapping shared library sections:
libwpa_client.so: No such file or directory.
Error while mapping shared library sections:
libhardware_legacy.so: No such file or directory.
Error while mapping shared library sections:
libpixelflinger.so: No such file or directory.
Error while mapping shared library sections:
libhardware.so: No such file or directory.
Error while mapping shared library sections:
libui.so: No such file or directory.
Error while mapping shared library sections:
libgui.so: No such file or directory.
Error while mapping shared library sections:
libsurfaceflinger_client.so: No such file or directory.
Error while mapping shared library sections:
libcamera_client.so: No such file or directory.
Error while mapping shared library sections:
libemoji.so: No such file or directory.
Error while mapping shared library sections:
libjpeg.so: No such file or directory.
Error while mapping shared library sections:
libskia.so: No such file or directory.
Error while mapping shared library sections:
libGLESv1_CM.so: No such file or directory.
Error while mapping shared library sections:
libskiagl.so: No such file or directory.
Error while mapping shared library sections:
libdvm.so: No such file or directory.
Error while mapping shared library sections:
libGLESv2.so: No such file or directory.
Error while mapping shared library sections:
libETC1.so: No such file or directory.
Error while mapping shared library sections:
libsonivox.so: No such file or directory.
Error while mapping shared library sections:
libmedia.so: No such file or directory.
Error while mapping shared library sections:
libnfc_ndef.so: No such file or directory.
Error while mapping shared library sections:
libbluedroid.so: No such file or directory.
Error while mapping shared library sections:
libdbus.so: No such file or directory.
Error while mapping shared library sections:
libandroid_runtime.so: No such file or directory.
Error while mapping shared library sections:
libvorbisidec.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_amrnb_common.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_enc_common.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_avc_common.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_foundation.so: No such file or directory.
Error while mapping shared library sections:
libstagefright_color_conversion.so: No such file or directory.
Error while mapping shared library sections:
libstagefright.so: No such file or directory.
Error while mapping shared library sections:
libmedia_jni.so: No such file or directory.
Error while mapping shared library sections:
libexif.so: No such file or directory.
Error while mapping shared library sections:
libsoundpool.so: No such file or directory.
Error while mapping shared library sections:
libacc.so: No such file or directory.
Error while mapping shared library sections:
libRS.so: No such file or directory.
Error while mapping shared library sections:
librs_jni.so: No such file or directory.
Error while mapping shared library sections:
libstlport.so: No such file or directory.
Error while mapping shared library sections:
libwebcore.so: No such file or directory.
Error while mapping shared library sections:
libAppleJuice.so: No such file or directory.
Error while mapping shared library sections:
gralloc.qsd8k.so: No such file or directory.
Error while mapping shared library sections:
libGLES_android.so: No such file or directory.
Error while mapping shared library sections:
libgsl.so: No such file or directory.
Error while mapping shared library sections:
libEGL_adreno200.so: No such file or directory.
Error while mapping shared library sections:
libGLESv1_CM_adreno200.so: No such file or directory.
Error while mapping shared library sections:
libGLESv2_adreno200.so: No such file or directory.
Error while mapping shared library sections:
libq3dtools_adreno200.so: No such file or directory.
(no debugging symbols found)
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint
0xafd0c51c in epoll_wait () from F:\restaurant\trunk\Client\Project
\Android/./obj/local/armeabi/libc.so
F:\restaurant\trunk\Client\Project\Android/obj/local/armeabi/gdb.setup:
7: Error in sourced command file:
No line 305 in file "jni/demo2.cpp".
(gdb) b appOnTouch(int, int, int)
Breakpoint 1 at 0x809f9474: file D:/android/android-ndk-r7/sources/cxx-
stl/stlport/stlport/stl/_alloc.h, line 158.
(gdb) c
Continuing.
[New Thread 22960]
[Switching to Thread 22960]

Breakpoint 1, 0x809f9474 in appOnTouch (action=40960, x=31386632, y=1)
at D:/android/android-ndk-r7/sources/cxx-stl/stlport/stlport/stl/
_alloc.h:158
158 { return (__n > (size_t)_MAX_BYTES) ? __stl_new(__n) :
_M_allocate(__n); }
Current language: auto; currently c++
(gdb) bt
#0 0x809f9474 in appOnTouch (action=40960, x=31386632, y=1)
at D:/android/android-ndk-r7/sources/cxx-stl/stlport/stlport/stl/
_alloc.h:158
#1 0x809f9360 in
Java_com_tencent_game_qqrestaurant_DemoGLSurfaceView_nativeOnTouch
(action=0, x=423, y=165)
at D:/android/android-ndk-r7/sources/cxx-stl/stlport/stlport/stl/
_alloc.h:158
#2 0x80017e38 in ?? ()
(gdb) l
153 public:
154 // this one is needed for proper simple_alloc wrapping
155 typedef char value_type;
156 /* __n must be > 0 */
157 static void* _STLP_CALL allocate(size_t& __n)
158 { return (__n > (size_t)_MAX_BYTES) ? __stl_new(__n) :
_M_allocate(__n); }
159 /* __p may not be 0 */
160 static void _STLP_CALL deallocate(void *__p, size_t __n)
161 { if (__n > (size_t)_MAX_BYTES) __stl_delete(__p); else
_M_deallocate(__p, __n); }
162 };
(gdb) n
0x80017e38 in ?? ()
(gdb) b demo2.cpp:305
No line 305 in file "jni/demo2.cpp".
(gdb) list
163
164 # if defined (_STLP_USE_TEMPLATE_EXPORT)
165 _STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__node_alloc>;
166 # endif
167
168 #endif
169
170 #if defined (_STLP_USE_TEMPLATE_EXPORT)
171 _STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__new_alloc>;
172 _STLP_EXPORT_TEMPLATE_CLASS __debug_alloc<__malloc_alloc>;
(gdb) n
Cannot find bounds of current function
(gdb)

dnick

unread,
Nov 23, 2011, 1:44:32 PM11/23/11
to android-ndk
Today I've got the same problem when switched from r6 to r7.
Further research showed me that commands
(gdb) maint print symbols my_source.cpp
(gdb) maint print psymtabs my_source.cpp
print different debug information for r6/r7 build file (for new build
<fullname> prop is '(none)').
Still don't know how to fix it so any help appreciated.

mrzerg

unread,
Nov 24, 2011, 3:13:20 AM11/24/11
to android-ndk

mingw android

unread,
Nov 24, 2011, 4:52:00 AM11/24/11
to andro...@googlegroups.com
Hi,

The post you linked to from Tor had a response from me with a version
of the NDK that doesn't have this problem (unfortunately I don't have
time to upgrade to basing it on r7 yet). Though Tor was on Mac, I've
also made versions for Windows and Linux. The link for the Windows
version is:

http://mingw-and-ndk.googlecode.com/files/android-ndk-r6b-gdb-7.3.50.20110709-windows.7z

Like Google's r7, this can be used from cmd.exe, so long as you add
<INSTALLPATH>\android-ndk-r6b\cmd-exe-tools to your path, either from
within windows or from cmd.exe as:

PATH=<INSTALLPATH>\android-ndk-r6b\cmd-exe-tools:%PATH%

The GDB I've supplied with it is very recent and includes Python
pretty printing support. It's also compiled as large-address-aware (as
I've seen GDB consume more than 2GB -and promptly crash without this
change - when debugging Qt applications). Also, GCC 4.4.3 has been
recompiled with Graphite support and an experimental 4.6.2 build is
also provided. ndk-gdb has been modified to work with MSYS too (it
doesn't work from cmd.exe as porting it to be a batch file would be a
bit painful)

Almost everything has been recompiled from scratch (the only
exceptions are the tools in cmd-exe-tools) and the test suite pass
also (with 4.4.3 anyway).

2011/11/24 mrzerg <mrzer...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>
>

chris

unread,
Nov 24, 2011, 3:19:03 AM11/24/11
to android-ndk
When I swittched to NDK-r7 I've the same problem...
it seems that the debug info goes wrong, in specific case, and i was
unable to isolate the problem ( some c++ source trigger the problem in
my case but in sample case it works... ).

To overcome this i switched the debug info from DWARF ( default) to
stabs by adding -gstabs+ to LOCAL_CPPFLAGS, LOCAL_CFLAGS,
LOCAL_LDLIBS.

Chris

> ...
>
> read more »

David Turner

unread,
Nov 24, 2011, 6:30:15 AM11/24/11
to andro...@googlegroups.com
On Thu, Nov 24, 2011 at 9:19 AM, chris <cgru...@gmail.com> wrote:
When I swittched to NDK-r7 I've the same problem...
it seems that the debug info goes wrong, in specific case, and i was
unable to isolate the problem ( some c++ source trigger the problem in
my case but in sample case it works... ).

To overcome this i switched the debug info from DWARF ( default) to
stabs by adding -gstabs+ to LOCAL_CPPFLAGS, LOCAL_CFLAGS,
LOCAL_LDLIBS.

Thanks for the information. For the record, there is already a bug filed for it at http://code.google.com/p/android/issues/detail?id=22211

I don't know exactly why this happens for now. I suspect this is a regression that is due to the fact that binutils was bumped to 2.20.1 for NDK r7 (it was using version 2.19 previously). Other than that, there were no other significant change to the way gdb is built.
 

mingw android

unread,
Nov 24, 2011, 7:05:47 AM11/24/11
to andro...@googlegroups.com
Hi David,

Anecdotal, but my version of the NDK uses binutils 2.20.1 apparently
without this issue. I suspect, if anything, that the GDB in the
official NDK is getting a bit too old and thus out of sync with the
rest of the toolchain (granted, this is not the most technical
analysis).

It should be possible (and easy) to try mixing in my GDB with the
official NDK to test this theory though (be careful to get all the
Python dependencies), here's the links:

http://mingw-and-ndk.googlecode.com/files/android-ndk-r6b-gdb-7.3.50.20110709-linux-x86.7z
http://mingw-and-ndk.googlecode.com/files/android-ndk-r6b-gdb-7.3.50.20110709-darwin-x86.7z
http://mingw-and-ndk.googlecode.com/files/android-ndk-r6b-gdb-7.3.50.20110709-windows.7z

Cheers,

Ray.

David Turner

unread,
Nov 24, 2011, 7:24:04 AM11/24/11
to andro...@googlegroups.com
On Thu, Nov 24, 2011 at 1:05 PM, mingw android <mingw....@gmail.com> wrote:
Hi David,

Anecdotal, but my version of the NDK uses binutils 2.20.1 apparently
without this issue. I suspect, if anything, that the GDB in the
official NDK is getting a bit too old and thus out of sync with the
rest of the toolchain (granted, this is not the most technical
analysis).

Interesting, thanks for the data point. It is actually possible to build gdb 7.1.x from the AOSP toolchain sources.

I just didn't enable this yet because I wanted more time for proper testing (it's hard to completely automate that kind of thing at the moment, but this is for another post :-))

Maybe just upgrading GDB would fix this bug. We'll see.

mingw android

unread,
Nov 24, 2011, 7:31:59 AM11/24/11
to andro...@googlegroups.com
With regards to testing, the Necessitas Qt project have been using
GDBs from my NDK for ages now (3 alpha releases * 3 host platforms)
and the only issue we've seen is that thumb-2 debugging doesn't work
well (it doesn't on 6.6 either though). I'd like to request, if
possible, to upgrade as far as the latest release, 7.3.1 and also
include Python support.

David Turner

unread,
Nov 24, 2011, 8:48:21 AM11/24/11
to andro...@googlegroups.com
On Thu, Nov 24, 2011 at 1:31 PM, mingw android <mingw....@gmail.com> wrote:
With regards to testing, the Necessitas Qt project have been using
GDBs from my NDK for ages now (3 alpha releases * 3 host platforms)
and the only issue we've seen is that thumb-2 debugging doesn't work
well (it doesn't on 6.6 either though). I'd like to request, if
possible, to upgrade as far as the latest release, 7.3.1 and also
include Python support.

I can only used the versions provided by our c compiler team, so for now this is 7.1.x, but hopefully this will be upgraded in the future to something more recent.

Regarding the Python support, if this doesn't add a Python installation requirement for the program to work properly, I don't see any reason not to. On the other hand, I don't want to have to deal with the usual Python version/modules/installation madness. Can I ask you how you did solve this issue?

mingw android

unread,
Nov 24, 2011, 8:57:58 AM11/24/11
to andro...@googlegroups.com
I branched Python 2.7.1, applied patches by Roumen Petrov and Руслан
Ижбулатов, fixed the patches, made it compile for MinGW to give a more
posix-y variant of Python (i.e. one that can be picked up and used by
configure scripts), made this version also work for Mac and Linux and
bundled it with my NDK, so I removed the variable of the locally
installed Python version as I didn't want the additional support
issues that would cause.

My Python version can be found here:

https://gitorious.org/mingw-python/mingw-python

Some things are really hacky (check build-python.sh if you want to see
the worst of that) but, on the plus side, it works well.

From lurking on CPython lists, I think that efforts are being made
towards making it build on MSYS/MinGW, which would be great.

So I bundle all the Python modules up with my NDKs and the gdb.exe
uses a relative path to find the modules and the so/dylib/dll (though
I'm considering moving to it being a static version instead - will
still have to support module loading of course).

dnick

unread,
Nov 24, 2011, 1:57:26 PM11/24/11
to android-ndk
Hi Ray, It's out of topic, but I decided to test your NDK with
4.6.2 toolchain, to check whether gcc 4.6.2 really eliminated 4.4.3's
compiling issues with a lot of neon intrinsics (this could save me a
lot of time rewriting our neon math on asm=):internal compiler error:
in reload_cse_simplify_operands, at postreload.c:396internal compiler
error: in change_address_1, at emit-rtl.c:1954
But unfortunately just replacing 'android-ndk-r6b' with yours one
breaks C++ compile with error:fatal error: opening dependency file /
cygdrive/{...}/my_source.o.d.org: No such file or directorycompilation
terminated.
The only difference I have encountered in the log of `ndk-build
V=1 NDK_LOG=1`:Android NDK: Host OS was auto-detected: windows /
official r6bAndroid NDK: Host OS was auto-detected: cygwin /your
r6band every path to .cpp,.o,.o.d.org (but not include paths) becomes /
cygdrive/ What do you think about this problem? (is it possible that
my own cygwin is interfering in paths with SDKs one?)

On Nov 24, 4:05 pm, mingw android <mingw.andr...@gmail.com> wrote:
> Hi David,
>
> Anecdotal, but my version of the NDK uses binutils 2.20.1 apparently
> without this issue. I suspect, if anything, that the GDB in the
> official NDK is getting a bit too old and thus out of sync with the
> rest of the toolchain (granted, this is not the most technical
> analysis).
>
> It should be possible (and easy) to try mixing in my GDB with the
> official NDK to test this theory though (be careful to get all the
> Python dependencies), here's the links:
>

> http://mingw-and-ndk.googlecode.com/files/android-ndk-r6b-gdb-7.3.50....http://mingw-and-ndk.googlecode.com/files/android-ndk-r6b-gdb-7.3.50....http://mingw-and-ndk.googlecode.com/files/android-ndk-r6b-gdb-7.3.50....
>
> Cheers,
>
> Ray.

mingw android

unread,
Nov 24, 2011, 2:21:55 PM11/24/11
to andro...@googlegroups.com

Can you try from cmd.exe or msys? I have a deep rooted hatred for cygwin which prevents me from installing it!

Actually I will install it just this once! If you are wanting to use 4.6.2 then use mklink from cmd.exe to link sources/cxx-stl to sources/cxx-stl-4.6.2.

Its also worth trying my 4.4.3 as its compiled differently from the google version and I've seen ICEs that happen on google's version that cant be reproduced on mine.

mingw android

unread,
Nov 24, 2011, 2:22:58 PM11/24/11
to andro...@googlegroups.com

Those ICEs were specifically neon related btw.

dnick

unread,
Nov 25, 2011, 6:39:05 AM11/25/11
to android-ndk
building solved:You were right - build is correct from cmd.exe via ndk-
build.bat, only necessary to include in PATH %NDK%\cmd-exe-tools
(otherwise it cannot find make-ma.exe).
When I changed toolchain by NDK_TOOLCHAIN environment variable, it was
necessary to create config.mk/setup.mk in toolchains folder (otherwise
error - 'NDK_TOOLCHAIN is defined to the unsupported value').by the
way - little note: in yours android-ndk-r6b-gdb-7.3.50.20110709-
windows.7z, cxx-stl is already equal to cxx-stl-4.6.2 (but default
toolchain of course 4.4.3)
Old neon compile errors has been dissapeared.But but unfortunately
there appeared another errors in asm compilation of temporary files
which cpp sources have many inlined neon intrinsics. =(
may be late i'll try to isolate them.. not casual iOS/XCode people
moved on llvmgcc and android isn't first platform where gcc kicks me
=)

On Nov 24, 11:22 pm, mingw android <mingw.andr...@gmail.com> wrote:
> Those ICEs were specifically neon related btw.

> On Nov 24, 2011 7:21 PM, "mingw android" <mingw.andr...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Can you try from cmd.exe or msys? I have a deep rooted hatred for cygwin
> > which prevents me from installing it!
>
> > Actually I will install it just this once! If you are wanting to use 4.6.2
> > then use mklink from cmd.exe to link sources/cxx-stl to
> > sources/cxx-stl-4.6.2.
>
> > Its also worth trying my 4.4.3 as its compiled differently from the google
> > version and I've seen ICEs that happen on google's version that cant be
> > reproduced on mine.

> >>http://mingw-and-ndk.googlecode.com/files/android-ndk-r6b-gdb-7.3.50......

Reply all
Reply to author
Forward
0 new messages