rust-lang / rustc_codegen_cranelift

Cranelift based backend for rustc
Apache License 2.0
1.53k stars 96 forks source link

CodeView debug info support for Windows #1287

Open afonso360 opened 1 year ago

afonso360 commented 1 year ago

It looks like cg_clif doesn't support debug info on Windows. It would be nice if we could do that!

Some pdb files are generated but I'm not sure what's in them (see: https://github.com/bjorn3/rustc_codegen_cranelift/issues/1249#issuecomment-1262034841).

I've been looking into this mostly because I have no idea how any of this works. I found two crates that seem to produce pdb files (bao-pdb, pdb_wrapper), but I'm not sure how complete they are or if they work for our use case.

A more interesting approach is what LLVM does for generating CodeView. LLVM apparently only emits CodeView line tables, and DWARF debug info (which we already know how to do!) And lets link.exe convert it into a PDB file, this seems like a much easier solution and maybe implementing only that part of CodeView would be easier.

Edit: Re-reading the rust issue, it looks like this doesn't get us variable and type information, only line information.

Edit 2: That information is also out of date, LLVM now has full CodeView support, but its good to know that that's how they started out.

Additional links:

bjorn3 commented 1 year ago

I found two crates that seem to produce pdb files (bao-pdb, pdb_wrapper), but I'm not sure how complete they are or if they work for our use case.

They are both licensed under Unlicense and from the same author. I'm not sure if Unlicense is allowed.

Edit: Re-reading the rust issue, it looks like this https://github.com/rust-lang/rust/issues/19533#issuecomment-115827953, only line information.

cg_clif already only supports line information anyway. I couldn't quite get the Cranelift integration for value tracking working reliably last time I tried.