Skip to content

Commit 2331008

Browse files
committed
Stage 0 and Stage 1
codetracer-python-recorder/src/ffi.rs: codetracer-python-recorder/src/runtime/frame_inspector.rs: codetracer-python-recorder/src/runtime/mod.rs: codetracer-python-recorder/src/runtime/thread_snapshots.rs: codetracer-python-recorder/src/runtime/trace_writer_host.rs: codetracer-python-recorder/src/session.rs: design-docs/capture-output-implementation-plan.status.md: Signed-off-by: Tzanko Matev <[email protected]>
1 parent f16a748 commit 2331008

File tree

12 files changed

+1495
-81
lines changed

12 files changed

+1495
-81
lines changed

codetracer-python-recorder/Cargo.lock

Lines changed: 41 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codetracer-python-recorder/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,22 @@ serde = { version = "1.0", features = ["derive"] }
3131
serde_json = "1.0"
3232
uuid = { version = "1.10", features = ["v4"] }
3333
recorder-errors = { version = "0.1.0", path = "crates/recorder-errors" }
34+
crossbeam-channel = "0.5"
35+
libc = "0.2"
3436

3537
[dev-dependencies]
3638
pyo3 = { version = "0.25.1", features = ["auto-initialize"] }
3739
tempfile = "3.10"
40+
41+
[target.'cfg(unix)'.dev-dependencies]
42+
os_pipe = "1.2"
43+
44+
[target.'cfg(windows)'.dependencies]
45+
windows-sys = { version = "0.59", features = [
46+
"Win32_Foundation",
47+
"Win32_System_IO",
48+
"Win32_System_Pipes",
49+
"Win32_System_Threading",
50+
"Win32_System_WindowsProgramming",
51+
"Win32_Storage_FileSystem",
52+
] }

codetracer-python-recorder/src/ffi.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,9 @@ mod tests {
145145
#[test]
146146
fn map_recorder_error_sets_python_attributes() {
147147
Python::with_gil(|py| {
148-
let err = usage!(
149-
ErrorCode::UnsupportedFormat,
150-
"invalid trace format"
151-
)
152-
.with_context("format", "yaml")
153-
.with_source(std::io::Error::new(std::io::ErrorKind::Other, "boom"));
148+
let err = usage!(ErrorCode::UnsupportedFormat, "invalid trace format")
149+
.with_context("format", "yaml")
150+
.with_source(std::io::Error::new(std::io::ErrorKind::Other, "boom"));
154151
let pyerr = map_recorder_error(err);
155152
let ty = pyerr.get_type(py);
156153
assert!(ty.is(py.get_type::<PyUsageError>()));
@@ -191,9 +188,8 @@ mod tests {
191188
#[test]
192189
fn dispatch_converts_recorder_error_to_pyerr() {
193190
Python::with_gil(|py| {
194-
let result: PyResult<()> = dispatch("dispatch_env", || {
195-
Err(enverr!(ErrorCode::Io, "disk full"))
196-
});
191+
let result: PyResult<()> =
192+
dispatch("dispatch_env", || Err(enverr!(ErrorCode::Io, "disk full")));
197193
let err = result.expect_err("expected PyErr");
198194
let ty = err.get_type(py);
199195
assert!(ty.is(py.get_type::<PyEnvironmentError>()));

codetracer-python-recorder/src/runtime/frame_inspector.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ impl<'py> FrameSnapshot<'py> {
4040
pub fn locals_is_globals(&self) -> bool {
4141
self.locals_is_globals
4242
}
43+
44+
/// Return a stable identifier for the captured frame.
45+
pub fn frame_id(&self) -> usize {
46+
self.frame_ptr as usize
47+
}
4348
}
4449

4550
impl<'py> Drop for FrameSnapshot<'py> {

0 commit comments

Comments
 (0)