Skip to content

Commit

Permalink
feat: StackSnapshotType (All). (#235)
Browse files Browse the repository at this point in the history
Add "StackSnapshotType::All" for easier reading of trace steps, as shown
in the picture.

![CleanShot 2567-10-22 at 03 05
05@2x](https://github.com/user-attachments/assets/6ea29c79-9d58-4d62-be18-782fa4e359f7)
  • Loading branch information
piyanggoon authored Oct 26, 2024
1 parent f67b4b8 commit d345f58
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion src/tracing/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,21 @@ pub enum StackSnapshotType {
/// Don't record stack snapshots
#[default]
None,
/// Record full, push stack
All,
/// Record only the items pushed to the stack
Pushes,
/// Record the full stack
Full,
Full
}

impl StackSnapshotType {
/// Returns true if this is the [StackSnapshotType::All] variant
#[inline]
pub const fn is_all(self) -> bool {
matches!(self, Self::All)
}

/// Returns true if this is the [StackSnapshotType::Full] variant
#[inline]
pub const fn is_full(self) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl TracingInspector {
RecordedMemory::new(interp.shared_memory.context_memory())
});

let stack = if self.config.record_stack_snapshots.is_full() {
let stack = if self.config.record_stack_snapshots.is_all() || self.config.record_stack_snapshots.is_full() {
Some(interp.stack.data().clone())
} else {
None
Expand Down Expand Up @@ -469,7 +469,7 @@ impl TracingInspector {

let step = &mut self.traces.arena[trace_idx].trace.steps[step_idx];

if self.config.record_stack_snapshots.is_pushes() {
if self.config.record_stack_snapshots.is_all() || self.config.record_stack_snapshots.is_pushes() {
let start = interp.stack.len() - step.op.outputs() as usize;
step.push_stack = Some(interp.stack.data()[start..].to_vec());
}
Expand Down

0 comments on commit d345f58

Please sign in to comment.