Skip to content

Commit 24724ef

Browse files
committed
miri: debug! print when we are leaving/entering a function
With a hack to exclude the topmost function for now, because that triggers an ICE...
1 parent abf6f47 commit 24724ef

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/librustc_mir/interpret/eval_context.rs

+14
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
438438
return_place: Option<PlaceTy<'tcx, M::PointerTag>>,
439439
return_to_block: StackPopCleanup,
440440
) -> EvalResult<'tcx> {
441+
if self.stack.len() > 1 { // FIXME should be "> 0", printing topmost frame crashes rustc...
442+
debug!("PAUSING({}) {}", self.cur_frame(), self.frame().instance);
443+
}
441444
::log_settings::settings().indentation += 1;
442445

443446
// first push a stack frame so we have access to the local substs
@@ -502,6 +505,10 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
502505
self.frame_mut().locals = locals;
503506
}
504507

508+
if self.stack.len() > 1 { // FIXME no check should be needed, but printing topmost frame crashes rustc...
509+
debug!("ENTERING({}) {}", self.cur_frame(), self.frame().instance);
510+
}
511+
505512
if self.stack.len() > self.tcx.sess.const_eval_stack_frame_limit {
506513
err!(StackFrameLimitReached)
507514
} else {
@@ -510,6 +517,9 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
510517
}
511518

512519
pub(super) fn pop_stack_frame(&mut self) -> EvalResult<'tcx> {
520+
if self.stack.len() > 1 { // FIXME no check should be needed, but printing topmost frame crashes rustc...
521+
debug!("LEAVING({}) {}", self.cur_frame(), self.frame().instance);
522+
}
513523
::log_settings::settings().indentation -= 1;
514524
let frame = self.stack.pop().expect(
515525
"tried to pop a stack frame, but there were none",
@@ -553,6 +563,10 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
553563
return err!(Unreachable);
554564
}
555565

566+
if self.stack.len() > 1 { // FIXME should be "> 0", printing topmost frame crashes rustc...
567+
debug!("CONTINUING({}) {}", self.cur_frame(), self.frame().instance);
568+
}
569+
556570
Ok(())
557571
}
558572

0 commit comments

Comments
 (0)