This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Regression: gdb.trace/unavailable.exp [3/5] make value_primitive_field respect virtual bases
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> Also in non-extended gdbserver mode:
Jan> PASS
->
Jan> FAIL: gdb.trace/unavailable.exp: collect globals: print (small_struct)
Jan> g_smallstruct_b
Jan> FAIL: gdb.trace/unavailable.exp: collect globals: print (small_struct) $
Thanks.
The bug was that we changed the output, because the new code called
value_contents on an unavailable value, causing an exception.
I'm checking in the appended. It special-cases virtual bases to avoid
this problem. It seemed like a reasonable approach to me; I also
considered an explicit availability check -- but I think that would
amount to about the same thing, as it is only with virtual bases that we
have to go through all the funny business.
Tom
2012-03-05 Tom Tromey <tromey@redhat.com>
* value.c (value_primitive_field): Don't fetch contents for
non-virtual bases.
diff --git a/gdb/value.c b/gdb/value.c
index bee6907..e8eb33f 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -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));