linux add ptrace_syscall_info ptrace query.

closes #1920
This commit is contained in:
David Carlier 2021-11-13 09:22:09 +00:00
parent 52382d65fb
commit 1dd86b2d91
11 changed files with 90 additions and 1 deletions

View file

@ -3325,7 +3325,9 @@ fn test_linux(target: &str) {
// FIXME: It now takes mode_t since glibc 2.31 on some targets.
(struct_ == "ipc_perm" && field == "mode"
&& ((x86_64 || i686 || arm || riscv64) && gnu || x86_64_gnux32)
)
) ||
// the `u` field is in fact an anonymous union
(gnu && struct_ == "ptrace_syscall_info" && (field == "u" || field == "pad"))
});
cfg.skip_roundtrip(move |s| match s {

View file

@ -350,6 +350,7 @@ PF_MPLS
PF_XDP
PROC_SUPER_MAGIC
PTHREAD_MUTEX_ADAPTIVE_NP
PTRACE_GET_SYSCALL_INFO
QNX4_SUPER_MAGIC
QNX6_SUPER_MAGIC
RDTGROUP_SUPER_MAGIC
@ -617,6 +618,7 @@ pthread_rwlockattr_getpshared
pthread_rwlockattr_setkind_np
pthread_setname_np
ptrace_peeksiginfo_args
ptrace_syscall_info
pututxline
pwritev2
pwritev64

View file

@ -11,6 +11,7 @@ pub type msgqnum_t = ::c_ulong;
pub type msglen_t = ::c_ulong;
pub type nlink_t = u32;
pub type __u64 = ::c_ulonglong;
pub type __s64 = ::c_longlong;
pub type __fsword_t = i32;
pub type fsblkcnt64_t = u64;
pub type fsfilcnt64_t = u64;

View file

@ -6,6 +6,7 @@ pub type nlink_t = u32;
pub type blksize_t = i32;
pub type suseconds_t = i64;
pub type __u64 = ::c_ulonglong;
pub type __s64 = ::c_longlong;
s! {
pub struct sigaction {

View file

@ -8,6 +8,7 @@ pub type nlink_t = u64;
pub type suseconds_t = i64;
pub type wchar_t = i32;
pub type __u64 = ::c_ulong;
pub type __s64 = ::c_long;
s! {
pub struct stat {

View file

@ -10,6 +10,7 @@ pub type nlink_t = u64;
pub type blksize_t = i64;
pub type suseconds_t = i64;
pub type __u64 = ::c_ulong;
pub type __s64 = ::c_long;
s! {
pub struct sigaction {

View file

@ -11,6 +11,7 @@ pub type fsblkcnt64_t = ::c_ulong;
pub type fsfilcnt64_t = ::c_ulong;
pub type suseconds_t = i64;
pub type __u64 = ::c_ulonglong;
pub type __s64 = ::c_longlong;
s! {
pub struct pthread_attr_t {

View file

@ -11,6 +11,7 @@ pub type suseconds_t = i64;
pub type wchar_t = i32;
pub type greg_t = u64;
pub type __u64 = u64;
pub type __s64 = i64;
s! {
pub struct sigaction {

View file

@ -10,6 +10,7 @@ pub type nlink_t = u32;
pub type blksize_t = i64;
pub type suseconds_t = i32;
pub type __u64 = ::c_ulonglong;
pub type __s64 = ::c_longlong;
s! {
pub struct sigaction {

View file

@ -7,6 +7,7 @@ pub type blksize_t = i64;
pub type greg_t = i64;
pub type suseconds_t = i64;
pub type __u64 = ::c_ulonglong;
pub type __s64 = ::c_longlong;
s! {
pub struct sigaction {

View file

@ -324,6 +324,32 @@ s! {
pub flags: ::__u32,
pub nr: ::__s32,
}
pub struct __c_anonymous_ptrace_syscall_info_entry {
pub nr: ::__u64,
pub args: [::__u64; 6],
}
pub struct __c_anonymous_ptrace_syscall_info_exit {
pub sval: ::__s64,
pub is_error: ::__u8,
}
pub struct __c_anonymous_ptrace_syscall_info_seccomp {
pub nr: ::__u64,
pub args: [::__u64; 6],
pub ret_data: ::__u32,
}
pub struct ptrace_syscall_info {
pub op: ::__u8,
pub pad: [::__u8; 3],
pub arch: ::__u32,
pub instruction_pointer: ::__u64,
pub stack_pointer: ::__u64,
#[cfg(libc_union)]
pub u: __c_anonymous_ptrace_syscall_info_data,
}
}
impl siginfo_t {
@ -411,6 +437,18 @@ cfg_if! {
self.sifields().sigchld.si_stime
}
}
pub union __c_anonymous_ptrace_syscall_info_data {
pub entry: __c_anonymous_ptrace_syscall_info_entry,
pub exit: __c_anonymous_ptrace_syscall_info_exit,
pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp,
}
impl ::Copy for __c_anonymous_ptrace_syscall_info_data {}
impl ::Clone for __c_anonymous_ptrace_syscall_info_data {
fn clone(&self) -> __c_anonymous_ptrace_syscall_info_data {
*self
}
}
}
}
@ -509,6 +547,44 @@ cfg_if! {
self.__glibc_reserved.hash(state);
}
}
#[cfg(libc_union)]
impl PartialEq for __c_anonymous_ptrace_syscall_info_data {
fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool {
unsafe {
self.entry == other.entry ||
self.exit == other.exit ||
self.seccomp == other.seccomp
}
}
}
#[cfg(libc_union)]
impl Eq for __c_anonymous_ptrace_syscall_info_data {}
#[cfg(libc_union)]
impl ::fmt::Debug for __c_anonymous_ptrace_syscall_info_data {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
unsafe {
f.debug_struct("__c_anonymous_ptrace_syscall_info_data")
.field("entry", &self.entry)
.field("exit", &self.exit)
.field("seccomp", &self.seccomp)
.finish()
}
}
}
#[cfg(libc_union)]
impl ::hash::Hash for __c_anonymous_ptrace_syscall_info_data {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
unsafe {
self.entry.hash(state);
self.exit.hash(state);
self.seccomp.hash(state);
}
}
}
}
}
@ -906,6 +982,7 @@ pub const PTRACE_SEIZE: ::c_uint = 0x4206;
pub const PTRACE_INTERRUPT: ::c_uint = 0x4207;
pub const PTRACE_LISTEN: ::c_uint = 0x4208;
pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209;
pub const PTRACE_GET_SYSCALL_INFO: ::c_uint = 0x420e;
// linux/fs.h