/* Process record and replay target code for GNU/Linux.
- Copyright (C) 2008-2016 Free Software Foundation, Inc.
+ Copyright (C) 2008-2022 Free Software Foundation, Inc.
This file is part of GDB.
#include "record.h"
#include "record-full.h"
#include "linux-record.h"
+#include "gdbarch.h"
/* These macros are the values of the first argument of system call
"sys_ptrace". The values of these macros were obtained from Linux
#define RECORD_Q_XGETQUOTA (('3' << 8) + 3)
#define OUTPUT_REG(val, num) phex_nz ((val), \
- TYPE_LENGTH (gdbarch_register_type (get_regcache_arch (regcache), (num))))
+ TYPE_LENGTH (gdbarch_register_type (regcache->arch (), (num))))
/* Record a memory area of length LEN pointed to by register
REGNUM. */
{
gdb_byte *a;
int addrlen;
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = regcache->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
if (!addr)
if (target_read_memory ((CORE_ADDR) len, a, tdep->size_int))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading "
- "memory at addr = 0x%s len = %d.\n",
- phex_nz (len, tdep->size_pointer),
- tdep->size_int);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading "
+ "memory at addr = 0x%s len = %d.\n",
+ phex_nz (len, tdep->size_pointer),
+ tdep->size_int);
return -1;
}
addrlen = (int) extract_unsigned_integer (a, tdep->size_int, byte_order);
struct linux_record_tdep *tdep, ULONGEST addr)
{
gdb_byte *a;
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = regcache->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR tmpaddr;
int tmpint;
if (target_read_memory ((CORE_ADDR) addr, a, tdep->size_msghdr))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading "
- "memory at addr = 0x%s "
- "len = %d.\n",
- phex_nz (addr, tdep->size_pointer),
- tdep->size_msghdr);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading "
+ "memory at addr = 0x%s "
+ "len = %d.\n",
+ phex_nz (addr, tdep->size_pointer),
+ tdep->size_msghdr);
return -1;
}
if (target_read_memory ((CORE_ADDR) addr, iov, tdep->size_iovec))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error "
- "reading memory at "
- "addr = 0x%s "
- "len = %d.\n",
- phex_nz (addr,tdep->size_pointer),
- tdep->size_iovec);
+ gdb_printf (gdb_stdlog,
+ "Process record: error "
+ "reading memory at "
+ "addr = 0x%s "
+ "len = %d.\n",
+ phex_nz (addr,tdep->size_pointer),
+ tdep->size_iovec);
return -1;
}
tmpaddr = (CORE_ADDR) extract_unsigned_integer (iov,
struct regcache *regcache,
struct linux_record_tdep *tdep)
{
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch *gdbarch = regcache->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST tmpulongest;
CORE_ADDR tmpaddr;
break;
case gdb_sys_exit:
- {
- int q;
-
- target_terminal_ours ();
- q = yquery (_("The next instruction is syscall exit. "
- "It will make the program exit. "
- "Do you want to stop the program?"));
- target_terminal_inferior ();
- if (q)
- return 1;
- }
+ if (yquery (_("The next instruction is syscall exit. "
+ "It will make the program exit. "
+ "Do you want to stop the program?")))
+ return 1;
break;
case gdb_sys_fork:
break;
case gdb_sys_read:
+ case gdb_sys_readlink:
+ case gdb_sys_recv:
regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
if (record_mem_at_reg (regcache, tdep->arg2, (int) tmpulongest))
return -1;
break;
case gdb_sys_pipe:
+ case gdb_sys_pipe2:
if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int * 2))
return -1;
break;
}
else if (tmpulongest == tdep->ioctl_TIOCSERGSTRUCT)
{
- printf_unfiltered (_("Process record and replay target doesn't "
- "support ioctl request TIOCSERGSTRUCT\n"));
+ gdb_printf (gdb_stderr,
+ _("Process record and replay target doesn't "
+ "support ioctl request TIOCSERGSTRUCT\n"));
return 1;
}
else
{
- printf_unfiltered (_("Process record and replay target doesn't "
- "support ioctl request 0x%s.\n"),
- OUTPUT_REG (tmpulongest, tdep->arg2));
+ gdb_printf (gdb_stderr,
+ _("Process record and replay target doesn't "
+ "support ioctl request 0x%s.\n"),
+ OUTPUT_REG (tmpulongest, tdep->arg2));
return 1;
}
break;
if (target_read_memory (tmpulongest, a, sz_sel_arg))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading memory "
- "at addr = 0x%s len = %lu.\n",
- OUTPUT_REG (tmpulongest, tdep->arg1),
- sz_sel_arg);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading memory "
+ "at addr = 0x%s len = %lu.\n",
+ OUTPUT_REG (tmpulongest, tdep->arg1),
+ sz_sel_arg);
return -1;
}
/* Skip n. */
case gdb_sys_symlink:
break;
- case gdb_sys_readlink:
- regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
- if (record_mem_at_reg (regcache, tdep->arg2, (int) tmpulongest))
- return -1;
- break;
-
case gdb_sys_uselib:
case gdb_sys_swapon:
break;
case gdb_sys_reboot:
- {
- int q;
-
- target_terminal_ours ();
- q = yquery (_("The next instruction is syscall reboot. "
- "It will restart the computer. "
- "Do you want to stop the program?"));
- target_terminal_inferior ();
- if (q)
- return 1;
- }
+ if (yquery (_("The next instruction is syscall reboot. "
+ "It will restart the computer. "
+ "Do you want to stop the program?")))
+ return 1;
break;
case gdb_old_readdir:
regcache_raw_read_unsigned (regcache, tdep->arg2, &len);
if (record_full_memory_query)
{
- int q;
-
- target_terminal_ours ();
- q = yquery (_("\
+ if (yquery (_("\
The next instruction is syscall munmap.\n\
It will free the memory addr = 0x%s len = %u.\n\
It will make record target cannot record some memory change.\n\
Do you want to stop the program?"),
- OUTPUT_REG (tmpulongest, tdep->arg1), (int) len);
- target_terminal_inferior ();
- if (q)
+ OUTPUT_REG (tmpulongest, tdep->arg1), (int) len))
return 1;
}
}
}
break;
- case gdb_sys_recv:
- regcache_raw_read_unsigned (regcache, tdep->arg3, &tmpulongest);
- if (record_mem_at_reg (regcache, tdep->arg2, (int) tmpulongest))
- return -1;
- break;
-
case gdb_sys_recvmsg:
regcache_raw_read_unsigned (regcache, tdep->arg2, &tmpulongest);
if (record_linux_msghdr (regcache, tdep, tmpulongest))
tdep->size_int))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading "
- "memory at addr = 0x%s "
- "len = %d.\n",
- OUTPUT_REG (tmpulongest, tdep->arg5),
- tdep->size_int);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading "
+ "memory at addr = 0x%s "
+ "len = %d.\n",
+ OUTPUT_REG (tmpulongest, tdep->arg5),
+ tdep->size_int);
return -1;
}
regcache_raw_read_unsigned (regcache, tdep->arg4, &optvalp);
tdep->size_ulong * 2))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading "
- "memory at addr = 0x%s len = %d.\n",
- OUTPUT_REG (tmpulongest, tdep->arg2),
- tdep->size_ulong * 2);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading "
+ "memory at addr = 0x%s len = %d.\n",
+ OUTPUT_REG (tmpulongest, tdep->arg2),
+ tdep->size_ulong * 2);
return -1;
}
tmpulongest = extract_unsigned_integer (a,
tdep->size_ulong))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading "
- "memory at addr = 0x%s len = %d.\n",
- OUTPUT_REG (tmpulongest, tdep->arg2),
- tdep->size_ulong);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading "
+ "memory at addr = 0x%s len = %d.\n",
+ OUTPUT_REG (tmpulongest, tdep->arg2),
+ tdep->size_ulong);
return -1;
}
tmpaddr
tdep->size_ulong * 2))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading "
- "memory at addr = 0x%s len = %d.\n",
- OUTPUT_REG (tmpulongest, tdep->arg2),
- tdep->size_ulong * 2);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading "
+ "memory at addr = 0x%s len = %d.\n",
+ OUTPUT_REG (tmpulongest, tdep->arg2),
+ tdep->size_ulong * 2);
return -1;
}
tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
if (record_linux_sockaddr (regcache, tdep, tmpulongest, len))
return -1;
}
+ break;
case RECORD_SYS_RECV:
regcache_raw_read_unsigned (regcache, tdep->arg2,
&tmpulongest);
tdep->size_ulong))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading "
- "memory at addr = 0x%s len = %d.\n",
- OUTPUT_REG (tmpulongest, tdep->arg2),
- tdep->size_ulong);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading "
+ "memory at addr = 0x%s len = %d.\n",
+ OUTPUT_REG (tmpulongest, tdep->arg2),
+ tdep->size_ulong);
return -1;
}
tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
tdep->size_ulong * 2))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading "
- "memory at addr = 0x%s len = %d.\n",
- OUTPUT_REG (tmpulongest, tdep->arg2),
- tdep->size_ulong * 2);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading "
+ "memory at addr = 0x%s len = %d.\n",
+ OUTPUT_REG (tmpulongest, tdep->arg2),
+ tdep->size_ulong * 2);
return -1;
}
tmpulongest = extract_unsigned_integer (a + tdep->size_ulong,
tdep->size_int))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading "
- "memory at addr = 0x%s "
- "len = %d.\n",
- phex_nz (tmpulongest,
- tdep->size_ulong),
- tdep->size_int);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading "
+ "memory at addr = 0x%s "
+ "len = %d.\n",
+ phex_nz (tmpulongest,
+ tdep->size_ulong),
+ tdep->size_int);
return -1;
}
tmpaddr
tdep->size_ulong))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading "
- "memory at addr = 0x%s len = %d.\n",
- OUTPUT_REG (tmpulongest, tdep->arg2),
- tdep->size_ulong);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading "
+ "memory at addr = 0x%s len = %d.\n",
+ OUTPUT_REG (tmpulongest, tdep->arg2),
+ tdep->size_ulong);
return -1;
}
tmpulongest = extract_unsigned_integer (a, tdep->size_ulong,
}
break;
default:
- printf_unfiltered (_("Process record and replay target "
- "doesn't support socketcall call 0x%s\n"),
- OUTPUT_REG (tmpulongest, tdep->arg1));
+ gdb_printf (gdb_stderr,
+ _("Process record and replay target "
+ "doesn't support socketcall call 0x%s\n"),
+ OUTPUT_REG (tmpulongest, tdep->arg1));
return -1;
break;
}
break;
default:
/* XXX RECORD_SEMCTL still not supported. */
- printf_unfiltered (_("Process record and replay target doesn't "
- "support ipc number %s\n"),
- pulongest (tmpulongest));
+ gdb_printf (gdb_stderr,
+ _("Process record and replay target doesn't "
+ "support ipc number %s\n"),
+ pulongest (tmpulongest));
break;
}
break;
tdep->size_iovec))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading "
- "memory at addr = 0x%s len = %d.\n",
- OUTPUT_REG (vec, tdep->arg2),
- tdep->size_iovec);
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading "
+ "memory at addr = 0x%s len = %d.\n",
+ OUTPUT_REG (vec, tdep->arg2),
+ tdep->size_iovec);
return -1;
}
tmpaddr
nr * tdep->size_pointer))
{
if (record_debug)
- fprintf_unfiltered (gdb_stdlog,
- "Process record: error reading memory "
- "at addr = 0x%s len = %u.\n",
- OUTPUT_REG (tmpulongest, tdep->arg2),
- (int) (nr * tdep->size_pointer));
+ gdb_printf (gdb_stdlog,
+ "Process record: error reading memory "
+ "at addr = 0x%s len = %u.\n",
+ OUTPUT_REG (tmpulongest, tdep->arg2),
+ (int) (nr * tdep->size_pointer));
return -1;
}
for (i = 0; i < nr; i++)
break;
case gdb_sys_exit_group:
- {
- int q;
-
- target_terminal_ours ();
- q = yquery (_("The next instruction is syscall exit_group. "
- "It will make the program exit. "
- "Do you want to stop the program?"));
- target_terminal_inferior ();
- if (q)
- return 1;
- }
+ if (yquery (_("The next instruction is syscall exit_group. "
+ "It will make the program exit. "
+ "Do you want to stop the program?")))
+ return 1;
break;
case gdb_sys_lookup_dcookie:
case gdb_sys_dup3:
break;
- case gdb_sys_pipe2:
- if (record_mem_at_reg (regcache, tdep->arg1, tdep->size_int * 2))
- return -1;
- break;
-
case gdb_sys_inotify_init1:
break;
default:
- printf_unfiltered (_("Process record and replay target doesn't "
- "support syscall number %d\n"), syscall);
+ gdb_printf (gdb_stderr,
+ _("Process record and replay target doesn't "
+ "support syscall number %d\n"), syscall);
return -1;
break;
}