aboutsummaryrefslogtreecommitdiff
path: root/gdb/valops.c
diff options
context:
space:
mode:
authorBruno Larsen <blarsen@redhat.com>2022-09-23 11:36:02 +0200
committerBruno Larsen <blarsen@redhat.com>2022-10-03 10:09:30 +0200
commit2820f08f2331820808ac2f54d8e3619f36ea258b (patch)
tree3f313ad341e11515c40869d04d738b631a162507 /gdb/valops.c
parent7b4f240762ffa03e65e17cb7dee807bc1628c24a (diff)
downloadbinutils-2820f08f2331820808ac2f54d8e3619f36ea258b.zip
binutils-2820f08f2331820808ac2f54d8e3619f36ea258b.tar.gz
binutils-2820f08f2331820808ac2f54d8e3619f36ea258b.tar.bz2
Improve GDB's baseclass detection with typedefs
When a class inherits from a typedef'd baseclass, GDB may be unable to find the baseclass if the user is not using the typedef'd name, as is tested on gdb.cp/virtbase2.exp; the reason that test case is working under gcc is that the dwarf generated by gcc links the class to the original definition of the baseclass, not to the typedef. If the inheritance is linked to the typedef, such as how clang does it, gdb.cp/virtbase2.exp starts failing. This can also be seen in gdb.cp/impl-this.exp, when attempting to print D::Bint::i, and GDB not being able to find the baseclass Bint. This happens because searching for baseclasses only uses the macro TYPE_BASECLASS_NAME, which returns the typedef'd name. However, we can't switch that macro to checking for typedefs, otherwise we wouldn't be able to find the typedef'd name anymore. This is fixed by searching for members or baseclasses by name, we check both the saved name and the name after checking for typedefs. This also fixes said long-standing bug in gdb.cp/impl-this.exp when the compiler adds information about typedefs in the debuginfo.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r--gdb/valops.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/gdb/valops.c b/gdb/valops.c
index 0a215d6..de8a688 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -2066,9 +2066,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset,
name is not yet filled in. */
int found_baseclass = (m_looking_for_baseclass
&& TYPE_BASECLASS_NAME (type, i) != NULL
- && (strcmp_iw (m_name,
- TYPE_BASECLASS_NAME (type,
- i)) == 0));
+ && (strcmp_iw (m_name, basetype->name ()) == 0));
LONGEST boffset = value_embedded_offset (arg1) + offset;
if (BASETYPE_VIA_VIRTUAL (type, i))