diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 14:35:56 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 14:39:55 -0300 |
| commit | 97ce7f485fc0419df693fdf16d634e9e9a6085fc (patch) | |
| tree | 9d36463512024242665c7836b94a4de4e541b3bf /src/trace/ptrace.zig | |
| parent | f8740f6996eefc235af066a6686f52847c158a6b (diff) | |
| download | computeranim-97ce7f485fc0419df693fdf16d634e9e9a6085fc.tar.gz computeranim-97ce7f485fc0419df693fdf16d634e9e9a6085fc.zip | |
context: what an instruction is about to touch, and the call chain
At a stop the instruction at the pc is decoded against the registers it
will run with (capstone's operands): a touch event for each memory operand
(address, size, read or write), what is there recorded with it, and what a
write left there read back at the next stop. An instruction-level
recording so has every memory write of the stepped thread, nothing watched.
The frames of the call chain are recorded and their return addresses
named; telescope.backtrace walks them from the recording and ztrace show
prints them. Process.read no longer panics on address 0.
Diffstat (limited to 'src/trace/ptrace.zig')
| -rw-r--r-- | src/trace/ptrace.zig | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/trace/ptrace.zig b/src/trace/ptrace.zig index ca3dc39..0e60c13 100644 --- a/src/trace/ptrace.zig +++ b/src/trace/ptrace.zig @@ -190,6 +190,8 @@ pub const Process = struct { /// The target's memory in one syscall, however long. Returns the bytes /// read: short where the range leaves mapped memory. pub fn read(p: *const Process, addr: u64, buf: []u8) usize { + // Nothing is mapped at 0, and a pointer type cannot say 0. + if (addr == 0 or buf.len == 0) return 0; const local = [1]std.posix.iovec{.{ .base = buf.ptr, .len = buf.len }}; const remote = [1]std.posix.iovec_const{.{ .base = @ptrFromInt(addr), .len = buf.len }}; const rc = linux.process_vm_readv(p.pid, &local, &remote, 0); |
