Improve execution trace logging.
This commit is contained in:
parent
4a22283d8b
commit
f74d1dc7f1
1 changed files with 25 additions and 7 deletions
|
@ -192,31 +192,49 @@ impl<'a, 'tcx: 'a> Interpreter<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run(&mut self) -> EvalResult<()> {
|
fn run(&mut self) -> EvalResult<()> {
|
||||||
|
fn print_indent(n: usize) {
|
||||||
|
for _ in 0..n {
|
||||||
|
print!(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
'outer: while !self.stack.is_empty() {
|
'outer: while !self.stack.is_empty() {
|
||||||
let mut current_block = self.current_frame().next_block;
|
let mut current_block = self.current_frame().next_block;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if TRACE_EXECUTION { println!("Entering block: {:?}", current_block); }
|
if TRACE_EXECUTION {
|
||||||
|
print_indent(self.stack.len());
|
||||||
|
println!("{:?}:", current_block);
|
||||||
|
}
|
||||||
|
|
||||||
let current_mir = self.current_frame().mir.clone(); // Cloning a reference.
|
let current_mir = self.current_frame().mir.clone(); // Cloning a reference.
|
||||||
let block_data = current_mir.basic_block_data(current_block);
|
let block_data = current_mir.basic_block_data(current_block);
|
||||||
|
|
||||||
for stmt in &block_data.statements {
|
for stmt in &block_data.statements {
|
||||||
if TRACE_EXECUTION { println!("{:?}", stmt); }
|
if TRACE_EXECUTION {
|
||||||
|
print_indent(self.stack.len() + 1);
|
||||||
|
println!("{:?}", stmt);
|
||||||
|
}
|
||||||
let mir::StatementKind::Assign(ref lvalue, ref rvalue) = stmt.kind;
|
let mir::StatementKind::Assign(ref lvalue, ref rvalue) = stmt.kind;
|
||||||
try!(self.eval_assignment(lvalue, rvalue));
|
try!(self.eval_assignment(lvalue, rvalue));
|
||||||
}
|
}
|
||||||
|
|
||||||
let terminator = block_data.terminator();
|
let terminator = block_data.terminator();
|
||||||
if TRACE_EXECUTION { println!("{:?}", terminator); }
|
if TRACE_EXECUTION {
|
||||||
|
print_indent(self.stack.len() + 1);
|
||||||
|
println!("{:?}", terminator);
|
||||||
|
}
|
||||||
|
|
||||||
match try!(self.eval_terminator(terminator)) {
|
match try!(self.eval_terminator(terminator)) {
|
||||||
TerminatorTarget::Block(block) => current_block = block,
|
TerminatorTarget::Block(block) => current_block = block,
|
||||||
TerminatorTarget::Return => break,
|
TerminatorTarget::Return => {
|
||||||
|
self.pop_stack_frame();
|
||||||
|
self.substs_stack.pop();
|
||||||
|
continue 'outer;
|
||||||
|
}
|
||||||
TerminatorTarget::Call => continue 'outer,
|
TerminatorTarget::Call => continue 'outer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.pop_stack_frame();
|
|
||||||
self.substs_stack.pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue