]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: ensure the cast in gdbarch_tdep is valid
authorAndrew Burgess <aburgess@redhat.com>
Thu, 19 May 2022 12:55:41 +0000 (13:55 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Thu, 21 Jul 2022 14:19:43 +0000 (15:19 +0100)
commitc44885db3b56c83a12e88a176c03f2a2268428b8
tree9228ea030e570e4eea98ac41939b296a6a61971c
parent11da1b13b313ae46c84008ebf096ffed1701e3c1
gdb: ensure the cast in gdbarch_tdep is valid

This commit makes use of gdb::checked_static_cast when casting the
generic gdbarch_tdep pointer to a specific sub-class type.  This means
that, when compiled in developer mode, GDB will validate that the cast
is correct.

In order to use gdb::checked_static_cast the types involved must have
RTTI, which is why the gdbarch_tdep base class now has a virtual
destructor.

Assuming there are no bugs in GDB where we cast a gdbarch_tdep pointer
to the wrong type, then there should be no changes after this commit.

If any bugs do exist, then GDB will now assert (in a developer build).
gdb/gdbarch.h