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

Emit windows-specific debug info #19533

Closed
brson opened this issue Dec 4, 2014 · 10 comments
Closed

Emit windows-specific debug info #19533

brson opened this issue Dec 4, 2014 · 10 comments
Assignees
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) O-windows Operating system: Windows

Comments

@brson
Copy link
Contributor

brson commented Dec 4, 2014

LLVM supports a simple windows-specific debug info containing just line numbers, that works correctly in the MS debugger. @michaelwoerister knows the details.

@brson brson added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Dec 4, 2014
@michaelwoerister
Copy link
Member

The relevant information can be found at http://clang.llvm.org/docs/MSVCCompatibility.html:

Clang emits both CodeView line tables (similar to what MSVC emits when given the /Z7 flag) and DWARF debug information into the object file. Microsoft’s link.exe will transform the CodeView line tables into a PDB, enabling stack traces in all modern Windows debuggers. Clang does not emit any CodeView-compatible type info or description of variable layout.

We should try and support this functionality also in rustc.

@retep998
Copy link
Member

This depends on adding support for rustc using link.exe.

@michaelwoerister
Copy link
Member

Yes, if you don't want to do your linking manually. I agree that if we say that we support this type of debuginfo, we should also make it as ergonomic as possible.

@sanxiyn sanxiyn added the O-windows Operating system: Windows label Jan 25, 2015
@Manishearth
Copy link
Member

cc @metajack @larsberg

@alexcrichton
Copy link
Member

Assigning to @michaelwoerister, this is coming more relevant now that we have initial MSVC support!

@jrmuizel
Copy link
Contributor

FWIW, I have the beginnings of a LLVM patch for adding x86-32 FPO information for unwinding.

@michaelwoerister
Copy link
Member

Quick update: It seems that LLVM on Windows will already emit CodeView line tables alongside DWARF if debuginfo is enabled. We just have to instruct link.exe to convert these into a PDB file, using the /DEBUG option. In a minimal proof of concept I was able to compile a small Rust program and step through it using WinDbg.

@Manishearth
Copy link
Member

Would this solve the problem? Or will we still need to rig something up for printing local vars &c?

@michaelwoerister
Copy link
Member

As far as I know, it should bring us on the same level as Clang as far as PDB debuginfo is concerned. Variable and type information just isn't supported by LLVM yet.

bors added a commit that referenced this issue Jul 13, 2015
This PR will enable RUSTC to generate PDB debuginfo files when targeting the MSVC toolchain. Mind that these are not full featured PDB files -- they just contain line tables, so you can get proper backtraces and step through your code, but variable values can't be inspected. We are just levering (LLVM's current support)[http://clang.llvm.org/docs/MSVCCompatibility.html] for creating Windows debuginfo. When LLVM's support gets better, we should benefit from that too without much effort.

I also wanted to include some kind of auto test with this PR but I could not get the `rmake` tests to work properly when targeting MSVC.

EDIT:
Closes #19533
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.) O-windows Operating system: Windows
Projects
None yet
Development

No branches or pull requests

7 participants