|
|
a094f6 |
commit 88dfca6c43c11dea69db24cfb87e6821e63e29b2
|
|
|
a094f6 |
Author: Ulrich Weigand <ulrich.weigand@de.ibm.com>
|
|
|
a094f6 |
Date: Tue Sep 6 17:26:32 2016 +0200
|
|
|
a094f6 |
|
|
|
a094f6 |
Add some missing arch_..._type helpers
|
|
|
a094f6 |
|
|
|
a094f6 |
gdbtypes provides a number of helper routines that can be called instead of
|
|
|
a094f6 |
using arch_type directly to create a type of a particular kind. This patch
|
|
|
a094f6 |
adds two additional such routines that have been missing so far, to allow
|
|
|
a094f6 |
creation of TYPE_CODE_DECFLOAT and TYPE_CODE_POINTER types.
|
|
|
a094f6 |
|
|
|
a094f6 |
The patch also changes a number of places to use the new helper routines
|
|
|
a094f6 |
instead of calling arch_type directly. No functional change intended.
|
|
|
a094f6 |
|
|
|
a094f6 |
gdb/ChangeLog:
|
|
|
a094f6 |
|
|
|
a094f6 |
* gdbtypes.h (arch_decfloat_type): New prototype.
|
|
|
a094f6 |
(arch_pointer_type): Likewise.
|
|
|
a094f6 |
* gdbtypes.c (arch_decfloat_type): New function.
|
|
|
a094f6 |
(arch_pointer_type): Likewise.
|
|
|
a094f6 |
(gdbtypes_post_init): Use arch_decfloat_type.
|
|
|
a094f6 |
* avr-tdep.c (avr_gdbarch_init): Use arch_pointer_type.
|
|
|
a094f6 |
* ft32-tdep.c (ft32_gdbarch_init): Likewise.
|
|
|
a094f6 |
* m32c-tdep.c (make_types): Likewise.
|
|
|
a094f6 |
* rl78-tdep.c (rl78_gdbarch_init): Likewise.
|
|
|
a094f6 |
|
|
|
a094f6 |
Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
|
|
|
a094f6 |
|
|
|
a094f6 |
### a/gdb/ChangeLog
|
|
|
a094f6 |
### b/gdb/ChangeLog
|
|
|
a094f6 |
## -1,5 +1,17 @@
|
|
|
a094f6 |
2016-09-05 Ulrich Weigand <uweigand@de.ibm.com>
|
|
|
a094f6 |
|
|
|
a094f6 |
+ * gdbtypes.h (arch_decfloat_type): New prototype.
|
|
|
a094f6 |
+ (arch_pointer_type): Likewise.
|
|
|
a094f6 |
+ * gdbtypes.c (arch_decfloat_type): New function.
|
|
|
a094f6 |
+ (arch_pointer_type): Likewise.
|
|
|
a094f6 |
+ (gdbtypes_post_init): Use arch_decfloat_type.
|
|
|
a094f6 |
+ * avr-tdep.c (avr_gdbarch_init): Use arch_pointer_type.
|
|
|
a094f6 |
+ * ft32-tdep.c (ft32_gdbarch_init): Likewise.
|
|
|
a094f6 |
+ * m32c-tdep.c (make_types): Likewise.
|
|
|
a094f6 |
+ * rl78-tdep.c (rl78_gdbarch_init): Likewise.
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+2016-09-05 Ulrich Weigand <uweigand@de.ibm.com>
|
|
|
a094f6 |
+
|
|
|
a094f6 |
* gdbtypes.c (set_type_code): New function.
|
|
|
a094f6 |
(init_type, arch_type): Use it.
|
|
|
a094f6 |
|
|
|
a094f6 |
Index: gdb-7.6.1/gdb/avr-tdep.c
|
|
|
a094f6 |
===================================================================
|
|
|
a094f6 |
--- gdb-7.6.1.orig/gdb/avr-tdep.c 2017-03-11 21:27:41.914206796 +0100
|
|
|
a094f6 |
+++ gdb-7.6.1/gdb/avr-tdep.c 2017-03-11 21:27:46.928242088 +0100
|
|
|
a094f6 |
@@ -1390,9 +1390,8 @@
|
|
|
a094f6 |
be defined. */
|
|
|
a094f6 |
tdep->void_type = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
|
|
|
a094f6 |
tdep->func_void_type = make_function_type (tdep->void_type, NULL);
|
|
|
a094f6 |
- tdep->pc_type = arch_type (gdbarch, TYPE_CODE_PTR, 4, NULL);
|
|
|
a094f6 |
- TYPE_TARGET_TYPE (tdep->pc_type) = tdep->func_void_type;
|
|
|
a094f6 |
- TYPE_UNSIGNED (tdep->pc_type) = 1;
|
|
|
a094f6 |
+ tdep->pc_type = arch_pointer_type (gdbarch, 4 * TARGET_CHAR_BIT, NULL,
|
|
|
a094f6 |
+ tdep->func_void_type);
|
|
|
a094f6 |
|
|
|
a094f6 |
set_gdbarch_short_bit (gdbarch, 2 * TARGET_CHAR_BIT);
|
|
|
a094f6 |
set_gdbarch_int_bit (gdbarch, 2 * TARGET_CHAR_BIT);
|
|
|
a094f6 |
Index: gdb-7.6.1/gdb/gdbtypes.c
|
|
|
a094f6 |
===================================================================
|
|
|
a094f6 |
--- gdb-7.6.1.orig/gdb/gdbtypes.c 2017-03-11 21:27:41.914206796 +0100
|
|
|
a094f6 |
+++ gdb-7.6.1/gdb/gdbtypes.c 2017-03-11 21:29:16.324862413 +0100
|
|
|
a094f6 |
@@ -3932,7 +3932,7 @@
|
|
|
a094f6 |
|
|
|
a094f6 |
struct type *
|
|
|
a094f6 |
arch_type (struct gdbarch *gdbarch,
|
|
|
a094f6 |
- enum type_code code, LONGEST length, char *name)
|
|
|
a094f6 |
+ enum type_code code, LONGEST length, const char *name)
|
|
|
a094f6 |
{
|
|
|
a094f6 |
struct type *type;
|
|
|
a094f6 |
|
|
|
a094f6 |
@@ -4023,6 +4023,18 @@
|
|
|
a094f6 |
return t;
|
|
|
a094f6 |
}
|
|
|
a094f6 |
|
|
|
a094f6 |
+/* Allocate a TYPE_CODE_DECFLOAT type structure associated with GDBARCH.
|
|
|
a094f6 |
+ BIT is the type size in bits. NAME is the type name. */
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+struct type *
|
|
|
a094f6 |
+arch_decfloat_type (struct gdbarch *gdbarch, int bit, const char *name)
|
|
|
a094f6 |
+{
|
|
|
a094f6 |
+ struct type *t;
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ t = arch_type (gdbarch, TYPE_CODE_DECFLOAT, bit / TARGET_CHAR_BIT, name);
|
|
|
a094f6 |
+ return t;
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
/* Allocate a TYPE_CODE_COMPLEX type structure associated with GDBARCH.
|
|
|
a094f6 |
NAME is the type name. TARGET_TYPE is the component float type. */
|
|
|
a094f6 |
|
|
|
a094f6 |
@@ -4038,6 +4050,23 @@
|
|
|
a094f6 |
return t;
|
|
|
a094f6 |
}
|
|
|
a094f6 |
|
|
|
a094f6 |
+/* Allocate a TYPE_CODE_PTR type structure associated with GDBARCH.
|
|
|
a094f6 |
+ BIT is the pointer type size in bits. NAME is the type name.
|
|
|
a094f6 |
+ TARGET_TYPE is the pointer target type. Always sets the pointer type's
|
|
|
a094f6 |
+ TYPE_UNSIGNED flag. */
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+struct type *
|
|
|
a094f6 |
+arch_pointer_type (struct gdbarch *gdbarch,
|
|
|
a094f6 |
+ int bit, const char *name, struct type *target_type)
|
|
|
a094f6 |
+{
|
|
|
a094f6 |
+ struct type *t;
|
|
|
a094f6 |
+
|
|
|
a094f6 |
+ t = arch_type (gdbarch, TYPE_CODE_PTR, bit / TARGET_CHAR_BIT, name);
|
|
|
a094f6 |
+ TYPE_TARGET_TYPE (t) = target_type;
|
|
|
a094f6 |
+ TYPE_UNSIGNED (t) = 1;
|
|
|
a094f6 |
+ return t;
|
|
|
a094f6 |
+}
|
|
|
a094f6 |
+
|
|
|
a094f6 |
/* Allocate a TYPE_CODE_FLAGS type structure associated with GDBARCH.
|
|
|
a094f6 |
NAME is the type name. LENGTH is the size of the flag word in bytes. */
|
|
|
a094f6 |
|
|
|
a094f6 |
@@ -4235,11 +4264,11 @@
|
|
|
a094f6 |
/* The following three are about decimal floating point types, which
|
|
|
a094f6 |
are 32-bits, 64-bits and 128-bits respectively. */
|
|
|
a094f6 |
builtin_type->builtin_decfloat
|
|
|
a094f6 |
- = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 32 / 8, "_Decimal32");
|
|
|
a094f6 |
+ = arch_decfloat_type (gdbarch, 32, "_Decimal32");
|
|
|
a094f6 |
builtin_type->builtin_decdouble
|
|
|
a094f6 |
- = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 64 / 8, "_Decimal64");
|
|
|
a094f6 |
+ = arch_decfloat_type (gdbarch, 64, "_Decimal64");
|
|
|
a094f6 |
builtin_type->builtin_declong
|
|
|
a094f6 |
- = arch_type (gdbarch, TYPE_CODE_DECFLOAT, 128 / 8, "_Decimal128");
|
|
|
a094f6 |
+ = arch_decfloat_type (gdbarch, 128, "_Decimal128");
|
|
|
a094f6 |
|
|
|
a094f6 |
/* "True" character types. */
|
|
|
a094f6 |
builtin_type->builtin_true_char
|
|
|
a094f6 |
Index: gdb-7.6.1/gdb/gdbtypes.h
|
|
|
a094f6 |
===================================================================
|
|
|
a094f6 |
--- gdb-7.6.1.orig/gdb/gdbtypes.h 2017-03-11 21:27:41.914206796 +0100
|
|
|
a094f6 |
+++ gdb-7.6.1/gdb/gdbtypes.h 2017-03-11 21:29:02.861770587 +0100
|
|
|
a094f6 |
@@ -1547,14 +1547,17 @@
|
|
|
a094f6 |
|
|
|
a094f6 |
/* Helper functions to construct architecture-owned types. */
|
|
|
a094f6 |
extern struct type *arch_type (struct gdbarch *, enum type_code, LONGEST,
|
|
|
a094f6 |
- char *);
|
|
|
a094f6 |
+ const char *);
|
|
|
a094f6 |
extern struct type *arch_integer_type (struct gdbarch *, int, int, char *);
|
|
|
a094f6 |
extern struct type *arch_character_type (struct gdbarch *, int, int, char *);
|
|
|
a094f6 |
extern struct type *arch_boolean_type (struct gdbarch *, int, int, char *);
|
|
|
a094f6 |
extern struct type *arch_float_type (struct gdbarch *, int, char *,
|
|
|
a094f6 |
const struct floatformat **);
|
|
|
a094f6 |
+extern struct type *arch_decfloat_type (struct gdbarch *, int, const char *);
|
|
|
a094f6 |
extern struct type *arch_complex_type (struct gdbarch *, char *,
|
|
|
a094f6 |
struct type *);
|
|
|
a094f6 |
+extern struct type *arch_pointer_type (struct gdbarch *, int, const char *,
|
|
|
a094f6 |
+ struct type *);
|
|
|
a094f6 |
|
|
|
a094f6 |
/* Helper functions to construct a struct or record type. An
|
|
|
a094f6 |
initially empty type is created using arch_composite_type().
|
|
|
a094f6 |
Index: gdb-7.6.1/gdb/m32c-tdep.c
|
|
|
a094f6 |
===================================================================
|
|
|
a094f6 |
--- gdb-7.6.1.orig/gdb/m32c-tdep.c 2017-03-11 21:27:41.914206796 +0100
|
|
|
a094f6 |
+++ gdb-7.6.1/gdb/m32c-tdep.c 2017-03-11 21:27:46.930242102 +0100
|
|
|
a094f6 |
@@ -194,27 +194,18 @@
|
|
|
a094f6 |
this is called, so we avoid using them. */
|
|
|
a094f6 |
tdep->voyd = arch_type (arch, TYPE_CODE_VOID, 1, "void");
|
|
|
a094f6 |
tdep->ptr_voyd
|
|
|
a094f6 |
- = arch_type (arch, TYPE_CODE_PTR, gdbarch_ptr_bit (arch) / TARGET_CHAR_BIT,
|
|
|
a094f6 |
- NULL);
|
|
|
a094f6 |
- TYPE_TARGET_TYPE (tdep->ptr_voyd) = tdep->voyd;
|
|
|
a094f6 |
- TYPE_UNSIGNED (tdep->ptr_voyd) = 1;
|
|
|
a094f6 |
+ = arch_pointer_type (arch, gdbarch_ptr_bit (arch), NULL, tdep->voyd);
|
|
|
a094f6 |
tdep->func_voyd = lookup_function_type (tdep->voyd);
|
|
|
a094f6 |
|
|
|
a094f6 |
xsnprintf (type_name, sizeof (type_name), "%s_data_addr_t",
|
|
|
a094f6 |
gdbarch_bfd_arch_info (arch)->printable_name);
|
|
|
a094f6 |
tdep->data_addr_reg_type
|
|
|
a094f6 |
- = arch_type (arch, TYPE_CODE_PTR, data_addr_reg_bits / TARGET_CHAR_BIT,
|
|
|
a094f6 |
- xstrdup (type_name));
|
|
|
a094f6 |
- TYPE_TARGET_TYPE (tdep->data_addr_reg_type) = tdep->voyd;
|
|
|
a094f6 |
- TYPE_UNSIGNED (tdep->data_addr_reg_type) = 1;
|
|
|
a094f6 |
+ = arch_pointer_type (arch, data_addr_reg_bits, type_name, tdep->voyd);
|
|
|
a094f6 |
|
|
|
a094f6 |
xsnprintf (type_name, sizeof (type_name), "%s_code_addr_t",
|
|
|
a094f6 |
gdbarch_bfd_arch_info (arch)->printable_name);
|
|
|
a094f6 |
tdep->code_addr_reg_type
|
|
|
a094f6 |
- = arch_type (arch, TYPE_CODE_PTR, code_addr_reg_bits / TARGET_CHAR_BIT,
|
|
|
a094f6 |
- xstrdup (type_name));
|
|
|
a094f6 |
- TYPE_TARGET_TYPE (tdep->code_addr_reg_type) = tdep->func_voyd;
|
|
|
a094f6 |
- TYPE_UNSIGNED (tdep->code_addr_reg_type) = 1;
|
|
|
a094f6 |
+ = arch_pointer_type (arch, code_addr_reg_bits, type_name, tdep->func_voyd);
|
|
|
a094f6 |
|
|
|
a094f6 |
tdep->uint8 = arch_integer_type (arch, 8, 1, "uint8_t");
|
|
|
a094f6 |
tdep->uint16 = arch_integer_type (arch, 16, 1, "uint16_t");
|