Skip to content

Commit 5d5e67a

Browse files
committed
Embed any available .natvis files into the pdb.
1 parent f85579d commit 5d5e67a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/librustc_trans/back/linker.rs

+25
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,31 @@ impl<'a> Linker for MsvcLinker<'a> {
475475
// This will cause the Microsoft linker to generate a PDB file
476476
// from the CodeView line tables in the object files.
477477
self.cmd.arg("/DEBUG");
478+
479+
// This will cause the Microsoft linker to embed .natvis info into the the PDB file
480+
let sysroot = self.sess.sysroot();
481+
let natvis_dir_path = sysroot.join("lib\\rustlib\\etc");
482+
if let Ok(natvis_dir) = fs::read_dir(&natvis_dir_path) {
483+
for entry in natvis_dir {
484+
match entry {
485+
Ok(entry) => {
486+
let path = entry.path();
487+
if let Some(ext) = path.extension() {
488+
if ext == OsStr::new("natvis") {
489+
if let Some(natvis_path_str) = path.to_str() {
490+
self.cmd.arg(&format!("/NATVIS:{}",natvis_path_str));
491+
} else {
492+
self.sess.warn(&format!("natvis path not unicode: {:?}", path));
493+
}
494+
}
495+
}
496+
},
497+
Err(err) => {
498+
self.sess.warn(&format!("error enumerating natvis directory: {}", err));
499+
},
500+
}
501+
}
502+
}
478503
}
479504

480505
// Currently the compiler doesn't use `dllexport` (an LLVM attribute) to

0 commit comments

Comments
 (0)