From a8d2e5856f87a658d69018fe1ccd56482eebdd59 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 21 Dec 2017 18:19:17 -0500 Subject: [PATCH] Do not emit "field_type" var if not needed on "maint print c-tdesc" While fiddling a bit with -Wunused-variable, Sergio noticed that "maint print c-tdesc" was always generating code for the "tdesc_type *field_type" variable, even when it wasn't used. This is caught by GCC when using -Wunused-variable, of course. This patch changes the print_c_tdesc class to only output the field declaration when we actually need it. It shouldn't be necessary to do the same with the other variable declarations (type_with_fields and element_type), because they are always if they are declared. The C files in features/ are regenerated, some declarations of field_type are removed, as expected, while some others move to where they are used for the first time. gdb/ChangeLog: * target-descriptions.c (print_c_tdesc) : Don't output field_type declaration, use printf_field_type_assignment instead. : New method. * features/aarch64-core.c, features/aarch64-fpu.c features/arc-arcompact.c, features/arc-v2.c, features/arm/arm-with-iwmmxt.c, features/i386/32bit-core.c, features/i386/32bit-mpx.c, features/i386/32bit-sse.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-mpx.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/or1k.c, features/rs6000/powerpc-7400.c, features/rs6000/powerpc-altivec32.c, features/rs6000/powerpc-altivec32l.c, features/rs6000/powerpc-altivec64.c, features/rs6000/powerpc-altivec64l.c, features/rs6000/powerpc-cell32l.c, features/rs6000/powerpc-cell64l.c, features/rs6000/powerpc-isa205-altivec32l.c, features/rs6000/powerpc-isa205-altivec64l.c, features/rs6000/powerpc-isa205-vsx32l.c, features/rs6000/powerpc-isa205-vsx64l.c, features/rs6000/powerpc-vsx32.c, features/rs6000/powerpc-vsx32l.c, features/rs6000/powerpc-vsx64.c, features/rs6000/powerpc-vsx64l.c, features/s390-gs-linux64.c, features/s390-tevx-linux64.c, features/s390-vx-linux64.c, features/s390x-gs-linux64.c, features/s390x-tevx-linux64.c, features/s390x-vx-linux64.c: Re-generate. --- gdb/ChangeLog | 33 +++++++++++++++ gdb/features/aarch64-core.c | 1 - gdb/features/aarch64-fpu.c | 2 +- gdb/features/arc-arcompact.c | 1 - gdb/features/arc-v2.c | 1 - gdb/features/arm/arm-with-iwmmxt.c | 2 +- gdb/features/i386/32bit-core.c | 1 - gdb/features/i386/32bit-mpx.c | 2 +- gdb/features/i386/32bit-sse.c | 2 +- gdb/features/i386/64bit-avx512.c | 2 +- gdb/features/i386/64bit-core.c | 1 - gdb/features/i386/64bit-mpx.c | 2 +- gdb/features/i386/64bit-sse.c | 2 +- gdb/features/i386/x32-core.c | 1 - gdb/features/or1k.c | 1 - gdb/features/rs6000/powerpc-7400.c | 2 +- gdb/features/rs6000/powerpc-altivec32.c | 2 +- gdb/features/rs6000/powerpc-altivec32l.c | 2 +- gdb/features/rs6000/powerpc-altivec64.c | 2 +- gdb/features/rs6000/powerpc-altivec64l.c | 2 +- gdb/features/rs6000/powerpc-cell32l.c | 2 +- gdb/features/rs6000/powerpc-cell64l.c | 2 +- .../rs6000/powerpc-isa205-altivec32l.c | 2 +- .../rs6000/powerpc-isa205-altivec64l.c | 2 +- gdb/features/rs6000/powerpc-isa205-vsx32l.c | 2 +- gdb/features/rs6000/powerpc-isa205-vsx64l.c | 2 +- gdb/features/rs6000/powerpc-vsx32.c | 2 +- gdb/features/rs6000/powerpc-vsx32l.c | 2 +- gdb/features/rs6000/powerpc-vsx64.c | 2 +- gdb/features/rs6000/powerpc-vsx64l.c | 2 +- gdb/features/s390-gs-linux64.c | 2 +- gdb/features/s390-tevx-linux64.c | 2 +- gdb/features/s390-vx-linux64.c | 2 +- gdb/features/s390x-gs-linux64.c | 2 +- gdb/features/s390x-tevx-linux64.c | 2 +- gdb/features/s390x-vx-linux64.c | 2 +- gdb/target-descriptions.c | 41 +++++++++++-------- 37 files changed, 86 insertions(+), 51 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4f2c5c33c89..1b4b13aba96 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,36 @@ +2017-12-21 Simon Marchi + Sergio Durigan Junior + + * target-descriptions.c (print_c_tdesc) : Don't output + field_type declaration, use printf_field_type_assignment + instead. + : New method. + * features/aarch64-core.c, features/aarch64-fpu.c + features/arc-arcompact.c, features/arc-v2.c, + features/arm/arm-with-iwmmxt.c, features/i386/32bit-core.c, + features/i386/32bit-mpx.c, features/i386/32bit-sse.c, + features/i386/64bit-avx512.c, features/i386/64bit-core.c, + features/i386/64bit-mpx.c, features/i386/64bit-sse.c, + features/i386/x32-core.c, features/or1k.c, + features/rs6000/powerpc-7400.c, + features/rs6000/powerpc-altivec32.c, + features/rs6000/powerpc-altivec32l.c, + features/rs6000/powerpc-altivec64.c, + features/rs6000/powerpc-altivec64l.c, + features/rs6000/powerpc-cell32l.c, + features/rs6000/powerpc-cell64l.c, + features/rs6000/powerpc-isa205-altivec32l.c, + features/rs6000/powerpc-isa205-altivec64l.c, + features/rs6000/powerpc-isa205-vsx32l.c, + features/rs6000/powerpc-isa205-vsx64l.c, + features/rs6000/powerpc-vsx32.c, + features/rs6000/powerpc-vsx32l.c, + features/rs6000/powerpc-vsx64.c, + features/rs6000/powerpc-vsx64l.c, features/s390-gs-linux64.c, + features/s390-tevx-linux64.c, features/s390-vx-linux64.c, + features/s390x-gs-linux64.c, features/s390x-tevx-linux64.c, + features/s390x-vx-linux64.c: Re-generate. + 2017-12-20 Uros Bizjak * rs6000-tdep.c (ppc_deal_with_atomic_sequence): Remove diff --git a/gdb/features/aarch64-core.c b/gdb/features/aarch64-core.c index 618a7ef787c..3707b7e0556 100644 --- a/gdb/features/aarch64-core.c +++ b/gdb/features/aarch64-core.c @@ -10,7 +10,6 @@ create_feature_aarch64_core (struct target_desc *result, long regnum) feature = tdesc_create_feature (result, "org.gnu.gdb.aarch64.core", "aarch64-core.xml"); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_flags (feature, "cpsr_flags", 4); tdesc_add_flag (type_with_fields, 0, "SP"); tdesc_add_flag (type_with_fields, 1, ""); diff --git a/gdb/features/aarch64-fpu.c b/gdb/features/aarch64-fpu.c index 7328eb14d9d..cac3981f7dd 100644 --- a/gdb/features/aarch64-fpu.c +++ b/gdb/features/aarch64-fpu.c @@ -47,8 +47,8 @@ create_feature_aarch64_fpu (struct target_desc *result, long regnum) tdesc_create_vector (feature, "v1i", element_type, 1); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vnd"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "v2d"); tdesc_add_field (type_with_fields, "f", field_type); field_type = tdesc_named_type (feature, "v2u"); diff --git a/gdb/features/arc-arcompact.c b/gdb/features/arc-arcompact.c index 79b6889172a..f81f0a26ba2 100644 --- a/gdb/features/arc-arcompact.c +++ b/gdb/features/arc-arcompact.c @@ -52,7 +52,6 @@ initialize_tdesc_arc_arcompact (void) feature = tdesc_create_feature (result, "org.gnu.gdb.arc.aux-minimal"); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_flags (feature, "status32_type", 4); tdesc_add_flag (type_with_fields, 0, "H"); tdesc_add_bitfield (type_with_fields, "E", 1, 2); diff --git a/gdb/features/arc-v2.c b/gdb/features/arc-v2.c index 9908b4c5ecb..b2254b293cf 100644 --- a/gdb/features/arc-v2.c +++ b/gdb/features/arc-v2.c @@ -52,7 +52,6 @@ initialize_tdesc_arc_v2 (void) feature = tdesc_create_feature (result, "org.gnu.gdb.arc.aux-minimal"); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_flags (feature, "status32_type", 4); tdesc_add_flag (type_with_fields, 0, "H"); tdesc_add_bitfield (type_with_fields, "E", 1, 4); diff --git a/gdb/features/arm/arm-with-iwmmxt.c b/gdb/features/arm/arm-with-iwmmxt.c index 5d6c35762f2..8729285a0ed 100644 --- a/gdb/features/arm/arm-with-iwmmxt.c +++ b/gdb/features/arm/arm-with-iwmmxt.c @@ -45,8 +45,8 @@ initialize_tdesc_arm_with_iwmmxt (void) tdesc_create_vector (feature, "iwmmxt_v2u32", element_type, 2); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "iwmmxt_vec64i"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "iwmmxt_v8u8"); tdesc_add_field (type_with_fields, "u8", field_type); field_type = tdesc_named_type (feature, "iwmmxt_v4u16"); diff --git a/gdb/features/i386/32bit-core.c b/gdb/features/i386/32bit-core.c index de2ce474d50..294e86d81ee 100644 --- a/gdb/features/i386/32bit-core.c +++ b/gdb/features/i386/32bit-core.c @@ -10,7 +10,6 @@ create_feature_i386_32bit_core (struct target_desc *result, long regnum) feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core", "32bit-core.xml"); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_flags (feature, "i386_eflags", 4); tdesc_add_flag (type_with_fields, 0, "CF"); tdesc_add_flag (type_with_fields, 1, ""); diff --git a/gdb/features/i386/32bit-mpx.c b/gdb/features/i386/32bit-mpx.c index 38910d3b159..8f1be3a60f0 100644 --- a/gdb/features/i386/32bit-mpx.c +++ b/gdb/features/i386/32bit-mpx.c @@ -10,8 +10,8 @@ create_feature_i386_32bit_mpx (struct target_desc *result, long regnum) feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx", "32bit-mpx.xml"); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_struct (feature, "br128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint64"); tdesc_add_field (type_with_fields, "lbound", field_type); field_type = tdesc_named_type (feature, "uint64"); diff --git a/gdb/features/i386/32bit-sse.c b/gdb/features/i386/32bit-sse.c index 1c8a7e8010a..cf489603538 100644 --- a/gdb/features/i386/32bit-sse.c +++ b/gdb/features/i386/32bit-sse.c @@ -29,8 +29,8 @@ create_feature_i386_32bit_sse (struct target_desc *result, long regnum) tdesc_create_vector (feature, "v2i64", element_type, 2); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "v4f"); tdesc_add_field (type_with_fields, "v4_float", field_type); field_type = tdesc_named_type (feature, "v2d"); diff --git a/gdb/features/i386/64bit-avx512.c b/gdb/features/i386/64bit-avx512.c index a565f4280ef..e103e43464c 100644 --- a/gdb/features/i386/64bit-avx512.c +++ b/gdb/features/i386/64bit-avx512.c @@ -29,8 +29,8 @@ create_feature_i386_64bit_avx512 (struct target_desc *result, long regnum) tdesc_create_vector (feature, "v2i64", element_type, 2); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "v4f"); tdesc_add_field (type_with_fields, "v4_float", field_type); field_type = tdesc_named_type (feature, "v2d"); diff --git a/gdb/features/i386/64bit-core.c b/gdb/features/i386/64bit-core.c index f4cad06e660..9e39ee42d9a 100644 --- a/gdb/features/i386/64bit-core.c +++ b/gdb/features/i386/64bit-core.c @@ -10,7 +10,6 @@ create_feature_i386_64bit_core (struct target_desc *result, long regnum) feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core", "64bit-core.xml"); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_flags (feature, "i386_eflags", 4); tdesc_add_flag (type_with_fields, 0, "CF"); tdesc_add_flag (type_with_fields, 1, ""); diff --git a/gdb/features/i386/64bit-mpx.c b/gdb/features/i386/64bit-mpx.c index f8730b4feb0..725e76a0dd9 100644 --- a/gdb/features/i386/64bit-mpx.c +++ b/gdb/features/i386/64bit-mpx.c @@ -10,8 +10,8 @@ create_feature_i386_64bit_mpx (struct target_desc *result, long regnum) feature = tdesc_create_feature (result, "org.gnu.gdb.i386.mpx", "64bit-mpx.xml"); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_struct (feature, "br128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint64"); tdesc_add_field (type_with_fields, "lbound", field_type); field_type = tdesc_named_type (feature, "uint64"); diff --git a/gdb/features/i386/64bit-sse.c b/gdb/features/i386/64bit-sse.c index e4f99c2ebbb..2859217f458 100644 --- a/gdb/features/i386/64bit-sse.c +++ b/gdb/features/i386/64bit-sse.c @@ -29,8 +29,8 @@ create_feature_i386_64bit_sse (struct target_desc *result, long regnum) tdesc_create_vector (feature, "v2i64", element_type, 2); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "v4f"); tdesc_add_field (type_with_fields, "v4_float", field_type); field_type = tdesc_named_type (feature, "v2d"); diff --git a/gdb/features/i386/x32-core.c b/gdb/features/i386/x32-core.c index acafc7dace2..c268e11bea9 100644 --- a/gdb/features/i386/x32-core.c +++ b/gdb/features/i386/x32-core.c @@ -10,7 +10,6 @@ create_feature_i386_x32_core (struct target_desc *result, long regnum) feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core", "x32-core.xml"); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_flags (feature, "i386_eflags", 4); tdesc_add_flag (type_with_fields, 0, "CF"); tdesc_add_flag (type_with_fields, 1, ""); diff --git a/gdb/features/or1k.c b/gdb/features/or1k.c index 929a5f92089..9169cae940e 100644 --- a/gdb/features/or1k.c +++ b/gdb/features/or1k.c @@ -16,7 +16,6 @@ initialize_tdesc_or1k (void) feature = tdesc_create_feature (result, "org.gnu.gdb.or1k.group0"); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_flags (feature, "sr_flags", 4); tdesc_add_flag (type_with_fields, 0, "SM"); tdesc_add_flag (type_with_fields, 1, "TEE"); diff --git a/gdb/features/rs6000/powerpc-7400.c b/gdb/features/rs6000/powerpc-7400.c index ba9f12c94b1..58f8a69a1e2 100644 --- a/gdb/features/rs6000/powerpc-7400.c +++ b/gdb/features/rs6000/powerpc-7400.c @@ -152,8 +152,8 @@ initialize_tdesc_powerpc_7400 (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-altivec32.c b/gdb/features/rs6000/powerpc-altivec32.c index 9cb83cad1c2..bbb36c8aa59 100644 --- a/gdb/features/rs6000/powerpc-altivec32.c +++ b/gdb/features/rs6000/powerpc-altivec32.c @@ -104,8 +104,8 @@ initialize_tdesc_powerpc_altivec32 (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-altivec32l.c b/gdb/features/rs6000/powerpc-altivec32l.c index afaf8ed3e41..81862cb9ef4 100644 --- a/gdb/features/rs6000/powerpc-altivec32l.c +++ b/gdb/features/rs6000/powerpc-altivec32l.c @@ -108,8 +108,8 @@ initialize_tdesc_powerpc_altivec32l (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-altivec64.c b/gdb/features/rs6000/powerpc-altivec64.c index 94041e113b4..f7a7c729637 100644 --- a/gdb/features/rs6000/powerpc-altivec64.c +++ b/gdb/features/rs6000/powerpc-altivec64.c @@ -104,8 +104,8 @@ initialize_tdesc_powerpc_altivec64 (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-altivec64l.c b/gdb/features/rs6000/powerpc-altivec64l.c index c7ed171cfa8..ce0bc86137e 100644 --- a/gdb/features/rs6000/powerpc-altivec64l.c +++ b/gdb/features/rs6000/powerpc-altivec64l.c @@ -108,8 +108,8 @@ initialize_tdesc_powerpc_altivec64l (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-cell32l.c b/gdb/features/rs6000/powerpc-cell32l.c index 390d7b28824..74c42f94bcb 100644 --- a/gdb/features/rs6000/powerpc-cell32l.c +++ b/gdb/features/rs6000/powerpc-cell32l.c @@ -110,8 +110,8 @@ initialize_tdesc_powerpc_cell32l (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-cell64l.c b/gdb/features/rs6000/powerpc-cell64l.c index 39890baf83f..cbfda4c50ab 100644 --- a/gdb/features/rs6000/powerpc-cell64l.c +++ b/gdb/features/rs6000/powerpc-cell64l.c @@ -110,8 +110,8 @@ initialize_tdesc_powerpc_cell64l (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-isa205-altivec32l.c b/gdb/features/rs6000/powerpc-isa205-altivec32l.c index 203bb4a71a3..09f5c075c8a 100644 --- a/gdb/features/rs6000/powerpc-isa205-altivec32l.c +++ b/gdb/features/rs6000/powerpc-isa205-altivec32l.c @@ -108,8 +108,8 @@ initialize_tdesc_powerpc_isa205_altivec32l (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-isa205-altivec64l.c b/gdb/features/rs6000/powerpc-isa205-altivec64l.c index 8f66a161ff0..246fcef085c 100644 --- a/gdb/features/rs6000/powerpc-isa205-altivec64l.c +++ b/gdb/features/rs6000/powerpc-isa205-altivec64l.c @@ -108,8 +108,8 @@ initialize_tdesc_powerpc_isa205_altivec64l (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-isa205-vsx32l.c b/gdb/features/rs6000/powerpc-isa205-vsx32l.c index fc0f615cd0b..2a6e232e994 100644 --- a/gdb/features/rs6000/powerpc-isa205-vsx32l.c +++ b/gdb/features/rs6000/powerpc-isa205-vsx32l.c @@ -108,8 +108,8 @@ initialize_tdesc_powerpc_isa205_vsx32l (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-isa205-vsx64l.c b/gdb/features/rs6000/powerpc-isa205-vsx64l.c index 3313d04a6ab..d0e32f29b1b 100644 --- a/gdb/features/rs6000/powerpc-isa205-vsx64l.c +++ b/gdb/features/rs6000/powerpc-isa205-vsx64l.c @@ -108,8 +108,8 @@ initialize_tdesc_powerpc_isa205_vsx64l (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-vsx32.c b/gdb/features/rs6000/powerpc-vsx32.c index 1a824a825f3..9eafb1c4823 100644 --- a/gdb/features/rs6000/powerpc-vsx32.c +++ b/gdb/features/rs6000/powerpc-vsx32.c @@ -104,8 +104,8 @@ initialize_tdesc_powerpc_vsx32 (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-vsx32l.c b/gdb/features/rs6000/powerpc-vsx32l.c index f5bf11e675e..f08df14f9e8 100644 --- a/gdb/features/rs6000/powerpc-vsx32l.c +++ b/gdb/features/rs6000/powerpc-vsx32l.c @@ -108,8 +108,8 @@ initialize_tdesc_powerpc_vsx32l (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-vsx64.c b/gdb/features/rs6000/powerpc-vsx64.c index 601df398e08..7991115cf6e 100644 --- a/gdb/features/rs6000/powerpc-vsx64.c +++ b/gdb/features/rs6000/powerpc-vsx64.c @@ -104,8 +104,8 @@ initialize_tdesc_powerpc_vsx64 (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/rs6000/powerpc-vsx64l.c b/gdb/features/rs6000/powerpc-vsx64l.c index d34bd811fb6..1726e6754fd 100644 --- a/gdb/features/rs6000/powerpc-vsx64l.c +++ b/gdb/features/rs6000/powerpc-vsx64l.c @@ -108,8 +108,8 @@ initialize_tdesc_powerpc_vsx64l (void) tdesc_create_vector (feature, "v16i8", element_type, 16); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "uint128"); tdesc_add_field (type_with_fields, "uint128", field_type); field_type = tdesc_named_type (feature, "v4f"); diff --git a/gdb/features/s390-gs-linux64.c b/gdb/features/s390-gs-linux64.c index 126835b4fbf..1416183d3db 100644 --- a/gdb/features/s390-gs-linux64.c +++ b/gdb/features/s390-gs-linux64.c @@ -135,8 +135,8 @@ initialize_tdesc_s390_gs_linux64 (void) tdesc_create_vector (feature, "v2i64", element_type, 2); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "v4f"); tdesc_add_field (type_with_fields, "v4_float", field_type); field_type = tdesc_named_type (feature, "v2d"); diff --git a/gdb/features/s390-tevx-linux64.c b/gdb/features/s390-tevx-linux64.c index a9ee9e155d4..ae62e8de372 100644 --- a/gdb/features/s390-tevx-linux64.c +++ b/gdb/features/s390-tevx-linux64.c @@ -135,8 +135,8 @@ initialize_tdesc_s390_tevx_linux64 (void) tdesc_create_vector (feature, "v2i64", element_type, 2); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "v4f"); tdesc_add_field (type_with_fields, "v4_float", field_type); field_type = tdesc_named_type (feature, "v2d"); diff --git a/gdb/features/s390-vx-linux64.c b/gdb/features/s390-vx-linux64.c index b6c5dda128f..d3ec0814608 100644 --- a/gdb/features/s390-vx-linux64.c +++ b/gdb/features/s390-vx-linux64.c @@ -113,8 +113,8 @@ initialize_tdesc_s390_vx_linux64 (void) tdesc_create_vector (feature, "v2i64", element_type, 2); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "v4f"); tdesc_add_field (type_with_fields, "v4_float", field_type); field_type = tdesc_named_type (feature, "v2d"); diff --git a/gdb/features/s390x-gs-linux64.c b/gdb/features/s390x-gs-linux64.c index 5ab3e3d8c53..d253a09997a 100644 --- a/gdb/features/s390x-gs-linux64.c +++ b/gdb/features/s390x-gs-linux64.c @@ -119,8 +119,8 @@ initialize_tdesc_s390x_gs_linux64 (void) tdesc_create_vector (feature, "v2i64", element_type, 2); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "v4f"); tdesc_add_field (type_with_fields, "v4_float", field_type); field_type = tdesc_named_type (feature, "v2d"); diff --git a/gdb/features/s390x-tevx-linux64.c b/gdb/features/s390x-tevx-linux64.c index e5ecedfc2ab..1ac3249a054 100644 --- a/gdb/features/s390x-tevx-linux64.c +++ b/gdb/features/s390x-tevx-linux64.c @@ -119,8 +119,8 @@ initialize_tdesc_s390x_tevx_linux64 (void) tdesc_create_vector (feature, "v2i64", element_type, 2); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "v4f"); tdesc_add_field (type_with_fields, "v4_float", field_type); field_type = tdesc_named_type (feature, "v2d"); diff --git a/gdb/features/s390x-vx-linux64.c b/gdb/features/s390x-vx-linux64.c index 1f243496cbf..2e3d3824a26 100644 --- a/gdb/features/s390x-vx-linux64.c +++ b/gdb/features/s390x-vx-linux64.c @@ -97,8 +97,8 @@ initialize_tdesc_s390x_vx_linux64 (void) tdesc_create_vector (feature, "v2i64", element_type, 2); tdesc_type_with_fields *type_with_fields; - tdesc_type *field_type; type_with_fields = tdesc_create_union (feature, "vec128"); + tdesc_type *field_type; field_type = tdesc_named_type (feature, "v4f"); tdesc_add_field (type_with_fields, "v4_float", field_type); field_type = tdesc_named_type (feature, "v2d"); diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index 88ac55f404a..5dcc4c4c5c0 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -1894,13 +1894,6 @@ public: m_printed_type_with_fields = true; } - if (!type->fields.empty () - && !m_printed_field_type) - { - printf_unfiltered (" tdesc_type *field_type;\n"); - m_printed_field_type = true; - } - switch (type->kind) { case TDESC_TYPE_STRUCT: @@ -1949,8 +1942,8 @@ public: } else { - printf_unfiltered - (" field_type = tdesc_named_type (feature, \"%s\");\n", + printf_field_type_assignment + ("tdesc_named_type (feature, \"%s\");\n", type_name); printf_unfiltered (" tdesc_add_typed_bitfield (type_with_fields, \"%s\"," @@ -1962,10 +1955,8 @@ public: { gdb_assert (f.end == -1); gdb_assert (type->kind == TDESC_TYPE_STRUCT); - printf_unfiltered - (" field_type = tdesc_named_type (feature," - " \"%s\");\n", - type_name); + printf_field_type_assignment + ("tdesc_named_type (feature, \"%s\");\n", type_name); printf_unfiltered (" tdesc_add_field (type_with_fields, \"%s\", field_type);\n", f.name.c_str ()); @@ -1978,9 +1969,8 @@ public: type->name.c_str ()); for (const tdesc_type_field &f : type->fields) { - printf_unfiltered - (" field_type = tdesc_named_type (feature, \"%s\");\n", - f.type->name.c_str ()); + printf_field_type_assignment + ("tdesc_named_type (feature, \"%s\");\n", f.type->name.c_str ()); printf_unfiltered (" tdesc_add_field (type_with_fields, \"%s\", field_type);\n", f.name.c_str ()); @@ -2018,6 +2008,25 @@ protected: std::string m_filename_after_features; private: + + /* Print an assignment to the field_type variable. Print the declaration + of field_type if that has not been done yet. */ + void printf_field_type_assignment (const char *fmt, ...) + { + if (!m_printed_field_type) + { + printf_unfiltered (" tdesc_type *field_type;\n"); + m_printed_field_type = true; + } + + printf_unfiltered (" field_type = "); + + va_list args; + va_start (args, fmt); + vprintf_unfiltered (fmt, args); + va_end (args); + } + char *m_function; /* Did we print "struct tdesc_type *element_type;" yet? */ -- 2.30.2