The gdb in NDK r7 on MacOSX maps code addresses to source code completely wrong

387 views
Skip to first unread message

Tor Lillqvist

unread,
Nov 15, 2011, 7:54:56 AM11/15/11
to andro...@googlegroups.com
When I debug an app written in mostly native code (C++ and some C, multiple shared objects), that uses NativeActivity, ndk-gdb manages to set breakpoints in C++ functions just fine, but it maps code addresses to completely wrong source code locations. If I set a breakpoint at one C++ function that is in no way special as far as I can see, "i b" shows the breakpoint being at /Users/tml/android-ndk-r7/sources/cxx-stl/gnu-libstdc++/include/exception:61 ... and that is also where it thinks I am when I then hit the breakpoint. (From debugging printouts I do see that I actually am in the function where I set the breakpoint, though.) This makes single stepping through the function a bit pointless, as gdb all the time thinks I am at line 61 in that "exception" header. What could be the problem?

--tml

David Turner

unread,
Nov 15, 2011, 10:35:33 AM11/15/11
to andro...@googlegroups.com
On Tue, Nov 15, 2011 at 1:54 PM, Tor Lillqvist <t...@iki.fi> wrote:
When I debug an app written in mostly native code (C++ and some C, multiple shared objects), that uses NativeActivity, ndk-gdb manages to set breakpoints in C++ functions just fine, but it maps code addresses to completely wrong source code locations. If I set a breakpoint at one C++ function that is in no way special as far as I can see, "i b" shows the breakpoint being at /Users/tml/android-ndk-r7/sources/cxx-stl/gnu-libstdc++/include/exception:61 ... and that is also where it thinks I am when I then hit the breakpoint. (From debugging printouts I do see that I actually am in the function where I set the breakpoint, though.) This makes single stepping through the function a bit pointless, as gdb all the time thinks I am at line 61 in that "exception" header. What could be the problem?

This is really unexpected. Is there a way for you to reproduce the problem with a minimal source file that could be used for debugging this?
Do you know if the same issue happens on Linux and Windows?

I encourage you to file a bug at b.android.com about this and add as much detail about this condition as possible.

Thanks

--tml

--
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/-/MNTxTlXJZssJ.
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.

a1

unread,
Nov 15, 2011, 6:01:03 PM11/15/11
to andro...@googlegroups.com
It does happens on Windows, I have similar problems with an moderate size app written in C++, project consists of several static libs linked into single .so. Application uses gnustl_static std lib with exceptions enabled, std is set to gnu++0x.

--
Bart Janusz

mingw android

unread,
Nov 16, 2011, 7:38:21 AM11/16/11
to andro...@googlegroups.com
Hi Tor (from GTK+ on Windows fame?)

I work on the Necessitas Qt Android project, maintaining NDK
toolchains and Mac and Windows builds. We use a much more recent GDB
than what Google provide (sources from July of this year):

I'd really appreciate it if you could test to see if your problem
persists with my version:

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

I've compressed it as a 7z and because that format isn't supported too
well on Mac OS X, I've also provided a 7z executable (though there's
something called keka that can also be used):

http://mingw-and-ndk.googlecode.com/files/p7zip-macosx.tar.bz2

Best regards,

Ray Donnelly.

p.s. It also contains GCC 4.4.3 recompiled with Graphite support and
GCC 4.6.2 (though this isn't enabled by default yet, and there's no
parameters to ndk-build to select it yet either, hence the WIP
status).

> --
> 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/-/c8FP5PvQD64J.

Tor Lillqvist

unread,
Nov 16, 2011, 3:13:39 PM11/16/11
to andro...@googlegroups.com
> from GTK+ on Windows fame?

Yes...


> I'd really appreciate it if you could test to see if your problem
> persists with my version

Hmm, I am using NDK r7 and I didn't manage to get the arm-linux-androideabi-gdb from your archive to work... I renamed the arm-linux-androideabi-gdb and arm-linux-androideabi-gdbtui in my r7 and copied yours in place instead, and also copied the "python" subdirectory. But when I run arm-linux-androideabi-gdb , it just says ImportError: No module named site.

--tml

mingw android

unread,
Nov 16, 2011, 3:39:30 PM11/16/11
to andro...@googlegroups.com

Cool,

There are various support modules needed for python, so rather than trying to mix mine with Google's you should use one or the other. I've included a more recent binutils as well for fixes to thumb debugging info.

--
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/-/3poMPtoGrloJ.

Tor Lillqvist

unread,
Nov 16, 2011, 3:59:03 PM11/16/11
to andro...@googlegroups.com
> There are various support modules needed for python, so rather than trying to mix mine with Google's you should use one or the other.

OK. If I try to use just your stuff, then when running ndk-build I get:

