aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbtypes.c
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2016-09-06 17:26:32 +0200
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2016-09-06 17:26:32 +0200
commit88dfca6c43c11dea69db24cfb87e6821e63e29b2 (patch)
tree0efdcd0b229d16125cbf2423247685231a9bba28 /gdb/gdbtypes.c
parentae438bc5c06b770c00f37e4ed244707ce3ab9ff4 (diff)
downloadgdb-88dfca6c43c11dea69db24cfb87e6821e63e29b2.zip
gdb-88dfca6c43c11dea69db24cfb87e6821e63e29b2.tar.gz
gdb-88dfca6c43c11dea69db24cfb87e6821e63e29b2.tar.bz2
Add some missing arch_..._type helpers
gdbtypes provides a number of helper routines that can be called instead of using arch_type directly to create a type of a particular kind. This patch adds two additional such routines that have been missing so far, to allow creation of TYPE_CODE_DECFLOAT and TYPE_CODE_POINTER types. The patch also changes a number of places to use the new helper routines instead of calling arch_type directly. No functional change intended. gdb/ChangeLog: * gdbtypes.h (arch_decfloat_type): New prototype. (arch_pointer_type): Likewise. * gdbtypes.c (arch_decfloat_type): New function. (arch_pointer_type): Likewise. (gdbtypes_post_init): Use arch_decfloat_type. * avr-tdep.c (avr_gdbarch_init): Use arch_pointer_type. * ft32-tdep.c (ft32_gdbarch_init): Likewise. * m32c-tdep.c (make_types): Likewise. * rl78-tdep.c (rl78_gdbarch_init): Likewise. Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Diffstat (limited to 'gdb/gdbtypes.c')
-rw-r--r--gdb/gdbtypes.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 241bf08..45fdf84 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4740,6 +4740,18 @@ arch_float_type (struct gdbarch *gdbarch,
return t;
}
+/* Allocate a TYPE_CODE_DECFLOAT type structure associated with GDBARCH.
+ BIT is the type size in bits. NAME is the type name. */
+
+struct type *
+arch_decfloat_type (struct gdbarch *gdbarch, int bit, const char *name)
+{
+ struct type *t;
+
+ t = arch_type (gdbarch, TYPE_CODE_DECFLOAT, bit / TARGET_CHAR_BIT, name);
+ return t;
+}
+
/* Allocate a TYPE_CODE_COMPLEX type structure associated with GDBARCH.
NAME is the type name. TARGET_TYPE is the component float type. */
@@ -4755,6 +4767,23 @@ arch_complex_type (struct gdbarch *gdbarch,
return t;
}
+/* Allocate a TYPE_CODE_PTR type structure associated with GDBARCH.
+ BIT is the pointer type size in bits. NAME is the type name.
+ TARGET_TYPE is the pointer target type. Always sets the pointer type's
+ TYPE_UNSIGNED flag. */
+
+struct type *
+arch_pointer_type (struct gdbarch *gdbarch,
+ int bit, const char *name, struct type *target_type)
+{
+ struct type *t;
+
+ t = arch_type (gdbarch, TYPE_CODE_PTR, bit / TARGET_CHAR_BIT, name);
+ TYPE_TARGET_TYPE (t) = target_type;
+ TYPE_UNSIGNED (t) = 1;
+ return t;
+}
+
/* Allocate a TYPE_CODE_FLAGS type structure associated with GDBARCH.
NAME is the type name. LENGTH is the size of the flag word in bytes. */
@@ -4971,11 +5000,11 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
/* The following three are about decimal floating point types, which
are 32-bits, 64-bits and 128-bits respectively. */
builtin_type->builtin_decfloat
- = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 32 / 8, "_Decimal32");
+ = arch_decfloat_type (gdbarch, 32, "_Decimal32");
builtin_type->builtin_decdouble
- = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 64 / 8, "_Decimal64");
+ = arch_decfloat_type (gdbarch, 64, "_Decimal64");
builtin_type->builtin_declong
- = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 128 / 8, "_Decimal128");
+ = arch_decfloat_type (gdbarch, 128, "_Decimal128");
/* "True" character types. */
builtin_type->builtin_true_char