https://bugs.gentoo.org/897874 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109420 https://github.com/rr-debugger/rr/issues/3485 https://github.com/rr-debugger/rr/commit/e32502d00b18a5225d3b7fbab75fb1e63cb367d2 From e32502d00b18a5225d3b7fbab75fb1e63cb367d2 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Wed, 5 Apr 2023 08:15:23 +1200 Subject: [PATCH] Avoid having type members and enum members of `Arch` with the same name Resolves #3485 --- a/src/kernel_abi.h +++ b/src/kernel_abi.h @@ -1282,7 +1282,7 @@ struct BaseArch : public wordsize, }; RR_VERIFY_TYPE_EXPLICIT(struct ::timezone, timezone); - struct statfs { + struct statfs_t { __statfs_word f_type; __statfs_word f_bsize; __statfs_word f_blocks; @@ -1298,9 +1298,9 @@ struct BaseArch : public wordsize, __statfs_word f_flags; __statfs_word f_spare[4]; }; - RR_VERIFY_TYPE_EXPLICIT(struct ::statfs, statfs); + RR_VERIFY_TYPE_EXPLICIT(struct ::statfs, statfs_t); - struct statfs64 { + struct statfs64_t { __statfs_word f_type; __statfs_word f_bsize; uint64_t f_blocks; @@ -1316,7 +1316,7 @@ struct BaseArch : public wordsize, __statfs_word f_flags; __statfs_word f_spare[4]; }; - RR_VERIFY_TYPE_EXPLICIT(struct ::statfs64, statfs64); + RR_VERIFY_TYPE_EXPLICIT(struct ::statfs64, statfs64_t); struct itimerval { timeval it_interval; @@ -1338,7 +1338,7 @@ struct BaseArch : public wordsize, } stack_t; RR_VERIFY_TYPE(stack_t); - struct sysinfo { + struct sysinfo_t { __kernel_long_t uptime; __kernel_ulong_t loads[3]; __kernel_ulong_t totalram; @@ -1355,7 +1355,7 @@ struct BaseArch : public wordsize, uint32_t mem_unit; char _f[20 - 2 * sizeof(__kernel_ulong_t) - sizeof(uint32_t)]; }; - RR_VERIFY_TYPE_EXPLICIT(struct ::sysinfo, sysinfo); + RR_VERIFY_TYPE_EXPLICIT(struct ::sysinfo, sysinfo_t); static const ::size_t UTSNAME_LENGTH = 65; struct utsname { @@ -2093,7 +2093,7 @@ struct X64Arch : public BaseArch { // Can't verify this one because glibc leaves out the last two members and the // kernel header isn't available to userspace. - struct stat { + struct stat_t { dev_t st_dev; ino_t st_ino; nlink_t st_nlink; @@ -2110,10 +2110,10 @@ struct X64Arch : public BaseArch { struct timespec st_ctim; syscall_slong_t __rr_unused[3]; }; - RR_VERIFY_TYPE_ARCH(SupportedArch::x86_64, struct ::stat, struct stat); + RR_VERIFY_TYPE_ARCH(SupportedArch::x86_64, struct ::stat, struct stat_t); - struct stat64 : public stat {}; - RR_VERIFY_TYPE_ARCH(SupportedArch::x86_64, struct ::stat64, struct stat64); + struct stat64_t : public stat_t {}; + RR_VERIFY_TYPE_ARCH(SupportedArch::x86_64, struct ::stat64, struct stat64_t); struct semid64_ds { ipc64_perm sem_perm; @@ -2291,7 +2291,7 @@ struct X86Arch : public BaseArch { }; RR_VERIFY_TYPE_X86_ARCH(SupportedArch::x86, ::user, user); - struct stat { + struct stat_t { dev_t st_dev; unsigned_short __pad1; ino_t st_ino; @@ -2310,9 +2310,9 @@ struct X86Arch : public BaseArch { unsigned_long __unused4; unsigned_long __unused5; }; - RR_VERIFY_TYPE_ARCH(SupportedArch::x86, struct ::stat, struct stat); + RR_VERIFY_TYPE_ARCH(SupportedArch::x86, struct ::stat, struct stat_t); - struct __attribute__((packed)) stat64 { + struct __attribute__((packed)) stat64_t { dev_t st_dev; unsigned_int __pad1; ino_t __st_ino; @@ -2330,7 +2330,7 @@ struct X86Arch : public BaseArch { timespec st_ctim; ino64_t st_ino; }; - RR_VERIFY_TYPE_ARCH(SupportedArch::x86, struct ::stat64, struct stat64); + RR_VERIFY_TYPE_ARCH(SupportedArch::x86, struct ::stat64, struct stat64_t); struct semid64_ds { ipc64_perm sem_perm; @@ -2377,7 +2377,7 @@ struct GenericArch : public BaseArch { typedef uint32_t legacy_uid_t; typedef uint32_t legacy_gid_t; - struct stat { + struct stat_t { dev_t st_dev; ino_t st_ino; mode_t st_mode; @@ -2405,7 +2405,7 @@ struct GenericArch : public BaseArch { typename BaseArch::unsigned_long __unused4; }; - struct stat64 : public stat {}; + struct stat64_t : public stat_t {}; }; struct ARM64Arch : public GenericArch { --- a/src/syscalls.py +++ b/src/syscalls.py @@ -544,7 +544,7 @@ def __init__(self, **kwargs): # system. path is the pathname of any file within the mounted file # system. buf is a pointer to a statfs structure defined # approximately as follows: -statfs = EmulatedSyscall(x86=99, x64=137, generic=43, arg2="struct Arch::statfs") +statfs = EmulatedSyscall(x86=99, x64=137, generic=43, arg2="struct Arch::statfs_t") # int fstatfs(int fd, struct statfs *buf) # @@ -552,7 +552,7 @@ def __init__(self, **kwargs): # system. path is the pathname of any file within the # get_time(GET_TID(thread_id));mounted file system. buf is a pointer # to a statfs structure defined approximately as follows: -fstatfs = EmulatedSyscall(x86=100, x64=138, generic=44, arg2="struct Arch::statfs") +fstatfs = EmulatedSyscall(x86=100, x64=138, generic=44, arg2="struct Arch::statfs_t") ioperm = EmulatedSyscall(x86=101, x64=173) @@ -574,9 +574,9 @@ def __init__(self, **kwargs): # stored there. setitimer = EmulatedSyscall(x86=104, x64=38, generic=103, arg3="typename Arch::itimerval") getitimer = EmulatedSyscall(x86=105, x64=36, generic=102, arg2="typename Arch::itimerval") -stat = EmulatedSyscall(x86=106, x64=4, arg2="struct Arch::stat") -lstat = EmulatedSyscall(x86=107, x64=6, arg2="struct Arch::stat") -fstat = EmulatedSyscall(x86=108, x64=5, generic=80, arg2="struct Arch::stat") +stat = EmulatedSyscall(x86=106, x64=4, arg2="struct Arch::stat_t") +lstat = EmulatedSyscall(x86=107, x64=6, arg2="struct Arch::stat_t") +fstat = EmulatedSyscall(x86=108, x64=5, generic=80, arg2="struct Arch::stat_t") olduname = UnsupportedSyscall(x86=109) iopl = EmulatedSyscall(x86=110, x64=172) vhangup = UnsupportedSyscall(x86=111, x64=153, generic=58) @@ -596,7 +596,7 @@ def __init__(self, **kwargs): # # sysinfo() provides a simple way of getting overall system # statistics. -sysinfo = EmulatedSyscall(x86=116, x64=99, generic=179, arg1="struct Arch::sysinfo") +sysinfo = EmulatedSyscall(x86=116, x64=99, generic=179, arg1="struct Arch::sysinfo_t") # int ipc(unsigned int call, int first, int second, int third, void *ptr, long #fifth); # @@ -992,20 +992,20 @@ def __init__(self, **kwargs): # int stat(const char *path, struct stat *buf); # # stat() stats the file pointed to by path and fills in buf. -stat64 = EmulatedSyscall(x86=195, arg2="struct Arch::stat64") +stat64 = EmulatedSyscall(x86=195, arg2="struct Arch::stat64_t") # int lstat(const char *path, struct stat *buf); # # lstat() is identical to stat(), except that if path is a symbolic # link, then the link itself is stat-ed, not the file that it refers # to. -lstat64 = EmulatedSyscall(x86=196, arg2="struct Arch::stat64") +lstat64 = EmulatedSyscall(x86=196, arg2="struct Arch::stat64_t") # int fstat(int fd, struct stat *buf) # # fstat() is identical to stat(), except that the file to be stat-ed # is specified by the file descriptor fd. -fstat64 = EmulatedSyscall(x86=197, arg2="struct Arch::stat64") +fstat64 = EmulatedSyscall(x86=197, arg2="struct Arch::stat64_t") lchown32 = EmulatedSyscall(x86=198) @@ -1342,8 +1342,8 @@ def __init__(self, **kwargs): # # FIXME: we use arg3() here, although according to man pages this system # call has only 2 paramaters. However, strace tells another story... -statfs64 = EmulatedSyscall(x86=268, arg3="struct Arch::statfs64") -fstatfs64 = EmulatedSyscall(x86=269, arg3="struct Arch::statfs64") +statfs64 = EmulatedSyscall(x86=268, arg3="struct Arch::statfs64_t") +fstatfs64 = EmulatedSyscall(x86=269, arg3="struct Arch::statfs64_t") # int tgkill(int tgid, int tid, int sig) # @@ -1443,8 +1443,8 @@ def __init__(self, **kwargs): # The fstatat() system call operates in exactly the same way as # stat(2), except for the differences described in this manual # page.... -fstatat = EmulatedSyscall(x64=262, generic=79, arg3="struct Arch::stat") -fstatat64 = EmulatedSyscall(x86=300, arg3="struct Arch::stat64") +fstatat = EmulatedSyscall(x64=262, generic=79, arg3="struct Arch::stat_t") +fstatat64 = EmulatedSyscall(x86=300, arg3="struct Arch::stat64_t") # int unlinkat(int dirfd, const char *pathname, int flags) #