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