Add tiny memory model GD test cases.
[deliverable/binutils-gdb.git] / gdb / i386-tdep.c
index 88fc31f2a2b99e3dc0df34eb646f3144f51b433a..1c8842c42c1ae1b2eed68ff63c8e2b0f3cf40a95 100644 (file)
@@ -1,6 +1,6 @@
 /* Intel 386 target-dependent stuff.
 
-   Copyright (C) 1988-2014 Free Software Foundation, Inc.
+   Copyright (C) 1988-2015 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -28,6 +28,7 @@
 #include "frame-base.h"
 #include "frame-unwind.h"
 #include "inferior.h"
+#include "infrun.h"
 #include "gdbcmd.h"
 #include "gdbcore.h"
 #include "gdbtypes.h"
 #include "dis-asm.h"
 #include "disasm.h"
 #include "remote.h"
-#include "exceptions.h"
-#include "gdb_assert.h"
-#include <string.h>
-
 #include "i386-tdep.h"
 #include "i387-tdep.h"
-#include "i386-xstate.h"
+#include "x86-xstate.h"
 
 #include "record.h"
 #include "record-full.h"
@@ -1820,14 +1817,15 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
     {
       CORE_ADDR post_prologue_pc
        = skip_prologue_using_sal (gdbarch, func_addr);
-      struct symtab *s = find_pc_symtab (func_addr);
+      struct compunit_symtab *cust = find_pc_compunit_symtab (func_addr);
 
       /* Clang always emits a line note before the prologue and another
         one after.  We trust clang to emit usable line notes.  */
       if (post_prologue_pc
-         && (s != NULL
-             && s->producer != NULL
-             && strncmp (s->producer, "clang ", sizeof ("clang ") - 1) == 0))
+         && (cust != NULL
+             && COMPUNIT_PRODUCER (cust) != NULL
+             && strncmp (COMPUNIT_PRODUCER (cust), "clang ",
+                         sizeof ("clang ") - 1) == 0))
         return max (start_pc, post_prologue_pc);
     }
  
@@ -2186,10 +2184,10 @@ static int
 i386_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
 {
   gdb_byte insn;
-  struct symtab *symtab;
+  struct compunit_symtab *cust;
 
-  symtab = find_pc_symtab (pc);
-  if (symtab && symtab->epilogue_unwind_valid)
+  cust = find_pc_compunit_symtab (pc);
+  if (cust != NULL && COMPUNIT_EPILOGUE_UNWIND_VALID (cust))
     return 0;
 
   if (target_read_memory (pc, &insn, 1))
@@ -3729,7 +3727,7 @@ i386_supply_gregset (const struct regset *regset, struct regcache *regcache,
   const gdb_byte *regs = gregs;
   int i;
 
-  gdb_assert (len == tdep->sizeof_gregset);
+  gdb_assert (len >= tdep->sizeof_gregset);
 
   for (i = 0; i < tdep->gregset_num_regs; i++)
     {
@@ -3754,7 +3752,7 @@ i386_collect_gregset (const struct regset *regset,
   gdb_byte *regs = gregs;
   int i;
 
-  gdb_assert (len == tdep->sizeof_gregset);
+  gdb_assert (len >= tdep->sizeof_gregset);
 
   for (i = 0; i < tdep->gregset_num_regs; i++)
     {
@@ -3781,7 +3779,7 @@ i386_supply_fpregset (const struct regset *regset, struct regcache *regcache,
       return;
     }
 
-  gdb_assert (len == tdep->sizeof_fpregset);
+  gdb_assert (len >= tdep->sizeof_fpregset);
   i387_supply_fsave (regcache, regnum, fpregs);
 }
 
@@ -3804,30 +3802,10 @@ i386_collect_fpregset (const struct regset *regset,
       return;
     }
 
-  gdb_assert (len == tdep->sizeof_fpregset);
+  gdb_assert (len >= tdep->sizeof_fpregset);
   i387_collect_fsave (regcache, regnum, fpregs);
 }
 
-/* Similar to i386_supply_fpregset, but use XSAVE extended state.  */
-
-static void
-i386_supply_xstateregset (const struct regset *regset,
-                         struct regcache *regcache, int regnum,
-                         const void *xstateregs, size_t len)
-{
-  i387_supply_xsave (regcache, regnum, xstateregs);
-}
-
-/* Similar to i386_collect_fpregset , but use XSAVE extended state.  */
-
-static void
-i386_collect_xstateregset (const struct regset *regset,
-                          const struct regcache *regcache,
-                          int regnum, void *xstateregs, size_t len)
-{
-  i387_collect_xsave (regcache, regnum, xstateregs, 1);
-}
-
 /* Register set definitions.  */
 
 const struct regset i386_gregset =
@@ -3835,37 +3813,24 @@ const struct regset i386_gregset =
     NULL, i386_supply_gregset, i386_collect_gregset
   };
 
-static const struct regset i386_fpregset =
+const struct regset i386_fpregset =
   {
     NULL, i386_supply_fpregset, i386_collect_fpregset
   };
 
-static const struct regset i386_xstateregset =
-  {
-    NULL, i386_supply_xstateregset, i386_collect_xstateregset
-  };
-
-/* Return the appropriate register set for the core section identified
-   by SECT_NAME and SECT_SIZE.  */
+/* Default iterator over core file register note sections.  */
 
-const struct regset *
-i386_regset_from_core_section (struct gdbarch *gdbarch,
-                              const char *sect_name, size_t sect_size)
+void
+i386_iterate_over_regset_sections (struct gdbarch *gdbarch,
+                                  iterate_over_regset_sections_cb *cb,
+                                  void *cb_data,
+                                  const struct regcache *regcache)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
-  if (strcmp (sect_name, ".reg") == 0 && sect_size == tdep->sizeof_gregset)
-      return &i386_gregset;
-
-  if ((strcmp (sect_name, ".reg2") == 0 && sect_size == tdep->sizeof_fpregset)
-      || (strcmp (sect_name, ".reg-xfp") == 0
-         && sect_size == I387_SIZEOF_FXSAVE))
-    return &i386_fpregset;
-
-  if (strcmp (sect_name, ".reg-xstate") == 0)
-    return &i386_xstateregset;
-
-  return NULL;
+  cb (".reg", tdep->sizeof_gregset, &i386_gregset, NULL, cb_data);
+  if (tdep->sizeof_fpregset)
+    cb (".reg2", tdep->sizeof_fpregset, tdep->fpregset, NULL, cb_data);
 }
 \f
 
@@ -4341,6 +4306,17 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
 
 \f
 
+/* gdbarch gnu_triplet_regexp method.  Both arches are acceptable as GDB always
+   also supplies -m64 or -m32 by gdbarch_gcc_target_options.  */
+
+static const char *
+i386_gnu_triplet_regexp (struct gdbarch *gdbarch)
+{
+  return "(x86_64|i.86)";
+}
+
+\f
+
 /* Generic ELF.  */
 
 void
@@ -4367,6 +4343,8 @@ i386_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
                                      i386_stap_is_single_operand);
   set_gdbarch_stap_parse_special_token (gdbarch,
                                        i386_stap_parse_special_token);
+
+  set_gdbarch_gnu_triplet_regexp (gdbarch, i386_gnu_triplet_regexp);
 }
 
 /* System V Release 4 (SVR4).  */
@@ -4414,6 +4392,8 @@ i386_go32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_sdb_reg_to_regnum (gdbarch, i386_svr4_reg_to_regnum);
 
   set_gdbarch_has_dos_based_file_system (gdbarch, 1);
+
+  set_gdbarch_gnu_triplet_regexp (gdbarch, i386_gnu_triplet_regexp);
 }
 \f
 
@@ -4480,12 +4460,12 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
   ymm_avx512_regnum_p = i386_ymm_avx512_regnum_p (gdbarch, regnum);
   zmm_regnum_p = i386_zmm_regnum_p (gdbarch, regnum);
 
-  avx512_p = ((tdep->xcr0 & I386_XSTATE_AVX512_MASK)
-              == I386_XSTATE_AVX512_MASK);
-  avx_p = ((tdep->xcr0 & I386_XSTATE_AVX512_MASK)
-           == I386_XSTATE_AVX_MASK) && !avx512_p;
-  sse_p = ((tdep->xcr0 & I386_XSTATE_AVX512_MASK)
-           == I386_XSTATE_SSE_MASK) && !avx512_p && ! avx_p;
+  avx512_p = ((tdep->xcr0 & X86_XSTATE_AVX512_MASK)
+             == X86_XSTATE_AVX512_MASK);
+  avx_p = ((tdep->xcr0 & X86_XSTATE_AVX512_MASK)
+          == X86_XSTATE_AVX_MASK) && !avx512_p;
+  sse_p = ((tdep->xcr0 & X86_XSTATE_AVX512_MASK)
+          == X86_XSTATE_SSE_MASK) && !avx512_p && ! avx_p;
 
   if (group == vector_reggroup)
     return (mmx_regnum_p
@@ -4514,17 +4494,17 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
 
   bnd_regnum_p = i386_bnd_regnum_p (gdbarch, regnum);
   if (group == all_reggroup
-      && ((bnd_regnum_p && (tdep->xcr0 & I386_XSTATE_MPX_MASK))))
+      && ((bnd_regnum_p && (tdep->xcr0 & X86_XSTATE_MPX_MASK))))
     return bnd_regnum_p;
 
   bndr_regnum_p = i386_bndr_regnum_p (gdbarch, regnum);
   if (group == all_reggroup
-      && ((bndr_regnum_p && (tdep->xcr0 & I386_XSTATE_MPX_MASK))))
+      && ((bndr_regnum_p && (tdep->xcr0 & X86_XSTATE_MPX_MASK))))
     return 0;
 
   mpx_ctrl_regnum_p = i386_mpx_ctrl_regnum_p (gdbarch, regnum);
   if (group == all_reggroup
-      && ((mpx_ctrl_regnum_p && (tdep->xcr0 & I386_XSTATE_MPX_MASK))))
+      && ((mpx_ctrl_regnum_p && (tdep->xcr0 & X86_XSTATE_MPX_MASK))))
     return mpx_ctrl_regnum_p;
 
   if (group == general_reggroup)
@@ -4559,18 +4539,6 @@ i386_fetch_pointer_argument (struct frame_info *frame, int argi,
   return read_memory_unsigned_integer (sp + (4 * (argi + 1)), 4, byte_order);
 }
 
-static void
-i386_skip_permanent_breakpoint (struct regcache *regcache)
-{
-  CORE_ADDR current_pc = regcache_read_pc (regcache);
-
- /* On i386, breakpoint is exactly 1 byte long, so we just
-    adjust the PC in the regcache.  */
-  current_pc += 1;
-  regcache_write_pc (regcache, current_pc);
-}
-
-
 #define PREFIX_REPZ    0x01
 #define PREFIX_REPNZ   0x02
 #define PREFIX_LOCK    0x04
@@ -8162,7 +8130,7 @@ i386_validate_tdesc_p (struct gdbarch_tdep *tdep,
       if (!feature_avx)
        return 0;
 
-      tdep->xcr0 = I386_XSTATE_MPX_AVX512_MASK;
+      tdep->xcr0 = X86_XSTATE_MPX_AVX512_MASK;
 
       /* It may have been set by OSABI initialization function.  */
       if (tdep->k0_regnum < 0)
@@ -8205,7 +8173,7 @@ i386_validate_tdesc_p (struct gdbarch_tdep *tdep,
        return 0;
 
       if (!feature_avx512)
-       tdep->xcr0 = I386_XSTATE_AVX_MASK;
+       tdep->xcr0 = X86_XSTATE_AVX_MASK;
 
       /* It may have been set by OSABI initialization function.  */
       if (tdep->num_ymm_regs == 0)
@@ -8221,10 +8189,10 @@ i386_validate_tdesc_p (struct gdbarch_tdep *tdep,
                                            tdep->ymmh_register_names[i]);
     }
   else if (feature_sse)
-    tdep->xcr0 = I386_XSTATE_SSE_MASK;
+    tdep->xcr0 = X86_XSTATE_SSE_MASK;
   else
     {
-      tdep->xcr0 = I386_XSTATE_X87_MASK;
+      tdep->xcr0 = X86_XSTATE_X87_MASK;
       tdep->num_xmm_regs = 0;
     }
 
@@ -8244,7 +8212,7 @@ i386_validate_tdesc_p (struct gdbarch_tdep *tdep,
 
   if (feature_mpx)
     {
-      tdep->xcr0 |= I386_XSTATE_MPX_MASK;
+      tdep->xcr0 |= X86_XSTATE_MPX_MASK;
 
       if (tdep->bnd0r_regnum < 0)
        {
@@ -8293,6 +8261,7 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
 
   /* Floating-point registers.  */
   tdep->sizeof_fpregset = I387_SIZEOF_FSAVE;
+  tdep->fpregset = &i386_fpregset;
 
   /* The default settings include the FPU registers, the MMX registers
      and the SSE registers.  This can be overridden for a specific ABI
@@ -8448,6 +8417,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
      gap for the upper AVX, MPX and AVX512 registers.  */
   set_gdbarch_num_regs (gdbarch, I386_AVX512_NUM_REGS);
 
+  set_gdbarch_gnu_triplet_regexp (gdbarch, i386_gnu_triplet_regexp);
+
   /* Get the x86 target description from INFO.  */
   tdesc = info.target_desc;
   if (! tdesc_has_registers (tdesc))
@@ -8597,12 +8568,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* If we have a register mapping, enable the generic core file
      support, unless it has already been enabled.  */
   if (tdep->gregset_reg_offset
-      && !gdbarch_regset_from_core_section_p (gdbarch))
-    set_gdbarch_regset_from_core_section (gdbarch,
-                                         i386_regset_from_core_section);
-
-  set_gdbarch_skip_permanent_breakpoint (gdbarch,
-                                        i386_skip_permanent_breakpoint);
+      && !gdbarch_iterate_over_regset_sections_p (gdbarch))
+    set_gdbarch_iterate_over_regset_sections
+      (gdbarch, i386_iterate_over_regset_sections);
 
   set_gdbarch_fast_tracepoint_valid_at (gdbarch,
                                        i386_fast_tracepoint_valid_at);
This page took 0.029436 seconds and 4 git commands to generate.