Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
splitdebug not working due to path issue
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
flexibeast
Guru
Guru


Joined: 04 Apr 2022
Posts: 449
Location: Naarm/Melbourne, Australia

PostPosted: Sun Nov 10, 2024 8:34 am    Post subject: splitdebug not working due to path issue Reply with quote

Hi all,

Not sure if this is a bug, or (more likely) some sort of PEBKAC issue.

i'm again wanting to step through some s6 code. So, with the env files described on the "Debugging" wiki page, i enabled them on sys-apps/s6, and rebuilt the package.

* The relevant debug files are indeed created in /usr/lib/debug/ (e.g. /usr/lib/debug/bin/s6-notifyoncheck.debug).

* The binary indeed has a debug link:

Code:
$ readelf --string-dump=.gnu_debuglink /bin/s6-notifyoncheck

String dump of section '.gnu_debuglink':
  [     0]  s6-notifyoncheck.debug
  [    1a]  X^I


* There are two actually two paths to the s6-notifyoncheck binary, with the same inode:

Code:
$ ls -i /bin/s6-notifyoncheck
3154773 /bin/s6-notifyoncheck*
$ ls -i /usr/bin/s6-notifyoncheck
3154773 /usr/bin/s6-notifyoncheck*


* But:

Code:
$ $ gdb /bin/s6-notifyoncheck
[snip]
Reading symbols from /bin/s6-notifyoncheck...
(No debugging symbols found in /bin/s6-notifyoncheck)
(gdb) set debug separate-debug-file on
(gdb) file /bin/s6-notifyoncheck
Reading symbols from /bin/s6-notifyoncheck...

Looking for separate debug info (debug link) for /usr/bin/s6-notifyoncheck
  Trying /usr/bin/s6-notifyoncheck.debug... no, unable to open.
  Trying /usr/bin/.debug/s6-notifyoncheck.debug... no, unable to open.
  Trying /usr/lib/debug//usr/bin/s6-notifyoncheck.debug... no, unable to open.
(No debugging symbols found in /bin/s6-notifyoncheck)

because indeed, the path to s6-notifyoncheck.debug doesn't have 'usr' in it.

Not sure if this is related to me being on a (default/linux/amd64/23.0) merged-usr system. Full `emerge --info` output.
_________________
https://wiki.gentoo.org/wiki/User:Flexibeast
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1699
Location: South America

PostPosted: Sun Nov 10, 2024 1:06 pm    Post subject: Re: splitdebug not working due to path issue Reply with quote

flexibeast wrote:
Not sure if this is related to me being on a (default/linux/amd64/23.0) merged-usr system. Full `emerge --info` output.

I'm quite sure it is. I guess /usr-merged filesystems also need /usr/lib/debug/bin -> /usr/lib/debug/usr/bin and the other symlinks... :P

It looks like pathnames of split debug information are somehow derived from the pathnames constructed by the build system for installation, regardless of where files actually end up because of symlinks.

Does 'reverse symlinking' /usr/lib/debug/usr/bin -> /usr/lib/debug/bin make GDB work?

On the other hand, out of curiosity, what do you want to debug in s6-notifyoncheck?
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1961

PostPosted: Sun Nov 10, 2024 3:11 pm    Post subject: Reply with quote

See bug 917287. There's a workaround in there (run merge-usr with --prefix=).
Back to top
View user's profile Send private message
flexibeast
Guru
Guru


Joined: 04 Apr 2022
Posts: 449
Location: Naarm/Melbourne, Australia

PostPosted: Sun Nov 10, 2024 10:44 pm    Post subject: Re: splitdebug not working due to path issue Reply with quote

GDH-gentoo wrote:
what do you want to debug in s6-notifyoncheck?

i'm putting together an Emacs service. The servicedir, ~/s6/emacs/, has a file, notification-fd, containing only the value '3'. If, with that servicedir as my current working directory, i do:

Code:
$ s6-notifyoncheck emacs --fg-daemon

i get:

Code:
s6-notifyoncheck: fatal: notification-fd sanity check failed: Bad file descriptor

which comes from this part of s6-notifyoncheck.c:

Code:
if (autodetect)
{
  int r = read_uint("notification-fd", &fd) ;
  if (r < 0) strerr_diefu2sys(111, "read ", "./notification-fd") ;
  if (!r) strerr_dief2x(100, "invalid ", "./notification-fd") ;
}
if (fcntl(fd, F_GETFD) < 0)
  strerr_dief2sys(111, "notification-fd", " sanity check failed") ;

i want to know the actual value pointed to by the `fd` variable, which i'd expect to be 3.
_________________
https://wiki.gentoo.org/wiki/User:Flexibeast
Back to top
View user's profile Send private message
flexibeast
Guru
Guru


Joined: 04 Apr 2022
Posts: 449
Location: Naarm/Melbourne, Australia

PostPosted: Sun Nov 10, 2024 10:50 pm    Post subject: Reply with quote

