From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 3/7] gdb: remove TYPE_FIELD_ARTIFICIAL
Date: Thu, 31 Aug 2023 11:46:24 -0400 [thread overview]
Message-ID: <20230831154727.1240363-4-simon.marchi@efficios.com> (raw)
In-Reply-To: <20230831154727.1240363-1-simon.marchi@efficios.com>
From: Simon Marchi <simon.marchi@polymtl.ca>
Replace with type::field + field::is_artificial.
Change-Id: Ie3bacae49d9bd02e83e504c1ce01470aba56a081
---
gdb/c-typeprint.c | 4 ++--
gdb/c-varobj.c | 4 ++--
gdb/compile/compile-cplus-types.c | 4 ++--
gdb/dwarf2/read.c | 8 ++++----
gdb/f-lang.c | 2 +-
gdb/gdbtypes.c | 2 +-
gdb/gdbtypes.h | 1 -
gdb/i386-windows-tdep.c | 2 +-
gdb/python/py-type.c | 2 +-
gdb/rust-lang.c | 6 +++---
gdb/valops.c | 4 ++--
11 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 57b2c09be8bf..a23ceb0ddc4a 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -535,7 +535,7 @@ c_type_print_args (struct type *type, struct ui_file *stream,
{
struct type *param_type;
- if (TYPE_FIELD_ARTIFICIAL (type, i) && linkage_name)
+ if (type->field (i).is_artificial () && linkage_name)
continue;
if (printed_any)
@@ -1102,7 +1102,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
virtual table pointers are not specifically marked in
the debug info, they should be artificial. */
if ((i == vptr_fieldno && type == basetype)
- || TYPE_FIELD_ARTIFICIAL (type, i))
+ || type->field (i).is_artificial ())
continue;
if (need_access_label)
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index 87eca6b069ab..b00a2345e2c3 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -651,7 +651,7 @@ cplus_class_num_children (struct type *type, int children[3])
table pointers are not specifically marked in the debug info,
they should be artificial. */
if ((type == basetype && i == vptr_fieldno)
- || TYPE_FIELD_ARTIFICIAL (type, i))
+ || type->field (i).is_artificial ())
continue;
if (TYPE_FIELD_PROTECTED (type, i))
@@ -751,7 +751,7 @@ cplus_describe_child (const struct varobj *parent, int index,
while (index >= 0)
{
if ((type == basetype && type_index == vptr_fieldno)
- || TYPE_FIELD_ARTIFICIAL (type, type_index))
+ || type->field (type_index).is_artificial ())
; /* ignore vptr */
else if (match_accessibility (type, type_index, acc))
--index;
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index d8e305f237a4..cea04b74d10a 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -584,7 +584,7 @@ compile_cplus_convert_struct_or_union_members
const char *field_name = type->field (i).name ();
if (TYPE_FIELD_IGNORE (type, i)
- || TYPE_FIELD_ARTIFICIAL (type, i))
+ || type->field (i).is_artificial ())
continue;
/* GDB records unnamed/anonymous fields with empty string names. */
@@ -982,7 +982,7 @@ compile_cplus_convert_func (compile_cplus_instance *instance,
int artificials = 0;
for (int i = 0; i < type->num_fields (); ++i)
{
- if (strip_artificial && TYPE_FIELD_ARTIFICIAL (type, i))
+ if (strip_artificial && type->field (i).is_artificial ())
{
--array.n_elements;
++artificials;
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 63b099c111b5..25e8034397a4 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -7066,7 +7066,7 @@ dwarf2_compute_name (const char *name,
artificial; there is no way to differentiate
the two cases. */
if (type->num_fields () > 0
- && TYPE_FIELD_ARTIFICIAL (type, 0)
+ && type->field (0).is_artificial ()
&& type->field (0).type ()->code () == TYPE_CODE_PTR
&& TYPE_CONST (type->field (0).type ()->target_type ()))
buf.puts (" const");
@@ -12239,7 +12239,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
parameter for non-static member functions (which is the this
pointer) as artificial. We obtain this information from
read_subroutine_type via TYPE_FIELD_ARTIFICIAL. */
- if (nparams == 0 || TYPE_FIELD_ARTIFICIAL (this_type, 0) == 0)
+ if (nparams == 0 || this_type->field (0).is_artificial () == 0)
fnp->voffset = VOFFSET_STATIC;
}
else
@@ -12328,7 +12328,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
we cannot actually find a base class context for the
vtable! */
if (this_type->num_fields () == 0
- || !TYPE_FIELD_ARTIFICIAL (this_type, 0))
+ || !this_type->field (0).is_artificial ())
{
complaint (_("cannot determine context for virtual member "
"function \"%s\" (offset %s)"),
@@ -14723,7 +14723,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
but not in the class specifications (GCC PR 43053). */
if (cu->lang () == language_cplus
&& !TYPE_CONST (arg_type)
- && TYPE_FIELD_ARTIFICIAL (ftype, iparams))
+ && ftype->field (iparams).is_artificial ())
{
int is_this = 0;
struct dwarf2_cu *arg_cu = cu;
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index bb177007303a..fc0614e57617 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -1932,7 +1932,7 @@ fortran_prepare_argument (struct expression *exp,
bool is_artificial = ((arg_num >= func_type->num_fields ())
? true
- : TYPE_FIELD_ARTIFICIAL (func_type, arg_num));
+ : func_type->field (arg_num).is_artificial ());
/* If this is an artificial argument, then either, this is an argument
beyond the end of the known arguments, or possibly, there are no known
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 076a0817b265..0f0638e7bd77 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5542,7 +5542,7 @@ copy_type_recursive (struct type *type, htab_t copied_types)
for (i = 0; i < nfields; i++)
{
new_type->field (i).set_is_artificial
- (TYPE_FIELD_ARTIFICIAL (type, i));
+ (type->field (i).is_artificial ());
TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i);
if (type->field (i).type ())
new_type->field (i).set_type
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 9aa4a5c8a856..be65669ac5f5 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1925,7 +1925,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
-#define TYPE_FIELD_ARTIFICIAL(thistype, n) ((thistype)->field (n).is_artificial ())
#define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE((thistype)->field (n))
#define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE((thistype)->field (n))!=0)
diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c
index 686004a5d320..a5fe5dc8a1c8 100644
--- a/gdb/i386-windows-tdep.c
+++ b/gdb/i386-windows-tdep.c
@@ -122,7 +122,7 @@ i386_windows_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
artificial flag of the first parameter ('this' pointer). */
if (type->code () == TYPE_CODE_METHOD
&& type->num_fields () > 0
- && TYPE_FIELD_ARTIFICIAL (type, 0)
+ && type->field (0).is_artificial ()
&& type->field (0).type ()->code () == TYPE_CODE_PTR)
thiscall = 1;
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index b60875c792ed..9933bb378b57 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -197,7 +197,7 @@ convert_field (struct type *type, int field)
if (PyObject_SetAttrString (result.get (), "name", arg.get ()) < 0)
return NULL;
- arg.reset (PyBool_FromLong (TYPE_FIELD_ARTIFICIAL (type, field)));
+ arg.reset (PyBool_FromLong (type->field (field).is_artificial ()));
if (PyObject_SetAttrString (result.get (), "artificial", arg.get ()) < 0)
return NULL;
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 27e8069f1481..0b4a7d47c957 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -93,7 +93,7 @@ rust_enum_variant (struct type *type)
{
/* The active variant is simply the first non-artificial field. */
for (int i = 0; i < type->num_fields (); ++i)
- if (!TYPE_FIELD_ARTIFICIAL (type, i))
+ if (!type->field (i).is_artificial ())
return i;
/* Perhaps we could get here by trying to print an Ada variant
@@ -724,7 +724,7 @@ rust_print_struct_def (struct type *type, const char *varstring,
{
if (type->field (i).is_static ())
continue;
- if (is_enum && TYPE_FIELD_ARTIFICIAL (type, i))
+ if (is_enum && type->field (i).is_artificial ())
continue;
fields.push_back (i);
}
@@ -741,7 +741,7 @@ rust_print_struct_def (struct type *type, const char *varstring,
QUIT;
gdb_assert (!type->field (i).is_static ());
- gdb_assert (! (is_enum && TYPE_FIELD_ARTIFICIAL (type, i)));
+ gdb_assert (! (is_enum && type->field (i).is_artificial ()));
if (flags->print_offsets)
podata->update (type, i, stream);
diff --git a/gdb/valops.c b/gdb/valops.c
index 6404091d451d..b007fe08d348 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3464,7 +3464,7 @@ compare_parameters (struct type *t1, struct type *t2, int skip_artificial)
{
int start = 0;
- if (t1->num_fields () > 0 && TYPE_FIELD_ARTIFICIAL (t1, 0))
+ if (t1->num_fields () > 0 && t1->field (0).is_artificial ())
++start;
/* If skipping artificial fields, find the first real field
@@ -3472,7 +3472,7 @@ compare_parameters (struct type *t1, struct type *t2, int skip_artificial)
if (skip_artificial)
{
while (start < t1->num_fields ()
- && TYPE_FIELD_ARTIFICIAL (t1, start))
+ && t1->field (start).is_artificial ())
++start;
}
--
2.42.0
next prev parent reply other threads:[~2023-08-31 15:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-31 15:46 [PATCH 0/7] Remove some more TYPE/FIELD macros Simon Marchi
2023-08-31 15:46 ` [PATCH 1/7] gdb: introduce field::is_artificial / field::set_is_artificial Simon Marchi
2023-08-31 15:46 ` [PATCH 2/7] gdb: remove FIELD_ARTIFICIAL Simon Marchi
2023-08-31 15:46 ` Simon Marchi [this message]
2023-08-31 15:46 ` [PATCH 4/7] gdb: introduce field::bitsize / field::set_bitsize Simon Marchi
2023-08-31 15:46 ` [PATCH 5/7] gdb: remove FIELD_BITSIZE Simon Marchi
2023-08-31 15:46 ` [PATCH 6/7] gdb: remove TYPE_FIELD_BITSIZE Simon Marchi
2023-08-31 15:46 ` [PATCH 7/7] gdb: remove TYPE_FIELD_PACKED Simon Marchi
2023-08-31 17:05 ` [PATCH 0/7] Remove some more TYPE/FIELD macros Tom Tromey
2023-08-31 17:16 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230831154727.1240363-4-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).