Automatic date update in version.in
[binutils-gdb.git] / gdb / linux-record.c
blob46ab21467b750d265edc269af28b5a33dbf48dad
1 /* Process record and replay target code for GNU/Linux.
3 Copyright (C) 2008-2023 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #include "defs.h"
21 #include "target.h"
22 #include "gdbtypes.h"
23 #include "regcache.h"
24 #include "record.h"
25 #include "record-full.h"
26 #include "linux-record.h"
27 #include "gdbarch.h"
29 /* These macros are the values of the first argument of system call
30 "sys_ptrace". The values of these macros were obtained from Linux
31 Kernel source. */
33 #define RECORD_PTRACE_PEEKTEXT 1
34 #define RECORD_PTRACE_PEEKDATA 2
35 #define RECORD_PTRACE_PEEKUSR 3
37 /* These macros are the values of the first argument of system call
38 "sys_socketcall". The values of these macros were obtained from
39 Linux Kernel source. */
41 #define RECORD_SYS_SOCKET 1
42 #define RECORD_SYS_BIND 2
43 #define RECORD_SYS_CONNECT 3
44 #define RECORD_SYS_LISTEN 4
45 #define RECORD_SYS_ACCEPT 5
46 #define RECORD_SYS_GETSOCKNAME 6
47 #define RECORD_SYS_GETPEERNAME 7
48 #define RECORD_SYS_SOCKETPAIR 8
49 #define RECORD_SYS_SEND 9
50 #define RECORD_SYS_RECV 10
51 #define RECORD_SYS_SENDTO 11
52 #define RECORD_SYS_RECVFROM 12
53 #define RECORD_SYS_SHUTDOWN 13
54 #define RECORD_SYS_SETSOCKOPT 14
55 #define RECORD_SYS_GETSOCKOPT 15
56 #define RECORD_SYS_SENDMSG 16
57 #define RECORD_SYS_RECVMSG 17
59 /* These macros are the values of the first argument of system call
60 "sys_ipc". The values of these macros were obtained from Linux
61 Kernel source. */
63 #define RECORD_SEMOP 1
64 #define RECORD_SEMGET 2
65 #define RECORD_SEMCTL 3
66 #define RECORD_SEMTIMEDOP 4
67 #define RECORD_MSGSND 11
68 #define RECORD_MSGRCV 12
69 #define RECORD_MSGGET 13
70 #define RECORD_MSGCTL 14
71 #define RECORD_SHMAT 21
72 #define RECORD_SHMDT 22
73 #define RECORD_SHMGET 23
74 #define RECORD_SHMCTL 24
76 /* These macros are the values of the first argument of system call
77 "sys_quotactl". The values of these macros were obtained from Linux
78 Kernel source. */
80 #define RECORD_Q_GETFMT 0x800004
81 #define RECORD_Q_GETINFO 0x800005
82 #define RECORD_Q_GETQUOTA 0x800007
83 #define RECORD_Q_XGETQSTAT (('5' << 8) + 5)
84 #define RECORD_Q_XGETQUOTA (('3' << 8) + 3)
86 #define OUTPUT_REG(val, num) phex_nz ((val), \
87 gdbarch_register_type (regcache->arch (), (num))->length ())
89 /* Record a memory area of length LEN pointed to by register
90 REGNUM. */
92 static int
93 record_mem_at_reg (struct regcache *regcache, int regnum, int len)
95 ULONGEST addr;
97 regcache_raw_read_unsigned (regcache, regnum, &addr);
98 return record_full_arch_list_add_mem ((CORE_ADDR) addr, len);
101 static int
102 record_linux_sockaddr (struct regcache *regcache,
103 struct linux_record_tdep *tdep, ULONGEST addr,
104 ULONGEST len)
106 gdb_byte *a;
107 int addrlen;
108 struct gdbarch *gdbarch = regcache->arch ();
109 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
111 if (!addr)
112 return 0;
114 a = (gdb_byte *) alloca (tdep->size_int);
116 if (record_full_arch_list_add_mem ((CORE_ADDR) len, tdep->size_int))
117 return -1;
119 /* Get the addrlen. */
120 if (target_read_memory ((CORE_ADDR) len, a, tdep->size_int))
122 if (record_debug)
123 gdb_printf (gdb_stdlog,
124 "Process record: error reading "
125 "memory at addr = 0x%s len = %d.\n",
126 phex_nz (len, tdep->size_pointer),
127 tdep->size_int);
128 return -1;
130 addrlen = (int) extract_unsigned_integer (a, tdep->size_int, byte_order);
131 if (addrlen <= 0 || addrlen > tdep->size_sockaddr)
132 addrlen = tdep->size_sockaddr;
134 if (record_full_arch_list_add_mem ((CORE_ADDR) addr, addrlen))
135 return -1;
137 return 0;
140 static int
141 record_linux_msghdr (struct regcache *regcache,
142 struct linux_record_tdep *tdep, ULONGEST addr)
144 gdb_byte *a;
145 struct gdbarch *gdbarch = regcache->arch ();
146 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
147 CORE_ADDR tmpaddr;
148 int tmpint;
150 if (!addr)
151 return 0;
153 if (record_full_arch_list_add_mem ((CORE_ADDR) addr, tdep->size_msghdr))
154 return -1;
156 a = (gdb_byte *) alloca (tdep->size_msghdr);
157 if (target_read_memory ((CORE_ADDR) addr, a, tdep->size_msghdr))
159 if (record_debug)
160 gdb_printf (gdb_stdlog,
161 "Process record: error reading "
162 "memory at addr = 0x%s "
163 "len = %d.\n",
164 phex_nz (addr, tdep->size_pointer),
165 tdep->size_msghdr);
166 return -1;
169 /* msg_name msg_namelen */
170 addr = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
171 a += tdep->size_pointer;
172 if (record_full_arch_list_add_mem
173 ((CORE_ADDR) addr,
174 (int) extract_unsigned_integer (a,
175 tdep->size_int,
176 byte_order)))
177 return -1;
178 /* We have read an int, but skip size_pointer bytes to account for alignment
179 of the next field on 64-bit targets. */
180 a += tdep->size_pointer;
182 /* msg_iov msg_iovlen */
183 addr = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
184 a += tdep->size_pointer;
185 if (addr)
187 ULONGEST i;
188 ULONGEST len = extract_unsigned_integer (a, tdep->size_size_t,
189 byte_order);
190 gdb_byte *iov = (gdb_byte *) alloca (tdep->size_iovec);
192 for (i = 0; i < len; i++)
194 if (target_read_memory ((CORE_ADDR) addr, iov, tdep->size_iovec))
196 if (record_debug)
197 gdb_printf (gdb_stdlog,
198 "Process record: error "
199 "reading memory at "
200 "addr = 0x%s "
201 "len = %d.\n",
202 phex_nz (addr,tdep->size_pointer),
203 tdep->size_iovec);
204 return -1;
206 tmpaddr = (CORE_ADDR) extract_unsigned_integer (iov,
207 tdep->size_pointer,
208 byte_order);
209 tmpint = (int) extract_unsigned_integer (iov + tdep->size_pointer,
210 tdep->size_size_t,
211 byte_order);
212 if (record_full_arch_list_add_mem (tmpaddr, tmpint))
213 return -1;
214 addr += tdep->size_iovec;
217 a += tdep->size_size_t;
219 /* msg_control msg_controllen */
220 addr = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
221 a += tdep->size_pointer;
222 tmpint = (int) extract_unsigned_integer (a, tdep->size_size_t, byte_order);
223 if (record_full_arch_list_add_mem ((CORE_ADDR) addr, tmpint))
224 return -1;
226 return 0;
229 /* When the architecture process record get a Linux syscall
230 instruction, it will get a Linux syscall number of this
231 architecture and convert it to the Linux syscall number "num" which
232 is internal to GDB. Most Linux syscalls across architectures in
233 Linux would be similar and mostly differ by sizes of types and
234 structures. This sizes are put to "tdep".
236 Record the values of the registers and memory that will be changed
237 in current system call.
239 Return -1 if something wrong. */
242 record_linux_system_call (enum gdb_syscall syscall,
243 struct regcache *regcache,
244 struct linux_record_tdep *tdep)
246 struct gdbarch *gdbarch = regcache->arch ();
247 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
248 ULONGEST tmpulongest;
249 CORE_ADDR tmpaddr;
250 int tmpint;
252 switch (syscall)
254 case gdb_sys_restart_syscall:
255 break;
257 case gdb_sys_exit:
258 if (yquery (_("The next instruction is syscall exit. "
259 "It will make the program exit. "
260 "Do you want to stop the program?")))
261 return 1;
262 break;
264 case gdb_sys_fork:
265 break;
267 case gdb_sys_read:
268 case gdb_sys_readlink:
269 case gdb_sys_recv:
270 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
271 if (record_mem_at_reg (regcache, tdep->arg2, (int) tmpulongest))
272 return -1;
273 break;
275 case gdb_sys_write:
276 case gdb_sys_open:
277 case gdb_sys_close:
278 break;
280 case gdb_sys_waitpid:
281 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
282 if (tmpulongest)
283 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
284 tdep->size_int))
285 return -1;
286 break;
288 case gdb_sys_creat:
289 case gdb_sys_link:
290 case gdb_sys_unlink:
291 case gdb_sys_execve:
292 case gdb_sys_chdir:
293 break;
295 case gdb_sys_time:
296 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
297 if (tmpulongest)
298 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
299 tdep->size_time_t))
300 return -1;
301 break;
303 case gdb_sys_mknod:
304 case gdb_sys_chmod:
305 case gdb_sys_lchown16:
306 case gdb_sys_ni_syscall17:
307 break;
309 case gdb_sys_stat:
310 case gdb_sys_fstat:
311 case gdb_sys_lstat:
312 if (record_mem_at_reg (regcache, tdep->arg2,
313 tdep->size__old_kernel_stat))
314 return -1;
315 break;
317 case gdb_sys_lseek:
318 case gdb_sys_getpid:
319 case gdb_sys_mount:
320 case gdb_sys_oldumount:
321 case gdb_sys_setuid16:
322 case gdb_sys_getuid16:
323 case gdb_sys_stime:
324 break;
326 case gdb_sys_ptrace:
327 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
328 if (tmpulongest == RECORD_PTRACE_PEEKTEXT
329 || tmpulongest == RECORD_PTRACE_PEEKDATA
330 || tmpulongest == RECORD_PTRACE_PEEKUSR)
332 if (record_mem_at_reg (regcache, tdep->arg4, 4))
333 return -1;
335 break;
337 case gdb_sys_alarm:
338 case gdb_sys_pause:
339 case gdb_sys_utime:
340 case gdb_sys_ni_syscall31:
341 case gdb_sys_ni_syscall32:
342 case gdb_sys_access:
343 case gdb_sys_nice:
344 case gdb_sys_ni_syscall35:
345 case gdb_sys_sync:
346 case gdb_sys_kill:
347 case gdb_sys_rename:
348 case gdb_sys_mkdir:
349 case gdb_sys_rmdir:
350 case gdb_sys_dup:
351 break;
353 case gdb_sys_pipe:
354 case gdb_sys_pipe2:
355 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int * 2))
356 return -1;
357 break;
359 case gdb_sys_getrandom:
360 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
361 if (record_mem_at_reg (regcache, tdep->arg1, tmpulongest))
362 return -1;
363 break;
365 case gdb_sys_times:
366 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_tms))
367 return -1;
368 break;
370 case gdb_sys_ni_syscall44:
371 case gdb_sys_brk:
372 case gdb_sys_setgid16:
373 case gdb_sys_getgid16:
374 case gdb_sys_signal:
375 case gdb_sys_geteuid16:
376 case gdb_sys_getegid16:
377 case gdb_sys_acct:
378 case gdb_sys_umount:
379 case gdb_sys_ni_syscall53:
380 break;
382 case gdb_sys_ioctl:
383 /* XXX Need to add a lot of support of other ioctl requests. */
384 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
385 if (tmpulongest == tdep->ioctl_FIOCLEX
386 || tmpulongest == tdep->ioctl_FIONCLEX
387 || tmpulongest == tdep->ioctl_FIONBIO
388 || tmpulongest == tdep->ioctl_FIOASYNC
389 || tmpulongest == tdep->ioctl_TCSETS
390 || tmpulongest == tdep->ioctl_TCSETSW
391 || tmpulongest == tdep->ioctl_TCSETSF
392 || tmpulongest == tdep->ioctl_TCSETA
393 || tmpulongest == tdep->ioctl_TCSETAW
394 || tmpulongest == tdep->ioctl_TCSETAF
395 || tmpulongest == tdep->ioctl_TCSBRK
396 || tmpulongest == tdep->ioctl_TCXONC
397 || tmpulongest == tdep->ioctl_TCFLSH
398 || tmpulongest == tdep->ioctl_TIOCEXCL
399 || tmpulongest == tdep->ioctl_TIOCNXCL
400 || tmpulongest == tdep->ioctl_TIOCSCTTY
401 || tmpulongest == tdep->ioctl_TIOCSPGRP
402 || tmpulongest == tdep->ioctl_TIOCSTI
403 || tmpulongest == tdep->ioctl_TIOCSWINSZ
404 || tmpulongest == tdep->ioctl_TIOCMBIS
405 || tmpulongest == tdep->ioctl_TIOCMBIC
406 || tmpulongest == tdep->ioctl_TIOCMSET
407 || tmpulongest == tdep->ioctl_TIOCSSOFTCAR
408 || tmpulongest == tdep->ioctl_TIOCCONS
409 || tmpulongest == tdep->ioctl_TIOCSSERIAL
410 || tmpulongest == tdep->ioctl_TIOCPKT
411 || tmpulongest == tdep->ioctl_TIOCNOTTY
412 || tmpulongest == tdep->ioctl_TIOCSETD
413 || tmpulongest == tdep->ioctl_TCSBRKP
414 || tmpulongest == tdep->ioctl_TIOCTTYGSTRUCT
415 || tmpulongest == tdep->ioctl_TIOCSBRK
416 || tmpulongest == tdep->ioctl_TIOCCBRK
417 || tmpulongest == tdep->ioctl_TCSETS2
418 || tmpulongest == tdep->ioctl_TCSETSW2
419 || tmpulongest == tdep->ioctl_TCSETSF2
420 || tmpulongest == tdep->ioctl_TIOCSPTLCK
421 || tmpulongest == tdep->ioctl_TIOCSERCONFIG
422 || tmpulongest == tdep->ioctl_TIOCSERGWILD
423 || tmpulongest == tdep->ioctl_TIOCSERSWILD
424 || tmpulongest == tdep->ioctl_TIOCSLCKTRMIOS
425 || tmpulongest == tdep->ioctl_TIOCSERGETMULTI
426 || tmpulongest == tdep->ioctl_TIOCSERSETMULTI
427 || tmpulongest == tdep->ioctl_TIOCMIWAIT
428 || tmpulongest == tdep->ioctl_TIOCSHAYESESP)
430 /* Nothing to do. */
432 else if (tmpulongest == tdep->ioctl_TCGETS
433 || tmpulongest == tdep->ioctl_TCGETA
434 || tmpulongest == tdep->ioctl_TIOCGLCKTRMIOS)
436 if (record_mem_at_reg (regcache, tdep->arg3,
437 tdep->size_termios))
438 return -1;
440 else if (tmpulongest == tdep->ioctl_TIOCGPGRP
441 || tmpulongest == tdep->ioctl_TIOCGSID)
443 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_pid_t))
444 return -1;
446 else if (tmpulongest == tdep->ioctl_TIOCOUTQ
447 || tmpulongest == tdep->ioctl_TIOCMGET
448 || tmpulongest == tdep->ioctl_TIOCGSOFTCAR
449 || tmpulongest == tdep->ioctl_FIONREAD
450 || tmpulongest == tdep->ioctl_TIOCINQ
451 || tmpulongest == tdep->ioctl_TIOCGETD
452 || tmpulongest == tdep->ioctl_TIOCGPTN
453 || tmpulongest == tdep->ioctl_TIOCSERGETLSR)
455 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_int))
456 return -1;
458 else if (tmpulongest == tdep->ioctl_TIOCGWINSZ)
460 if (record_mem_at_reg (regcache, tdep->arg3,
461 tdep->size_winsize))
462 return -1;
464 else if (tmpulongest == tdep->ioctl_TIOCLINUX)
466 /* This syscall affects a char-size memory. */
467 if (record_mem_at_reg (regcache, tdep->arg3, 1))
468 return -1;
470 else if (tmpulongest == tdep->ioctl_TIOCGSERIAL)
472 if (record_mem_at_reg (regcache, tdep->arg3,
473 tdep->size_serial_struct))
474 return -1;
476 else if (tmpulongest == tdep->ioctl_TCGETS2)
478 if (record_mem_at_reg (regcache, tdep->arg3,
479 tdep->size_termios2))
480 return -1;
482 else if (tmpulongest == tdep->ioctl_FIOQSIZE)
484 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_loff_t))
485 return -1;
487 else if (tmpulongest == tdep->ioctl_TIOCGICOUNT)
489 if (record_mem_at_reg (regcache, tdep->arg3,
490 tdep->size_serial_icounter_struct))
491 return -1;
493 else if (tmpulongest == tdep->ioctl_TIOCGHAYESESP)
495 if (record_mem_at_reg (regcache, tdep->arg3,
496 tdep->size_hayes_esp_config))
497 return -1;
499 else if (tmpulongest == tdep->ioctl_TIOCSERGSTRUCT)
501 gdb_printf (gdb_stderr,
502 _("Process record and replay target doesn't "
503 "support ioctl request TIOCSERGSTRUCT\n"));
504 return 1;
506 else
508 gdb_printf (gdb_stderr,
509 _("Process record and replay target doesn't "
510 "support ioctl request 0x%s.\n"),
511 OUTPUT_REG (tmpulongest, tdep->arg2));
512 return 1;
514 break;
516 case gdb_sys_fcntl:
517 /* XXX */
518 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
519 sys_fcntl:
520 if (tmpulongest == tdep->fcntl_F_GETLK)
522 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_flock))
523 return -1;
525 break;
527 case gdb_sys_ni_syscall56:
528 case gdb_sys_setpgid:
529 case gdb_sys_ni_syscall58:
530 break;
532 case gdb_sys_olduname:
533 if (record_mem_at_reg (regcache, tdep->arg1,
534 tdep->size_oldold_utsname))
535 return -1;
536 break;
538 case gdb_sys_umask:
539 case gdb_sys_chroot:
540 break;
542 case gdb_sys_ustat:
543 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_ustat))
544 return -1;
545 break;
547 case gdb_sys_dup2:
548 case gdb_sys_getppid:
549 case gdb_sys_getpgrp:
550 case gdb_sys_setsid:
551 break;
553 case gdb_sys_sigaction:
554 if (record_mem_at_reg (regcache, tdep->arg3,
555 tdep->size_old_sigaction))
556 return -1;
557 break;
559 case gdb_sys_sgetmask:
560 case gdb_sys_ssetmask:
561 case gdb_sys_setreuid16:
562 case gdb_sys_setregid16:
563 case gdb_sys_sigsuspend:
564 break;
566 case gdb_sys_sigpending:
567 if (record_mem_at_reg (regcache, tdep->arg1,
568 tdep->size_old_sigset_t))
569 return -1;
570 break;
572 case gdb_sys_sethostname:
573 case gdb_sys_setrlimit:
574 break;
576 case gdb_sys_old_getrlimit:
577 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_rlimit))
578 return -1;
579 break;
581 case gdb_sys_getrusage:
582 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_rusage))
583 return -1;
584 break;
586 case gdb_sys_gettimeofday:
587 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_timeval)
588 || record_mem_at_reg (regcache, tdep->arg2, tdep->size_timezone))
589 return -1;
590 break;
592 case gdb_sys_settimeofday:
593 break;
595 case gdb_sys_getgroups16:
596 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
597 if (tmpulongest)
599 ULONGEST gidsetsize;
601 regcache_raw_read_unsigned (regcache, tdep->arg1,
602 &gidsetsize);
603 tmpint = tdep->size_old_gid_t * (int) gidsetsize;
604 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest, tmpint))
605 return -1;
607 break;
609 case gdb_sys_setgroups16:
610 break;
612 case gdb_old_select:
614 unsigned long sz_sel_arg = tdep->size_long + tdep->size_pointer * 4;
615 gdb_byte *a = (gdb_byte *) alloca (sz_sel_arg);
616 CORE_ADDR inp, outp, exp, tvp;
618 regcache_raw_read_unsigned (regcache, tdep->arg1,
619 &tmpulongest);
620 if (tmpulongest)
622 if (target_read_memory (tmpulongest, a, sz_sel_arg))
624 if (record_debug)
625 gdb_printf (gdb_stdlog,
626 "Process record: error reading memory "
627 "at addr = 0x%s len = %lu.\n",
628 OUTPUT_REG (tmpulongest, tdep->arg1),
629 sz_sel_arg);
630 return -1;
632 /* Skip n. */
633 a += tdep->size_long;
634 inp = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
635 a += tdep->size_pointer;
636 outp = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
637 a += tdep->size_pointer;
638 exp = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
639 a += tdep->size_pointer;
640 tvp = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
641 if (inp)
642 if (record_full_arch_list_add_mem (inp, tdep->size_fd_set))
643 return -1;
644 if (outp)
645 if (record_full_arch_list_add_mem (outp, tdep->size_fd_set))
646 return -1;
647 if (exp)
648 if (record_full_arch_list_add_mem (exp, tdep->size_fd_set))
649 return -1;
650 if (tvp)
651 if (record_full_arch_list_add_mem (tvp, tdep->size_timeval))
652 return -1;
655 break;
657 case gdb_sys_symlink:
658 break;
660 case gdb_sys_uselib:
661 case gdb_sys_swapon:
662 break;
664 case gdb_sys_reboot:
665 if (yquery (_("The next instruction is syscall reboot. "
666 "It will restart the computer. "
667 "Do you want to stop the program?")))
668 return 1;
669 break;
671 case gdb_old_readdir:
672 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_old_dirent))
673 return -1;
674 break;
676 case gdb_old_mmap:
677 break;
679 case gdb_sys_munmap:
681 ULONGEST len;
683 regcache_raw_read_unsigned (regcache, tdep->arg1,
684 &tmpulongest);
685 regcache_raw_read_unsigned (regcache, tdep->arg2, &len);
686 if (record_full_memory_query)
688 if (yquery (_("\
689 The next instruction is syscall munmap.\n\
690 It will free the memory addr = 0x%s len = %u.\n\
691 It will make record target cannot record some memory change.\n\
692 Do you want to stop the program?"),
693 OUTPUT_REG (tmpulongest, tdep->arg1), (int) len))
694 return 1;
697 break;
699 case gdb_sys_truncate:
700 case gdb_sys_ftruncate:
701 case gdb_sys_fchmod:
702 case gdb_sys_fchown16:
703 case gdb_sys_getpriority:
704 case gdb_sys_setpriority:
705 case gdb_sys_ni_syscall98:
706 break;
708 case gdb_sys_statfs:
709 case gdb_sys_fstatfs:
710 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_statfs))
711 return -1;
712 break;
714 case gdb_sys_ioperm:
715 break;
717 case gdb_sys_socket:
718 case gdb_sys_sendto:
719 case gdb_sys_sendmsg:
720 case gdb_sys_shutdown:
721 case gdb_sys_bind:
722 case gdb_sys_connect:
723 case gdb_sys_listen:
724 case gdb_sys_setsockopt:
725 break;
727 case gdb_sys_accept:
728 case gdb_sys_getsockname:
729 case gdb_sys_getpeername:
731 ULONGEST len;
733 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
734 regcache_raw_read_unsigned (regcache, tdep->arg3, &len);
735 if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
736 return -1;
738 break;
740 case gdb_sys_recvfrom:
742 ULONGEST len;
744 regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
745 regcache_raw_read_unsigned (regcache, tdep->arg5, &len);
746 if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
747 return -1;
749 break;
751 case gdb_sys_recvmsg:
752 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
753 if (record_linux_msghdr (regcache, tdep, tmpulongest))
754 return -1;
755 break;
757 case gdb_sys_socketpair:
758 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_int))
759 return -1;
760 break;
762 case gdb_sys_getsockopt:
763 regcache_raw_read_unsigned (regcache, tdep->arg5, &tmpulongest);
764 if (tmpulongest)
766 ULONGEST optvalp;
767 gdb_byte *optlenp = (gdb_byte *) alloca (tdep->size_int);
769 if (target_read_memory ((CORE_ADDR) tmpulongest, optlenp,
770 tdep->size_int))
772 if (record_debug)
773 gdb_printf (gdb_stdlog,
774 "Process record: error reading "
775 "memory at addr = 0x%s "
776 "len = %d.\n",
777 OUTPUT_REG (tmpulongest, tdep->arg5),
778 tdep->size_int);
779 return -1;
781 regcache_raw_read_unsigned (regcache, tdep->arg4, &optvalp);
782 tmpint = (int) extract_signed_integer (optlenp, tdep->size_int,
783 byte_order);
784 if (record_full_arch_list_add_mem ((CORE_ADDR) optvalp, tmpint))
785 return -1;
786 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
787 tdep->size_int))
788 return -1;
790 break;
792 case gdb_sys_socketcall:
793 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
794 switch (tmpulongest)
796 case RECORD_SYS_SOCKET:
797 case RECORD_SYS_BIND:
798 case RECORD_SYS_CONNECT:
799 case RECORD_SYS_LISTEN:
800 break;
801 case RECORD_SYS_ACCEPT:
802 case RECORD_SYS_GETSOCKNAME:
803 case RECORD_SYS_GETPEERNAME:
805 regcache_raw_read_unsigned (regcache, tdep->arg2,
806 &tmpulongest);
807 if (tmpulongest)
809 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong * 2);
810 ULONGEST len;
812 tmpulongest += tdep->size_ulong;
813 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
814 tdep->size_ulong * 2))
816 if (record_debug)
817 gdb_printf (gdb_stdlog,
818 "Process record: error reading "
819 "memory at addr = 0x%s len = %d.\n",
820 OUTPUT_REG (tmpulongest, tdep->arg2),
821 tdep->size_ulong * 2);
822 return -1;
824 tmpulongest = extract_unsigned_integer (a,
825 tdep->size_ulong,
826 byte_order);
827 len = extract_unsigned_integer (a + tdep->size_ulong,
828 tdep->size_ulong, byte_order);
829 if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
830 return -1;
833 break;
835 case RECORD_SYS_SOCKETPAIR:
837 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong);
839 regcache_raw_read_unsigned (regcache, tdep->arg2,
840 &tmpulongest);
841 if (tmpulongest)
843 tmpulongest += tdep->size_ulong * 3;
844 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
845 tdep->size_ulong))
847 if (record_debug)
848 gdb_printf (gdb_stdlog,
849 "Process record: error reading "
850 "memory at addr = 0x%s len = %d.\n",
851 OUTPUT_REG (tmpulongest, tdep->arg2),
852 tdep->size_ulong);
853 return -1;
855 tmpaddr
856 = (CORE_ADDR) extract_unsigned_integer (a, tdep->size_ulong,
857 byte_order);
858 if (record_full_arch_list_add_mem (tmpaddr, tdep->size_int))
859 return -1;
862 break;
863 case RECORD_SYS_SEND:
864 case RECORD_SYS_SENDTO:
865 break;
866 case RECORD_SYS_RECVFROM:
867 regcache_raw_read_unsigned (regcache, tdep->arg2,
868 &tmpulongest);
869 if (tmpulongest)
871 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong * 2);
872 ULONGEST len;
874 tmpulongest += tdep->size_ulong * 4;
875 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
876 tdep->size_ulong * 2))
878 if (record_debug)
879 gdb_printf (gdb_stdlog,
880 "Process record: error reading "
881 "memory at addr = 0x%s len = %d.\n",
882 OUTPUT_REG (tmpulongest, tdep->arg2),
883 tdep->size_ulong * 2);
884 return -1;
886 tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
887 byte_order);
888 len = extract_unsigned_integer (a + tdep->size_ulong,
889 tdep->size_ulong, byte_order);
890 if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
891 return -1;
893 break;
894 case RECORD_SYS_RECV:
895 regcache_raw_read_unsigned (regcache, tdep->arg2,
896 &tmpulongest);
897 if (tmpulongest)
899 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong * 2);
901 tmpulongest += tdep->size_ulong;
902 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
903 tdep->size_ulong))
905 if (record_debug)
906 gdb_printf (gdb_stdlog,
907 "Process record: error reading "
908 "memory at addr = 0x%s len = %d.\n",
909 OUTPUT_REG (tmpulongest, tdep->arg2),
910 tdep->size_ulong);
911 return -1;
913 tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
914 byte_order);
915 if (tmpulongest)
917 a += tdep->size_ulong;
918 tmpint = (int) extract_unsigned_integer (a, tdep->size_ulong,
919 byte_order);
920 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
921 tmpint))
922 return -1;
925 break;
926 case RECORD_SYS_SHUTDOWN:
927 case RECORD_SYS_SETSOCKOPT:
928 break;
929 case RECORD_SYS_GETSOCKOPT:
931 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong * 2);
932 gdb_byte *av = (gdb_byte *) alloca (tdep->size_int);
934 regcache_raw_read_unsigned (regcache, tdep->arg2,
935 &tmpulongest);
936 if (tmpulongest)
938 tmpulongest += tdep->size_ulong * 3;
939 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
940 tdep->size_ulong * 2))
942 if (record_debug)
943 gdb_printf (gdb_stdlog,
944 "Process record: error reading "
945 "memory at addr = 0x%s len = %d.\n",
946 OUTPUT_REG (tmpulongest, tdep->arg2),
947 tdep->size_ulong * 2);
948 return -1;
950 tmpulongest = extract_unsigned_integer (a + tdep->size_ulong,
951 tdep->size_ulong,
952 byte_order);
953 if (tmpulongest)
955 if (target_read_memory ((CORE_ADDR) tmpulongest, av,
956 tdep->size_int))
958 if (record_debug)
959 gdb_printf (gdb_stdlog,
960 "Process record: error reading "
961 "memory at addr = 0x%s "
962 "len = %d.\n",
963 phex_nz (tmpulongest,
964 tdep->size_ulong),
965 tdep->size_int);
966 return -1;
968 tmpaddr
969 = (CORE_ADDR) extract_unsigned_integer (a,
970 tdep->size_ulong,
971 byte_order);
972 tmpint = (int) extract_unsigned_integer (av,
973 tdep->size_int,
974 byte_order);
975 if (record_full_arch_list_add_mem (tmpaddr, tmpint))
976 return -1;
977 a += tdep->size_ulong;
978 tmpaddr
979 = (CORE_ADDR) extract_unsigned_integer (a,
980 tdep->size_ulong,
981 byte_order);
982 if (record_full_arch_list_add_mem (tmpaddr,
983 tdep->size_int))
984 return -1;
988 break;
989 case RECORD_SYS_SENDMSG:
990 break;
991 case RECORD_SYS_RECVMSG:
993 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong);
995 regcache_raw_read_unsigned (regcache, tdep->arg2,
996 &tmpulongest);
997 if (tmpulongest)
999 tmpulongest += tdep->size_ulong;
1000 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
1001 tdep->size_ulong))
1003 if (record_debug)
1004 gdb_printf (gdb_stdlog,
1005 "Process record: error reading "
1006 "memory at addr = 0x%s len = %d.\n",
1007 OUTPUT_REG (tmpulongest, tdep->arg2),
1008 tdep->size_ulong);
1009 return -1;
1011 tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
1012 byte_order);
1013 if (record_linux_msghdr (regcache, tdep, tmpulongest))
1014 return -1;
1017 break;
1018 default:
1019 gdb_printf (gdb_stderr,
1020 _("Process record and replay target "
1021 "doesn't support socketcall call 0x%s\n"),
1022 OUTPUT_REG (tmpulongest, tdep->arg1));
1023 return -1;
1024 break;
1026 break;
1028 case gdb_sys_syslog:
1029 break;
1031 case gdb_sys_setitimer:
1032 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_itimerval))
1033 return -1;
1034 break;
1036 case gdb_sys_getitimer:
1037 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_itimerval))
1038 return -1;
1039 break;
1041 case gdb_sys_newstat:
1042 case gdb_sys_newlstat:
1043 case gdb_sys_newfstat:
1044 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_stat))
1045 return -1;
1046 break;
1048 case gdb_sys_newfstatat:
1049 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1050 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1051 tdep->size_stat))
1052 return -1;
1053 break;
1055 case gdb_sys_statx:
1056 regcache_raw_read_unsigned (regcache, tdep->arg5, &tmpulongest);
1057 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest, 256))
1058 return -1;
1059 break;
1061 case gdb_sys_uname:
1062 if (record_mem_at_reg (regcache, tdep->arg1,
1063 tdep->size_old_utsname))
1064 return -1;
1065 break;
1067 case gdb_sys_iopl:
1068 case gdb_sys_vhangup:
1069 case gdb_sys_ni_syscall112:
1070 case gdb_sys_vm86old:
1071 break;
1073 case gdb_sys_wait4:
1074 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_int)
1075 || record_mem_at_reg (regcache, tdep->arg4, tdep->size_rusage))
1076 return -1;
1077 break;
1079 case gdb_sys_swapoff:
1080 break;
1082 case gdb_sys_sysinfo:
1083 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_sysinfo))
1084 return -1;
1085 break;
1087 case gdb_sys_shmget:
1088 case gdb_sys_semget:
1089 case gdb_sys_semop:
1090 case gdb_sys_msgget:
1091 /* XXX maybe need do some record works with sys_shmdt. */
1092 case gdb_sys_shmdt:
1093 case gdb_sys_msgsnd:
1094 case gdb_sys_semtimedop:
1095 break;
1097 case gdb_sys_shmat:
1098 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_ulong))
1099 return -1;
1100 break;
1102 case gdb_sys_shmctl:
1103 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_shmid_ds))
1104 return -1;
1105 break;
1107 /* XXX sys_semctl 525 still not supported. */
1108 /* sys_semctl */
1110 case gdb_sys_msgrcv:
1112 LONGEST l;
1114 regcache_raw_read_signed (regcache, tdep->arg3, &l);
1115 tmpint = l + tdep->size_long;
1116 if (record_mem_at_reg (regcache, tdep->arg2, tmpint))
1117 return -1;
1119 break;
1121 case gdb_sys_msgctl:
1122 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_msqid_ds))
1123 return -1;
1124 break;
1126 case gdb_sys_ipc:
1127 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1128 tmpulongest &= 0xffff;
1129 switch (tmpulongest)
1131 case RECORD_SEMOP:
1132 case RECORD_SEMGET:
1133 case RECORD_SEMTIMEDOP:
1134 case RECORD_MSGSND:
1135 case RECORD_MSGGET:
1136 /* XXX maybe need do some record works with RECORD_SHMDT. */
1137 case RECORD_SHMDT:
1138 case RECORD_SHMGET:
1139 break;
1140 case RECORD_MSGRCV:
1142 LONGEST second;
1144 regcache_raw_read_signed (regcache, tdep->arg3, &second);
1145 tmpint = (int) second + tdep->size_long;
1146 if (record_mem_at_reg (regcache, tdep->arg5, tmpint))
1147 return -1;
1149 break;
1150 case RECORD_MSGCTL:
1151 if (record_mem_at_reg (regcache, tdep->arg5,
1152 tdep->size_msqid_ds))
1153 return -1;
1154 break;
1155 case RECORD_SHMAT:
1156 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_ulong))
1157 return -1;
1158 break;
1159 case RECORD_SHMCTL:
1160 if (record_mem_at_reg (regcache, tdep->arg5,
1161 tdep->size_shmid_ds))
1162 return -1;
1163 break;
1164 default:
1165 /* XXX RECORD_SEMCTL still not supported. */
1166 gdb_printf (gdb_stderr,
1167 _("Process record and replay target doesn't "
1168 "support ipc number %s\n"),
1169 pulongest (tmpulongest));
1170 break;
1172 break;
1174 case gdb_sys_fsync:
1175 case gdb_sys_sigreturn:
1176 case gdb_sys_clone:
1177 case gdb_sys_setdomainname:
1178 break;
1180 case gdb_sys_newuname:
1181 if (record_mem_at_reg (regcache, tdep->arg1,
1182 tdep->size_new_utsname))
1183 return -1;
1184 break;
1186 case gdb_sys_modify_ldt:
1187 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1188 if (tmpulongest == 0 || tmpulongest == 2)
1190 ULONGEST bytecount;
1192 regcache_raw_read_unsigned (regcache, tdep->arg3, &bytecount);
1193 if (record_mem_at_reg (regcache, tdep->arg2, (int) bytecount))
1194 return -1;
1196 break;
1198 case gdb_sys_adjtimex:
1199 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_timex))
1200 return -1;
1201 break;
1203 case gdb_sys_mprotect:
1204 break;
1206 case gdb_sys_sigprocmask:
1207 if (record_mem_at_reg (regcache, tdep->arg3,
1208 tdep->size_old_sigset_t))
1209 return -1;
1210 break;
1212 case gdb_sys_ni_syscall127:
1213 case gdb_sys_init_module:
1214 case gdb_sys_delete_module:
1215 case gdb_sys_ni_syscall130:
1216 break;
1218 case gdb_sys_quotactl:
1219 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1220 switch (tmpulongest)
1222 case RECORD_Q_GETFMT:
1223 /* __u32 */
1224 if (record_mem_at_reg (regcache, tdep->arg4, 4))
1225 return -1;
1226 break;
1227 case RECORD_Q_GETINFO:
1228 if (record_mem_at_reg (regcache, tdep->arg4,
1229 tdep->size_mem_dqinfo))
1230 return -1;
1231 break;
1232 case RECORD_Q_GETQUOTA:
1233 if (record_mem_at_reg (regcache, tdep->arg4,
1234 tdep->size_if_dqblk))
1235 return -1;
1236 break;
1237 case RECORD_Q_XGETQSTAT:
1238 case RECORD_Q_XGETQUOTA:
1239 if (record_mem_at_reg (regcache, tdep->arg4,
1240 tdep->size_fs_quota_stat))
1241 return -1;
1242 break;
1244 break;
1246 case gdb_sys_getpgid:
1247 case gdb_sys_fchdir:
1248 case gdb_sys_bdflush:
1249 break;
1251 case gdb_sys_sysfs:
1252 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1253 if (tmpulongest == 2)
1255 /*XXX the size of memory is not very clear. */
1256 if (record_mem_at_reg (regcache, tdep->arg3, 10))
1257 return -1;
1259 break;
1261 case gdb_sys_personality:
1262 case gdb_sys_ni_syscall137:
1263 case gdb_sys_setfsuid16:
1264 case gdb_sys_setfsgid16:
1265 break;
1267 case gdb_sys_llseek:
1268 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_loff_t))
1269 return -1;
1270 break;
1272 case gdb_sys_getdents:
1273 case gdb_sys_getdents64:
1274 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1275 if (record_mem_at_reg (regcache, tdep->arg2, tmpulongest))
1276 return -1;
1277 break;
1279 case gdb_sys_select:
1280 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_fd_set)
1281 || record_mem_at_reg (regcache, tdep->arg3, tdep->size_fd_set)
1282 || record_mem_at_reg (regcache, tdep->arg4, tdep->size_fd_set)
1283 || record_mem_at_reg (regcache, tdep->arg5, tdep->size_timeval))
1284 return -1;
1285 break;
1287 case gdb_sys_flock:
1288 case gdb_sys_msync:
1289 break;
1291 case gdb_sys_readv:
1293 ULONGEST vec, vlen;
1295 regcache_raw_read_unsigned (regcache, tdep->arg2, &vec);
1296 if (vec)
1298 gdb_byte *iov = (gdb_byte *) alloca (tdep->size_iovec);
1300 regcache_raw_read_unsigned (regcache, tdep->arg3, &vlen);
1301 for (tmpulongest = 0; tmpulongest < vlen; tmpulongest++)
1303 if (target_read_memory ((CORE_ADDR) vec, iov,
1304 tdep->size_iovec))
1306 if (record_debug)
1307 gdb_printf (gdb_stdlog,
1308 "Process record: error reading "
1309 "memory at addr = 0x%s len = %d.\n",
1310 OUTPUT_REG (vec, tdep->arg2),
1311 tdep->size_iovec);
1312 return -1;
1314 tmpaddr
1315 = (CORE_ADDR) extract_unsigned_integer (iov,
1316 tdep->size_pointer,
1317 byte_order);
1318 tmpint
1319 = (int) extract_unsigned_integer (iov + tdep->size_pointer,
1320 tdep->size_size_t,
1321 byte_order);
1322 if (record_full_arch_list_add_mem (tmpaddr, tmpint))
1323 return -1;
1324 vec += tdep->size_iovec;
1328 break;
1330 case gdb_sys_writev:
1331 case gdb_sys_getsid:
1332 case gdb_sys_fdatasync:
1333 case gdb_sys_sysctl:
1334 case gdb_sys_mlock:
1335 case gdb_sys_munlock:
1336 case gdb_sys_mlockall:
1337 case gdb_sys_munlockall:
1338 case gdb_sys_sched_setparam:
1339 break;
1341 case gdb_sys_sched_getparam:
1342 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_int))
1343 return -1;
1344 break;
1346 case gdb_sys_sched_setscheduler:
1347 case gdb_sys_sched_getscheduler:
1348 case gdb_sys_sched_yield:
1349 case gdb_sys_sched_get_priority_max:
1350 case gdb_sys_sched_get_priority_min:
1351 break;
1353 case gdb_sys_sched_rr_get_interval:
1354 case gdb_sys_nanosleep:
1355 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_timespec))
1356 return -1;
1357 break;
1359 case gdb_sys_mremap:
1360 case gdb_sys_setresuid16:
1361 break;
1363 case gdb_sys_getresuid16:
1364 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_old_uid_t)
1365 || record_mem_at_reg (regcache, tdep->arg2,
1366 tdep->size_old_uid_t)
1367 || record_mem_at_reg (regcache, tdep->arg3,
1368 tdep->size_old_uid_t))
1369 return -1;
1370 break;
1372 case gdb_sys_vm86:
1373 case gdb_sys_ni_syscall167:
1374 break;
1376 case gdb_sys_poll:
1377 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1378 if (tmpulongest)
1380 ULONGEST nfds;
1382 regcache_raw_read_unsigned (regcache, tdep->arg2, &nfds);
1383 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1384 tdep->size_pollfd * nfds))
1385 return -1;
1387 break;
1389 case gdb_sys_nfsservctl:
1390 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1391 if (tmpulongest == 7 || tmpulongest == 8)
1393 int rsize;
1395 if (tmpulongest == 7)
1396 rsize = tdep->size_NFS_FHSIZE;
1397 else
1398 rsize = tdep->size_knfsd_fh;
1399 if (record_mem_at_reg (regcache, tdep->arg3, rsize))
1400 return -1;
1402 break;
1404 case gdb_sys_setresgid16:
1405 break;
1407 case gdb_sys_getresgid16:
1408 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_old_gid_t)
1409 || record_mem_at_reg (regcache, tdep->arg2,
1410 tdep->size_old_gid_t)
1411 || record_mem_at_reg (regcache, tdep->arg3,
1412 tdep->size_old_gid_t))
1413 return -1;
1414 break;
1416 case gdb_sys_prctl:
1417 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1418 switch (tmpulongest)
1420 case 2:
1421 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_int))
1422 return -1;
1423 break;
1424 case 16:
1425 if (record_mem_at_reg (regcache, tdep->arg2,
1426 tdep->size_TASK_COMM_LEN))
1427 return -1;
1428 break;
1430 break;
1432 case gdb_sys_rt_sigreturn:
1433 break;
1435 case gdb_sys_rt_sigaction:
1436 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_sigaction))
1437 return -1;
1438 break;
1440 case gdb_sys_rt_sigprocmask:
1441 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_sigset_t))
1442 return -1;
1443 break;
1445 case gdb_sys_rt_sigpending:
1446 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1447 if (tmpulongest)
1449 ULONGEST sigsetsize;
1451 regcache_raw_read_unsigned (regcache, tdep->arg2,&sigsetsize);
1452 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1453 (int) sigsetsize))
1454 return -1;
1456 break;
1458 case gdb_sys_rt_sigtimedwait:
1459 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_siginfo_t))
1460 return -1;
1461 break;
1463 case gdb_sys_rt_sigqueueinfo:
1464 case gdb_sys_rt_sigsuspend:
1465 break;
1467 case gdb_sys_pread64:
1468 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1469 if (tmpulongest)
1471 ULONGEST count;
1473 regcache_raw_read_unsigned (regcache, tdep->arg3,&count);
1474 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1475 (int) count))
1476 return -1;
1478 break;
1480 case gdb_sys_pwrite64:
1481 case gdb_sys_chown16:
1482 break;
1484 case gdb_sys_getcwd:
1485 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1486 if (tmpulongest)
1488 ULONGEST size;
1490 regcache_raw_read_unsigned (regcache, tdep->arg2, &size);
1491 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1492 (int) size))
1493 return -1;
1495 break;
1497 case gdb_sys_capget:
1498 if (record_mem_at_reg (regcache, tdep->arg2,
1499 tdep->size_cap_user_data_t))
1500 return -1;
1501 break;
1503 case gdb_sys_capset:
1504 break;
1506 case gdb_sys_sigaltstack:
1507 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_stack_t))
1508 return -1;
1509 break;
1511 case gdb_sys_sendfile:
1512 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_off_t))
1513 return -1;
1514 break;
1516 case gdb_sys_ni_syscall188:
1517 case gdb_sys_ni_syscall189:
1518 case gdb_sys_vfork:
1519 break;
1521 case gdb_sys_getrlimit:
1522 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_rlimit))
1523 return -1;
1524 break;
1526 case gdb_sys_mmap2:
1527 break;
1529 case gdb_sys_truncate64:
1530 case gdb_sys_ftruncate64:
1531 break;
1533 case gdb_sys_stat64:
1534 case gdb_sys_lstat64:
1535 case gdb_sys_fstat64:
1536 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_stat64))
1537 return -1;
1538 break;
1540 case gdb_sys_lchown:
1541 case gdb_sys_getuid:
1542 case gdb_sys_getgid:
1543 case gdb_sys_geteuid:
1544 case gdb_sys_getegid:
1545 case gdb_sys_setreuid:
1546 case gdb_sys_setregid:
1547 break;
1549 case gdb_sys_getgroups:
1550 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1551 if (tmpulongest)
1553 ULONGEST gidsetsize;
1555 regcache_raw_read_unsigned (regcache, tdep->arg1,
1556 &gidsetsize);
1557 tmpint = tdep->size_gid_t * (int) gidsetsize;
1558 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest, tmpint))
1559 return -1;
1561 break;
1563 case gdb_sys_setgroups:
1564 case gdb_sys_fchown:
1565 case gdb_sys_setresuid:
1566 break;
1568 case gdb_sys_getresuid:
1569 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_uid_t)
1570 || record_mem_at_reg (regcache, tdep->arg2, tdep->size_uid_t)
1571 || record_mem_at_reg (regcache, tdep->arg3, tdep->size_uid_t))
1572 return -1;
1573 break;
1575 case gdb_sys_setresgid:
1576 break;
1578 case gdb_sys_getresgid:
1579 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_gid_t)
1580 || record_mem_at_reg (regcache, tdep->arg2, tdep->size_gid_t)
1581 || record_mem_at_reg (regcache, tdep->arg3, tdep->size_gid_t))
1582 return -1;
1583 break;
1585 case gdb_sys_chown:
1586 case gdb_sys_setuid:
1587 case gdb_sys_setgid:
1588 case gdb_sys_setfsuid:
1589 case gdb_sys_setfsgid:
1590 case gdb_sys_pivot_root:
1591 break;
1593 case gdb_sys_mincore:
1594 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_PAGE_SIZE))
1595 return -1;
1596 break;
1598 case gdb_sys_madvise:
1599 break;
1601 case gdb_sys_fcntl64:
1602 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1603 if (tmpulongest == tdep->fcntl_F_GETLK64)
1605 if (record_mem_at_reg (regcache, tdep->arg3,
1606 tdep->size_flock64))
1607 return -1;
1609 else if (tmpulongest != tdep->fcntl_F_SETLK64
1610 && tmpulongest != tdep->fcntl_F_SETLKW64)
1612 goto sys_fcntl;
1614 break;
1616 case gdb_sys_ni_syscall222:
1617 case gdb_sys_ni_syscall223:
1618 case gdb_sys_gettid:
1619 case gdb_sys_readahead:
1620 case gdb_sys_setxattr:
1621 case gdb_sys_lsetxattr:
1622 case gdb_sys_fsetxattr:
1623 break;
1625 case gdb_sys_getxattr:
1626 case gdb_sys_lgetxattr:
1627 case gdb_sys_fgetxattr:
1628 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1629 if (tmpulongest)
1631 ULONGEST size;
1633 regcache_raw_read_unsigned (regcache, tdep->arg4, &size);
1634 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1635 (int) size))
1636 return -1;
1638 break;
1640 case gdb_sys_listxattr:
1641 case gdb_sys_llistxattr:
1642 case gdb_sys_flistxattr:
1643 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1644 if (tmpulongest)
1646 ULONGEST size;
1648 regcache_raw_read_unsigned (regcache, tdep->arg3, &size);
1649 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1650 (int) size))
1651 return -1;
1653 break;
1655 case gdb_sys_removexattr:
1656 case gdb_sys_lremovexattr:
1657 case gdb_sys_fremovexattr:
1658 case gdb_sys_tkill:
1659 break;
1661 case gdb_sys_sendfile64:
1662 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_loff_t))
1663 return -1;
1664 break;
1666 case gdb_sys_futex:
1667 case gdb_sys_sched_setaffinity:
1668 break;
1670 case gdb_sys_sched_getaffinity:
1671 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1672 if (tmpulongest)
1674 ULONGEST len;
1676 regcache_raw_read_unsigned (regcache, tdep->arg2, &len);
1677 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1678 (int) len))
1679 return -1;
1681 break;
1683 case gdb_sys_set_thread_area:
1684 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int))
1685 return -1;
1686 break;
1688 case gdb_sys_get_thread_area:
1689 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_user_desc))
1690 return -1;
1691 break;
1693 case gdb_sys_io_setup:
1694 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_long))
1695 return -1;
1696 break;
1698 case gdb_sys_io_destroy:
1699 break;
1701 case gdb_sys_io_getevents:
1702 regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
1703 if (tmpulongest)
1705 ULONGEST nr;
1707 regcache_raw_read_unsigned (regcache, tdep->arg3, &nr);
1708 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1709 nr * tdep->size_io_event))
1710 return -1;
1712 break;
1714 case gdb_sys_io_submit:
1715 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1716 if (tmpulongest)
1718 ULONGEST nr, i;
1719 gdb_byte *iocbp;
1721 regcache_raw_read_unsigned (regcache, tdep->arg2, &nr);
1722 iocbp = (gdb_byte *) alloca (nr * tdep->size_pointer);
1723 if (target_read_memory ((CORE_ADDR) tmpulongest, iocbp,
1724 nr * tdep->size_pointer))
1726 if (record_debug)
1727 gdb_printf (gdb_stdlog,
1728 "Process record: error reading memory "
1729 "at addr = 0x%s len = %u.\n",
1730 OUTPUT_REG (tmpulongest, tdep->arg2),
1731 (int) (nr * tdep->size_pointer));
1732 return -1;
1734 for (i = 0; i < nr; i++)
1736 tmpaddr
1737 = (CORE_ADDR) extract_unsigned_integer (iocbp,
1738 tdep->size_pointer,
1739 byte_order);
1740 if (record_full_arch_list_add_mem (tmpaddr, tdep->size_iocb))
1741 return -1;
1742 iocbp += tdep->size_pointer;
1745 break;
1747 case gdb_sys_io_cancel:
1748 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_io_event))
1749 return -1;
1750 break;
1752 case gdb_sys_fadvise64:
1753 case gdb_sys_ni_syscall251:
1754 break;
1756 case gdb_sys_exit_group:
1757 if (yquery (_("The next instruction is syscall exit_group. "
1758 "It will make the program exit. "
1759 "Do you want to stop the program?")))
1760 return 1;
1761 break;
1763 case gdb_sys_lookup_dcookie:
1764 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1765 if (tmpulongest)
1767 ULONGEST len;
1769 regcache_raw_read_unsigned (regcache, tdep->arg3, &len);
1770 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1771 (int) len))
1772 return -1;
1774 break;
1776 case gdb_sys_epoll_create:
1777 case gdb_sys_epoll_ctl:
1778 break;
1780 case gdb_sys_epoll_wait:
1781 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1782 if (tmpulongest)
1784 ULONGEST maxevents;
1786 regcache_raw_read_unsigned (regcache, tdep->arg3, &maxevents);
1787 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1788 (maxevents
1789 * tdep->size_epoll_event)))
1790 return -1;
1792 break;
1794 case gdb_sys_remap_file_pages:
1795 case gdb_sys_set_tid_address:
1796 break;
1798 case gdb_sys_timer_create:
1799 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_int))
1800 return -1;
1801 break;
1803 case gdb_sys_timer_settime:
1804 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_itimerspec))
1805 return -1;
1806 break;
1808 case gdb_sys_timer_gettime:
1809 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_itimerspec))
1810 return -1;
1811 break;
1813 case gdb_sys_timer_getoverrun:
1814 case gdb_sys_timer_delete:
1815 case gdb_sys_clock_settime:
1816 break;
1818 case gdb_sys_clock_gettime:
1819 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_timespec))
1820 return -1;
1821 break;
1823 case gdb_sys_clock_getres:
1824 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_timespec))
1825 return -1;
1826 break;
1828 case gdb_sys_clock_nanosleep:
1829 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_timespec))
1830 return -1;
1831 break;
1833 case gdb_sys_statfs64:
1834 case gdb_sys_fstatfs64:
1835 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_statfs64))
1836 return -1;
1837 break;
1839 case gdb_sys_tgkill:
1840 case gdb_sys_utimes:
1841 case gdb_sys_fadvise64_64:
1842 case gdb_sys_ni_syscall273:
1843 case gdb_sys_mbind:
1844 break;
1846 case gdb_sys_get_mempolicy:
1847 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int))
1848 return -1;
1849 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1850 if (tmpulongest)
1852 ULONGEST maxnode;
1854 regcache_raw_read_unsigned (regcache, tdep->arg3, &maxnode);
1855 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1856 maxnode * tdep->size_long))
1857 return -1;
1859 break;
1861 case gdb_sys_set_mempolicy:
1862 case gdb_sys_mq_open:
1863 case gdb_sys_mq_unlink:
1864 case gdb_sys_mq_timedsend:
1865 break;
1867 case gdb_sys_mq_timedreceive:
1868 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1869 if (tmpulongest)
1871 ULONGEST msg_len;
1873 regcache_raw_read_unsigned (regcache, tdep->arg3, &msg_len);
1874 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1875 (int) msg_len))
1876 return -1;
1878 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_int))
1879 return -1;
1880 break;
1882 case gdb_sys_mq_notify:
1883 break;
1885 case gdb_sys_mq_getsetattr:
1886 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_mq_attr))
1887 return -1;
1888 break;
1890 case gdb_sys_kexec_load:
1891 break;
1893 case gdb_sys_waitid:
1894 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_siginfo_t)
1895 || record_mem_at_reg (regcache, tdep->arg5, tdep->size_rusage))
1896 return -1;
1897 break;
1899 case gdb_sys_ni_syscall285:
1900 case gdb_sys_add_key:
1901 case gdb_sys_request_key:
1902 break;
1904 case gdb_sys_keyctl:
1905 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1906 if (tmpulongest == 6 || tmpulongest == 11)
1908 regcache_raw_read_unsigned (regcache, tdep->arg3,
1909 &tmpulongest);
1910 if (tmpulongest)
1912 ULONGEST buflen;
1914 regcache_raw_read_unsigned (regcache, tdep->arg4, &buflen);
1915 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1916 (int) buflen))
1917 return -1;
1920 break;
1922 case gdb_sys_ioprio_set:
1923 case gdb_sys_ioprio_get:
1924 case gdb_sys_inotify_init:
1925 case gdb_sys_inotify_add_watch:
1926 case gdb_sys_inotify_rm_watch:
1927 case gdb_sys_migrate_pages:
1928 case gdb_sys_openat:
1929 case gdb_sys_mkdirat:
1930 case gdb_sys_mknodat:
1931 case gdb_sys_fchownat:
1932 case gdb_sys_futimesat:
1933 break;
1935 case gdb_sys_fstatat64:
1936 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_stat64))
1937 return -1;
1938 break;
1940 case gdb_sys_unlinkat:
1941 case gdb_sys_renameat:
1942 case gdb_sys_linkat:
1943 case gdb_sys_symlinkat:
1944 break;
1946 case gdb_sys_readlinkat:
1947 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1948 if (tmpulongest)
1950 ULONGEST bufsiz;
1952 regcache_raw_read_unsigned (regcache, tdep->arg4, &bufsiz);
1953 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1954 (int) bufsiz))
1955 return -1;
1957 break;
1959 case gdb_sys_fchmodat:
1960 case gdb_sys_faccessat:
1961 break;
1963 case gdb_sys_pselect6:
1964 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_fd_set)
1965 || record_mem_at_reg (regcache, tdep->arg3, tdep->size_fd_set)
1966 || record_mem_at_reg (regcache, tdep->arg4, tdep->size_fd_set)
1967 || record_mem_at_reg (regcache, tdep->arg5, tdep->size_timespec))
1968 return -1;
1969 break;
1971 case gdb_sys_ppoll:
1972 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1973 if (tmpulongest)
1975 ULONGEST nfds;
1977 regcache_raw_read_unsigned (regcache, tdep->arg2, &nfds);
1978 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1979 tdep->size_pollfd * nfds))
1980 return -1;
1982 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_timespec))
1983 return -1;
1984 break;
1986 case gdb_sys_unshare:
1987 case gdb_sys_set_robust_list:
1988 break;
1990 case gdb_sys_get_robust_list:
1991 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_int)
1992 || record_mem_at_reg (regcache, tdep->arg3, tdep->size_int))
1993 return -1;
1994 break;
1996 case gdb_sys_splice:
1997 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_loff_t)
1998 || record_mem_at_reg (regcache, tdep->arg4, tdep->size_loff_t))
1999 return -1;
2000 break;
2002 case gdb_sys_sync_file_range:
2003 case gdb_sys_tee:
2004 case gdb_sys_vmsplice:
2005 break;
2007 case gdb_sys_move_pages:
2008 regcache_raw_read_unsigned (regcache, tdep->arg5, &tmpulongest);
2009 if (tmpulongest)
2011 ULONGEST nr_pages;
2013 regcache_raw_read_unsigned (regcache, tdep->arg2, &nr_pages);
2014 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2015 nr_pages * tdep->size_int))
2016 return -1;
2018 break;
2020 case gdb_sys_getcpu:
2021 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int)
2022 || record_mem_at_reg (regcache, tdep->arg2, tdep->size_int)
2023 || record_mem_at_reg (regcache, tdep->arg3,
2024 tdep->size_ulong * 2))
2025 return -1;
2026 break;
2028 case gdb_sys_epoll_pwait:
2029 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
2030 if (tmpulongest)
2032 ULONGEST maxevents;
2034 regcache_raw_read_unsigned (regcache, tdep->arg3, &maxevents);
2035 tmpint = (int) maxevents * tdep->size_epoll_event;
2036 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest, tmpint))
2037 return -1;
2039 break;
2041 case gdb_sys_fallocate:
2042 case gdb_sys_eventfd2:
2043 case gdb_sys_epoll_create1:
2044 case gdb_sys_dup3:
2045 break;
2047 case gdb_sys_inotify_init1:
2048 break;
2050 default:
2051 gdb_printf (gdb_stderr,
2052 _("Process record and replay target doesn't "
2053 "support syscall number %d\n"), syscall);
2054 return -1;
2055 break;
2058 return 0;