+/* Return non-zero if the debugger should print the index of each element
+ when printing array values. */
+
+int
+print_array_indexes_p (void)
+{
+ return print_array_indexes;
+}
+
+/* Assuming TYPE is a simple, non-empty array type, compute its lower bound.
+ Save it into LOW_BOUND if not NULL.
+
+ Return 1 if the operation was successful. Return zero otherwise,
+ in which case the value of LOW_BOUND is unmodified.
+
+ Computing the array lower bound is pretty easy, but this function
+ does some additional verifications before returning the low bound.
+ If something incorrect is detected, it is better to return a status
+ rather than throwing an error, making it easier for the caller to
+ implement an error-recovery plan. For instance, it may decide to
+ warn the user that the bound was not found and then use a default
+ value instead. */
+
+int
+get_array_low_bound (struct type *type, long *low_bound)
+{
+ struct type *index = TYPE_INDEX_TYPE (type);
+ long low = 0;
+
+ if (index == NULL)
+ return 0;
+
+ if (TYPE_CODE (index) != TYPE_CODE_RANGE
+ && TYPE_CODE (index) != TYPE_CODE_ENUM)
+ return 0;
+
+ low = TYPE_LOW_BOUND (index);
+ if (low > TYPE_HIGH_BOUND (index))
+ return 0;
+
+ if (low_bound)
+ *low_bound = low;
+
+ return 1;
+}
+
+/* Print on STREAM using the given FORMAT the index for the element
+ at INDEX of an array whose index type is INDEX_TYPE. */
+
+void
+maybe_print_array_index (struct type *index_type, LONGEST index,
+ struct ui_file *stream, int format,
+ enum val_prettyprint pretty)
+{
+ struct value *index_value;
+
+ if (!print_array_indexes)
+ return;
+
+ index_value = value_from_longest (index_type, index);
+
+ LA_PRINT_ARRAY_INDEX (index_value, stream, format, pretty);
+}
+