From 27e69b7aedcfee8af8fc6ee4f2e99aca2d41daca Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 14 Sep 2020 11:08:00 -0400 Subject: [PATCH] gdb: add type::is_prototyped / type::set_is_prototyped Add the `is_prototyped` and `set_is_prototyped` methods on `struct type`, in order to remove the `TYPE_PROTOTYPED` 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) : New methods. (TYPE_PROTOTYPED): Use type::is_prototyped, change all write call sites to use type::set_is_prototyped. Change-Id: I6ba285250fae413f7c1bf2ffcb5a2cedc8e743da --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2/read.c | 2 +- gdb/eval.c | 2 +- gdb/gdbtypes.c | 4 ++-- gdb/gdbtypes.h | 14 ++++++++++++-- gdb/mdebugread.c | 2 +- gdb/stabsread.c | 6 +++--- 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 376bb9dade0..05cb60a3787 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2020-09-14 Simon Marchi + + * gdbtypes.h (struct type) : + New methods. + (TYPE_PROTOTYPED): Use type::is_prototyped, change all write + call sites to use type::set_is_prototyped. + 2020-09-14 Simon Marchi * gdbtypes.h (TYPE_TARGET_STUB): Remove, replace all diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5f02acc01cb..f4f3a029a76 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -17665,7 +17665,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) ftype = lookup_function_type (type); if (prototyped_function_p (die, cu)) - TYPE_PROTOTYPED (ftype) = 1; + ftype->set_is_prototyped (true); /* Store the calling convention in the type if it's available in the subroutine die. Otherwise set the calling convention to diff --git a/gdb/eval.c b/gdb/eval.c index 3587dfeae07..7f9515b2c11 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -673,7 +673,7 @@ fake_method::fake_method (type_instance_flags flags, --num_types; /* Caller should have ensured this. */ gdb_assert (num_types == 0); - TYPE_PROTOTYPED (type) = 1; + type->set_is_prototyped (true); } } diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 91f3ed82b8c..075363000b4 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -560,10 +560,10 @@ lookup_function_type_with_arguments (struct type *type, --nparams; /* Caller should have ensured this. */ gdb_assert (nparams == 0); - TYPE_PROTOTYPED (fn) = 1; + fn->set_is_prototyped (true); } else - TYPE_PROTOTYPED (fn) = 1; + fn->set_is_prototyped (true); } fn->set_num_fields (nparams); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index e03564c7584..b41e91f6ee6 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -221,7 +221,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags); to coerce the args, or to just do the standard conversions. This is used with a short field. */ -#define TYPE_PROTOTYPED(t) (TYPE_MAIN_TYPE (t)->flag_prototyped) +#define TYPE_PROTOTYPED(t) ((t)->is_prototyped ()) /* * FIXME drow/2002-06-03: Only used for methods, but applies as well to functions. */ @@ -834,7 +834,7 @@ struct main_type unsigned int m_flag_nosign : 1; unsigned int m_flag_stub : 1; unsigned int m_flag_target_stub : 1; - unsigned int flag_prototyped : 1; + unsigned int m_flag_prototyped : 1; unsigned int flag_varargs : 1; unsigned int flag_vector : 1; unsigned int flag_stub_supported : 1; @@ -1100,6 +1100,16 @@ struct type this->main_type->m_flag_target_stub = target_is_stub; } + bool is_prototyped () const + { + return this->main_type->m_flag_prototyped; + } + + void set_is_prototyped (bool is_prototyped) + { + this->main_type->m_flag_prototyped = is_prototyped; + } + /* * 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; diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index f68f4efdafa..480b67b0e86 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -786,7 +786,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, /* All functions in C++ have prototypes. For C we don't have enough information in the debug info. */ if (s->language () == language_cplus) - TYPE_PROTOTYPED (SYMBOL_TYPE (s)) = 1; + SYMBOL_TYPE (s)->set_is_prototyped (true); /* Create and enter a new lexical context. */ b = new_block (FUNCTION_BLOCK, s->language ()); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 752612f14e8..2f9458ce186 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -958,7 +958,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, than the "declared-as" type for unprototyped functions, so we treat all functions as if they were prototyped. This is used primarily for promotion when calling the function from GDB. */ - TYPE_PROTOTYPED (SYMBOL_TYPE (sym)) = 1; + SYMBOL_TYPE (sym)->set_is_prototyped (true); /* fall into process_prototype_types. */ @@ -1005,7 +1005,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, TYPE_FIELD_ARTIFICIAL (ftype, nparams++) = 0; } ftype->set_num_fields (nparams); - TYPE_PROTOTYPED (ftype) = 1; + ftype->set_is_prototyped (true); } break; @@ -1813,7 +1813,7 @@ again: func_type->field (i).set_type (t->type); } func_type->set_num_fields (num_args); - TYPE_PROTOTYPED (func_type) = 1; + func_type->set_is_prototyped (true); type = func_type; break; -- 2.30.2