diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2020-09-14 11:08:01 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-09-14 11:08:01 -0400 |
commit | 1d6286ed048eb1997a0afea0f18cb9eb1789f386 (patch) | |
tree | 48207320acbbca8f9252bb1d11ca41d3780c4564 | |
parent | 7f9f399b34b7e2278eb1e8d6b7653e2b38070c55 (diff) | |
download | gdb-1d6286ed048eb1997a0afea0f18cb9eb1789f386.zip gdb-1d6286ed048eb1997a0afea0f18cb9eb1789f386.tar.gz gdb-1d6286ed048eb1997a0afea0f18cb9eb1789f386.tar.bz2 |
gdb: add type::has_varargs / type::set_has_varargs
Add the `has_varargs` and `set_has_varargs` methods on `struct type`, in
order to remove the `TYPE_VARARGS` macro. In this patch, the macro is
changed to use the getter, so all the call sites of the macro that are
used as a setter are changed to use the setter method directly. The
next patch will remove the macro completely.
gdb/ChangeLog:
* gdbtypes.h (struct type) <has_varargs, set_has_varargs>: New methods.
(TYPE_VARARGS): Use type::has_varargs, change all write call sites to
use type::set_has_varargs.
Change-Id: I898a1093ae40808b37a7c6fced7f6fa2aae604de
-rw-r--r-- | gdb/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/ctfread.c | 2 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 3 | ||||
-rw-r--r-- | gdb/eval.c | 2 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 4 | ||||
-rw-r--r-- | gdb/gdbtypes.h | 14 |
6 files changed, 24 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 193d0c8..e8fecf7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,11 @@ 2020-09-14 Simon Marchi <simon.marchi@efficios.com> + * gdbtypes.h (struct type) <has_varargs, set_has_varargs>: New methods. + (TYPE_VARARGS): Use type::has_varargs, change all write call sites to + use type::set_has_varargs. + +2020-09-14 Simon Marchi <simon.marchi@efficios.com> + * gdbtypes.h (TYPE_PROTOTYPED): Remove, replace all uses with type::is_prototyped. diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 81490ba..0237b48 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -1142,7 +1142,7 @@ add_stt_func (struct ctf_context *ccp, unsigned long idx) tid = ctf_lookup_by_symbol (ccp->fp, idx); ftype = get_tid_type (ccp->of, tid); if (finfo.ctc_flags & CTF_FUNC_VARARG) - TYPE_VARARGS (ftype) = 1; + ftype->set_has_varargs (true); ftype->set_num_fields (argc); /* If argc is 0, it has a "void" type. */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index f4f3a02..e61eda7 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -17707,7 +17707,8 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) if (child_die->tag == DW_TAG_formal_parameter) nparams++; else if (child_die->tag == DW_TAG_unspecified_parameters) - TYPE_VARARGS (ftype) = 1; + ftype->set_has_varargs (true); + child_die = child_die->sibling; } @@ -665,7 +665,7 @@ fake_method::fake_method (type_instance_flags flags, if (param_types[num_types - 1] == NULL) { --num_types; - TYPE_VARARGS (type) = 1; + type->set_has_varargs (true); } else if (check_typedef (param_types[num_types - 1])->code () == TYPE_CODE_VOID) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index ae3d927..2ff458a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -552,7 +552,7 @@ lookup_function_type_with_arguments (struct type *type, if (param_types[nparams - 1] == NULL) { --nparams; - TYPE_VARARGS (fn) = 1; + fn->set_has_varargs (true); } else if (check_typedef (param_types[nparams - 1])->code () == TYPE_CODE_VOID) @@ -1556,7 +1556,7 @@ smash_to_method_type (struct type *type, struct type *self_type, type->set_fields (args); type->set_num_fields (nargs); if (varargs) - TYPE_VARARGS (type) = 1; + type->set_has_varargs (true); TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */ } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index abb6746..e1b0d44 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -219,7 +219,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags); /* * FIXME drow/2002-06-03: Only used for methods, but applies as well to functions. */ -#define TYPE_VARARGS(t) (TYPE_MAIN_TYPE (t)->flag_varargs) +#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 @@ -828,7 +828,7 @@ struct main_type unsigned int m_flag_stub : 1; unsigned int m_flag_target_stub : 1; unsigned int m_flag_prototyped : 1; - unsigned int flag_varargs : 1; + unsigned int m_flag_varargs : 1; unsigned int flag_vector : 1; unsigned int flag_stub_supported : 1; unsigned int flag_gnu_ifunc : 1; @@ -1108,6 +1108,16 @@ struct type this->main_type->m_flag_prototyped = is_prototyped; } + bool has_varargs () const + { + return this->main_type->m_flag_varargs; + } + + void set_has_varargs (bool has_varargs) + { + this->main_type->m_flag_varargs = has_varargs; + } + /* * 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; |