OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [linux-record.c] - Blame information for rev 842

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.