Minor formatting changes:
[deliverable/binutils-gdb.git] / gdb / ada-lang.c
index 34f229297670ee62c85cc473224ca2f082a9ff5c..9eee22c44acec4e0ab71ce64b300b20cc533cdb1 100644 (file)
@@ -574,8 +574,8 @@ coerce_unspec_val_to_type (struct value *val, struct type *type)
       VALUE_BITSIZE (result) = VALUE_BITSIZE (val);
       VALUE_BITPOS (result) = VALUE_BITPOS (val);
       VALUE_ADDRESS (result) = VALUE_ADDRESS (val) + VALUE_OFFSET (val);
-      if (VALUE_LAZY (val) ||
-          TYPE_LENGTH (type) > TYPE_LENGTH (VALUE_TYPE (val)))
+      if (VALUE_LAZY (val)
+          || TYPE_LENGTH (type) > TYPE_LENGTH (VALUE_TYPE (val)))
         VALUE_LAZY (result) = 1;
       else
         memcpy (VALUE_CONTENTS_RAW (result), VALUE_CONTENTS (val),
@@ -623,30 +623,51 @@ ada_translate_error_message (const char *string)
     return string;
 }
 
+/* Note: would have used MAX_OF_TYPE and MIN_OF_TYPE macros from
+   gdbtypes.h, but some of the necessary definitions in that file
+   seem to have gone missing. */
+
+/* Maximum value of a SIZE-byte signed integer type. */
 static LONGEST
-MAX_OF_SIZE (int size)
+max_of_size (int size)
 {
   LONGEST top_bit = (LONGEST) 1 << (size * 8 - 2);
   return top_bit | (top_bit - 1);
 }
 
+/* Minimum value of a SIZE-byte signed integer type. */
 static LONGEST
-MIN_OF_SIZE (int size)
+min_of_size (int size)
 {
-  return -MAX_OF_SIZE (size) - 1;
+  return -max_of_size (size) - 1;
 }
 
+/* Maximum value of a SIZE-byte unsigned integer type. */
 static ULONGEST
-UMAX_OF_SIZE (int size)
+umax_of_size (int size)
 {
   ULONGEST top_bit = (ULONGEST) 1 << (size * 8 - 1);
   return top_bit | (top_bit - 1);
 }
 
-static ULONGEST
-UMIN_OF_SIZE (int size)
+/* Maximum value of integral type T, as a signed quantity. */
+static LONGEST
+max_of_type (struct type *t)
 {
-  return 0;
+  if (TYPE_UNSIGNED (t))
+    return (LONGEST) umax_of_size (TYPE_LENGTH (t));
+  else
+    return max_of_size (TYPE_LENGTH (t));
+}
+
+/* Minimum value of integral type T, as a signed quantity. */
+static LONGEST
+min_of_type (struct type *t)
+{
+  if (TYPE_UNSIGNED (t)) 
+    return 0;
+  else
+    return min_of_size (TYPE_LENGTH (t));
 }
 
 /* The largest value in the domain of TYPE, a discrete type, as an integer.  */
@@ -664,7 +685,7 @@ discrete_type_high_bound (struct type *type)
                             TYPE_FIELD_BITPOS (type,
                                                TYPE_NFIELDS (type) - 1));
     case TYPE_CODE_INT:
-      return value_from_longest (type, MAX_OF_TYPE (type));
+      return value_from_longest (type, max_of_type (type));
     default:
       error ("Unexpected type in discrete_type_high_bound.");
     }
@@ -682,7 +703,7 @@ discrete_type_low_bound (struct type *type)
     case TYPE_CODE_ENUM:
       return value_from_longest (type, TYPE_FIELD_BITPOS (type, 0));
     case TYPE_CODE_INT:
-      return value_from_longest (type, MIN_OF_TYPE (type));
+      return value_from_longest (type, min_of_type (type));
     default:
       error ("Unexpected type in discrete_type_low_bound.");
     }
@@ -732,6 +753,7 @@ ada_main_name (void)
   struct minimal_symbol *msym;
   CORE_ADDR main_program_name_addr;
   static char main_program_name[1024];
