diff --git a/src/shims/backtrace.rs b/src/shims/backtrace.rs index 64bd546458..c7b399228b 100644 --- a/src/shims/backtrace.rs +++ b/src/shims/backtrace.rs @@ -1,5 +1,4 @@ use rustc_abi::{ExternAbi, Size}; -use rustc_ast::ast::Mutability; use rustc_middle::ty::layout::LayoutOf as _; use rustc_middle::ty::{self, Instance, Ty}; use rustc_span::{BytePos, Loc, Symbol, hygiene}; @@ -179,14 +178,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { match flags { 0 => { - // These are "mutable" allocations as we consider them to be owned by the callee. - let name_alloc = - this.allocate_str(&name, MiriMemoryKind::Rust.into(), Mutability::Mut)?; - let filename_alloc = - this.allocate_str(&filename, MiriMemoryKind::Rust.into(), Mutability::Mut)?; - - this.write_immediate(name_alloc.to_ref(this), &this.project_field(dest, 0)?)?; - this.write_immediate(filename_alloc.to_ref(this), &this.project_field(dest, 1)?)?; + throw_unsup_format!("miri_resolve_frame: v0 is not supported any more"); } 1 => { this.write_scalar( diff --git a/src/shims/panic.rs b/src/shims/panic.rs index 722c3a2f0c..9347954000 100644 --- a/src/shims/panic.rs +++ b/src/shims/panic.rs @@ -12,7 +12,6 @@ //! metadata we remembered when pushing said frame. use rustc_abi::ExternAbi; -use rustc_ast::Mutability; use rustc_middle::{mir, ty}; use rustc_target::spec::PanicStrategy; @@ -161,7 +160,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let this = self.eval_context_mut(); // First arg: message. - let msg = this.allocate_str(msg, MiriMemoryKind::Machine.into(), Mutability::Not)?; + let msg = this.allocate_str_dedup(msg)?; // Call the lang item. let panic = this.tcx.lang_items().panic_fn().unwrap(); @@ -180,7 +179,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { let this = self.eval_context_mut(); // First arg: message. - let msg = this.allocate_str(msg, MiriMemoryKind::Machine.into(), Mutability::Not)?; + let msg = this.allocate_str_dedup(msg)?; // Call the lang item. let panic = this.tcx.lang_items().panic_nounwind().unwrap(); diff --git a/tests/pass/backtrace/backtrace-api-v0.rs b/tests/pass/backtrace/backtrace-api-v0.rs deleted file mode 100644 index 3fff7921af..0000000000 --- a/tests/pass/backtrace/backtrace-api-v0.rs +++ /dev/null @@ -1,69 +0,0 @@ -//@normalize-stderr-test: "::<.*>" -> "" - -#[inline(never)] -fn func_a() -> Box<[*mut ()]> { - func_b::() -} -#[inline(never)] -fn func_b() -> Box<[*mut ()]> { - func_c() -} - -macro_rules! invoke_func_d { - () => { - func_d() - }; -} - -#[inline(never)] -fn func_c() -> Box<[*mut ()]> { - invoke_func_d!() -} -#[inline(never)] -fn func_d() -> Box<[*mut ()]> { - unsafe { miri_get_backtrace(0) } -} - -fn main() { - let mut seen_main = false; - let frames = func_a(); - for frame in frames.iter() { - let miri_frame = unsafe { miri_resolve_frame(*frame, 0) }; - let name = String::from_utf8(miri_frame.name.into()).unwrap(); - let filename = String::from_utf8(miri_frame.filename.into()).unwrap(); - - if name == "func_a" { - assert_eq!(func_a as *mut (), miri_frame.fn_ptr); - } - - // Print every frame to stderr. - let out = format!("{}:{}:{} ({})", filename, miri_frame.lineno, miri_frame.colno, name); - eprintln!("{}", out); - // Print the 'main' frame (and everything before it) to stdout, skipping - // the printing of internal (and possibly fragile) libstd frames. - // Stdout is less normalized so we see more, but it also means we can print less - // as platform differences would lead to test suite failures. - if !seen_main { - println!("{}", out); - seen_main = name == "main"; - } - } -} - -// This goes at the bottom of the file so that we can change it -// without disturbing line numbers of the functions in the backtrace. - -extern "Rust" { - fn miri_get_backtrace(flags: u64) -> Box<[*mut ()]>; - fn miri_resolve_frame(ptr: *mut (), flags: u64) -> MiriFrame; -} - -#[derive(Debug)] -#[repr(C)] -struct MiriFrame { - name: Box<[u8]>, - filename: Box<[u8]>, - lineno: u32, - colno: u32, - fn_ptr: *mut (), -} diff --git a/tests/pass/backtrace/backtrace-api-v0.stderr b/tests/pass/backtrace/backtrace-api-v0.stderr deleted file mode 100644 index 9849a1aa74..0000000000 --- a/tests/pass/backtrace/backtrace-api-v0.stderr +++ /dev/null @@ -1,18 +0,0 @@ -tests/pass/backtrace/backtrace-api-v0.rs:LL:CC (func_d) -tests/pass/backtrace/backtrace-api-v0.rs:LL:CC (func_c) -tests/pass/backtrace/backtrace-api-v0.rs:LL:CC (func_b) -tests/pass/backtrace/backtrace-api-v0.rs:LL:CC (func_a) -tests/pass/backtrace/backtrace-api-v0.rs:LL:CC (main) -RUSTLIB/core/src/ops/function.rs:LL:CC (>::call_once - shim(fn())) -RUSTLIB/std/src/sys/backtrace.rs:LL:CC (std::sys::backtrace::__rust_begin_short_backtrace) -RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start::{closure#0}) -RUSTLIB/core/src/ops/function.rs:LL:CC (std::ops::function::impls::call_once) -RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) -RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) -RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind) -RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal::{closure#1}) -RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try::do_call) -RUSTLIB/std/src/panicking.rs:LL:CC (std::panicking::r#try) -RUSTLIB/std/src/panic.rs:LL:CC (std::panic::catch_unwind) -RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start_internal) -RUSTLIB/std/src/rt.rs:LL:CC (std::rt::lang_start) diff --git a/tests/pass/backtrace/backtrace-api-v0.stdout b/tests/pass/backtrace/backtrace-api-v0.stdout deleted file mode 100644 index 8c1bc5c353..0000000000 --- a/tests/pass/backtrace/backtrace-api-v0.stdout +++ /dev/null @@ -1,5 +0,0 @@ -tests/pass/backtrace/backtrace-api-v0.rs:24:14 (func_d) -tests/pass/backtrace/backtrace-api-v0.rs:14:9 (func_c) -tests/pass/backtrace/backtrace-api-v0.rs:9:5 (func_b::) -tests/pass/backtrace/backtrace-api-v0.rs:5:5 (func_a) -tests/pass/backtrace/backtrace-api-v0.rs:29:18 (main)