Change tui_show_symtab_source to be a method
[external/binutils.git] / gdb / i386-tdep.c
index 54d9dd8..ccec6d1 100644 (file)
@@ -46,7 +46,7 @@
 #include "remote.h"
 #include "i386-tdep.h"
 #include "i387-tdep.h"
-#include "common/x86-xstate.h"
+#include "gdbsupport/x86-xstate.h"
 #include "x86-tdep.h"
 
 #include "record.h"
@@ -64,6 +64,7 @@
 #include "parser-defs.h"
 #include <ctype.h>
 #include <algorithm>
+#include <unordered_set>
 
 /* Register names.  */
 
@@ -4033,10 +4034,10 @@ i386_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
    This function parses operands of the form `-8+3+1(%rbp)', which
    must be interpreted as `*(-8 + 3 - 1 + (void *) $eax)'.
 
-   Return 1 if the operand was parsed successfully, zero
+   Return true if the operand was parsed successfully, false
    otherwise.  */
 
-static int
+static bool
 i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
                                       struct stap_parse_info *p)
 {
@@ -4044,7 +4045,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
 
   if (isdigit (*s) || *s == '-' || *s == '+')
     {
-      int got_minus[3];
+      bool got_minus[3];
       int i;
       long displacements[3];
       const char *start;
@@ -4053,17 +4054,17 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
       struct stoken str;
       char *endp;
 
-      got_minus[0] = 0;
+      got_minus[0] = false;
       if (*s == '+')
        ++s;
       else if (*s == '-')
        {
          ++s;
-         got_minus[0] = 1;
+         got_minus[0] = true;
        }
 
       if (!isdigit ((unsigned char) *s))
-       return 0;
+       return false;
 
       displacements[0] = strtol (s, &endp, 10);
       s = endp;
@@ -4071,20 +4072,20 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
       if (*s != '+' && *s != '-')
        {
          /* We are not dealing with a triplet.  */
-         return 0;
+         return false;
        }
 
-      got_minus[1] = 0;
+      got_minus[1] = false;
       if (*s == '+')
        ++s;
       else
        {
          ++s;
-         got_minus[1] = 1;
+         got_minus[1] = true;
        }
 
       if (!isdigit ((unsigned char) *s))
-       return 0;
+       return false;
 
       displacements[1] = strtol (s, &endp, 10);
       s = endp;
@@ -4092,26 +4093,26 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
       if (*s != '+' && *s != '-')
        {
          /* We are not dealing with a triplet.  */
-         return 0;
+         return false;
        }
 
-      got_minus[2] = 0;
+      got_minus[2] = false;
       if (*s == '+')
        ++s;
       else
        {
          ++s;
-         got_minus[2] = 1;
+         got_minus[2] = true;
        }
 
       if (!isdigit ((unsigned char) *s))
-       return 0;
+       return false;
 
       displacements[2] = strtol (s, &endp, 10);
       s = endp;
 
       if (*s != '(' || s[1] != '%')
-       return 0;
+       return false;
 
       s += 2;
       start = s;
@@ -4120,7 +4121,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
        ++s;
 
       if (*s++ != ')')
-       return 0;
+       return false;
 
       len = s - start - 1;
       regname = (char *) alloca (len + 1);
@@ -4167,10 +4168,10 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
 
       p->arg = s;
 
-      return 1;
+      return true;
     }
 
-  return 0;
+  return false;
 }
 
 /* Helper function for i386_stap_parse_special_token.
@@ -4179,10 +4180,10 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch,
    (register index * size) + offset', as represented in
    `(%rcx,%rax,8)', or `[OFFSET](BASE_REG,INDEX_REG[,SIZE])'.
 
-   Return 1 if the operand was parsed successfully, zero
+   Return true if the operand was parsed successfully, false
    otherwise.  */
 
-static int
+static bool
 i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
                                              struct stap_parse_info *p)
 {
@@ -4190,9 +4191,9 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
 
   if (isdigit (*s) || *s == '(' || *s == '-' || *s == '+')
     {
-      int offset_minus = 0;
+      bool offset_minus = false;
       long offset = 0;
-      int size_minus = 0;
+      bool size_minus = false;
       long size = 0;
       const char *start;
       char *base;
@@ -4206,11 +4207,11 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
       else if (*s == '-')
        {
          ++s;
-         offset_minus = 1;
+         offset_minus = true;
        }
 
       if (offset_minus && !isdigit (*s))
-       return 0;
+       return false;
 
       if (isdigit (*s))
        {
@@ -4221,7 +4222,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
        }
 
       if (*s != '(' || s[1] != '%')
-       return 0;
+       return false;
 
       s += 2;
       start = s;
@@ -4230,7 +4231,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
        ++s;
 
       if (*s != ',' || s[1] != '%')
-       return 0;
+       return false;
 
       len_base = s - start;
       base = (char *) alloca (len_base + 1);
@@ -4257,7 +4258,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
               index, p->saved_arg);
 
       if (*s != ',' && *s != ')')
-       return 0;
+       return false;
 
       if (*s == ',')
        {
@@ -4269,14 +4270,14 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
          else if (*s == '-')
            {
              ++s;
-             size_minus = 1;
+             size_minus = true;
            }
 
          size = strtol (s, &endp, 10);
          s = endp;
 
          if (*s != ')')
-           return 0;
+           return false;
        }
 
       ++s;
@@ -4330,10 +4331,10 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch,
 
       p->arg = s;
 
-      return 1;
+      return true;
     }
 
-  return 0;
+  return false;
 }
 
 /* Implementation of `gdbarch_stap_parse_special_token', as defined in
@@ -4385,6 +4386,29 @@ i386_stap_parse_special_token (struct gdbarch *gdbarch,
   return 0;
 }
 
+/* Implementation of 'gdbarch_stap_adjust_register', as defined in
+   gdbarch.h.  */
+
+static std::string
+i386_stap_adjust_register (struct gdbarch *gdbarch, struct stap_parse_info *p,
+                          const std::string &regname, int regnum)
+{
+  static const std::unordered_set<std::string> reg_assoc
+    = { "ax", "bx", "cx", "dx",
+       "si", "di", "bp", "sp" };
+
+  /* If we are dealing with a register whose size is less than the size
+     specified by the "[-]N@" prefix, and it is one of the registers that
+     we know has an extended variant available, then use the extended
+     version of the register instead.  */
+  if (register_size (gdbarch, regnum) < TYPE_LENGTH (p->arg_type)
+      && reg_assoc.find (regname) != reg_assoc.end ())
+    return "e" + regname;
+
+  /* Otherwise, just use the requested register.  */
+  return regname;
+}
+
 \f
 
 /* gdbarch gnu_triplet_regexp method.  Both arches are acceptable as GDB always
@@ -4433,6 +4457,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_stap_adjust_register (gdbarch,
+                                   i386_stap_adjust_register);
 
   set_gdbarch_in_indirect_branch_thunk (gdbarch,
                                        i386_in_indirect_branch_thunk);
@@ -8158,7 +8184,9 @@ i386_floatformat_for_type (struct gdbarch *gdbarch,
   if (len == 128 && name)
     if (strcmp (name, "__float128") == 0
        || strcmp (name, "_Float128") == 0
-       || strcmp (name, "complex _Float128") == 0)
+       || strcmp (name, "complex _Float128") == 0
+       || strcmp (name, "complex(kind=16)") == 0
+       || strcmp (name, "real(kind=16)") == 0)
       return floatformats_ia64_quad;
 
   return default_floatformat_for_type (gdbarch, name, len);
@@ -8883,7 +8911,7 @@ i386_mpx_print_bounds (const CORE_ADDR bt_entry[4])
 
       size = (size > -1 ? size + 1 : size);
       uiout->text (", size = ");
-      uiout->field_fmt ("size", "%s", plongest (size));
+      uiout->field_string ("size", plongest (size));
 
       uiout->text (", metadata = ");
       uiout->field_core_addr ("metadata", gdbarch, bt_entry[3]);
@@ -9067,28 +9095,4 @@ Show Intel Memory Protection Extensions specific variables."),
 
   /* Tell remote stub that we support XML target description.  */
   register_remote_support_xml ("i386");
-
-#if GDB_SELF_TEST
-  struct
-  {
-    const char *xml;
-    uint64_t mask;
-  } xml_masks[] = {
-    { "i386/i386.xml", X86_XSTATE_SSE_MASK },
-    { "i386/i386-mmx.xml", X86_XSTATE_X87_MASK },
-    { "i386/i386-avx.xml", X86_XSTATE_AVX_MASK },
-    { "i386/i386-mpx.xml", X86_XSTATE_MPX_MASK },
-    { "i386/i386-avx-mpx.xml", X86_XSTATE_AVX_MPX_MASK },
-    { "i386/i386-avx-avx512.xml", X86_XSTATE_AVX_AVX512_MASK },
-    { "i386/i386-avx-mpx-avx512-pku.xml",
-      X86_XSTATE_AVX_MPX_AVX512_PKU_MASK },
-  };
-
-  for (auto &a : xml_masks)
-    {
-      auto tdesc = i386_target_description (a.mask, false);
-
-      selftests::record_xml_tdesc (a.xml, tdesc);
-    }
-#endif /* GDB_SELF_TEST */
 }