This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Fix inherit.exp tests
- From: Andrew Stubbs <ams at codesourcery dot com>
- To: <gdb-patches at sourceware dot org>
- Date: Fri, 2 Oct 2015 09:58:00 +0100
- Subject: [PATCH] Fix inherit.exp tests
- Authentication-results: sourceware.org; auth=none
Some of the tests in inherit.exp make invalid assumptions about vtable
pointers in printed values.
I find that these tests pass on most targets, but fail on a few targets,
including mips-sde.
The reason is that the "_vptr" entries in C++ types do not point to the
head of the vtable, but point to the address following the last entry in
the table, which mean that when GDB prints the symbol associated with
the address, it actually prints the name of the value that follows the
table in memory.
Historically, it appears to have been fairly predictable what symbol
would follow the vtable, and remains so on most targets, but this is no
longer true in general (or perhaps never was). In mips-sde, in
particular, the "VTT for *" symbols are placed in a completely different
section, so cannot follow the vtable. The alignment and padding appears
to have varied slightly, and the order of vtable and typeinfo sections
appears to have varied also (or maybe the test was never right?)
The attached patch adds new expect patterns that don't require any
specific symbol at all, since they're basically meaningless.
OK to commit?
Andrew
2015-10-02 Andrew Stubbs <ams@codesourcery.com>
gdb/testsuite/
* gdb.cp/inherit.exp (print g_vB, print g_vC, print g_vD,
print g_vE): Add new pass patterns.
Index: gdb/testsuite/gdb.cp/inherit.exp
===================================================================
--- gdb/testsuite/gdb.cp/inherit.exp (revision 455195)
+++ gdb/testsuite/gdb.cp/inherit.exp (working copy)
@@ -524,6 +524,11 @@
# gcc HEAD 2004-07-31 -gstabs+
pass $name
}
+ -re "$vhn = \{<vA> = \{va = 3, vx = 4\}, $re_vbptr_3 = ${hex}( <\[^>]*>)?, vb = 5, vx = 6\}$nl$gdb_prompt $" {
+ # gcc HEAD 2015?+
+ # the vptr is set to the address *after* the vtable, so the symbol shown is unpredictable
+ pass "$name (symbols ignored)"
+ }
}
# Print all members of g_vC.
@@ -552,6 +557,11 @@
# gcc HEAD 2004-07-31 -gstabs+
pass $name
}
+ -re "$vhn = \{<vA> = \{va = 7, vx = 8\}, $re_vbptr_3 = ${hex}( <\[^>]*>)?, vc = 9, vx = 10\}$nl$gdb_prompt $" {
+ # gcc HEAD 2015?+
+ # the vptr is set to the address *after* the vtable, so the symbol shown is unpredictable
+ pass "$name (symbols ignored)"
+ }
}
}
@@ -623,6 +633,11 @@
# gcc 3.3.2 -gstabs+
pass "$name"
}
+ -re "$vhn = \{<vB> = \{<vA> = \{va = 19, vx = 20\}, $re_vbptr_3_vB = ${hex}( <\[^>]*>)?, vb = 21, vx = 22\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <\[^>]*>)?, vc = 23, vx = 24\}, $re_vbptr_3_vD = ${hex}( <\[^>]*>)?, vd = 25, vx = 26\}$nl$gdb_prompt $" {
+ # gcc HEAD 2015?+
+ # the vptr is set to the address *after* the vtable, so the symbol shown is unpredictable
+ pass "$name (symbols ignored)"
+ }
}
# Print all members of g_vE.
@@ -650,6 +665,11 @@
# gcc HEAD 2004-07-31 -gstabs+
pass $name
}
+ -re "$vhn = \{<vD> = \{<vB> = \{<vA> = \{va = 0, vx = 0\}, $re_vbptr_3_vB = ${hex}( <\[^>]*>)?, vb = 0, vx = 0\}, <vC> = \{$re_vbptr_3_vC = ${hex}( <\[^>]*>)?, vc = 0, vx = 0\}, $re_vbptr_3_vD = ${hex}( <\[^>]*>)?, vd = 0, vx = 0\}, $re_vbptr_3_vE = ${hex}( <\[^>]*>)?, ve = 27, vx = 28\}$nl$gdb_prompt $" {
+ # gcc HEAD 2015?+
+ # the vptr is set to the address *after* the vtable, so the symbol shown is unpredictable
+ pass "$name (symbols ignored)"
+ }
}
}