Skip to content

Commit 4c7c337

Browse files
committed
Auto merge of #2606 - devnexen:ptrace_get_syscall_info_linux_gnu, r=Amanieu
linux add ptrace_syscall_info ptrace query. closes #1920
2 parents fd48bbb + 1dd86b2 commit 4c7c337

File tree

11 files changed

+90
-1
lines changed

11 files changed

+90
-1
lines changed

libc-test/build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,9 @@ fn test_linux(target: &str) {
33253325
// FIXME: It now takes mode_t since glibc 2.31 on some targets.
33263326
(struct_ == "ipc_perm" && field == "mode"
33273327
&& ((x86_64 || i686 || arm || riscv64) && gnu || x86_64_gnux32)
3328-
)
3328+
) ||
3329+
// the `u` field is in fact an anonymous union
3330+
(gnu && struct_ == "ptrace_syscall_info" && (field == "u" || field == "pad"))
33293331
});
33303332

33313333
cfg.skip_roundtrip(move |s| match s {

libc-test/semver/linux-gnu.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ PF_MPLS
350350
PF_XDP
351351
PROC_SUPER_MAGIC
352352
PTHREAD_MUTEX_ADAPTIVE_NP
353+
PTRACE_GET_SYSCALL_INFO
353354
QNX4_SUPER_MAGIC
354355
QNX6_SUPER_MAGIC
355356
RDTGROUP_SUPER_MAGIC
@@ -617,6 +618,7 @@ pthread_rwlockattr_getpshared
617618
pthread_rwlockattr_setkind_np
618619
pthread_setname_np
619620
ptrace_peeksiginfo_args
621+
ptrace_syscall_info
620622
pututxline
621623
pwritev2
622624
pwritev64

src/unix/linux_like/linux/gnu/b32/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub type msgqnum_t = ::c_ulong;
1111
pub type msglen_t = ::c_ulong;
1212
pub type nlink_t = u32;
1313
pub type __u64 = ::c_ulonglong;
14+
pub type __s64 = ::c_longlong;
1415
pub type __fsword_t = i32;
1516
pub type fsblkcnt64_t = u64;
1617
pub type fsfilcnt64_t = u64;

src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ pub type nlink_t = u32;
66
pub type blksize_t = i32;
77
pub type suseconds_t = i64;
88
pub type __u64 = ::c_ulonglong;
9+
pub type __s64 = ::c_longlong;
910

1011
s! {
1112
pub struct sigaction {

src/unix/linux_like/linux/gnu/b64/mips64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub type nlink_t = u64;
88
pub type suseconds_t = i64;
99
pub type wchar_t = i32;
1010
pub type __u64 = ::c_ulong;
11+
pub type __s64 = ::c_long;
1112

1213
s! {
1314
pub struct stat {

src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub type nlink_t = u64;
1010
pub type blksize_t = i64;
1111
pub type suseconds_t = i64;
1212
pub type __u64 = ::c_ulong;
13+
pub type __s64 = ::c_long;
1314

1415
s! {
1516
pub struct sigaction {

src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub type fsblkcnt64_t = ::c_ulong;
1111
pub type fsfilcnt64_t = ::c_ulong;
1212
pub type suseconds_t = i64;
1313
pub type __u64 = ::c_ulonglong;
14+
pub type __s64 = ::c_longlong;
1415

1516
s! {
1617
pub struct pthread_attr_t {

src/unix/linux_like/linux/gnu/b64/s390x.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub type suseconds_t = i64;
1111
pub type wchar_t = i32;
1212
pub type greg_t = u64;
1313
pub type __u64 = u64;
14+
pub type __s64 = i64;
1415

1516
s! {
1617
pub struct sigaction {

src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub type nlink_t = u32;
1010
pub type blksize_t = i64;
1111
pub type suseconds_t = i32;
1212
pub type __u64 = ::c_ulonglong;
13+
pub type __s64 = ::c_longlong;
1314

1415
s! {
1516
pub struct sigaction {

src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pub type blksize_t = i64;
77
pub type greg_t = i64;
88
pub type suseconds_t = i64;
99
pub type __u64 = ::c_ulonglong;
10+
pub type __s64 = ::c_longlong;
1011

1112
s! {
1213
pub struct sigaction {

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,32 @@ s! {
324324
pub flags: ::__u32,
325325
pub nr: ::__s32,
326326
}
327+
328+
pub struct __c_anonymous_ptrace_syscall_info_entry {
329+
pub nr: ::__u64,
330+
pub args: [::__u64; 6],
331+
}
332+
333+
pub struct __c_anonymous_ptrace_syscall_info_exit {
334+
pub sval: ::__s64,
335+
pub is_error: ::__u8,
336+
}
337+
338+
pub struct __c_anonymous_ptrace_syscall_info_seccomp {
339+
pub nr: ::__u64,
340+
pub args: [::__u64; 6],
341+
pub ret_data: ::__u32,
342+
}
343+
344+
pub struct ptrace_syscall_info {
345+
pub op: ::__u8,
346+
pub pad: [::__u8; 3],
347+
pub arch: ::__u32,
348+
pub instruction_pointer: ::__u64,
349+
pub stack_pointer: ::__u64,
350+
#[cfg(libc_union)]
351+
pub u: __c_anonymous_ptrace_syscall_info_data,
352+
}
327353
}
328354

329355
impl siginfo_t {
@@ -411,6 +437,18 @@ cfg_if! {
411437
self.sifields().sigchld.si_stime
412438
}
413439
}
440+
441+
pub union __c_anonymous_ptrace_syscall_info_data {
442+
pub entry: __c_anonymous_ptrace_syscall_info_entry,
443+
pub exit: __c_anonymous_ptrace_syscall_info_exit,
444+
pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp,
445+
}
446+
impl ::Copy for __c_anonymous_ptrace_syscall_info_data {}
447+
impl ::Clone for __c_anonymous_ptrace_syscall_info_data {
448+
fn clone(&self) -> __c_anonymous_ptrace_syscall_info_data {
449+
*self
450+
}
451+
}
414452
}
415453
}
416454

@@ -509,6 +547,44 @@ cfg_if! {
509547
self.__glibc_reserved.hash(state);
510548
}
511549
}
550+
551+
#[cfg(libc_union)]
552+
impl PartialEq for __c_anonymous_ptrace_syscall_info_data {
553+
fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool {
554+
unsafe {
555+
self.entry == other.entry ||
556+
self.exit == other.exit ||
557+
self.seccomp == other.seccomp
558+
}
559+
}
560+
}
561+
562+
#[cfg(libc_union)]
563+
impl Eq for __c_anonymous_ptrace_syscall_info_data {}
564+
565+
#[cfg(libc_union)]
566+
impl ::fmt::Debug for __c_anonymous_ptrace_syscall_info_data {
567+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
568+
unsafe {
569+
f.debug_struct("__c_anonymous_ptrace_syscall_info_data")
570+
.field("entry", &self.entry)
571+
.field("exit", &self.exit)
572+
.field("seccomp", &self.seccomp)
573+
.finish()
574+
}
575+
}
576+
}
577+
578+
#[cfg(libc_union)]
579+
impl ::hash::Hash for __c_anonymous_ptrace_syscall_info_data {
580+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
581+
unsafe {
582+
self.entry.hash(state);
583+
self.exit.hash(state);
584+
self.seccomp.hash(state);
585+
}
586+
}
587+
}
512588
}
513589
}
514590

@@ -906,6 +982,7 @@ pub const PTRACE_SEIZE: ::c_uint = 0x4206;
906982
pub const PTRACE_INTERRUPT: ::c_uint = 0x4207;
907983
pub const PTRACE_LISTEN: ::c_uint = 0x4208;
908984
pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209;
985+
pub const PTRACE_GET_SYSCALL_INFO: ::c_uint = 0x420e;
909986

910987
// linux/fs.h
911988

0 commit comments

Comments
 (0)