Subject: bug#63047: Can't load glib debug symbols in gdb

From: Andrew Tropin <[email-masked]>
Date: Mon, 24 Apr 2023 11:29:49 +0400

I try to run emacs in gdb with debug symbols for some libs available, I
succeed with gtk+, but it doesn't work for glib and glibc.  It looks
strange to me, but maybe I am doing something wrong.

Reproducer:

guix shell gdb emacs-next-pgtk glibc:debug gtk+:debug glib:debug \
     --with-debug-info=glibc --with-debug-info=glib --with-debug-info=gtk+ \
     --no-grafts -- gdb .emacs-30.0.50-real

--8<---------------cut here---------------start------------->8---
GNU gdb (GDB) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from .emacs-30.0.50-real...
(No debugging symbols found in .emacs-30.0.50-real)
(gdb) run -q
Starting program: /gnu/store/g59lvzvhbai1dcrbckaw4qvf4amxyfa2-profile/bin/.emacs-30.0.50-real -q
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
[New LWP 14944]
[New LWP 14945]
[New LWP 14946]
Gdk-Message: 11:19:32.820: Unable to load sb_v_double_arrow from the cursor theme
Gdk-Message: 11:19:32.820: Unable to load sb_h_double_arrow from the cursor theme
Gdk-Message: 11:19:32.838: Unable to load hand2 from the cursor theme
Gdk-Message: 11:19:32.838: Unable to load sb_h_double_arrow from the cursor theme
Gdk-Message: 11:19:32.838: Unable to load sb_v_double_arrow from the cursor theme
[New LWP 14947]
[LWP 14947 exited]
[New LWP 14948]
[New LWP 14949]
[LWP 14948 exited]
[LWP 14949 exited]
[New LWP 14950]
[New LWP 14951]
[LWP 14950 exited]
[LWP 14951 exited]
^Z
Thread 1 ".emacs-30.0.50-" received signal SIGTSTP, Stopped (user).
0x00007ffff3def17b in pselect () from /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libc.so.6
(gdb) info dll
From                To                  Syms Read   Shared Object Library
0x00007ffff7fcf050  0x00007ffff7ff15ee  Yes (*)     /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/ld-linux-x86-64.so.2
0x00007ffff769c070  0x00007ffff79e9936  Yes         /gnu/store/whgbkfyggc3ljkh7y9wqwvqgnsnnyf7w-gtk+-3.24.30/lib/libgtk-3.so.0
0x00007ffff7ee6190  0x00007ffff7f5efdd  Yes         /gnu/store/whgbkfyggc3ljkh7y9wqwvqgnsnnyf7w-gtk+-3.24.30/lib/libgdk-3.so.0
0x00007ffff7ea9b20  0x00007ffff7eaf8c0  Yes (*)     /gnu/store/vk23fcm4livzrnb3kzhxs6yjds8f355c-pango-1.48.10/lib/libpangocairo-1.0.so.0
0x00007ffff7e61c80  0x00007ffff7e8711e  Yes (*)     /gnu/store/vk23fcm4livzrnb3kzhxs6yjds8f355c-pango-1.48.10/lib/libpango-1.0.so.0
0x00007ffff751fec0  0x00007ffff75c462e  Yes (*)     /gnu/store/f6ibajh7x233cvr30c2p314l2absk36h-harfbuzz-2.8.2/lib/libharfbuzz.so.0
0x00007ffff7e316b0  0x00007ffff7e3ed44  Yes (*)     /gnu/store/np9pryvn0rxc00cc6g4jd7rlcxwk2mxs-atk-2.36.0/lib/libatk-1.0.so.0
0x00007ffff750d0a0  0x00007ffff750e20d  Yes (*)     /gnu/store/6gq2n65ixpn6drd5wai2h7g5wjm6bp2b-cairo-1.16.0/lib/libcairo-gobject.so.2
0x00007ffff73fc680  0x00007ffff74c3a97  Yes (*)     /gnu/store/6gq2n65ixpn6drd5wai2h7g5wjm6bp2b-cairo-1.16.0/lib/libcairo.so.2
0x00007ffff73c9b50  0x00007ffff73dccde  Yes (*)     /gnu/store/xgiz9rvzvfhwx655lb6jpjx1whc4kjg8-gdk-pixbuf-2.42.4/lib/libgdk_pixbuf-2.0.so.0
0x00007ffff721e980  0x00007ffff73267e6  Yes (*)     /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgio-2.0.so.0
0x00007ffff7191760  0x00007ffff71be826  Yes (*)     /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libgobject-2.0.so.0
0x00007ffff706ed40  0x00007ffff70f4a7e  Yes (*)     /gnu/store/96srhmpmxa20wmsck95g3iq4hb3lz4a0-glib-2.70.2/lib/libglib-2.0.so.0
0x00007ffff6fd5dc0  0x00007ffff7018105  Yes (*)     /gnu/store/343iqv9hvbvzp2in0hs03dvygccrcapl-libtiff-4.3.0/lib/libtiff.so.5
0x00007ffff6f39500  0x00007ffff6f8e0c5  Yes (*)     /gnu/store/g5hf1zhqlcyx9vw3q1xa52bgddaqsfm5-libjpeg-turbo-2.0.5/lib/libjpeg.so.62
0x00007ffff6f05900  0x00007ffff6f2739a  Yes (*)     /gnu/store/p7iq81hxxyk9zy7a9dngbf16zm8d4klx-libpng-1.6.37/lib/libpng16.so.16
0x00007ffff6ee52f0  0x00007ffff6ef5cc4  Yes (*)     /gnu/store/8qv5kb2fgm4c3bf70zcg9l6hkf3qzpw9-zlib-1.2.11/lib/libz.so.1
0x00007ffff6ed9390  0x00007ffff6edd58b  Yes (*)     /gnu/store/4d0ssibbd2glk1vc93zj738awmy22xad-giflib-5.2.1/lib/libgif.so.7
0x00007ffff6e0fcc0  0x00007ffff6e93bd6  Yes (*)     /gnu/store/nfxcjvv9c2q6in9x52kkkayqv38k00ai-alsa-lib-1.2.4/lib/libasound.so.2
0x00007ffff6512070  0x00007ffff6a2df5c  Yes (*)     /gnu/store/0w390zkxhzhkmyp0sns8z97bfmzbr7gz-librsvg-2.50.7/lib/librsvg-2.so.2
0x00007ffff62cc200  0x00007ffff6362d11  Yes (*)     /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libm.so.6
0x00007ffff6dd4370  0x00007ffff6dd8340  Yes (*)     /gnu/store/a38k2v29l6l0iz6pmlk4dmzwdbvl10lq-acl-2.3.1/lib/libacl.so.1
0x00007ffff6dca3f0  0x00007ffff6dcd1b1  Yes (*)     /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/librt.so.1
0x00007ffff626dd20  0x00007ffff62a636a  Yes (*)     /gnu/store/8zigz7afvz2rjrvrh7zq1d389qbl2684-dbus-1.12.20/lib/libdbus-1.so.3
0x00007ffff6122bd0  0x00007ffff62068ce  Yes (*)     /gnu/store/g3y6ifhm0751vgsxv90yipfw6mk189kj-libxml2-2.9.12/lib/libxml2.so.2
0x00007ffff6097cc0  0x00007ffff60d13e8  Yes (*)     /gnu/store/9rrnm5hdjw7cy96a2a9rfgh6y08wsbmf-ncurses-6.2.20210619/lib/libncursesw.so.6
0x00007ffff6052f80  0x00007ffff6071dd1  Yes (*)     /gnu/store/3hmh0srgky1a621rzaxf98qvr0p9r1dv-libselinux-3.4/lib/libselinux.so.1
0x00007ffff5fa79c0  0x00007ffff6018c0d  Yes (*)     /gnu/store/ak70pk2hjks17cx7zjdmdmzpcpiy9gpi-freetype-2.10.4/lib/libfreetype.so.6
0x00007ffff5f577a0  0x00007ffff5f7d05a  Yes (*)     /gnu/store/3r5sl1l02kjxzw3gicjpjz4kw6v4rgs9-fontconfig-minimal-2.13.94/lib/libfontconfig.so.1
0x00007ffff5f38230  0x00007ffff5f49380  Yes (*)     /gnu/store/64ic06l5pd78n7blzikqzfnnp0xp5msd-libotf-0.9.16/lib/libotf.so.1
0x00007ffff5d76940  0x00007ffff5e89670  Yes (*)     /gnu/store/zl9wf0zwq2ka9rpmayp53hnp2mn460xf-gnutls-3.7.2/lib/libgnutls.so.30
0x00007ffff5d22540  0x00007ffff5d2fba1  Yes (*)     /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libpthread.so.0
0x00007ffff5d17200  0x00007ffff5d18301  Yes (*)     /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libanl.so.1
0x00007ffff5cc3280  0x00007ffff5cf9bfa  Yes (*)     /gnu/store/0dhvl2lvb7gsrbjf5jq5pd7hdvznsazz-lcms-2.12/lib/liblcms2.so.2
0x00007ffff5cb2130  0x00007ffff5cb2f31  Yes (*)     /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libdl.so.2
0x00007ffff5c1b830  0x00007ffff5c8537c  Yes (*)     /gnu/store/v3hqc5i1jqi0s04zxvi465bihrgb1sq1-elogind-246.10/lib/libelogind.so.0
0x00007ffff5bfb1f0  0x00007ffff5c02f2b  Yes (*)     /gnu/store/nprljhh7a86351vg6h23va3kfdnkwnd4-jansson-2.13.1/lib/libjansson.so.4
0x00007ffff5b6d440  0x00007ffff5bde0ab  Yes (*)     /gnu/store/fwbiihd2sbhai63y1pvvdh0f2bakfzrf-gmp-6.2.1/lib/libgmp.so.10
0x00007ffff4219c50  0x00007ffff508025e  Yes (*)     /gnu/store/lphzb1z0r4kbb453rsvnw7msrxxzp5r7-libgccjit-10.3.0/lib/libgccjit.so.0
0x00007ffff5b2e8c0  0x00007ffff5b51e83  Yes (*)     /gnu/store/cbviswij2rbqnbsc889166wm7ri5pc2r-tree-sitter-0.20.7/lib/libtree-sitter.so.0
0x00007ffff3ed5ca0  0x00007ffff3fc4c36  Yes (*)     /gnu/store/xmzx5mzv4863yw9kmr2ykndgp37p8if0-sqlite-3.36.0/lib/libsqlite3.so.0
0x00007ffff5b12310  0x00007ffff5b22b1d  Yes (*)     /gnu/store/094bbaq6glba86h1d4cj16xhdi6fk2jl-gcc-10.3.0-lib/lib/libgcc_s.so.1
0x00007ffff3d25330  0x00007ffff3e64389  Yes (*)     /gnu/store/5h2w4qi9hk1qzzgi1w83220ydslinr4s-glibc-2.33/lib/libc.so.6
0x00007ffff5b09100  0x00007ffff5b099ec  Yes (*)     /gnu/store/6h8skg2n4gpbi0bwfmw6qyh03phic6dm-libxinerama-1.1.4/lib/libXinerama.so.1
...
(*): Shared library is missing debugging information.
--8<---------------cut here---------------end--------------->8---

My .gdbinit:
--8<---------------cut here---------------start------------->8---
# Tell GDB where to look for separate debugging files.
guile
(use-modules (gdb))
(execute (string-append "set debug-file-directory "
                        (string-join
                         (if (getenv "GDB_DEBUG_FILE_DIRECTORY")
                             (list (getenv "GDB_DEBUG_FILE_DIRECTORY"))
                             '())
                          ":")))
end

# Authorize extensions found in the store, such as the
# pretty-printers of libstdc++.
set auto-load safe-path /
# /gnu/store/*/lib
set history filename ~/.cache/gdb_history
set history save on
--8<---------------cut here---------------end--------------->8---

-- 
Best regards,
Andrew Tropin