Skip to content

[MIR] Implement debug info #31005

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

Closed
nagisa opened this issue Jan 18, 2016 · 3 comments · Fixed by #32952
Closed

[MIR] Implement debug info #31005

nagisa opened this issue Jan 18, 2016 · 3 comments · Fixed by #32952
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html

Comments

@nagisa
Copy link
Member

nagisa commented Jan 18, 2016

Currently we do not emit any debuginfo from the MIR translator.

It doesn’t seem like there should be many issues implementing support, other than DebugLoc wanting a ast::NodeId, which eventually gets passed down to trans::debuginfo::metadata::scope_metadata.

Precondition to this work is to either decouple trans::debuginfo and its DIScope-building-related functionality from the NodeId or create a independent code for MIR’s use.

@nagisa nagisa added the A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Jan 18, 2016
@nagisa
Copy link
Member Author

nagisa commented Jan 18, 2016

It might certainly be possible that by the translation time we do not retain enough information to build good debuginfo. In that case MIR itself should be adjusted to carry enough data.

@nagisa nagisa added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Jan 19, 2016
@eddyb
Copy link
Member

eddyb commented Apr 7, 2016

While working on #32803 I've found that we're still missing information on arguments, closure captures and returns.

For arguments, I tried leaving them anonymous, as gcc and clang do for void foo(A, B, C) {} in C++.
However, gdb doesn't display the value at all, while lldb makes an effort and uses (null) as the name.

Our options involve:

  • the name of single-binding patterns (and anonymous for the rest)
  • a pretty-printed pattern in ArgDecl
  • a source fragment extracted from the pattern span, in ArgDecl
  • some mapping from Name to Lvalue (could be translated to DWARF deref/offset expressions)

That last option would also help with closure captures, as they are effectively fields of the first argument.

As for returns, old trans seems to use the closing brace of the function (span.hi?), now that I think about it.
We're probably not going to be able to do anything interesting for each early return as they're just a branch and will remain that way for the foreseeable future.

bors added a commit that referenced this issue Apr 13, 2016
Initial implementation of debuginfo in MIR trans.

Progress is made towards #31005, but several issues remain, such as #32790.
@eddyb
Copy link
Member

eddyb commented Apr 14, 2016

Filed #32949 for uninitialized variables always being in scope during their initialization.

bors added a commit that referenced this issue Apr 17, 2016
Get all (but one) of debuginfo tests to pass with MIR codegen.

I didn't get much feedback in #31005 so I went ahead and implemented something simple.
Closes #31005, as MIR debuginfo should work now for most usecases.

The `no-debug-attribute` test no longer assumes variables are in scope of `return`.
We might also want to revisit that in #32949, but the test is more reliable now either way.

In order to get one last function in the `associated-type` test pass, this PR also fixes #32790.
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.) A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants