From a409645d13f6cddef4827cf7240c01ec3e09559c Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 14 Sep 2020 11:08:02 -0400 Subject: [PATCH] gdb: remove TYPE_VARARGS gdb/ChangeLog: * gdbtypes.h (TYPE_VARARGS): Remove, replace all uses with type::has_varargs. Change-Id: Ieea4a64b4bfa4b8be643e68cb403081881133740 --- gdb/ChangeLog | 5 +++++ gdb/arm-tdep.c | 2 +- gdb/c-typeprint.c | 6 +++--- gdb/compile/compile-c-types.c | 2 +- gdb/compile/compile-cplus-types.c | 2 +- gdb/dwarf2/read.c | 6 +++--- gdb/gdbtypes.c | 4 ++-- gdb/gdbtypes.h | 8 +++----- gdb/nds32-tdep.c | 2 +- gdb/or1k-tdep.c | 2 +- gdb/riscv-tdep.c | 2 +- gdb/rust-lang.c | 2 +- gdb/rx-tdep.c | 2 +- gdb/s390-tdep.c | 4 ++-- gdb/sh-tdep.c | 4 ++-- gdb/tic6x-tdep.c | 2 +- gdb/valops.c | 2 +- 17 files changed, 30 insertions(+), 27 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e8fecf714cf..cde84e1159f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-09-14 Simon Marchi + + * gdbtypes.h (TYPE_VARARGS): Remove, replace all + uses with type::has_varargs. + 2020-09-14 Simon Marchi * gdbtypes.h (struct type) : New methods. diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 1a5017495ad..1eeaea32dc6 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -3694,7 +3694,7 @@ arm_vfp_abi_for_function (struct gdbarch *gdbarch, struct type *func_type) struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); /* Variadic functions always use the base ABI. Assume that functions without debug info are not variadic. */ - if (func_type && TYPE_VARARGS (check_typedef (func_type))) + if (func_type && check_typedef (func_type)->has_varargs ()) return 0; /* The VFP ABI is only supported as a variant of AAPCS. */ if (tdep->arm_abi != ARM_ABI_AAPCS) diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 37bb16e6dae..0c2268f8d0a 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -279,7 +279,7 @@ cp_type_print_method_args (struct type *mtype, const char *prefix, { struct field *args = mtype->fields (); int nargs = mtype->num_fields (); - int varargs = TYPE_VARARGS (mtype); + int varargs = mtype->has_varargs (); int i; fprintf_symbol_filtered (stream, prefix, @@ -591,12 +591,12 @@ c_type_print_args (struct type *type, struct ui_file *stream, printed_any = 1; } - if (printed_any && TYPE_VARARGS (type)) + if (printed_any && type->has_varargs ()) { /* Print out a trailing ellipsis for varargs functions. Ignore TYPE_VARARGS if the function has no named arguments; that represents unprototyped (K&R style) C functions. */ - if (printed_any && TYPE_VARARGS (type)) + if (printed_any && type->has_varargs ()) { fprintf_filtered (stream, ", "); wrap_here (" "); diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index 08c8c6b4a9a..03536c0ca33 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -153,7 +153,7 @@ convert_func (compile_c_instance *context, struct type *type) int i; gcc_type result, return_type; struct gcc_type_array array; - int is_varargs = TYPE_VARARGS (type) || !type->is_prototyped (); + int is_varargs = type->has_varargs () || !type->is_prototyped (); struct type *target_type = TYPE_TARGET_TYPE (type); diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index 8431cbc6c11..8270defa17c 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -964,7 +964,7 @@ static gcc_type compile_cplus_convert_func (compile_cplus_instance *instance, struct type *type, bool strip_artificial) { - int is_varargs = TYPE_VARARGS (type); + int is_varargs = type->has_varargs (); struct type *target_type = TYPE_TARGET_TYPE (type); /* Functions with no debug info have no return type. Ideally we'd diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e61eda73de4..45fdaf86375 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -15631,7 +15631,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, TYPE_TARGET_TYPE (this_type), this_type->fields (), this_type->num_fields (), - TYPE_VARARGS (this_type)); + this_type->has_varargs ()); /* Handle static member functions. Dwarf2 has no clean way to discern C++ static and non-static @@ -15847,7 +15847,7 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) new_type = alloc_type (objfile); smash_to_method_type (new_type, self_type, TYPE_TARGET_TYPE (pfn_type), pfn_type->fields (), pfn_type->num_fields (), - TYPE_VARARGS (pfn_type)); + pfn_type->has_varargs ()); smash_to_methodptr_type (type, new_type); } @@ -17352,7 +17352,7 @@ read_tag_ptr_to_member_type (struct die_info *die, struct dwarf2_cu *cu) smash_to_method_type (new_type, domain, TYPE_TARGET_TYPE (to_type), to_type->fields (), to_type->num_fields (), - TYPE_VARARGS (to_type)); + to_type->has_varargs ()); type = lookup_methodptr_type (new_type); } else diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 2ff458af908..5927f500781 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -3992,7 +3992,7 @@ check_types_equal (struct type *type1, struct type *type2, || type1->is_unsigned () != type2->is_unsigned () || type1->has_no_signedness () != type2->has_no_signedness () || TYPE_ENDIANITY_NOT_DEFAULT (type1) != TYPE_ENDIANITY_NOT_DEFAULT (type2) - || TYPE_VARARGS (type1) != TYPE_VARARGS (type2) + || type1->has_varargs () != type2->has_varargs () || TYPE_VECTOR (type1) != TYPE_VECTOR (type2) || TYPE_NOTTEXT (type1) != TYPE_NOTTEXT (type2) || TYPE_INSTANCE_FLAGS (type1) != TYPE_INSTANCE_FLAGS (type2) @@ -5088,7 +5088,7 @@ recursive_dump_type (struct type *type, int spaces) { puts_filtered (" TYPE_PROTOTYPED"); } - if (TYPE_VARARGS (type)) + if (type->has_varargs ()) { puts_filtered (" TYPE_VARARGS"); } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index e1b0d442f1c..86d2f8cd903 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -216,11 +216,6 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags); #define TYPE_ENDIANITY_NOT_DEFAULT(t) (TYPE_MAIN_TYPE (t)->flag_endianity_not_default) -/* * FIXME drow/2002-06-03: Only used for methods, but applies as well - to functions. */ - -#define TYPE_VARARGS(t) ((t)->has_varargs ()) - /* * Identify a vector type. Gcc is handling this by adding an extra attribute to the array type. We slurp that in as a new flag of a type. This is used only in dwarf2read.c. */ @@ -1108,6 +1103,9 @@ struct type this->main_type->m_flag_prototyped = is_prototyped; } + /* FIXME drow/2002-06-03: Only used for methods, but applies as well + to functions. */ + bool has_varargs () const { return this->main_type->m_flag_varargs; diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index 94ac234d3fb..fc90797f6d0 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -1495,7 +1495,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, For ABI2FP+, the caller pushes only named arguments in registers and pushes all unnamed arguments in stack. */ - if (abi_use_fpr && TYPE_VARARGS (func_type) + if (abi_use_fpr && func_type->has_varargs () && i >= func_type->num_fields ()) goto use_stack; diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index 75df206a2bd..6ba6503864f 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -635,7 +635,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int len = TYPE_LENGTH (arg_type); enum type_code typecode = arg_type->code (); - if (TYPE_VARARGS (func_type) && argnum >= func_type->num_fields ()) + if (func_type->has_varargs () && argnum >= func_type->num_fields ()) break; /* end or regular args, varargs go to stack. */ /* Extract the value, either a reference or the data. */ diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index b86ba630540..a79b5f5b0cf 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -2589,7 +2589,7 @@ riscv_push_dummy_call (struct gdbarch *gdbarch, arg_type = check_typedef (value_type (arg_value)); riscv_arg_location (gdbarch, info, &call_info, arg_type, - TYPE_VARARGS (ftype) && i >= ftype->num_fields ()); + ftype->has_varargs () && i >= ftype->num_fields ()); if (info->type != arg_type) arg_value = value_cast (info->type, arg_value); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index a0310a0b9d6..b8ab59bd207 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -779,7 +779,7 @@ rust_internal_print_type (struct type *type, const char *varstring, case TYPE_CODE_FUNC: /* Delegate varargs to the C printer. */ - if (TYPE_VARARGS (type)) + if (type->has_varargs ()) goto c_printer; fputs_filtered ("fn ", stream); diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 04477945917..6401ef236c8 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -686,7 +686,7 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function, requiring multiple registers, etc. We rely instead on the value of the ``arg_reg'' variable to get these other details correct. */ - if (TYPE_VARARGS (func_type)) + if (func_type->has_varargs ()) num_register_candidate_args = func_type->num_fields () - 1; else num_register_candidate_args = 4; diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index bc6f98e0484..efe650ae036 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1939,7 +1939,7 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function, and arg_state.argp with the size of the parameter area. */ for (i = 0; i < nargs; i++) s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order, - TYPE_VARARGS (ftype) && i >= ftype->num_fields ()); + ftype->has_varargs () && i >= ftype->num_fields ()); param_area_start = align_down (arg_state.copy - arg_state.argp, 8); @@ -1966,7 +1966,7 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Write all parameters. */ for (i = 0; i < nargs; i++) s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order, - TYPE_VARARGS (ftype) && i >= ftype->num_fields ()); + ftype->has_varargs () && i >= ftype->num_fields ()); /* Store return PSWA. In 31-bit mode, keep addressing mode bit. */ if (word_size == 4) diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index 7aadf9165ca..2c3342156f4 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -1083,7 +1083,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch, non-vararg argument to be on the stack, no matter how many registers have been used so far. */ if (sh_is_renesas_calling_convention (func_type) - && TYPE_VARARGS (func_type)) + && func_type->has_varargs ()) last_reg_arg = func_type->num_fields () - 2; /* First force sp to a 4-byte alignment. */ @@ -1224,7 +1224,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch, non-vararg argument to be on the stack, no matter how many registers have been used so far. */ if (sh_is_renesas_calling_convention (func_type) - && TYPE_VARARGS (func_type)) + && func_type->has_varargs ()) last_reg_arg = func_type->num_fields () - 2; /* First force sp to a 4-byte alignment. */ diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c index 57945d21db7..4227e716622 100644 --- a/gdb/tic6x-tdep.c +++ b/gdb/tic6x-tdep.c @@ -889,7 +889,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* For a variadic C function, the last explicitly declared argument and all remaining arguments are passed on the stack. */ - if (TYPE_VARARGS (func_type)) + if (func_type->has_varargs ()) first_arg_on_stack = func_type->num_fields () - 1; /* Now make space on the stack for the args. */ diff --git a/gdb/valops.c b/gdb/valops.c index 60f6041d053..aba4c70d45e 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -2010,7 +2010,7 @@ search_struct_method (const char *name, struct value **arg1p, while (j >= 0) { if (!typecmp (TYPE_FN_FIELD_STATIC_P (f, j), - TYPE_VARARGS (TYPE_FN_FIELD_TYPE (f, j)), + TYPE_FN_FIELD_TYPE (f, j)->has_varargs (), TYPE_FN_FIELD_TYPE (f, j)->num_fields (), TYPE_FN_FIELD_ARGS (f, j), args)) { -- 2.30.2