+
   /* For Ada, the name of the main procedure is stored in a specific
      string constant, generated by the binder.  Look for that symbol,
      extract its address, and then read that string.  If we didn't find
@@ -849,9 +871,9 @@ ada_encode (const char *decoded)
           const struct ada_opname_map *mapping;
 
           for (mapping = ada_opname_table;
-               mapping->encoded != NULL &&
-               strncmp (mapping->decoded, p,
-                        strlen (mapping->decoded)) != 0; mapping += 1)
+               mapping->encoded != NULL
+               && strncmp (mapping->decoded, p,
+                           strlen (mapping->decoded)) != 0; mapping += 1)
             ;
           if (mapping->encoded == NULL)
             error ("invalid Ada operator name: %s", p);
@@ -993,8 +1015,9 @@ ada_decode (const char *encoded)
           for (k = 0; ada_opname_table[k].encoded != NULL; k += 1)
             {
               int op_len = strlen (ada_opname_table[k].encoded);
-              if (strncmp (ada_opname_table[k].encoded + 1, encoded + i + 1,
-                           op_len - 1) == 0 && !isalnum (encoded[i + op_len]))
+              if ((strncmp (ada_opname_table[k].encoded + 1, encoded + i + 1,
+                            op_len - 1) == 0)
+                  && !isalnum (encoded[i + op_len]))
                 {
                   strcpy (decoded + j, ada_opname_table[k].decoded);
                   at_start_name = 0;
@@ -1193,9 +1216,9 @@ desc_base_type (struct type *type)
   if (type == NULL)
     return NULL;
   CHECK_TYPEDEF (type);
-  if (type != NULL &&
-      (TYPE_CODE (type) == TYPE_CODE_PTR
-       || TYPE_CODE (type) == TYPE_CODE_REF))
+  if (type != NULL
+      && (TYPE_CODE (type) == TYPE_CODE_PTR
+          || TYPE_CODE (type) == TYPE_CODE_REF))
     return check_typedef (TYPE_TARGET_TYPE (type));
   else
     return type;
@@ -1509,8 +1532,7 @@ ada_is_array_descriptor_type (struct type *type)
     && ((TYPE_CODE (data_type) == TYPE_CODE_PTR
          && TYPE_TARGET_TYPE (data_type) != NULL
          && TYPE_CODE (TYPE_TARGET_TYPE (data_type)) == TYPE_CODE_ARRAY)
-        ||
-        TYPE_CODE (data_type) == TYPE_CODE_ARRAY)
+        || TYPE_CODE (data_type) == TYPE_CODE_ARRAY)
     && desc_arity (desc_bounds_type (type)) > 0;
 }
 
@@ -1918,8 +1940,8 @@ ada_value_primitive_packed_val (struct value *obj, char *valaddr, long offset,
   else if (BITS_BIG_ENDIAN)
     {
       src = len - 1;
-      if (has_negatives (type) &&
-          ((bytes[0] << bit_offset) & (1 << (HOST_CHAR_BIT - 1))))
+      if (has_negatives (type)
+          && ((bytes[0] << bit_offset) & (1 << (HOST_CHAR_BIT - 1))))
         sign = ~0;
 
       unusedLS =
@@ -2170,6 +2192,37 @@ ada_value_ptr_subscript (struct value *arr, struct type *type, int arity,
   return value_ind (arr);
 }
 
+/* Given that ARRAY_PTR is a pointer or reference to an array of type TYPE (the
+   actual type of ARRAY_PTR is ignored), returns a reference to
+   the Ada slice of HIGH-LOW+1 elements starting at index LOW.  The lower
+   bound of this array is LOW, as per Ada rules. */
+static struct value *
+ada_value_slice_ptr (struct value *array_ptr, struct type *type,
+                     int low, int high)
+{
+  CORE_ADDR base = value_as_address (array_ptr)
+    + ((low - TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)))
+       * TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
+  struct type *index_type =
+    create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type)),
+                       low, high);
+  struct type *slice_type =
+    create_array_type (NULL, TYPE_TARGET_TYPE (type), index_type);
+  return value_from_pointer (lookup_reference_type (slice_type), base);
+}
+
+
+static struct value *
+ada_value_slice (struct value *array, int low, int high)
+{
+  struct type *type = VALUE_TYPE (array);
+  struct type *index_type =
+    create_range_type (NULL, TYPE_INDEX_TYPE (type), low, high);
+  struct type *slice_type =
+    create_array_type (NULL, TYPE_TARGET_TYPE (type), index_type);
+  return value_cast (slice_type, value_slice (array, low, high - low + 1));
+}
+
 /* If type is a record type in the form of a standard GNAT array
    descriptor, returns the number of dimensions for type.  If arr is a
    simple array, returns the number of "array of"s that prefix its
@@ -2400,8 +2453,11 @@ ada_array_length (struct value *arr, int n)
 static struct value *
 empty_array (struct type *arr_type, int low)
 {
-  return allocate_value (create_range_type (NULL, TYPE_INDEX_TYPE (arr_type),
-                                            low, low - 1));
+  struct type *index_type =
+    create_range_type (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (arr_type)),
+                       low, low - 1);
+  struct type *elt_type = ada_array_element_type (arr_type, 1);
+  return allocate_value (create_array_type (NULL, elt_type, index_type));
 }
 \f
 
@@ -2596,9 +2652,9 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
       break;
 
     case OP_STRING:
-      (*pos) += 3
-        + BYTES_TO_EXP_ELEM (longest_to_int (exp->elts[pc + 1].longconst) +
-                             1);
+      (*pos) += 3 
+        + BYTES_TO_EXP_ELEM (longest_to_int (exp->elts[pc + 1].longconst) 
+                             1);
       break;
 
     case TERNOP_SLICE:
@@ -2689,11 +2745,10 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
           else if (deprocedure_p
                    && !is_nonfunction (candidates, n_candidates))
             {
-              i = ada_resolve_function (candidates, n_candidates, NULL, 0,
-                                        SYMBOL_LINKAGE_NAME (exp->
-                                                             elts[pc +
-                                                                  2].symbol),
-                                        context_type);
+              i = ada_resolve_function
+                (candidates, n_candidates, NULL, 0,
+                 SYMBOL_LINKAGE_NAME (exp->elts[pc + 2].symbol),
+                 context_type);
               if (i < 0)
                 error ("Could not find a match for %s",
                        SYMBOL_PRINT_NAME (exp->elts[pc + 2].symbol));
@@ -2708,8 +2763,8 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
 
           exp->elts[pc + 1].block = candidates[i].block;
           exp->elts[pc + 2].symbol = candidates[i].sym;
-          if (innermost_block == NULL ||
-              contained_in (candidates[i].block, innermost_block))
+          if (innermost_block == NULL
+              || contained_in (candidates[i].block, innermost_block))
             innermost_block = candidates[i].block;
         }
 
@@ -2741,13 +2796,11 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
               i = 0;
             else
               {
-                i = ada_resolve_function (candidates, n_candidates,
-                                          argvec, nargs,
-                                          SYMBOL_LINKAGE_NAME (exp->
-                                                               elts[pc +
-                                                                    5].
-                                                               symbol),
-                                          context_type);
+                i = ada_resolve_function
+                  (candidates, n_candidates,
+                   argvec, nargs,
+                   SYMBOL_LINKAGE_NAME (exp->elts[pc + 5].symbol),
+                   context_type);
                 if (i < 0)
                   error ("Could not find a match for %s",
                          SYMBOL_PRINT_NAME (exp->elts[pc + 5].symbol));
@@ -2755,8 +2808,8 @@ resolve_subexp (struct expression **expp, int *pos, int deprocedure_p,
 
             exp->elts[pc + 4].block = candidates[i].block;
             exp->elts[pc + 5].symbol = candidates[i].sym;
-            if (innermost_block == NULL ||
-                contained_in (candidates[i].block, innermost_block))
+            if (innermost_block == NULL
+                || contained_in (candidates[i].block, innermost_block))
               innermost_block = candidates[i].block;
           }
       }
@@ -2841,8 +2894,8 @@ ada_type_match (struct type *ftype, struct type *atype, int may_deref)
         return ada_type_match (TYPE_TARGET_TYPE (ftype),
                                TYPE_TARGET_TYPE (atype), 0);
       else
-        return (may_deref &&
-                ada_type_match (TYPE_TARGET_TYPE (ftype), atype, 0));
+        return (may_deref
+                && ada_type_match (TYPE_TARGET_TYPE (ftype), atype, 0));
     case TYPE_CODE_INT:
     case TYPE_CODE_ENUM:
     case TYPE_CODE_RANGE:
@@ -2885,8 +2938,8 @@ ada_args_match (struct symbol *func, struct value **actuals, int n_actuals)
   int i;
   struct type *func_type = SYMBOL_TYPE (func);
 
-  if (SYMBOL_CLASS (func) == LOC_CONST &&
-      TYPE_CODE (func_type) == TYPE_CODE_ENUM)
+  if (SYMBOL_CLASS (func) == LOC_CONST
+      && TYPE_CODE (func_type) == TYPE_CODE_ENUM)
     return (n_actuals == 0);
   else if (func_type == NULL || TYPE_CODE (func_type) != TYPE_CODE_FUNC)
     return 0;
@@ -3098,9 +3151,9 @@ user_select_syms (struct ada_symbol_info *syms, int nsyms, int max_results)
             find_function_start_sal (syms[i].sym, 1);
           printf_unfiltered ("[%d] %s at %s:%d\n", i + first_choice,
                              SYMBOL_PRINT_NAME (syms[i].sym),
-                             sal.symtab ==
-                             NULL ? "<no source file available>" : sal.
-                             symtab->filename, sal.line);
+                             (sal.symtab == NULL
+                              ? "<no source file available>"
+                              : sal.symtab->filename), sal.line);
           continue;
         }
       else
@@ -3407,13 +3460,14 @@ possible_user_operator_p (enum exp_opcode op, struct value *args[])
       return (!(scalar_type_p (type0) && scalar_type_p (type1)));
 
     case BINOP_CONCAT:
-      return ((TYPE_CODE (type0) != TYPE_CODE_ARRAY &&
-               (TYPE_CODE (type0) != TYPE_CODE_PTR ||
-                TYPE_CODE (TYPE_TARGET_TYPE (type0))
-                != TYPE_CODE_ARRAY))
-              || (TYPE_CODE (type1) != TYPE_CODE_ARRAY &&
-                  (TYPE_CODE (type1) != TYPE_CODE_PTR ||
-                   TYPE_CODE (TYPE_TARGET_TYPE (type1)) != TYPE_CODE_ARRAY)));
+      return
+        ((TYPE_CODE (type0) != TYPE_CODE_ARRAY
+          && (TYPE_CODE (type0) != TYPE_CODE_PTR
+              || TYPE_CODE (TYPE_TARGET_TYPE (type0)) != TYPE_CODE_ARRAY))
+         || (TYPE_CODE (type1) != TYPE_CODE_ARRAY
+             && (TYPE_CODE (type1) != TYPE_CODE_PTR
+                 || (TYPE_CODE (TYPE_TARGET_TYPE (type1)) 
+                    != TYPE_CODE_ARRAY))));
 
     case BINOP_EXP:
       return (!(numeric_type_p (type0) && integer_type_p (type1)));
@@ -3503,24 +3557,36 @@ ada_simple_renamed_entity (struct symbol *sym)
 static struct value *
 ensure_lval (struct value *val, CORE_ADDR *sp)
 {
-  CORE_ADDR old_sp = *sp;
-
-  if (VALUE_LVAL (val))
-    return val;
-
-  if (DEPRECATED_STACK_ALIGN_P ())
-    *sp = push_bytes (*sp, VALUE_CONTENTS_RAW (val),
-                      DEPRECATED_STACK_ALIGN
-                      (TYPE_LENGTH (check_typedef (VALUE_TYPE (val)))));
-  else
-    *sp = push_bytes (*sp, VALUE_CONTENTS_RAW (val),
-                      TYPE_LENGTH (check_typedef (VALUE_TYPE (val))));
+  if (! VALUE_LVAL (val))
+    {
+      int len = TYPE_LENGTH (check_typedef (VALUE_TYPE (val)));
+
+      /* The following is taken from the structure-return code in
+        call_function_by_hand. FIXME: Therefore, some refactoring seems 
+        indicated. */
+      if (INNER_THAN (1, 2))
+       {
+         /* Stack grows downward.  Align SP and VALUE_ADDRESS (val) after
+            reserving sufficient space. */
+         *sp -= len;
+         if (gdbarch_frame_align_p (current_gdbarch))
+           *sp = gdbarch_frame_align (current_gdbarch, *sp);
+         VALUE_ADDRESS (val) = *sp;
+       }
+      else
+       {
+         /* Stack grows upward.  Align the frame, allocate space, and
+            then again, re-align the frame. */
+         if (gdbarch_frame_align_p (current_gdbarch))
+           *sp = gdbarch_frame_align (current_gdbarch, *sp);
+         VALUE_ADDRESS (val) = *sp;
+         *sp += len;
+         if (gdbarch_frame_align_p (current_gdbarch))
+           *sp = gdbarch_frame_align (current_gdbarch, *sp);
+       }
 
