@@ -4,7 +4,6 @@ use rustc_middle::ty::{self, Instance, Ty};
44use rustc_span:: { BytePos , Loc , Symbol , hygiene} ;
55use rustc_target:: callconv:: { Conv , FnAbi } ;
66
7- use crate :: helpers:: check_min_arg_count;
87use crate :: * ;
98
109impl < ' tcx > EvalContextExt < ' tcx > for crate :: MiriInterpCx < ' tcx > { }
@@ -34,13 +33,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3433 abi : & FnAbi < ' tcx , Ty < ' tcx > > ,
3534 link_name : Symbol ,
3635 args : & [ OpTy < ' tcx > ] ,
37- dest : & MPlaceTy < ' tcx > ,
3836 ) -> InterpResult < ' tcx > {
3937 let this = self . eval_context_mut ( ) ;
40- let tcx = this. tcx ;
38+ let ptr_ty = this. machine . layouts . mut_raw_ptr . ty ;
39+ let ptr_layout = this. layout_of ( ptr_ty) ?;
40+
41+ let [ flags, buf] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
4142
42- let [ flags] = check_min_arg_count ( "miri_get_backtrace" , args) ?;
4343 let flags = this. read_scalar ( flags) ?. to_u64 ( ) ?;
44+ let buf_place = this. deref_pointer_as ( buf, ptr_layout) ?;
4445
4546 let mut data = Vec :: new ( ) ;
4647 for frame in this. active_thread_stack ( ) . iter ( ) . rev ( ) {
@@ -63,43 +64,18 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
6364 } )
6465 . collect ( ) ;
6566
66- let len: u64 = ptrs. len ( ) . try_into ( ) . unwrap ( ) ;
67-
68- let ptr_ty = this. machine . layouts . mut_raw_ptr . ty ;
69- let array_layout = this. layout_of ( Ty :: new_array ( tcx. tcx , ptr_ty, len) ) . unwrap ( ) ;
70-
7167 match flags {
72- // storage for pointers is allocated by miri
73- // deallocating the slice is undefined behavior with a custom global allocator
7468 0 => {
75- let [ _flags] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
76-
77- let alloc = this. allocate ( array_layout, MiriMemoryKind :: Rust . into ( ) ) ?;
78-
79- // Write pointers into array
80- for ( i, ptr) in ptrs. into_iter ( ) . enumerate ( ) {
81- let place = this. project_index ( & alloc, i as u64 ) ?;
82-
83- this. write_pointer ( ptr, & place) ?;
84- }
85-
86- this. write_immediate ( Immediate :: new_slice ( alloc. ptr ( ) , len, this) , dest) ?;
69+ throw_unsup_format ! ( "miri_get_backtrace: v0 is not supported any more" ) ;
8770 }
88- // storage for pointers is allocated by the caller
89- 1 => {
90- let [ _flags, buf] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
91-
92- let ptr_layout = this. layout_of ( ptr_ty) ?;
93- let buf_place = this. deref_pointer_as ( buf, ptr_layout) ?;
94-
71+ 1 =>
9572 for ( i, ptr) in ptrs. into_iter ( ) . enumerate ( ) {
9673 let offset = ptr_layout. size . checked_mul ( i. try_into ( ) . unwrap ( ) , this) . unwrap ( ) ;
9774
9875 let op_place = buf_place. offset ( offset, ptr_layout, this) ?;
9976
10077 this. write_pointer ( ptr, & op_place) ?;
101- }
102- }
78+ } ,
10379 _ => throw_unsup_format ! ( "unknown `miri_get_backtrace` flags {}" , flags) ,
10480 } ;
10581
0 commit comments