* gdb.server/ext-run.exp: Relax regexp for init program.
[deliverable/binutils-gdb.git] / gdb / target-descriptions.c
index 2f1b82e4c557b06590e8c61ff523f1515676bbb4..337a0bd0db693777f303273f75e960558f952382 100644 (file)
@@ -1,6 +1,6 @@
 /* Target description support for GDB.
 
-   Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
 
    Contributed by CodeSourcery.
 
@@ -183,7 +183,7 @@ target_find_description (void)
   /* The current architecture should not have any target description
      specified.  It should have been cleared, e.g. when we
      disconnected from the previous target.  */
-  gdb_assert (gdbarch_target_desc (current_gdbarch) == NULL);
+  gdb_assert (gdbarch_target_desc (target_gdbarch) == NULL);
 
   /* First try to fetch an XML description from the user-specified
      file.  */
@@ -216,7 +216,7 @@ target_find_description (void)
        {
          struct tdesc_arch_data *data;
 
-         data = gdbarch_data (current_gdbarch, tdesc_data);
+         data = gdbarch_data (target_gdbarch, tdesc_data);
          if (tdesc_has_registers (current_target_desc)
              && data->registers == NULL)
            warning (_("Target-supplied registers are not supported "
@@ -352,10 +352,12 @@ static struct
     { "int16", &builtin_type_int16 },
     { "int32", &builtin_type_int32 },
     { "int64", &builtin_type_int64 },
+    { "int128", &builtin_type_int128 },
     { "uint8", &builtin_type_uint8 },
     { "uint16", &builtin_type_uint16 },
     { "uint32", &builtin_type_uint32 },
     { "uint64", &builtin_type_uint64 },
+    { "uint128", &builtin_type_uint128 },
     { "ieee_single", &builtin_type_ieee_single },
     { "ieee_double", &builtin_type_ieee_double },
     { "arm_fpa_ext", &builtin_type_arm_ext }
@@ -421,10 +423,9 @@ tdesc_data_cleanup (void *data_untyped)
 
 /* Search FEATURE for a register named NAME.  */
 
-int
-tdesc_numbered_register (const struct tdesc_feature *feature,
-                        struct tdesc_arch_data *data,
-                        int regno, const char *name)
+static struct tdesc_reg *
+tdesc_find_register_early (const struct tdesc_feature *feature,
+                          const char *name)
 {
   int ixr;
   struct tdesc_reg *reg;
@@ -433,18 +434,32 @@ tdesc_numbered_register (const struct tdesc_feature *feature,
        VEC_iterate (tdesc_reg_p, feature->registers, ixr, reg);
        ixr++)
     if (strcasecmp (reg->name, name) == 0)
-      {
-       /* Make sure the vector includes a REGNO'th element.  */
-       while (regno >= VEC_length (tdesc_reg_p, data->registers))
-         VEC_safe_push (tdesc_reg_p, data->registers, NULL);
-       VEC_replace (tdesc_reg_p, data->registers, regno, reg);
-       return 1;
-      }
+      return reg;
 
-  return 0;
+  return NULL;
 }
 
-/* Search FEATURE for a register whose name is in NAMES.  */
+/* Search FEATURE for a register named NAME.  Assign REGNO to it.  */
+
+int
+tdesc_numbered_register (const struct tdesc_feature *feature,
+                        struct tdesc_arch_data *data,
+                        int regno, const char *name)
+{
+  struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
+
+  if (reg == NULL)
+    return 0;
+
+  /* Make sure the vector includes a REGNO'th element.  */
+  while (regno >= VEC_length (tdesc_reg_p, data->registers))
+    VEC_safe_push (tdesc_reg_p, data->registers, NULL);
+  VEC_replace (tdesc_reg_p, data->registers, regno, reg);
+  return 1;
+}
+
+/* Search FEATURE for a register whose name is in NAMES and assign
+   REGNO to it.  */
 
 int
 tdesc_numbered_register_choices (const struct tdesc_feature *feature,
@@ -460,6 +475,19 @@ tdesc_numbered_register_choices (const struct tdesc_feature *feature,
   return 0;
 }
 
+/* Search FEATURE for a register named NAME, and return its size in
+   bits.  The register must exist.  */
+
+int
+tdesc_register_size (const struct tdesc_feature *feature,
+                    const char *name)
+{
+  struct tdesc_reg *reg = tdesc_find_register_early (feature, name);
+
+  gdb_assert (reg != NULL);
+  return reg->bitsize;
+}
+
 /* Look up a register by its GDB internal register number.  */
 
 static struct tdesc_reg *
@@ -479,21 +507,20 @@ tdesc_find_register (struct gdbarch *gdbarch, int regno)
    from an architecture-provided pseudo_register_name method.  */
 
 const char *
-tdesc_register_name (int regno)
+tdesc_register_name (struct gdbarch *gdbarch, int regno)
 {
-  struct tdesc_reg *reg = tdesc_find_register (current_gdbarch, regno);
-  int num_regs = gdbarch_num_regs (current_gdbarch);
-  int num_pseudo_regs = gdbarch_num_pseudo_regs (current_gdbarch);
+  struct tdesc_reg *reg = tdesc_find_register (gdbarch, regno);
+  int num_regs = gdbarch_num_regs (gdbarch);
+  int num_pseudo_regs = gdbarch_num_pseudo_regs (gdbarch);
 
   if (reg != NULL)
     return reg->name;
 
   if (regno >= num_regs && regno < num_regs + num_pseudo_regs)
     {
-      struct tdesc_arch_data *data = gdbarch_data (current_gdbarch,
-                                                  tdesc_data);
+      struct tdesc_arch_data *data = gdbarch_data (gdbarch, tdesc_data);
       gdb_assert (data->pseudo_register_name != NULL);
-      return data->pseudo_register_name (regno);
+      return data->pseudo_register_name (gdbarch, regno);
     }
 
   return "";
@@ -525,32 +552,32 @@ tdesc_register_type (struct gdbarch *gdbarch, int regno)
   if (strcmp (reg->type, "float") == 0)
     {
       if (reg->bitsize == gdbarch_float_bit (gdbarch))
-       return builtin_type_float;
+       return builtin_type (gdbarch)->builtin_float;
       else if (reg->bitsize == gdbarch_double_bit (gdbarch))
-       return builtin_type_double;
+       return builtin_type (gdbarch)->builtin_double;
       else if (reg->bitsize == gdbarch_long_double_bit (gdbarch))
-       return builtin_type_long_double;
+       return builtin_type (gdbarch)->builtin_long_double;
     }
   else if (strcmp (reg->type, "int") == 0)
     {
       if (reg->bitsize == gdbarch_long_bit (gdbarch))
-       return builtin_type_long;
+       return builtin_type (gdbarch)->builtin_long;
       else if (reg->bitsize == TARGET_CHAR_BIT)
-       return builtin_type_char;
+       return builtin_type (gdbarch)->builtin_char;
       else if (reg->bitsize == gdbarch_short_bit (gdbarch))
-       return builtin_type_short;
+       return builtin_type (gdbarch)->builtin_short;
       else if (reg->bitsize == gdbarch_int_bit (gdbarch))
-       return builtin_type_int;
+       return builtin_type (gdbarch)->builtin_int;
       else if (reg->bitsize == gdbarch_long_long_bit (gdbarch))
-       return builtin_type_long_long;
+       return builtin_type (gdbarch)->builtin_long_long;
       else if (reg->bitsize == gdbarch_ptr_bit (gdbarch))
        /* A bit desperate by this point... */
-       return builtin_type_void_data_ptr;
+       return builtin_type (gdbarch)->builtin_data_ptr;
     }
   else if (strcmp (reg->type, "code_ptr") == 0)
-    return builtin_type_void_func_ptr;
+    return builtin_type (gdbarch)->builtin_func_ptr;
   else if (strcmp (reg->type, "data_ptr") == 0)
-    return builtin_type_void_data_ptr;
+    return builtin_type (gdbarch)->builtin_data_ptr;
   else
     internal_error (__FILE__, __LINE__,
                    "Register \"%s\" has an unknown type \"%s\"",
@@ -558,7 +585,7 @@ tdesc_register_type (struct gdbarch *gdbarch, int regno)
 
   warning (_("Register \"%s\" has an unsupported size (%d bits)"),
           reg->name, reg->bitsize);
-  return builtin_type_long;
+  return builtin_type (gdbarch)->builtin_long;
 }
 
 static int
@@ -682,18 +709,16 @@ set_tdesc_pseudo_register_reggroup_p
 
 void
 tdesc_use_registers (struct gdbarch *gdbarch,
+                    const struct target_desc *target_desc,
                     struct tdesc_arch_data *early_data)
 {
   int num_regs = gdbarch_num_regs (gdbarch);
   int i, ixf, ixr;
-  const struct target_desc *target_desc;
   struct tdesc_feature *feature;
   struct tdesc_reg *reg;
   struct tdesc_arch_data *data;
   htab_t reg_hash;
 
-  target_desc = gdbarch_target_desc (gdbarch);
-
   /* We can't use the description for registers if it doesn't describe
      any.  This function should only be called after validating
      registers, so the caller should know that registers are
@@ -988,7 +1013,7 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
     error (_("The current target description did not come from an XML file."));
 
   filename = lbasename (target_description_filename);
-  function = xmalloc (strlen (filename) + 1);
+  function = alloca (strlen (filename) + 1);
   for (inp = filename, outp = function; *inp != '\0'; inp++)
     if (*inp == '.')
       break;
@@ -1071,7 +1096,7 @@ maint_print_c_tdesc_cmd (char *args, int from_tty)
                }
              if (TYPE_VECTOR (type))
                printf_unfiltered
-                 ("  TYPE_FLAGS (type) |= TYPE_FLAG_VECTOR;\n");
+                 ("  TYPE_VECTOR (type) = 1;\n");
              break;
            default:
              error (_("C output is not supported type \"%s\"."), TYPE_NAME (type));
This page took 0.027054 seconds and 4 git commands to generate.