From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id A68763858D28 for ; Thu, 31 Aug 2023 15:47:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A68763858D28 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com Received: from smarchi-efficios.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id EAF4C1E098; Thu, 31 Aug 2023 11:47:29 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/7] gdb: introduce field::is_artificial / field::set_is_artificial Date: Thu, 31 Aug 2023 11:46:22 -0400 Message-ID: <20230831154727.1240363-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230831154727.1240363-1-simon.marchi@efficios.com> References: <20230831154727.1240363-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3497.2 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Simon Marchi Add these two methods, rename the field to m_artificial to make it pseudo private. Change-Id: If3a3825473d1d79bb586a8a074b87bba9b43fb1a --- gdb/buildsym.c | 2 +- gdb/dwarf2/read.c | 14 +++++++------- gdb/gdb-gdb.py.in | 2 +- gdb/gdbtypes.c | 4 ++-- gdb/gdbtypes.h | 14 ++++++++++++-- gdb/mdebugread.c | 2 +- gdb/stabsread.c | 3 ++- 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 3c1e9179411b..03d6e03b6304 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -277,7 +277,7 @@ buildsym_compunit::finish_block_internal if (sym->is_argument ()) { ftype->field (iparams).set_type (sym->type ()); - TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0; + ftype->field (iparams).set_is_artificial (false); iparams++; } } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 94d98feb56b6..63b099c111b5 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -6060,7 +6060,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* Put the discriminant at index 0. */ type->field (0).set_type (field_type); - TYPE_FIELD_ARTIFICIAL (type, 0) = 1; + type->field (0).set_is_artificial (true); type->field (0).set_name ("<>"); type->field (0).set_loc_bitpos (bit_offset); @@ -6158,7 +6158,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* Install the discriminant at index 0 in the union. */ type->field (0) = *disr_field; - TYPE_FIELD_ARTIFICIAL (type, 0) = 1; + type->field (0).set_is_artificial (true); type->field (0).set_name ("<>"); /* We need a way to find the correct discriminant given a @@ -11743,7 +11743,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die, pointer or virtual base class pointer) to private. */ if (dwarf2_attr (die, DW_AT_artificial, cu)) { - FIELD_ARTIFICIAL (*fp) = 1; + fp->set_is_artificial (true); new_field->accessibility = DW_ACCESS_private; fip->non_public_fields = true; } @@ -13588,10 +13588,10 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu, struct field &upper = range_fields[range_fields.size () - 1]; lower.set_type (underlying); - FIELD_ARTIFICIAL (lower) = 1; + lower.set_is_artificial (true); upper.set_type (underlying); - FIELD_ARTIFICIAL (upper) = 1; + upper.set_is_artificial (true); if (!recognize_bound_expression (child_die, DW_AT_lower_bound, &bounds_offset, &lower, cu) @@ -14713,9 +14713,9 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu) 4.5 does not yet generate. */ attr = dwarf2_attr (child_die, DW_AT_artificial, cu); if (attr != nullptr) - TYPE_FIELD_ARTIFICIAL (ftype, iparams) = attr->as_boolean (); + ftype->field (iparams).set_is_artificial (attr->as_boolean ()); else - TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0; + ftype->field (iparams).set_is_artificial (false); arg_type = die_type (child_die, cu); /* RealView does not mark THIS as const, which the testsuite diff --git a/gdb/gdb-gdb.py.in b/gdb/gdb-gdb.py.in index 56d063cd506b..af4453f6eb22 100644 --- a/gdb/gdb-gdb.py.in +++ b/gdb/gdb-gdb.py.in @@ -172,7 +172,7 @@ class StructMainTypePrettyPrinter: """Return an image of the main_type field number FIELDNO.""" f = self.val["flds_bnds"]["fields"][fieldno] label = "flds_bnds.fields[%d]:" % fieldno - if f["artificial"]: + if f["m_artificial"]: label += " (artificial)" fields = [] fields.append("m_name = %s" % f["m_name"]) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 6abe5eaad0a1..ca168b31529f 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5541,8 +5541,8 @@ copy_type_recursive (struct type *type, htab_t copied_types) for (i = 0; i < nfields; i++) { - TYPE_FIELD_ARTIFICIAL (new_type, i) = - TYPE_FIELD_ARTIFICIAL (type, i); + new_type->field (i).set_is_artificial + (TYPE_FIELD_ARTIFICIAL (type, i)); 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 8f592dbe1c01..43263a90714d 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -564,6 +564,16 @@ struct field m_name = name; } + bool is_artificial () const + { + return m_artificial; + } + + void set_is_artificial (bool is_artificial) + { + m_artificial = is_artificial; + } + /* Return true if this field is static; false if not. */ bool is_static () const { @@ -650,7 +660,7 @@ struct field to the user. For TYPE_CODE_RANGE it is set if the specific bound is not defined. */ - unsigned int artificial : 1; + unsigned int m_artificial : 1; /* * Discriminant for union field_location. */ @@ -1913,7 +1923,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *); (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \ : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index))) -#define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial) +#define FIELD_ARTIFICIAL(thisfld) ((thisfld).is_artificial ()) #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize) #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n)) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index ad9967b75fad..109bd64e5183 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1206,7 +1206,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, if (sym->is_argument ()) { ftype->field (iparams).set_type (sym->type ()); - TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0; + ftype->field (iparams).set_is_artificial (false); iparams++; } } diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 1269fc02d724..4a4b39b41e09 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1002,7 +1002,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, if (ptype->code () == TYPE_CODE_VOID) ptype = builtin_type (objfile)->builtin_int; ftype->field (nparams).set_type (ptype); - TYPE_FIELD_ARTIFICIAL (ftype, nparams++) = 0; + ftype->field (nparams).set_is_artificial (false); + nparams++; } ftype->set_num_fields (nparams); ftype->set_is_prototyped (true); -- 2.42.0