about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-11-12 21:27:04 +0000
committerbors <bors@rust-lang.org>2019-11-12 21:27:04 +0000
commita333eed7fc0c903df9d6befcfb40af02148bf255 (patch)
treef58c8bd9ef3b92b31916f3a4eda588a00e41fb75 /src/libstd
parent4f03f4a989d1c8346c19dfb417a77c09b34408b8 (diff)
parentb4545a4ad625c68479120db845280f4c61b39640 (diff)
downloadrust-a333eed7fc0c903df9d6befcfb40af02148bf255.tar.gz
rust-a333eed7fc0c903df9d6befcfb40af02148bf255.zip
Auto merge of #60026 - Aaron1011:feature/miri-unwind, r=RalfJung,oli-obk
Add hooks for Miri panic unwinding

This commits adds in some additional hooks to allow Miri to properly
handle panic unwinding. None of this should have any impact on CTFE mode

This supports https://github.com/rust-lang/miri/pull/693
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sys_common/backtrace.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libstd/sys_common/backtrace.rs b/src/libstd/sys_common/backtrace.rs
index 9c406ec39cc..d7296b43fbe 100644
--- a/src/libstd/sys_common/backtrace.rs
+++ b/src/libstd/sys_common/backtrace.rs
@@ -66,7 +66,14 @@ unsafe fn _print(w: &mut dyn Write, format: PrintFmt) -> io::Result<()> {
 }
 
 unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt::Result {
-    let cwd = env::current_dir().ok();
+    // Always 'fail' to get the cwd when running under Miri -
+    // this allows Miri to display backtraces in isolation mode
+    let cwd = if !cfg!(miri) {
+        env::current_dir().ok()
+    } else {
+        None
+    };
+
     let mut print_path = move |fmt: &mut fmt::Formatter<'_>, bows: BytesOrWideString<'_>| {
         output_filename(fmt, bows, print_fmt, cwd.as_ref())
     };