Android NDK: : Cannot find module with tag 'cxx-stl/system' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
Android NDK:
/Volumes/tmp/android-ndk-r6b/build/core/setup-toolchain.mk:142: *** Android NDK: Aborting.    .  Stop.

I have not needed to set any NDK_MODULE_PATH thingie with the Google toolchain... I now have in PATH:

/Volumes/tmp/android-ndk-r6b:/Volumes/tmp/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin:/Users/tml/android-sdk-macosx/platform-tools:/Users/tml/android-sdk-macosx/tools:/Users/tml/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

where /Volumes/tmp/android-ndk-r6b is where I unpacked your 7z arhive.

--tml

mingw android

unread,
Nov 16, 2011, 4:01:58 PM11/16/11
to andro...@googlegroups.com

Ah yeah. A small packaging bug. I will uploaded another version shortly. The fix is to copy system folder from sources/cxx-stl from Google's ndk into mine. I'll post again when uploaded.

--
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/-/hNZZtLxR1eAJ.

Tor Lillqvist

unread,
Nov 16, 2011, 4:35:57 PM11/16/11
to andro...@googlegroups.com
I think the problem is that the 7z format doesn't support symlinks, and I assume sources/cxx-stl is supposed to be a symlink, not a plain file...

--tml

mingw android

unread,
Nov 16, 2011, 4:44:00 PM11/16/11
to andro...@googlegroups.com
7z does handle links ok (keka and my 7za executable), it's a missing
file issue, sorry for the hassle; there'll be a new NDK uploaded as
soon as I get it sorted out, that'll teach me not to skip running the
(comprehensive) test scripts in future!

Cheers.

> --
> 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/-/C3XBcwtzJJwJ.

Tor Lillqvist

unread,
Nov 16, 2011, 5:19:45 PM11/16/11
to andro...@googlegroups.com
Yeah, once I fixed the cxx-stl issue, your ndk-gdb indeed works much better thanks! (Why does Google ship an outdated gdb etc in their NDK? Have you attempted to upstream your work?)

--tml

mingw android

unread,
Nov 16, 2011, 5:23:30 PM11/16/11
to andro...@googlegroups.com
It's uploaded now:

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

I ran all the tests and they passed. I made cxx-stl a link to my own
rebuild of libstdc++, but also copied the google version to
android-ndk-r6b/sources/cxx-stl-google; just in case. There's also
cxx-stl-4.6.2 there if you wanted to try any C++11 stuff. Just remove
the cxx-stl and relink it to one of the others.

Both toolchains (Google 4.4.3 and Linaro 4.6.2) have been rebuilt with
graphite support. To try this, you should add the following arguments
to g++

For 4.4.3: -floop-block -fgraphite-identity
For 4.6.2: -floop-interchange -floop-strip-mine -floop-block
-fgraphite-identity -floop-parallelize-all

Cheers,

Ray.

mingw android

unread,
Nov 16, 2011, 5:42:13 PM11/16/11
to andro...@googlegroups.com
> Yeah, once I fixed the cxx-stl issue, your ndk-gdb indeed works much better thanks!

Great, thanks for helping me shake out the issues.

If you want to try a full IDE geared for Android C++ development
(either purely NDK and of course supporting Qt), can I recommend you
take a look at Necessitas Qt Creator (usual disclaimer, I work on it).

We released the third alpha (and an update for it which included the
Mac version) recently. Please check the video links and try it out if
you're interested.

Homepage: http://sourceforge.net/p/necessitas/home/necessitas/
Alpha 0.3 announcement:
http://groups.google.com/group/android-qt/msg/77d239196a097f5b
Alpha 0.3 update 1 announcement:
http://groups.google.com/group/android-qt/browse_thread/thread/199000fb8aaaeef7
Installer downloads: http://sourceforge.net/projects/necessitas/files/
NDK development video: http://www.youtube.com/watch?v=DIJQBpPSPB0
Qt App development video: http://labs.qt.nokia.com/2011/02/28/necessitas/

Cheers,

Ray.

p.s. I know Qt's not GTK+ and you've hacked on that in the past, but
don't let that put you off ;-)

mingw android

unread,
Nov 16, 2011, 5:48:09 PM11/16/11
to andro...@googlegroups.com
Re: upstreaming, I've not made a concerted effort really. Some of my
patches are probably a bit intrusive (e.g. fixes for building cross
toolchains on MinGW) and some a bit hacky (gdbserver changes in
particular) and while I'd love to clean them up and submit them, I've
only got so much spare time to hack on this stuff, so tidying up seems
to keep getting pushed to the back of the list. Also, given that I've
now combined Google's NDK with Linaro's version I'm not sure where to
push to...
Reply all
Reply to author
Forward
0 new messages