From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 25A4C3857C77 for ; Mon, 6 Jul 2020 13:38:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 25A4C3857C77 X-ASG-Debug-ID: 1594042719-0c856e6bfb360300001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id d9Zb3CTSp3slNubH (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 06 Jul 2020 09:38:39 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) by smtp.ebox.ca (Postfix) with ESMTP id 4273F441D64; Mon, 6 Jul 2020 09:38:39 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: 173-246-6-90.qc.cable.ebox.net[173.246.6.90] X-Barracuda-Apparent-Source-IP: 173.246.6.90 X-Barracuda-RBL-IP: 173.246.6.90 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 01/12] gdb: add type::bounds / type::set_bounds Date: Mon, 6 Jul 2020 09:38:22 -0400 X-ASG-Orig-Subj: [PATCH 01/12] gdb: add type::bounds / type::set_bounds Message-Id: <20200706133833.145408-2-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200706133833.145408-1-simon.marchi@polymtl.ca> References: <20200706133833.145408-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1594042719 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 4601 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE_7582B X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.83013 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE_7582B Custom Rule 7582B X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2020 13:38:41 -0000 From: Simon Marchi Add the `bounds` and `set_bounds` methods on `struct type`, in order to remove the `TYPE_RANGE_DATA` macro. In this patch, the `TYPE_RANGE_DATA` macro is changed to use `type::bounds`, so all the call sites that are used to set a range type's bounds are changed to use `type::set_bounds`. The next patch will remove `TYPE_RANGE_DATA` completely. gdb/ChangeLog: * gdbtypes.h (struct type) : New methods. (TYPE_RANGE_DATA): Use type::bounds. Change all uses that are used to set the range type's bounds to use set_bounds. Change-Id: I62e15506239b98404e62bbea8120db184ed87847 --- gdb/gdbtypes.c | 23 ++++++++++++++--------- gdb/gdbtypes.h | 18 +++++++++++++++++- gdb/mdebugread.c | 4 ++-- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index cdf88a4a7d15..66f094328991 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -935,15 +935,17 @@ create_range_type (struct type *result_type, struct type *index_type, else TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type)); - TYPE_RANGE_DATA (result_type) = (struct range_bounds *) - TYPE_ZALLOC (result_type, sizeof (struct range_bounds)); - TYPE_RANGE_DATA (result_type)->low = *low_bound; - TYPE_RANGE_DATA (result_type)->high = *high_bound; - TYPE_RANGE_DATA (result_type)->bias = bias; + range_bounds *bounds + = (struct range_bounds *) TYPE_ZALLOC (result_type, sizeof (range_bounds)); + bounds->low = *low_bound; + bounds->high = *high_bound; + bounds->bias = bias; /* Initialize the stride to be a constant, the value will already be zero thanks to the use of TYPE_ZALLOC above. */ - TYPE_RANGE_DATA (result_type)->stride.kind = PROP_CONST; + bounds->stride.kind = PROP_CONST; + + result_type->set_bounds (bounds); if (low_bound->kind == PROP_CONST && low_bound->data.const_val >= 0) TYPE_UNSIGNED (result_type) = 1; @@ -5363,9 +5365,12 @@ copy_type_recursive (struct objfile *objfile, /* For range types, copy the bounds information. */ if (type->code () == TYPE_CODE_RANGE) { - TYPE_RANGE_DATA (new_type) = (struct range_bounds *) - TYPE_ALLOC (new_type, sizeof (struct range_bounds)); - *TYPE_RANGE_DATA (new_type) = *TYPE_RANGE_DATA (type); + range_bounds *bounds + = ((struct range_bounds *) TYPE_ALLOC + (new_type, sizeof (struct range_bounds))); + + *bounds = *type->bounds (); + new_type->set_bounds (bounds); } if (type->main_type->dyn_prop_list != NULL) diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 28d42efb7285..236d37b1ce2a 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -953,6 +953,22 @@ struct type this->field (0).set_type (index_type); } + /* Get the bounds bounds of this type. The type must be a range type. */ + range_bounds *bounds () const + { + gdb_assert (this->code () == TYPE_CODE_RANGE); + + return this->main_type->flds_bnds.bounds; + } + + /* Set the bounds of this type. The type must be a range type. */ + void set_bounds (range_bounds *bounds) + { + gdb_assert (this->code () == TYPE_CODE_RANGE); + + this->main_type->flds_bnds.bounds = bounds; + } + /* * 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; @@ -1502,7 +1518,7 @@ extern unsigned type_align (struct type *); space in struct type. */ extern bool set_type_align (struct type *, ULONGEST); -#define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds +#define TYPE_RANGE_DATA(thistype) ((thistype)->bounds ()) #define TYPE_LOW_BOUND(range_type) \ TYPE_RANGE_DATA(range_type)->low.data.const_val #define TYPE_HIGH_BOUND(range_type) \ diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 6f76bc6a84e2..aa0c715b054a 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1734,8 +1734,8 @@ parse_type (int fd, union aux_ext *ax, unsigned int aux_index, int *bs, if (t->bt == btRange) { tp->set_num_fields (0); - TYPE_RANGE_DATA (tp) = ((struct range_bounds *) - TYPE_ZALLOC (tp, sizeof (struct range_bounds))); + tp->set_bounds (((struct range_bounds *) + TYPE_ZALLOC (tp, sizeof (struct range_bounds)))); TYPE_LOW_BOUND (tp) = AUX_GET_DNLOW (bigend, ax); ax++; TYPE_HIGH_BOUND (tp) = AUX_GET_DNHIGH (bigend, ax); -- 2.27.0