Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 917287 - FEATURES=splitdebug should follow usrmerge symlinks in /usr/lib/debug/
Summary: FEATURES=splitdebug should follow usrmerge symlinks in /usr/lib/debug/
Status: UNCONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - External Interaction (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: usrmerge, usrmerge-fixes
  Show dependency tree
 
Reported: 2023-11-13 09:45 UTC by Maxim Britov
Modified: 2024-03-23 19:54 UTC (History)
6 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
gdb: Don't use realpath on objfile names (gdb_Dont_use_realpath_on_objfile_names.patch,5.83 KB, patch)
2024-03-17 18:10 UTC, Zac Medico
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maxim Britov 2023-11-13 09:45:41 UTC
For now FEATURE=splitdebug creating old style split bin, sbin, usr/bin, usr/sbin in /usr/lib/debug/

tree -d -n /usr/lib/debug/
/usr/lib/debug/
├── lib64
├── sbin
└── usr
    ├── bin
    ├── lib64
    └── sbin

This confuses tools like gdb/valgrind, etc.

For example gdb /usr/[s]bin/squid can't find symbols.
I have to copy /usr/lib/debug/usr/sbin/squid.debug into /usr/lib/debug/usr/bin/
Then gdb /usr/[s]bin/squid load debug symbols.

Reproducible: Always
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-11-13 09:49:53 UTC
This came up on the gdb side at https://sourceware.org/bugzilla/show_bug.cgi?id=24143 too...
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-11-13 10:22:03 UTC
Could you consider filing a bug for Valgrind upstream if there isn't one already, and possibly elfutils if it also suffers from the same problem?

Thank you.
Comment 3 Matt Whitlock 2023-11-13 19:13:27 UTC
What if you create the same symlinks beneath /usr/lib/debug as exist within the top level? Then the package manager will install the split debug files in /usr/lib/debug/usr/bin regardless of whether they were split from binaries intending to be installed in /bin, /sbin, /usr/bin, or /usr/sbin, and debug tools should then find them regardless of whether they're implementing the original or patched lookup behavior.
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-11-13 20:12:19 UTC
That sounds like a good idea. Could I tempt one of you to have a go at implementing it? I'm swamped at the moment.
Comment 5 Matt Whitlock 2023-11-13 20:39:47 UTC
Seems to work...


$ /sbin/fdisk --version
fdisk from util-linux 2.39.2

$ readlink -e /sbin/fdisk
/usr/bin/fdisk

$ readlink -e /usr/lib/debug/sbin/fdisk.debug
/usr/lib/debug/sbin/fdisk.debug

$ gdb /sbin/fdisk </dev/null | tail -n3 | head -n2
Reading symbols from /sbin/fdisk...
(No debugging symbols found in /sbin/fdisk)

$ gdb /usr/bin/fdisk </dev/null | tail -n3 | head -n2
Reading symbols from /usr/bin/fdisk...
(No debugging symbols found in /usr/bin/fdisk)


# cd /usr/lib/debug
# mv --no-clobber {{,s}bin,usr/sbin}/* usr/bin/
# rmdir {,s}bin usr/sbin
# for each in {,s}bin usr/sbin ; do ln -rsfnv usr/bin "${each}" ; done
'bin' -> 'usr/bin'
'sbin' -> 'usr/bin'
'usr/sbin' -> 'bin'


$ readlink -e /usr/lib/debug/sbin/fdisk.debug
/usr/lib/debug/usr/bin/fdisk.debug

$ gdb /sbin/fdisk </dev/null | tail -n3 | head -n2
Reading symbols from /sbin/fdisk...
Reading symbols from /usr/lib/debug//usr/bin/fdisk.debug...

$ gdb /usr/bin/fdisk </dev/null | tail -n3 | head -n2
Reading symbols from /usr/bin/fdisk...
Reading symbols from /usr/lib/debug//usr/bin/fdisk.debug...
Comment 6 Zac Medico gentoo-dev 2024-03-17 18:10:43 UTC
Created attachment 887847 [details, diff]
gdb: Don't use realpath on objfile names

This gdb patch still applies cleanly, mentioned in https://sourceware.org/bugzilla/show_bug.cgi?id=24143#c5 and downloaded from  https://sourceware.org/pipermail/gdb-patches/2022-April/187545.html.
Comment 7 Zac Medico gentoo-dev 2024-03-18 03:05:39 UTC
(In reply to Zac Medico from comment #6)
> Created attachment 887847 [details, diff] [details, diff]
> gdb: Don't use realpath on objfile names
> 
> This gdb patch still applies cleanly, mentioned in
> https://sourceware.org/bugzilla/show_bug.cgi?id=24143#c5 and downloaded from
> https://sourceware.org/pipermail/gdb-patches/2022-April/187545.html.

I applied this patch to dev-debug/gdb-14.1-r1 and it appears to correctly resolve /usr/lib/debug/sbin/fdisk.debug regardless of how I refer to fdisk:

> $ gdb /sbin/fdisk </dev/null | tail -n4 | head -n2
> Reading symbols from /sbin/fdisk...
> Reading symbols from /usr/lib/debug/sbin/fdisk.debug...
> $ gdb /bin/fdisk </dev/null | tail -n4 | head -n2
> Reading symbols from /bin/fdisk...
> Reading symbols from /usr/lib/debug/sbin/fdisk.debug...
> $ gdb /usr/bin/fdisk </dev/null | tail -n4 | head -n2
> Reading symbols from /usr/bin/fdisk...
> Reading symbols from /usr/lib/debug/sbin/fdisk.debug...
> $ gdb /usr/sbin/fdisk </dev/null | tail -n4 | head -n2
> Reading symbols from /usr/sbin/fdisk...
> Reading symbols from /usr/lib/debug/sbin/fdisk.debug...
Comment 8 Zac Medico gentoo-dev 2024-03-18 03:21:43 UTC
Comment on attachment 887847 [details, diff]
gdb: Don't use realpath on objfile names

Actually dev-debug/gdb-14.1-r1 without this patch also resolves /usr/lib/debug/sbin/fdisk.debug for me correctly for all the same cases shown in comment #7.
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-18 08:35:12 UTC
I think I last tried w/ gdb-14.1 (14.2 has very few changes on top) but even that patch didn't seem to help me.. interesting!