-  VALUE_LVAL (val) = lval_memory;
-  if (INNER_THAN (1, 2))
-    VALUE_ADDRESS (val) = *sp;
-  else
-    VALUE_ADDRESS (val) = old_sp;
+      write_memory (VALUE_ADDRESS (val), VALUE_CONTENTS_RAW (val), len);
+    }
 
   return val;
 }
@@ -3942,8 +4008,8 @@ ada_lookup_partial_symbol (struct partial_symtab *pst, const char *name,
         {
           struct partial_symbol *psym = start[i];
 
-          if (SYMBOL_DOMAIN (psym) == namespace &&
-              wild_match (name, name_len, SYMBOL_LINKAGE_NAME (psym)))
+          if (SYMBOL_DOMAIN (psym) == namespace
+              && wild_match (name, name_len, SYMBOL_LINKAGE_NAME (psym)))
             return psym;
         }
       return NULL;
@@ -4371,8 +4437,7 @@ is_package_name (const char *name)
   if (strstr (name, "__") != NULL)
     return 0;
 
-  fun_name = (char *) alloca (strlen (name) + 5 + 1);
-  xasprintf (&fun_name, "_ada_%s", name);
+  fun_name = xstrprintf ("_ada_%s", name);
 
   return (standard_lookup (fun_name, NULL, VAR_DOMAIN) == NULL);
 }
