This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfc] Ada simplification: ada_coerce_to_simple_array_type


Hello,

in my ongoing attempts to eliminate current_gdbarch from GDB, I've run into
a couple of places in Ada-specific code that makes things difficult.  This
(and the following three) patches rework a couple of Ada details in order
to make life simpler for my subsequent changes ...

This patch addresses ada_coerce_to_simple_array_type, which creates a
dummy value only to pass it to ada_type_of_array which in the end only
inspects its type.  Not only is that a bit wasteful; it makes a future
change to create values relative to a gdbarch difficult (because there
is no good choice of architecture to use for that dummy value).

This patch inlines the part of ada_type_of_array that is used in the
case of a "bounds == 0" parameter -- in this piece of code, only
the type of the passed-in value is inspected.

There should be no change in behaviour with this patch.

Joel, would this be OK?

Thanks,
Ulrich


ChangeLog:

	* ada-lang.c (ada_coerce_to_simple_array_type): Reimplement to
	avoid creating a dummy value.


Index: gdb-head/gdb/ada-lang.c
===================================================================
--- gdb-head.orig/gdb/ada-lang.c
+++ gdb-head/gdb/ada-lang.c
@@ -1689,13 +1689,13 @@ ada_coerce_to_simple_array (struct value
 struct type *
 ada_coerce_to_simple_array_type (struct type *type)
 {
-  struct value *mark = value_mark ();
-  struct value *dummy = value_from_longest (builtin_type_int32, 0);
-  struct type *result;
-  deprecated_set_value_type (dummy, type);
-  result = ada_type_of_array (dummy, 0);
-  value_free_to_mark (mark);
-  return result;
+  if (ada_is_packed_array_type (type))
+    return decode_packed_array_type (type);
+
+  if (ada_is_array_descriptor_type (type))
+    return ada_check_typedef (TYPE_TARGET_TYPE (desc_data_type (type)));
+
+  return type;
 }
 
 /* Non-zero iff TYPE represents a standard GNAT packed-array type.  */
-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]