This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

[vla] [commit] Fix regression on: gdb.opt/array-from-register.exp


commit 27418f1593e66ca3467c35e74976c959c43cce24

The VLA code was needlessly asking for address of variables it did not need to
(variables with non-dynamic types).

gdb/
	Fix accessing variables with non-dynamic types if stored in a register.
	* eval.c (evaluate_subexp_with_coercion): Initialize `val'.  Make the
	early address_of_variable conditional.  Restore the original later call
	of address_of_variable for the other cases.
	* dwarf2read.c (read_type_die): Call finalize_type.
	* gdbtypes.c (create_array_type): Remove TYPE_DYNAMIC propagation.
	(finalize_type): New function.
	* gdbtypes.h (finalize_type): New prototype.
---
 gdb/dwarf2read.c |    3 +++
 gdb/eval.c       |   10 +++++++---
 gdb/gdbtypes.c   |   28 +++++++++++++++++++---------
 gdb/gdbtypes.h   |    2 ++
 4 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 8dea626..b57f44c 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8196,6 +8196,9 @@ read_type_die (struct die_info *die, struct dwarf2_cu *cu)
       break;
     }
 
+  if (this_type)
+    finalize_type (this_type);
+
   return this_type;
 }
 
diff --git a/gdb/eval.c b/gdb/eval.c
index eb933ac..e2ee7f4 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2635,7 +2635,7 @@ evaluate_subexp_with_coercion (struct expression *exp,
 {
   enum exp_opcode op;
   int pc;
-  struct value *val;
+  struct value *val = NULL;
   struct symbol *var;
   struct type *type;
 
@@ -2646,13 +2646,17 @@ evaluate_subexp_with_coercion (struct expression *exp,
     {
     case OP_VAR_VALUE:
       var = exp->elts[pc + 2].symbol;
-      /* address_of_variable will call object_address_set for check_typedef.  */
-      val = address_of_variable (var, exp->elts[pc + 1].block);
+      /* address_of_variable will call object_address_set for check_typedef.
+	 Call it only if required as it can error-out on VAR in register.  */
+      if (TYPE_DYNAMIC (SYMBOL_TYPE (var)))
+	val = address_of_variable (var, exp->elts[pc + 1].block);
       type = check_typedef (SYMBOL_TYPE (var));
       if (TYPE_CODE (type) == TYPE_CODE_ARRAY
 	  && CAST_IS_CONVERSION)
 	{
 	  (*pos) += 4;
+	  if (!val)
+	    val = address_of_variable (var, exp->elts[pc + 1].block);
 	  return value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
 			     val);
 	}
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index b3217fb..012485c 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -894,15 +894,6 @@ create_array_type (struct type *result_type,
 	TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
     }
 
-  if (TYPE_DYNAMIC (range_type))
-    TYPE_DYNAMIC (result_type) = 1;
-
-  /* Multidimensional dynamic arrays need to have all the outer dimensions
-     dynamic to update the outer TYPE_TARGET_TYPE pointer with the new type
-     with statically evaluated dimensions.  */
-  if (TYPE_DYNAMIC (element_type))
-    TYPE_DYNAMIC (result_type) = 1;
-
   if (TYPE_LENGTH (result_type) == 0)
     {
       /* The real size will be computed for specific instances by
@@ -1512,6 +1503,25 @@ type_length_get (struct type *type, struct type *target_type, int full_span)
   return (count - 1) * byte_stride + element_size;
 }
 
+/* Prepare TYPE after being read in by the backend.  Currently this function
+   only propagates the TYPE_DYNAMIC flag.  */
+
+void
+finalize_type (struct type *type)
+{
+  int i;
+
+  for (i = 0; i < TYPE_NFIELDS (type); ++i)
+    if (TYPE_FIELD_TYPE (type, i) && TYPE_DYNAMIC (TYPE_FIELD_TYPE (type, i)))
+      break;
+
+  /* FIXME: cplus_stuff is ignored here.  */
+  if (i < TYPE_NFIELDS (type)
+      || (TYPE_VPTR_BASETYPE (type) && TYPE_DYNAMIC (TYPE_VPTR_BASETYPE (type)))
+      || (TYPE_TARGET_TYPE (type) && TYPE_DYNAMIC (TYPE_TARGET_TYPE (type))))
+    TYPE_DYNAMIC (type) = 1;
+}
+
 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
 
    If this is a stubbed struct (i.e. declared as struct foo *), see if
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 86df022..71463a2 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1267,6 +1267,8 @@ extern int type_range_count_bound_internal (struct type *range_type);
 extern CORE_ADDR type_range_byte_stride_internal (struct type *range_type,
 						  struct type *element_type);
 
+extern void finalize_type (struct type *type);
+
 extern struct type *create_string_type (struct type *, struct type *);
 
 extern struct type *create_set_type (struct type *, struct type *);
-- 
1.6.0.6


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