Skip to content

Commit f28e827

Browse files
committed
Merge branch 'master' into binary_trace_format
2 parents a710f7b + 2281e02 commit f28e827

File tree

5 files changed

+31
-13
lines changed

5 files changed

+31
-13
lines changed

runtime_tracing/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "runtime_tracing"
3-
version = "0.10.0"
3+
version = "0.11.0"
44
edition = "2021"
55
authors = ["Metacraft Labs Ltd"]
66
description = "A library for the schema and tracing helpers for the CodeTracer db trace format"
@@ -13,6 +13,7 @@ build = "build.rs"
1313
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1414

1515
[dependencies]
16+
base64 = "0.22.1"
1617
num-traits = "0.2"
1718
num-derive = "0.4"
1819
serde = { version = "1.0", features = ["derive"] }

runtime_tracing/src/base64.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use base64::Engine;
2+
use serde::{Deserialize, Serialize};
3+
use serde::{Deserializer, Serializer};
4+
5+
pub fn serialize<S: Serializer>(v: &Vec<u8>, s: S) -> Result<S::Ok, S::Error> {
6+
let base64 = base64::engine::general_purpose::STANDARD.encode(v);
7+
String::serialize(&base64, s)
8+
}
9+
10+
pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Vec<u8>, D::Error> {
11+
let base64 = String::deserialize(d)?;
12+
base64::engine::general_purpose::STANDARD.decode(base64.as_bytes()).map_err(serde::de::Error::custom)
13+
}

runtime_tracing/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//! The format is documented in `docs/` and the README.
1111
mod tracer;
1212
mod types;
13+
mod base64;
1314
mod capnptrace;
1415
pub use crate::tracer::{Tracer, TraceEventsFileFormat, NONE_TYPE_ID, NONE_VALUE};
1516
pub use crate::types::*;

runtime_tracing/src/tracer.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -254,33 +254,29 @@ impl Tracer {
254254

255255
pub fn bind_variable(&mut self, variable_name: &str, place: Place) {
256256
let variable_id = self.ensure_variable_id(variable_name);
257-
self.events.push(TraceLowLevelEvent::BindVariable(crate::BindVariableRecord {
258-
variable_id,
259-
place,
260-
}));
257+
self.events
258+
.push(TraceLowLevelEvent::BindVariable(crate::BindVariableRecord { variable_id, place }));
261259
}
262260

263261
pub fn drop_variables(&mut self, variable_names: &[String]) {
264-
let variable_ids : Vec<VariableId> = variable_names
262+
let variable_ids: Vec<VariableId> = variable_names
265263
.to_vec()
266264
.iter()
267-
.map(| variable_name | self.ensure_variable_id(variable_name))
265+
.map(|variable_name| self.ensure_variable_id(variable_name))
268266
.collect();
269-
self.events.push(TraceLowLevelEvent::DropVariables(
270-
variable_ids
271-
))
267+
self.events.push(TraceLowLevelEvent::DropVariables(variable_ids))
272268
}
273269

274270
pub fn simple_rvalue(&mut self, variable_name: &str) -> RValue {
275271
let variable_id = self.ensure_variable_id(variable_name);
276272
RValue::Simple(variable_id)
277273
}
278-
274+
279275
pub fn compound_rvalue(&mut self, variable_dependencies: &[String]) -> RValue {
280-
let variable_ids : Vec<VariableId> = variable_dependencies
276+
let variable_ids: Vec<VariableId> = variable_dependencies
281277
.to_vec()
282278
.iter()
283-
.map(| variable_dependency | self.ensure_variable_id(variable_dependency))
279+
.map(|variable_dependency| self.ensure_variable_id(variable_dependency))
284280
.collect();
285281
RValue::Compound(variable_ids)
286282
}

runtime_tracing/src/types.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use std::path::PathBuf;
99
use num_derive::FromPrimitive;
1010
use serde::{Deserialize, Serialize};
1111
use serde_repr::*;
12+
use crate::base64;
1213

1314
// currently, we do assume that we record the whole program
1415
// so, we try to include minimal amount of data,
@@ -386,6 +387,12 @@ pub enum ValueRecord {
386387
Cell {
387388
place: Place,
388389
},
390+
BigInt {
391+
#[serde(with = "base64")]
392+
b: Vec<u8>, // Base64 encoded bytes of a big-endian unsigned integer
393+
negative: bool,
394+
type_id: TypeId,
395+
},
389396
}
390397

391398
/// Categories of types recorded in the trace.

0 commit comments

Comments
 (0)