Fix up the VM trace.
This commit is contained in:
parent
40a304b177
commit
52355855fc
@ -99,11 +99,11 @@ impl<'a> Executive<'a> {
|
||||
let check = options.check_nonce;
|
||||
match options.tracing {
|
||||
true => match options.vm_tracing {
|
||||
true => self.transact_with_tracer(t, check, ExecutiveTracer::default(), ExecutiveVMTracer::default()),
|
||||
true => self.transact_with_tracer(t, check, ExecutiveTracer::default(), ExecutiveVMTracer::toplevel()),
|
||||
false => self.transact_with_tracer(t, check, ExecutiveTracer::default(), NoopVMTracer),
|
||||
},
|
||||
false => match options.vm_tracing {
|
||||
true => self.transact_with_tracer(t, check, NoopTracer, ExecutiveVMTracer::default()),
|
||||
true => self.transact_with_tracer(t, check, NoopTracer, ExecutiveVMTracer::toplevel()),
|
||||
false => self.transact_with_tracer(t, check, NoopTracer, NoopVMTracer),
|
||||
},
|
||||
}
|
||||
|
@ -160,11 +160,24 @@ impl Tracer for ExecutiveTracer {
|
||||
}
|
||||
|
||||
/// Simple VM tracer. Traces all operations.
|
||||
#[derive(Default)]
|
||||
pub struct ExecutiveVMTracer {
|
||||
data: VMTrace,
|
||||
}
|
||||
|
||||
impl ExecutiveVMTracer {
|
||||
/// Create a new top-level instance.
|
||||
pub fn toplevel() -> Self {
|
||||
ExecutiveVMTracer {
|
||||
data: VMTrace {
|
||||
parent_step: 0,
|
||||
code: vec![],
|
||||
operations: vec![Default::default()], // prefill with a single entry so that prepare_subtrace can get the parent_step
|
||||
subs: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VMTracer for ExecutiveVMTracer {
|
||||
fn trace_prepare_execute(&mut self, pc: usize, instruction: u8, gas_cost: &U256) -> bool {
|
||||
self.data.operations.push(VMOperation {
|
||||
@ -188,7 +201,7 @@ impl VMTracer for ExecutiveVMTracer {
|
||||
|
||||
fn prepare_subtrace(&self, code: &[u8]) -> Self {
|
||||
ExecutiveVMTracer { data: VMTrace {
|
||||
parent_step: self.data.operations.len(),
|
||||
parent_step: self.data.operations.len() - 1, // won't overflow since we must already have pushed an operation in trace_prepare_execute.
|
||||
code: code.to_vec(),
|
||||
operations: vec![],
|
||||
subs: vec![],
|
||||
|
@ -473,7 +473,7 @@ impl Decodable for VMExecutedOperation {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Binary)]
|
||||
#[derive(Debug, Clone, PartialEq, Binary, Default)]
|
||||
/// A record of the execution of a single VM operation.
|
||||
pub struct VMOperation {
|
||||
/// The program counter.
|
||||
|
Loading…
Reference in New Issue
Block a user