Jan Kratochvil fb75065
commit a999ae2c722b366b94987941f0ce899f95e8d679
Jan Kratochvil fb75065
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Jan Kratochvil fb75065
Date:   Fri Mar 2 22:08:49 2012 +0100
Jan Kratochvil fb75065
Jan Kratochvil fb75065
    Fix crash for gdb.fortran/dynamic.exp with gcc-gfortran-4.1.2-51.el5.x86_64.
Jan Kratochvil fb75065
Jan Kratochvil fb75065
--- a/gdb/valops.c
Jan Kratochvil fb75065
+++ b/gdb/valops.c
Jan Kratochvil fb75065
@@ -1037,7 +1037,8 @@ int
Jan Kratochvil fb75065
 value_fetch_lazy (struct value *val)
Jan Kratochvil fb75065
 {
Jan Kratochvil fb75065
   gdb_assert (value_lazy (val));
Jan Kratochvil fb75065
-  allocate_value_contents (val);
Jan Kratochvil fb75065
+  if (VALUE_LVAL (val) != lval_memory)
Jan Kratochvil fb75065
+    allocate_value_contents (val);
Jan Kratochvil fb75065
   if (value_bitsize (val))
Jan Kratochvil fb75065
     {
Jan Kratochvil fb75065
       /* To read a lazy bitfield, read the entire enclosing value.  This
Jan Kratochvil fb75065
@@ -1080,11 +1081,15 @@ value_fetch_lazy (struct value *val)
Jan Kratochvil fb75065
 
Jan Kratochvil fb75065
 	  if (length)
Jan Kratochvil fb75065
 	    {
Jan Kratochvil fb75065
+	      /* Delay it after object_address_get_data above.  */
Jan Kratochvil fb75065
+	      allocate_value_contents (val);
Jan Kratochvil fb75065
 	      addr += value_offset (val);
Jan Kratochvil fb75065
 	      read_value_memory (val, 0, value_stack (val),
Jan Kratochvil fb75065
 				 addr, value_contents_all_raw (val), length);
Jan Kratochvil fb75065
 	    }
Jan Kratochvil fb75065
 	}
Jan Kratochvil fb75065
+      /* Just to be sure it has been called.  */
Jan Kratochvil fb75065
+      allocate_value_contents (val);
Jan Kratochvil fb75065
     }
Jan Kratochvil fb75065
   else if (VALUE_LVAL (val) == lval_register)
Jan Kratochvil fb75065
     {