@@ -4758,7 +4823,8 @@ ada_lookup_symbol_nonlocal (const char *name,
    names (e.g., XVE) are not included here.  Currently, the possible suffixes
    are given by either of the regular expression:
 
-   (__[0-9]+)?\.[0-9]+  [nested subprogram suffix, on platforms such as Linux]
+   (__[0-9]+)?\.[0-9]+  [nested subprogram suffix, on platforms such 
+                         as GNU/Linux]
    ___[0-9]+            [nested subprogram suffix, on platforms such as HP/UX]
    (X[nb]*)?((\$|__)[0-9](_?[0-9]+)|___(LJM|X([FDBUP].*|R[^T]?)))?$
  */
@@ -4827,8 +4893,8 @@ is_name_suffix (const char *str)
             return 1;
           if (str[3] != 'X')
             return 0;
-          if (str[4] == 'F' || str[4] == 'D' || str[4] == 'B' ||
-              str[4] == 'U' || str[4] == 'P')
+          if (str[4] == 'F' || str[4] == 'D' || str[4] == 'B'
+              || str[4] == 'U' || str[4] == 'P')
             return 1;
           if (str[4] == 'R' && str[5] != 'T')
             return 1;
@@ -4996,8 +5062,8 @@ ada_add_block_symbols (struct obstack *obstackp,
       struct symbol *sym;
       ALL_BLOCK_SYMBOLS (block, iter, sym)
       {
-        if (SYMBOL_DOMAIN (sym) == domain &&
-            wild_match (name, name_len, SYMBOL_LINKAGE_NAME (sym)))
+        if (SYMBOL_DOMAIN (sym) == domain
+            && wild_match (name, name_len, SYMBOL_LINKAGE_NAME (sym)))
           {
             switch (SYMBOL_CLASS (sym))
               {
@@ -5507,8 +5573,8 @@ ada_finish_decode_line_1 (char **spec, struct symtab *file_table,
     {
       if (is_quoted)
         *spec = skip_quoted (*spec);
-      while (**spec != '\000' &&
-             !strchr (ada_completer_word_break_characters, **spec))
+      while (**spec != '\000'
+             && !strchr (ada_completer_word_break_characters, **spec))
         *spec += 1;
     }
   len = *spec - name;
@@ -5588,7 +5654,9 @@ ada_finish_decode_line_1 (char **spec, struct symtab *file_table,
           val.section = SYMBOL_BFD_SECTION (msymbol);
           if (funfirstline)
             {
-              val.pc += DEPRECATED_FUNCTION_START_OFFSET;
+              val.pc = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
+                                                          val.pc,
+                                                          &current_target);
               SKIP_PROLOGUE (val.pc);
             }
           selected.sals = (struct symtab_and_line *)
@@ -5598,8 +5666,8 @@ ada_finish_decode_line_1 (char **spec, struct symtab *file_table,
           return selected;
         }
 
-      if (!have_full_symbols () &&
-          !have_partial_symbols () && !have_minimal_symbols ())
+      if (!have_full_symbols ()
+          && !have_partial_symbols () && !have_minimal_symbols ())
         error ("No symbol table is loaded.  Use the \"file\" command.");
 
       error ("Function \"%s\" not defined.", unquoted_name);
@@ -6112,6 +6180,20 @@ extended_canonical_line_spec (struct symtab_and_line sal, const char *name)
   return r;
 }
 
+\f
+                               /* Exception-related */
+
+int
+ada_is_exception_sym (struct symbol *sym)
+{
+  char *type_name = type_name_no_tag (SYMBOL_TYPE (sym));
+
+  return (SYMBOL_CLASS (sym) != LOC_TYPEDEF
+          && SYMBOL_CLASS (sym) != LOC_BLOCK
+          && SYMBOL_CLASS (sym) != LOC_CONST
+          && type_name != NULL && strcmp (type_name, "exception") == 0);
+}
+
 /* Return type of Ada breakpoint associated with bp_stat:
    0 if not an Ada-specific breakpoint, 1 for break on specific exception,
    2 for break on unhandled exception, 3 for assert.  */
@@ -6363,25 +6445,6 @@ ada_print_exception_breakpoint_task (struct breakpoint *b)
     }
 }
 
-int
-ada_is_exception_sym (struct symbol *sym)
-{
-  char *type_name = type_name_no_tag (SYMBOL_TYPE (sym));
-
-  return (SYMBOL_CLASS (sym) != LOC_TYPEDEF
-          && SYMBOL_CLASS (sym) != LOC_BLOCK
-          && SYMBOL_CLASS (sym) != LOC_CONST
-          && type_name != NULL && strcmp (type_name, "exception") == 0);
-}
-
-int
-ada_maybe_exception_partial_symbol (struct partial_symbol *sym)
-{
-  return (SYMBOL_CLASS (sym) != LOC_TYPEDEF
-          && SYMBOL_CLASS (sym) != LOC_BLOCK
-          && SYMBOL_CLASS (sym) != LOC_CONST);
-}
-
 /* Cause the appropriate error if no appropriate runtime symbol is
    found to set a breakpoint, using ERR_DESC to describe the
    breakpoint.  */
@@ -6506,7 +6569,7 @@ ada_breakpoint_rewrite (char *arg, int *break_on_exceptionp)
     }
   return arg;
 }
-#endif
+#endif /* GNAT_GDB */
 \f
                                 /* Field Access */
 
@@ -6703,8 +6766,8 @@ ada_is_variant_part (struct type *type, int field_num)
   struct type *field_type = TYPE_FIELD_TYPE (type, field_num);
   return (TYPE_CODE (field_type) == TYPE_CODE_UNION
           || (is_dynamic_field (type, field_num)
-              && TYPE_CODE (TYPE_TARGET_TYPE (field_type)) ==
-              TYPE_CODE_UNION));
+              && (TYPE_CODE (TYPE_TARGET_TYPE (field_type)) 
+                 == TYPE_CODE_UNION)));
 }
 
 /* Assuming that VAR_TYPE is a variant wrapper (type of the variant part)
@@ -6994,13 +7057,10 @@ ada_search_struct_field (char *name, struct value *arg, int offset,
 
       else if (ada_is_wrapper_field (type, i))
         {
-          struct value *v = ada_search_struct_field (name, arg,
-                                                     offset +
-                                                     TYPE_FIELD_BITPOS (type,
-                                                                        i) /
-                                                     8,
-                                                     TYPE_FIELD_TYPE (type,
-                                                                      i));
+          struct value *v =     /* Do not let indent join lines here. */
+            ada_search_struct_field (name, arg,
+                                     offset + TYPE_FIELD_BITPOS (type, i) / 8,
+                                     TYPE_FIELD_TYPE (type, i));
           if (v != NULL)
             return v;
         }
