Skip to content

Commit 9fabd40

Browse files
committed
std.os.linux: add ptrace
1 parent 0750495 commit 9fabd40

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

lib/std/os/linux.zig

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,6 +1820,23 @@ pub fn seccomp(operation: u32, flags: u32, args: ?*const anyopaque) usize {
18201820
return syscall3(.seccomp, operation, flags, @ptrToInt(args));
18211821
}
18221822

1823+
pub fn ptrace(
1824+
req: u32,
1825+
pid: pid_t,
1826+
addr: usize,
1827+
data: usize,
1828+
addr2: usize,
1829+
) usize {
1830+
return syscall5(
1831+
.ptrace,
1832+
req,
1833+
@bitCast(usize, @as(isize, pid)),
1834+
addr,
1835+
data,
1836+
addr2,
1837+
);
1838+
}
1839+
18231840
pub const E = switch (native_arch) {
18241841
.mips, .mipsel => @import("linux/errno/mips.zig").E,
18251842
.sparc, .sparcel, .sparc64 => @import("linux/errno/sparc.zig").E,
@@ -5721,3 +5738,40 @@ pub const AUDIT = struct {
57215738
}
57225739
};
57235740
};
5741+
5742+
pub const PTRACE = struct {
5743+
pub const TRACEME = 0;
5744+
pub const PEEKTEXT = 1;
5745+
pub const PEEKDATA = 2;
5746+
pub const PEEKUSER = 3;
5747+
pub const POKETEXT = 4;
5748+
pub const POKEDATA = 5;
5749+
pub const POKEUSER = 6;
5750+
pub const CONT = 7;
5751+
pub const KILL = 8;
5752+
pub const SINGLESTEP = 9;
5753+
pub const GETREGS = 12;
5754+
pub const SETREGS = 13;
5755+
pub const GETFPREGS = 14;
5756+
pub const SETFPREGS = 15;
5757+
pub const ATTACH = 16;
5758+
pub const DETACH = 17;
5759+
pub const GETFPXREGS = 18;
5760+
pub const SETFPXREGS = 19;
5761+
pub const SYSCALL = 24;
5762+
pub const SETOPTIONS = 0x4200;
5763+
pub const GETEVENTMSG = 0x4201;
5764+
pub const GETSIGINFO = 0x4202;
5765+
pub const SETSIGINFO = 0x4203;
5766+
pub const GETREGSET = 0x4204;
5767+
pub const SETREGSET = 0x4205;
5768+
pub const SEIZE = 0x4206;
5769+
pub const INTERRUPT = 0x4207;
5770+
pub const LISTEN = 0x4208;
5771+
pub const PEEKSIGINFO = 0x4209;
5772+
pub const GETSIGMASK = 0x420a;
5773+
pub const SETSIGMASK = 0x420b;
5774+
pub const SECCOMP_GET_FILTER = 0x420c;
5775+
pub const SECCOMP_GET_METADATA = 0x420d;
5776+
pub const GET_SYSCALL_INFO = 0x420e;
5777+
};

0 commit comments

Comments
 (0)