Skip to content

ptrace_coredump ptrace query addition for FreeBSD 14. #2574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2136,6 +2136,9 @@ fn test_freebsd(target: &str) {
true
}

// Added in FreeBSD 14.
"PT_COREDUMP" | "PC_ALL" | "PC_COMPRESS" if Some(14) > freebsd_ver => true,

_ => false,
}
});
Expand Down Expand Up @@ -2170,6 +2173,9 @@ fn test_freebsd(target: &str) {
// obsolete version
"vmtotal" if Some(11) == freebsd_ver => true,

// `ptrace_coredump` introduced in FreeBSD 14.
"ptrace_coredump" if Some(14) > freebsd_ver => true,

_ => false,
}
});
Expand Down
10 changes: 10 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ s! {
pub sr_error: ::c_int,
}

pub struct ptrace_coredump {
pub pc_fd: ::c_int,
pub pc_flags: u32,
pub pc_limit: ::off_t,
}

pub struct cpuset_t {
#[cfg(target_pointer_width = "64")]
__bits: [::c_long; 4],
Expand Down Expand Up @@ -1948,6 +1954,7 @@ pub const PT_GET_EVENT_MASK: ::c_int = 25;
pub const PT_SET_EVENT_MASK: ::c_int = 26;
pub const PT_GET_SC_ARGS: ::c_int = 27;
pub const PT_GET_SC_RET: ::c_int = 28;
pub const PT_COREDUMP: ::c_int = 29;
pub const PT_GETREGS: ::c_int = 33;
pub const PT_SETREGS: ::c_int = 34;
pub const PT_GETFPREGS: ::c_int = 35;
Expand All @@ -1967,6 +1974,9 @@ pub const PTRACE_LWP: ::c_int = 0x0010;
pub const PTRACE_VFORK: ::c_int = 0x0020;
pub const PTRACE_DEFAULT: ::c_int = PTRACE_EXEC;

pub const PC_COMPRESS: u32 = 0x00000001;
pub const PC_ALL: u32 = 0x00000002;

pub const PROC_SPROTECT: ::c_int = 1;
pub const PROC_REAP_ACQUIRE: ::c_int = 2;
pub const PROC_REAP_RELEASE: ::c_int = 3;
Expand Down