-/* Native-dependent code for Linux/x86-64.
- Copyright 2001
- Free Software Foundation, Inc.
+/* Native-dependent code for GNU/Linux x86-64.
+
+ Copyright 2001, 2002 Free Software Foundation, Inc.
+
Contributed by Jiri Smid, SuSE Labs.
This file is part of GDB.
#include <sys/debugreg.h>
#include <sys/syscall.h>
#include <sys/procfs.h>
+#include <sys/reg.h>
+
+/* Mapping between the general-purpose registers in `struct user'
+ format and GDB's register array layout. */
+
+static int x86_64_regmap[] = {
+ RAX, RDX, RCX, RBX,
+ RSI, RDI, RBP, RSP,
+ R8, R9, R10, R11,
+ R12, R13, R14, R15,
+ RIP, EFLAGS
+};
static unsigned long
x86_64_linux_dr_get (int regnum)
}
\f
-/* The register sets used in Linux ELF core-dumps are identical to the
- register sets used by `ptrace'. */
+/* The register sets used in GNU/Linux ELF core-dumps are identical to
+ the register sets used by `ptrace'. */
#define GETREGS_SUPPLIES(regno) \
(0 <= (regno) && (regno) <= 17)
{
int tid;
- /* Linux LWP ID's are process ID's. */
+ /* GNU/Linux LWP ID's are process ID's. */
if ((tid = TIDGET (inferior_ptid)) == 0)
tid = PIDGET (inferior_ptid); /* Not a threaded program. */
{
int tid;
- /* Linux LWP ID's are process ID's. */
+ /* GNU/Linux LWP ID's are process ID's. */
if ((tid = TIDGET (inferior_ptid)) == 0)
tid = PIDGET (inferior_ptid); /* Not a threaded program. */
int
child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
- struct mem_attrib *attrib ATTRIBUTE_UNUSED,
- struct target_ops *target)
+ struct mem_attrib *attrib, struct target_ops *target)
{
register int i;
/* Round starting address down to longword boundary. */
0 --- the general-purpose register set, in elf_gregset_t format
2 --- the floating-point register set, in elf_fpregset_t format
- REG_ADDR isn't used on Linux. */
+ REG_ADDR isn't used on GNU/Linux. */
static void
fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
}
}
-/* Register that we are able to handle Linux ELF core file formats. */
+/* Register that we are able to handle GNU/Linux ELF core file formats. */
static struct core_fns linux_elf_core_fns = {
bfd_target_elf_flavour, /* core_flavour */
/* Record which address associates with which register. */
static CORE_ADDR address_lookup[DR_LASTADDR - DR_FIRSTADDR + 1];
+/* Return the address of register REGNUM. BLOCKEND is the value of
+ u.u_ar0, which should point to the registers. */
+CORE_ADDR
+x86_64_register_u_addr (CORE_ADDR blockend, int regnum)
+{
+ struct user u;
+ CORE_ADDR fpstate;
+ CORE_ADDR ubase;
+ ubase = blockend;
+ if (IS_FP_REGNUM(regnum))
+ {
+ fpstate = ubase + ((char *) &u.i387.st_space - (char *) &u);
+ return (fpstate + 16 * (regnum - FP0_REGNUM));
+ }
+ else if (IS_SSE_REGNUM(regnum))
+ {
+ fpstate = ubase + ((char *) &u.i387.xmm_space - (char *) &u);
+ return (fpstate + 16 * (regnum - XMM0_REGNUM));
+ }
+ else
+ return (ubase + 8 * x86_64_regmap[regnum]);
+}
+
void
_initialize_x86_64_linux_nat (void)
{