@@ -4,7 +4,6 @@ use rustc_middle::ty::{self, Instance, Ty};
4
4
use rustc_span:: { BytePos , Loc , Symbol , hygiene} ;
5
5
use rustc_target:: callconv:: { Conv , FnAbi } ;
6
6
7
- use crate :: helpers:: check_min_arg_count;
8
7
use crate :: * ;
9
8
10
9
impl < ' tcx > EvalContextExt < ' tcx > for crate :: MiriInterpCx < ' tcx > { }
@@ -34,13 +33,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
34
33
abi : & FnAbi < ' tcx , Ty < ' tcx > > ,
35
34
link_name : Symbol ,
36
35
args : & [ OpTy < ' tcx > ] ,
37
- dest : & MPlaceTy < ' tcx > ,
38
36
) -> InterpResult < ' tcx > {
39
37
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) ?;
41
42
42
- let [ flags] = check_min_arg_count ( "miri_get_backtrace" , args) ?;
43
43
let flags = this. read_scalar ( flags) ?. to_u64 ( ) ?;
44
+ let buf_place = this. deref_pointer_as ( buf, ptr_layout) ?;
44
45
45
46
let mut data = Vec :: new ( ) ;
46
47
for frame in this. active_thread_stack ( ) . iter ( ) . rev ( ) {
@@ -63,43 +64,18 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
63
64
} )
64
65
. collect ( ) ;
65
66
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
-
71
67
match flags {
72
- // storage for pointers is allocated by miri
73
- // deallocating the slice is undefined behavior with a custom global allocator
74
68
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" ) ;
87
70
}
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 =>
95
72
for ( i, ptr) in ptrs. into_iter ( ) . enumerate ( ) {
96
73
let offset = ptr_layout. size . checked_mul ( i. try_into ( ) . unwrap ( ) , this) . unwrap ( ) ;
97
74
98
75
let op_place = buf_place. offset ( offset, ptr_layout, this) ?;
99
76
100
77
this. write_pointer ( ptr, & op_place) ?;
101
- }
102
- }
78
+ } ,
103
79
_ => throw_unsup_format ! ( "unknown `miri_get_backtrace` flags {}" , flags) ,
104
80
} ;
105
81
0 commit comments