From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0Hk6CIWRiWG5MAAAWB0awg (envelope-from ) for ; Mon, 08 Nov 2021 16:07:17 -0500 Received: by simark.ca (Postfix, from userid 112) id 1F2051F0C7; Mon, 8 Nov 2021 16:07:17 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 03FA81EE1F for ; Mon, 8 Nov 2021 16:07:13 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 49BDE3858404 for ; Mon, 8 Nov 2021 21:07:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49BDE3858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1636405632; bh=DfR6nHQKklMfdFBvlFs3Eqdzdikg8vl2klwvoiYC0B8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=OSsbK0tlR3i7UW2bPiDXN5vG8e0ds/FPbZVpOJPOU0HA8UElW9GyfTiijvVxWXjZX 2UzBFKKTgne+2TDadQ/wTzxVtoa4wPJFJhNHWQgpoxQVmoSwMvIPtrZDk4oOvSzNhG LcNG1PVVimmoIw/LI+LzKKVRmyFh2injEw3ARjII= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 6F6C43858C2C for ; Mon, 8 Nov 2021 21:06:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6F6C43858C2C X-ASG-Debug-ID: 1636405570-0c856e0387959d00001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id ZKIceOd2VNNCVMyQ (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 08 Nov 2021 16:06:10 -0500 (EST) 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-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id A5382441D68; Mon, 8 Nov 2021 16:06:10 -0500 (EST) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Subject: [PATCH 4/4] gdb: trivial changes to use array_view Date: Mon, 8 Nov 2021 16:06:09 -0500 X-ASG-Orig-Subj: [PATCH 4/4] gdb: trivial changes to use array_view Message-Id: <20211108210609.353208-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211108210609.353208-1-simon.marchi@efficios.com> References: <20211108210609.353208-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: 1636405570 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 6076 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.93830 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 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: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" From: Simon Marchi Change a few relatively obvious spots using value contents to propagate the use array_view a bit more. Change-Id: I5338a60986f06d5969fec803d04f8423c9288a15 --- gdb/frame.c | 2 +- gdb/rust-lang.c | 10 ++++------ gdb/valarith.c | 9 +++------ gdb/valops.c | 28 ++++++++++------------------ gdb/value.c | 2 +- 5 files changed, 19 insertions(+), 32 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index 70b1247d15e..268397259de 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1261,7 +1261,7 @@ frame_unwind_register_value (frame_info *next_frame, int regnum) else { int i; - const gdb_byte *buf = value_contents (value).data (); + gdb::array_view buf = value_contents (value); fprintf_unfiltered (&debug_file, " bytes="); fprintf_unfiltered (&debug_file, "["); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index e5a404187be..9ab8fbe30c0 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1317,9 +1317,8 @@ eval_op_rust_struct_anon (struct type *expect_type, struct expression *exp, if (rust_enum_p (type)) { - gdb::array_view view (value_contents (lhs).data (), - TYPE_LENGTH (type)); - type = resolve_dynamic_type (type, view, value_address (lhs)); + type = resolve_dynamic_type (type, value_contents (lhs), + value_address (lhs)); if (rust_empty_enum_p (type)) error (_("Cannot access field %d of empty enum %s"), @@ -1380,9 +1379,8 @@ eval_op_rust_structop (struct type *expect_type, struct expression *exp, struct type *type = value_type (lhs); if (type->code () == TYPE_CODE_STRUCT && rust_enum_p (type)) { - gdb::array_view view (value_contents (lhs).data (), - TYPE_LENGTH (type)); - type = resolve_dynamic_type (type, view, value_address (lhs)); + type = resolve_dynamic_type (type, value_contents (lhs), + value_address (lhs)); if (rust_empty_enum_p (type)) error (_("Cannot access field %s of empty enum %s"), diff --git a/gdb/valarith.c b/gdb/valarith.c index ebf394df437..ac995a5cbb0 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -927,12 +927,10 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) type2 = type1; } - v1.read_fixed_point (gdb::make_array_view (value_contents (arg1).data (), - TYPE_LENGTH (type1)), + v1.read_fixed_point (value_contents (arg1), type_byte_order (type1), type1->is_unsigned (), type1->fixed_point_scaling_factor ()); - v2.read_fixed_point (gdb::make_array_view (value_contents (arg2).data (), - TYPE_LENGTH (type2)), + v2.read_fixed_point (value_contents (arg2), type_byte_order (type2), type2->is_unsigned (), type2->fixed_point_scaling_factor ()); } @@ -942,8 +940,7 @@ fixed_point_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) value *fp_val = allocate_value (type1); fp.write_fixed_point - (gdb::make_array_view (value_contents_raw (fp_val).data (), - TYPE_LENGTH (type1)), + (value_contents_raw (fp_val), type_byte_order (type1), type1->is_unsigned (), type1->fixed_point_scaling_factor ()); diff --git a/gdb/valops.c b/gdb/valops.c index 106e12d3234..86a1da11ec3 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -351,9 +351,8 @@ value_to_gdb_mpq (struct value *value) || is_fixed_point_type (type)); gdb_mpz vz; - vz.read (gdb::make_array_view (value_contents (value).data (), - TYPE_LENGTH (type)), - type_byte_order (type), type->is_unsigned ()); + vz.read (value_contents (value), type_byte_order (type), + type->is_unsigned ()); mpq_set_z (result.val, vz.val); if (is_fixed_point_type (type)) @@ -392,8 +391,7 @@ value_cast_to_fixed_point (struct type *to_type, struct value *from_val) /* Finally, create the result value, and pack the unscaled value in it. */ struct value *result = allocate_value (to_type); - unscaled.write (gdb::make_array_view (value_contents_raw (result).data (), - TYPE_LENGTH (to_type)), + unscaled.write (value_contents_raw (result), type_byte_order (to_type), to_type->is_unsigned ()); @@ -554,11 +552,10 @@ value_cast (struct type *type, struct value *arg2) { gdb_mpq fp_val; - fp_val.read_fixed_point - (gdb::make_array_view (value_contents (arg2).data (), - TYPE_LENGTH (type2)), - type_byte_order (type2), type2->is_unsigned (), - type2->fixed_point_scaling_factor ()); + fp_val.read_fixed_point (value_contents (arg2), + type_byte_order (type2), + type2->is_unsigned (), + type2->fixed_point_scaling_factor ()); struct value *v = allocate_value (to_type); target_float_from_host_double (value_contents_raw (v).data (), @@ -1259,14 +1256,9 @@ value_assign (struct value *toval, struct value *fromval) value_contents (fromval).data ()); } else - { - gdb::array_view contents - = gdb::make_array_view (value_contents (fromval).data (), - TYPE_LENGTH (type)); - put_frame_register_bytes (frame, value_reg, - value_offset (toval), - contents); - } + put_frame_register_bytes (frame, value_reg, + value_offset (toval), + value_contents (fromval)); } gdb::observers::register_changed.notify (frame, value_reg); diff --git a/gdb/value.c b/gdb/value.c index 7c86e7e13ca..88080a01df8 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -4010,7 +4010,7 @@ value_fetch_lazy_register (struct value *val) else { int i; - const gdb_byte *buf = value_contents (new_val).data (); + gdb::array_view buf = value_contents (new_val); if (VALUE_LVAL (new_val) == lval_register) fprintf_unfiltered (&debug_file, " register=%d", -- 2.33.0