Skip to content

trans: Inform LLVM we want CodeView on MSVC #31319

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

Merged
merged 1 commit into from
Feb 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/librustc_trans/trans/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ pub fn finalize(cx: &CrateContext) {
2)
}

// Indicate that we want CodeView debug information on MSVC
if cx.sess().target.target.options.is_like_msvc {
llvm::LLVMRustAddModuleFlag(cx.llmod(),
"CodeView\0".as_ptr() as *const _,
1)
}

// Prevent bitcode readers from deleting the debug info.
let ptr = "Debug Info Version\0".as_ptr();
llvm::LLVMRustAddModuleFlag(cx.llmod(), ptr as *const _,
Expand Down
28 changes: 11 additions & 17 deletions src/test/run-pass/backtrace-debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// seemingly completely unrelated change.
// Unfortunately, LLVM has no "disable" option for this, so we have to set
// "enable" to 0 instead.

// compile-flags:-g -Cllvm-args=-enable-tail-merge=0
// ignore-pretty as this critically relies on line numbers

Expand All @@ -27,30 +28,23 @@ macro_rules! pos {
() => ((file!(), line!()))
}

#[cfg(all(unix,
not(target_os = "macos"),
not(target_os = "ios"),
not(target_os = "android"),
not(all(target_os = "linux", target_arch = "arm"))))]
macro_rules! dump_and_die {
($($pos:expr),*) => ({
// FIXME(#18285): we cannot include the current position because
// the macro span takes over the last frame's file/line.
dump_filelines(&[$($pos),*]);
panic!();
if cfg!(target_os = "macos") ||
cfg!(target_os = "ios") ||
cfg!(target_os = "android") ||
cfg!(all(target_os = "linux", target_arch = "arm")) ||
cfg!(all(windows, target_env = "gnu")) {
// skip these platforms as this support isn't implemented yet.
} else {
dump_filelines(&[$($pos),*]);
panic!();
}
})
}

// this does not work on Windows, Android, OSX or iOS
#[cfg(not(all(unix,
not(target_os = "macos"),
not(target_os = "ios"),
not(target_os = "android"),
not(all(target_os = "linux", target_arch = "arm")))))]
macro_rules! dump_and_die {
($($pos:expr),*) => ({ let _ = [$($pos),*]; })
}

// we can't use a function as it will alter the backtrace
macro_rules! check {
($counter:expr; $($pos:expr),*) => ({
Expand Down
18 changes: 8 additions & 10 deletions src/test/run-pass/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@

// no-pretty-expanded FIXME #15189
// ignore-android FIXME #17520
// ignore-msvc FIXME #28133
// compile-flags:-g

use std::env;
use std::process::{Command, Stdio};
use std::str;
use std::ops::{Drop, FnMut, FnOnce};

#[inline(never)]
fn foo() {
Expand Down Expand Up @@ -52,7 +51,7 @@ fn runtest(me: &str) {
let out = p.wait_with_output().unwrap();
assert!(!out.status.success());
let s = str::from_utf8(&out.stderr).unwrap();
assert!(s.contains("stack backtrace") && s.contains("foo::h"),
assert!(s.contains("stack backtrace") && s.contains(" - foo"),
"bad output: {}", s);

// Make sure the stack trace is *not* printed
Expand All @@ -62,7 +61,7 @@ fn runtest(me: &str) {
let out = p.wait_with_output().unwrap();
assert!(!out.status.success());
let s = str::from_utf8(&out.stderr).unwrap();
assert!(!s.contains("stack backtrace") && !s.contains("foo::h"),
assert!(!s.contains("stack backtrace") && !s.contains(" - foo"),
"bad output2: {}", s);

// Make sure a stack trace is printed
Expand All @@ -72,7 +71,7 @@ fn runtest(me: &str) {
let s = str::from_utf8(&out.stderr).unwrap();
// loosened the following from double::h to double:: due to
// spurious failures on mac, 32bit, optimized
assert!(s.contains("stack backtrace") && s.contains("double::"),
assert!(s.contains("stack backtrace") && s.contains(" - double"),
"bad output3: {}", s);

// Make sure a stack trace isn't printed too many times
Expand All @@ -89,8 +88,11 @@ fn runtest(me: &str) {
"bad output4: {}", s);
}

#[cfg(not(all(windows, target_arch = "x86")))]
fn main() {
if cfg!(windows) && cfg!(target_arch = "x86") && cfg!(target_env = "gnu") {
return
}

let args: Vec<String> = env::args().collect();
if args.len() >= 2 && args[1] == "fail" {
foo();
Expand All @@ -100,7 +102,3 @@ fn main() {
runtest(&args[0]);
}
}

// See issue 28218
#[cfg(all(windows, target_arch = "x86"))]
fn main() {}