This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: fix virtual base bugs in search_struct_field
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 04 Feb 2010 13:37:57 -0700
- Subject: FYI: fix virtual base bugs in search_struct_field
- Reply-to: Tom Tromey <tromey at redhat dot com>
I'm checking this in.
This fixes a couple bugs that Jan reported arising from my virtual base
class patch from earlier this week.
First, there were test failures on x86-64. I tracked this down to
search_struct_field not respecting value_embedded_offset.
As an aside, embedded_offset and enclosing_type must die. They are
confusing and hard to use, as evidenced by the bugs I've fixed this
week. E.g., value_contents offsets the result by embedded_offset, but
value_address does not -- this leads to a lot of problems.
The second fix is to rename a couple of tests in virtbase.exp so that
they are unique.
Built and regtested on x86-64 (compile farm).
I also did ran some subset of the test suite on my local x86 box as
well, because some regressions only turned up on one or the other.
Tom
2010-02-04 Tom Tromey <tromey@redhat.com>
* valops.c (search_struct_field): Account for
value_embedded_offset. Fix check for virtual base past the end of
the object. Use value_copy when making a slice of the value.
2010-02-04 Tom Tromey <tromey@redhat.com>
* gdb.cp/virtbase.exp: Make test case names unique.
Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.235
diff -u -r1.235 valops.c
--- valops.c 2 Feb 2010 23:40:27 -0000 1.235
+++ valops.c 4 Feb 2010 20:36:00 -0000
@@ -1903,7 +1903,9 @@
boffset = baseclass_offset (type, i,
value_contents (arg1) + offset,
- value_address (arg1) + offset);
+ value_address (arg1)
+ + value_embedded_offset (arg1)
+ + offset);
if (boffset == -1)
error (_("virtual baseclass botch"));
@@ -1911,8 +1913,9 @@
by the user program. Make sure that it still points to a
valid memory location. */
- boffset += offset;
- if (boffset < 0 || boffset >= TYPE_LENGTH (type))
+ boffset += value_embedded_offset (arg1) + offset;
+ if (boffset < 0
+ || boffset >= TYPE_LENGTH (value_enclosing_type (arg1)))
{
CORE_ADDR base_addr;
@@ -1927,18 +1930,9 @@
}
else
{
- if (VALUE_LVAL (arg1) == lval_memory && value_lazy (arg1))
- v2 = allocate_value_lazy (basetype);
- else
- {
- v2 = allocate_value (basetype);
- memcpy (value_contents_raw (v2),
- value_contents_raw (arg1) + boffset,
- TYPE_LENGTH (basetype));
- }
- set_value_component_location (v2, arg1);
- VALUE_FRAME_ID (v2) = VALUE_FRAME_ID (arg1);
- set_value_offset (v2, value_offset (arg1) + boffset);
+ v2 = value_copy (arg1);
+ deprecated_set_value_type (v2, basetype);
+ set_value_embedded_offset (v2, boffset);
}
if (found_baseclass)
Index: testsuite/gdb.cp/virtbase.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/virtbase.exp,v
retrieving revision 1.2
diff -u -r1.2 virtbase.exp
--- testsuite/gdb.cp/virtbase.exp 2 Feb 2010 23:40:28 -0000 1.2
+++ testsuite/gdb.cp/virtbase.exp 4 Feb 2010 20:36:01 -0000
@@ -42,13 +42,13 @@
# In PR 11226, we failed to print x correctly in the "print *this"
# case.
gdb_test "print *this" " = {<mc::Base> = {x = 2}, _vptr.Middle = $hex, y = 3}"
-gdb_test "print x" " = 2"
+gdb_test "print x" " = 2" "print x in get_y"
gdb_breakpoint [gdb_get_line_number "breakpoint 2"]
gdb_continue_to_breakpoint "second breakpoint"
# In PR 11226, we could not find x here.
-gdb_test "print x" " = 2"
+gdb_test "print x" " = 2" "print x in get_z"
gdb_breakpoint [gdb_get_line_number "breakpoint 3"]
gdb_continue_to_breakpoint "third breakpoint"