(Ada) Fix resolving of homonym components in tagged types
[binutils-gdb.git] / gdb / linux-record.c
blob1d0735e41aea46df244aecfb9ad2175b9d669aa3
1 /* Process record and replay target code for GNU/Linux.
3 Copyright (C) 2008-2018 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"
28 /* These macros are the values of the first argument of system call
29 "sys_ptrace". The values of these macros were obtained from Linux
30 Kernel source. */
32 #define RECORD_PTRACE_PEEKTEXT 1
33 #define RECORD_PTRACE_PEEKDATA 2
34 #define RECORD_PTRACE_PEEKUSR 3
36 /* These macros are the values of the first argument of system call
37 "sys_socketcall". The values of these macros were obtained from
38 Linux Kernel source. */
40 #define RECORD_SYS_SOCKET 1
41 #define RECORD_SYS_BIND 2
42 #define RECORD_SYS_CONNECT 3
43 #define RECORD_SYS_LISTEN 4
44 #define RECORD_SYS_ACCEPT 5
45 #define RECORD_SYS_GETSOCKNAME 6
46 #define RECORD_SYS_GETPEERNAME 7
47 #define RECORD_SYS_SOCKETPAIR 8
48 #define RECORD_SYS_SEND 9
49 #define RECORD_SYS_RECV 10
50 #define RECORD_SYS_SENDTO 11
51 #define RECORD_SYS_RECVFROM 12
52 #define RECORD_SYS_SHUTDOWN 13
53 #define RECORD_SYS_SETSOCKOPT 14
54 #define RECORD_SYS_GETSOCKOPT 15
55 #define RECORD_SYS_SENDMSG 16
56 #define RECORD_SYS_RECVMSG 17
58 /* These macros are the values of the first argument of system call
59 "sys_ipc". The values of these macros were obtained from Linux
60 Kernel source. */
62 #define RECORD_SEMOP 1
63 #define RECORD_SEMGET 2
64 #define RECORD_SEMCTL 3
65 #define RECORD_SEMTIMEDOP 4
66 #define RECORD_MSGSND 11
67 #define RECORD_MSGRCV 12
68 #define RECORD_MSGGET 13
69 #define RECORD_MSGCTL 14
70 #define RECORD_SHMAT 21
71 #define RECORD_SHMDT 22
72 #define RECORD_SHMGET 23
73 #define RECORD_SHMCTL 24
75 /* These macros are the values of the first argument of system call
76 "sys_quotactl". The values of these macros were obtained from Linux
77 Kernel source. */
79 #define RECORD_Q_GETFMT 0x800004
80 #define RECORD_Q_GETINFO 0x800005
81 #define RECORD_Q_GETQUOTA 0x800007
82 #define RECORD_Q_XGETQSTAT (('5' << 8) + 5)
83 #define RECORD_Q_XGETQUOTA (('3' << 8) + 3)
85 #define OUTPUT_REG(val, num) phex_nz ((val), \
86 TYPE_LENGTH (gdbarch_register_type (regcache->arch (), (num))))
88 /* Record a memory area of length LEN pointed to by register
89 REGNUM. */
91 static int
92 record_mem_at_reg (struct regcache *regcache, int regnum, int len)
94 ULONGEST addr;
96 regcache_raw_read_unsigned (regcache, regnum, &addr);
97 return record_full_arch_list_add_mem ((CORE_ADDR) addr, len);
100 static int
101 record_linux_sockaddr (struct regcache *regcache,
102 struct linux_record_tdep *tdep, ULONGEST addr,
103 ULONGEST len)
105 gdb_byte *a;
106 int addrlen;
107 struct gdbarch *gdbarch = regcache->arch ();
108 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
110 if (!addr)
111 return 0;
113 a = (gdb_byte *) alloca (tdep->size_int);
115 if (record_full_arch_list_add_mem ((CORE_ADDR) len, tdep->size_int))
116 return -1;
118 /* Get the addrlen. */
119 if (target_read_memory ((CORE_ADDR) len, a, tdep->size_int))
121 if (record_debug)
122 fprintf_unfiltered (gdb_stdlog,
123 "Process record: error reading "
124 "memory at addr = 0x%s len = %d.\n",
125 phex_nz (len, tdep->size_pointer),
126 tdep->size_int);
127 return -1;
129 addrlen = (int) extract_unsigned_integer (a, tdep->size_int, byte_order);
130 if (addrlen <= 0 || addrlen > tdep->size_sockaddr)
131 addrlen = tdep->size_sockaddr;
133 if (record_full_arch_list_add_mem ((CORE_ADDR) addr, addrlen))
134 return -1;
136 return 0;
139 static int
140 record_linux_msghdr (struct regcache *regcache,
141 struct linux_record_tdep *tdep, ULONGEST addr)
143 gdb_byte *a;
144 struct gdbarch *gdbarch = regcache->arch ();
145 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
146 CORE_ADDR tmpaddr;
147 int tmpint;
149 if (!addr)
150 return 0;
152 if (record_full_arch_list_add_mem ((CORE_ADDR) addr, tdep->size_msghdr))
153 return -1;
155 a = (gdb_byte *) alloca (tdep->size_msghdr);
156 if (target_read_memory ((CORE_ADDR) addr, a, tdep->size_msghdr))
158 if (record_debug)
159 fprintf_unfiltered (gdb_stdlog,
160 "Process record: error reading "
161 "memory at addr = 0x%s "
162 "len = %d.\n",
163 phex_nz (addr, tdep->size_pointer),
164 tdep->size_msghdr);
165 return -1;
168 /* msg_name msg_namelen */
169 addr = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
170 a += tdep->size_pointer;
171 if (record_full_arch_list_add_mem
172 ((CORE_ADDR) addr,
173 (int) extract_unsigned_integer (a,
174 tdep->size_int,
175 byte_order)))
176 return -1;
177 /* We have read an int, but skip size_pointer bytes to account for alignment
178 of the next field on 64-bit targets. */
179 a += tdep->size_pointer;
181 /* msg_iov msg_iovlen */
182 addr = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
183 a += tdep->size_pointer;
184 if (addr)
186 ULONGEST i;
187 ULONGEST len = extract_unsigned_integer (a, tdep->size_size_t,
188 byte_order);
189 gdb_byte *iov = (gdb_byte *) alloca (tdep->size_iovec);
191 for (i = 0; i < len; i++)
193 if (target_read_memory ((CORE_ADDR) addr, iov, tdep->size_iovec))
195 if (record_debug)
196 fprintf_unfiltered (gdb_stdlog,
197 "Process record: error "
198 "reading memory at "
199 "addr = 0x%s "
200 "len = %d.\n",
201 phex_nz (addr,tdep->size_pointer),
202 tdep->size_iovec);
203 return -1;
205 tmpaddr = (CORE_ADDR) extract_unsigned_integer (iov,
206 tdep->size_pointer,
207 byte_order);
208 tmpint = (int) extract_unsigned_integer (iov + tdep->size_pointer,
209 tdep->size_size_t,
210 byte_order);
211 if (record_full_arch_list_add_mem (tmpaddr, tmpint))
212 return -1;
213 addr += tdep->size_iovec;
216 a += tdep->size_size_t;
218 /* msg_control msg_controllen */
219 addr = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
220 a += tdep->size_pointer;
221 tmpint = (int) extract_unsigned_integer (a, tdep->size_size_t, byte_order);
222 if (record_full_arch_list_add_mem ((CORE_ADDR) addr, tmpint))
223 return -1;
225 return 0;
228 /* When the architecture process record get a Linux syscall
229 instruction, it will get a Linux syscall number of this
230 architecture and convert it to the Linux syscall number "num" which
231 is internal to GDB. Most Linux syscalls across architectures in
232 Linux would be similar and mostly differ by sizes of types and
233 structures. This sizes are put to "tdep".
235 Record the values of the registers and memory that will be changed
236 in current system call.
238 Return -1 if something wrong. */
241 record_linux_system_call (enum gdb_syscall syscall,
242 struct regcache *regcache,
243 struct linux_record_tdep *tdep)
245 struct gdbarch *gdbarch = regcache->arch ();
246 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
247 ULONGEST tmpulongest;
248 CORE_ADDR tmpaddr;
249 int tmpint;
251 switch (syscall)
253 case gdb_sys_restart_syscall:
254 break;
256 case gdb_sys_exit:
257 if (yquery (_("The next instruction is syscall exit. "
258 "It will make the program exit. "
259 "Do you want to stop the program?")))
260 return 1;
261 break;
263 case gdb_sys_fork:
264 break;
266 case gdb_sys_read:
267 case gdb_sys_readlink:
268 case gdb_sys_recv:
269 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
270 if (record_mem_at_reg (regcache, tdep->arg2, (int) tmpulongest))
271 return -1;
272 break;
274 case gdb_sys_write:
275 case gdb_sys_open:
276 case gdb_sys_close:
277 break;
279 case gdb_sys_waitpid:
280 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
281 if (tmpulongest)
282 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
283 tdep->size_int))
284 return -1;
285 break;
287 case gdb_sys_creat:
288 case gdb_sys_link:
289 case gdb_sys_unlink:
290 case gdb_sys_execve:
291 case gdb_sys_chdir:
292 break;
294 case gdb_sys_time:
295 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
296 if (tmpulongest)
297 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
298 tdep->size_time_t))
299 return -1;
300 break;
302 case gdb_sys_mknod:
303 case gdb_sys_chmod:
304 case gdb_sys_lchown16:
305 case gdb_sys_ni_syscall17:
306 break;
308 case gdb_sys_stat:
309 case gdb_sys_fstat:
310 case gdb_sys_lstat:
311 if (record_mem_at_reg (regcache, tdep->arg2,
312 tdep->size__old_kernel_stat))
313 return -1;
314 break;
316 case gdb_sys_lseek:
317 case gdb_sys_getpid:
318 case gdb_sys_mount:
319 case gdb_sys_oldumount:
320 case gdb_sys_setuid16:
321 case gdb_sys_getuid16:
322 case gdb_sys_stime:
323 break;
325 case gdb_sys_ptrace:
326 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
327 if (tmpulongest == RECORD_PTRACE_PEEKTEXT
328 || tmpulongest == RECORD_PTRACE_PEEKDATA
329 || tmpulongest == RECORD_PTRACE_PEEKUSR)
331 if (record_mem_at_reg (regcache, tdep->arg4, 4))
332 return -1;
334 break;
336 case gdb_sys_alarm:
337 case gdb_sys_pause:
338 case gdb_sys_utime:
339 case gdb_sys_ni_syscall31:
340 case gdb_sys_ni_syscall32:
341 case gdb_sys_access:
342 case gdb_sys_nice:
343 case gdb_sys_ni_syscall35:
344 case gdb_sys_sync:
345 case gdb_sys_kill:
346 case gdb_sys_rename:
347 case gdb_sys_mkdir:
348 case gdb_sys_rmdir:
349 case gdb_sys_dup:
350 break;
352 case gdb_sys_pipe:
353 case gdb_sys_pipe2:
354 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int * 2))
355 return -1;
356 break;
358 case gdb_sys_times:
359 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_tms))
360 return -1;
361 break;
363 case gdb_sys_ni_syscall44:
364 case gdb_sys_brk:
365 case gdb_sys_setgid16:
366 case gdb_sys_getgid16:
367 case gdb_sys_signal:
368 case gdb_sys_geteuid16:
369 case gdb_sys_getegid16:
370 case gdb_sys_acct:
371 case gdb_sys_umount:
372 case gdb_sys_ni_syscall53:
373 break;
375 case gdb_sys_ioctl:
376 /* XXX Need to add a lot of support of other ioctl requests. */
377 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
378 if (tmpulongest == tdep->ioctl_FIOCLEX
379 || tmpulongest == tdep->ioctl_FIONCLEX
380 || tmpulongest == tdep->ioctl_FIONBIO
381 || tmpulongest == tdep->ioctl_FIOASYNC
382 || tmpulongest == tdep->ioctl_TCSETS
383 || tmpulongest == tdep->ioctl_TCSETSW
384 || tmpulongest == tdep->ioctl_TCSETSF
385 || tmpulongest == tdep->ioctl_TCSETA
386 || tmpulongest == tdep->ioctl_TCSETAW
387 || tmpulongest == tdep->ioctl_TCSETAF
388 || tmpulongest == tdep->ioctl_TCSBRK
389 || tmpulongest == tdep->ioctl_TCXONC
390 || tmpulongest == tdep->ioctl_TCFLSH
391 || tmpulongest == tdep->ioctl_TIOCEXCL
392 || tmpulongest == tdep->ioctl_TIOCNXCL
393 || tmpulongest == tdep->ioctl_TIOCSCTTY
394 || tmpulongest == tdep->ioctl_TIOCSPGRP
395 || tmpulongest == tdep->ioctl_TIOCSTI
396 || tmpulongest == tdep->ioctl_TIOCSWINSZ
397 || tmpulongest == tdep->ioctl_TIOCMBIS
398 || tmpulongest == tdep->ioctl_TIOCMBIC
399 || tmpulongest == tdep->ioctl_TIOCMSET
400 || tmpulongest == tdep->ioctl_TIOCSSOFTCAR
401 || tmpulongest == tdep->ioctl_TIOCCONS
402 || tmpulongest == tdep->ioctl_TIOCSSERIAL
403 || tmpulongest == tdep->ioctl_TIOCPKT
404 || tmpulongest == tdep->ioctl_TIOCNOTTY
405 || tmpulongest == tdep->ioctl_TIOCSETD
406 || tmpulongest == tdep->ioctl_TCSBRKP
407 || tmpulongest == tdep->ioctl_TIOCTTYGSTRUCT
408 || tmpulongest == tdep->ioctl_TIOCSBRK
409 || tmpulongest == tdep->ioctl_TIOCCBRK
410 || tmpulongest == tdep->ioctl_TCSETS2
411 || tmpulongest == tdep->ioctl_TCSETSW2
412 || tmpulongest == tdep->ioctl_TCSETSF2
413 || tmpulongest == tdep->ioctl_TIOCSPTLCK
414 || tmpulongest == tdep->ioctl_TIOCSERCONFIG
415 || tmpulongest == tdep->ioctl_TIOCSERGWILD
416 || tmpulongest == tdep->ioctl_TIOCSERSWILD
417 || tmpulongest == tdep->ioctl_TIOCSLCKTRMIOS
418 || tmpulongest == tdep->ioctl_TIOCSERGETMULTI
419 || tmpulongest == tdep->ioctl_TIOCSERSETMULTI
420 || tmpulongest == tdep->ioctl_TIOCMIWAIT
421 || tmpulongest == tdep->ioctl_TIOCSHAYESESP)
423 /* Nothing to do. */
425 else if (tmpulongest == tdep->ioctl_TCGETS
426 || tmpulongest == tdep->ioctl_TCGETA
427 || tmpulongest == tdep->ioctl_TIOCGLCKTRMIOS)
429 if (record_mem_at_reg (regcache, tdep->arg3,
430 tdep->size_termios))
431 return -1;
433 else if (tmpulongest == tdep->ioctl_TIOCGPGRP
434 || tmpulongest == tdep->ioctl_TIOCGSID)
436 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_pid_t))
437 return -1;
439 else if (tmpulongest == tdep->ioctl_TIOCOUTQ
440 || tmpulongest == tdep->ioctl_TIOCMGET
441 || tmpulongest == tdep->ioctl_TIOCGSOFTCAR
442 || tmpulongest == tdep->ioctl_FIONREAD
443 || tmpulongest == tdep->ioctl_TIOCINQ
444 || tmpulongest == tdep->ioctl_TIOCGETD
445 || tmpulongest == tdep->ioctl_TIOCGPTN
446 || tmpulongest == tdep->ioctl_TIOCSERGETLSR)
448 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_int))
449 return -1;
451 else if (tmpulongest == tdep->ioctl_TIOCGWINSZ)
453 if (record_mem_at_reg (regcache, tdep->arg3,
454 tdep->size_winsize))
455 return -1;
457 else if (tmpulongest == tdep->ioctl_TIOCLINUX)
459 /* This syscall affects a char-size memory. */
460 if (record_mem_at_reg (regcache, tdep->arg3, 1))
461 return -1;
463 else if (tmpulongest == tdep->ioctl_TIOCGSERIAL)
465 if (record_mem_at_reg (regcache, tdep->arg3,
466 tdep->size_serial_struct))
467 return -1;
469 else if (tmpulongest == tdep->ioctl_TCGETS2)
471 if (record_mem_at_reg (regcache, tdep->arg3,
472 tdep->size_termios2))
473 return -1;
475 else if (tmpulongest == tdep->ioctl_FIOQSIZE)
477 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_loff_t))
478 return -1;
480 else if (tmpulongest == tdep->ioctl_TIOCGICOUNT)
482 if (record_mem_at_reg (regcache, tdep->arg3,
483 tdep->size_serial_icounter_struct))
484 return -1;
486 else if (tmpulongest == tdep->ioctl_TIOCGHAYESESP)
488 if (record_mem_at_reg (regcache, tdep->arg3,
489 tdep->size_hayes_esp_config))
490 return -1;
492 else if (tmpulongest == tdep->ioctl_TIOCSERGSTRUCT)
494 printf_unfiltered (_("Process record and replay target doesn't "
495 "support ioctl request TIOCSERGSTRUCT\n"));
496 return 1;
498 else
500 printf_unfiltered (_("Process record and replay target doesn't "
501 "support ioctl request 0x%s.\n"),
502 OUTPUT_REG (tmpulongest, tdep->arg2));
503 return 1;
505 break;
507 case gdb_sys_fcntl:
508 /* XXX */
509 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
510 sys_fcntl:
511 if (tmpulongest == tdep->fcntl_F_GETLK)
513 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_flock))
514 return -1;
516 break;
518 case gdb_sys_ni_syscall56:
519 case gdb_sys_setpgid:
520 case gdb_sys_ni_syscall58:
521 break;
523 case gdb_sys_olduname:
524 if (record_mem_at_reg (regcache, tdep->arg1,
525 tdep->size_oldold_utsname))
526 return -1;
527 break;
529 case gdb_sys_umask:
530 case gdb_sys_chroot:
531 break;
533 case gdb_sys_ustat:
534 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_ustat))
535 return -1;
536 break;
538 case gdb_sys_dup2:
539 case gdb_sys_getppid:
540 case gdb_sys_getpgrp:
541 case gdb_sys_setsid:
542 break;
544 case gdb_sys_sigaction:
545 if (record_mem_at_reg (regcache, tdep->arg3,
546 tdep->size_old_sigaction))
547 return -1;
548 break;
550 case gdb_sys_sgetmask:
551 case gdb_sys_ssetmask:
552 case gdb_sys_setreuid16:
553 case gdb_sys_setregid16:
554 case gdb_sys_sigsuspend:
555 break;
557 case gdb_sys_sigpending:
558 if (record_mem_at_reg (regcache, tdep->arg1,
559 tdep->size_old_sigset_t))
560 return -1;
561 break;
563 case gdb_sys_sethostname:
564 case gdb_sys_setrlimit:
565 break;
567 case gdb_sys_old_getrlimit:
568 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_rlimit))
569 return -1;
570 break;
572 case gdb_sys_getrusage:
573 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_rusage))
574 return -1;
575 break;
577 case gdb_sys_gettimeofday:
578 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_timeval)
579 || record_mem_at_reg (regcache, tdep->arg2, tdep->size_timezone))
580 return -1;
581 break;
583 case gdb_sys_settimeofday:
584 break;
586 case gdb_sys_getgroups16:
587 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
588 if (tmpulongest)
590 ULONGEST gidsetsize;
592 regcache_raw_read_unsigned (regcache, tdep->arg1,
593 &gidsetsize);
594 tmpint = tdep->size_old_gid_t * (int) gidsetsize;
595 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest, tmpint))
596 return -1;
598 break;
600 case gdb_sys_setgroups16:
601 break;
603 case gdb_old_select:
605 unsigned long sz_sel_arg = tdep->size_long + tdep->size_pointer * 4;
606 gdb_byte *a = (gdb_byte *) alloca (sz_sel_arg);
607 CORE_ADDR inp, outp, exp, tvp;
609 regcache_raw_read_unsigned (regcache, tdep->arg1,
610 &tmpulongest);
611 if (tmpulongest)
613 if (target_read_memory (tmpulongest, a, sz_sel_arg))
615 if (record_debug)
616 fprintf_unfiltered (gdb_stdlog,
617 "Process record: error reading memory "
618 "at addr = 0x%s len = %lu.\n",
619 OUTPUT_REG (tmpulongest, tdep->arg1),
620 sz_sel_arg);
621 return -1;
623 /* Skip n. */
624 a += tdep->size_long;
625 inp = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
626 a += tdep->size_pointer;
627 outp = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
628 a += tdep->size_pointer;
629 exp = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
630 a += tdep->size_pointer;
631 tvp = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
632 if (inp)
633 if (record_full_arch_list_add_mem (inp, tdep->size_fd_set))
634 return -1;
635 if (outp)
636 if (record_full_arch_list_add_mem (outp, tdep->size_fd_set))
637 return -1;
638 if (exp)
639 if (record_full_arch_list_add_mem (exp, tdep->size_fd_set))
640 return -1;
641 if (tvp)
642 if (record_full_arch_list_add_mem (tvp, tdep->size_timeval))
643 return -1;
646 break;
648 case gdb_sys_symlink:
649 break;
651 case gdb_sys_uselib:
652 case gdb_sys_swapon:
653 break;
655 case gdb_sys_reboot:
656 if (yquery (_("The next instruction is syscall reboot. "
657 "It will restart the computer. "
658 "Do you want to stop the program?")))
659 return 1;
660 break;
662 case gdb_old_readdir:
663 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_old_dirent))
664 return -1;
665 break;
667 case gdb_old_mmap:
668 break;
670 case gdb_sys_munmap:
672 ULONGEST len;
674 regcache_raw_read_unsigned (regcache, tdep->arg1,
675 &tmpulongest);
676 regcache_raw_read_unsigned (regcache, tdep->arg2, &len);
677 if (record_full_memory_query)
679 if (yquery (_("\
680 The next instruction is syscall munmap.\n\
681 It will free the memory addr = 0x%s len = %u.\n\
682 It will make record target cannot record some memory change.\n\
683 Do you want to stop the program?"),
684 OUTPUT_REG (tmpulongest, tdep->arg1), (int) len))
685 return 1;
688 break;
690 case gdb_sys_truncate:
691 case gdb_sys_ftruncate:
692 case gdb_sys_fchmod:
693 case gdb_sys_fchown16:
694 case gdb_sys_getpriority:
695 case gdb_sys_setpriority:
696 case gdb_sys_ni_syscall98:
697 break;
699 case gdb_sys_statfs:
700 case gdb_sys_fstatfs:
701 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_statfs))
702 return -1;
703 break;
705 case gdb_sys_ioperm:
706 break;
708 case gdb_sys_socket:
709 case gdb_sys_sendto:
710 case gdb_sys_sendmsg:
711 case gdb_sys_shutdown:
712 case gdb_sys_bind:
713 case gdb_sys_connect:
714 case gdb_sys_listen:
715 case gdb_sys_setsockopt:
716 break;
718 case gdb_sys_accept:
719 case gdb_sys_getsockname:
720 case gdb_sys_getpeername:
722 ULONGEST len;
724 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
725 regcache_raw_read_unsigned (regcache, tdep->arg3, &len);
726 if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
727 return -1;
729 break;
731 case gdb_sys_recvfrom:
733 ULONGEST len;
735 regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
736 regcache_raw_read_unsigned (regcache, tdep->arg5, &len);
737 if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
738 return -1;
740 break;
742 case gdb_sys_recvmsg:
743 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
744 if (record_linux_msghdr (regcache, tdep, tmpulongest))
745 return -1;
746 break;
748 case gdb_sys_socketpair:
749 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_int))
750 return -1;
751 break;
753 case gdb_sys_getsockopt:
754 regcache_raw_read_unsigned (regcache, tdep->arg5, &tmpulongest);
755 if (tmpulongest)
757 ULONGEST optvalp;
758 gdb_byte *optlenp = (gdb_byte *) alloca (tdep->size_int);
760 if (target_read_memory ((CORE_ADDR) tmpulongest, optlenp,
761 tdep->size_int))
763 if (record_debug)
764 fprintf_unfiltered (gdb_stdlog,
765 "Process record: error reading "
766 "memory at addr = 0x%s "
767 "len = %d.\n",
768 OUTPUT_REG (tmpulongest, tdep->arg5),
769 tdep->size_int);
770 return -1;
772 regcache_raw_read_unsigned (regcache, tdep->arg4, &optvalp);
773 tmpint = (int) extract_signed_integer (optlenp, tdep->size_int,
774 byte_order);
775 if (record_full_arch_list_add_mem ((CORE_ADDR) optvalp, tmpint))
776 return -1;
777 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
778 tdep->size_int))
779 return -1;
781 break;
783 case gdb_sys_socketcall:
784 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
785 switch (tmpulongest)
787 case RECORD_SYS_SOCKET:
788 case RECORD_SYS_BIND:
789 case RECORD_SYS_CONNECT:
790 case RECORD_SYS_LISTEN:
791 break;
792 case RECORD_SYS_ACCEPT:
793 case RECORD_SYS_GETSOCKNAME:
794 case RECORD_SYS_GETPEERNAME:
796 regcache_raw_read_unsigned (regcache, tdep->arg2,
797 &tmpulongest);
798 if (tmpulongest)
800 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong * 2);
801 ULONGEST len;
803 tmpulongest += tdep->size_ulong;
804 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
805 tdep->size_ulong * 2))
807 if (record_debug)
808 fprintf_unfiltered (gdb_stdlog,
809 "Process record: error reading "
810 "memory at addr = 0x%s len = %d.\n",
811 OUTPUT_REG (tmpulongest, tdep->arg2),
812 tdep->size_ulong * 2);
813 return -1;
815 tmpulongest = extract_unsigned_integer (a,
816 tdep->size_ulong,
817 byte_order);
818 len = extract_unsigned_integer (a + tdep->size_ulong,
819 tdep->size_ulong, byte_order);
820 if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
821 return -1;
824 break;
826 case RECORD_SYS_SOCKETPAIR:
828 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong);
830 regcache_raw_read_unsigned (regcache, tdep->arg2,
831 &tmpulongest);
832 if (tmpulongest)
834 tmpulongest += tdep->size_ulong * 3;
835 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
836 tdep->size_ulong))
838 if (record_debug)
839 fprintf_unfiltered (gdb_stdlog,
840 "Process record: error reading "
841 "memory at addr = 0x%s len = %d.\n",
842 OUTPUT_REG (tmpulongest, tdep->arg2),
843 tdep->size_ulong);
844 return -1;
846 tmpaddr
847 = (CORE_ADDR) extract_unsigned_integer (a, tdep->size_ulong,
848 byte_order);
849 if (record_full_arch_list_add_mem (tmpaddr, tdep->size_int))
850 return -1;
853 break;
854 case RECORD_SYS_SEND:
855 case RECORD_SYS_SENDTO:
856 break;
857 case RECORD_SYS_RECVFROM:
858 regcache_raw_read_unsigned (regcache, tdep->arg2,
859 &tmpulongest);
860 if (tmpulongest)
862 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong * 2);
863 ULONGEST len;
865 tmpulongest += tdep->size_ulong * 4;
866 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
867 tdep->size_ulong * 2))
869 if (record_debug)
870 fprintf_unfiltered (gdb_stdlog,
871 "Process record: error reading "
872 "memory at addr = 0x%s len = %d.\n",
873 OUTPUT_REG (tmpulongest, tdep->arg2),
874 tdep->size_ulong * 2);
875 return -1;
877 tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
878 byte_order);
879 len = extract_unsigned_integer (a + tdep->size_ulong,
880 tdep->size_ulong, byte_order);
881 if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
882 return -1;
884 break;
885 case RECORD_SYS_RECV:
886 regcache_raw_read_unsigned (regcache, tdep->arg2,
887 &tmpulongest);
888 if (tmpulongest)
890 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong * 2);
892 tmpulongest += tdep->size_ulong;
893 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
894 tdep->size_ulong))
896 if (record_debug)
897 fprintf_unfiltered (gdb_stdlog,
898 "Process record: error reading "
899 "memory at addr = 0x%s len = %d.\n",
900 OUTPUT_REG (tmpulongest, tdep->arg2),
901 tdep->size_ulong);
902 return -1;
904 tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
905 byte_order);
906 if (tmpulongest)
908 a += tdep->size_ulong;
909 tmpint = (int) extract_unsigned_integer (a, tdep->size_ulong,
910 byte_order);
911 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
912 tmpint))
913 return -1;
916 break;
917 case RECORD_SYS_SHUTDOWN:
918 case RECORD_SYS_SETSOCKOPT:
919 break;
920 case RECORD_SYS_GETSOCKOPT:
922 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong * 2);
923 gdb_byte *av = (gdb_byte *) alloca (tdep->size_int);
925 regcache_raw_read_unsigned (regcache, tdep->arg2,
926 &tmpulongest);
927 if (tmpulongest)
929 tmpulongest += tdep->size_ulong * 3;
930 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
931 tdep->size_ulong * 2))
933 if (record_debug)
934 fprintf_unfiltered (gdb_stdlog,
935 "Process record: error reading "
936 "memory at addr = 0x%s len = %d.\n",
937 OUTPUT_REG (tmpulongest, tdep->arg2),
938 tdep->size_ulong * 2);
939 return -1;
941 tmpulongest = extract_unsigned_integer (a + tdep->size_ulong,
942 tdep->size_ulong,
943 byte_order);
944 if (tmpulongest)
946 if (target_read_memory ((CORE_ADDR) tmpulongest, av,
947 tdep->size_int))
949 if (record_debug)
950 fprintf_unfiltered (gdb_stdlog,
951 "Process record: error reading "
952 "memory at addr = 0x%s "
953 "len = %d.\n",
954 phex_nz (tmpulongest,
955 tdep->size_ulong),
956 tdep->size_int);
957 return -1;
959 tmpaddr
960 = (CORE_ADDR) extract_unsigned_integer (a,
961 tdep->size_ulong,
962 byte_order);
963 tmpint = (int) extract_unsigned_integer (av,
964 tdep->size_int,
965 byte_order);
966 if (record_full_arch_list_add_mem (tmpaddr, tmpint))
967 return -1;
968 a += tdep->size_ulong;
969 tmpaddr
970 = (CORE_ADDR) extract_unsigned_integer (a,
971 tdep->size_ulong,
972 byte_order);
973 if (record_full_arch_list_add_mem (tmpaddr,
974 tdep->size_int))
975 return -1;
979 break;
980 case RECORD_SYS_SENDMSG:
981 break;
982 case RECORD_SYS_RECVMSG:
984 gdb_byte *a = (gdb_byte *) alloca (tdep->size_ulong);
986 regcache_raw_read_unsigned (regcache, tdep->arg2,
987 &tmpulongest);
988 if (tmpulongest)
990 tmpulongest += tdep->size_ulong;
991 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
992 tdep->size_ulong))
994 if (record_debug)
995 fprintf_unfiltered (gdb_stdlog,
996 "Process record: error reading "
997 "memory at addr = 0x%s len = %d.\n",
998 OUTPUT_REG (tmpulongest, tdep->arg2),
999 tdep->size_ulong);
1000 return -1;
1002 tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
1003 byte_order);
1004 if (record_linux_msghdr (regcache, tdep, tmpulongest))
1005 return -1;
1008 break;
1009 default:
1010 printf_unfiltered (_("Process record and replay target "
1011 "doesn't support socketcall call 0x%s\n"),
1012 OUTPUT_REG (tmpulongest, tdep->arg1));
1013 return -1;
1014 break;
1016 break;
1018 case gdb_sys_syslog:
1019 break;
1021 case gdb_sys_setitimer:
1022 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_itimerval))
1023 return -1;
1024 break;
1026 case gdb_sys_getitimer:
1027 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_itimerval))
1028 return -1;
1029 break;
1031 case gdb_sys_newstat:
1032 case gdb_sys_newlstat:
1033 case gdb_sys_newfstat:
1034 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_stat))
1035 return -1;
1036 break;
1038 case gdb_sys_newfstatat:
1039 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1040 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1041 tdep->size_stat))
1042 return -1;
1043 break;
1045 case gdb_sys_uname:
1046 if (record_mem_at_reg (regcache, tdep->arg1,
1047 tdep->size_old_utsname))
1048 return -1;
1049 break;
1051 case gdb_sys_iopl:
1052 case gdb_sys_vhangup:
1053 case gdb_sys_ni_syscall112:
1054 case gdb_sys_vm86old:
1055 break;
1057 case gdb_sys_wait4:
1058 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_int)
1059 || record_mem_at_reg (regcache, tdep->arg4, tdep->size_rusage))
1060 return -1;
1061 break;
1063 case gdb_sys_swapoff:
1064 break;
1066 case gdb_sys_sysinfo:
1067 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_sysinfo))
1068 return -1;
1069 break;
1071 case gdb_sys_shmget:
1072 case gdb_sys_semget:
1073 case gdb_sys_semop:
1074 case gdb_sys_msgget:
1075 /* XXX maybe need do some record works with sys_shmdt. */
1076 case gdb_sys_shmdt:
1077 case gdb_sys_msgsnd:
1078 case gdb_sys_semtimedop:
1079 break;
1081 case gdb_sys_shmat:
1082 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_ulong))
1083 return -1;
1084 break;
1086 case gdb_sys_shmctl:
1087 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_shmid_ds))
1088 return -1;
1089 break;
1091 /* XXX sys_semctl 525 still not supported. */
1092 /* sys_semctl */
1094 case gdb_sys_msgrcv:
1096 LONGEST l;
1098 regcache_raw_read_signed (regcache, tdep->arg3, &l);
1099 tmpint = l + tdep->size_long;
1100 if (record_mem_at_reg (regcache, tdep->arg2, tmpint))
1101 return -1;
1103 break;
1105 case gdb_sys_msgctl:
1106 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_msqid_ds))
1107 return -1;
1108 break;
1110 case gdb_sys_ipc:
1111 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1112 tmpulongest &= 0xffff;
1113 switch (tmpulongest)
1115 case RECORD_SEMOP:
1116 case RECORD_SEMGET:
1117 case RECORD_SEMTIMEDOP:
1118 case RECORD_MSGSND:
1119 case RECORD_MSGGET:
1120 /* XXX maybe need do some record works with RECORD_SHMDT. */
1121 case RECORD_SHMDT:
1122 case RECORD_SHMGET:
1123 break;
1124 case RECORD_MSGRCV:
1126 LONGEST second;
1128 regcache_raw_read_signed (regcache, tdep->arg3, &second);
1129 tmpint = (int) second + tdep->size_long;
1130 if (record_mem_at_reg (regcache, tdep->arg5, tmpint))
1131 return -1;
1133 break;
1134 case RECORD_MSGCTL:
1135 if (record_mem_at_reg (regcache, tdep->arg5,
1136 tdep->size_msqid_ds))
1137 return -1;
1138 break;
1139 case RECORD_SHMAT:
1140 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_ulong))
1141 return -1;
1142 break;
1143 case RECORD_SHMCTL:
1144 if (record_mem_at_reg (regcache, tdep->arg5,
1145 tdep->size_shmid_ds))
1146 return -1;
1147 break;
1148 default:
1149 /* XXX RECORD_SEMCTL still not supported. */
1150 printf_unfiltered (_("Process record and replay target doesn't "
1151 "support ipc number %s\n"),
1152 pulongest (tmpulongest));
1153 break;
1155 break;
1157 case gdb_sys_fsync:
1158 case gdb_sys_sigreturn:
1159 case gdb_sys_clone:
1160 case gdb_sys_setdomainname:
1161 break;
1163 case gdb_sys_newuname:
1164 if (record_mem_at_reg (regcache, tdep->arg1,
1165 tdep->size_new_utsname))
1166 return -1;
1167 break;
1169 case gdb_sys_modify_ldt:
1170 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1171 if (tmpulongest == 0 || tmpulongest == 2)
1173 ULONGEST bytecount;
1175 regcache_raw_read_unsigned (regcache, tdep->arg3, &bytecount);
1176 if (record_mem_at_reg (regcache, tdep->arg2, (int) bytecount))
1177 return -1;
1179 break;
1181 case gdb_sys_adjtimex:
1182 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_timex))
1183 return -1;
1184 break;
1186 case gdb_sys_mprotect:
1187 break;
1189 case gdb_sys_sigprocmask:
1190 if (record_mem_at_reg (regcache, tdep->arg3,
1191 tdep->size_old_sigset_t))
1192 return -1;
1193 break;
1195 case gdb_sys_ni_syscall127:
1196 case gdb_sys_init_module:
1197 case gdb_sys_delete_module:
1198 case gdb_sys_ni_syscall130:
1199 break;
1201 case gdb_sys_quotactl:
1202 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1203 switch (tmpulongest)
1205 case RECORD_Q_GETFMT:
1206 /* __u32 */
1207 if (record_mem_at_reg (regcache, tdep->arg4, 4))
1208 return -1;
1209 break;
1210 case RECORD_Q_GETINFO:
1211 if (record_mem_at_reg (regcache, tdep->arg4,
1212 tdep->size_mem_dqinfo))
1213 return -1;
1214 break;
1215 case RECORD_Q_GETQUOTA:
1216 if (record_mem_at_reg (regcache, tdep->arg4,
1217 tdep->size_if_dqblk))
1218 return -1;
1219 break;
1220 case RECORD_Q_XGETQSTAT:
1221 case RECORD_Q_XGETQUOTA:
1222 if (record_mem_at_reg (regcache, tdep->arg4,
1223 tdep->size_fs_quota_stat))
1224 return -1;
1225 break;
1227 break;
1229 case gdb_sys_getpgid:
1230 case gdb_sys_fchdir:
1231 case gdb_sys_bdflush:
1232 break;
1234 case gdb_sys_sysfs:
1235 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1236 if (tmpulongest == 2)
1238 /*XXX the size of memory is not very clear. */
1239 if (record_mem_at_reg (regcache, tdep->arg3, 10))
1240 return -1;
1242 break;
1244 case gdb_sys_personality:
1245 case gdb_sys_ni_syscall137:
1246 case gdb_sys_setfsuid16:
1247 case gdb_sys_setfsgid16:
1248 break;
1250 case gdb_sys_llseek:
1251 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_loff_t))
1252 return -1;
1253 break;
1255 case gdb_sys_getdents:
1256 case gdb_sys_getdents64:
1257 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1258 if (record_mem_at_reg (regcache, tdep->arg2, tmpulongest))
1259 return -1;
1260 break;
1262 case gdb_sys_select:
1263 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_fd_set)
1264 || record_mem_at_reg (regcache, tdep->arg3, tdep->size_fd_set)
1265 || record_mem_at_reg (regcache, tdep->arg4, tdep->size_fd_set)
1266 || record_mem_at_reg (regcache, tdep->arg5, tdep->size_timeval))
1267 return -1;
1268 break;
1270 case gdb_sys_flock:
1271 case gdb_sys_msync:
1272 break;
1274 case gdb_sys_readv:
1276 ULONGEST vec, vlen;
1278 regcache_raw_read_unsigned (regcache, tdep->arg2, &vec);
1279 if (vec)
1281 gdb_byte *iov = (gdb_byte *) alloca (tdep->size_iovec);
1283 regcache_raw_read_unsigned (regcache, tdep->arg3, &vlen);
1284 for (tmpulongest = 0; tmpulongest < vlen; tmpulongest++)
1286 if (target_read_memory ((CORE_ADDR) vec, iov,
1287 tdep->size_iovec))
1289 if (record_debug)
1290 fprintf_unfiltered (gdb_stdlog,
1291 "Process record: error reading "
1292 "memory at addr = 0x%s len = %d.\n",
1293 OUTPUT_REG (vec, tdep->arg2),
1294 tdep->size_iovec);
1295 return -1;
1297 tmpaddr
1298 = (CORE_ADDR) extract_unsigned_integer (iov,
1299 tdep->size_pointer,
1300 byte_order);
1301 tmpint
1302 = (int) extract_unsigned_integer (iov + tdep->size_pointer,
1303 tdep->size_size_t,
1304 byte_order);
1305 if (record_full_arch_list_add_mem (tmpaddr, tmpint))
1306 return -1;
1307 vec += tdep->size_iovec;
1311 break;
1313 case gdb_sys_writev:
1314 case gdb_sys_getsid:
1315 case gdb_sys_fdatasync:
1316 case gdb_sys_sysctl:
1317 case gdb_sys_mlock:
1318 case gdb_sys_munlock:
1319 case gdb_sys_mlockall:
1320 case gdb_sys_munlockall:
1321 case gdb_sys_sched_setparam:
1322 break;
1324 case gdb_sys_sched_getparam:
1325 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_int))
1326 return -1;
1327 break;
1329 case gdb_sys_sched_setscheduler:
1330 case gdb_sys_sched_getscheduler:
1331 case gdb_sys_sched_yield:
1332 case gdb_sys_sched_get_priority_max:
1333 case gdb_sys_sched_get_priority_min:
1334 break;
1336 case gdb_sys_sched_rr_get_interval:
1337 case gdb_sys_nanosleep:
1338 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_timespec))
1339 return -1;
1340 break;
1342 case gdb_sys_mremap:
1343 case gdb_sys_setresuid16:
1344 break;
1346 case gdb_sys_getresuid16:
1347 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_old_uid_t)
1348 || record_mem_at_reg (regcache, tdep->arg2,
1349 tdep->size_old_uid_t)
1350 || record_mem_at_reg (regcache, tdep->arg3,
1351 tdep->size_old_uid_t))
1352 return -1;
1353 break;
1355 case gdb_sys_vm86:
1356 case gdb_sys_ni_syscall167:
1357 break;
1359 case gdb_sys_poll:
1360 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1361 if (tmpulongest)
1363 ULONGEST nfds;
1365 regcache_raw_read_unsigned (regcache, tdep->arg2, &nfds);
1366 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1367 tdep->size_pollfd * nfds))
1368 return -1;
1370 break;
1372 case gdb_sys_nfsservctl:
1373 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1374 if (tmpulongest == 7 || tmpulongest == 8)
1376 int rsize;
1378 if (tmpulongest == 7)
1379 rsize = tdep->size_NFS_FHSIZE;
1380 else
1381 rsize = tdep->size_knfsd_fh;
1382 if (record_mem_at_reg (regcache, tdep->arg3, rsize))
1383 return -1;
1385 break;
1387 case gdb_sys_setresgid16:
1388 break;
1390 case gdb_sys_getresgid16:
1391 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_old_gid_t)
1392 || record_mem_at_reg (regcache, tdep->arg2,
1393 tdep->size_old_gid_t)
1394 || record_mem_at_reg (regcache, tdep->arg3,
1395 tdep->size_old_gid_t))
1396 return -1;
1397 break;
1399 case gdb_sys_prctl:
1400 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1401 switch (tmpulongest)
1403 case 2:
1404 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_int))
1405 return -1;
1406 break;
1407 case 16:
1408 if (record_mem_at_reg (regcache, tdep->arg2,
1409 tdep->size_TASK_COMM_LEN))
1410 return -1;
1411 break;
1413 break;
1415 case gdb_sys_rt_sigreturn:
1416 break;
1418 case gdb_sys_rt_sigaction:
1419 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_sigaction))
1420 return -1;
1421 break;
1423 case gdb_sys_rt_sigprocmask:
1424 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_sigset_t))
1425 return -1;
1426 break;
1428 case gdb_sys_rt_sigpending:
1429 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1430 if (tmpulongest)
1432 ULONGEST sigsetsize;
1434 regcache_raw_read_unsigned (regcache, tdep->arg2,&sigsetsize);
1435 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1436 (int) sigsetsize))
1437 return -1;
1439 break;
1441 case gdb_sys_rt_sigtimedwait:
1442 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_siginfo_t))
1443 return -1;
1444 break;
1446 case gdb_sys_rt_sigqueueinfo:
1447 case gdb_sys_rt_sigsuspend:
1448 break;
1450 case gdb_sys_pread64:
1451 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1452 if (tmpulongest)
1454 ULONGEST count;
1456 regcache_raw_read_unsigned (regcache, tdep->arg3,&count);
1457 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1458 (int) count))
1459 return -1;
1461 break;
1463 case gdb_sys_pwrite64:
1464 case gdb_sys_chown16:
1465 break;
1467 case gdb_sys_getcwd:
1468 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1469 if (tmpulongest)
1471 ULONGEST size;
1473 regcache_raw_read_unsigned (regcache, tdep->arg2, &size);
1474 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1475 (int) size))
1476 return -1;
1478 break;
1480 case gdb_sys_capget:
1481 if (record_mem_at_reg (regcache, tdep->arg2,
1482 tdep->size_cap_user_data_t))
1483 return -1;
1484 break;
1486 case gdb_sys_capset:
1487 break;
1489 case gdb_sys_sigaltstack:
1490 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_stack_t))
1491 return -1;
1492 break;
1494 case gdb_sys_sendfile:
1495 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_off_t))
1496 return -1;
1497 break;
1499 case gdb_sys_ni_syscall188:
1500 case gdb_sys_ni_syscall189:
1501 case gdb_sys_vfork:
1502 break;
1504 case gdb_sys_getrlimit:
1505 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_rlimit))
1506 return -1;
1507 break;
1509 case gdb_sys_mmap2:
1510 break;
1512 case gdb_sys_truncate64:
1513 case gdb_sys_ftruncate64:
1514 break;
1516 case gdb_sys_stat64:
1517 case gdb_sys_lstat64:
1518 case gdb_sys_fstat64:
1519 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_stat64))
1520 return -1;
1521 break;
1523 case gdb_sys_lchown:
1524 case gdb_sys_getuid:
1525 case gdb_sys_getgid:
1526 case gdb_sys_geteuid:
1527 case gdb_sys_getegid:
1528 case gdb_sys_setreuid:
1529 case gdb_sys_setregid:
1530 break;
1532 case gdb_sys_getgroups:
1533 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1534 if (tmpulongest)
1536 ULONGEST gidsetsize;
1538 regcache_raw_read_unsigned (regcache, tdep->arg1,
1539 &gidsetsize);
1540 tmpint = tdep->size_gid_t * (int) gidsetsize;
1541 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest, tmpint))
1542 return -1;
1544 break;
1546 case gdb_sys_setgroups:
1547 case gdb_sys_fchown:
1548 case gdb_sys_setresuid:
1549 break;
1551 case gdb_sys_getresuid:
1552 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_uid_t)
1553 || record_mem_at_reg (regcache, tdep->arg2, tdep->size_uid_t)
1554 || record_mem_at_reg (regcache, tdep->arg3, tdep->size_uid_t))
1555 return -1;
1556 break;
1558 case gdb_sys_setresgid:
1559 break;
1561 case gdb_sys_getresgid:
1562 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_gid_t)
1563 || record_mem_at_reg (regcache, tdep->arg2, tdep->size_gid_t)
1564 || record_mem_at_reg (regcache, tdep->arg3, tdep->size_gid_t))
1565 return -1;
1566 break;
1568 case gdb_sys_chown:
1569 case gdb_sys_setuid:
1570 case gdb_sys_setgid:
1571 case gdb_sys_setfsuid:
1572 case gdb_sys_setfsgid:
1573 case gdb_sys_pivot_root:
1574 break;
1576 case gdb_sys_mincore:
1577 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_PAGE_SIZE))
1578 return -1;
1579 break;
1581 case gdb_sys_madvise:
1582 break;
1584 case gdb_sys_fcntl64:
1585 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1586 if (tmpulongest == tdep->fcntl_F_GETLK64)
1588 if (record_mem_at_reg (regcache, tdep->arg3,
1589 tdep->size_flock64))
1590 return -1;
1592 else if (tmpulongest != tdep->fcntl_F_SETLK64
1593 && tmpulongest != tdep->fcntl_F_SETLKW64)
1595 goto sys_fcntl;
1597 break;
1599 case gdb_sys_ni_syscall222:
1600 case gdb_sys_ni_syscall223:
1601 case gdb_sys_gettid:
1602 case gdb_sys_readahead:
1603 case gdb_sys_setxattr:
1604 case gdb_sys_lsetxattr:
1605 case gdb_sys_fsetxattr:
1606 break;
1608 case gdb_sys_getxattr:
1609 case gdb_sys_lgetxattr:
1610 case gdb_sys_fgetxattr:
1611 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1612 if (tmpulongest)
1614 ULONGEST size;
1616 regcache_raw_read_unsigned (regcache, tdep->arg4, &size);
1617 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1618 (int) size))
1619 return -1;
1621 break;
1623 case gdb_sys_listxattr:
1624 case gdb_sys_llistxattr:
1625 case gdb_sys_flistxattr:
1626 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1627 if (tmpulongest)
1629 ULONGEST size;
1631 regcache_raw_read_unsigned (regcache, tdep->arg3, &size);
1632 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1633 (int) size))
1634 return -1;
1636 break;
1638 case gdb_sys_removexattr:
1639 case gdb_sys_lremovexattr:
1640 case gdb_sys_fremovexattr:
1641 case gdb_sys_tkill:
1642 break;
1644 case gdb_sys_sendfile64:
1645 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_loff_t))
1646 return -1;
1647 break;
1649 case gdb_sys_futex:
1650 case gdb_sys_sched_setaffinity:
1651 break;
1653 case gdb_sys_sched_getaffinity:
1654 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1655 if (tmpulongest)
1657 ULONGEST len;
1659 regcache_raw_read_unsigned (regcache, tdep->arg2, &len);
1660 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1661 (int) len))
1662 return -1;
1664 break;
1666 case gdb_sys_set_thread_area:
1667 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int))
1668 return -1;
1669 break;
1671 case gdb_sys_get_thread_area:
1672 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_user_desc))
1673 return -1;
1674 break;
1676 case gdb_sys_io_setup:
1677 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_long))
1678 return -1;
1679 break;
1681 case gdb_sys_io_destroy:
1682 break;
1684 case gdb_sys_io_getevents:
1685 regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
1686 if (tmpulongest)
1688 ULONGEST nr;
1690 regcache_raw_read_unsigned (regcache, tdep->arg3, &nr);
1691 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1692 nr * tdep->size_io_event))
1693 return -1;
1695 break;
1697 case gdb_sys_io_submit:
1698 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1699 if (tmpulongest)
1701 ULONGEST nr, i;
1702 gdb_byte *iocbp;
1704 regcache_raw_read_unsigned (regcache, tdep->arg2, &nr);
1705 iocbp = (gdb_byte *) alloca (nr * tdep->size_pointer);
1706 if (target_read_memory ((CORE_ADDR) tmpulongest, iocbp,
1707 nr * tdep->size_pointer))
1709 if (record_debug)
1710 fprintf_unfiltered (gdb_stdlog,
1711 "Process record: error reading memory "
1712 "at addr = 0x%s len = %u.\n",
1713 OUTPUT_REG (tmpulongest, tdep->arg2),
1714 (int) (nr * tdep->size_pointer));
1715 return -1;
1717 for (i = 0; i < nr; i++)
1719 tmpaddr
1720 = (CORE_ADDR) extract_unsigned_integer (iocbp,
1721 tdep->size_pointer,
1722 byte_order);
1723 if (record_full_arch_list_add_mem (tmpaddr, tdep->size_iocb))
1724 return -1;
1725 iocbp += tdep->size_pointer;
1728 break;
1730 case gdb_sys_io_cancel:
1731 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_io_event))
1732 return -1;
1733 break;
1735 case gdb_sys_fadvise64:
1736 case gdb_sys_ni_syscall251:
1737 break;
1739 case gdb_sys_exit_group:
1740 if (yquery (_("The next instruction is syscall exit_group. "
1741 "It will make the program exit. "
1742 "Do you want to stop the program?")))
1743 return 1;
1744 break;
1746 case gdb_sys_lookup_dcookie:
1747 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1748 if (tmpulongest)
1750 ULONGEST len;
1752 regcache_raw_read_unsigned (regcache, tdep->arg3, &len);
1753 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1754 (int) len))
1755 return -1;
1757 break;
1759 case gdb_sys_epoll_create:
1760 case gdb_sys_epoll_ctl:
1761 break;
1763 case gdb_sys_epoll_wait:
1764 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1765 if (tmpulongest)
1767 ULONGEST maxevents;
1769 regcache_raw_read_unsigned (regcache, tdep->arg3, &maxevents);
1770 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1771 (maxevents
1772 * tdep->size_epoll_event)))
1773 return -1;
1775 break;
1777 case gdb_sys_remap_file_pages:
1778 case gdb_sys_set_tid_address:
1779 break;
1781 case gdb_sys_timer_create:
1782 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_int))
1783 return -1;
1784 break;
1786 case gdb_sys_timer_settime:
1787 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_itimerspec))
1788 return -1;
1789 break;
1791 case gdb_sys_timer_gettime:
1792 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_itimerspec))
1793 return -1;
1794 break;
1796 case gdb_sys_timer_getoverrun:
1797 case gdb_sys_timer_delete:
1798 case gdb_sys_clock_settime:
1799 break;
1801 case gdb_sys_clock_gettime:
1802 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_timespec))
1803 return -1;
1804 break;
1806 case gdb_sys_clock_getres:
1807 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_timespec))
1808 return -1;
1809 break;
1811 case gdb_sys_clock_nanosleep:
1812 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_timespec))
1813 return -1;
1814 break;
1816 case gdb_sys_statfs64:
1817 case gdb_sys_fstatfs64:
1818 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_statfs64))
1819 return -1;
1820 break;
1822 case gdb_sys_tgkill:
1823 case gdb_sys_utimes:
1824 case gdb_sys_fadvise64_64:
1825 case gdb_sys_ni_syscall273:
1826 case gdb_sys_mbind:
1827 break;
1829 case gdb_sys_get_mempolicy:
1830 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int))
1831 return -1;
1832 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1833 if (tmpulongest)
1835 ULONGEST maxnode;
1837 regcache_raw_read_unsigned (regcache, tdep->arg3, &maxnode);
1838 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1839 maxnode * tdep->size_long))
1840 return -1;
1842 break;
1844 case gdb_sys_set_mempolicy:
1845 case gdb_sys_mq_open:
1846 case gdb_sys_mq_unlink:
1847 case gdb_sys_mq_timedsend:
1848 break;
1850 case gdb_sys_mq_timedreceive:
1851 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1852 if (tmpulongest)
1854 ULONGEST msg_len;
1856 regcache_raw_read_unsigned (regcache, tdep->arg3, &msg_len);
1857 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1858 (int) msg_len))
1859 return -1;
1861 if (record_mem_at_reg (regcache, tdep->arg4, tdep->size_int))
1862 return -1;
1863 break;
1865 case gdb_sys_mq_notify:
1866 break;
1868 case gdb_sys_mq_getsetattr:
1869 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_mq_attr))
1870 return -1;
1871 break;
1873 case gdb_sys_kexec_load:
1874 break;
1876 case gdb_sys_waitid:
1877 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_siginfo_t)
1878 || record_mem_at_reg (regcache, tdep->arg5, tdep->size_rusage))
1879 return -1;
1880 break;
1882 case gdb_sys_ni_syscall285:
1883 case gdb_sys_add_key:
1884 case gdb_sys_request_key:
1885 break;
1887 case gdb_sys_keyctl:
1888 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1889 if (tmpulongest == 6 || tmpulongest == 11)
1891 regcache_raw_read_unsigned (regcache, tdep->arg3,
1892 &tmpulongest);
1893 if (tmpulongest)
1895 ULONGEST buflen;
1897 regcache_raw_read_unsigned (regcache, tdep->arg4, &buflen);
1898 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1899 (int) buflen))
1900 return -1;
1903 break;
1905 case gdb_sys_ioprio_set:
1906 case gdb_sys_ioprio_get:
1907 case gdb_sys_inotify_init:
1908 case gdb_sys_inotify_add_watch:
1909 case gdb_sys_inotify_rm_watch:
1910 case gdb_sys_migrate_pages:
1911 case gdb_sys_openat:
1912 case gdb_sys_mkdirat:
1913 case gdb_sys_mknodat:
1914 case gdb_sys_fchownat:
1915 case gdb_sys_futimesat:
1916 break;
1918 case gdb_sys_fstatat64:
1919 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_stat64))
1920 return -1;
1921 break;
1923 case gdb_sys_unlinkat:
1924 case gdb_sys_renameat:
1925 case gdb_sys_linkat:
1926 case gdb_sys_symlinkat:
1927 break;
1929 case gdb_sys_readlinkat:
1930 regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1931 if (tmpulongest)
1933 ULONGEST bufsiz;
1935 regcache_raw_read_unsigned (regcache, tdep->arg4, &bufsiz);
1936 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1937 (int) bufsiz))
1938 return -1;
1940 break;
1942 case gdb_sys_fchmodat:
1943 case gdb_sys_faccessat:
1944 break;
1946 case gdb_sys_pselect6:
1947 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_fd_set)
1948 || record_mem_at_reg (regcache, tdep->arg3, tdep->size_fd_set)
1949 || record_mem_at_reg (regcache, tdep->arg4, tdep->size_fd_set)
1950 || record_mem_at_reg (regcache, tdep->arg5, tdep->size_timespec))
1951 return -1;
1952 break;
1954 case gdb_sys_ppoll:
1955 regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1956 if (tmpulongest)
1958 ULONGEST nfds;
1960 regcache_raw_read_unsigned (regcache, tdep->arg2, &nfds);
1961 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1962 tdep->size_pollfd * nfds))
1963 return -1;
1965 if (record_mem_at_reg (regcache, tdep->arg3, tdep->size_timespec))
1966 return -1;
1967 break;
1969 case gdb_sys_unshare:
1970 case gdb_sys_set_robust_list:
1971 break;
1973 case gdb_sys_get_robust_list:
1974 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_int)
1975 || record_mem_at_reg (regcache, tdep->arg3, tdep->size_int))
1976 return -1;
1977 break;
1979 case gdb_sys_splice:
1980 if (record_mem_at_reg (regcache, tdep->arg2, tdep->size_loff_t)
1981 || record_mem_at_reg (regcache, tdep->arg4, tdep->size_loff_t))
1982 return -1;
1983 break;
1985 case gdb_sys_sync_file_range:
1986 case gdb_sys_tee:
1987 case gdb_sys_vmsplice:
1988 break;
1990 case gdb_sys_move_pages:
1991 regcache_raw_read_unsigned (regcache, tdep->arg5, &tmpulongest);
1992 if (tmpulongest)
1994 ULONGEST nr_pages;
1996 regcache_raw_read_unsigned (regcache, tdep->arg2, &nr_pages);
1997 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1998 nr_pages * tdep->size_int))
1999 return -1;
2001 break;
2003 case gdb_sys_getcpu:
2004 if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int)
2005 || record_mem_at_reg (regcache, tdep->arg2, tdep->size_int)
2006 || record_mem_at_reg (regcache, tdep->arg3,
2007 tdep->size_ulong * 2))
2008 return -1;
2009 break;
2011 case gdb_sys_epoll_pwait:
2012 regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
2013 if (tmpulongest)
2015 ULONGEST maxevents;
2017 regcache_raw_read_unsigned (regcache, tdep->arg3, &maxevents);
2018 tmpint = (int) maxevents * tdep->size_epoll_event;
2019 if (record_full_arch_list_add_mem ((CORE_ADDR) tmpulongest, tmpint))
2020 return -1;
2022 break;
2024 case gdb_sys_fallocate:
2025 case gdb_sys_eventfd2:
2026 case gdb_sys_epoll_create1:
2027 case gdb_sys_dup3:
2028 break;
2030 case gdb_sys_inotify_init1:
2031 break;
2033 default:
2034 printf_unfiltered (_("Process record and replay target doesn't "
2035 "support syscall number %d\n"), syscall);
2036 return -1;
2037 break;
2040 return 0;