[gdb/record] Support recording syscall accept4

While reviewing the enum gdb_syscall entries with values >= 500, I noticed
that gdb_sys_accept exists, but gdb_sys_accept4 doesn't, while recording
support is essentially the same, given that the difference in interface is
only an extra int parameter:
...
int accept (int sockfd, struct sockaddr *addr, socklen_t *addrlen);
int accept4 (int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags);
...

Fix this by:
- adding gdb_sys_accept4,
- supporting it in record_linux_system_call alongside gdb_sys_accept, and
- mapping to gdb_sys_accept4 in various syscall canonicalization functions.

The usual thing to do before the rewrite of i386_canonicalize_syscall would
have been to use the value from arch/x86/entry/syscalls/syscall_32.tbl:
...
  gdb_sys_accept4 = 364,
...
but that's no longer necessary, so instead we use some >= 500 value:
...
  gdb_sys_accept4 = 533,
...
to steer clear of the space where ppc_canonicalize_syscall and
s390_canonicalize_syscall do hard-coded number magic.

Tested on x86_64-linux, with and without target board unix/-m32, and
aarch64-linux.

Approved-By: Guinevere Larsen <guinevere@redhat.com>
This commit is contained in:
Tom de Vries
2025-03-13 07:41:51 +01:00
parent fbfb29b304
commit f9f0332200
8 changed files with 13 additions and 3 deletions

View File

@@ -2291,7 +2291,7 @@ aarch64_canonicalize_syscall (enum aarch64_syscall syscall_number)
SYSCALL_MAP (move_pages);
UNSUPPORTED_SYSCALL_MAP (rt_tgsigqueueinfo);
UNSUPPORTED_SYSCALL_MAP (perf_event_open);
UNSUPPORTED_SYSCALL_MAP (accept4);
SYSCALL_MAP (accept4);
UNSUPPORTED_SYSCALL_MAP (recvmmsg);
SYSCALL_MAP (wait4);

View File

@@ -556,6 +556,10 @@ amd64_canonicalize_syscall (enum amd64_syscall syscall_number)
case amd64_x32_sys_accept:
return gdb_sys_accept;
case amd64_sys_accept4:
case amd64_x32_sys_accept4:
return gdb_sys_accept4;
case amd64_sys_sendto:
case amd64_x32_sys_sendto:
return gdb_sys_sendto;

View File

@@ -302,6 +302,7 @@ enum amd64_syscall {
amd64_sys_sync_file_range = 277,
amd64_sys_vmsplice = 278,
amd64_sys_move_pages = 279,
amd64_sys_accept4 = 288,
amd64_sys_pipe2 = 293,
amd64_sys_getrandom = 318
};
@@ -553,6 +554,7 @@ enum amd64_x32_syscall {
amd64_x32_sys_splice = (amd64_x32_syscall_bit + 275),
amd64_x32_sys_tee = (amd64_x32_syscall_bit + 276),
amd64_x32_sys_sync_file_range = (amd64_x32_syscall_bit + 277),
amd64_x32_sys_accept4 = (amd64_x32_syscall_bit + 288),
amd64_x32_sys_rt_sigaction = (amd64_x32_syscall_bit + 512),
amd64_x32_sys_rt_sigreturn = (amd64_x32_syscall_bit + 513),
amd64_x32_sys_ioctl = (amd64_x32_syscall_bit + 514),

View File

@@ -1629,7 +1629,9 @@ arm_canonicalize_syscall (int syscall)
case 363: return gdb_sys_rt_tgsigqueueinfo;
case 364: return gdb_sys_perf_event_open;
case 365: return gdb_sys_recvmmsg;
*/
case 366: return gdb_sys_accept4;
/*
case 367: return gdb_sys_fanotify_init;
case 368: return gdb_sys_fanotify_mark;
case 369: return gdb_sys_prlimit64;

View File

@@ -764,7 +764,7 @@ i386_canonicalize_syscall (int syscall)
SYSCALL_MAP (bind);
SYSCALL_MAP (connect);
SYSCALL_MAP (listen);
UNSUPPORTED_SYSCALL_MAP (accept4);
SYSCALL_MAP (accept4);
SYSCALL_MAP (getsockopt);
SYSCALL_MAP (setsockopt);
SYSCALL_MAP (getsockname);

View File

@@ -725,6 +725,7 @@ Do you want to stop the program?"),
break;
case gdb_sys_accept:
case gdb_sys_accept4:
case gdb_sys_getsockname:
case gdb_sys_getpeername:
{

View File

@@ -541,6 +541,7 @@ enum gdb_syscall {
gdb_sys_msgrcv = 530,
gdb_sys_msgctl = 531,
gdb_sys_semtimedop = 532,
gdb_sys_accept4 = 533,
gdb_sys_newfstatat = 540,
};

View File

@@ -828,7 +828,7 @@ loongarch_canonicalize_syscall (enum loongarch_syscall syscall_number)
SYSCALL_MAP (move_pages);
UNSUPPORTED_SYSCALL_MAP (rt_tgsigqueueinfo);
UNSUPPORTED_SYSCALL_MAP (perf_event_open);
UNSUPPORTED_SYSCALL_MAP (accept4);
SYSCALL_MAP (accept4);
UNSUPPORTED_SYSCALL_MAP (recvmmsg);
SYSCALL_MAP (wait4);
UNSUPPORTED_SYSCALL_MAP (prlimit64);