aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.h
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-07-25 12:07:11 +0100
committerAndrew Burgess <aburgess@redhat.com>2022-07-26 12:04:07 +0100
commitab25d9bbe4a04aefb47d2514b4b02e6035ff769e (patch)
tree4ac73d86e7ca5fe334eab657a3b716b44730270f /gdb/gdbarch.h
parent27121f6740fa2051609b2d781d77c4cd23aa590b (diff)
downloadfsf-binutils-gdb-ab25d9bbe4a04aefb47d2514b4b02e6035ff769e.zip
fsf-binutils-gdb-ab25d9bbe4a04aefb47d2514b4b02e6035ff769e.tar.gz
fsf-binutils-gdb-ab25d9bbe4a04aefb47d2514b4b02e6035ff769e.tar.bz2
gdb: rename gdbarch_tdep struct to fix g++ 4.8 build
After the commit: commit 08106042d9f5fdff60c129bf33190639f1a98b2a Date: Thu May 19 13:20:17 2022 +0100 gdb: move the type cast into gdbarch_tdep GDB would no longer build using g++ 4.8. The issue appears to be some confusion caused by GDB having 'struct gdbarch_tdep', but also a templated function called 'gdbarch_tdep'. Prior to the above commit the gdbarch_tdep function was not templated, and this compiled just fine. Note that the above commit compiles just fine with later versions of g++, so this issue was clearly fixed at some point, though I've not tried to track down exactly when. In this commit I propose to fix the g++ 4.8 build problem by renaming 'struct gdbarch_tdep' to 'struct gdbarch_tdep_base'. This rename better represents that the struct is only ever used as a base class, and removes the overloading of the name, which allows GDB to build with g++ 4.8. I've also updated the comment on 'struct gdbarch_tdep_base' to fix a typo, and the comment on the 'gdbarch_tdep' function, to mention that in maintainer mode a run-time type check is performed.
Diffstat (limited to 'gdb/gdbarch.h')
-rw-r--r--gdb/gdbarch.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 16c7391..3249584 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -61,11 +61,11 @@ struct inferior;
/* The base class for every architecture's tdep sub-class. The virtual
destructor ensures the class has RTTI information, which allows
- gdb::checked_static_cast to be used, the gdbarch_tdep the function. */
+ gdb::checked_static_cast to be used in the gdbarch_tdep function. */
-struct gdbarch_tdep
+struct gdbarch_tdep_base
{
- virtual ~gdbarch_tdep() = default;
+ virtual ~gdbarch_tdep_base() = default;
};
/* The architecture associated with the inferior through the
@@ -151,20 +151,23 @@ using read_core_file_mappings_loop_ftype =
#include "gdbarch-gen.h"
/* An internal function that should _only_ be called from gdbarch_tdep.
- Returns the gdbarch_tdep field held within GDBARCH. */
+ Returns the gdbarch_tdep_base field held within GDBARCH. */
-extern struct gdbarch_tdep *gdbarch_tdep_1 (struct gdbarch *gdbarch);
+extern struct gdbarch_tdep_base *gdbarch_tdep_1 (struct gdbarch *gdbarch);
-/* Return the gdbarch_tdep object held within GDBARCH cast to the type
- TDepType, which should be a sub-class of gdbarch_tdep. There is no
- checking done that the gdbarch_tdep within GDBARCH actually is of the
- type TDepType, we just assume the caller knows what they are doing. */
+/* Return the gdbarch_tdep_base object held within GDBARCH cast to the type
+ TDepType, which should be a sub-class of gdbarch_tdep_base.
+
+ When GDB is compiled in maintainer mode a run-time check is performed
+ that the gdbarch_tdep_base within GDBARCH really is of type TDepType.
+ When GDB is compiled in release mode the run-time check is not
+ performed, and we assume the caller knows what they are doing. */
template<typename TDepType>
static inline TDepType *
gdbarch_tdep (struct gdbarch *gdbarch)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep_1 (gdbarch);
+ struct gdbarch_tdep_base *tdep = gdbarch_tdep_1 (gdbarch);
return gdb::checked_static_cast<TDepType *> (tdep);
}
@@ -293,7 +296,7 @@ extern struct gdbarch_list *gdbarch_list_lookup_by_info (struct gdbarch_list *ar
parameters. set_gdbarch_*() functions are called to complete the
initialization of the object. */
-extern struct gdbarch *gdbarch_alloc (const struct gdbarch_info *info, struct gdbarch_tdep *tdep);
+extern struct gdbarch *gdbarch_alloc (const struct gdbarch_info *info, struct gdbarch_tdep_base *tdep);
/* Helper function. Free a partially-constructed ``struct gdbarch''.