@@ -7013,13 +7073,10 @@ ada_search_struct_field (char *name, struct value *arg, int offset,
 
           for (j = TYPE_NFIELDS (field_type) - 1; j >= 0; j -= 1)
             {
-              struct value *v = ada_search_struct_field (name, arg,
-                                                         var_offset
-                                                         +
-                                                         TYPE_FIELD_BITPOS
-                                                         (field_type, j) / 8,
-                                                         TYPE_FIELD_TYPE
-                                                         (field_type, j));
+              struct value *v = ada_search_struct_field /* Force line break.  */
+                (name, arg,
+                 var_offset + TYPE_FIELD_BITPOS (field_type, j) / 8,
+                 TYPE_FIELD_TYPE (field_type, j));
               if (v != NULL)
                 return v;
             }
@@ -7174,8 +7231,8 @@ ada_lookup_struct_elt_type (struct type *type, char *name, int refok,
       }
 
   if (type == NULL
-      || (TYPE_CODE (type) != TYPE_CODE_STRUCT &&
-          TYPE_CODE (type) != TYPE_CODE_UNION))
+      || (TYPE_CODE (type) != TYPE_CODE_STRUCT
+          && TYPE_CODE (type) != TYPE_CODE_UNION))
     {
       if (noerr)
         return NULL;
@@ -7659,9 +7716,8 @@ ada_template_to_fixed_record_type_1 (struct type *type, char *valaddr,
 
   for (f = 0; f < nfields; f += 1)
     {
-      off =
-        align_value (off,
-                     field_alignment (type, f)) + TYPE_FIELD_BITPOS (type, f);
+      off = align_value (off, field_alignment (type, f))
+       + TYPE_FIELD_BITPOS (type, f);
       TYPE_FIELD_BITPOS (rtype, f) = off;
       TYPE_FIELD_BITSIZE (rtype, f) = 0;
 
@@ -8438,7 +8494,8 @@ ada_enum_name (const char *name)
      but stop searching when we hit an overloading suffix, which is
      of the form "__" followed by digits.  */
 
-  if ((tmp = strrchr (name, '.')) != NULL)
+  tmp = strrchr (name, '.');
+  if (tmp != NULL)
     name = tmp + 1;
   else
     {
@@ -8474,8 +8531,10 @@ ada_enum_name (const char *name)
     }
   else
     {
-      if ((tmp = strstr (name, "__")) != NULL
-          || (tmp = strstr (name, "$")) != NULL)
+      tmp = strstr (name, "__");
+      if (tmp == NULL)
+       tmp = strstr (name, "$");
+      if (tmp != NULL)
         {
           GROW_VECT (result, result_len, tmp - name + 1);
           strncpy (result, name, tmp - name);
@@ -8930,11 +8989,6 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
           {
             int arity;
 
-            /* Make sure to use the parallel ___XVS type if any.
-               Otherwise, we won't be able to find the array arity
-               and element type.  */
-            type = ada_get_base_type (type);
-
             arity = ada_array_arity (type);
             type = ada_array_element_type (type, nargs);
             if (type == NULL)
@@ -8989,14 +9043,6 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
         if (noside == EVAL_SKIP)
           goto nosideret;
 
-        /* If this is a reference type or a pointer type, and
-           the target type has an XVS parallel type, then get
-           the real target type.  */
-        if (TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_REF
-            || TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_PTR)
-          TYPE_TARGET_TYPE (VALUE_TYPE (array)) =
-            ada_get_base_type (TYPE_TARGET_TYPE (VALUE_TYPE (array)));
-
         /* If this is a reference to an aligner type, then remove all
            the aligners.  */
         if (TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_REF
@@ -9014,26 +9060,16 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
                 && VALUE_LVAL (array) == lval_memory))
           array = value_addr (array);
 
-        if (noside == EVAL_AVOID_SIDE_EFFECTS &&
-            ada_is_array_descriptor_type (check_typedef (VALUE_TYPE (array))))
-          {
-            /* Try dereferencing the array, in case it is an access
-               to array.  */
-            struct type *arrType = ada_type_of_array (array, 0);
-            if (arrType != NULL)
-              array = value_at_lazy (arrType, 0, NULL);
-          }
+        if (noside == EVAL_AVOID_SIDE_EFFECTS
+            && ada_is_array_descriptor_type (check_typedef
+                                            (VALUE_TYPE (array))))
+          return empty_array (ada_type_of_array (array, 0), low_bound);
 
         array = ada_coerce_to_simple_array_ptr (array);
 
-        /* When EVAL_AVOID_SIDE_EFFECTS, we may get the bounds wrong,
-           but only in contexts where the value is not being requested
-           (FIXME?).  */
         if (TYPE_CODE (VALUE_TYPE (array)) == TYPE_CODE_PTR)
           {
-            if (noside == EVAL_AVOID_SIDE_EFFECTS)
-              return ada_value_ind (array);
-            else if (high_bound < low_bound)
+            if (high_bound < low_bound || noside == EVAL_AVOID_SIDE_EFFECTS)
               return empty_array (TYPE_TARGET_TYPE (VALUE_TYPE (array)),
                                   low_bound);
             else
@@ -9041,15 +9077,9 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
                 struct type *arr_type0 =
                   to_fixed_array_type (TYPE_TARGET_TYPE (VALUE_TYPE (array)),
                                        NULL, 1);
-                struct value *item0 =
-                  ada_value_ptr_subscript (array, arr_type0, 1,
-                                           &low_bound_val);
-                struct value *slice =
-                  value_repeat (item0, high_bound - low_bound + 1);
-                struct type *arr_type1 = VALUE_TYPE (slice);
-                TYPE_LOW_BOUND (TYPE_INDEX_TYPE (arr_type1)) = low_bound;
-                TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (arr_type1)) += low_bound;
-                return slice;
+                return ada_value_slice_ptr (array, arr_type0,
+                                            (int) low_bound, 
+                                           (int) high_bound);
               }
           }
         else if (noside == EVAL_AVOID_SIDE_EFFECTS)
@@ -9057,7 +9087,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
         else if (high_bound < low_bound)
           return empty_array (VALUE_TYPE (array), low_bound);
         else
-          return value_slice (array, low_bound, high_bound - low_bound + 1);
+          return ada_value_slice (array, (int) low_bound, (int) high_bound);
       }
 
     case UNOP_IN_RANGE:
@@ -10054,188 +10084,7 @@ static const struct op_print ada_op_print_tab[] = {
   {NULL, 0, 0, 0}
 };
 \f
-                        /* Assorted Types and Interfaces */
-
-struct type *builtin_type_ada_int;
-struct type *builtin_type_ada_short;
-struct type *builtin_type_ada_long;
-struct type *builtin_type_ada_long_long;
-struct type *builtin_type_ada_char;
-struct type *builtin_type_ada_float;
-struct type *builtin_type_ada_double;
-struct type *builtin_type_ada_long_double;
-struct type *builtin_type_ada_natural;
-struct type *builtin_type_ada_positive;
-struct type *builtin_type_ada_system_address;
-
-struct type **const (ada_builtin_types[]) =
-{
-  &builtin_type_ada_int,
-    &builtin_type_ada_long,
-    &builtin_type_ada_short,
-    &builtin_type_ada_char,
-    &builtin_type_ada_float,
-    &builtin_type_ada_double,
-    &builtin_type_ada_long_long,
-    &builtin_type_ada_long_double,
-    &builtin_type_ada_natural, &builtin_type_ada_positive,
-    /* The following types are carried over from C for convenience.  */
-&builtin_type_int,
-    &builtin_type_long,
-    &builtin_type_short,
-    &builtin_type_char,
-    &builtin_type_float,
-    &builtin_type_double,
-    &builtin_type_long_long,
-    &builtin_type_void,
-    &builtin_type_signed_char,
-    &builtin_type_unsigned_char,
-    &builtin_type_unsigned_short,
-    &builtin_type_unsigned_int,
-    &builtin_type_unsigned_long,
-    &builtin_type_unsigned_long_long,
-    &builtin_type_long_double,
-    &builtin_type_complex, &builtin_type_double_complex, 0};
-
-/* Not really used, but needed in the ada_language_defn.  */
-
-static void
-emit_char (int c, struct ui_file *stream, int quoter)
-{
-  ada_emit_char (c, stream, quoter, 1);
-}
-
-static int
-parse ()
-{
-  warnings_issued = 0;
-  return ada_parse ();
-}
-
-static const struct exp_descriptor ada_exp_descriptor = {
-  ada_print_subexp,
-  ada_operator_length,
-  ada_op_name,
-  ada_dump_subexp_body,
-  ada_evaluate_subexp
-};
-
-const struct language_defn ada_language_defn = {
-  "ada",                        /* Language name */
-  language_ada,
-  ada_builtin_types,
-  range_check_off,
-  type_check_off,
-  case_sensitive_on,            /* Yes, Ada is case-insensitive, but
-                                   that's not quite what this means.  */
-#ifdef GNAT_GDB
-  ada_lookup_symbol,
-  ada_lookup_minimal_symbol,
-#endif /* GNAT_GDB */
-  &ada_exp_descriptor,
-  parse,
-  ada_error,
-  resolve,
-  ada_printchar,                /* Print a character constant */
-  ada_printstr,                 /* Function to print string constant */
-  emit_char,                    /* Function to print single char (not used) */
-  ada_create_fundamental_type,  /* Create fundamental type in this language */
-  ada_print_type,               /* Print a type using appropriate syntax */
-  ada_val_print,                /* Print a value using appropriate syntax */
-  ada_value_print,              /* Print a top-level value */
-  NULL,                         /* Language specific skip_trampoline */
-  NULL,                         /* value_of_this */
-  ada_lookup_symbol_nonlocal,   /* Looking up non-local symbols.  */
-  basic_lookup_transparent_type,        /* lookup_transparent_type */
-  ada_la_decode,                /* Language specific symbol demangler */
-  {"", "", "", ""},             /* Binary format info */
-#if 0
-  {"8#%lo#", "8#", "o", "#"},   /* Octal format info */
-  {"%ld", "", "d", ""},         /* Decimal format info */
-  {"16#%lx#", "16#", "x", "#"}, /* Hex format info */
-#else
-  /* Copied from c-lang.c.  */
-  {"0%lo", "0", "o", ""},       /* Octal format info */
-  {"%ld", "", "d", ""},         /* Decimal format info */
-  {"0x%lx", "0x", "x", ""},     /* Hex format info */
-#endif
-  ada_op_print_tab,             /* expression operators for printing */
-  0,                            /* c-style arrays */
-  1,                            /* String lower bound */
-  &builtin_type_ada_char,
-  ada_get_gdb_completer_word_break_characters,
-#ifdef GNAT_GDB
-  ada_translate_error_message,  /* Substitute Ada-specific terminology
-                                   in errors and warnings.  */
-#endif /* GNAT_GDB */
-  LANG_MAGIC
-};
-
-static void
-build_ada_types (void)
-{
-  builtin_type_ada_int =
-    init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
-               0, "integer", (struct objfile *) NULL);
-  builtin_type_ada_long =
-    init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
-               0, "long_integer", (struct objfile *) NULL);
-  builtin_type_ada_short =
-    init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
-               0, "short_integer", (struct objfile *) NULL);
-  builtin_type_ada_char =
-    init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
-               0, "character", (struct objfile *) NULL);
-  builtin_type_ada_float =
-    init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
-               0, "float", (struct objfile *) NULL);
-  builtin_type_ada_double =
-    init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
-               0, "long_float", (struct objfile *) NULL);
-  builtin_type_ada_long_long =
-    init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
-               0, "long_long_integer", (struct objfile *) NULL);
-  builtin_type_ada_long_double =
-    init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
-               0, "long_long_float", (struct objfile *) NULL);
-  builtin_type_ada_natural =
-    init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
-               0, "natural", (struct objfile *) NULL);
-  builtin_type_ada_positive =
-    init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
-               0, "positive", (struct objfile *) NULL);
-
-
-  builtin_type_ada_system_address =
-    lookup_pointer_type (init_type (TYPE_CODE_VOID, 1, 0, "void",
-                                    (struct objfile *) NULL));
-  TYPE_NAME (builtin_type_ada_system_address) = "system__address";
-}
-
-void
-_initialize_ada_language (void)
-{
-
-  build_ada_types ();
-  deprecated_register_gdbarch_swap (NULL, 0, build_ada_types);
-  add_language (&ada_language_defn);
-
-  varsize_limit = 65536;
-#ifdef GNAT_GDB
-  add_show_from_set
-    (add_set_cmd ("varsize-limit", class_support, var_uinteger,
-                  (char *) &varsize_limit,
-                  "Set maximum bytes in dynamic-sized object.",
-                  &setlist), &showlist);
-  obstack_init (&cache_space);
-#endif /* GNAT_GDB */
-
-  obstack_init (&symbol_list_obstack);
-
-  decoded_names_store = htab_create_alloc_ex
-    (256, htab_hash_string, (int (*)(const void *, const void *)) streq,
-     NULL, NULL, xmcalloc, xmfree);
-}
+                               /* Fundamental Ada Types */
 
 /* Create a fundamental Ada type using default reasonable for the current
    target machine.
@@ -10374,22 +10223,177 @@ ada_create_fundamental_type (struct objfile *objfile, int typeid)
   return (type);
 }
 
+struct type *builtin_type_ada_int;
+struct type *builtin_type_ada_short;
+struct type *builtin_type_ada_long;
+struct type *builtin_type_ada_long_long;
+struct type *builtin_type_ada_char;
+struct type *builtin_type_ada_float;
+struct type *builtin_type_ada_double;
+struct type *builtin_type_ada_long_double;
+struct type *builtin_type_ada_natural;
+struct type *builtin_type_ada_positive;
+struct type *builtin_type_ada_system_address;
+
+struct type **const (ada_builtin_types[]) =
+{
+  &builtin_type_ada_int,
+    &builtin_type_ada_long,
+    &builtin_type_ada_short,
+    &builtin_type_ada_char,
+    &builtin_type_ada_float,
+    &builtin_type_ada_double,
+    &builtin_type_ada_long_long,
+    &builtin_type_ada_long_double,
+    &builtin_type_ada_natural, &builtin_type_ada_positive,
+    /* The following types are carried over from C for convenience.  */
+&builtin_type_int,
+    &builtin_type_long,
+    &builtin_type_short,
+    &builtin_type_char,
+    &builtin_type_float,
+    &builtin_type_double,
+    &builtin_type_long_long,
+    &builtin_type_void,
+    &builtin_type_signed_char,
+    &builtin_type_unsigned_char,
+    &builtin_type_unsigned_short,
+    &builtin_type_unsigned_int,
+    &builtin_type_unsigned_long,
+    &builtin_type_unsigned_long_long,
+    &builtin_type_long_double,
+    &builtin_type_complex, &builtin_type_double_complex, 0};
+
+static void
+build_ada_types (struct gdbarch *current_gdbarch)
+{
+  builtin_type_ada_int =
+    init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
+               0, "integer", (struct objfile *) NULL);
+  builtin_type_ada_long =
+    init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
+               0, "long_integer", (struct objfile *) NULL);
+  builtin_type_ada_short =
+    init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
+               0, "short_integer", (struct objfile *) NULL);
+  builtin_type_ada_char =
+    init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+               0, "character", (struct objfile *) NULL);
+  builtin_type_ada_float =
+    init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
+               0, "float", (struct objfile *) NULL);
+  builtin_type_ada_double =
+    init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
+               0, "long_float", (struct objfile *) NULL);
+  builtin_type_ada_long_long =
+    init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
+               0, "long_long_integer", (struct objfile *) NULL);
+  builtin_type_ada_long_double =
+    init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
+               0, "long_long_float", (struct objfile *) NULL);
+  builtin_type_ada_natural =
+    init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
+               0, "natural", (struct objfile *) NULL);
+  builtin_type_ada_positive =
+    init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
+               0, "positive", (struct objfile *) NULL);
+
+
+  builtin_type_ada_system_address =
+    lookup_pointer_type (init_type (TYPE_CODE_VOID, 1, 0, "void",
+                                    (struct objfile *) NULL));
+  TYPE_NAME (builtin_type_ada_system_address) = "system__address";
+}
+
+\f
+                               /* Language vector */
+
+/* Not really used, but needed in the ada_language_defn.  */
+
+static void
+emit_char (int c, struct ui_file *stream, int quoter)
+{
+  ada_emit_char (c, stream, quoter, 1);
+}
+
+static int
+parse (void)
+{
+  warnings_issued = 0;
+  return ada_parse ();
+}
+
+static const struct exp_descriptor ada_exp_descriptor = {
+  ada_print_subexp,
+  ada_operator_length,
+  ada_op_name,
+  ada_dump_subexp_body,
+  ada_evaluate_subexp
+};
+
+const struct language_defn ada_language_defn = {
+  "ada",                        /* Language name */
+  language_ada,
+  ada_builtin_types,
+  range_check_off,
+  type_check_off,
+  case_sensitive_on,            /* Yes, Ada is case-insensitive, but
+                                   that's not quite what this means.  */
+#ifdef GNAT_GDB
+  ada_lookup_symbol,
+  ada_lookup_minimal_symbol,
+#endif /* GNAT_GDB */
+  array_row_major,
+  &ada_exp_descriptor,
+  parse,
+  ada_error,
+  resolve,
+  ada_printchar,                /* Print a character constant */
+  ada_printstr,                 /* Function to print string constant */
+  emit_char,                    /* Function to print single char (not used) */
+  ada_create_fundamental_type,  /* Create fundamental type in this language */
+  ada_print_type,               /* Print a type using appropriate syntax */
+  ada_val_print,                /* Print a value using appropriate syntax */
+  ada_value_print,              /* Print a top-level value */
+  NULL,                         /* Language specific skip_trampoline */
+  NULL,                         /* value_of_this */
+  ada_lookup_symbol_nonlocal,   /* Looking up non-local symbols.  */
+  basic_lookup_transparent_type,        /* lookup_transparent_type */
+  ada_la_decode,                /* Language specific symbol demangler */
+  NULL,                         /* Language specific class_name_from_physname */
+  ada_op_print_tab,             /* expression operators for printing */
+  0,                            /* c-style arrays */
+  1,                            /* String lower bound */
+  &builtin_type_ada_char,
+  ada_get_gdb_completer_word_break_characters,
+#ifdef GNAT_GDB
+  ada_translate_error_message,  /* Substitute Ada-specific terminology
+                                   in errors and warnings.  */
+#endif /* GNAT_GDB */
+  LANG_MAGIC
+};
+
 void
