diff --git a/gdb/ChangeLog b/gdb/ChangeLog index bb186766e3f9..c1eedea35d79 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2021-01-23 Simon Marchi + + * gdbtypes.c (copy_type_recursive): Use get_type_arch. + * gdbtypes.h (struct type) : Add asserts. + 2021-01-23 Lancelot SIX * Makefile.in (SELFTESTS_SRCS): Add diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 115f078787bc..b66b89c7e564 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5518,7 +5518,7 @@ copy_type_recursive (struct objfile *objfile, copy the entire thing and then update specific fields as needed. */ *TYPE_MAIN_TYPE (new_type) = *TYPE_MAIN_TYPE (type); - new_type->set_owner (type->arch ()); + new_type->set_owner (get_type_arch (type)); if (type->name ()) new_type->set_name (xstrdup (type->name ())); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 30e8ac542604..2e0b01a37dfb 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1245,6 +1245,8 @@ struct type /* Set the owner of the type to be OBJFILE. */ void set_owner (objfile *objfile) { + gdb_assert (objfile != nullptr); + this->main_type->m_owner.objfile = objfile; this->main_type->m_flag_objfile_owned = true; } @@ -1252,6 +1254,8 @@ struct type /* Set the owner of the type to be ARCH. */ void set_owner (gdbarch *arch) { + gdb_assert (arch != nullptr); + this->main_type->m_owner.gdbarch = arch; this->main_type->m_flag_objfile_owned = false; }