/* Native-dependent code for GNU/Linux i386.
- Copyright (C) 1999-2018 Free Software Foundation, Inc.
+ Copyright (C) 1999-2023 Free Software Foundation, Inc.
This file is part of GDB.
#include "i387-tdep.h"
#include "i386-tdep.h"
#include "i386-linux-tdep.h"
-#include "x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
#include "x86-linux-nat.h"
#include "nat/linux-ptrace.h"
gdb_assert (!have_ptrace_getregs);
if (i386_linux_gregset_reg_offset[regno] == -1)
{
- regcache_raw_supply (regcache, regno, NULL);
+ regcache->raw_supply (regno, NULL);
return;
}
- tid = get_ptrace_pid (regcache_get_ptid (regcache));
+ tid = get_ptrace_pid (regcache->ptid ());
errno = 0;
val = ptrace (PTRACE_PEEKUSER, tid,
gdbarch_register_name (regcache->arch (), regno),
regno, safe_strerror (errno));
- regcache_raw_supply (regcache, regno, &val);
+ regcache->raw_supply (regno, &val);
}
/* Store one register. */
if (i386_linux_gregset_reg_offset[regno] == -1)
return;
- tid = get_ptrace_pid (regcache_get_ptid (regcache));
+ tid = get_ptrace_pid (regcache->ptid ());
errno = 0;
- regcache_raw_collect (regcache, regno, &val);
+ regcache->raw_collect (regno, &val);
ptrace (PTRACE_POKEUSER, tid,
i386_linux_gregset_reg_offset[regno], val);
if (errno != 0)
int i;
for (i = 0; i < I386_NUM_GREGS; i++)
- regcache_raw_supply (regcache, i,
- regp + i386_linux_gregset_reg_offset[i]);
+ regcache->raw_supply (i, regp + i386_linux_gregset_reg_offset[i]);
if (I386_LINUX_ORIG_EAX_REGNUM
< gdbarch_num_regs (regcache->arch ()))
- regcache_raw_supply (regcache, I386_LINUX_ORIG_EAX_REGNUM, regp
- + i386_linux_gregset_reg_offset[I386_LINUX_ORIG_EAX_REGNUM]);
+ regcache->raw_supply
+ (I386_LINUX_ORIG_EAX_REGNUM,
+ regp + i386_linux_gregset_reg_offset[I386_LINUX_ORIG_EAX_REGNUM]);
}
/* Fill register REGNO (if it is a general-purpose register) in
for (i = 0; i < I386_NUM_GREGS; i++)
if (regno == -1 || regno == i)
- regcache_raw_collect (regcache, i,
- regp + i386_linux_gregset_reg_offset[i]);
+ regcache->raw_collect (i, regp + i386_linux_gregset_reg_offset[i]);
if ((regno == -1 || regno == I386_LINUX_ORIG_EAX_REGNUM)
&& I386_LINUX_ORIG_EAX_REGNUM
< gdbarch_num_regs (regcache->arch ()))
- regcache_raw_collect (regcache, I386_LINUX_ORIG_EAX_REGNUM, regp
- + i386_linux_gregset_reg_offset[I386_LINUX_ORIG_EAX_REGNUM]);
+ regcache->raw_collect
+ (I386_LINUX_ORIG_EAX_REGNUM,
+ regp + i386_linux_gregset_reg_offset[I386_LINUX_ORIG_EAX_REGNUM]);
}
#ifdef HAVE_PTRACE_GETREGS
if (errno == EIO)
{
/* The kernel we're running on doesn't support the GETREGS
- request. Reset `have_ptrace_getregs'. */
+ request. Reset `have_ptrace_getregs'. */
have_ptrace_getregs = 0;
return;
}
return;
}
- tid = get_ptrace_pid (regcache_get_ptid (regcache));
+ tid = get_ptrace_pid (regcache->ptid ());
/* Use the PTRACE_GETFPXREGS request whenever possible, since it
transfers more registers in one system call, and we'll cache the
return;
}
- internal_error (__FILE__, __LINE__,
- _("Got request for bad register number %d."), regno);
+ internal_error (_("Got request for bad register number %d."), regno);
}
/* Store register REGNO back into the child process. If REGNO is -1,
return;
}
- tid = get_ptrace_pid (regcache_get_ptid (regcache));
+ tid = get_ptrace_pid (regcache->ptid ());
/* Use the PTRACE_SETFPXREGS requests whenever possible, since it
transfers more registers in one system call. But remember that
return;
}
- internal_error (__FILE__, __LINE__,
- _("Got request to store bad register number %d."), regno);
+ internal_error (_("Got request to store bad register number %d."), regno);
}
\f
void
i386_linux_nat_target::low_resume (ptid_t ptid, int step, enum gdb_signal signal)
{
- int pid = ptid_get_lwp (ptid);
+ int pid = ptid.lwp ();
int request;
if (catch_syscall_enabled () > 0)
if (step)
{
- struct regcache *regcache = get_thread_regcache (ptid);
+ struct regcache *regcache = get_thread_regcache (this, ptid);
struct gdbarch *gdbarch = regcache->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST pc;
gdbarch_pc_regnum (gdbarch), &pc);
/* Returning from a signal trampoline is done by calling a
- special system call (sigreturn or rt_sigreturn, see
- i386-linux-tdep.c for more information). This system call
- restores the registers that were saved when the signal was
- raised, including %eflags. That means that single-stepping
- won't work. Instead, we'll have to modify the signal context
- that's about to be restored, and set the trace flag there. */
+ special system call (sigreturn or rt_sigreturn, see
+ i386-linux-tdep.c for more information). This system call
+ restores the registers that were saved when the signal was
+ raised, including %eflags. That means that single-stepping
+ won't work. Instead, we'll have to modify the signal context
+ that's about to be restored, and set the trace flag there. */
/* First check if PC is at a system call. */
if (target_read_memory (pc, buf, LINUX_SYSCALL_LEN) == 0
addr = sp;
/* Set the trace flag in the context that's about to be
- restored. */
+ restored. */
addr += LINUX_SIGCONTEXT_EFLAGS_OFFSET;
read_memory (addr, (gdb_byte *) &eflags, 4);
eflags |= 0x0100;
perror_with_name (("ptrace"));
}
+void _initialize_i386_linux_nat ();
void
-_initialize_i386_linux_nat (void)
+_initialize_i386_linux_nat ()
{
linux_target = &the_i386_linux_nat_target;
/* Add the target. */
- x86_linux_add_target (linux_target);
+ add_inf_child_target (linux_target);
}