The --enable-libstdcxx-debug option builds extra versions of libstdc++ without optimisation and installs them in $libdir/debug, which can be used via RPATH or LD_LIBRARY_PATH. However, there's no gdb.py installed alongside those debug versions of the libs, so while you can step into unoptimised libstdc++ code in GDB, you can't use the pretty printers.
This patch installs a symlink in $libdir/debug pointing to the gdb.py file in the parent dir, and adjusts the gdb.py file to handle the $libdir/debug case. This seems to work. An alternative would be to install a modified copy of the gdb.py file specific to that directory, instead of a symlink to a file that works for either case. Better ideas are welcome.
commit b4c640fed872eba973b6ca29326856b5a3101c39 Author: Jonathan Wakely <jwak...@redhat.com> Date: Thu Jun 22 16:14:24 2017 +0100 possible fix diff --git a/libstdc++-v3/python/Makefile.am b/libstdc++-v3/python/Makefile.am index 80790e2..6090ffe 100644 --- a/libstdc++-v3/python/Makefile.am +++ b/libstdc++-v3/python/Makefile.am @@ -29,6 +29,12 @@ else pythondir = $(datadir)/gcc-$(gcc_version)/python endif +if GLIBCXX_BUILD_DEBUG +LINK_DEBUG = -$(LN_S) ../$$libname-gdb.py $(DESTDIR)$(toolexeclibdir)/debug/ +else +LINK_DEBUG = +endif + all-local: gdb.py nobase_python_DATA = \ @@ -62,3 +68,5 @@ install-data-local: gdb.py cd $$here; \ echo " $(INSTALL_DATA) gdb.py $(DESTDIR)$(toolexeclibdir)/$$libname-gdb.py"; \ $(INSTALL_DATA) gdb.py $(DESTDIR)$(toolexeclibdir)/$$libname-gdb.py + $(LINK_DEBUG) + diff --git a/libstdc++-v3/python/hook.in b/libstdc++-v3/python/hook.in index b82604a6c..7701415 100644 --- a/libstdc++-v3/python/hook.in +++ b/libstdc++-v3/python/hook.in @@ -50,6 +50,8 @@ if gdb.current_objfile () is not None: dotdots = ('..' + os.sep) * len (libdir.split (os.sep)) objfile = gdb.current_objfile ().filename + if str (os.path.dirname (objfile)).endswith (libdir + os.sep + "debug"): + dotdots = dotdots + ('..' + os.sep) dir_ = os.path.join (os.path.dirname (objfile), dotdots, pythondir) if not dir_ in sys.path: