include/elf/
[deliverable/binutils-gdb.git] / gdb / i386-linux-tdep.c
index 34a19249ce69debe9ca33e71cb856b8cf9148ceb..7c3962ec79eda74fa4b32088e20511d29e44d901 100644 (file)
@@ -1,7 +1,7 @@
 /* Target-dependent code for GNU/Linux i386.
 
-   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
-   Free Software Foundation, Inc.
+   Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010,
+   2011 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include <stdint.h>
 
 #include "features/i386/i386-linux.c"
+#include "features/i386/i386-mmx-linux.c"
 #include "features/i386/i386-avx-linux.c"
 
 /* Supported register note sections.  */
 static struct core_regset_section i386_linux_regset_sections[] =
 {
-  { ".reg", 144, "general-purpose" },
+  { ".reg", 68, "general-purpose" },
   { ".reg2", 108, "floating-point" },
+  { NULL, 0 }
+};
+
+static struct core_regset_section i386_linux_sse_regset_sections[] =
+{
+  { ".reg", 68, "general-purpose" },
   { ".reg-xfp", 512, "extended floating-point" },
+  { NULL, 0 }
+};
+
+static struct core_regset_section i386_linux_avx_regset_sections[] =
+{
+  { ".reg", 68, "general-purpose" },
   { ".reg-xstate", I386_XSTATE_MAX_SIZE, "XSAVE extended state" },
   { NULL, 0 }
 };
@@ -516,7 +529,7 @@ i386_linux_get_syscall_number (struct gdbarch *gdbarch,
    format and GDB's register cache layout.  */
 
 /* From <sys/reg.h>.  */
-static int i386_linux_gregset_reg_offset[] =
+int i386_linux_gregset_reg_offset[] =
 {
   6 * 4,                       /* %eax */
   1 * 4,                       /* %ecx */
@@ -590,7 +603,8 @@ i386_linux_core_read_xcr0 (struct gdbarch *gdbarch,
                                          I386_LINUX_XSAVE_XCR0_OFFSET,
                                          8))
            {
-             warning (_("Couldn't read `xcr0' bytes from `.reg-xstate' section in core file."));
+             warning (_("Couldn't read `xcr0' bytes from "
+                        "`.reg-xstate' section in core file."));
              return 0;
            }
 
@@ -598,7 +612,7 @@ i386_linux_core_read_xcr0 (struct gdbarch *gdbarch,
        }
     }
   else
-    xcr0 = I386_XSTATE_SSE_MASK;
+    xcr0 = 0;
 
   return xcr0;
 }
@@ -610,18 +624,24 @@ i386_linux_core_read_description (struct gdbarch *gdbarch,
                                  struct target_ops *target,
                                  bfd *abfd)
 {
-  asection *section = bfd_get_section_by_name (abfd, ".reg2");
-  uint64_t xcr0;
-
-  if (section == NULL)
-    return NULL;
-
   /* Linux/i386.  */
-  xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd);
-  if ((xcr0 & I386_XSTATE_AVX_MASK) == I386_XSTATE_AVX_MASK)
-    return tdesc_i386_avx_linux;
-  else
+  uint64_t xcr0 = i386_linux_core_read_xcr0 (gdbarch, target, abfd);
+  switch ((xcr0 & I386_XSTATE_AVX_MASK))
+    {
+    case I386_XSTATE_AVX_MASK:
+      return tdesc_i386_avx_linux;
+    case I386_XSTATE_SSE_MASK:
+      return tdesc_i386_linux;
+    case I386_XSTATE_X87_MASK:
+      return tdesc_i386_mmx_linux;
+    default:
+      break;
+    }
+
+  if (bfd_get_section_by_name (abfd, ".reg-xfp") != NULL)
     return tdesc_i386_linux;
+  else
+    return tdesc_i386_mmx_linux;
 }
 
 static void
@@ -635,6 +655,8 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 
   gdb_assert (tdesc_data);
 
+  linux_init_abi (info, gdbarch);
+
   /* GNU/Linux uses ELF.  */
   i386_elf_init_abi (info, gdbarch);
 
@@ -839,7 +861,7 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   tdep->i386_sysenter_record = i386_linux_intx80_sysenter_record;
 
   /* N_FUN symbols in shared libaries have 0 for their values and need
-     to be relocated. */
+     to be relocated.  */
   set_gdbarch_sofun_address_maybe_missing (gdbarch, 1);
 
   /* GNU/Linux uses SVR4-style shared libraries.  */
@@ -857,14 +879,19 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
                                              svr4_fetch_objfile_link_map);
 
   /* Install supported register note sections.  */
-  set_gdbarch_core_regset_sections (gdbarch, i386_linux_regset_sections);
+  if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.avx"))
+    set_gdbarch_core_regset_sections (gdbarch, i386_linux_avx_regset_sections);
+  else if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.sse"))
+    set_gdbarch_core_regset_sections (gdbarch, i386_linux_sse_regset_sections);
+  else
+    set_gdbarch_core_regset_sections (gdbarch, i386_linux_regset_sections);
 
   set_gdbarch_core_read_description (gdbarch,
                                     i386_linux_core_read_description);
 
   /* Displaced stepping.  */
   set_gdbarch_displaced_step_copy_insn (gdbarch,
-                                        simple_displaced_step_copy_insn);
+                                        i386_displaced_step_copy_insn);
   set_gdbarch_displaced_step_fixup (gdbarch, i386_displaced_step_fixup);
   set_gdbarch_displaced_step_free_closure (gdbarch,
                                            simple_displaced_step_free_closure);
@@ -888,7 +915,8 @@ _initialize_i386_linux_tdep (void)
   gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_LINUX,
                          i386_linux_init_abi);
 
-  /* Initialize the Linux target description  */
+  /* Initialize the Linux target description.  */
   initialize_tdesc_i386_linux ();
+  initialize_tdesc_i386_mmx_linux ();
   initialize_tdesc_i386_avx_linux ();
 }
This page took 0.027825 seconds and 4 git commands to generate.