* value.c (value_primitive_field): Don't fetch contents for
authorTom Tromey <tromey@redhat.com>
Mon, 5 Mar 2012 20:53:15 +0000 (20:53 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 5 Mar 2012 20:53:15 +0000 (20:53 +0000)
non-virtual bases.

gdb/ChangeLog
gdb/value.c

index 2def55d883326906645351e376c6da1c49cc9f7a..65ba222512d4b3eb91223ca685a897eb3e0df5c4 100644 (file)
@@ -1,3 +1,8 @@
+2012-03-05  Tom Tromey  <tromey@redhat.com>
+
+       * value.c (value_primitive_field): Don't fetch contents for
+       non-virtual bases.
+
 2012-03-05  Tom Tromey  <tromey@redhat.com>
 
        * jv-valprint.c (java_value_print): Correctly compute 'obj_addr'.
index bee6907413052d57ce24e540099899a17e5a229e..e8eb33f3400f7155931c3aeb01202d5dc449e908 100644 (file)
@@ -2556,11 +2556,17 @@ value_primitive_field (struct value *arg1, int offset,
       if (VALUE_LVAL (arg1) == lval_register && value_lazy (arg1))
        value_fetch_lazy (arg1);
 
-      boffset = baseclass_offset (arg_type, fieldno,
-                                 value_contents (arg1),
-                                 value_embedded_offset (arg1),
-                                 value_address (arg1),
-                                 arg1);
+      /* We special case virtual inheritance here because this
+        requires access to the contents, which we would rather avoid
+        for references to ordinary fields of unavailable values.  */
+      if (BASETYPE_VIA_VIRTUAL (arg_type, fieldno))
+       boffset = baseclass_offset (arg_type, fieldno,
+                                   value_contents (arg1),
+                                   value_embedded_offset (arg1),
+                                   value_address (arg1),
+                                   arg1);
+      else
+       boffset = TYPE_FIELD_BITPOS (arg_type, fieldno) / 8;
 
       if (value_lazy (arg1))
        v = allocate_value_lazy (value_enclosing_type (arg1));