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 1640A396E04A for ; Thu, 30 Apr 2020 18:17:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1640A396E04A X-ASG-Debug-ID: 1588270674-0c856e314b604440001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id xjTilTDZOsJYqBKE (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 30 Apr 2020 14:17:54 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by smtp.ebox.ca (Postfix) with ESMTP id B5BA7441D64; Thu, 30 Apr 2020 14:17:54 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-181-218.qc.cable.ebox.net[192.222.181.218] X-Barracuda-Apparent-Source-IP: 192.222.181.218 X-Barracuda-RBL-IP: 192.222.181.218 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/4] gdb: make get_dyn_prop a method of struct type Date: Thu, 30 Apr 2020 14:17:50 -0400 X-ASG-Orig-Subj: [PATCH 1/4] gdb: make get_dyn_prop a method of struct type Message-Id: <20200430181753.1093-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200430181753.1093-1-simon.marchi@efficios.com> References: <20200430181753.1093-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1588270674 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: 8250 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.81535 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-39.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_NONE, 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: Thu, 30 Apr 2020 18:17:57 -0000 Move get_dyn_prop, currently a free function, to be a method on struct type. gdb/ChangeLog: * gdbtypes.h (struct type) : New method. (get_dyn_prop): Remove. Update all users to use type::get_dyn_prop. * gdbtypes.c (get_dyn_prop): Rename to... (type::get_dyn_prop): ... this. --- gdb/ada-lang.c | 4 ++-- gdb/ada-typeprint.c | 4 ++-- gdb/gdbtypes.c | 16 ++++++++-------- gdb/gdbtypes.h | 23 +++++++++++------------ gdb/rust-lang.c | 3 +-- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index bfbc69084ec..6932a544ec6 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2812,7 +2812,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type, = create_static_range_type (NULL, base_index_type, low, high); struct type *slice_type = create_array_type_with_stride (NULL, TYPE_TARGET_TYPE (type0), index_type, - get_dyn_prop (DYN_PROP_BYTE_STRIDE, type0), + type0->get_dyn_prop (DYN_PROP_BYTE_STRIDE), TYPE_FIELD_BITSIZE (type0, 0)); int base_low = ada_discrete_type_low_bound (TYPE_INDEX_TYPE (type0)); LONGEST base_low_pos, low_pos; @@ -2842,7 +2842,7 @@ ada_value_slice (struct value *array, int low, int high) = create_static_range_type (NULL, TYPE_INDEX_TYPE (type), low, high); struct type *slice_type = create_array_type_with_stride (NULL, TYPE_TARGET_TYPE (type), index_type, - get_dyn_prop (DYN_PROP_BYTE_STRIDE, type), + type->get_dyn_prop (DYN_PROP_BYTE_STRIDE), TYPE_FIELD_BITSIZE (type, 0)); LONGEST low_pos, high_pos; diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index 83972fe125d..9071eeace13 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -776,13 +776,13 @@ print_record_field_types (struct type *type, struct type *outer_type, struct ui_file *stream, int show, int level, const struct type_print_options *flags) { - struct dynamic_prop *prop = get_dyn_prop (DYN_PROP_VARIANT_PARTS, type); + struct dynamic_prop *prop = type->get_dyn_prop (DYN_PROP_VARIANT_PARTS); if (prop != nullptr) { if (prop->kind == PROP_TYPE) { type = prop->data.original_type; - prop = get_dyn_prop (DYN_PROP_VARIANT_PARTS, type); + prop = type->get_dyn_prop (DYN_PROP_VARIANT_PARTS); } gdb_assert (prop->kind == PROP_VARIANT_PARTS); print_record_field_types_dynamic (*prop->data.variant_parts, diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 6648dc4d678..9efcfea1ef9 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1938,7 +1938,7 @@ stub_noname_complaint (void) static int array_type_has_dynamic_stride (struct type *type) { - struct dynamic_prop *prop = get_dyn_prop (DYN_PROP_BYTE_STRIDE, type); + struct dynamic_prop *prop = type->get_dyn_prop (DYN_PROP_BYTE_STRIDE); return (prop != NULL && prop->kind != PROP_CONST); } @@ -1971,7 +1971,7 @@ is_dynamic_type_internal (struct type *type, int top_level) if (TYPE_ALLOCATED_PROP (type)) return 1; - struct dynamic_prop *prop = get_dyn_prop (DYN_PROP_VARIANT_PARTS, type); + struct dynamic_prop *prop = type->get_dyn_prop (DYN_PROP_VARIANT_PARTS); if (prop != nullptr && prop->kind != PROP_TYPE) return 1; @@ -2180,7 +2180,7 @@ resolve_dynamic_array_or_string (struct type *type, else elt_type = TYPE_TARGET_TYPE (type); - prop = get_dyn_prop (DYN_PROP_BYTE_STRIDE, type); + prop = type->get_dyn_prop (DYN_PROP_BYTE_STRIDE); if (prop != NULL) { if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value)) @@ -2417,8 +2417,8 @@ resolve_dynamic_struct (struct type *type, resolved_type = copy_type (type); - struct dynamic_prop *variant_prop = get_dyn_prop (DYN_PROP_VARIANT_PARTS, - resolved_type); + dynamic_prop *variant_prop + = resolved_type->get_dyn_prop (DYN_PROP_VARIANT_PARTS); if (variant_prop != nullptr && variant_prop->kind == PROP_VARIANT_PARTS) { compute_variant_fields (type, resolved_type, addr_stack, @@ -2633,10 +2633,10 @@ resolve_dynamic_type (struct type *type, /* See gdbtypes.h */ -struct dynamic_prop * -get_dyn_prop (enum dynamic_prop_node_kind prop_kind, const struct type *type) +dynamic_prop * +type::get_dyn_prop (dynamic_prop_node_kind prop_kind) const { - struct dynamic_prop_list *node = TYPE_DYN_PROP_LIST (type); + dynamic_prop_list *node = TYPE_DYN_PROP_LIST (this); while (node != NULL) { diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 87b1bca3a22..a56570726fe 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -349,15 +349,15 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags); /* * True if this type is allocatable. */ #define TYPE_IS_ALLOCATABLE(t) \ - (get_dyn_prop (DYN_PROP_ALLOCATED, t) != NULL) + ((t)->get_dyn_prop (DYN_PROP_ALLOCATED) != NULL) /* * True if this type has variant parts. */ #define TYPE_HAS_VARIANT_PARTS(t) \ - (get_dyn_prop (DYN_PROP_VARIANT_PARTS, t) != nullptr) + ((t)->get_dyn_prop (DYN_PROP_VARIANT_PARTS) != nullptr) /* * True if this type has a dynamic length. */ #define TYPE_HAS_DYNAMIC_LENGTH(t) \ - (get_dyn_prop (DYN_PROP_BYTE_SIZE, t) != nullptr) + ((t)->get_dyn_prop (DYN_PROP_BYTE_SIZE) != nullptr) /* * Instruction-space delimited type. This is for Harvard architectures which have separate instruction and data address spaces (and perhaps @@ -886,6 +886,10 @@ struct main_type struct type { + /* * Return the dynamic property of the requested KIND from this type's + list of dynamic properties. */ + dynamic_prop *get_dyn_prop (dynamic_prop_node_kind kind) const; + /* * Type that is a pointer to this type. NULL if no such pointer-to type is known yet. The debugger may add the address of such a type @@ -1445,7 +1449,7 @@ extern bool set_type_align (struct type *, ULONGEST); /* Property accessors for the type data location. */ #define TYPE_DATA_LOCATION(thistype) \ - get_dyn_prop (DYN_PROP_DATA_LOCATION, thistype) + ((thistype)->get_dyn_prop (DYN_PROP_DATA_LOCATION)) #define TYPE_DATA_LOCATION_BATON(thistype) \ TYPE_DATA_LOCATION (thistype)->data.baton #define TYPE_DATA_LOCATION_ADDR(thistype) \ @@ -1453,13 +1457,13 @@ extern bool set_type_align (struct type *, ULONGEST); #define TYPE_DATA_LOCATION_KIND(thistype) \ TYPE_DATA_LOCATION (thistype)->kind #define TYPE_DYNAMIC_LENGTH(thistype) \ - get_dyn_prop (DYN_PROP_BYTE_SIZE, thistype) + ((thistype)->get_dyn_prop (DYN_PROP_BYTE_SIZE)) /* Property accessors for the type allocated/associated. */ #define TYPE_ALLOCATED_PROP(thistype) \ - get_dyn_prop (DYN_PROP_ALLOCATED, thistype) + ((thistype)->get_dyn_prop (DYN_PROP_ALLOCATED)) #define TYPE_ASSOCIATED_PROP(thistype) \ - get_dyn_prop (DYN_PROP_ASSOCIATED, thistype) + ((thistype)->get_dyn_prop (DYN_PROP_ASSOCIATED)) /* Attribute accessors for dynamic properties. */ #define TYPE_DYN_PROP_LIST(thistype) \ @@ -2105,11 +2109,6 @@ extern struct type *resolve_dynamic_type /* * Predicate if the type has dynamic values, which are not resolved yet. */ extern int is_dynamic_type (struct type *type); -/* * Return the dynamic property of the requested KIND from TYPE's - list of dynamic properties. */ -extern struct dynamic_prop *get_dyn_prop - (enum dynamic_prop_node_kind kind, const struct type *type); - /* * Given a dynamic property PROP of a given KIND, add this dynamic property to the given TYPE. diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 20661e48d96..4233834dff3 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -708,8 +708,7 @@ rust_print_struct_def (struct type *type, const char *varstring, if (is_enum) { fputs_filtered ("enum ", stream); - struct dynamic_prop *prop = get_dyn_prop (DYN_PROP_VARIANT_PARTS, - type); + dynamic_prop *prop = type->get_dyn_prop (DYN_PROP_VARIANT_PARTS); if (prop != nullptr && prop->kind == PROP_TYPE) type = prop->data.original_type; } -- 2.26.2