[gmx-developers] stepping through libgromacs
Eric Irrgang
ericirrgang at gmail.com
Mon Feb 27 20:45:23 CET 2017
Hello Gromacs code enthusiasts,
Michael suggested I share some observations made while trying to step
through Gromacs with GDB in case they warrant further attention or are
useful to others, though none are particularly Gromacs-specific.
I was building Gromacs master to step through with a debugger. Problematic
environments were
* OS X 10.12 Sierra with gdb the 7.11, 7.12, and various compilers
* various Debian/Ubuntu based Docker containers running in the Mac OS
host, gdb 7.11, 7.12, gcc 4.9, various gcc 5 and 6.
* various Linux VMs running in VirtualBox on the Mac host
I had similar symptoms in each case, but the causes turn out to be
different.
OS X 10.12 changed something about the way dynamic linking works, and it
appears that gdb does not know how to find the source code and debugging
symbols after execution passes into a shared library, so it is hard to step
into functions called by, say, gmx, or to set break points.
https://sourceware.org/bugzilla/show_bug.cgi?id=20981
However, the Xcode IDE seems to be fine if cmake is first run with
appropriate options.
By default, a Docker container does not have sufficient access to the
memory to keep track of what function it is in after crossing into the
shared library, but this is overcome by running the Docker container with
``--security-opt seccomp=unconfined``
https://forums.docker.com/t/gdb-breakpoints-dont-work-error-disabling-address-space-randomization/14365/2
VirtualBox has similar problems if you are optimistic enough to try running
Docker and VirtualBox at the same time, but you shouldn't.
https://www.virtualbox.org/manual/ch10.html#hwvirt
With some compilers I had better results from gdb with different debug
compiler flags. The CMAKE_BUILD_TYPE=Debug only gave me a '-g'. The most
universally successful cmake options were
-DCMAKE_CXX_FLAGS_DEBUG='-O0 -g3' -DCMAKE_C_FLAGS_DEBUG='-O0 -g3'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.sys.kth.se/pipermail/gromacs.org_gmx-developers/attachments/20170227/32316051/attachment.html>
More information about the gromacs.org_gmx-developers
mailing list