-ada_dump_symtab (struct symtab *s)
+_initialize_ada_language (void)
 {
-  int i;
-  fprintf (stderr, "New symtab: [\n");
-  fprintf (stderr, "  Name: %s/%s;\n",
-           s->dirname ? s->dirname : "?", s->filename ? s->filename : "?");
-  fprintf (stderr, "  Format: %s;\n", s->debugformat);
-  if (s->linetable != NULL)
-    {
-      fprintf (stderr, "  Line table (section %d):\n", s->block_line_section);
-      for (i = 0; i < s->linetable->nitems; i += 1)
-        {
-          struct linetable_entry *e = s->linetable->item + i;
-          fprintf (stderr, "    %4ld: %8lx\n", (long) e->line, (long) e->pc);
-        }
-    }
-  fprintf (stderr, "]\n");
+
+  build_ada_types (current_gdbarch);
+  gdbarch_data_register_post_init (build_ada_types);
+  add_language (&ada_language_defn);
+
+  varsize_limit = 65536;
+#ifdef GNAT_GDB
+  add_setshow_uinteger_cmd ("varsize-limit", class_support,
+                           &varsize_limit, "\
+Set the maximum number of bytes allowed in a dynamic-sized object.", "\
+Show the maximum number of bytes allowed in a dynamic-sized object.",
+                           NULL, NULL, &setlist, &showlist);
+  obstack_init (&cache_space);
+#endif /* GNAT_GDB */
+
+  obstack_init (&symbol_list_obstack);
+
+  decoded_names_store = htab_create_alloc
+    (256, htab_hash_string, (int (*)(const void *, const void *)) streq,
+     NULL, xcalloc, xfree);
 }
This page took 0.04002 seconds and 4 git commands to generate.