* gdbtypes.c (check_typedef): Document that this function can
[platform/upstream/binutils.git] / gdb / linux-record.c
1 /* Process record and replay target code for GNU/Linux.
2
3    Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4
5    This file is part of GDB.
6
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.
11
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.
16
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/>.  */
19
20 #include "defs.h"
21 #include "target.h"
22 #include "gdbtypes.h"
23 #include "regcache.h"
24 #include "record.h"
25 #include "linux-record.h"
26
27 /* These macros are the values of the first argument of system call
28    "sys_ptrace".  The values of these macros were obtained from Linux
29    Kernel source.  */
30
31 #define RECORD_PTRACE_PEEKTEXT  1
32 #define RECORD_PTRACE_PEEKDATA  2
33 #define RECORD_PTRACE_PEEKUSR   3
34
35 /* These macros are the values of the first argument of system call
36    "sys_socketcall".  The values of these macros were obtained from
37    Linux Kernel source.  */
38
39 #define RECORD_SYS_SOCKET       1
40 #define RECORD_SYS_BIND         2
41 #define RECORD_SYS_CONNECT      3
42 #define RECORD_SYS_LISTEN       4
43 #define RECORD_SYS_ACCEPT       5
44 #define RECORD_SYS_GETSOCKNAME  6
45 #define RECORD_SYS_GETPEERNAME  7
46 #define RECORD_SYS_SOCKETPAIR   8
47 #define RECORD_SYS_SEND         9
48 #define RECORD_SYS_RECV         10
49 #define RECORD_SYS_SENDTO       11
50 #define RECORD_SYS_RECVFROM     12
51 #define RECORD_SYS_SHUTDOWN     13
52 #define RECORD_SYS_SETSOCKOPT   14
53 #define RECORD_SYS_GETSOCKOPT   15
54 #define RECORD_SYS_SENDMSG      16
55 #define RECORD_SYS_RECVMSG      17
56
57 /* These macros are the values of the first argument of system call
58    "sys_ipc".  The values of these macros were obtained from Linux
59    Kernel source.  */
60
61 #define RECORD_SEMOP            1
62 #define RECORD_SEMGET           2
63 #define RECORD_SEMCTL           3
64 #define RECORD_SEMTIMEDOP       4
65 #define RECORD_MSGSND           11
66 #define RECORD_MSGRCV           12
67 #define RECORD_MSGGET           13
68 #define RECORD_MSGCTL           14
69 #define RECORD_SHMAT            21
70 #define RECORD_SHMDT            22
71 #define RECORD_SHMGET           23
72 #define RECORD_SHMCTL           24
73
74 /* These macros are the values of the first argument of system call
75    "sys_quotactl".  The values of these macros were obtained from Linux
76    Kernel source.  */
77
78 #define RECORD_Q_GETFMT         0x800004
79 #define RECORD_Q_GETINFO        0x800005
80 #define RECORD_Q_GETQUOTA       0x800007
81 #define RECORD_Q_XGETQSTAT      (('5' << 8) + 5)
82 #define RECORD_Q_XGETQUOTA      (('3' << 8) + 3)
83
84 #define OUTPUT_REG(val, num)      phex_nz ((val), \
85     TYPE_LENGTH (gdbarch_register_type (get_regcache_arch (regcache), (num))))
86
87 static int
88 record_linux_sockaddr (struct regcache *regcache,
89                        struct linux_record_tdep *tdep, ULONGEST addr,
90                        ULONGEST len)
91 {
92   gdb_byte *a;
93   int addrlen;
94   struct gdbarch *gdbarch = get_regcache_arch (regcache);
95   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
96
97   if (!addr)
98     return 0;
99
100   a = alloca (tdep->size_int);
101
102   if (record_arch_list_add_mem ((CORE_ADDR) len, tdep->size_int))
103     return -1;
104
105   /* Get the addrlen.  */
106   if (target_read_memory ((CORE_ADDR) len, a, tdep->size_int))
107     {
108       if (record_debug)
109         fprintf_unfiltered (gdb_stdlog,
110                             "Process record: error reading "
111                             "memory at addr = 0x%s len = %d.\n",
112                             phex_nz (len, tdep->size_pointer),
113                             tdep->size_int);
114         return -1;
115     }
116   addrlen = (int) extract_unsigned_integer (a, tdep->size_int, byte_order);
117   if (addrlen <= 0 || addrlen > tdep->size_sockaddr)
118     addrlen = tdep->size_sockaddr;
119
120   if (record_arch_list_add_mem ((CORE_ADDR) addr, addrlen))
121     return -1;
122
123   return 0;
124 }
125
126 static int
127 record_linux_msghdr (struct regcache *regcache,
128                      struct linux_record_tdep *tdep, ULONGEST addr)
129 {
130   gdb_byte *a;
131   struct gdbarch *gdbarch = get_regcache_arch (regcache);
132   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
133   CORE_ADDR tmpaddr;
134   int tmpint;
135
136   if (!addr)
137     return 0;
138
139   if (record_arch_list_add_mem ((CORE_ADDR) addr, tdep->size_msghdr))
140     return -1;
141
142   a = alloca (tdep->size_msghdr);
143   if (target_read_memory ((CORE_ADDR) addr, a, tdep->size_msghdr))
144     {
145       if (record_debug)
146         fprintf_unfiltered (gdb_stdlog,
147                             "Process record: error reading "
148                             "memory at addr = 0x%s "
149                             "len = %d.\n",
150                             phex_nz (addr, tdep->size_pointer),
151                             tdep->size_msghdr);
152         return -1;
153     }
154
155   /* msg_name msg_namelen */
156   addr = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
157   a += tdep->size_pointer;
158   if (record_arch_list_add_mem ((CORE_ADDR) addr,
159                                 (int) extract_unsigned_integer (a,
160                                                                 tdep->size_int,
161                                                                 byte_order)))
162     return -1;
163   a += tdep->size_int;
164
165   /* msg_iov msg_iovlen */
166   addr = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
167   a += tdep->size_pointer;
168   if (addr)
169     {
170       ULONGEST i;
171       ULONGEST len = extract_unsigned_integer (a, tdep->size_size_t,
172                                                byte_order);
173       gdb_byte *iov = alloca (tdep->size_iovec);
174
175       for (i = 0; i < len; i++)
176         {
177           if (target_read_memory ((CORE_ADDR) addr, iov, tdep->size_iovec))
178             {
179               if (record_debug)
180                 fprintf_unfiltered (gdb_stdlog,
181                                     "Process record: error "
182                                     "reading memory at "
183                                     "addr = 0x%s "
184                                     "len = %d.\n",
185                                     phex_nz (addr,tdep->size_pointer),
186                                     tdep->size_iovec);
187                 return -1;
188             }
189           tmpaddr = (CORE_ADDR) extract_unsigned_integer (iov,
190                                                           tdep->size_pointer,
191                                                           byte_order);
192           tmpint = (int) extract_unsigned_integer (iov + tdep->size_pointer,
193                                                    tdep->size_size_t,
194                                                    byte_order);
195           if (record_arch_list_add_mem (tmpaddr, tmpint))
196             return -1;
197           addr += tdep->size_iovec;
198         }
199     }
200   a += tdep->size_size_t;
201
202   /* msg_control msg_controllen */
203   addr = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
204   a += tdep->size_pointer;
205   tmpint = (int) extract_unsigned_integer (a, tdep->size_size_t, byte_order);
206   if (record_arch_list_add_mem ((CORE_ADDR) addr, tmpint))
207     return -1;
208
209   return 0;
210 }
211
212 /* When the architecture process record get a Linux syscall
213    instruction, it will get a Linux syscall number of this
214    architecture and convert it to the Linux syscall number "num" which
215    is internal to GDB.  Most Linux syscalls across architectures in
216    Linux would be similar and mostly differ by sizes of types and
217    structures.  This sizes are put to "tdep".
218
219    Record the values of the registers and memory that will be changed
220    in current system call.
221
222    Return -1 if something wrong.  */
223
224 int
225 record_linux_system_call (enum gdb_syscall syscall, 
226                           struct regcache *regcache,
227                           struct linux_record_tdep *tdep)
228 {
229   struct gdbarch *gdbarch = get_regcache_arch (regcache);
230   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
231   ULONGEST tmpulongest;
232   CORE_ADDR tmpaddr;
233   int tmpint;
234
235   switch (syscall)
236     {
237     case gdb_sys_restart_syscall:
238       break;
239
240     case gdb_sys_exit:
241       {
242         int q;
243
244         target_terminal_ours ();
245         q = yquery (_("The next instruction is syscall exit.  "
246                       "It will make the program exit.  "
247                       "Do you want to stop the program?"));
248         target_terminal_inferior ();
249         if (q)
250           return 1;
251       }
252       break;
253
254     case gdb_sys_fork:
255       break;
256
257     case gdb_sys_read:
258       {
259         ULONGEST addr, count;
260
261         regcache_raw_read_unsigned (regcache, tdep->arg2, &addr);
262         regcache_raw_read_unsigned (regcache, tdep->arg3, &count);
263         if (record_arch_list_add_mem ((CORE_ADDR) addr, (int) count))
264           return -1;
265       }
266       break;
267
268     case gdb_sys_write:
269     case gdb_sys_open:
270     case gdb_sys_close:
271     case gdb_sys_waitpid:
272     case gdb_sys_creat:
273     case gdb_sys_link:
274     case gdb_sys_unlink:
275     case gdb_sys_execve:
276     case gdb_sys_chdir:
277     case gdb_sys_time:
278     case gdb_sys_mknod:
279     case gdb_sys_chmod:
280     case gdb_sys_lchown16:
281     case gdb_sys_ni_syscall17:
282       break;
283
284     case gdb_sys_stat:
285     case gdb_sys_fstat:
286     case gdb_sys_lstat:
287       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
288       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
289                                     tdep->size__old_kernel_stat))
290         return -1;
291       break;
292
293     case gdb_sys_lseek:
294     case gdb_sys_getpid:
295     case gdb_sys_mount:
296     case gdb_sys_oldumount:
297     case gdb_sys_setuid16:
298     case gdb_sys_getuid16:
299     case gdb_sys_stime:
300       break;
301
302     case gdb_sys_ptrace:
303       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
304       if (tmpulongest == RECORD_PTRACE_PEEKTEXT
305           || tmpulongest == RECORD_PTRACE_PEEKDATA
306           || tmpulongest == RECORD_PTRACE_PEEKUSR)
307         {
308           regcache_raw_read_unsigned (regcache, tdep->arg4,
309                                       &tmpulongest);
310           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, 4))
311             return -1;
312         }
313       break;
314
315     case gdb_sys_alarm:
316     case gdb_sys_pause:
317     case gdb_sys_utime:
318     case gdb_sys_ni_syscall31:
319     case gdb_sys_ni_syscall32:
320     case gdb_sys_access:
321     case gdb_sys_nice:
322     case gdb_sys_ni_syscall35:
323     case gdb_sys_sync:
324     case gdb_sys_kill:
325     case gdb_sys_rename:
326     case gdb_sys_mkdir:
327     case gdb_sys_rmdir:
328     case gdb_sys_dup:
329     case gdb_sys_pipe:
330       break;
331
332     case gdb_sys_times:
333       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
334       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_tms))
335         return -1;
336       break;
337
338     case gdb_sys_ni_syscall44:
339     case gdb_sys_brk:
340     case gdb_sys_setgid16:
341     case gdb_sys_getgid16:
342     case gdb_sys_signal:
343     case gdb_sys_geteuid16:
344     case gdb_sys_getegid16:
345     case gdb_sys_acct:
346     case gdb_sys_umount:
347     case gdb_sys_ni_syscall53:
348       break;
349
350     case gdb_sys_ioctl:
351       /* XXX Need to add a lot of support of other ioctl requests.  */
352       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
353       if (tmpulongest == tdep->ioctl_FIOCLEX
354           || tmpulongest == tdep->ioctl_FIONCLEX
355           || tmpulongest == tdep->ioctl_FIONBIO
356           || tmpulongest == tdep->ioctl_FIOASYNC
357           || tmpulongest == tdep->ioctl_TCSETS
358           || tmpulongest == tdep->ioctl_TCSETSW
359           || tmpulongest == tdep->ioctl_TCSETSF
360           || tmpulongest == tdep->ioctl_TCSETA
361           || tmpulongest == tdep->ioctl_TCSETAW
362           || tmpulongest == tdep->ioctl_TCSETAF
363           || tmpulongest == tdep->ioctl_TCSBRK
364           || tmpulongest == tdep->ioctl_TCXONC
365           || tmpulongest == tdep->ioctl_TCFLSH
366           || tmpulongest == tdep->ioctl_TIOCEXCL
367           || tmpulongest == tdep->ioctl_TIOCNXCL
368           || tmpulongest == tdep->ioctl_TIOCSCTTY
369           || tmpulongest == tdep->ioctl_TIOCSPGRP
370           || tmpulongest == tdep->ioctl_TIOCSTI
371           || tmpulongest == tdep->ioctl_TIOCSWINSZ
372           || tmpulongest == tdep->ioctl_TIOCMBIS
373           || tmpulongest == tdep->ioctl_TIOCMBIC
374           || tmpulongest == tdep->ioctl_TIOCMSET
375           || tmpulongest == tdep->ioctl_TIOCSSOFTCAR
376           || tmpulongest == tdep->ioctl_TIOCCONS
377           || tmpulongest == tdep->ioctl_TIOCSSERIAL
378           || tmpulongest == tdep->ioctl_TIOCPKT
379           || tmpulongest == tdep->ioctl_TIOCNOTTY
380           || tmpulongest == tdep->ioctl_TIOCSETD
381           || tmpulongest == tdep->ioctl_TCSBRKP
382           || tmpulongest == tdep->ioctl_TIOCTTYGSTRUCT
383           || tmpulongest == tdep->ioctl_TIOCSBRK
384           || tmpulongest == tdep->ioctl_TIOCCBRK
385           || tmpulongest == tdep->ioctl_TCSETS2
386           || tmpulongest == tdep->ioctl_TCSETSW2
387           || tmpulongest == tdep->ioctl_TCSETSF2
388           || tmpulongest == tdep->ioctl_TIOCSPTLCK
389           || tmpulongest == tdep->ioctl_TIOCSERCONFIG
390           || tmpulongest == tdep->ioctl_TIOCSERGWILD
391           || tmpulongest == tdep->ioctl_TIOCSERSWILD
392           || tmpulongest == tdep->ioctl_TIOCSLCKTRMIOS
393           || tmpulongest == tdep->ioctl_TIOCSERGETMULTI
394           || tmpulongest == tdep->ioctl_TIOCSERSETMULTI
395           || tmpulongest == tdep->ioctl_TIOCMIWAIT
396           || tmpulongest == tdep->ioctl_TIOCSHAYESESP)
397         {
398           /* Nothing to do.  */
399         }
400       else if (tmpulongest == tdep->ioctl_TCGETS
401                || tmpulongest == tdep->ioctl_TCGETA
402                || tmpulongest == tdep->ioctl_TIOCGLCKTRMIOS)
403         {
404           regcache_raw_read_unsigned (regcache, tdep->arg3,
405                                       &tmpulongest);
406           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
407                                         tdep->size_termios))
408             return -1;
409         }
410       else if (tmpulongest == tdep->ioctl_TIOCGPGRP
411                || tmpulongest == tdep->ioctl_TIOCGSID)
412         {
413           regcache_raw_read_unsigned (regcache, tdep->arg3,
414                                       &tmpulongest);
415           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
416                                         tdep->size_pid_t))
417             return -1;
418         }
419       else if (tmpulongest == tdep->ioctl_TIOCOUTQ
420                || tmpulongest == tdep->ioctl_TIOCMGET
421                || tmpulongest == tdep->ioctl_TIOCGSOFTCAR
422                || tmpulongest == tdep->ioctl_FIONREAD
423                || tmpulongest == tdep->ioctl_TIOCINQ
424                || tmpulongest == tdep->ioctl_TIOCGETD
425                || tmpulongest == tdep->ioctl_TIOCGPTN
426                || tmpulongest == tdep->ioctl_TIOCSERGETLSR)
427         {
428           regcache_raw_read_unsigned (regcache, tdep->arg3,
429                                       &tmpulongest);
430           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
431                                         tdep->size_int))
432             return -1;
433         }
434       else if (tmpulongest == tdep->ioctl_TIOCGWINSZ)
435         {
436           regcache_raw_read_unsigned (regcache, tdep->arg3,
437                                       &tmpulongest);
438           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
439                                         tdep->size_winsize))
440             return -1;
441         }
442       else if (tmpulongest == tdep->ioctl_TIOCLINUX)
443         {
444           regcache_raw_read_unsigned (regcache, tdep->arg3,
445                                       &tmpulongest);
446           /* This syscall affects a char-size memory.  */
447           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, 1))
448             return -1;
449         }
450       else if (tmpulongest == tdep->ioctl_TIOCGSERIAL)
451         {
452           regcache_raw_read_unsigned (regcache, tdep->arg3,
453                                       &tmpulongest);
454           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
455                                         tdep->size_serial_struct))
456             return -1;
457         }
458       else if (tmpulongest == tdep->ioctl_TCGETS2)
459         {
460           regcache_raw_read_unsigned (regcache, tdep->arg3,
461                                       &tmpulongest);
462           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
463                                         tdep->size_termios2))
464             return -1;
465         }
466       else if (tmpulongest == tdep->ioctl_FIOQSIZE)
467         {
468           regcache_raw_read_unsigned (regcache, tdep->arg3,
469                                       &tmpulongest);
470           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
471                                         tdep->size_loff_t))
472             return -1;
473         }
474       else if (tmpulongest == tdep->ioctl_TIOCGICOUNT)
475         {
476           regcache_raw_read_unsigned (regcache, tdep->arg3,
477                                       &tmpulongest);
478           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
479                                         tdep->size_serial_icounter_struct))
480             return -1;
481         }
482       else if (tmpulongest == tdep->ioctl_TIOCGHAYESESP)
483         {
484           regcache_raw_read_unsigned (regcache, tdep->arg3,
485                                       &tmpulongest);
486           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
487                                         tdep->size_hayes_esp_config))
488             return -1;
489         }
490       else if (tmpulongest == tdep->ioctl_TIOCSERGSTRUCT)
491         {
492           printf_unfiltered (_("Process record and replay target doesn't "
493                                "support ioctl request TIOCSERGSTRUCT\n"));
494           return 1;
495         }
496       else
497         {
498           printf_unfiltered (_("Process record and replay target doesn't "
499                                "support ioctl request 0x%s.\n"),
500                              OUTPUT_REG (tmpulongest, tdep->arg2));
501           return 1;
502         }
503       break;
504
505     case gdb_sys_fcntl:
506       /* XXX */
507       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
508     sys_fcntl:
509       if (tmpulongest == tdep->fcntl_F_GETLK)
510         {
511           regcache_raw_read_unsigned (regcache, tdep->arg3,
512                                       &tmpulongest);
513           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
514                                         tdep->size_flock))
515             return -1;
516         }
517       break;
518
519     case gdb_sys_ni_syscall56:
520     case gdb_sys_setpgid:
521     case gdb_sys_ni_syscall58:
522       break;
523
524     case gdb_sys_olduname:
525       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
526       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
527                                     tdep->size_oldold_utsname))
528         return -1;
529       break;
530
531     case gdb_sys_umask:
532     case gdb_sys_chroot:
533       break;
534
535     case gdb_sys_ustat:
536       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
537       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
538                                     tdep->size_ustat))
539         return -1;
540       break;
541
542     case gdb_sys_dup2:
543     case gdb_sys_getppid:
544     case gdb_sys_getpgrp:
545     case gdb_sys_setsid:
546       break;
547
548     case gdb_sys_sigaction:
549       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
550       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
551                                     tdep->size_old_sigaction))
552         return -1;
553       break;
554
555     case gdb_sys_sgetmask:
556     case gdb_sys_ssetmask:
557     case gdb_sys_setreuid16:
558     case gdb_sys_setregid16:
559     case gdb_sys_sigsuspend:
560       break;
561
562     case gdb_sys_sigpending:
563       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
564       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
565                                     tdep->size_old_sigset_t))
566         return -1;
567       break;
568
569     case gdb_sys_sethostname:
570     case gdb_sys_setrlimit:
571       break;
572
573     case gdb_sys_old_getrlimit:
574       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
575       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
576                                     tdep->size_rlimit))
577         return -1;
578       break;
579
580     case gdb_sys_getrusage:
581       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
582       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
583                                     tdep->size_rusage))
584         return -1;
585       break;
586
587     case gdb_sys_gettimeofday:
588       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
589       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
590                                     tdep->size_timeval))
591         return -1;
592       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
593       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
594                                     tdep->size_timezone))
595         return -1;
596       break;
597
598     case gdb_sys_settimeofday:
599       break;
600
601     case gdb_sys_getgroups16:
602       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
603       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
604                                     tdep->size_old_gid_t))
605         return -1;
606       break;
607
608     case gdb_sys_setgroups16:
609       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
610       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
611                                     tdep->size_old_gid_t))
612         return -1;
613       break;
614
615     case gdb_old_select:
616       {
617         struct sel_arg_struct
618         {
619           CORE_ADDR n;
620           CORE_ADDR inp;
621           CORE_ADDR outp;
622           CORE_ADDR exp;
623           CORE_ADDR tvp;
624         } sel;
625
626         regcache_raw_read_unsigned (regcache, tdep->arg1,
627                                     &tmpulongest);
628         if (tmpulongest)
629           {
630             if (target_read_memory (tmpulongest, (gdb_byte *) &sel,
631                                     sizeof(sel)))
632               {
633                 if (record_debug)
634                   fprintf_unfiltered (gdb_stdlog,
635                                       "Process record: error reading memory "
636                                       "at addr = 0x%s len = %lu.\n",
637                                       OUTPUT_REG (tmpulongest, tdep->arg1),
638                                       (unsigned long) sizeof (sel));
639                 return -1;
640               }
641             if (record_arch_list_add_mem (sel.inp, tdep->size_fd_set))
642               return -1;
643             if (record_arch_list_add_mem (sel.outp, tdep->size_fd_set))
644               return -1;
645             if (record_arch_list_add_mem (sel.exp, tdep->size_fd_set))
646               return -1;
647             if (record_arch_list_add_mem (sel.tvp, tdep->size_timeval))
648               return -1;
649           }
650       }
651       break;
652
653     case gdb_sys_symlink:
654       break;
655
656     case gdb_sys_readlink:
657       {
658         ULONGEST len;
659
660         regcache_raw_read_unsigned (regcache, tdep->arg2,
661                                     &tmpulongest);
662         regcache_raw_read_unsigned (regcache, tdep->arg3, &len);
663         if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, (int) len))
664           return -1;
665       }
666       break;
667
668     case gdb_sys_uselib:
669     case gdb_sys_swapon:
670       break;
671
672     case gdb_sys_reboot:
673       {
674         int q;
675
676         target_terminal_ours ();
677         q = yquery (_("The next instruction is syscall reboot.  "
678                       "It will restart the computer.  "
679                       "Do you want to stop the program?"));
680         target_terminal_inferior ();
681         if (q)
682           return 1;
683       }
684       break;
685
686     case gdb_old_readdir:
687       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
688       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
689                                     tdep->size_dirent))
690         return -1;
691       break;
692
693     case gdb_old_mmap:
694       break;
695
696     case gdb_sys_munmap:
697       {
698         ULONGEST len;
699
700         regcache_raw_read_unsigned (regcache, tdep->arg1,
701                                     &tmpulongest);
702         regcache_raw_read_unsigned (regcache, tdep->arg2, &len);
703         if (record_memory_query)
704           {
705             int q;
706
707             target_terminal_ours ();
708             q = yquery (_("\
709 The next instruction is syscall munmap.\n\
710 It will free the memory addr = 0x%s len = %u.\n\
711 It will make record target cannot record some memory change.\n\
712 Do you want to stop the program?"),
713                         OUTPUT_REG (tmpulongest, tdep->arg1), (int) len);
714             target_terminal_inferior ();
715             if (q)
716               return 1;
717           }
718       }
719       break;
720
721     case gdb_sys_truncate:
722     case gdb_sys_ftruncate:
723     case gdb_sys_fchmod:
724     case gdb_sys_fchown16:
725     case gdb_sys_getpriority:
726     case gdb_sys_setpriority:
727     case gdb_sys_ni_syscall98:
728       break;
729
730     case gdb_sys_statfs:
731     case gdb_sys_fstatfs:
732       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
733       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
734                                     tdep->size_statfs))
735         return -1;
736       break;
737
738     case gdb_sys_ioperm:
739       break;
740
741     case gdb_sys_socket:
742     case gdb_sys_sendto:
743     case gdb_sys_sendmsg:
744     case gdb_sys_shutdown:
745     case gdb_sys_bind:
746     case gdb_sys_connect:
747     case gdb_sys_listen:
748     case gdb_sys_setsockopt:
749       break;
750
751     case gdb_sys_accept:
752     case gdb_sys_getsockname:
753     case gdb_sys_getpeername:
754       {
755         ULONGEST len;
756
757         regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
758         regcache_raw_read_unsigned (regcache, tdep->arg3, &len);
759         if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
760           return -1;
761       }
762       break;
763
764     case gdb_sys_recvfrom:
765       {
766         ULONGEST len;
767
768         regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
769         regcache_raw_read_unsigned (regcache, tdep->arg5, &len);
770         if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
771           return -1;
772       }
773       break;
774
775     case gdb_sys_recv:
776       {
777         ULONGEST size;
778
779         regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
780         regcache_raw_read_unsigned (regcache, tdep->arg3, &size);
781         if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, (int) size))
782           return -1;
783       }
784       break;
785
786     case gdb_sys_recvmsg:
787       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
788       if (record_linux_msghdr (regcache, tdep, tmpulongest))
789         return -1;
790       break;
791
792     case gdb_sys_socketpair:
793       regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
794       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_int))
795         return -1;
796       break;
797
798     case gdb_sys_getsockopt:
799       regcache_raw_read_unsigned (regcache, tdep->arg5, &tmpulongest);
800       if (tmpulongest)
801         {
802           ULONGEST optvalp;
803           gdb_byte *optlenp = alloca (tdep->size_int);
804
805           if (target_read_memory ((CORE_ADDR) tmpulongest, optlenp,
806                                   tdep->size_int))
807             {
808               if (record_debug)
809                 fprintf_unfiltered (gdb_stdlog,
810                                     "Process record: error reading "
811                                     "memory at addr = 0x%s "
812                                     "len = %d.\n",
813                                     OUTPUT_REG (tmpulongest, tdep->arg5),
814                                     tdep->size_int);
815               return -1;
816             }
817           regcache_raw_read_unsigned (regcache, tdep->arg4, &optvalp);
818           tmpint = (int) extract_signed_integer (optlenp, tdep->size_int,
819                                                  byte_order);
820           if (record_arch_list_add_mem ((CORE_ADDR) optvalp, tmpint))
821             return -1;
822           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
823                                         tdep->size_int))
824             return -1;
825         }
826       break;
827
828     case gdb_sys_socketcall:
829       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
830       switch (tmpulongest)
831         {
832         case RECORD_SYS_SOCKET:
833         case RECORD_SYS_BIND:
834         case RECORD_SYS_CONNECT:
835         case RECORD_SYS_LISTEN:
836           break;
837         case RECORD_SYS_ACCEPT:
838         case RECORD_SYS_GETSOCKNAME:
839         case RECORD_SYS_GETPEERNAME:
840           {
841             regcache_raw_read_unsigned (regcache, tdep->arg2,
842                                         &tmpulongest);
843             if (tmpulongest)
844               {
845                 gdb_byte *a = alloca (tdep->size_ulong * 2);
846                 ULONGEST len;
847
848                 tmpulongest += tdep->size_ulong;
849                 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
850                                         tdep->size_ulong * 2))
851                   {
852                     if (record_debug)
853                       fprintf_unfiltered (gdb_stdlog,
854                                           "Process record: error reading "
855                                           "memory at addr = 0x%s len = %d.\n",
856                                           OUTPUT_REG (tmpulongest, tdep->arg2),
857                                           tdep->size_ulong * 2);
858                     return -1;
859                   }
860                 tmpulongest = extract_unsigned_integer (a,
861                                                         tdep->size_ulong,
862                                                         byte_order);
863                 len = extract_unsigned_integer (a + tdep->size_ulong,
864                                                 tdep->size_ulong, byte_order);
865                 if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
866                   return -1;
867               }
868           }
869           break;
870
871         case RECORD_SYS_SOCKETPAIR:
872           {
873             gdb_byte *a = alloca (tdep->size_ulong);
874
875             regcache_raw_read_unsigned (regcache, tdep->arg2,
876                                         &tmpulongest);
877             if (tmpulongest)
878               {
879                 tmpulongest += tdep->size_ulong * 3;
880                 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
881                                         tdep->size_ulong))
882                   {
883                     if (record_debug)
884                       fprintf_unfiltered (gdb_stdlog,
885                                           "Process record: error reading "
886                                           "memory at addr = 0x%s len = %d.\n",
887                                           OUTPUT_REG (tmpulongest, tdep->arg2),
888                                           tdep->size_ulong);
889                     return -1;
890                   }
891                 tmpaddr
892                   = (CORE_ADDR) extract_unsigned_integer (a, tdep->size_ulong,
893                                                           byte_order);
894                 if (record_arch_list_add_mem (tmpaddr, tdep->size_int))
895                   return -1;
896               }
897           }
898           break;
899         case RECORD_SYS_SEND:
900         case RECORD_SYS_SENDTO:
901           break;
902         case RECORD_SYS_RECVFROM:
903           regcache_raw_read_unsigned (regcache, tdep->arg2,
904                                       &tmpulongest);
905           if (tmpulongest)
906             {
907               gdb_byte *a = alloca (tdep->size_ulong * 2);
908               ULONGEST len;
909
910               tmpulongest += tdep->size_ulong * 4;
911               if (target_read_memory ((CORE_ADDR) tmpulongest, a,
912                                       tdep->size_ulong * 2))
913                 {
914                   if (record_debug)
915                     fprintf_unfiltered (gdb_stdlog,
916                                         "Process record: error reading "
917                                         "memory at addr = 0x%s len = %d.\n",
918                                         OUTPUT_REG (tmpulongest, tdep->arg2),
919                                         tdep->size_ulong * 2);
920                   return -1;
921                 }
922               tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
923                                                       byte_order);
924               len = extract_unsigned_integer (a + tdep->size_ulong,
925                                               tdep->size_ulong, byte_order);
926               if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
927                 return -1;
928             }
929         case RECORD_SYS_RECV:
930           regcache_raw_read_unsigned (regcache, tdep->arg2,
931                                       &tmpulongest);
932           if (tmpulongest)
933             {
934               gdb_byte *a = alloca (tdep->size_ulong * 2);
935
936               tmpulongest += tdep->size_ulong;
937               if (target_read_memory ((CORE_ADDR) tmpulongest, a,
938                                       tdep->size_ulong))
939                 {
940                   if (record_debug)
941                     fprintf_unfiltered (gdb_stdlog,
942                                         "Process record: error reading "
943                                         "memory at addr = 0x%s len = %d.\n",
944                                         OUTPUT_REG (tmpulongest, tdep->arg2),
945                                         tdep->size_ulong);
946                     return -1;
947                 }
948               tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
949                                                       byte_order);
950               if (tmpulongest)
951                 {
952                   a += tdep->size_ulong;
953                   tmpint = (int) extract_unsigned_integer (a, tdep->size_ulong,
954                                                            byte_order);
955                   if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
956                                                 tmpint))
957                     return -1;
958                 }
959             }
960           break;
961         case RECORD_SYS_SHUTDOWN:
962         case RECORD_SYS_SETSOCKOPT:
963           break;
964         case RECORD_SYS_GETSOCKOPT:
965           {
966             gdb_byte *a = alloca (tdep->size_ulong * 2);
967             gdb_byte *av = alloca (tdep->size_int);
968
969             regcache_raw_read_unsigned (regcache, tdep->arg2,
970                                         &tmpulongest);
971             if (tmpulongest)
972               {
973                 tmpulongest += tdep->size_ulong * 3;
974                 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
975                                         tdep->size_ulong * 2))
976                   {
977                     if (record_debug)
978                       fprintf_unfiltered (gdb_stdlog,
979                                           "Process record: error reading "
980                                           "memory at addr = 0x%s len = %d.\n",
981                                           OUTPUT_REG (tmpulongest, tdep->arg2),
982                                           tdep->size_ulong * 2);
983                     return -1;
984                   }
985                 tmpulongest = extract_unsigned_integer (a + tdep->size_ulong,
986                                                         tdep->size_ulong,
987                                                         byte_order);
988                 if (tmpulongest)
989                   {
990                     if (target_read_memory ((CORE_ADDR) tmpulongest, av,
991                                             tdep->size_int))
992                       {
993                         if (record_debug)
994                           fprintf_unfiltered (gdb_stdlog,
995                                               "Process record: error reading "
996                                               "memory at addr = 0x%s "
997                                               "len = %d.\n",
998                                               phex_nz (tmpulongest,
999                                                        tdep->size_ulong),
1000                                               tdep->size_int);
1001                         return -1;
1002                       }
1003                     tmpaddr
1004                       = (CORE_ADDR) extract_unsigned_integer (a,
1005                                                               tdep->size_ulong,
1006                                                               byte_order);
1007                     tmpint = (int) extract_unsigned_integer (av,
1008                                                              tdep->size_int,
1009                                                              byte_order);
1010                     if (record_arch_list_add_mem (tmpaddr, tmpint))
1011                       return -1;
1012                     a += tdep->size_ulong;
1013                     tmpaddr
1014                       = (CORE_ADDR) extract_unsigned_integer (a,
1015                                                               tdep->size_ulong,
1016                                                               byte_order);
1017                     if (record_arch_list_add_mem (tmpaddr, tdep->size_int))
1018                       return -1;
1019                   }
1020               }
1021           }
1022           break;
1023         case RECORD_SYS_SENDMSG:
1024           break;
1025         case RECORD_SYS_RECVMSG:
1026           {
1027             gdb_byte *a = alloca (tdep->size_ulong);
1028
1029             regcache_raw_read_unsigned (regcache, tdep->arg2,
1030                                         &tmpulongest);
1031             if (tmpulongest)
1032               {
1033                 tmpulongest += tdep->size_ulong;
1034                 if (target_read_memory ((CORE_ADDR) tmpulongest, a,
1035                                         tdep->size_ulong))
1036                   {
1037                     if (record_debug)
1038                       fprintf_unfiltered (gdb_stdlog,
1039                                           "Process record: error reading "
1040                                           "memory at addr = 0x%s len = %d.\n",
1041                                           OUTPUT_REG (tmpulongest, tdep->arg2),
1042                                           tdep->size_ulong);
1043                     return -1;
1044                   }
1045                 tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
1046                                                         byte_order);
1047                 if (record_linux_msghdr (regcache, tdep, tmpulongest))
1048                   return -1;
1049               }
1050           }
1051           break;
1052         default:
1053           printf_unfiltered (_("Process record and replay target "
1054                                "doesn't support socketcall call 0x%s\n"),
1055                              OUTPUT_REG (tmpulongest, tdep->arg1));
1056           return -1;
1057           break;
1058         }
1059       break;
1060
1061     case gdb_sys_syslog:
1062       break;
1063
1064     case gdb_sys_setitimer:
1065       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1066       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1067                                     tdep->size_itimerval))
1068         return -1;
1069       break;
1070
1071     case gdb_sys_getitimer:
1072       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1073       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1074                                     tdep->size_itimerval))
1075         return -1;
1076       break;
1077
1078     case gdb_sys_newstat:
1079     case gdb_sys_newlstat:
1080     case gdb_sys_newfstat:
1081     case gdb_sys_newfstatat:
1082       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1083       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_stat))
1084         return -1;
1085       break;
1086
1087     case gdb_sys_uname:
1088       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1089       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1090                                     tdep->size_old_utsname))
1091         return -1;
1092       break;
1093
1094     case gdb_sys_iopl:
1095     case gdb_sys_vhangup:
1096     case gdb_sys_ni_syscall112:
1097     case gdb_sys_vm86old:
1098       break;
1099
1100     case gdb_sys_wait4:
1101       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1102       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1103                                     tdep->size_int))
1104         return -1;
1105       regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
1106       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1107                                     tdep->size_rusage))
1108         return -1;
1109       break;
1110
1111     case gdb_sys_swapoff:
1112       break;
1113
1114     case gdb_sys_sysinfo:
1115       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1116       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1117                                     tdep->size_sysinfo))
1118         return -1;
1119       break;
1120
1121     case gdb_sys_shmget:
1122     case gdb_sys_semget:
1123     case gdb_sys_semop:
1124     case gdb_sys_msgget:
1125       /* XXX maybe need do some record works with sys_shmdt.  */
1126     case gdb_sys_shmdt:
1127     case gdb_sys_msgsnd:
1128     case gdb_sys_semtimedop:
1129       break;
1130
1131     case gdb_sys_shmat:
1132       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1133       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1134                                     tdep->size_ulong))
1135         return -1;
1136       break;
1137
1138     case gdb_sys_shmctl:
1139       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1140       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1141                                     tdep->size_shmid_ds))
1142         return -1;
1143       break;
1144
1145       /* XXX sys_semctl 525 still not supported.  */
1146       /* sys_semctl */
1147
1148     case gdb_sys_msgrcv:
1149       {
1150         ULONGEST msgp;
1151
1152         regcache_raw_read_signed (regcache, tdep->arg3, &tmpulongest);
1153         regcache_raw_read_unsigned (regcache, tdep->arg2, &msgp);
1154         tmpint = (int) tmpulongest + tdep->size_long;
1155         if (record_arch_list_add_mem ((CORE_ADDR) msgp, tmpint))
1156           return -1;
1157       }
1158       break;
1159
1160     case gdb_sys_msgctl:
1161       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1162       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1163                                     tdep->size_msqid_ds))
1164         return -1;
1165       break;
1166
1167     case gdb_sys_ipc:
1168       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1169       tmpulongest &= 0xffff;
1170       switch (tmpulongest)
1171         {
1172         case RECORD_SEMOP:
1173         case RECORD_SEMGET:
1174         case RECORD_SEMTIMEDOP:
1175         case RECORD_MSGSND:
1176         case RECORD_MSGGET:
1177           /* XXX maybe need do some record works with RECORD_SHMDT.  */
1178         case RECORD_SHMDT:
1179         case RECORD_SHMGET:
1180           break;
1181         case RECORD_MSGRCV:
1182           {
1183             ULONGEST second;
1184             ULONGEST ptr;
1185
1186             regcache_raw_read_signed (regcache, tdep->arg3, &second);
1187             regcache_raw_read_unsigned (regcache, tdep->arg5, &ptr);
1188             tmpint = (int) second + tdep->size_long;
1189             if (record_arch_list_add_mem ((CORE_ADDR) ptr, tmpint))
1190               return -1;
1191           }
1192           break;
1193         case RECORD_MSGCTL:
1194           regcache_raw_read_unsigned (regcache, tdep->arg5,
1195                                       &tmpulongest);
1196           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1197                                         tdep->size_msqid_ds))
1198             return -1;
1199           break;
1200         case RECORD_SHMAT:
1201           regcache_raw_read_unsigned (regcache, tdep->arg4,
1202                                       &tmpulongest);
1203           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1204                                         tdep->size_ulong))
1205             return -1;
1206           break;
1207         case RECORD_SHMCTL:
1208           regcache_raw_read_unsigned (regcache, tdep->arg5,
1209                                       &tmpulongest);
1210           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1211                                         tdep->size_shmid_ds))
1212             return -1;
1213           break;
1214         default:
1215           /* XXX RECORD_SEMCTL still not supported.  */
1216           printf_unfiltered (_("Process record and replay target doesn't "
1217                                "support ipc number %s\n"), 
1218                              pulongest (tmpulongest));
1219           break;
1220         }
1221       break;
1222
1223     case gdb_sys_fsync:
1224     case gdb_sys_sigreturn:
1225     case gdb_sys_clone:
1226     case gdb_sys_setdomainname:
1227       break;
1228
1229     case gdb_sys_newuname:
1230       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1231       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1232                                     tdep->size_new_utsname))
1233         return -1;
1234       break;
1235
1236     case gdb_sys_modify_ldt:
1237       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1238       if (tmpulongest == 0 || tmpulongest == 2)
1239         {
1240           ULONGEST ptr, bytecount;
1241
1242           regcache_raw_read_unsigned (regcache, tdep->arg2, &ptr);
1243           regcache_raw_read_unsigned (regcache, tdep->arg3, &bytecount);
1244           if (record_arch_list_add_mem ((CORE_ADDR) ptr, (int) bytecount))
1245             return -1;
1246         }
1247       break;
1248
1249     case gdb_sys_adjtimex:
1250       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1251       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_timex))
1252         return -1;
1253       break;
1254
1255     case gdb_sys_mprotect:
1256       break;
1257
1258     case gdb_sys_sigprocmask:
1259       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1260       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1261                                     tdep->size_old_sigset_t))
1262         return -1;
1263       break;
1264
1265     case gdb_sys_ni_syscall127:
1266     case gdb_sys_init_module:
1267     case gdb_sys_delete_module:
1268     case gdb_sys_ni_syscall130:
1269       break;
1270
1271     case gdb_sys_quotactl:
1272       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1273       switch (tmpulongest)
1274         {
1275         case RECORD_Q_GETFMT:
1276           regcache_raw_read_unsigned (regcache, tdep->arg4,
1277                                       &tmpulongest);
1278           /* __u32 */
1279           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, 4))
1280             return -1;
1281           break;
1282         case RECORD_Q_GETINFO:
1283           regcache_raw_read_unsigned (regcache, tdep->arg4,
1284                                       &tmpulongest);
1285           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1286                                         tdep->size_mem_dqinfo))
1287             return -1;
1288           break;
1289         case RECORD_Q_GETQUOTA:
1290           regcache_raw_read_unsigned (regcache, tdep->arg4,
1291                                       &tmpulongest);
1292           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1293                                         tdep->size_if_dqblk))
1294             return -1;
1295           break;
1296         case RECORD_Q_XGETQSTAT:
1297         case RECORD_Q_XGETQUOTA:
1298           regcache_raw_read_unsigned (regcache, tdep->arg4,
1299                                       &tmpulongest);
1300           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1301                                         tdep->size_fs_quota_stat))
1302             return -1;
1303           break;
1304         }
1305       break;
1306
1307     case gdb_sys_getpgid:
1308     case gdb_sys_fchdir:
1309     case gdb_sys_bdflush:
1310       break;
1311
1312     case gdb_sys_sysfs:
1313       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1314       if (tmpulongest == 2)
1315         {
1316           regcache_raw_read_unsigned (regcache, tdep->arg3,
1317                                       &tmpulongest);
1318           /*XXX the size of memory is not very clear.  */
1319           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, 10))
1320             return -1;
1321         }
1322       break;
1323
1324     case gdb_sys_personality:
1325     case gdb_sys_ni_syscall137:
1326     case gdb_sys_setfsuid16:
1327     case gdb_sys_setfsgid16:
1328       break;
1329
1330     case gdb_sys_llseek:
1331       regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
1332       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1333                                     tdep->size_loff_t))
1334         return -1;
1335       break;
1336
1337     case gdb_sys_getdents:
1338       {
1339         ULONGEST count;
1340
1341         regcache_raw_read_unsigned (regcache, tdep->arg2,
1342                                     &tmpulongest);
1343         regcache_raw_read_unsigned (regcache, tdep->arg3, &count);
1344         if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1345                                       tdep->size_dirent * count))
1346           return -1;
1347       }
1348       break;
1349
1350     case gdb_sys_select:
1351       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1352       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1353                                     tdep->size_fd_set))
1354         return -1;
1355       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1356       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1357                                     tdep->size_fd_set))
1358         return -1;
1359       regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
1360       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1361                                     tdep->size_fd_set))
1362         return -1;
1363       regcache_raw_read_unsigned (regcache, tdep->arg5, &tmpulongest);
1364       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1365                                     tdep->size_timeval))
1366         return -1;
1367       break;
1368
1369     case gdb_sys_flock:
1370     case gdb_sys_msync:
1371       break;
1372
1373     case gdb_sys_readv:
1374       {
1375         ULONGEST vec, vlen;
1376
1377         regcache_raw_read_unsigned (regcache, tdep->arg2, &vec);
1378         if (vec)
1379           {
1380             gdb_byte *iov = alloca (tdep->size_iovec);
1381
1382             regcache_raw_read_unsigned (regcache, tdep->arg3, &vlen);
1383             for (tmpulongest = 0; tmpulongest < vlen; tmpulongest++)
1384               {
1385                 if (target_read_memory ((CORE_ADDR) vec, iov,
1386                                         tdep->size_iovec))
1387                   {
1388                     if (record_debug)
1389                       fprintf_unfiltered (gdb_stdlog,
1390                                           "Process record: error reading "
1391                                           "memory at addr = 0x%s len = %d.\n",
1392                                           OUTPUT_REG (vec, tdep->arg2),
1393                                           tdep->size_iovec);
1394                     return -1;
1395                   }
1396                 tmpaddr
1397                   = (CORE_ADDR) extract_unsigned_integer (iov,
1398                                                           tdep->size_pointer,
1399                                                           byte_order);
1400                 tmpint
1401                   = (int) extract_unsigned_integer (iov + tdep->size_pointer,
1402                                                     tdep->size_size_t,
1403                                                     byte_order);
1404                 if (record_arch_list_add_mem (tmpaddr, tmpint))
1405                   return -1;
1406                 vec += tdep->size_iovec;
1407               }
1408           }
1409       }
1410       break;
1411
1412     case gdb_sys_writev:
1413     case gdb_sys_getsid:
1414     case gdb_sys_fdatasync:
1415     case gdb_sys_sysctl:
1416     case gdb_sys_mlock:
1417     case gdb_sys_munlock:
1418     case gdb_sys_mlockall:
1419     case gdb_sys_munlockall:
1420     case gdb_sys_sched_setparam:
1421       break;
1422
1423     case gdb_sys_sched_getparam:
1424       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1425       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_int))
1426         return -1;
1427       break;
1428
1429     case gdb_sys_sched_setscheduler:
1430     case gdb_sys_sched_getscheduler:
1431     case gdb_sys_sched_yield:
1432     case gdb_sys_sched_get_priority_max:
1433     case gdb_sys_sched_get_priority_min:
1434       break;
1435
1436     case gdb_sys_sched_rr_get_interval:
1437     case gdb_sys_nanosleep:
1438       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1439       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1440                                     tdep->size_timespec))
1441         return -1;
1442       break;
1443
1444     case gdb_sys_mremap:
1445     case gdb_sys_setresuid16:
1446       break;
1447
1448     case gdb_sys_getresuid16:
1449       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1450       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1451                                     tdep->size_old_uid_t))
1452         return -1;
1453       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1454       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1455                                     tdep->size_old_uid_t))
1456         return -1;
1457       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1458       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1459                                     tdep->size_old_uid_t))
1460         return -1;
1461       break;
1462
1463     case gdb_sys_vm86:
1464     case gdb_sys_ni_syscall167:
1465       break;
1466
1467     case gdb_sys_poll:
1468       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1469       if (tmpulongest)
1470         {
1471           ULONGEST nfds;
1472
1473           regcache_raw_read_unsigned (regcache, tdep->arg2, &nfds);
1474           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1475                                         tdep->size_pollfd * nfds))
1476             return -1;
1477         }
1478       break;
1479
1480     case gdb_sys_nfsservctl:
1481       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1482       if (tmpulongest == 7 || tmpulongest == 8)
1483         {
1484           int rsize;
1485
1486           if (tmpulongest == 7)
1487             rsize = tdep->size_NFS_FHSIZE;
1488           else
1489             rsize = tdep->size_knfsd_fh;
1490           regcache_raw_read_unsigned (regcache, tdep->arg3,
1491                                       &tmpulongest);
1492           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, rsize))
1493             return -1;
1494         }
1495       break;
1496
1497     case gdb_sys_setresgid16:
1498       break;
1499
1500     case gdb_sys_getresgid16:
1501       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1502       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1503                                     tdep->size_old_gid_t))
1504         return -1;
1505       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1506       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1507                                     tdep->size_old_gid_t))
1508         return -1;
1509       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1510       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1511                                     tdep->size_old_gid_t))
1512         return -1;
1513       break;
1514
1515     case gdb_sys_prctl:
1516       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1517       switch (tmpulongest)
1518         {
1519         case 2:
1520           regcache_raw_read_unsigned (regcache, tdep->arg2,
1521                                       &tmpulongest);
1522           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1523                                         tdep->size_int))
1524             return -1;
1525           break;
1526         case 16:
1527           regcache_raw_read_unsigned (regcache, tdep->arg2,
1528                                       &tmpulongest);
1529           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1530                                         tdep->size_TASK_COMM_LEN))
1531             return -1;
1532           break;
1533         }
1534       break;
1535
1536     case gdb_sys_rt_sigreturn:
1537       break;
1538
1539     case gdb_sys_rt_sigaction:
1540       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1541       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1542                                     tdep->size_sigaction))
1543         return -1;
1544       break;
1545
1546     case gdb_sys_rt_sigprocmask:
1547       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1548       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1549                                     tdep->size_sigset_t))
1550         return -1;
1551       break;
1552
1553     case gdb_sys_rt_sigpending:
1554       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1555       if (tmpulongest)
1556         {
1557           ULONGEST sigsetsize;
1558
1559           regcache_raw_read_unsigned (regcache, tdep->arg2,&sigsetsize);
1560           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1561                                         (int) sigsetsize))
1562             return -1;
1563         }
1564       break;
1565
1566     case gdb_sys_rt_sigtimedwait:
1567       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1568       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1569                                     tdep->size_siginfo_t))
1570         return -1;
1571       break;
1572
1573     case gdb_sys_rt_sigqueueinfo:
1574     case gdb_sys_rt_sigsuspend:
1575       break;
1576
1577     case gdb_sys_pread64:
1578       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1579       if (tmpulongest)
1580         {
1581           ULONGEST count;
1582
1583           regcache_raw_read_unsigned (regcache, tdep->arg3,&count);
1584           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, (int) count))
1585             return -1;
1586         }
1587       break;
1588
1589     case gdb_sys_pwrite64:
1590     case gdb_sys_chown16:
1591       break;
1592
1593     case gdb_sys_getcwd:
1594       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1595       if (tmpulongest)
1596         {
1597           ULONGEST size;
1598
1599           regcache_raw_read_unsigned (regcache, tdep->arg2, &size);
1600           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, (int) size))
1601             return -1;
1602         }
1603       break;
1604
1605     case gdb_sys_capget:
1606       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1607       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1608                                     tdep->size_cap_user_data_t))
1609         return -1;
1610       break;
1611
1612     case gdb_sys_capset:
1613       break;
1614
1615     case gdb_sys_sigaltstack:
1616       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1617       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1618                                     tdep->size_stack_t))
1619         return -1;
1620       break;
1621
1622     case gdb_sys_sendfile:
1623       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1624       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1625                                     tdep->size_off_t))
1626         return -1;
1627       break;
1628
1629     case gdb_sys_ni_syscall188:
1630     case gdb_sys_ni_syscall189:
1631     case gdb_sys_vfork:
1632       break;
1633
1634     case gdb_sys_getrlimit:
1635       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1636       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1637                                     tdep->size_rlimit))
1638         return -1;
1639       break;
1640
1641     case gdb_sys_mmap2:
1642       break;
1643
1644     case gdb_sys_truncate64:
1645     case gdb_sys_ftruncate64:
1646       break;
1647
1648     case gdb_sys_stat64:
1649     case gdb_sys_lstat64:
1650     case gdb_sys_fstat64:
1651       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1652       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1653                                     tdep->size_stat64))
1654         return -1;
1655       break;
1656
1657     case gdb_sys_lchown:
1658     case gdb_sys_getuid:
1659     case gdb_sys_getgid:
1660     case gdb_sys_geteuid:
1661     case gdb_sys_getegid:
1662     case gdb_sys_setreuid:
1663     case gdb_sys_setregid:
1664       break;
1665
1666     case gdb_sys_getgroups:
1667       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1668       if (tmpulongest)
1669         {
1670           ULONGEST gidsetsize;
1671
1672           regcache_raw_read_unsigned (regcache, tdep->arg1,
1673                                       &gidsetsize);
1674           tmpint = tdep->size_gid_t * (int) gidsetsize;
1675           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tmpint))
1676             return -1;
1677         }
1678       break;
1679
1680     case gdb_sys_setgroups:
1681     case gdb_sys_fchown:
1682     case gdb_sys_setresuid:
1683       break;
1684
1685     case gdb_sys_getresuid:
1686       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1687       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_uid_t))
1688         return -1;
1689       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1690       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_uid_t))
1691         return -1;
1692       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1693       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_uid_t))
1694         return -1;
1695       break;
1696
1697     case gdb_sys_setresgid:
1698       break;
1699
1700     case gdb_sys_getresgid:
1701       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1702       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_gid_t))
1703         return -1;
1704       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1705       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_gid_t))
1706         return -1;
1707       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1708       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_gid_t))
1709         return -1;
1710       break;
1711
1712     case gdb_sys_chown:
1713     case gdb_sys_setuid:
1714     case gdb_sys_setgid:
1715     case gdb_sys_setfsuid:
1716     case gdb_sys_setfsgid:
1717     case gdb_sys_pivot_root:
1718       break;
1719
1720     case gdb_sys_mincore:
1721       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1722       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1723                                     tdep->size_PAGE_SIZE))
1724         return -1;
1725       break;
1726
1727     case gdb_sys_madvise:
1728       break;
1729
1730     case gdb_sys_getdents64:
1731       {
1732         ULONGEST count;
1733
1734         regcache_raw_read_unsigned (regcache, tdep->arg2,
1735                                     &tmpulongest);
1736         regcache_raw_read_unsigned (regcache, tdep->arg3, &count);
1737         if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1738                                       tdep->size_dirent64 * count))
1739           return -1;
1740       }
1741       break;
1742
1743     case gdb_sys_fcntl64:
1744       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1745       if (tmpulongest == tdep->fcntl_F_GETLK64)
1746         {
1747           regcache_raw_read_unsigned (regcache, tdep->arg3,
1748                                       &tmpulongest);
1749           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1750                                         tdep->size_flock64))
1751             return -1;
1752         }
1753       else if (tmpulongest != tdep->fcntl_F_SETLK64
1754                && tmpulongest != tdep->fcntl_F_SETLKW64)
1755         {
1756           goto sys_fcntl;
1757         }
1758       break;
1759
1760     case gdb_sys_ni_syscall222:
1761     case gdb_sys_ni_syscall223:
1762     case gdb_sys_gettid:
1763     case gdb_sys_readahead:
1764     case gdb_sys_setxattr:
1765     case gdb_sys_lsetxattr:
1766     case gdb_sys_fsetxattr:
1767       break;
1768
1769     case gdb_sys_getxattr:
1770     case gdb_sys_lgetxattr:
1771     case gdb_sys_fgetxattr:
1772       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1773       if (tmpulongest)
1774         {
1775           ULONGEST size;
1776
1777           regcache_raw_read_unsigned (regcache, tdep->arg4, &size);
1778           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, (int) size))
1779             return -1;
1780         }
1781       break;
1782
1783     case gdb_sys_listxattr:
1784     case gdb_sys_llistxattr:
1785     case gdb_sys_flistxattr:
1786       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1787       if (tmpulongest)
1788         {
1789           ULONGEST size;
1790
1791           regcache_raw_read_unsigned (regcache, tdep->arg3, &size);
1792           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, (int) size))
1793             return -1;
1794         }
1795       break;
1796
1797     case gdb_sys_removexattr:
1798     case gdb_sys_lremovexattr:
1799     case gdb_sys_fremovexattr:
1800     case gdb_sys_tkill:
1801       break;
1802
1803     case gdb_sys_sendfile64:
1804       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1805       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1806                                     tdep->size_loff_t))
1807         return -1;
1808       break;
1809
1810     case gdb_sys_futex:
1811     case gdb_sys_sched_setaffinity:
1812       break;
1813
1814     case gdb_sys_sched_getaffinity:
1815       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1816       if (tmpulongest)
1817         {
1818           ULONGEST len;
1819
1820           regcache_raw_read_unsigned (regcache, tdep->arg2, &len);
1821           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, (int) len))
1822             return -1;
1823         }
1824       break;
1825
1826     case gdb_sys_set_thread_area:
1827       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1828       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_int))
1829         return -1;
1830       break;
1831
1832     case gdb_sys_get_thread_area:
1833       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
1834       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1835                                     tdep->size_user_desc))
1836         return -1;
1837       break;
1838
1839     case gdb_sys_io_setup:
1840       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1841       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_long))
1842         return -1;
1843       break;
1844
1845     case gdb_sys_io_destroy:
1846       break;
1847
1848     case gdb_sys_io_getevents:
1849       regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
1850       if (tmpulongest)
1851         {
1852           ULONGEST nr;
1853
1854           regcache_raw_read_unsigned (regcache, tdep->arg3, &nr);
1855           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1856                                         nr * tdep->size_io_event))
1857             return -1;
1858         }
1859       break;
1860
1861     case gdb_sys_io_submit:
1862       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1863       if (tmpulongest)
1864         {
1865           ULONGEST nr, i;
1866           gdb_byte *iocbp;
1867
1868           regcache_raw_read_unsigned (regcache, tdep->arg2, &nr);
1869           iocbp = alloca (nr * tdep->size_pointer);
1870           if (target_read_memory ((CORE_ADDR) tmpulongest, iocbp,
1871                                   nr * tdep->size_pointer))
1872             {
1873               if (record_debug)
1874                 fprintf_unfiltered (gdb_stdlog,
1875                                     "Process record: error reading memory "
1876                                     "at addr = 0x%s len = %u.\n",
1877                                     OUTPUT_REG (tmpulongest, tdep->arg2),
1878                                     (int) (nr * tdep->size_pointer));
1879               return -1;
1880             }
1881           for (i = 0; i < nr; i++)
1882             {
1883               tmpaddr
1884                 = (CORE_ADDR) extract_unsigned_integer (iocbp,
1885                                                         tdep->size_pointer,
1886                                                         byte_order);
1887               if (record_arch_list_add_mem (tmpaddr, tdep->size_iocb))
1888                 return -1;
1889               iocbp += tdep->size_pointer;
1890             }
1891         }
1892       break;
1893
1894     case gdb_sys_io_cancel:
1895       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1896       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1897                                     tdep->size_io_event))
1898         return -1;
1899       break;
1900
1901     case gdb_sys_fadvise64:
1902     case gdb_sys_ni_syscall251:
1903       break;
1904
1905     case gdb_sys_exit_group:
1906       {
1907         int q;
1908
1909         target_terminal_ours ();
1910         q = yquery (_("The next instruction is syscall exit_group.  "
1911                       "It will make the program exit.  "
1912                       "Do you want to stop the program?"));
1913         target_terminal_inferior ();
1914         if (q)
1915           return 1;
1916       }
1917       break;
1918
1919     case gdb_sys_lookup_dcookie:
1920       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1921       if (tmpulongest)
1922         {
1923           ULONGEST len;
1924
1925           regcache_raw_read_unsigned (regcache, tdep->arg3, &len);
1926           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, (int) len))
1927             return -1;
1928         }
1929       break;
1930
1931     case gdb_sys_epoll_create:
1932     case gdb_sys_epoll_ctl:
1933       break;
1934
1935     case gdb_sys_epoll_wait:
1936       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1937       if (tmpulongest)
1938         {
1939           ULONGEST maxevents;
1940
1941           regcache_raw_read_unsigned (regcache, tdep->arg3, &maxevents);
1942           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1943                                         maxevents * tdep->size_epoll_event))
1944             return -1;
1945         }
1946       break;
1947
1948     case gdb_sys_remap_file_pages:
1949     case gdb_sys_set_tid_address:
1950       break;
1951
1952     case gdb_sys_timer_create:
1953       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
1954       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_int))
1955         return -1;
1956       break;
1957
1958     case gdb_sys_timer_settime:
1959       regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
1960       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1961                                     tdep->size_itimerspec))
1962         return -1;
1963       break;
1964
1965     case gdb_sys_timer_gettime:
1966       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1967       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1968                                     tdep->size_itimerspec))
1969         return -1;
1970       break;
1971
1972     case gdb_sys_timer_getoverrun:
1973     case gdb_sys_timer_delete:
1974     case gdb_sys_clock_settime:
1975       break;
1976
1977     case gdb_sys_clock_gettime:
1978       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1979       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1980                                     tdep->size_timespec))
1981         return -1;
1982       break;
1983
1984     case gdb_sys_clock_getres:
1985       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
1986       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1987                                     tdep->size_timespec))
1988         return -1;
1989       break;
1990
1991     case gdb_sys_clock_nanosleep:
1992       regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
1993       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
1994                                     tdep->size_timespec))
1995         return -1;
1996       break;
1997
1998     case gdb_sys_statfs64:
1999     case gdb_sys_fstatfs64:
2000       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
2001       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2002                                     tdep->size_statfs64))
2003         return -1;
2004       break;
2005
2006     case gdb_sys_tgkill:
2007     case gdb_sys_utimes:
2008     case gdb_sys_fadvise64_64:
2009     case gdb_sys_ni_syscall273:
2010     case gdb_sys_mbind:
2011       break;
2012
2013     case gdb_sys_get_mempolicy:
2014       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
2015       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_int))
2016         return -1;
2017       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
2018       if (tmpulongest)
2019         {
2020           ULONGEST maxnode;
2021
2022           regcache_raw_read_unsigned (regcache, tdep->arg3, &maxnode);
2023           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2024                                         maxnode * tdep->size_long))
2025             return -1;
2026         }
2027       break;
2028
2029     case gdb_sys_set_mempolicy:
2030     case gdb_sys_mq_open:
2031     case gdb_sys_mq_unlink:
2032     case gdb_sys_mq_timedsend:
2033       break;
2034
2035     case gdb_sys_mq_timedreceive:
2036       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
2037       if (tmpulongest)
2038         {
2039           ULONGEST msg_len;
2040
2041           regcache_raw_read_unsigned (regcache, tdep->arg3, &msg_len);
2042           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2043                                         (int) msg_len))
2044             return -1;
2045         }
2046       regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
2047       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_int))
2048         return -1;
2049       break;
2050
2051     case gdb_sys_mq_notify:
2052       break;
2053
2054     case gdb_sys_mq_getsetattr:
2055       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
2056       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2057                                     tdep->size_mq_attr))
2058         return -1;
2059       break;
2060
2061     case gdb_sys_kexec_load:
2062       break;
2063
2064     case gdb_sys_waitid:
2065       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
2066       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2067                                     tdep->size_siginfo))
2068         return -1;
2069       regcache_raw_read_unsigned (regcache, tdep->arg5, &tmpulongest);
2070       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2071                                     tdep->size_rusage))
2072         return -1;
2073       break;
2074
2075     case gdb_sys_ni_syscall285:
2076     case gdb_sys_add_key:
2077     case gdb_sys_request_key:
2078       break;
2079
2080     case gdb_sys_keyctl:
2081       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
2082       if (tmpulongest == 6 || tmpulongest == 11)
2083         {
2084           regcache_raw_read_unsigned (regcache, tdep->arg3,
2085                                       &tmpulongest);
2086           if (tmpulongest)
2087             {
2088               ULONGEST buflen;
2089
2090               regcache_raw_read_unsigned (regcache, tdep->arg4, &buflen);
2091               if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2092                                             (int) buflen))
2093                 return -1;
2094             }
2095         }
2096       break;
2097
2098     case gdb_sys_ioprio_set:
2099     case gdb_sys_ioprio_get:
2100     case gdb_sys_inotify_init:
2101     case gdb_sys_inotify_add_watch:
2102     case gdb_sys_inotify_rm_watch:
2103     case gdb_sys_migrate_pages:
2104     case gdb_sys_openat:
2105     case gdb_sys_mkdirat:
2106     case gdb_sys_mknodat:
2107     case gdb_sys_fchownat:
2108     case gdb_sys_futimesat:
2109       break;
2110
2111     case gdb_sys_fstatat64:
2112       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
2113       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2114                                     tdep->size_stat64))
2115         return -1;
2116       break;
2117
2118     case gdb_sys_unlinkat:
2119     case gdb_sys_renameat:
2120     case gdb_sys_linkat:
2121     case gdb_sys_symlinkat:
2122       break;
2123
2124     case gdb_sys_readlinkat:
2125       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
2126       if (tmpulongest)
2127         {
2128           ULONGEST bufsiz;
2129
2130           regcache_raw_read_unsigned (regcache, tdep->arg4, &bufsiz);
2131           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, (int) bufsiz))
2132             return -1;
2133         }
2134       break;
2135
2136     case gdb_sys_fchmodat:
2137     case gdb_sys_faccessat:
2138       break;
2139
2140     case gdb_sys_pselect6:
2141       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
2142       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2143                                     tdep->size_fd_set))
2144         return -1;
2145       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
2146       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2147                                     tdep->size_fd_set))
2148         return -1;
2149       regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
2150       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2151                                     tdep->size_fd_set))
2152         return -1;
2153       regcache_raw_read_unsigned (regcache, tdep->arg5, &tmpulongest);
2154       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2155                                     tdep->size_timespec))
2156         return -1;
2157       break;
2158
2159     case gdb_sys_ppoll:
2160       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
2161       if (tmpulongest)
2162         {
2163           ULONGEST nfds;
2164
2165           regcache_raw_read_unsigned (regcache, tdep->arg2, &nfds);
2166           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2167                                         tdep->size_pollfd * nfds))
2168             return -1;
2169         }
2170       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
2171       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2172                                     tdep->size_timespec))
2173         return -1;
2174       break;
2175
2176     case gdb_sys_unshare:
2177     case gdb_sys_set_robust_list:
2178       break;
2179
2180     case gdb_sys_get_robust_list:
2181       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
2182       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_int))
2183         return -1;
2184       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
2185       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_int))
2186         return -1;
2187       break;
2188
2189     case gdb_sys_splice:
2190       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
2191       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2192                                     tdep->size_loff_t))
2193         return -1;
2194       regcache_raw_read_unsigned (regcache, tdep->arg4, &tmpulongest);
2195       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2196                                     tdep->size_loff_t))
2197         return -1;
2198       break;
2199
2200     case gdb_sys_sync_file_range:
2201     case gdb_sys_tee:
2202     case gdb_sys_vmsplice:
2203       break;
2204
2205     case gdb_sys_move_pages:
2206       regcache_raw_read_unsigned (regcache, tdep->arg5, &tmpulongest);
2207       if (tmpulongest)
2208         {
2209           ULONGEST nr_pages;
2210
2211           regcache_raw_read_unsigned (regcache, tdep->arg2, &nr_pages);
2212           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2213                                         nr_pages * tdep->size_int))
2214             return -1;
2215         }
2216       break;
2217
2218     case gdb_sys_getcpu:
2219       regcache_raw_read_unsigned (regcache, tdep->arg1, &tmpulongest);
2220       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_int))
2221         return -1;
2222       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
2223       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tdep->size_int))
2224         return -1;
2225       regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
2226       if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest,
2227                                     tdep->size_ulong * 2))
2228         return -1;
2229       break;
2230
2231     case gdb_sys_epoll_pwait:
2232       regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
2233       if (tmpulongest)
2234         {
2235           ULONGEST maxevents;
2236
2237           regcache_raw_read_unsigned (regcache, tdep->arg3, &maxevents);
2238           tmpint = (int) maxevents * tdep->size_epoll_event;
2239           if (record_arch_list_add_mem ((CORE_ADDR) tmpulongest, tmpint))
2240             return -1;
2241         }
2242       break;
2243
2244     default:
2245       printf_unfiltered (_("Process record and replay target doesn't "
2246                            "support syscall number %d\n"), syscall);
2247       return -1;
2248       break;
2249     }
2250
2251   return 0;
2252 }