rust-lang / rust-lang/rust

gdb on e.g. aarch64-unknown-linux-gnu/windows-gnu cannot print unused by-value non-immediate arguments

Open
#128,973 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-debuginfo A-LLVM C-bug E-needs-investigation T-compiler WG-debugging
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This test does not work on aarch64: https://github.com/rust-lang/rust/blob/c9bd03cb724e13cca96ad320733046cbdb16fbbe/tests/debuginfo/by-value-non-immediate-argument.rs

Stripped down (a bit):

fn by_val_enum(x: (usize, usize, usize)) {
    zzz(); // #break
}

fn main() {
    by_val_enum((usize::MAX, usize::MAX, usize::MAX));
}

fn zzz() { }

Set a breakpoint on line 2 and try to print x. gdb says it is optimized out. This can be reproduced even with -Zmir-opt-level=0, and doesn't reproduce on x86_64. If the argument is Option<(usize, usize)>, gdb will try to read from address 0x0.

I'm not sure if this is a rustc bug or a gdb bug because if I add any use of the non-immediate argument inside the function, we gain some instructions that look like a function prelude, and gdb is able to print the argument. https://godbolt.org/z/GeGxE7ExE

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/debuginfo/by-value-non-immediate-argument.rs and the reduced by_val_enum reproduction in the issue. Reproduce the breakpoint on aarch64-unknown-linux-gnu or windows-gnu with gdb, compare against x86_64, and inspect the Godbolt example. Done means gdb can print the unused by-value argument without reporting it as optimized out or reading address 0x0.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.