From aa37e95d856aec97c926372d9eae79037a65e434 Mon Sep 17 00:00:00 2001
From: Petar Atanasov
Date: Wed, 29 Jan 2025 18:46:52 +0200
Subject: [PATCH] feat(event): Define `Error` event
---
Cargo.toml | 2 +-
src/lib.rs | 3 ++-
src/types.rs | 12 ++++++++++++
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 9ba420d..14542c9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "runtime_tracing"
-version = "0.5.16"
+version = "0.6.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/src/lib.rs b/src/lib.rs
index 2d5578d..c7f7978 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -24,6 +24,7 @@ mod tests {
tracer.register_asm(&["asm0".to_string(), "asm1".to_string()]);
tracer.register_special_event(EventLogKind::Write, "test");
tracer.register_special_event(EventLogKind::Write, "test2");
+ tracer.register_special_event(EventLogKind::Error, "testError");
let function_path_id = tracer.ensure_path_id(&path);
let function_line = Line(3);
@@ -88,7 +89,7 @@ mod tests {
tracer.register_return(NONE_VALUE);
tracer.drop_variable("test_variable3");
- assert_eq!(tracer.events.len(), 33);
+ assert_eq!(tracer.events.len(), 34);
// visible with
// cargo tets -- --nocapture
// println!("{:#?}", tracer.events);
diff --git a/src/types.rs b/src/types.rs
index f57d27c..1df3d2f 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -6,6 +6,12 @@ use num_derive::FromPrimitive;
use serde::{Deserialize, Serialize};
use serde_repr::*;
+// currently, we do assume that we record the whole program
+// so, we try to include minimal amount of data,
+// as we can reconstruct some things like depth, id-s etc
+// afterwards in postprocessing
+// this assumption can change in the future
+
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum TraceLowLevelEvent {
Step(StepRecord),
@@ -19,12 +25,17 @@ pub enum TraceLowLevelEvent {
Return(ReturnRecord),
Event(RecordEvent),
Asm(Vec),
+
+ // experimental modification value tracking events
CompoundValue(CompoundValueRecord),
CellValue(CellValueRecord),
AssignCompoundItem(AssignCompoundItemRecord),
AssignCell(AssignCellRecord),
VariableCell(VariableCellRecord),
DropVariable(VariableId),
+
+ // normal event, workaround for cases when we need to drop
+ // a step event, but the trace needs to be append-only
DropLastStep,
}
@@ -371,6 +382,7 @@ pub enum EventLogKind {
CloseDir,
Socket,
Open,
+ Error,
// used for trace events
TraceLogEvent,
}