From 9c5d7fcfa8354db36eee13d86f9338b0ac8e591a Mon Sep 17 00:00:00 2001 From: nhtyy Date: Thu, 14 Nov 2024 15:23:42 -0800 Subject: [PATCH] fix: use global clk --- crates/core/executor/src/executor.rs | 4 ++-- crates/core/executor/src/profiler.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/core/executor/src/executor.rs b/crates/core/executor/src/executor.rs index 39693eb64..bed22912e 100644 --- a/crates/core/executor/src/executor.rs +++ b/crates/core/executor/src/executor.rs @@ -202,7 +202,7 @@ impl<'a> Executor<'a> { .unwrap_or(1); this.profiler = Some(( - Profiler::new(elf_bytes, sample_rate).expect("Failed to create profiler"), + Profiler::new(elf_bytes, sample_rate as u64).expect("Failed to create profiler"), trace_buf, )); } @@ -1662,7 +1662,7 @@ impl<'a> Executor<'a> { fn log(&mut self, _: &Instruction) { if let Some((ref mut profiler, _)) = self.profiler { if !self.unconstrained { - profiler.record(self.state.clk, self.state.pc as u64); + profiler.record(self.state.global_clk, self.state.pc as u64); } } diff --git a/crates/core/executor/src/profiler.rs b/crates/core/executor/src/profiler.rs index 837c24885..165b0fc60 100644 --- a/crates/core/executor/src/profiler.rs +++ b/crates/core/executor/src/profiler.rs @@ -19,7 +19,7 @@ pub enum ProfilerError { /// During exeuction, the profiler always keeps track of the callstack /// and will occasionally save the stack according to the sample rate. pub struct Profiler { - sample_rate: u32, + sample_rate: u64, /// `start_address`-> index in `function_ranges` start_lookup: HashMap, /// the start and end of the function @@ -44,7 +44,7 @@ struct Sample { } impl Profiler { - pub(super) fn new(elf_bytes: &[u8], sample_rate: u32) -> Result { + pub(super) fn new(elf_bytes: &[u8], sample_rate: u64) -> Result { let elf = Elf::parse(elf_bytes)?; let mut start_lookup = HashMap::new(); @@ -91,7 +91,7 @@ impl Profiler { }) } - pub(super) fn record(&mut self, clk: u32, pc: u64) { + pub(super) fn record(&mut self, clk: u64, pc: u64) { // We are still in the current function. if pc > self.current_function_range.0 && pc <= self.current_function_range.1 { if clk % self.sample_rate == 0 {