FS#75869 - [rust] cannot debug stdlib source code

Attached to Project: Arch Linux
Opened by Henrique (hdante) - Saturday, 10 September 2022, 18:20 GMT
Last edited by Buggy McBugFace (bugbot) - Saturday, 25 November 2023, 20:25 GMT
Task Type Feature Request
Category Packages: Extra
Status Closed
Assigned To Jan Alexander Steffens (heftig)
Johannes Löthberg (demize)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description: Hello, please provide the source code for the rust standard library in the package, so that it's possible to debug programs. Currently, it's not possible to debug any code because stepping in gdb results on it trying to step somewhere in stdlib code.


Additional info:
* package version(s)
rust 1:1.63.0-1

* config and/or log files etc.
* link to upstream bug report, if any

Steps to reproduce:
Example debugging session:
$ rust-gdb target/debug/tictactoe
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-pc-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 target/debug/tictactoe...
(gdb) break main
Breakpoint 1 at 0x30ee7: main. (2 locations)
(gdb) bt
No stack.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y <MULTIPLE>
1.1 y 0x0000000000030ee7 in tictactoe::main at src/main.rs:24
1.2 y 0x00000000000310b0 <main>
(gdb) run
Starting program: /home/hdante/backupbackup/clean/Code/tictactoe/tokio/tictactoe/target/debug/tictactoe

This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.archlinux.org
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Breakpoint 1, 0x00005555555850b0 in main ()
(gdb) step
Single stepping until exit from function main,
which has no line number information.
std::rt::lang_start<std::process::ExitCode> (main=0x555555584ee0 <tictactoe::main>, argc=1, argv=0x7fffffffe548) at /rustc/1.63.0/library/std/src/rt.rs:145
145 /rustc/1.63.0/library/std/src/rt.rs: Directory not empty.
(gdb)
144 in /rustc/1.63.0/library/std/src/rt.rs
(gdb)
std::rt::lang_start_internal (main=..., argc=1, argv=0x7fffffffe548) at library/std/src/rt.rs:127
127 library/std/src/rt.rs: No such file or directory.
(gdb)
std::panic::catch_unwind<std::rt::lang_start_internal::{closure_env#1}, ()> (f=...)
at library/std/src/panic.rs:137
137 library/std/src/panic.rs: Directory not empty.
(gdb)
std::panicking::try<(), std::rt::lang_start_internal::{closure_env#1}> (f=...)
at library/std/src/panicking.rs:456
456 library/std/src/panicking.rs: Directory not empty.
(gdb)
std::panicking::try::do_call<std::rt::lang_start_internal::{closure_env#1}, ()> (
data=<optimized out>) at library/std/src/panicking.rs:492
492 in library/std/src/panicking.rs
(gdb)
std::rt::lang_start_internal::{closure#1} () at library/std/src/rt.rs:127
127 library/std/src/rt.rs: No such file or directory.
(gdb)
std::rt::init (argc=<optimized out>, argv=<optimized out>) at library/std/src/rt.rs:78
78 in library/std/src/rt.rs
(gdb)
std::sys::unix::init (argc=<optimized out>, argv=<optimized out>)
at library/std/src/sys/unix/mod.rs:56
56 library/std/src/sys/unix/mod.rs: Directory not empty.
(gdb)
std::sys::unix::init::sanitize_standard_fds () at library/std/src/sys/unix/mod.rs:95
95 in library/std/src/sys/unix/mod.rs
(gdb)
101 in library/std/src/sys/unix/mod.rs
(gdb)
__GI___poll (fds=0x7fffffffe310, nfds=3, timeout=0) at ../sysdeps/unix/sysv/linux/poll.c:27
Downloading 0.00 MB source file /usr/src/debug/glibc/io/../sysdeps/unix/sysv/linux/poll.c
27 {
(gdb)
29 return SYSCALL_CANCEL (poll, fds, nfds, timeout);
(gdb)
std::sys::unix::init::sanitize_standard_fds () at library/std/src/sys/unix/mod.rs:113
113 library/std/src/sys/unix/mod.rs: No such file or directory.
(gdb)
std::sys::unix::init (argc=<optimized out>, argv=<optimized out>) at library/std/src/sys/unix/mod.rs:65
65 in library/std/src/sys/unix/mod.rs
(gdb)
std::sys::unix::init::reset_sigpipe () at library/std/src/sys/unix/mod.rs:155
155 in library/std/src/sys/unix/mod.rs
(gdb)
__bsd_signal (sig=13, handler=0x1) at ../sysdeps/posix/signal.c:30
Downloading 0.00 MB source file /usr/src/debug/glibc/signal/../sysdeps/posix/signal.c
30 {
(gdb)
34 if (handler == SIG_ERR || sig < 1 || sig >= NSIG
(gdb)
35 || is_internal_signal (sig))
(gdb)
is_internal_signal (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/internal-signals.h:53
53 ../sysdeps/unix/sysv/linux/internal-signals.h: Directory not empty.
(gdb)
43 __sigaddset (&act.sa_mask, sig);
(gdb)
__sigaddset (sig=<optimized out>, set=<optimized out>) at ../sysdeps/posix/signal.c:41
41 act.sa_handler = handler;
(gdb)
102 ../sysdeps/unix/sysv/linux/sigsetops.h: Directory not empty.
(gdb) f
#0 __bsd_signal (sig=13, handler=0x1) at ../sysdeps/unix/sysv/linux/sigsetops.h:102
102 in ../sysdeps/unix/sysv/linux/sigsetops.h
(gdb)
#0 __bsd_signal (sig=13, handler=0x1) at ../sysdeps/unix/sysv/linux/sigsetops.h:102
102 in ../sysdeps/unix/sysv/linux/sigsetops.h
(gdb)
#0 __bsd_signal (sig=13, handler=0x1) at ../sysdeps/unix/sysv/linux/sigsetops.h:102
102 in ../sysdeps/unix/sysv/linux/sigsetops.h
(gdb)
#0 __bsd_signal (sig=13, handler=0x1) at ../sysdeps/unix/sysv/linux/sigsetops.h:102
102 in ../sysdeps/unix/sysv/linux/sigsetops.h
(gdb) finish
Run till exit from #0 __bsd_signal (sig=13, handler=0x1)
at ../sysdeps/unix/sysv/linux/sigsetops.h:102
0x00005555556a1fc8 in std::sys::unix::init::reset_sigpipe () at library/std/src/sys/unix/mod.rs:155
155 library/std/src/sys/unix/mod.rs: No such file or directory.
Value returned is $1 = (*mut fn (int)) 0x0
(gdb)
Run till exit from #0 0x00005555556a1fc8 in std::sys::unix::init::reset_sigpipe ()
at library/std/src/sys/unix/mod.rs:155
std::sys::unix::init (argc=<optimized out>, argv=<optimized out>) at library/std/src/sys/unix/mod.rs:67
67 in library/std/src/sys/unix/mod.rs
(gdb)
Run till exit from #0 std::sys::unix::init (argc=<optimized out>, argv=<optimized out>)
at library/std/src/sys/unix/mod.rs:67
std::rt::init (argc=<optimized out>, argv=<optimized out>) at library/std/src/rt.rs:80
80 library/std/src/rt.rs: No such file or directory.
(gdb)
Run till exit from #0 std::rt::init (argc=<optimized out>, argv=<optimized out>)
at library/std/src/rt.rs:80
std::rt::lang_start_internal (main=..., argc=<optimized out>, argv=<optimized out>) at library/std/src/rt.rs:128
128 in library/std/src/rt.rs
(gdb)
Run till exit from #0 std::rt::lang_start_internal (main=..., argc=<optimized out>,
argv=<optimized out>) at library/std/src/rt.rs:128

Breakpoint 1, tictactoe::main () at src/main.rs:24
24 ExitCode::SUCCESS
(gdb) step
9 async fn main() -> ExitCode {
(gdb)
core::future::from_generator<tictactoe::main::{async_block_env#0}> (gen=...) at /rustc/1.63.0/library/core/src/future/mod.rs:98
98 /rustc/1.63.0/library/core/src/future/mod.rs: Directory not empty.
(gdb)
[New Thread 0x7ffff7c956c0 (LWP 5428)]
[New Thread 0x7fffeffff6c0 (LWP 5429)]
[New Thread 0x7ffff7a946c0 (LWP 5430)]
[New Thread 0x7ffff78936c0 (LWP 5431)]
[New Thread 0x7ffff76926c0 (LWP 5432)]
[New Thread 0x7ffff74916c0 (LWP 5433)]
[New Thread 0x7ffff72906c0 (LWP 5434)]
[New Thread 0x7ffff708f6c0 (LWP 5435)]

^C
Thread 1 "tictactoe" received signal SIGINT, Interrupt.
syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
38 cmpq $-4095, %rax /* Check %rax for error. */
This task depends upon

Closed by  Buggy McBugFace (bugbot)
Saturday, 25 November 2023, 20:25 GMT
Reason for closing:  Moved
Additional comments about closing:  https://gitlab.archlinux.org/archlinux/p ackaging/packages/rust/issues/1
Comment by Toolybird (Toolybird) - Sunday, 11 September 2022, 00:42 GMT
> please provide the source code for the rust standard library

$ pacman -Si rust-src | grep Description
Description : Source code for the Rust standard library

I'm no Rustacean but does installing that help?
Comment by Henrique (hdante) - Sunday, 11 September 2022, 19:32 GMT
Hello, I already had it installed and didn't know it. The problem seems to be that the binary and source packages do not talk with each other. I can see that gdb tries to look for the source at /rustc/, so maybe there could be a fix for the binary package ?

Meanwhile, I'll try to work around the problem with symbolic links. I'll post a reply after I test it.
Comment by Henrique (hdante) - Monday, 12 September 2022, 13:50 GMT
Hello, I created the directory /rustc and the symbolic link /rustc/1.63.0 pointing to /usr/lib/rustlib/src/rust/ and debugging with the standard library is now working. I'm still not fully able to debug my example code, but the problem seems to be elsewhere, in the coroutine functionality part, so that's not related to the packaging.

Conclusion: I think the binary rust package (rust) should not be linked to the /rustc/1.63.0 directory. If it assumed that the source were at /usr/lib/rustlib/src/rust, debugging would work out of the box.
Comment by Henrique (hdante) - Tuesday, 27 September 2022, 20:05 GMT
Hello, any updates about this bug ?
Comment by Toolybird (Toolybird) - Friday, 30 September 2022, 01:16 GMT
Again, I'm still no Rustacean, but reading the wiki [1] it says you should be using Rustup "if you intend to program anything in Rust". Have you installed "Rust" or "Rustup"?

[1] https://wiki.archlinux.org/title/Rust#Installation
Comment by Henrique (hdante) - Friday, 30 September 2022, 01:59 GMT
Hello, I've installed rust, not rustup. rustup, however is a package manager, it's not required for rust and does the equivalent of pacman and is redundant in an Arch Linux system. So the conclusion is incorrect, rustup is not necessary for using rust, only the rust package is.
Comment by Toolybird (Toolybird) - Friday, 30 September 2022, 02:45 GMT
The wiki is pretty clear about rust development. I still feel you're doing it wrong. But I will reluctantly assign to rust PM's who can hopefully shed some light on the presence of a packaging bug or not.
Comment by Henrique (hdante) - Friday, 30 September 2022, 04:41 GMT
The wiki gives recommendations about package usage. I don't know if the wiki is authoritative about the package rules or if it's just the personal opinion of the wiki editors, without any implication to the package users. I also don't know what are the implications for the bug reports in the case the recommendations are not followed. In this case I'm not following the recommendation: I'm using the rust package to develop programs. If the package contains a compiler (/usr/bin/rustc), a build tool (/usr/bin/cargo), 2 debugger front-ends (/usr/bin/rust-gdb and /usr/bin/rust-lldb) and a set of helper debug scripts, should the bug report be open for the non-recommended scenario ? You seem to be considering the answers to be 1) the wiki is authoritative and 2) non-recommended usage bugs are not packaging bugs. On the other hand I'm currently considering that 1) the wiki is not authoritative and 2) non-recommended usage bugs are still packaging bugs (because the package's contents are in contradiction to the recommended usage in the wiki).

In any case: I'm already planning to replace the rust package by the rustup package. Even if I don't, both the bug and workaround is confirmed: the problem is the hardcoded path difference between the rust package (/rustc/1.63.0) and the rust-src package (/usr/lib/rustlib/src/rust). The workaround is trivial, create a symbolic link from one to the other. I'm currently able to develop and debug with gdb with only the rust and rust-src packages, plus this workaround (without the rustup package). The package fix should also be trivial (hardcode the same path in both packages, possibly changing the build location). So regardless of my usage, the package may still be fixed.

A last option is also to delete the debugger scripts from the rust package. In this case, the authoritative split would be coherent with packaging. In this case this bug report may be ignored, but the package would also need to be changed anyway.
Comment by Jan Alexander Steffens (heftig) - Friday, 30 September 2022, 14:03 GMT
I'm not sure why you think this is in any way a trivial fix. We provide neither directory to the build. They're both calculated somewhere in Rust's bootstrap code.

Loading...