sam_ wrote:
See bug 917287. There's a workaround in there (run merge-usr with --prefix=).

Thanks! However:

Code:
# merge-usr --prefix /usr/lib/debug/
INFO: Migrating files from '/usr/lib/debug/bin' to '/usr/lib/debug/usr/bin'
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.12/merge-usr", line 183, in link_or_copy_file
    os.link(src, tmp, follow_symlinks=False)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/debug/bin/s6-svok.debug' -> '/usr/lib/debug/usr/bin/tmpr5vtyghr'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.12/merge-usr", line 308, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python-exec/python3.12/merge-usr", line 303, in main
    if not mu.run():
           ^^^^^^^^
  File "/usr/lib/python-exec/python3.12/merge-usr", line 257, in run
    self.copy_tree(src, dst)
  File "/usr/lib/python-exec/python3.12/merge-usr", line 225, in copy_tree
    self.link_or_copy_file(src, dst)
  File "/usr/lib/python-exec/python3.12/merge-usr", line 187, in link_or_copy_file
    shutil.copy2(src, tmp, follow_symlinks=False)
  File "/usr/lib/python3.12/shutil.py", line 475, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.12/shutil.py", line 262, in copyfile
    with open(dst, 'wb') as fdst:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/debug/usr/bin/tmpr5vtyghr'

i presume i'm holding it wrong?
_________________
https://wiki.gentoo.org/wiki/User:Flexibeast
Back to top
View user's profile Send private message
GDH-gentoo
Veteran
Veteran


Joined: 20 Jul 2019
Posts: 1699
Location: South America

PostPosted: Sun Nov 10, 2024 11:39 pm    Post subject: Re: splitdebug not working due to path issue Reply with quote

flexibeast wrote:
If, with that servicedir as my current working directory, i do:

Code:
$ s6-notifyoncheck emacs --fg-daemon

i get:

Code:
s6-notifyoncheck: fatal: notification-fd sanity check failed: Bad file descriptor

You mean that you ran s6-notifyoncheck from a shell? If yes, that is not going to work, it needs to inherit the writing end of the readiness notification pipe from s6-supervise, and the number read from the notification-fd file has to match its file descriptor. Therefore, it only makes sense to call s6-notifyoncheck from the run script in the service directory (or s6-rc longrun definition directory).

flexibeast wrote:
i want to know the actual value pointed to by the `fd` variable, which i'd expect to be 3.

It likely is the number 3, but it won't match a file descriptor :wink:
_________________
NeddySeagoon wrote:
I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:
As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Back to top
View user's profile Send private message
floppymaster
Developer
Developer


Joined: 07 Jul 2010
Posts: 231
Location: Detroit, MI, USA

PostPosted: Mon Nov 11, 2024 1:24 am    Post subject: Reply with quote

flexibeast wrote:
sam_ wrote:
See bug 917287. There's a workaround in there (run merge-usr with --prefix=).

Thanks! However:

Code:
# merge-usr --prefix /usr/lib/debug/
INFO: Migrating files from '/usr/lib/debug/bin' to '/usr/lib/debug/usr/bin'
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.12/merge-usr", line 183, in link_or_copy_file
    os.link(src, tmp, follow_symlinks=False)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/debug/bin/s6-svok.debug' -> '/usr/lib/debug/usr/bin/tmpr5vtyghr'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.12/merge-usr", line 308, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib/python-exec/python3.12/merge-usr", line 303, in main
    if not mu.run():
           ^^^^^^^^
  File "/usr/lib/python-exec/python3.12/merge-usr", line 257, in run
    self.copy_tree(src, dst)
  File "/usr/lib/python-exec/python3.12/merge-usr", line 225, in copy_tree
    self.link_or_copy_file(src, dst)
  File "/usr/lib/python-exec/python3.12/merge-usr", line 187, in link_or_copy_file
    shutil.copy2(src, tmp, follow_symlinks=False)
  File "/usr/lib/python3.12/shutil.py", line 475, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.12/shutil.py", line 262, in copyfile
    with open(dst, 'wb') as fdst:
         ^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/debug/usr/bin/tmpr5vtyghr'

i presume i'm holding it wrong?


I think merge-usr assumes that /usr/lib/debug/usr/bin already exists. Try creating an empty directory there if one does not exist already.
Back to top
View user's profile Send private message
flexibeast
Guru
Guru


Joined: 04 Apr 2022
Posts: 449
Location: Naarm/Melbourne, Australia

PostPosted: Mon Nov 11, 2024 2:49 am    Post subject: Reply with quote

floppymaster wrote:
I think merge-usr assumes that /usr/lib/debug/usr/bin already exists. Try creating an empty directory there if one does not exist already.

Yep, that worked, thanks! i also had to create /usr/lib/debug/usr/lib64/ before merge-usr returned successfully.

@sam_:

Is this something that should be noted in either bug 917287, or in a new bug, or in an addition to the "Debugging" page on the wiki?
_________________
https://wiki.gentoo.org/wiki/User:Flexibeast
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum