Add support to show the symbolic names of the MIPS CP1 registers.
[deliverable/binutils-gdb.git] / gdb / amd64-linux-tdep.c
index 0adc22b7e69f1a79f275d157a40608d8fc28e518..7fe92d1eea0183f9cd63fc010cce3944c7319ec7 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for GNU/Linux x86-64.
 
-   Copyright (C) 2001, 2003-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001-2013 Free Software Foundation, Inc.
    Contributed by Jiri Smid, SuSE Labs.
 
    This file is part of GDB.
@@ -33,7 +33,7 @@
 #include "linux-tdep.h"
 #include "i386-xstate.h"
 
-#include "gdb_string.h"
+#include <string.h>
 
 #include "amd64-tdep.h"
 #include "solib-svr4.h"
 
 #include "features/i386/amd64-linux.c"
 #include "features/i386/amd64-avx-linux.c"
+#include "features/i386/amd64-mpx-linux.c"
 #include "features/i386/x32-linux.c"
 #include "features/i386/x32-avx-linux.c"
 
 /* The syscall's XML filename for i386.  */
 #define XML_SYSCALL_FILENAME_AMD64 "syscalls/amd64-linux.xml"
 
-#include "record.h"
+#include "record-full.h"
 #include "linux-record.h"
 
 /* Supported register note sections.  */
@@ -96,6 +97,8 @@ int amd64_linux_gregset_reg_offset[] =
   -1, -1, -1, -1, -1, -1, -1, -1, -1,
   -1, -1, -1, -1, -1, -1, -1, -1,
   -1, -1, -1, -1, -1, -1, -1, -1,
+  -1, -1, -1, -1,              /* MPX registers BND0 ... BND3.  */
+  -1, -1,                      /* MPX registers BNDCFGU and BNDSTATUS.  */
   15 * 8                       /* "orig_rax" */
 };
 \f
@@ -107,7 +110,7 @@ int amd64_linux_gregset_reg_offset[] =
 #define LINUX_SIGTRAMP_INSN1   0x0f    /* syscall */
 #define LINUX_SIGTRAMP_OFFSET1 7
 
-static const gdb_byte linux_sigtramp_code[] =
+static const gdb_byte amd64_linux_sigtramp_code[] =
 {
   /* mov $__NR_rt_sigreturn, %rax */
   LINUX_SIGTRAMP_INSN0, 0xc7, 0xc0, 0x0f, 0x00, 0x00, 0x00,
@@ -115,7 +118,15 @@ static const gdb_byte linux_sigtramp_code[] =
   LINUX_SIGTRAMP_INSN1, 0x05
 };
 
-#define LINUX_SIGTRAMP_LEN (sizeof linux_sigtramp_code)
+static const gdb_byte amd64_x32_linux_sigtramp_code[] =
+{
+  /* mov $__NR_rt_sigreturn, %rax.  */
+  LINUX_SIGTRAMP_INSN0, 0xc7, 0xc0, 0x01, 0x02, 0x00, 0x40,
+  /* syscall */
+  LINUX_SIGTRAMP_INSN1, 0x05
+};
+
+#define LINUX_SIGTRAMP_LEN (sizeof amd64_linux_sigtramp_code)
 
 /* If PC is in a sigtramp routine, return the address of the start of
    the routine.  Otherwise, return 0.  */
@@ -123,6 +134,8 @@ static const gdb_byte linux_sigtramp_code[] =
 static CORE_ADDR
 amd64_linux_sigtramp_start (struct frame_info *this_frame)
 {
+  struct gdbarch *gdbarch;
+  const gdb_byte *sigtramp_code;
   CORE_ADDR pc = get_frame_pc (this_frame);
   gdb_byte buf[LINUX_SIGTRAMP_LEN];
 
@@ -146,7 +159,12 @@ amd64_linux_sigtramp_start (struct frame_info *this_frame)
        return 0;
     }
 
-  if (memcmp (buf, linux_sigtramp_code, LINUX_SIGTRAMP_LEN) != 0)
+  gdbarch = get_frame_arch (this_frame);
+  if (gdbarch_ptr_bit (gdbarch) == 32)
+    sigtramp_code = amd64_x32_linux_sigtramp_code;
+  else
+    sigtramp_code = amd64_linux_sigtramp_code;
+  if (memcmp (buf, sigtramp_code, LINUX_SIGTRAMP_LEN) != 0)
     return 0;
 
   return pc;
@@ -298,39 +316,39 @@ amd64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
 static int
 amd64_all_but_ip_registers_record (struct regcache *regcache)
 {
-  if (record_arch_list_add_reg (regcache, AMD64_RAX_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_RAX_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_RCX_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_RCX_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_RDX_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_RDX_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_RBX_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_RBX_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_RSP_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_RSP_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_RBP_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_RBP_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_RSI_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_RSI_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_RDI_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_RDI_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_R8_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_R8_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_R9_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_R9_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_R10_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_R10_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_R11_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_R11_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_R12_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_R12_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_R13_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_R13_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_R14_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_R14_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_R15_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_R15_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_EFLAGS_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_EFLAGS_REGNUM))
     return -1;
 
   return 0;
@@ -1149,7 +1167,7 @@ amd64_canonicalize_syscall (enum amd64_syscall syscall_number)
 
 /* Parse the arguments of current system call instruction and record
    the values of the registers and memory that will be changed into
-   "record_arch_list".  This instruction is "syscall".
+   "record_full_arch_list".  This instruction is "syscall".
 
    Return -1 if something wrong.  */
 
@@ -1188,8 +1206,8 @@ amd64_linux_syscall_record (struct regcache *regcache)
            regcache_raw_read_unsigned (regcache,
                                        amd64_linux_record_tdep.arg2,
                                        &addr);
-           if (record_arch_list_add_mem (addr,
-                                         amd64_linux_record_tdep.size_ulong))
+           if (record_full_arch_list_add_mem
+               (addr, amd64_linux_record_tdep.size_ulong))
              return -1;
          }
        goto record_regs;
@@ -1216,9 +1234,9 @@ amd64_linux_syscall_record (struct regcache *regcache)
 
  record_regs:
   /* Record the return value of the system call.  */
-  if (record_arch_list_add_reg (regcache, AMD64_RCX_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_RCX_REGNUM))
     return -1;
-  if (record_arch_list_add_reg (regcache, AMD64_R11_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_R11_REGNUM))
     return -1;
 
   return 0;
@@ -1238,7 +1256,7 @@ amd64_linux_record_signal (struct gdbarch *gdbarch,
   if (amd64_all_but_ip_registers_record (regcache))
     return -1;
 
-  if (record_arch_list_add_reg (regcache, AMD64_RIP_REGNUM))
+  if (record_full_arch_list_add_reg (regcache, AMD64_RIP_REGNUM))
     return -1;
 
   /* Record the change in the stack.  */
@@ -1252,12 +1270,12 @@ amd64_linux_record_signal (struct gdbarch *gdbarch,
   /* This is for frame_size.
      sp -= sizeof (struct rt_sigframe);  */
   rsp -= AMD64_LINUX_frame_size;
-  if (record_arch_list_add_mem (rsp, AMD64_LINUX_redzone
+  if (record_full_arch_list_add_mem (rsp, AMD64_LINUX_redzone
                                      + AMD64_LINUX_xstate
                                      + AMD64_LINUX_frame_size))
     return -1;
 
-  if (record_arch_list_add_end ())
+  if (record_full_arch_list_add_end ())
     return -1;
 
   return 0;
@@ -1271,9 +1289,15 @@ amd64_linux_core_read_description (struct gdbarch *gdbarch,
                                  bfd *abfd)
 {
   /* Linux/x86-64.  */
-  uint64_t xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd);
-  switch ((xcr0 & I386_XSTATE_AVX_MASK))
+  uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd);
+
+  switch (xcr0 & I386_XSTATE_ALL_MASK)
     {
+    case I386_XSTATE_MPX_MASK:
+      if (gdbarch_ptr_bit (gdbarch) == 32)
+       return tdesc_x32_avx_linux;  /* No x32 MPX falling back to AVX.  */
+      else
+       return tdesc_amd64_mpx_linux;
     case I386_XSTATE_AVX_MASK:
       if (gdbarch_ptr_bit (gdbarch) == 32)
        return tdesc_x32_avx_linux;
@@ -1608,6 +1632,7 @@ _initialize_amd64_linux_tdep (void)
   /* Initialize the Linux target description.  */
   initialize_tdesc_amd64_linux ();
   initialize_tdesc_amd64_avx_linux ();
+  initialize_tdesc_amd64_mpx_linux ();
   initialize_tdesc_x32_linux ();
   initialize_tdesc_x32_avx_linux ();
 }
This page took 0.026749 seconds and 4 git commands to generate.