* x86-64-tdep.h (sys/reg.h, x86_64_regmap): Moved to x86-64-linux-nat.c
[deliverable/binutils-gdb.git] / gdb / x86-64-linux-nat.c
index 85912e813804fdac74718981ca0531be177711cc..aafd2bed33ee825ba1ef7c990504736c03e77433 100644 (file)
@@ -1,6 +1,7 @@
-/* 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)
@@ -108,8 +121,8 @@ x86_64_linux_dr_get_status (void)
 }
 \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)
@@ -246,7 +259,7 @@ fetch_inferior_registers (int regno)
 {
   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.  */
 
@@ -281,7 +294,7 @@ store_inferior_registers (int regno)
 {
   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.  */
 
@@ -405,8 +418,7 @@ child_resume (ptid_t ptid, int step, enum target_signal signal)
 
 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.  */
@@ -499,7 +511,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write,
      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,
@@ -537,7 +549,7 @@ 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 */
@@ -558,6 +570,29 @@ static long debug_control_mirror;
 /* 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)
 {
This page took 0.028127 seconds and 4 git commands to generate.