24#include "elf/common.h"
34#include "gdbsupport/x86-xstate.h"
47 void low_resume (ptid_t ptid,
int step,
enum gdb_signal sig)
override;
67#define GETREGS_SUPPLIES(regno) \
68 ((0 <= (regno) && (regno) <= 15) || (regno) == I386_LINUX_ORIG_EAX_REGNUM)
70#define GETFPXREGS_SUPPLIES(regno) \
71 (I386_ST0_REGNUM <= (regno) && (regno) < I386_SSE_NUM_REGS)
73#define GETXSTATEREGS_SUPPLIES(regno) \
74 (I386_ST0_REGNUM <= (regno) && (regno) < I386_PKEYS_NUM_REGS)
78#ifdef HAVE_PTRACE_GETREGS
94#ifdef HAVE_PTRACE_GETFPXREGS
122 val =
ptrace (PTRACE_PEEKUSER, tid,
125 error (_(
"Couldn't read register %s (#%d): %s."),
127 regno, safe_strerror (errno));
148 ptrace (PTRACE_POKEUSER, tid,
151 error (_(
"Couldn't write register %s (#%d): %s."),
153 regno, safe_strerror (errno));
166 const gdb_byte *regp = (
const gdb_byte *) gregsetp;
185 elf_gregset_t *gregsetp,
int regno)
187 gdb_byte *regp = (gdb_byte *) gregsetp;
191 if (regno == -1 || regno == i)
202#ifdef HAVE_PTRACE_GETREGS
211 elf_gregset_t *regs_p = ®s;
223 perror_with_name (_(
"Couldn't get registers"));
238 perror_with_name (_(
"Couldn't get registers"));
243 perror_with_name (_(
"Couldn't write registers"));
271 elf_fpregset_t *fpregsetp,
int regno)
276#ifdef HAVE_PTRACE_GETREGS
284 elf_fpregset_t fpregs;
287 perror_with_name (_(
"Couldn't get floating point status"));
298 elf_fpregset_t fpregs;
301 perror_with_name (_(
"Couldn't get floating point status"));
306 perror_with_name (_(
"Couldn't write floating point status"));
341 iov.iov_base = xstateregs;
342 iov.iov_len =
sizeof(xstateregs);
345 perror_with_name (_(
"Couldn't read extended state status"));
366 iov.iov_base = xstateregs;
367 iov.iov_len =
sizeof(xstateregs);
370 perror_with_name (_(
"Couldn't read extended state status"));
376 perror_with_name (_(
"Couldn't write extended state status"));
381#ifdef HAVE_PTRACE_GETFPXREGS
390 elf_fpxregset_t fpxregs;
395 if (
ptrace (PTRACE_GETFPXREGS, tid, 0, (
int) &fpxregs) < 0)
403 perror_with_name (_(
"Couldn't read floating-point and SSE registers"));
417 elf_fpxregset_t fpxregs;
422 if (
ptrace (PTRACE_GETFPXREGS, tid, 0, &fpxregs) == -1)
430 perror_with_name (_(
"Couldn't read floating-point and SSE registers"));
435 if (
ptrace (PTRACE_SETFPXREGS, tid, 0, &fpxregs) == -1)
436 perror_with_name (_(
"Couldn't write floating-point and SSE registers"));
476 if (regno == -1 || regno == i)
534 internal_error (_(
"Got request for bad register number %d."), regno);
552 if (regno == -1 || regno == i)
598 internal_error (_(
"Got request to store bad register number %d."), regno);
607 lwpid_t lwpid,
int idx,
void **base)
609 unsigned int base_addr;
615 *(
int *) base = base_addr;
627#define LINUX_SYSCALL_LEN (sizeof linux_syscall)
630#define LINUX_SYSCALL_REGNUM I386_EAX_REGNUM
636#define SYS_sigreturn 0x77
638#ifndef SYS_rt_sigreturn
639#define SYS_rt_sigreturn 0xad
643#define LINUX_SIGCONTEXT_EFLAGS_OFFSET (64)
652 int pid = ptid.lwp ();
656 request = PTRACE_SYSCALL;
658 request = PTRACE_CONT;
668 request = PTRACE_SINGLESTEP;
693 unsigned long int eflags;
712 if (
ptrace (request,
pid, 0, gdb_signal_to_host (signal)) == -1)
713 perror_with_name ((
"ptrace"));
int catch_syscall_enabled(void)
void raw_collect(int regnum, void *buf) const override
void raw_supply(int regnum, const void *buf) override
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
#define ptrace(request, pid, addr, data)
int gdbarch_pc_regnum(struct gdbarch *gdbarch)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
int gdbarch_num_regs(struct gdbarch *gdbarch)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t int int rusage_t pid_t pid
void fill_fpregset(const struct regcache *regcache, elf_fpregset_t *fpregsetp, int regno)
static void fetch_register(struct regcache *regcache, int regno)
void fill_gregset(const struct regcache *regcache, elf_gregset_t *gregsetp, int regno)
#define LINUX_SYSCALL_LEN
static int fetch_xstateregs(struct regcache *regcache, int tid)
static i386_linux_nat_target the_i386_linux_nat_target
static void fetch_fpregs(struct regcache *regcache, int tid)
static void fetch_regs(struct regcache *regcache, int tid)
static int store_fpxregs(const struct regcache *regcache, int tid, int regno)
static void store_regs(const struct regcache *regcache, int tid, int regno)
static void store_register(const struct regcache *regcache, int regno)
ps_err_e ps_get_thread_area(struct ps_prochandle *ph, lwpid_t lwpid, int idx, void **base)
static int store_xstateregs(const struct regcache *regcache, int tid, int regno)
static const unsigned char linux_syscall[]
void _initialize_i386_linux_nat()
#define LINUX_SYSCALL_REGNUM
int have_ptrace_getfpxregs
void supply_gregset(struct regcache *regcache, const elf_gregset_t *gregsetp)
#define GETFPXREGS_SUPPLIES(regno)
#define LINUX_SIGCONTEXT_EFLAGS_OFFSET
static int fetch_fpxregs(struct regcache *regcache, int tid)
#define GETREGS_SUPPLIES(regno)
#define GETXSTATEREGS_SUPPLIES(regno)
static void store_fpregs(const struct regcache *regcache, int tid, int regno)
void supply_fpregset(struct regcache *regcache, const elf_fpregset_t *fpregsetp)
int i386_linux_gregset_reg_offset[]
#define I386_LINUX_ORIG_EAX_REGNUM
void i387_supply_xsave(struct regcache *regcache, int regnum, const void *xsave)
void i387_supply_fxsave(struct regcache *regcache, int regnum, const void *fxsave)
void i387_collect_fxsave(const struct regcache *regcache, int regnum, void *fxsave)
void i387_collect_xsave(const struct regcache *regcache, int regnum, void *xsave, int gcore)
void i387_supply_fsave(struct regcache *regcache, int regnum, const void *fsave)
void i387_collect_fsave(const struct regcache *regcache, int regnum, void *fsave)
void add_inf_child_target(inf_child_target *target)
pid_t get_ptrace_pid(ptid_t ptid)
struct linux_nat_target * linux_target
enum tribool have_ptrace_getregset
enum register_status regcache_cooked_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
struct regcache * get_thread_regcache(process_stratum_target *target, ptid_t ptid)
x86_xsave_layout xsave_layout
void store_registers(struct regcache *, int) override
void fetch_registers(struct regcache *, int) override
void low_resume(ptid_t ptid, int step, enum gdb_signal sig) override
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
ps_err_e x86_linux_get_thread_area(pid_t pid, void *addr, unsigned int *base_addr)