aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Brobecker <brobecker@adacore.com>2020-11-23 21:48:23 -0500
committerJoel Brobecker <brobecker@adacore.com>2020-11-23 21:48:23 -0500
commitd19937a74c51872e8bbff6e37d9b89b202519b07 (patch)
treea71a396d5b956b873682cf8829db491886c1fed3
parent2a12c336b9d55189780846324eda98c66d543de7 (diff)
downloadgdb-d19937a74c51872e8bbff6e37d9b89b202519b07.zip
gdb-d19937a74c51872e8bbff6e37d9b89b202519b07.tar.gz
gdb-d19937a74c51872e8bbff6e37d9b89b202519b07.tar.bz2
Make fixed_point_type_base_type a method of struct type
As suggested by Simon, to logically connect this function to the object it inspects. Note that, logically, this method should be "const". Unfortunately, the implementation iterates on struct type objects starting with "this", and thus trying to declare the method "const" triggers a compilation error. gdb/ChangeLog: * gdbtypes.h (struct type) <fixed_point_type_base_type> New method, replacing the fixed_point_type_base_type function. All callers updated throughout this project. (fixed_point_type_base_type): Remove declaration. * gdbtypes.c (type::fixed_point_type_base_type): Replaces fixed_point_type_base_type. Adjust implementation accordingly.
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/ada-valprint.c2
-rw-r--r--gdb/gdbtypes.c6
-rw-r--r--gdb/gdbtypes.h17
-rw-r--r--gdb/valprint.c2
-rw-r--r--gdb/value.c2
6 files changed, 25 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5e34c7e..3db6365 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,14 @@
2020-11-24 Joel Brobecker <brobecker@adacore.com>
+ * gdbtypes.h (struct type) <fixed_point_type_base_type> New method,
+ replacing the fixed_point_type_base_type function. All callers
+ updated throughout this project.
+ (fixed_point_type_base_type): Remove declaration.
+ * gdbtypes.c (type::fixed_point_type_base_type): Replaces
+ fixed_point_type_base_type. Adjust implementation accordingly.
+
+2020-11-24 Joel Brobecker <brobecker@adacore.com>
+
* gdbtypes.h (struct type) <fixed_point_info, set_fixed_point_info>:
New methods.
(INIT_FIXED_POINT_SPECIFIC): Adjust.
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 482069a..6ddb584 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -1028,7 +1028,7 @@ ada_value_print_1 (struct value *val, struct ui_file *stream, int recurse,
}
if (is_fixed_point_type (type))
- type = fixed_point_type_base_type (type);
+ type = type->fixed_point_type_base_type ();
switch (type->code ())
{
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index f0d9c24..fa4e8f0 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5866,8 +5866,10 @@ is_fixed_point_type (struct type *type)
/* See gdbtypes.h. */
struct type *
-fixed_point_type_base_type (struct type *type)
+type::fixed_point_type_base_type ()
{
+ struct type *type = this;
+
while (check_typedef (type)->code () == TYPE_CODE_RANGE)
type = TYPE_TARGET_TYPE (check_typedef (type));
type = check_typedef (type);
@@ -5881,7 +5883,7 @@ fixed_point_type_base_type (struct type *type)
const gdb_mpq &
fixed_point_scaling_factor (struct type *type)
{
- type = fixed_point_type_base_type (type);
+ type = type->fixed_point_type_base_type ();
return type->fixed_point_info ().scaling_factor;
}
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index c9d2343..88fb0e7 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1215,6 +1215,15 @@ struct type
this->main_type->type_specific.fixed_point_info = info;
}
+ /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its base type.
+
+ In other words, this returns the type after having peeled all
+ intermediate type layers (such as TYPE_CODE_RANGE, for instance).
+ The TYPE_CODE of the type returned is guaranteed to be
+ a TYPE_CODE_FIXED_POINT. */
+
+ struct type *fixed_point_type_base_type ();
+
/* * Return the dynamic property of the requested KIND from this type's
list of dynamic properties. */
dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
@@ -2587,14 +2596,6 @@ extern int type_not_associated (const struct type *type);
a range type whose base type is a TYPE_CODE_FIXED_POINT. */
extern bool is_fixed_point_type (struct type *type);
-/* Assuming that TYPE is a fixed point type, return its base type.
-
- In other words, this returns the type after having peeled all
- intermediate type layers (such as TYPE_CODE_RANGE, for instance).
- The TYPE_CODE of the type returned is guaranteed to be
- a TYPE_CODE_FIXED_POINT. */
-extern struct type *fixed_point_type_base_type (struct type *type);
-
/* Given TYPE, which is a fixed point type, return its scaling factor. */
extern const gdb_mpq &fixed_point_scaling_factor (struct type *type);
diff --git a/gdb/valprint.c b/gdb/valprint.c
index f428eb5..6e9262e 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -871,7 +871,7 @@ generic_value_print (struct value *val, struct ui_file *stream, int recurse,
type = check_typedef (type);
if (is_fixed_point_type (type))
- type = fixed_point_type_base_type (type);
+ type = type->fixed_point_type_base_type ();
switch (type->code ())
{
diff --git a/gdb/value.c b/gdb/value.c
index a122674..f6c1a36 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2759,7 +2759,7 @@ LONGEST
unpack_long (struct type *type, const gdb_byte *valaddr)
{
if (is_fixed_point_type (type))
- type = fixed_point_type_base_type (type);
+ type = type->fixed_point_type_base_type ();
enum bfd_endian byte_order = type_byte_order (type);
enum type_code code = type->code ();