rbpf-cli: capture log
This commit is contained in:
parent
857be1e237
commit
2fc888d864
|
@ -304,24 +304,6 @@ native machine code before execting it in the virtual machine.",
|
||||||
};
|
};
|
||||||
let duration = Instant::now() - start_time;
|
let duration = Instant::now() - start_time;
|
||||||
|
|
||||||
let output = Output {
|
|
||||||
result: format!("{:?}", result),
|
|
||||||
instruction_count: vm.get_total_instruction_count(),
|
|
||||||
execution_time: duration,
|
|
||||||
};
|
|
||||||
match matches.value_of("output_format") {
|
|
||||||
Some("json") => {
|
|
||||||
println!("{}", serde_json::to_string_pretty(&output).unwrap());
|
|
||||||
}
|
|
||||||
Some("json-compact") => {
|
|
||||||
println!("{}", serde_json::to_string(&output).unwrap());
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
println!("Program output:");
|
|
||||||
println!("{:?}", output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if matches.is_present("trace") {
|
if matches.is_present("trace") {
|
||||||
eprintln!("Trace is saved in trace.out");
|
eprintln!("Trace is saved in trace.out");
|
||||||
let mut file = File::create("trace.out").unwrap();
|
let mut file = File::create("trace.out").unwrap();
|
||||||
|
@ -339,6 +321,33 @@ native machine code before execting it in the virtual machine.",
|
||||||
.visualize_graphically(&mut file, Some(&dynamic_analysis))
|
.visualize_graphically(&mut file, Some(&dynamic_analysis))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let instruction_count = vm.get_total_instruction_count();
|
||||||
|
drop(vm);
|
||||||
|
|
||||||
|
let output = Output {
|
||||||
|
result: format!("{:?}", result),
|
||||||
|
instruction_count,
|
||||||
|
execution_time: duration,
|
||||||
|
log: invoke_context
|
||||||
|
.get_log_collector()
|
||||||
|
.unwrap()
|
||||||
|
.borrow()
|
||||||
|
.get_recorded_content()
|
||||||
|
.to_vec(),
|
||||||
|
};
|
||||||
|
match matches.value_of("output_format") {
|
||||||
|
Some("json") => {
|
||||||
|
println!("{}", serde_json::to_string_pretty(&output).unwrap());
|
||||||
|
}
|
||||||
|
Some("json-compact") => {
|
||||||
|
println!("{}", serde_json::to_string(&output).unwrap());
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
println!("Program output:");
|
||||||
|
println!("{:?}", output);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
|
@ -346,6 +355,7 @@ struct Output {
|
||||||
result: String,
|
result: String,
|
||||||
instruction_count: u64,
|
instruction_count: u64,
|
||||||
execution_time: Duration,
|
execution_time: Duration,
|
||||||
|
log: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Debug for Output {
|
impl Debug for Output {
|
||||||
|
@ -353,6 +363,9 @@ impl Debug for Output {
|
||||||
writeln!(f, "Result: {}", self.result)?;
|
writeln!(f, "Result: {}", self.result)?;
|
||||||
writeln!(f, "Instruction Count: {}", self.instruction_count)?;
|
writeln!(f, "Instruction Count: {}", self.instruction_count)?;
|
||||||
writeln!(f, "Execution time: {} us", self.execution_time.as_micros())?;
|
writeln!(f, "Execution time: {} us", self.execution_time.as_micros())?;
|
||||||
|
for line in &self.log {
|
||||||
|
writeln!(f, "{}", line)?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue