Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust-gdb doesn't set up path substitutions? #62945

Closed
lnicola opened this issue Jul 24, 2019 · 5 comments · Fixed by #109527
Closed

rust-gdb doesn't set up path substitutions? #62945

lnicola opened this issue Jul 24, 2019 · 5 comments · Fixed by #109527
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lnicola
Copy link
Member

lnicola commented Jul 24, 2019

I'm trying to use rust-gdb on project generated by cargo new and looks like the rust-src source code path is not configured:

Reading symbols from target/debug/hello...
(gdb) show directories
Source directories searched: ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/etc:$cdir:$cwd
(gdb) r
Starting program: target/debug/hello 

Program received signal SIGSEGV, Segmentation fault.
core::ops::function::FnOnce::call_once{{vtable-shim}} () at /rustc/a7f28678bbf4e16893bb6a718e427504167a9494/src/libcore/ops/function.rs:231
231	/rustc/a7f28678bbf4e16893bb6a718e427504167a9494/src/libcore/ops/function.rs: No such file or directory.
(gdb) set substitute-path /rustc/a7f28678bbf4e16893bb6a718e427504167a9494/ ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/
(gdb) l
226	    #[stable(feature = "fn_once_output", since = "1.12.0")]
227	    type Output;
228	
229	    /// Performs the call operation.
230	    #[unstable(feature = "fn_traits", issue = "29625")]
231	    extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
232	}
233	
234	mod impls {
235	    #[stable(feature = "rust1", since = "1.0.0")] 
@Centril Centril added A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 25, 2019
@wesleywiser wesleywiser added P-low Low priority E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Nov 21, 2022
@wesleywiser
Copy link
Member

Visited during wg-debugging's triage meeting. We think this is most likely still an issue but probably not a high priority one. If someone wants to work on this, the first thing they should do is retest and verify this is still broken (but we think it most likely is).

There may be a fairly simple resolution to modify rust-gdb to detect which toolchain it's being invoked from and then run the set substitute-path path with the appropriate paths.

I'm willing to help mentor someone in fixing this 🙂

@diogofriggo
Copy link

Hi, I'm looking for a first issue, would love the mentoring!

@diogofriggo
Copy link

diogofriggo commented Mar 22, 2023

can't reproduce it, it works just fine nearly 4 yrs later, has this perhaps already been fixed @wesleywiser, @lnicola @Centril ?

@lnicola
Copy link
Member Author

lnicola commented Mar 22, 2023

Past @lnicola should have included a sample test case.

@lnicola
Copy link
Member Author

lnicola commented Mar 23, 2023

No, I can still reproduce it. @diogofriggo are you maybe using a distro-packaged toolchain?

Crashing program:

use std::sync::Once;

static INIT: Once = Once::new();

fn main() {
    INIT.call_once(|| unsafe {
        *(0xaabbccdd as *mut usize) = 1234;
    });
}

gdb output:

Program received signal SIGSEGV, Segmentation fault.
0x0000555555568e15 in hello::expensive_computation () at src/main.rs:23
23	       *(0xaabbccdd as *mut usize) = 1234;
(gdb) bt
#0  0x0000555555568e15 in hello::expensive_computation () at src/main.rs:23
#1  0x0000555555568dc6 in hello::get_cached_val::{closure#0} () at src/main.rs:15
#2  0x0000555555568db1 in std::sync::once::{impl#2}::call_once::{closure#0}<hello::get_cached_val::{closure_env#0}> ()
    at /rustc/b955c8271da80a1af8a1d54c4e1bbdaf51b032e9/library/std/src/sync/once.rs:149
#3  0x0000555555568b77 in std::sys_common::once::futex::Once::call<std::sync::once::{impl#2}::call_once::{closure_env#0}<hello::get_cached_val::{closure_env#0}>> (
    self=0x5555555a5340 <hello::INIT::h9c84dac174d4d2e5>, ignore_poisoning=false, f=0x7fffffffdb28)
    at /rustc/b955c8271da80a1af8a1d54c4e1bbdaf51b032e9/library/std/src/sys_common/once/futex.rs:124
#4  0x0000555555568d16 in std::sync::once::Once::call_once<hello::get_cached_val::{closure_env#0}> (self=0x5555555a5340 <hello::INIT::h9c84dac174d4d2e5>, f=...)
    at /rustc/b955c8271da80a1af8a1d54c4e1bbdaf51b032e9/library/std/src/sync/once.rs:149
#5  0x0000555555568e04 in hello::get_cached_val () at src/main.rs:14
#6  0x0000555555568e36 in hello::main () at src/main.rs:29
(gdb) f 2
#2  0x0000555555568db1 in std::sync::once::{impl#2}::call_once::{closure#0}<hello::get_cached_val::{closure_env#0}> ()
    at /rustc/b955c8271da80a1af8a1d54c4e1bbdaf51b032e9/library/std/src/sync/once.rs:149
149	/rustc/b955c8271da80a1af8a1d54c4e1bbdaf51b032e9/library/std/src/sync/once.rs: No such file or directory.

To make set substitute-path work, don't use ~ in the replacement.

JohnTitor added a commit to JohnTitor/rust that referenced this issue Apr 11, 2023
…r=cuviper

Set up standard library path substitution in rust-gdb and gdbgui

Fixes rust-lang#62945

---

Only lightly tested (in release mode, where the paths are a bit of a mess) because my `gdb` appears to crash with `internal-error: inside_main_func: Assertion 'block != nullptr' failed.` and I don't have `gdbgui`. Please review carefully my shell syntax.

There's also `rust-lldb`, but I don't know the equivalent for it.
@bors bors closed this as completed in c617ddf Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) E-medium Call for participation: Medium difficulty. Experience needed to fix: Intermediate. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants