libiberty/md5: fix strict alias warnings
[deliverable/binutils-gdb.git] / gdb / i386-tdep.c
index d18aa9945da16f3d720c97b921833f72f717e649..84e9794ebbc17485f22f42615635682bbe4e624d 100644 (file)
 #include "ax.h"
 #include "ax-gdb.h"
 
+#include "stap-probe.h"
+#include "user-regs.h"
+#include "cli/cli-utils.h"
+#include "expression.h"
+#include "parser-defs.h"
+#include <ctype.h>
+
 /* Register names.  */
 
 static const char *i386_register_names[] =
@@ -1190,7 +1197,6 @@ i386_match_insn_block (CORE_ADDR pc, struct i386_insn *insn_patterns)
 {
   CORE_ADDR current_pc;
   int ix, i;
-  gdb_byte op;
   struct i386_insn *insn;
 
   insn = i386_match_insn (pc, insn_patterns);
@@ -2326,6 +2332,22 @@ i386_16_byte_align_p (struct type *type)
   return 0;
 }
 
+/* Implementation for set_gdbarch_push_dummy_code.  */
+
+static CORE_ADDR
+i386_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr,
+                     struct value **args, int nargs, struct type *value_type,
+                     CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
+                     struct regcache *regcache)
+{
+  /* Use 0xcc breakpoint - 1 byte.  */
+  *bp_addr = sp - 1;
+  *real_pc = funaddr;
+
+  /* Keep the stack aligned.  */
+  return sp - 16;
+}
+
 static CORE_ADDR
 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
                      struct regcache *regcache, CORE_ADDR bp_addr, int nargs,
@@ -2345,7 +2367,6 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   for (write_pass = 0; write_pass < 2; write_pass++)
     {
       int args_space_used = 0;
-      int have_16_byte_aligned_arg = 0;
 
       if (struct_return)
        {
@@ -2383,19 +2404,20 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
          else
            {
              if (i386_16_byte_align_p (value_enclosing_type (args[i])))
-               {
-                 args_space = align_up (args_space, 16);
-                 have_16_byte_aligned_arg = 1;
-               }
+               args_space = align_up (args_space, 16);
              args_space += align_up (len, 4);
            }
        }
 
       if (!write_pass)
        {
-         if (have_16_byte_aligned_arg)
-           args_space = align_up (args_space, 16);
          sp -= args_space;
+
+         /* The original System V ABI only requires word alignment,
+            but modern incarnations need 16-byte alignment in order
+            to support SSE.  Since wasting a few bytes here isn't
+            harmful we unconditionally enforce 16-byte alignment.  */
+         sp &= ~0xf;
        }
     }
 
@@ -2598,7 +2620,7 @@ i386_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
    from WRITEBUF into REGCACHE.  */
 
 static enum return_value_convention
-i386_return_value (struct gdbarch *gdbarch, struct type *func_type,
+i386_return_value (struct gdbarch *gdbarch, struct value *function,
                   struct type *type, struct regcache *regcache,
                   gdb_byte *readbuf, const gdb_byte *writebuf)
 {
@@ -2649,7 +2671,7 @@ i386_return_value (struct gdbarch *gdbarch, struct type *func_type,
   if (code == TYPE_CODE_STRUCT && TYPE_NFIELDS (type) == 1)
     {
       type = check_typedef (TYPE_FIELD_TYPE (type, 0));
-      return i386_return_value (gdbarch, func_type, type, regcache,
+      return i386_return_value (gdbarch, function, type, regcache,
                                readbuf, writebuf);
     }
 
@@ -2774,7 +2796,7 @@ i386_mmx_type (struct gdbarch *gdbarch)
 /* Return the GDB type object for the "standard" data type of data in
    register REGNUM.  */
 
-static struct type *
+struct type *
 i386_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
 {
   if (i386_mmx_regnum_p (gdbarch, regnum))
@@ -3363,6 +3385,323 @@ i386_svr4_sigcontext_addr (struct frame_info *this_frame)
 
   return read_memory_unsigned_integer (sp + 8, 4, byte_order);
 }
+
+\f
+
+/* Implementation of `gdbarch_stap_is_single_operand', as defined in
+   gdbarch.h.  */
+
+int
+i386_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
+{
+  return (*s == '$' /* Literal number.  */
+         || (isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement.  */
+         || (*s == '(' && s[1] == '%') /* Register indirection.  */
+         || (*s == '%' && isalpha (s[1]))); /* Register access.  */
+}
+
+/* Implementation of `gdbarch_stap_parse_special_token', as defined in
+   gdbarch.h.  */
+
+int
+i386_stap_parse_special_token (struct gdbarch *gdbarch,
+                              struct stap_parse_info *p)
+{
+  /* In order to parse special tokens, we use a state-machine that go
+     through every known token and try to get a match.  */
+  enum
+    {
+      TRIPLET,
+      THREE_ARG_DISPLACEMENT,
+      DONE
+    } current_state;
+
+  current_state = TRIPLET;
+
+  /* The special tokens to be parsed here are:
+
+     - `register base + (register index * size) + offset', as represented
+     in `(%rcx,%rax,8)', or `[OFFSET](BASE_REG,INDEX_REG[,SIZE])'.
+
+     - Operands of the form `-8+3+1(%rbp)', which must be interpreted as
+     `*(-8 + 3 - 1 + (void *) $eax)'.  */
+
+  while (current_state != DONE)
+    {
+      const char *s = p->arg;
+
+      switch (current_state)
+       {
+       case TRIPLET:
+           {
+             if (isdigit (*s) || *s == '-' || *s == '+')
+               {
+                 int got_minus[3];
+                 int i;
+                 long displacements[3];
+                 const char *start;
+                 char *regname;
+                 int len;
+                 struct stoken str;
+
+                 got_minus[0] = 0;
+                 if (*s == '+')
+                   ++s;
+                 else if (*s == '-')
+                   {
+                     ++s;
+                     got_minus[0] = 1;
+                   }
+
+                 displacements[0] = strtol (s, (char **) &s, 10);
+
+                 if (*s != '+' && *s != '-')
+                   {
+                     /* We are not dealing with a triplet.  */
+                     break;
+                   }
+
+                 got_minus[1] = 0;
+                 if (*s == '+')
+                   ++s;
+                 else
+                   {
+                     ++s;
+                     got_minus[1] = 1;
+                   }
+
+                 displacements[1] = strtol (s, (char **) &s, 10);
+
+                 if (*s != '+' && *s != '-')
+                   {
+                     /* We are not dealing with a triplet.  */
+                     break;
+                   }
+
+                 got_minus[2] = 0;
+                 if (*s == '+')
+                   ++s;
+                 else
+                   {
+                     ++s;
+                     got_minus[2] = 1;
+                   }
+
+                 displacements[2] = strtol (s, (char **) &s, 10);
+
+                 if (*s != '(' || s[1] != '%')
+                   break;
+
+                 s += 2;
+                 start = s;
+
+                 while (isalnum (*s))
+                   ++s;
+
+                 if (*s++ != ')')
+                   break;
+
+                 len = s - start;
+                 regname = alloca (len + 1);
+
+                 strncpy (regname, start, len);
+                 regname[len] = '\0';
+
+                 if (user_reg_map_name_to_regnum (gdbarch,
+                                                  regname, len) == -1)
+                   error (_("Invalid register name `%s' "
+                            "on expression `%s'."),
+                          regname, p->saved_arg);
+
+                 for (i = 0; i < 3; i++)
+                   {
+                     write_exp_elt_opcode (OP_LONG);
+                     write_exp_elt_type
+                       (builtin_type (gdbarch)->builtin_long);
+                     write_exp_elt_longcst (displacements[i]);
+                     write_exp_elt_opcode (OP_LONG);
+                     if (got_minus[i])
+                       write_exp_elt_opcode (UNOP_NEG);
+                   }
+
+                 write_exp_elt_opcode (OP_REGISTER);
+                 str.ptr = regname;
+                 str.length = len;
+                 write_exp_string (str);
+                 write_exp_elt_opcode (OP_REGISTER);
+
+                 write_exp_elt_opcode (UNOP_CAST);
+                 write_exp_elt_type (builtin_type (gdbarch)->builtin_data_ptr);
+                 write_exp_elt_opcode (UNOP_CAST);
+
+                 write_exp_elt_opcode (BINOP_ADD);
+                 write_exp_elt_opcode (BINOP_ADD);
+                 write_exp_elt_opcode (BINOP_ADD);
+
+                 write_exp_elt_opcode (UNOP_CAST);
+                 write_exp_elt_type (lookup_pointer_type (p->arg_type));
+                 write_exp_elt_opcode (UNOP_CAST);
+
+                 write_exp_elt_opcode (UNOP_IND);
+
+                 p->arg = s;
+
+                 return 1;
+               }
+             break;
+           }
+       case THREE_ARG_DISPLACEMENT:
+           {
+             if (isdigit (*s) || *s == '(' || *s == '-' || *s == '+')
+               {
+                 int offset_minus = 0;
+                 long offset = 0;
+                 int size_minus = 0;
+                 long size = 0;
+                 const char *start;
+                 char *base;
+                 int len_base;
+                 char *index;
+                 int len_index;
+                 struct stoken base_token, index_token;
+
+                 if (*s == '+')
+                   ++s;
+                 else if (*s == '-')
+                   {
+                     ++s;
+                     offset_minus = 1;
+                   }
+
+                 if (offset_minus && !isdigit (*s))
+                   break;
+
+                 if (isdigit (*s))
+                   offset = strtol (s, (char **) &s, 10);
+
+                 if (*s != '(' || s[1] != '%')
+                   break;
+
+                 s += 2;
+                 start = s;
+
+                 while (isalnum (*s))
+                   ++s;
+
+                 if (*s != ',' || s[1] != '%')
+                   break;
+
+                 len_base = s - start;
+                 base = alloca (len_base + 1);
+                 strncpy (base, start, len_base);
+                 base[len_base] = '\0';
+
+                 if (user_reg_map_name_to_regnum (gdbarch,
+                                                  base, len_base) == -1)
+                   error (_("Invalid register name `%s' "
+                            "on expression `%s'."),
+                          base, p->saved_arg);
+
+                 s += 2;
+                 start = s;
+
+                 while (isalnum (*s))
+                   ++s;
+
+                 len_index = s - start;
+                 index = alloca (len_index + 1);
+                 strncpy (index, start, len_index);
+                 index[len_index] = '\0';
+
+                 if (user_reg_map_name_to_regnum (gdbarch,
+                                                  index, len_index) == -1)
+                   error (_("Invalid register name `%s' "
+                            "on expression `%s'."),
+                          index, p->saved_arg);
+
+                 if (*s != ',' && *s != ')')
+                   break;
+
+                 if (*s == ',')
+                   {
+                     ++s;
+                     if (*s == '+')
+                       ++s;
+                     else if (*s == '-')
+                       {
+                         ++s;
+                         size_minus = 1;
+                       }
+
+                     size = strtol (s, (char **) &s, 10);
+
+                     if (*s != ')')
+                       break;
+                   }
+
+                 ++s;
+
+                 if (offset)
+                   {
+                     write_exp_elt_opcode (OP_LONG);
+                     write_exp_elt_type
+                       (builtin_type (gdbarch)->builtin_long);
+                     write_exp_elt_longcst (offset);
+                     write_exp_elt_opcode (OP_LONG);
+                     if (offset_minus)
+                       write_exp_elt_opcode (UNOP_NEG);
+                   }
+
+                 write_exp_elt_opcode (OP_REGISTER);
+                 base_token.ptr = base;
+                 base_token.length = len_base;
+                 write_exp_string (base_token);
+                 write_exp_elt_opcode (OP_REGISTER);
+
+                 if (offset)
+                   write_exp_elt_opcode (BINOP_ADD);
+
+                 write_exp_elt_opcode (OP_REGISTER);
+                 index_token.ptr = index;
+                 index_token.length = len_index;
+                 write_exp_string (index_token);
+                 write_exp_elt_opcode (OP_REGISTER);
+
+                 if (size)
+                   {
+                     write_exp_elt_opcode (OP_LONG);
+                     write_exp_elt_type
+                       (builtin_type (gdbarch)->builtin_long);
+                     write_exp_elt_longcst (size);
+                     write_exp_elt_opcode (OP_LONG);
+                     if (size_minus)
+                       write_exp_elt_opcode (UNOP_NEG);
+                     write_exp_elt_opcode (BINOP_MUL);
+                   }
+
+                 write_exp_elt_opcode (BINOP_ADD);
+
+                 write_exp_elt_opcode (UNOP_CAST);
+                 write_exp_elt_type (lookup_pointer_type (p->arg_type));
+                 write_exp_elt_opcode (UNOP_CAST);
+
+                 write_exp_elt_opcode (UNOP_IND);
+
+                 p->arg = s;
+
+                 return 1;
+               }
+             break;
+           }
+       }
+
+      /* Advancing to the next state.  */
+      ++current_state;
+    }
+
+  return 0;
+}
+
 \f
 
 /* Generic ELF.  */
@@ -3372,6 +3711,16 @@ i386_elf_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
 {
   /* We typically use stabs-in-ELF with the SVR4 register numbering.  */
   set_gdbarch_stab_reg_to_regnum (gdbarch, i386_svr4_reg_to_regnum);
+
+  /* Registering SystemTap handlers.  */
+  set_gdbarch_stap_integer_prefix (gdbarch, "$");
+  set_gdbarch_stap_register_prefix (gdbarch, "%");
+  set_gdbarch_stap_register_indirection_prefix (gdbarch, "(");
+  set_gdbarch_stap_register_indirection_suffix (gdbarch, ")");
+  set_gdbarch_stap_is_single_operand (gdbarch,
+                                     i386_stap_is_single_operand);
+  set_gdbarch_stap_parse_special_token (gdbarch,
+                                       i386_stap_parse_special_token);
 }
 
 /* System V Release 4 (SVR4).  */
@@ -3520,7 +3869,7 @@ i386_fetch_pointer_argument (struct frame_info *frame, int argi,
 {
   struct gdbarch *gdbarch = get_frame_arch (frame);
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  CORE_ADDR sp = get_frame_register_unsigned  (frame, I386_ESP_REGNUM);
+  CORE_ADDR sp = get_frame_register_unsigned (frame, I386_ESP_REGNUM);
   return read_memory_unsigned_integer (sp + (4 * (argi + 1)), 4, byte_order);
 }
 
@@ -3584,22 +3933,17 @@ struct i386_record_s
   const int *regmap;
 };
 
-/* Parse "modrm" part in current memory address that irp->addr point to
-   Return -1 if something wrong.  */
+/* Parse the "modrm" part of the memory address irp->addr points at.
+   Returns -1 if something goes wrong, 0 otherwise.  */
 
 static int
 i386_record_modrm (struct i386_record_s *irp)
 {
   struct gdbarch *gdbarch = irp->gdbarch;
 
-  if (target_read_memory (irp->addr, &irp->modrm, 1))
-    {
-      if (record_debug)
-       printf_unfiltered (_("Process record: error reading memory at "
-                            "addr %s len = 1.\n"),
-                          paddress (gdbarch, irp->addr));
-      return -1;
-    }
+  if (record_read_memory (gdbarch, irp->addr, &irp->modrm, 1))
+    return -1;
+
   irp->addr++;
   irp->mod = (irp->modrm >> 6) & 3;
   irp->reg = (irp->modrm >> 3) & 7;
@@ -3608,9 +3952,8 @@ i386_record_modrm (struct i386_record_s *irp)
   return 0;
 }
 
-/* Get the memory address that current instruction  write to and set it to
-   the argument "addr".
-   Return -1 if something wrong.  */
+/* Extract the memory address that the current instruction writes to,
+   and return it in *ADDR.  Return -1 if something goes wrong.  */
 
 static int
 i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
@@ -3633,14 +3976,8 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
       if (base == 4)
        {
          havesib = 1;
-         if (target_read_memory (irp->addr, &byte, 1))
-           {
-             if (record_debug)
-               printf_unfiltered (_("Process record: error reading memory "
-                                    "at addr %s len = 1.\n"),
-                                  paddress (gdbarch, irp->addr));
-             return -1;
-           }
+         if (record_read_memory (gdbarch, irp->addr, &byte, 1))
+           return -1;
          irp->addr++;
          scale = (byte >> 6) & 3;
          index = ((byte >> 3) & 7) | irp->rex_x;
@@ -3654,14 +3991,8 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
          if ((base & 7) == 5)
            {
              base = 0xff;
-             if (target_read_memory (irp->addr, buf, 4))
-               {
-                 if (record_debug)
-                   printf_unfiltered (_("Process record: error reading "
-                                        "memory at addr %s len = 4.\n"),
-                                      paddress (gdbarch, irp->addr));
-                 return -1;
-               }
+             if (record_read_memory (gdbarch, irp->addr, buf, 4))
+               return -1;
              irp->addr += 4;
              *addr = extract_signed_integer (buf, 4, byte_order);
              if (irp->regmap[X86_RECORD_R8_REGNUM] && !havesib)
@@ -3669,26 +4000,14 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
            }
          break;
        case 1:
-         if (target_read_memory (irp->addr, buf, 1))
-           {
-             if (record_debug)
-               printf_unfiltered (_("Process record: error reading memory "
-                                    "at addr %s len = 1.\n"),
-                                  paddress (gdbarch, irp->addr));
-             return -1;
-           }
+         if (record_read_memory (gdbarch, irp->addr, buf, 1))
+           return -1;
          irp->addr++;
          *addr = (int8_t) buf[0];
          break;
        case 2:
-         if (target_read_memory (irp->addr, buf, 4))
-           {
-             if (record_debug)
-               printf_unfiltered (_("Process record: error reading memory "
-                                    "at addr %s len = 4.\n"),
-                                  paddress (gdbarch, irp->addr));
-             return -1;
-           }
+         if (record_read_memory (gdbarch, irp->addr, buf, 4))
+           return -1;
          *addr = extract_signed_integer (buf, 4, byte_order);
          irp->addr += 4;
          break;
@@ -3727,14 +4046,8 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
        case 0:
          if (irp->rm == 6)
            {
-             if (target_read_memory (irp->addr, buf, 2))
-               {
-                 if (record_debug)
-                   printf_unfiltered (_("Process record: error reading "
-                                        "memory at addr %s len = 2.\n"),
-                                      paddress (gdbarch, irp->addr));
-                 return -1;
-               }
+             if (record_read_memory (gdbarch, irp->addr, buf, 2))
+               return -1;
              irp->addr += 2;
              *addr = extract_signed_integer (buf, 2, byte_order);
              irp->rm = 0;
@@ -3742,26 +4055,14 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
            }
          break;
        case 1:
-         if (target_read_memory (irp->addr, buf, 1))
-           {
-             if (record_debug)
-               printf_unfiltered (_("Process record: error reading memory "
-                                    "at addr %s len = 1.\n"),
-                                  paddress (gdbarch, irp->addr));
-             return -1;
-           }
+         if (record_read_memory (gdbarch, irp->addr, buf, 1))
+           return -1;
          irp->addr++;
          *addr = (int8_t) buf[0];
          break;
        case 2:
-         if (target_read_memory (irp->addr, buf, 2))
-           {
-             if (record_debug)
-               printf_unfiltered (_("Process record: error reading memory "
-                                    "at addr %s len = 2.\n"),
-                                  paddress (gdbarch, irp->addr));
-             return -1;
-           }
+         if (record_read_memory (gdbarch, irp->addr, buf, 2))
+           return -1;
          irp->addr += 2;
          *addr = extract_signed_integer (buf, 2, byte_order);
          break;
@@ -3841,9 +4142,9 @@ i386_record_lea_modrm_addr (struct i386_record_s *irp, uint64_t *addr)
   return 0;
 }
 
-/* Record the value of the memory that willbe changed in current instruction
-   to "record_arch_list".
-   Return -1 if something wrong.  */
+/* Record the address and contents of the memory that will be changed
+   by the current instruction.  Return -1 if something goes wrong, 0
+   otherwise.  */
 
 static int
 i386_record_lea_modrm (struct i386_record_s *irp)
@@ -3880,8 +4181,8 @@ Do you want to stop the program?"),
   return 0;
 }
 
-/* Record the push operation to "record_arch_list".
-   Return -1 if something wrong.  */
+/* Record the effects of a push operation.  Return -1 if something
+   goes wrong, 0 otherwise.  */
 
 static int
 i386_record_push (struct i386_record_s *irp, int size)
@@ -3906,9 +4207,9 @@ i386_record_push (struct i386_record_s *irp, int size)
 #define I386_SAVE_FPU_ENV               0xfffe
 #define I386_SAVE_FPU_ENV_REG_STACK     0xffff
 
-/* Record the value of floating point registers which will be changed
-   by the current instruction to "record_arch_list".  Return -1 if
-   something is wrong.  */
+/* Record the values of the floating point registers which will be
+   changed by the current instruction.  Returns -1 if something is
+   wrong, 0 otherwise.  */
 
 static int i386_record_floats (struct gdbarch *gdbarch,
                                struct i386_record_s *ir,
@@ -3968,9 +4269,9 @@ static int i386_record_floats (struct gdbarch *gdbarch,
   return 0;
 }
 
-/* Parse the current instruction and record the values of the registers and
-   memory that will be changed in current instruction to "record_arch_list".
-   Return -1 if something wrong.  */
+/* Parse the current instruction, and record the values of the
+   registers and memory that will be changed by the current
+   instruction.  Returns -1 if something goes wrong, 0 otherwise.  */
 
 #define I386_RECORD_ARCH_LIST_ADD_REG(regnum) \
     record_arch_list_add_reg (ir.regcache, ir.regmap[(regnum)])
@@ -3983,7 +4284,7 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
   int prefixes = 0;
   int regnum = 0;
   uint32_t opcode;
-  uint8_t  opcode8;
+  uint8_t opcode8;
   ULONGEST addr;
   gdb_byte buf[MAX_REGISTER_SIZE];
   struct i386_record_s ir;
@@ -4011,14 +4312,8 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
   /* prefixes */
   while (1)
     {
-      if (target_read_memory (ir.addr, &opcode8, 1))
-       {
-         if (record_debug)
-           printf_unfiltered (_("Process record: error reading memory at "
-                                "addr %s len = 1.\n"),
-                              paddress (gdbarch, ir.addr));
-         return -1;
-       }
+      if (record_read_memory (gdbarch, ir.addr, &opcode8, 1))
+       return -1;
       ir.addr++;
       switch (opcode8) /* Instruction prefixes */
        {
@@ -4109,14 +4404,8 @@ i386_process_record (struct gdbarch *gdbarch, struct regcache *regcache,
   switch (opcode)
     {
     case 0x0f:
-      if (target_read_memory (ir.addr, &opcode8, 1))
-       {
-         if (record_debug)
-           printf_unfiltered (_("Process record: error reading memory at "
-                                "addr %s len = 1.\n"),
-                              paddress (gdbarch, ir.addr));
-         return -1;
-       }
+      if (record_read_memory (gdbarch, ir.addr, &opcode8, 1))
+       return -1;
       ir.addr++;
       opcode = (uint32_t) opcode8 | 0x0f00;
       goto reswitch;
@@ -4781,40 +5070,22 @@ Do you want to stop the program?"),
            ir.ot = ir.dflag + OT_WORD;
          if (ir.aflag == 2)
            {
-              if (target_read_memory (ir.addr, buf, 8))
-               {
-                 if (record_debug)
-                   printf_unfiltered (_("Process record: error reading "
-                                        "memory at addr 0x%s len = 8.\n"),
-                                      paddress (gdbarch, ir.addr));
-                 return -1;
-               }
+              if (record_read_memory (gdbarch, ir.addr, buf, 8))
+               return -1;
              ir.addr += 8;
              addr = extract_unsigned_integer (buf, 8, byte_order);
            }
           else if (ir.aflag)
            {
-              if (target_read_memory (ir.addr, buf, 4))
-               {
-                 if (record_debug)
-                   printf_unfiltered (_("Process record: error reading "
-                                        "memory at addr 0x%s len = 4.\n"),
-                                      paddress (gdbarch, ir.addr));
-                 return -1;
-               }
+              if (record_read_memory (gdbarch, ir.addr, buf, 4))
+               return -1;
              ir.addr += 4;
               addr = extract_unsigned_integer (buf, 4, byte_order);
            }
           else
            {
-              if (target_read_memory (ir.addr, buf, 2))
-               {
-                 if (record_debug)
-                   printf_unfiltered (_("Process record: error reading "
-                                        "memory at addr 0x%s len = 2.\n"),
-                                      paddress (gdbarch, ir.addr));
-                 return -1;
-               }
+              if (record_read_memory (gdbarch, ir.addr, buf, 2))
+               return -1;
              ir.addr += 2;
               addr = extract_unsigned_integer (buf, 2, byte_order);
            }
@@ -5786,14 +6057,8 @@ Do you want to stop the program?"),
       break;
 
     case 0x9b:    /* fwait */
-      if (target_read_memory (ir.addr, &opcode8, 1))
-        {
-          if (record_debug)
-            printf_unfiltered (_("Process record: error reading memory at "
-                                "addr 0x%s len = 1.\n"),
-                              paddress (gdbarch, ir.addr));
-          return -1;
-        }
+      if (record_read_memory (gdbarch, ir.addr, &opcode8, 1))
+       return -1;
       opcode = (uint32_t) opcode8;
       ir.addr++;
       goto reswitch;
@@ -5812,14 +6077,8 @@ Do you want to stop the program?"),
       {
        int ret;
        uint8_t interrupt;
-       if (target_read_memory (ir.addr, &interrupt, 1))
-         {
-           if (record_debug)
-             printf_unfiltered (_("Process record: error reading memory "
-                                  "at addr %s len = 1.\n"),
-                                paddress (gdbarch, ir.addr));
-           return -1;
-         }
+       if (record_read_memory (gdbarch, ir.addr, &interrupt, 1))
+         return -1;
        ir.addr++;
        if (interrupt != 0x80
            || tdep->i386_intx80_record == NULL)
@@ -6289,13 +6548,8 @@ Do you want to stop the program?"),
     case 0x0f0f:    /* 3DNow! data */
       if (i386_record_modrm (&ir))
        return -1;
-      if (target_read_memory (ir.addr, &opcode8, 1))
-        {
-         printf_unfiltered (_("Process record: error reading memory at "
-                              "addr %s len = 1.\n"),
-                            paddress (gdbarch, ir.addr));
-          return -1;
-        }
+      if (record_read_memory (gdbarch, ir.addr, &opcode8, 1))
+       return -1;
       ir.addr++;
       switch (opcode8)
         {
@@ -6562,13 +6816,8 @@ reswitch_prefix_add:
         case 0xf20f38:
         case 0x0f3a:
         case 0x660f3a:
-          if (target_read_memory (ir.addr, &opcode8, 1))
-            {
-             printf_unfiltered (_("Process record: error reading memory at "
-                                  "addr %s len = 1.\n"),
-                                paddress (gdbarch, ir.addr));
-              return -1;
-            }
+          if (record_read_memory (gdbarch, ir.addr, &opcode8, 1))
+           return -1;
           ir.addr++;
           opcode = (uint32_t) opcode8 | opcode << 8;
           goto reswitch_prefix_add;
@@ -7372,6 +7621,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_get_longjmp_target (gdbarch, i386_get_longjmp_target);
 
   /* Call dummy code.  */
+  set_gdbarch_call_dummy_location (gdbarch, ON_STACK);
+  set_gdbarch_push_dummy_code (gdbarch, i386_push_dummy_code);
   set_gdbarch_push_dummy_call (gdbarch, i386_push_dummy_call);
   set_gdbarch_frame_align (gdbarch, i386_frame_align);
 
@@ -7454,6 +7705,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   tdep->num_mmx_regs = 8;
   tdep->num_ymm_regs = 0;
 
+  tdep->sp_regnum_from_eax = -1;
+  tdep->pc_regnum_from_eax = -1;
+
   tdesc_data = tdesc_data_alloc ();
 
   set_gdbarch_relocate_instruction (gdbarch, i386_relocate_instruction);
@@ -7498,6 +7752,14 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
       /* Support dword pseudo-register if it hasn't been disabled.  */
       tdep->eax_regnum = ymm0_regnum;
       ymm0_regnum += tdep->num_dword_regs;
+      if (tdep->sp_regnum_from_eax != -1)
+       set_gdbarch_sp_regnum (gdbarch,
+                              (tdep->eax_regnum
+                               + tdep->sp_regnum_from_eax));
+      if (tdep->pc_regnum_from_eax != -1)
+       set_gdbarch_pc_regnum (gdbarch,
+                              (tdep->eax_regnum
+                               + tdep->pc_regnum_from_eax));
     }
   else
     tdep->eax_regnum = -1;
This page took 0.034025 seconds and 4 git commands to generate.