Commit b754068fbc

David CARLIER <devnexen@gmail.com>
2023-05-15 22:04:21
std.c: add ptrace for freebsd support.
1 parent 87c7ef3
Changed files (1)
lib
lib/std/c/freebsd.zig
@@ -2704,3 +2704,117 @@ pub const RF = struct {
 };
 
 pub extern "c" fn rfork(flags: c_int) c_int;
+
+pub const PTRACE = struct {
+    pub const EXC = 0x0001;
+    pub const SCE = 0x0002;
+    pub const SCX = 0x0004;
+    pub const SYSCALL = (PTRACE.SCE | PTRACE.SCX);
+    pub const FORK = 0x0008;
+    pub const LWP = 0x0010;
+    pub const VFORK = 0x0020;
+    pub const DEFAULT = PTRACE.EXEC;
+};
+
+pub const PT = struct {
+    pub const TRACE_ME = 0;
+    pub const READ_I = 1;
+    pub const READ_D = 2;
+    pub const WRITE_I = 4;
+    pub const WRITE_D = 5;
+    pub const CONTINUE = 7;
+    pub const KILL = 8;
+    pub const STEP = 9;
+    pub const ATTACH = 10;
+    pub const DETACH = 11;
+    pub const IO = 12;
+    pub const LWPINFO = 13;
+    pub const GETNUMLWPS = 14;
+    pub const GETLWPLIST = 15;
+    pub const CLEARSTEP = 16;
+    pub const SETSTEP = 17;
+    pub const SUSPEND = 18;
+    pub const RESUME = 19;
+    pub const TO_SCE = 20;
+    pub const TO_SCX = 21;
+    pub const SYSCALL = 22;
+    pub const FOLLOW_FORK = 23;
+    pub const LWP_EVENTS = 24;
+    pub const GET_EVENT_MASK = 25;
+    pub const SET_EVENT_MASK = 26;
+    pub const GET_SC_ARGS = 27;
+    pub const GET_SC_RET = 28;
+    pub const COREDUMP = 29;
+    pub const GETREGS = 33;
+    pub const SETREGS = 34;
+    pub const GETFPREGS = 35;
+    pub const SETFPREGS = 36;
+    pub const GETDBREGS = 37;
+    pub const SETDBREGS = 38;
+    pub const VM_TIMESTAMP = 40;
+    pub const VM_ENTRY = 41;
+    pub const GETREGSET = 42;
+    pub const SETREGSET = 43;
+    pub const SC_REMOTE = 44;
+    pub const FIRSTMACH = 64;
+};
+
+pub const ptrace_io_desc = extern struct {
+    op: c_int,
+    offs: ?*anyopaque,
+    addr: ?*anyopaque,
+    len: usize,
+};
+
+pub const PIOD = struct {
+    pub const READ_D = 1;
+    pub const WRITE_D = 2;
+    pub const READ_I = 3;
+    pub const WRITE_I = 4;
+};
+
+pub const ptrace_lwpinfo = extern struct {
+    lwpid: lwpid_t,
+    event: c_int,
+    flags: c_int,
+    sigmask: sigset_t,
+    siglist: sigset_t,
+    siginfo: siginfo_t,
+    tdname: [MAXCOMLEN + 1]u8,
+    child_pid: pid_t,
+    syscall_code: c_uint,
+    syscall_narg: c_uint,
+};
+
+pub const ptrace_sc_ret = extern struct {
+    retval: [2]isize,
+    err: c_int,
+};
+
+pub const ptrace_vm_entry = extern struct {
+    entry: c_int,
+    timestamp: c_int,
+    start: c_ulong,
+    end: c_ulong,
+    offset: c_ulong,
+    prot: c_uint,
+    pathlen: c_uint,
+    fileid: c_long,
+    fsid: u32,
+    pve_path: ?[*:0]u8,
+};
+
+pub const ptrace_coredump = extern struct {
+    fd: c_int,
+    flags: u32,
+    limit: isize,
+};
+
+pub const ptrace_cs_remote = extern struct {
+    ret: ptrace_sc_ret,
+    syscall: c_uint,
+    nargs: c_uint,
+    args: *isize,
+};
+
+pub extern "c" fn ptrace(request: c_int, pid: pid_t, addr: [*:0]u8, data: c_int) c_int;