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