From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uZ6tKMwt/moL6x0AWB0awg (envelope-from ) for ; Wed, 18 Nov 2026 17:59:24 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=AO5n1eOB; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 9EB071E0BC; Wed, 18 Nov 2026 17:59:24 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (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 ESMTPS id 233601E023 for ; Wed, 18 Nov 2026 17:59:20 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C8E9E4BA23C5 for ; Wed, 18 Nov 2026 22:59:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C8E9E4BA23C5 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=AO5n1eOB Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id 542054BA2E2D for ; Wed, 18 Nov 2026 22:56:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 542054BA2E2D Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 542054BA2E2D Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::336 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795042573; cv=none; b=Q/qBmV9VCsKjANKh3MZlM13Nq9/IpS64liidHgJaTILgIAyskdULwAYdagGT9gWx+gIVlmgGjOALUMu1FQXaJoNTM/m6seVXygFwUaAZRatpKYeI8nSxTJXda7w1YCbCdnfV3t+lfYquLQLuUA5ne6PWErZv5pK6hVcBkIScoWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795042573; c=relaxed/simple; bh=Ng2cIEd1VCEh+mWMCAM9/qZblMwSrRrQGqcLEIYeDsg=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=LIt98HIE2c0DRkkLad0KETAodW0I3+BCjpuRMHHhsqY6wMGz8ipyz0BkLQnMoxyVyzlpSQmZKxR9W7JU2XscaCWqyz96SLo1JLyIUmIBPMy0o3Kbtq2cxam14O6YnDP2bru+3GJLFibd4l70+E0VUcrSlf7Qw/sD/p2V83fRz80= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=AO5n1eOB DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 542054BA2E2D Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-8451a619da7so898258a34.1 for ; Wed, 18 Nov 2026 14:56:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1795042572; x=1795647372; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=t+7d8diimpO0azpaYzFaZVXzLU6erFiYp1h0n0hgLG0=; b=AO5n1eOBmzwrBkbLw7cHR4xkzD2S4sFvL6MgbHHXlitp6wn0FohySnMD5Nlhy8dnkJ PmHNyEMLtQlnOMxG6gYULfzKK5O2uX8bbdoKzDosNOJu3C4ArCH+XJFsWBmWYOxBeXEA GQvvSKOL4nyed1RGM0/idwoGJbqdHsvan9NrIGU9leTAlP5/9HLnX996h7GSEbd0nmFk OrUGEAxUEzs2GViam27TsC96XE3OxX5NNHHZk40ygx1Om/b2en8U2IFHby8LkemsFvBG vqpalzHpLKfCBgmqasDY+fY1MkflfyqvW0d6pgANxVWnwCpbK2je6/pPbKJkJ7pcmFEH MSTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795042572; x=1795647372; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=t+7d8diimpO0azpaYzFaZVXzLU6erFiYp1h0n0hgLG0=; b=lGRe6Lr4H9vNa/jQ+U6XTgJeOFOOK1mkJ+leSx5ak8yrzrMfgtuUYFQ7vVeDUIJ5zB opskwa3ZhBWRod0/Z8JiU5zTmbByFP3MXMYbGQ5mjHtSOFkvHswK7CkxXMeiOtrKFAUc R9DOju8pwoIIz3UFQyzd3VEfEMRr3GmImqYJ+4bW3nnKFLqtz73i0KMOICTayTPxyT8G A0bwatU+d56wgEfNvHwtIOVBOUuB1qd2rOXJvViVpDYAsrjfk1/vDtjBGgPkt+U7FOjj cFVfPUsaavfyIoHA0glf6HyeEEZJ5rt9h0P7h2F5+LKFxa7VmwMgumFV155FRAHgqbLW e9MQ== X-Gm-Message-State: APuU4Z8qvqsvzyGOZ0gL06Mfk0gu4apzhYtR3jto2Icv0/f+g9C4Vcu/ Vabv3w8I5Fg3ZVvRqSADYdR3mZGAlcnPwKG/d4UbmufA0xWppK1n86uXyKzptDRwsVXCEqC2d9K kK2jxmw== X-Gm-Gg: AYBFou0HjoU1K2n7MQANCYfmIjQXhWNnSVlMso4j3uXwfsfmoJngN4yXhe8l9+zNSDc zeMjrc8fRQNpeaC0W39oYZEHZoPpaTR7Hxn3nah9Uesi6tKM1bgKtZgMBwjemsOFQV1EGZZIIee eQbh14xo2iICSkuTheePWSLJO7ytx443KLiM13huePbuBaPngFlzN6waclB85uTmmaS4NVULapo 8fEytYKYQq9INvIEHUfFOisKWx/ptYBvbvVsqFw9Xu0MgyWCgeuGKzz4mvryExIPQ9GSpBq2I4w St6K88KQrAkre67LCd0VDJW7nB8pKBMRb2MwdUnENaZJDfChCSeFXChDTaGOWbQVkgUM0j29y0A 7Fj00JYXKZ4T9omFptlYhwe2D+Bs6QuAIv5ubQYhWawbfj6R5nXjgCKbgKH/70T7nrkoifV3OET uiyFG1jJWowfMMAg8niyaPMHa1MmInOQqUSVke8FGXQ0gPK/OpXUim4OMIe0BSeyADsCEZ1Q3ze ziJhbG3hfepfF513Gdt3ePk9UpfyppnXeaPHMzzhFzGbkyzd2Qzy68BZDu02orGK4mPsTXB/4lw DLx5r5H1xzHWKyfB7L3cVmTW3wLlqzjr+hpDNO99x8ywSv9d9yib7hz5EgcCZg== X-Received: by 2002:a05:6830:2709:b0:862:a48e:24c7 with SMTP id 46e09a7af769-862f09b56fdmr4142144a34.30.1795042570411; Wed, 18 Nov 2026 14:56:10 -0800 (PST) Received: from [192.168.0.26] (97-122-110-129.hlrn.qwest.net. [97.122.110.129]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-862f01d4764sm2986263a34.5.2026.11.18.14.56.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2026 14:56:09 -0800 (PST) From: Tom Tromey Date: Wed, 18 Nov 2026 15:56:03 -0700 Subject: [PATCH v4 02/16] Rename gdb::array_view to gdb::span MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261118-span-part-1-v4-2-5ecf901e570b@adacore.com> References: <20261118-span-part-1-v4-0-5ecf901e570b@adacore.com> In-Reply-To: <20261118-span-part-1-v4-0-5ecf901e570b@adacore.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.16.0 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This rename gdb::array_view to gdb::span. The long term idea here is to eventually use the C++20 std::span. This rename was mostly done by a perl script. In v2 I've also updated various comments, re-run make-target-delegates.py, and updated target-debug.h. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31422 --- gdb/aarch64-tdep.c | 18 +-- gdb/ada-lang.c | 6 +- gdb/ada-typeprint.c | 4 +- gdb/ada-valprint.c | 2 +- gdb/amd64-tdep.c | 2 +- gdb/amd64-windows-tdep.c | 6 +- gdb/arch/arm-get-next-pcs.c | 2 +- gdb/arm-pikeos-tdep.c | 2 +- gdb/arm-tdep.c | 10 +- gdb/block.c | 4 +- gdb/block.h | 16 +-- gdb/breakpoint.c | 14 +-- gdb/breakpoint.h | 6 +- gdb/cli/cli-cmds.c | 4 +- gdb/cli/cli-option.c | 16 +-- gdb/cli/cli-option.h | 14 +-- gdb/compile/compile-loc2c.c | 12 +- gdb/compile/compile-object-load.c | 4 +- gdb/compile/compile.h | 4 +- gdb/corelow.c | 2 +- gdb/cp-support.c | 2 +- gdb/cp-support.h | 2 +- gdb/dicos-tdep.c | 2 +- gdb/disasm-selftests.c | 6 +- gdb/disasm.c | 4 +- gdb/displaced-stepping.h | 2 +- gdb/dwarf2/attribute.h | 2 +- gdb/dwarf2/call-site.h | 4 +- gdb/dwarf2/expr.c | 16 +-- gdb/dwarf2/expr.h | 16 +-- gdb/dwarf2/frame.c | 4 +- gdb/dwarf2/frame.h | 6 +- gdb/dwarf2/index-cache.c | 6 +- gdb/dwarf2/index-cache.h | 12 +- gdb/dwarf2/index-write.c | 2 +- gdb/dwarf2/loc.c | 32 ++--- gdb/dwarf2/loc.h | 18 +-- gdb/dwarf2/read-gdb-index.c | 24 ++-- gdb/dwarf2/read-gdb-index.h | 4 +- gdb/dwarf2/read.c | 42 +++---- gdb/dwarf2/read.h | 2 +- gdb/elfread.c | 2 +- gdb/eval.c | 12 +- gdb/expression.h | 2 +- gdb/extension.c | 2 +- gdb/extension.h | 6 +- gdb/extract-store-integer.c | 12 +- gdb/extract-store-integer.h | 16 +-- gdb/f-lang.c | 2 +- gdb/fbsd-nat.c | 2 +- gdb/fbsd-nat.h | 2 +- gdb/findvar.c | 4 +- gdb/frame-unwind.c | 4 +- gdb/frame-unwind.h | 2 +- gdb/frame.c | 22 ++-- gdb/frame.h | 18 +-- gdb/gdb-gdb.gdb | 2 +- gdb/gdb_bfd.c | 4 +- gdb/gdb_bfd.h | 2 +- gdb/gdbarch-gen.c | 2 +- gdb/gdbarch-gen.h | 4 +- gdb/gdbarch_components.py | 2 +- gdb/gdbthread.h | 2 +- gdb/gdbtypes.c | 12 +- gdb/gdbtypes.h | 24 ++-- gdb/gmp-utils.c | 8 +- gdb/gmp-utils.h | 14 +-- gdb/i386-tdep.c | 2 +- gdb/i386-tdep.h | 2 +- gdb/i386-windows-tdep.c | 2 +- gdb/infcall.c | 6 +- gdb/infcall.h | 4 +- gdb/inferior.h | 2 +- gdb/linux-nat.c | 4 +- gdb/linux-nat.h | 4 +- gdb/linux-thread-db.c | 4 +- gdb/main.c | 2 +- gdb/minsyms.c | 6 +- gdb/mips-tdep.c | 8 +- gdb/nat/x86-linux.c | 4 +- gdb/nat/x86-linux.h | 4 +- gdb/netbsd-nat.c | 2 +- gdb/netbsd-nat.h | 2 +- gdb/objfiles.c | 4 +- gdb/objfiles.h | 2 +- gdb/procfs.c | 4 +- gdb/python/py-connection.c | 6 +- gdb/python/py-inferior.c | 4 +- gdb/python/py-infthread.c | 2 +- gdb/python/py-unwind.c | 2 +- gdb/python/py-value.c | 4 +- gdb/python/py-wrappers.h | 2 +- gdb/python/py-xmethods.c | 8 +- gdb/python/python.c | 2 +- gdb/ravenscar-thread.h | 4 +- gdb/regcache.c | 56 ++++----- gdb/regcache.h | 36 +++--- gdb/remote.c | 28 ++--- gdb/remote.h | 6 +- gdb/rust-lang.c | 2 +- gdb/solib-darwin.c | 2 +- gdb/solib.c | 2 +- gdb/source.c | 2 +- gdb/symtab.c | 4 +- gdb/symtab.h | 6 +- gdb/target-debug.h | 10 +- gdb/target-delegates-gen.c | 48 +++---- gdb/target.c | 8 +- gdb/target.h | 18 +-- gdb/thread.c | 2 +- gdb/trad-frame.c | 2 +- gdb/trad-frame.h | 6 +- gdb/unittests/intrusive_list-selftests.c | 2 +- gdb/unittests/ranges-selftests.c | 2 +- gdb/unittests/span-selftests.c | 206 +++++++++++++++---------------- gdb/utils.c | 4 +- gdb/valarith.c | 22 ++-- gdb/valops.c | 36 +++--- gdb/value.c | 50 ++++---- gdb/value.h | 30 ++--- gdb/windows-tdep.c | 6 +- gdb/windows-tdep.h | 4 +- gdb/x86-linux-nat.c | 4 +- gdb/xcoffread.c | 2 +- gdbserver/linux-x86-low.cc | 4 +- gdbserver/regcache.cc | 8 +- gdbserver/regcache.h | 4 +- gdbserver/server.cc | 2 +- gdbserver/target.cc | 2 +- gdbserver/target.h | 2 +- gdbsupport/buildargv.h | 8 +- gdbsupport/common-inferior.cc | 8 +- gdbsupport/common-inferior.h | 2 +- gdbsupport/common-regcache.h | 4 +- gdbsupport/common-utils.cc | 2 +- gdbsupport/common-utils.h | 4 +- gdbsupport/pathstuff.cc | 2 +- gdbsupport/pathstuff.h | 4 +- gdbsupport/remote-args.h | 2 +- gdbsupport/rsp-low.cc | 2 +- gdbsupport/rsp-low.h | 2 +- gdbsupport/selftest.cc | 2 +- gdbsupport/selftest.h | 2 +- gdbsupport/span.h | 92 +++++++------- 144 files changed, 703 insertions(+), 703 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 109fca6bf11..ffd553fd981 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -3556,7 +3556,7 @@ aarch64_pseudo_read_value (gdbarch *gdbarch, const frame_info_ptr &next_frame, static void aarch64_pseudo_write_1 (gdbarch *gdbarch, const frame_info_ptr &next_frame, int regnum_offset, - gdb::array_view buf) + gdb::span buf) { unsigned raw_regnum = AARCH64_V0_REGNUM + regnum_offset; @@ -3569,7 +3569,7 @@ aarch64_pseudo_write_1 (gdbarch *gdbarch, const frame_info_ptr &next_frame, gdb::byte_vector raw_buf (register_size (gdbarch, raw_regnum), 0); static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM); - gdb::array_view raw_view (raw_buf); + gdb::span raw_view (raw_buf); copy (buf, raw_view.slice (0, buf.size ())); put_frame_register (next_frame, raw_regnum, raw_view); } @@ -3580,7 +3580,7 @@ aarch64_pseudo_write_1 (gdbarch *gdbarch, const frame_info_ptr &next_frame, static void aarch64_sme_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, const int regnum, - gdb::array_view data) + gdb::span data) { aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); @@ -3598,15 +3598,15 @@ aarch64_sme_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_ { /* Create a view only on the portion of za we want to write. */ - gdb::array_view za_view + gdb::span za_view = za_value->contents_writeable ().slice (offsets.starting_offset); /* Copy the requested data. */ for (int chunks = 0; chunks < offsets.chunks; chunks++) { - gdb::array_view src + gdb::span src = data.slice (chunks * offsets.chunk_size, offsets.chunk_size); - gdb::array_view dst + gdb::span dst = za_view.slice (chunks * offsets.stride_size, offsets.chunk_size); copy (src, dst); } @@ -3624,7 +3624,7 @@ static void aarch64_poe_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, const int pseudo_reg_num, - gdb::array_view data) + gdb::span data) { aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); @@ -3664,7 +3664,7 @@ aarch64_poe_pseudo_register_write (gdbarch *gdbarch, static void aarch64_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, const int pseudo_reg_num, - gdb::array_view buf) + gdb::span buf) { aarch64_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); @@ -3682,7 +3682,7 @@ aarch64_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, /* First zero-out the contents of X. */ gdb_byte bytes[8] {}; - gdb::array_view bytes_view (bytes); + gdb::span bytes_view (bytes); copy (buf, bytes_view.slice (offset, 4)); /* Write to the bottom 4 bytes of X. */ diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 30083e8c41d..bc861b0d944 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2584,7 +2584,7 @@ decode_constrained_packed_array (struct value *arr) sizes. */ const gdb_byte *valaddr = arr->contents_for_printing ().data (); CORE_ADDR address = arr->address (); - gdb::array_view view + gdb::span view = gdb::make_array_view (valaddr, type->length ()); type = resolve_dynamic_type (type, view, address); recursively_update_array_bitsize (type); @@ -6360,7 +6360,7 @@ value_tag_from_contents_and_address (struct type *type, int tag_byte_offset; struct type *tag_type; - gdb::array_view contents; + gdb::span contents; if (valaddr != nullptr) contents = gdb::make_array_view (valaddr, type->length ()); struct type *resolved_type = resolve_dynamic_type (type, contents, address); @@ -9204,7 +9204,7 @@ ada_promote_array_of_integrals (struct type *type, struct value *val) error (_("unable to determine array bounds")); value *res = value::allocate (type); - gdb::array_view res_contents = res->contents_writeable (); + gdb::span res_contents = res->contents_writeable (); /* Promote each array element. */ for (i = 0; i < hi - lo + 1; i++) diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index 15045a02f35..5e2bf675c12 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -649,7 +649,7 @@ print_selected_record_field_types (struct type *type, struct type *outer_type, } static void print_record_field_types_dynamic - (const gdb::array_view &parts, + (const gdb::span &parts, int from, int to, struct type *type, struct ui_file *stream, int show, int level, const struct type_print_options *flags); @@ -735,7 +735,7 @@ print_variant_part (const variant_part &part, and TO are the range of fields to print. */ static void -print_record_field_types_dynamic (const gdb::array_view &parts, +print_record_field_types_dynamic (const gdb::span &parts, int from, int to, struct type *type, struct ui_file *stream, int show, int level, diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 7bb5e1394b0..a533c83a6c8 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -852,7 +852,7 @@ ada_value_print_inner (struct value *val, struct ui_file *stream, int recurse, const gdb_byte *valaddr = val->contents_for_printing ().data (); CORE_ADDR address = val->address (); - gdb::array_view view + gdb::span view = gdb::make_array_view (valaddr, type->length ()); type = ada_check_typedef (resolve_dynamic_type (type, view, address)); if (type != saved_type) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 18b8f2a4c0b..60c89bf5e7f 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -527,7 +527,7 @@ amd64_pseudo_register_read_value (gdbarch *gdbarch, const frame_info_ptr &next_f static void amd64_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, - int regnum, gdb::array_view buf) + int regnum, gdb::span buf) { i386_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index 68dd2f354fe..33b149f8de4 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -205,7 +205,7 @@ static void amd64_windows_store_arg_in_reg (struct regcache *regcache, struct value *arg, int regno) { - gdb::array_view valbuf = arg->contents (); + gdb::span valbuf = arg->contents (); /* We only set 8 bytes, buf if it's a XMM register, 16 bytes are read. */ std::array buf {}; @@ -213,7 +213,7 @@ amd64_windows_store_arg_in_reg (struct regcache *regcache, std::copy (valbuf.begin (), valbuf.end (), buf.begin ()); size_t reg_size = regcache->register_size (regno); gdb_assert (reg_size <= buf.size ()); - gdb::array_view view (buf); + gdb::span view (buf); regcache->cooked_write (regno, view.slice (0, reg_size)); } @@ -1337,7 +1337,7 @@ static const gdb_byte amd64_sigdelayed_bytes[] = { /* 4 bytes for tls::stackptr operand. */ }; -static const gdb::array_view amd64_sig_patterns[] { +static const gdb::span amd64_sig_patterns[] { { amd64_sigbe_bytes }, { amd64_sigdelayed_bytes }, }; diff --git a/gdb/arch/arm-get-next-pcs.c b/gdb/arch/arm-get-next-pcs.c index 4f5ecc36fee..8ea93c3193a 100644 --- a/gdb/arch/arm-get-next-pcs.c +++ b/gdb/arch/arm-get-next-pcs.c @@ -42,7 +42,7 @@ arm_get_next_pcs_ctor (struct arm_get_next_pcs *self, /* Return true if INSN matches one of the pairs in MATCHES. */ static bool -insn_matches (uint32_t insn, gdb::array_view matches) +insn_matches (uint32_t insn, gdb::span matches) { gdb_assert (matches.size () % 2 == 0); diff --git a/gdb/arm-pikeos-tdep.c b/gdb/arm-pikeos-tdep.c index 8b84cc3f68a..e2704fb0c38 100644 --- a/gdb/arm-pikeos-tdep.c +++ b/gdb/arm-pikeos-tdep.c @@ -48,7 +48,7 @@ arm_pikeos_osabi_sniffer (bfd *abfd) OS ABI sniffers are called before the minimal symtabs are created. So inspect the symbol table using BFD. */ - gdb::array_view symbol_table + gdb::span symbol_table = gdb_bfd_canonicalize_symtab (abfd, false); if (symbol_table.empty ()) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index bffd5d22199..94b11e1715d 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -9868,7 +9868,7 @@ arm_neon_quad_write (struct gdbarch *gdbarch, struct regcache *regcache, static void arm_neon_quad_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, - int quad_reg_index, gdb::array_view buf) + int quad_reg_index, gdb::span buf) { std::string raw_reg_name = string_printf ("d%d", quad_reg_index << 1); int double_regnum @@ -9881,7 +9881,7 @@ arm_neon_quad_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, static void arm_mve_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, - int pseudo_reg_num, gdb::array_view buf) + int pseudo_reg_num, gdb::span buf) { arm_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); @@ -9892,7 +9892,7 @@ arm_mve_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, static void arm_pseudo_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, const int pseudo_reg_num, - gdb::array_view buf) + gdb::span buf) { arm_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); @@ -14761,7 +14761,7 @@ arm_record_test (void) class test_arm_instruction_reader : public arm_instruction_reader { public: - explicit test_arm_instruction_reader (gdb::array_view insns) + explicit test_arm_instruction_reader (gdb::span insns) : m_insns (insns) {} @@ -14774,7 +14774,7 @@ class test_arm_instruction_reader : public arm_instruction_reader } private: - const gdb::array_view m_insns; + const gdb::span m_insns; }; static void diff --git a/gdb/block.c b/gdb/block.c index ae9af08acb8..cb449591d21 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -372,7 +372,7 @@ block::static_link () const void block::relocate (struct objfile *objfile, - gdb::array_view offsets) + gdb::span offsets) { int block_line_section = SECT_OFF_TEXT (objfile); @@ -874,7 +874,7 @@ blockvector::~blockvector () void blockvector::relocate (struct objfile *objfile, - gdb::array_view offsets) + gdb::span offsets) { int block_line_section = SECT_OFF_TEXT (objfile); diff --git a/gdb/block.h b/gdb/block.h index 2fc1bdea919..69f980e2c2d 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -157,7 +157,7 @@ struct block : public allocate_on_obstack { m_multidict = multidict; } /* Return a view on this block's ranges. */ - gdb::array_view ranges () + gdb::span ranges () { if (m_ranges == nullptr) return {}; @@ -166,7 +166,7 @@ struct block : public allocate_on_obstack } /* Const version of the above. */ - gdb::array_view ranges () const + gdb::span ranges () const { if (m_ranges == nullptr) return {}; @@ -319,7 +319,7 @@ struct block : public allocate_on_obstack objfile holding this block, and OFFSETS is the relocation offsets to use. */ void relocate (struct objfile *objfile, - gdb::array_view offsets); + gdb::span offsets); private: @@ -435,17 +435,17 @@ struct blockvector DISABLE_COPY_AND_ASSIGN (blockvector); /* Return a view on the blocks of this blockvector. */ - gdb::array_view blocks () + gdb::span blocks () { - return gdb::array_view (m_blocks.data (), + return gdb::span (m_blocks.data (), m_blocks.size ()); } /* Const version of the above. */ - gdb::array_view blocks () const + gdb::span blocks () const { const struct block **blocks = (const struct block **) m_blocks.data (); - return gdb::array_view (blocks, + return gdb::span (blocks, m_blocks.size ()); } @@ -519,7 +519,7 @@ struct blockvector the objfile holding this blockvector, and OFFSETS is the relocation offsets to use. */ void relocate (struct objfile *objfile, - gdb::array_view offsets); + gdb::span offsets); private: /* An address map mapping addresses to blocks in this blockvector. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index a90c2de7ab5..a5ac06c46c3 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -794,7 +794,7 @@ maintenance_info_source_tracking_context (const char *args, int from_tty) empty structure if capture fails. Does not print the lines. */ static breakpoint_source -breakpoint_source_capture (gdb::array_view sals, +breakpoint_source_capture (gdb::span sals, int num_of_lines) { /* Check if we have a valid symtab - if not, we can't capture source lines. @@ -9032,7 +9032,7 @@ update_dprintf_commands (const char *args, int from_tty, code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_, enum bptype type_, - gdb::array_view sals, + gdb::span sals, location_spec_up &&locspec_, gdb::unique_xmalloc_ptr filter_, gdb::unique_xmalloc_ptr cond_string_, @@ -9161,7 +9161,7 @@ code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_, static void create_breakpoint_sal (struct gdbarch *gdbarch, - gdb::array_view sals, + gdb::span sals, location_spec_up &&locspec, gdb::unique_xmalloc_ptr filter, gdb::unique_xmalloc_ptr cond_string, @@ -9377,7 +9377,7 @@ breakpoint_sals_to_pc (std::vector &sals) static void check_fast_tracepoint_sals (struct gdbarch *gdbarch, - gdb::array_view sals) + gdb::span sals) { for (const auto &sal : sals) { @@ -11340,7 +11340,7 @@ clear_command (const char *arg, int from_tty) std::vector decoded_sals; symtab_and_line last_sal; - gdb::array_view sals; + gdb::span sals; if (arg) { decoded_sals @@ -13285,8 +13285,8 @@ breakpoint::steal_locations (program_space *pspace) void update_breakpoint_locations (code_breakpoint *b, struct program_space *filter_pspace, - gdb::array_view sals, - gdb::array_view sals_end) + gdb::span sals, + gdb::span sals_end) { if (!sals_end.empty () && (sals.size () != 1 || sals_end.size () != 1)) { diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 5a70785382a..62567db141c 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -950,7 +950,7 @@ struct code_breakpoint : public breakpoint expression. If LOCATION is NULL then create an "address location" from the address in the SAL. */ code_breakpoint (struct gdbarch *gdbarch, bptype type, - gdb::array_view sals, + gdb::span sals, location_spec_up &&locspec, gdb::unique_xmalloc_ptr filter, gdb::unique_xmalloc_ptr cond_string, @@ -1532,8 +1532,8 @@ extern void until_break_command (const char *, int, int); extern void update_breakpoint_locations (code_breakpoint *b, struct program_space *filter_pspace, - gdb::array_view sals, - gdb::array_view sals_end); + gdb::span sals, + gdb::span sals_end); extern void breakpoint_re_set (void); diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index cb6ad07704d..9ed0b8b4ffe 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -73,7 +73,7 @@ static void print_sal_location (const symtab_and_line &sal); -static void ambiguous_line_spec (gdb::array_view sals, +static void ambiguous_line_spec (gdb::span sals, const char *format, ...) ATTRIBUTE_PRINTF (2, 3); @@ -2332,7 +2332,7 @@ print_sal_location (const symtab_and_line &sal) ambiguous. */ static void -ambiguous_line_spec (gdb::array_view sals, +ambiguous_line_spec (gdb::span sals, const char *format, ...) { va_list ap; diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c index 435a86efc86..b4fafaa898c 100644 --- a/gdb/cli/cli-option.c +++ b/gdb/cli/cli-option.c @@ -152,7 +152,7 @@ find_end_options_delimiter (const char *args) /* Complete TEXT/WORD on all options in OPTIONS_GROUP. */ static void -complete_on_options (gdb::array_view options_group, +complete_on_options (gdb::span options_group, completion_tracker &tracker, const char *text, const char *word) { @@ -170,7 +170,7 @@ complete_on_options (gdb::array_view options_group, void complete_on_all_options (completion_tracker &tracker, - gdb::array_view options_group) + gdb::span options_group) { static const char opt[] = "-"; complete_on_options (options_group, tracker, opt + 1, opt); @@ -180,7 +180,7 @@ complete_on_all_options (completion_tracker &tracker, whole ARGS line included the "--" options-terminator delimiter. */ static std::optional -parse_option (gdb::array_view options_group, +parse_option (gdb::span options_group, process_options_mode mode, bool have_delimiter, const char **args, @@ -570,7 +570,7 @@ bool complete_options (completion_tracker &tracker, const char **args, process_options_mode mode, - gdb::array_view options_group) + gdb::span options_group) { const char *text = *args; @@ -734,7 +734,7 @@ save_option_value_in_ctx (std::optional &ov) bool process_options (const char **args, process_options_mode mode, - gdb::array_view options_group) + gdb::span options_group) { if (*args == nullptr) return false; @@ -866,7 +866,7 @@ append_indented_doc (const char *doc, std::string &help) OPTIONS. */ static void -build_help_option (gdb::array_view options, +build_help_option (gdb::span options, std::string &help) { std::string buffer; @@ -895,7 +895,7 @@ build_help_option (gdb::array_view options, std::string build_help (const char *help_tmpl, - gdb::array_view options_group) + gdb::span options_group) { bool need_newlines = false; std::string help_str; @@ -924,7 +924,7 @@ build_help (const char *help_tmpl, void add_setshow_cmds_for_options (command_class cmd_class, void *data, - gdb::array_view options, + gdb::span options, struct cmd_list_element **set_list, struct cmd_list_element **show_list) { diff --git a/gdb/cli/cli-option.h b/gdb/cli/cli-option.h index 99a8db2f8c7..0644872641c 100644 --- a/gdb/cli/cli-option.h +++ b/gdb/cli/cli-option.h @@ -116,7 +116,7 @@ struct option_def /* Convenience method that returns THIS as an option_def. Useful when you're putting an option_def subclass in an option_def - array_view. */ + span. */ const option_def &def () const { return *this; @@ -354,7 +354,7 @@ struct color_option_def : option_def struct option_def_group { /* The list of options. */ - gdb::array_view options; + gdb::span options; /* The context pointer to pass to the options' get-current-value callbacks. */ @@ -385,7 +385,7 @@ enum process_options_mode extern bool process_options (const char **args, process_options_mode mode, - gdb::array_view options_group); + gdb::span options_group); /* Complete ARGS on options listed by OPTIONS_GROUP. Returns true if the string has been fully parsed and there are no operands to @@ -395,25 +395,25 @@ extern bool complete_options (completion_tracker &tracker, const char **args, process_options_mode mode, - gdb::array_view options_group); + gdb::span options_group); /* Complete on all options listed by OPTIONS_GROUP. */ extern void complete_on_all_options (completion_tracker &tracker, - gdb::array_view options_group); + gdb::span options_group); /* Return a string with the result of replacing %OPTIONS% in HELP_TMLP with an auto-generated "help" string fragment for all the options in OPTIONS_GROUP. */ extern std::string build_help (const char *help_tmpl, - gdb::array_view options_group); + gdb::span options_group); /* Install set/show commands for options defined in OPTIONS. DATA is a pointer to the structure that holds the data associated with the OPTIONS array. */ extern void add_setshow_cmds_for_options (command_class cmd_class, void *data, - gdb::array_view options, + gdb::span options, struct cmd_list_element **set_list, struct cmd_list_element **show_list); diff --git a/gdb/compile/compile-loc2c.c b/gdb/compile/compile-loc2c.c index 5e208a86563..add5f6f6620 100644 --- a/gdb/compile/compile-loc2c.c +++ b/gdb/compile/compile-loc2c.c @@ -77,7 +77,7 @@ compute_stack_depth_worker (int start, int *need_tempvar, std::vector *info, std::vector *to_do, enum bfd_endian byte_order, unsigned int addr_size, - gdb::array_view expr) + gdb::span expr) { const gdb_byte *const base = expr.data (); const gdb_byte *op_ptr = expr.data (); @@ -390,7 +390,7 @@ compute_stack_depth_worker (int start, int *need_tempvar, static int compute_stack_depth (enum bfd_endian byte_order, unsigned int addr_size, int *need_tempvar, int *is_tls, - gdb::array_view expr, + gdb::span expr, int initial_depth, std::vector *info) { @@ -596,7 +596,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, struct gdbarch *arch, std::vector ®isters_used, unsigned int addr_size, - gdb::array_view expr, + gdb::span expr, CORE_ADDR *initial, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile) @@ -1074,7 +1074,7 @@ do_compile_dwarf_expr_to_c (int indent, string_file *stream, int regnum; CORE_ADDR text_offset; LONGEST off; - gdb::array_view cfa_expr; + gdb::span cfa_expr; if (dwarf2_fetch_cfa_info (arch, pc, per_cu, ®num, &off, &text_offset, cfa_expr)) @@ -1144,7 +1144,7 @@ compile_dwarf_expr_to_c (string_file *stream, const char *result_name, struct gdbarch *arch, std::vector ®isters_used, unsigned int addr_size, - gdb::array_view expr, + gdb::span expr, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile) { @@ -1163,7 +1163,7 @@ compile_dwarf_bounds_to_c (string_file *stream, struct gdbarch *arch, std::vector ®isters_used, unsigned int addr_size, - gdb::array_view expr, + gdb::span expr, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile) { diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index a70282c4e0c..5378f2e7895 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -333,7 +333,7 @@ struct link_hash_table_cleanup_data static void copy_section (bfd *abfd, asection *sect, - gdb::array_view symbol_table) + gdb::span symbol_table) { bfd_byte *sect_data_got; struct bfd_link_info link_info; @@ -689,7 +689,7 @@ compile_object_load (const compile_file_names &file_names, GCC_FE_WRAPPER_FUNCTION, styled_string (file_name_style.style (), objfile_name (objfile))); - gdb::array_view symbol_table + gdb::span symbol_table = gdb_bfd_canonicalize_symtab (abfd.get ()); missing_symbols = 0; diff --git a/gdb/compile/compile.h b/gdb/compile/compile.h index 15fc22cb62c..060adbaa2e4 100644 --- a/gdb/compile/compile.h +++ b/gdb/compile/compile.h @@ -213,7 +213,7 @@ extern void compile_dwarf_expr_to_c (string_file *stream, struct gdbarch *arch, std::vector ®isters_used, unsigned int addr_size, - gdb::array_view expr, + gdb::span expr, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile); @@ -251,7 +251,7 @@ extern void compile_dwarf_bounds_to_c (string_file *stream, struct gdbarch *arch, std::vector ®isters_used, unsigned int addr_size, - gdb::array_view expr, + gdb::span expr, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile); diff --git a/gdb/corelow.c b/gdb/corelow.c index 49031b29b2e..081fbe96023 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -1190,7 +1190,7 @@ core_target_open (const char *arg, int from_tty) std::vector argv; for (const gdb::unique_xmalloc_ptr &a : ctx.args ()) argv.push_back (a.get ()); - gdb::array_view view (argv.data (), argv.size ()); + gdb::span view (argv.data (), argv.size ()); current_inferior ()->set_args (view, true); /* And now copy the environment. */ diff --git a/gdb/cp-support.c b/gdb/cp-support.c index 7a1b07a3b16..51c836a06d0 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1354,7 +1354,7 @@ add_symbol_overload_list_adl_namespace (struct type *type, FUNC_NAME found through argument dependent lookup. */ void -add_symbol_overload_list_adl (gdb::array_view arg_types, +add_symbol_overload_list_adl (gdb::span arg_types, const char *func_name, std::vector *overload_list) { diff --git a/gdb/cp-support.h b/gdb/cp-support.h index dfb6865831b..b3040506c8a 100644 --- a/gdb/cp-support.h +++ b/gdb/cp-support.h @@ -114,7 +114,7 @@ extern std::vector make_symbol_overload_list (const char *, const char *); extern void add_symbol_overload_list_adl - (gdb::array_view arg_types, + (gdb::span arg_types, const char *func_name, std::vector *overload_list); diff --git a/gdb/dicos-tdep.c b/gdb/dicos-tdep.c index 805889174d1..0d0c865faa5 100644 --- a/gdb/dicos-tdep.c +++ b/gdb/dicos-tdep.c @@ -73,7 +73,7 @@ dicos_load_module_p (bfd *abfd, int header_size) /* Dicos LMs always have a "Dicos_loadModuleInfo" symbol defined. Look for it. */ - gdb::array_view symbol_table + gdb::span symbol_table = gdb_bfd_canonicalize_symtab (abfd, false); for (asymbol *sym : symbol_table) diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c index 485c1245118..90b16b2f8c1 100644 --- a/gdb/disasm-selftests.c +++ b/gdb/disasm-selftests.c @@ -334,7 +334,7 @@ memory_error_test (struct gdbarch *gdbarch) static std::string disassemble_one_insn_to_string (struct gdbarch *gdbarch, - gdb::array_view insn) + gdb::span insn) { string_file buffer; @@ -343,7 +343,7 @@ disassemble_one_insn_to_string (struct gdbarch *gdbarch, public: explicit gdb_disassembler_test (struct gdbarch *gdbarch, - gdb::array_view insn, + gdb::span insn, string_file &buffer) : gdb_disassembler (gdbarch, &buffer, @@ -366,7 +366,7 @@ disassemble_one_insn_to_string (struct gdbarch *gdbarch, } private: - gdb::array_view m_insn; + gdb::span m_insn; static int read_memory (bfd_vma memaddr, gdb_byte *myaddr, unsigned int len, diff --git a/gdb/disasm.c b/gdb/disasm.c index 01361fe4323..5c4fbf616dd 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -1224,7 +1224,7 @@ struct gdb_non_printing_buffer_disassembler contains the instruction to disassemble, and INSN_ADDRESS is the address (in target memory) of the instruction to disassemble. */ gdb_non_printing_buffer_disassembler (struct gdbarch *gdbarch, - gdb::array_view buffer, + gdb::span buffer, CORE_ADDR insn_address) : gdb_non_printing_disassembler (gdbarch, nullptr) { @@ -1242,7 +1242,7 @@ int gdb_buffered_insn_length (struct gdbarch *gdbarch, const gdb_byte *insn, int max_len, CORE_ADDR addr) { - gdb::array_view buffer + gdb::span buffer = gdb::make_array_view (insn, max_len); gdb_non_printing_buffer_disassembler dis (gdbarch, buffer, addr); int result = gdb_print_insn_1 (gdbarch, addr, dis.disasm_info ()); diff --git a/gdb/displaced-stepping.h b/gdb/displaced-stepping.h index e0bb77a3fff..e2bd9d21003 100644 --- a/gdb/displaced-stepping.h +++ b/gdb/displaced-stepping.h @@ -193,7 +193,7 @@ struct displaced_step_thread_state struct displaced_step_buffers { - explicit displaced_step_buffers (gdb::array_view buffer_addrs) + explicit displaced_step_buffers (gdb::span buffer_addrs) { gdb_assert (buffer_addrs.size () > 0); diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index f2648747d9c..1cd772e861e 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -34,7 +34,7 @@ struct dwarf_block { /* Return the contents of this block. */ - gdb::array_view view () const + gdb::span view () const { return gdb::make_array_view (data, size); } size_t size; diff --git a/gdb/dwarf2/call-site.h b/gdb/dwarf2/call-site.h index cfd2953cce1..b6d13f9649b 100644 --- a/gdb/dwarf2/call-site.h +++ b/gdb/dwarf2/call-site.h @@ -144,12 +144,12 @@ union call_site_parameter_u struct call_site_parameter { /* Return the DW_AT_call_value DWARF expression. */ - gdb::array_view value_expr () const + gdb::span value_expr () const { return gdb::make_array_view (value, value_size); } /* Return the DW_AT_call_data_value DWARF expression. Returns an empty view if not provided by DWARF. */ - gdb::array_view data_value_expr () const + gdb::span data_value_expr () const { return gdb::make_array_view (data_value, data_value_size); } call_site_parameter_kind kind : 2; diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c index f2e4deffd16..2fbde469c6e 100644 --- a/gdb/dwarf2/expr.c +++ b/gdb/dwarf2/expr.c @@ -825,7 +825,7 @@ dwarf_expr_context::fetch (int n) /* See expr.h. */ -gdb::array_view +gdb::span dwarf_expr_context::get_frame_base () { ensure_have_frame (this->m_frame, "DW_OP_fbreg"); @@ -1158,7 +1158,7 @@ dwarf_expr_context::fetch_result (struct type *type, struct type *subobj_type, /* See expr.h. */ value * -dwarf_expr_context::evaluate (gdb::array_view expr, +dwarf_expr_context::evaluate (gdb::span expr, bool as_lval, dwarf2_per_cu *per_cu, const frame_info_ptr &frame, const struct property_addr_info *addr_info, @@ -1327,7 +1327,7 @@ dwarf_expr_context::add_piece (ULONGEST size, ULONGEST offset, /* Evaluate the expression EXPR. */ void -dwarf_expr_context::eval (gdb::array_view expr) +dwarf_expr_context::eval (gdb::span expr) { int old_recursion_depth = this->m_recursion_depth; @@ -1408,7 +1408,7 @@ base_types_equal_p (struct type *t1, struct type *t2) DWARF register number. Otherwise return -1. */ int -dwarf_block_to_dwarf_reg (gdb::array_view block) +dwarf_block_to_dwarf_reg (gdb::span block) { uint64_t dwarf_reg; const gdb_byte *buf = block.data (); @@ -1453,7 +1453,7 @@ dwarf_block_to_dwarf_reg (gdb::array_view block) DW_OP_deref_size. */ int -dwarf_block_to_dwarf_reg_deref (gdb::array_view block, +dwarf_block_to_dwarf_reg_deref (gdb::span block, CORE_ADDR *deref_size_return) { uint64_t dwarf_reg; @@ -1513,7 +1513,7 @@ dwarf_block_to_dwarf_reg_deref (gdb::array_view block, /* See expr.h. */ bool -dwarf_block_to_fb_offset (gdb::array_view block, +dwarf_block_to_fb_offset (gdb::span block, CORE_ADDR *fb_offset_return) { int64_t fb_offset; @@ -1541,7 +1541,7 @@ dwarf_block_to_fb_offset (gdb::array_view block, bool dwarf_block_to_sp_offset (struct gdbarch *gdbarch, - gdb::array_view block, + gdb::span block, CORE_ADDR *sp_offset_return) { uint64_t dwarf_reg; @@ -1606,7 +1606,7 @@ trivial_entry_value (frame_info_ptr frame) object, evaluate the expression EXPR. */ void -dwarf_expr_context::execute_stack_op (gdb::array_view expr) +dwarf_expr_context::execute_stack_op (gdb::span expr) { gdbarch *arch = this->m_per_objfile->objfile->arch (); bfd_endian byte_order = gdbarch_byte_order (arch); diff --git a/gdb/dwarf2/expr.h b/gdb/dwarf2/expr.h index 02b0e41f6fd..0ea887464b3 100644 --- a/gdb/dwarf2/expr.h +++ b/gdb/dwarf2/expr.h @@ -139,7 +139,7 @@ struct dwarf_expr_context The ADDR_INFO property can be specified to override the range of memory addresses with the passed in buffer. */ - value *evaluate (gdb::array_view expr, bool as_lval, + value *evaluate (gdb::span expr, bool as_lval, dwarf2_per_cu *per_cu, const frame_info_ptr &frame, const struct property_addr_info *addr_info = nullptr, struct type *type = nullptr, @@ -207,12 +207,12 @@ struct dwarf_expr_context /* Property address info used for the evaluation. */ const struct property_addr_info *m_addr_info = nullptr; - void eval (gdb::array_view expr); + void eval (gdb::span expr); struct type *address_type () const; void push (struct value *value, bool in_stack_memory); bool stack_empty_p () const; void add_piece (ULONGEST size, ULONGEST offset, enum dwarf_location_atom op); - void execute_stack_op (gdb::array_view expr); + void execute_stack_op (gdb::span expr); void pop (); struct value *fetch (int n); CORE_ADDR fetch_address (int n); @@ -229,7 +229,7 @@ struct dwarf_expr_context /* Return the location expression for the frame base attribute. The result must be live until the current expression evaluation is complete. */ - gdb::array_view get_frame_base (); + gdb::span get_frame_base (); /* Return the base type given by the indicated DIE at DIE_CU_OFF. This can throw an exception if the DIE is invalid or does not @@ -268,16 +268,16 @@ CORE_ADDR read_addr_from_reg (const frame_info_ptr &frame, int reg); void dwarf_expr_require_composition (const gdb_byte *, const gdb_byte *, const char *); -int dwarf_block_to_dwarf_reg (gdb::array_view block); +int dwarf_block_to_dwarf_reg (gdb::span block); -int dwarf_block_to_dwarf_reg_deref (gdb::array_view block, +int dwarf_block_to_dwarf_reg_deref (gdb::span block, CORE_ADDR *deref_size_return); /* If BLOCK contains DW_FORM_block* with single DW_OP_fbreg(X) fill in FB_OFFSET_RETURN with the X offset and return true. Otherwise return false. */ -bool dwarf_block_to_fb_offset (gdb::array_view block, +bool dwarf_block_to_fb_offset (gdb::span block, CORE_ADDR *fb_offset_return); /* If BLOCK contains DW_FORM_block* with single DW_OP_bregSP(X) fill in @@ -285,7 +285,7 @@ bool dwarf_block_to_fb_offset (gdb::array_view block, false. The matched SP register number depends on GDBARCH. */ bool dwarf_block_to_sp_offset (struct gdbarch *gdbarch, - gdb::array_view block, + gdb::span block, CORE_ADDR *sp_offset_return); /* Wrappers around the leb128 reader routines to simplify them for our diff --git a/gdb/dwarf2/frame.c b/gdb/dwarf2/frame.c index 95e9f1e7c34..be003142e04 100644 --- a/gdb/dwarf2/frame.c +++ b/gdb/dwarf2/frame.c @@ -225,7 +225,7 @@ register %s (#%d) at %s"), } static CORE_ADDR -execute_stack_op (gdb::array_view expr, int addr_size, +execute_stack_op (gdb::span expr, int addr_size, const frame_info_ptr &this_frame, CORE_ADDR initial, int initial_in_stack_memory, dwarf2_per_objfile *per_objfile) { @@ -755,7 +755,7 @@ bool dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, dwarf2_per_cu *data, int *regnum_out, LONGEST *offset_out, CORE_ADDR *text_offset_out, - gdb::array_view &cfa_expr_out) + gdb::span &cfa_expr_out) { struct dwarf2_fde *fde; dwarf2_per_objfile *per_objfile; diff --git a/gdb/dwarf2/frame.h b/gdb/dwarf2/frame.h index 6462d008cc2..4a4fbeabeda 100644 --- a/gdb/dwarf2/frame.h +++ b/gdb/dwarf2/frame.h @@ -79,7 +79,7 @@ struct dwarf2_frame_state_reg struct { /* Return this expression. */ - gdb::array_view view () const + gdb::span view () const { return gdb::make_array_view (start, len); } const gdb_byte *start; @@ -147,7 +147,7 @@ struct dwarf2_frame_state_reg_info LONGEST cfa_offset = 0; ULONGEST cfa_reg = 0; enum cfa_how_kind cfa_how = CFA_UNSET; - gdb::array_view cfa_exp; + gdb::span cfa_exp; /* Used to implement DW_CFA_remember_state. */ struct dwarf2_frame_state_reg_info *prev = NULL; @@ -265,7 +265,7 @@ CORE_ADDR dwarf2_frame_cfa (const frame_info_ptr &this_frame); extern bool dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, dwarf2_per_cu *data, int *regnum_out, LONGEST *offset_out, CORE_ADDR *text_offset_out, - gdb::array_view &cfa_expr_out); + gdb::span &cfa_expr_out); /* Allocate a new instance of the function unique data. diff --git a/gdb/dwarf2/index-cache.c b/gdb/dwarf2/index-cache.c index 0e0aca3ac6d..abeb0c6a497 100644 --- a/gdb/dwarf2/index-cache.c +++ b/gdb/dwarf2/index-cache.c @@ -200,7 +200,7 @@ struct index_cache_resource_mmap final : public index_cache_resource /* See dwarf-index-cache.h. */ -gdb::array_view +gdb::span index_cache::lookup_gdb_index (const bfd_build_id *build_id, index_cache_resource_up *resource) { @@ -229,7 +229,7 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id, /* Yay, it worked! Hand the resource to the caller. */ resource->reset (mmap_resource); - return gdb::array_view + return gdb::span ((const gdb_byte *) mmap_resource->mapping.get (), mmap_resource->mapping.size ()); } @@ -246,7 +246,7 @@ index_cache::lookup_gdb_index (const bfd_build_id *build_id, /* See dwarf-index-cache.h. This is a no-op on unsupported systems. */ -gdb::array_view +gdb::span index_cache::lookup_gdb_index (const bfd_build_id *build_id, index_cache_resource_up *resource) { diff --git a/gdb/dwarf2/index-cache.h b/gdb/dwarf2/index-cache.h index 9ee51137d3b..4e9c5f1d5b6 100644 --- a/gdb/dwarf2/index-cache.h +++ b/gdb/dwarf2/index-cache.h @@ -83,13 +83,13 @@ class index_cache /* Disable the cache. */ void disable (); - /* Look for an index file matching BUILD_ID. If found, return the contents - as an array_view and store the underlying resources (allocated memory, - mapped file, etc) in RESOURCE. The returned array_view is valid as long - as RESOURCE is not destroyed. + /* Look for an index file matching BUILD_ID. If found, return the + contents as a span and store the underlying resources (allocated + memory, mapped file, etc) in RESOURCE. The returned span is + valid as long as RESOURCE is not destroyed. - If no matching index file is found, return an empty array view. */ - gdb::array_view + If no matching index file is found, return an empty span. */ + gdb::span lookup_gdb_index (const bfd_build_id *build_id, index_cache_resource_up *resource); diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index b008e1dd466..654abb1ef35 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -96,7 +96,7 @@ class data_buf { public: /* Copy ARRAY to the end of the buffer. */ - void append_array (gdb::array_view array) + void append_array (gdb::span array) { std::copy (array.begin (), array.end (), grow (array.size ())); } diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index f71141630de..e0aab443854 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -50,7 +50,7 @@ static struct value *dwarf2_evaluate_loc_desc_full (struct type *type, const frame_info_ptr &frame, - gdb::array_view loc_desc, dwarf2_per_cu *per_cu, + gdb::span loc_desc, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, struct type *subobj_type, LONGEST subobj_byte_offset, bool as_lval = true); @@ -362,7 +362,7 @@ decode_debug_loc_dwo_addresses (dwarf2_per_cu *per_cu, For now, only return the first matching location expression; there can be more than one in the list. */ -gdb::array_view +gdb::span dwarf2_find_location_expression (const dwarf2_loclist_baton *baton, const CORE_ADDR pc, bool at_entry) { @@ -481,7 +481,7 @@ dwarf2_find_location_expression (const dwarf2_loclist_baton *baton, /* Implement find_frame_base_location method for LOC_BLOCK functions using DWARF expression for its DW_AT_frame_base. */ -static gdb::array_view +static gdb::span locexpr_find_frame_base_location (struct symbol *framefunc, CORE_ADDR pc) { struct dwarf2_locexpr_baton *symbaton @@ -536,7 +536,7 @@ const struct symbol_block_ops dwarf2_block_frame_base_locexpr_funcs = /* Implement find_frame_base_location method for LOC_BLOCK functions using DWARF location list for its DW_AT_frame_base. */ -static gdb::array_view +static gdb::span loclist_find_frame_base_location (struct symbol *framefunc, CORE_ADDR pc) { struct dwarf2_loclist_baton *symbaton @@ -590,10 +590,10 @@ const struct symbol_block_ops dwarf2_block_frame_base_loclist_funcs = /* See dwarf2/loc.h. */ -gdb::array_view +gdb::span func_get_frame_base_dwarf_block (struct symbol *framefunc, CORE_ADDR pc) { - gdb::array_view block; + gdb::span block; if (const symbol_block_ops *block_ops = framefunc->block_ops (); block_ops != nullptr) @@ -1380,7 +1380,7 @@ value_of_dwarf_reg_entry (struct type *type, const frame_info_ptr &frame, static struct value * value_of_dwarf_block_entry (struct type *type, const frame_info_ptr &frame, - gdb::array_view block) + gdb::span block) { union call_site_parameter_u kind_u; @@ -1479,7 +1479,7 @@ indirect_synthetic_pointer (sect_offset die, LONGEST byte_offset, static struct value * dwarf2_evaluate_loc_desc_full (struct type *type, const frame_info_ptr &frame, - gdb::array_view loc_desc, + gdb::span loc_desc, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, struct type *subobj_type, @@ -1544,7 +1544,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, const frame_info_ptr &frame, struct value * dwarf2_evaluate_loc_desc (struct type *type, const frame_info_ptr &frame, - gdb::array_view loc_desc, + gdb::span loc_desc, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, bool as_lval) { @@ -1569,7 +1569,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton, const frame_info_ptr &frame, const struct property_addr_info *addr_stack, CORE_ADDR *valp, - gdb::array_view push_values, + gdb::span push_values, bool *is_reference) { if (dlbaton->size == 0) @@ -1630,7 +1630,7 @@ dwarf2_evaluate_property (const dynamic_prop *prop, const frame_info_ptr &initial_frame, const property_addr_info *addr_stack, CORE_ADDR *value, - gdb::array_view push_values) + gdb::span push_values) { /* Evaluating a property should not change the current language. Without this here this could happen if the code below selects a @@ -1792,7 +1792,7 @@ dwarf2_compile_property_to_c (string_file *stream, { #if defined (HAVE_COMPILE) const dwarf2_property_baton *baton = prop->baton (); - gdb::array_view expr; + gdb::span expr; dwarf2_per_cu *per_cu; dwarf2_per_objfile *per_objfile; @@ -1826,7 +1826,7 @@ dwarf2_compile_property_to_c (string_file *stream, expression. */ static enum symbol_needs_kind -dwarf2_get_symbol_read_needs (gdb::array_view expr, +dwarf2_get_symbol_read_needs (gdb::span expr, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, bfd_endian byte_order, @@ -2379,7 +2379,7 @@ access_memory (struct gdbarch *arch, struct agent_expr *expr, ULONGEST nbits) static void dwarf2_compile_expr_to_ax (struct agent_expr *ax, struct axs_value *loc, unsigned int addr_size, - gdb::array_view expr, + gdb::span expr, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile) { @@ -2878,7 +2878,7 @@ dwarf2_compile_expr_to_ax (struct agent_expr *ax, struct axs_value *loc, int regnum; CORE_ADDR text_offset; LONGEST off; - gdb::array_view cfa_expr; + gdb::span cfa_expr; if (dwarf2_fetch_cfa_info (arch, ax->scope, per_cu, ®num, &off, &text_offset, cfa_expr)) @@ -3722,7 +3722,7 @@ show_dwarf_always_disassemble (struct ui_file *file, int from_tty, static void locexpr_describe_location_1 (struct symbol *symbol, CORE_ADDR addr, struct ui_file *stream, - gdb::array_view expr, + gdb::span expr, unsigned int addr_size, int offset_size, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile) diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index 192e53318d6..bab9e270585 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -38,7 +38,7 @@ struct axs_value; extern unsigned int entry_values_debug; /* Find a particular location expression from a location list. */ -gdb::array_view dwarf2_find_location_expression +gdb::span dwarf2_find_location_expression (const dwarf2_loclist_baton *baton, CORE_ADDR pc, bool at_entry = false); /* Find the frame base information for FRAMEFUNC at PC and return the @@ -46,7 +46,7 @@ gdb::array_view dwarf2_find_location_expression Throw an exception if no expression is found. */ -gdb::array_view func_get_frame_base_dwarf_block +gdb::span func_get_frame_base_dwarf_block (struct symbol *framefunc, CORE_ADDR pc); /* A helper function to find the definition of NAME and compute its @@ -72,7 +72,7 @@ call_site_parameter *dwarf_expr_reg_to_entry_parameter description. */ value *dwarf2_evaluate_loc_desc (type *type, const frame_info_ptr &frame, - gdb::array_view loc_desc, + gdb::span loc_desc, dwarf2_per_cu *per_cu, dwarf2_per_objfile *per_objfile, bool as_lval = true); @@ -87,7 +87,7 @@ struct property_addr_info struct type *type; /* If not NULL, a buffer containing the object's value. */ - gdb::array_view valaddr; + gdb::span valaddr; /* The address of that object. */ CORE_ADDR addr; @@ -127,11 +127,11 @@ void dwarf2_compile_property_to_c (string_file *stream, struct dwarf2_locexpr_baton { /* Return the expression in this baton. */ - gdb::array_view expr () const + gdb::span expr () const { return gdb::make_array_view (data, size); } /* Set the expression in this baton from EXPR. */ - void set_expr (gdb::array_view expr) + void set_expr (gdb::span expr) { data = expr.data (); size = expr.size (); @@ -189,7 +189,7 @@ struct dwarf2_field_location_baton : public dwarf2_locexpr_baton struct dwarf2_loclist_baton { /* Return the location list in this baton. */ - gdb::array_view expr () const + gdb::span expr () const { return gdb::make_array_view (data, size); } /* The initial base address for the location list, based on the compilation @@ -327,7 +327,7 @@ bool dwarf2_evaluate_property (const struct dynamic_prop *prop, const frame_info_ptr &frame, const property_addr_info *addr_stack, CORE_ADDR *value, - gdb::array_view push_values = {}); + gdb::span push_values = {}); extern struct value *value_of_dwarf_reg_entry (struct type *type, const frame_info_ptr &frame, @@ -339,7 +339,7 @@ extern struct value *value_of_dwarf_reg_entry (struct type *type, static inline bool dwarf2_evaluate_property (const struct dynamic_prop *, const frame_info_ptr &, const property_addr_info *, CORE_ADDR *, - gdb::array_view = {}) + gdb::span = {}) { return false; } diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index 324984c0de2..c0bd6822711 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -94,7 +94,7 @@ class offset_view public: offset_view () = default; - explicit offset_view (gdb::array_view bytes) + explicit offset_view (gdb::span bytes) : m_bytes (bytes) { } @@ -122,7 +122,7 @@ class offset_view private: /* The underlying bytes. */ - gdb::array_view m_bytes; + gdb::span m_bytes; }; /* A worker for reading .gdb_index. The file format is described in @@ -138,16 +138,16 @@ struct mapped_gdb_index std::vector units; /* The address table data. */ - gdb::array_view address_table; + gdb::span address_table; /* The symbol table, implemented as a hash table. */ offset_view symbol_table; /* A pointer to the constant pool. */ - gdb::array_view constant_pool; + gdb::span constant_pool; /* The shortcut table data. */ - gdb::array_view shortcut_table; + gdb::span shortcut_table; /* An address map that maps from PC to dwarf2_per_cu. */ addrmap_fixed *index_addrmap = nullptr; @@ -417,7 +417,7 @@ gdb_index_worker::do_reading () static bool read_gdb_index_from_buffer (const char *filename, bool deprecated_ok, - gdb::array_view buffer, + gdb::span buffer, mapped_gdb_index *map, const gdb_byte **cu_list, offset_type *cu_list_elements, @@ -471,13 +471,13 @@ read_gdb_index_from_buffer (const char *filename, const gdb_byte *address_table = addr + metadata[i]; const gdb_byte *address_table_end = addr + metadata[i + 1]; map->address_table - = gdb::array_view (address_table, address_table_end); + = gdb::span (address_table, address_table_end); ++i; const gdb_byte *symbol_table = addr + metadata[i]; const gdb_byte *symbol_table_end = addr + metadata[i + 1]; map->symbol_table - = offset_view (gdb::array_view (symbol_table, + = offset_view (gdb::span (symbol_table, symbol_table_end)); ++i; @@ -487,7 +487,7 @@ read_gdb_index_from_buffer (const char *filename, const gdb_byte *shortcut_table = addr + metadata[i]; const gdb_byte *shortcut_table_end = addr + metadata[i + 1]; map->shortcut_table - = gdb::array_view (shortcut_table, shortcut_table_end); + = gdb::span (shortcut_table, shortcut_table_end); ++i; } @@ -498,7 +498,7 @@ read_gdb_index_from_buffer (const char *filename, /* An empty constant pool implies that all symbol table entries are empty. Make map->symbol_table.empty () == true. */ map->symbol_table - = offset_view (gdb::array_view (symbol_table, + = offset_view (gdb::span (symbol_table, symbol_table)); } @@ -728,7 +728,7 @@ dwarf2_read_gdb_index dwarf2_per_bfd *per_bfd = per_objfile->per_bfd; scoped_remove_all_units remove_all_units (*per_bfd); - gdb::array_view main_index_contents + gdb::span main_index_contents = get_gdb_index_contents (objfile, per_bfd); if (main_index_contents.empty ()) @@ -755,7 +755,7 @@ dwarf2_read_gdb_index const gdb_byte *dwz_types_ignore; offset_type dwz_types_elements_ignore; - gdb::array_view dwz_index_content + gdb::span dwz_index_content = get_gdb_index_contents_dwz (objfile, dwz); if (dwz_index_content.empty ()) diff --git a/gdb/dwarf2/read-gdb-index.h b/gdb/dwarf2/read-gdb-index.h index 56e112c6cbb..58425042088 100644 --- a/gdb/dwarf2/read-gdb-index.h +++ b/gdb/dwarf2/read-gdb-index.h @@ -44,10 +44,10 @@ struct objfile; /* Callback types for dwarf2_read_gdb_index. */ using get_gdb_index_contents_ftype - = gdb::function_view(objfile *, + = gdb::function_view(objfile *, dwarf2_per_bfd *)>; using get_gdb_index_contents_dwz_ftype - = gdb::function_view(objfile *, dwz_file *)>; + = gdb::function_view(objfile *, dwz_file *)>; /* Read .gdb_index. If everything went ok, initialize the "quick" elements of all the CUs and return true. Otherwise, return diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 078fdd9850b..31120df4225 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2027,7 +2027,7 @@ dwarf2_base_index_functions::has_unexpanded_symtabs (struct objfile *objfile) to either a dwarf2_per_bfd or dwz_file object. */ template -static gdb::array_view +static gdb::span get_gdb_index_contents_from_section (objfile *obj, T *section_owner) { dwarf2_section_info *section = §ion_owner->gdb_index; @@ -2043,7 +2043,7 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner) section->read (obj); /* dwarf2_section_info::size is a bfd_size_type, while - gdb::array_view works with size_t. On 32-bit hosts, with + gdb::span works with size_t. On 32-bit hosts, with --enable-64-bit-bfd, bfd_size_type is a 64-bit type, while size_t is 32-bit. So we need an explicit narrowing conversion here. This is fine, because it's impossible to allocate or mmap an @@ -2054,7 +2054,7 @@ get_gdb_index_contents_from_section (objfile *obj, T *section_owner) /* Lookup the index cache for the contents of the index associated to DWARF2_OBJ. */ -static gdb::array_view +static gdb::span get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd) { const bfd_build_id *build_id = build_id_bfd_get (obj->obfd.get ()); @@ -2071,7 +2071,7 @@ get_gdb_index_contents_from_cache (objfile *obj, dwarf2_per_bfd *dwarf2_per_bfd) /* Same as the above, but for DWZ. */ -static gdb::array_view +static gdb::span get_gdb_index_contents_from_cache_dwz (objfile *obj, dwz_file *dwz) { const bfd_build_id *build_id = build_id_bfd_get (dwz->dwz_bfd.get ()); @@ -4003,7 +4003,7 @@ rust_fully_qualify (struct obstack *obstack, const char *p1, const char *p2) static void alloc_rust_variant (struct obstack *obstack, struct type *type, int discriminant_index, int default_index, - gdb::array_view ranges) + gdb::span ranges) { /* When DISCRIMINANT_INDEX == -1, we have a univariant enum. */ gdb_assert (discriminant_index == -1 @@ -4050,11 +4050,11 @@ alloc_rust_variant (struct obstack *obstack, struct type *type, = (discriminant_index == -1 ? false : type->field (discriminant_index).type ()->is_unsigned ()); - part->variants = gdb::array_view (variants, n_variants); + part->variants = gdb::span (variants, n_variants); - void *storage = obstack_alloc (obstack, sizeof (gdb::array_view)); - gdb::array_view *prop_value - = new (storage) gdb::array_view (part, 1); + void *storage = obstack_alloc (obstack, sizeof (gdb::span)); + gdb::span *prop_value + = new (storage) gdb::span (part, 1); struct dynamic_prop prop; prop.set_variant_parts (prop_value); @@ -4287,7 +4287,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* Indicate that this is a variant type. */ alloc_rust_variant (&objfile->objfile_obstack, type, 0, -1, - gdb::array_view (ranges, + gdb::span (ranges, n_fields - 1)); } } @@ -9461,7 +9461,7 @@ using offset_map_type = gdb::unordered_map; process. IS_UNSIGNED indicates whether the discriminant is signed or unsigned. */ -static const gdb::array_view +static const gdb::span convert_variant_range (struct obstack *obstack, const variant_field &variant, bool is_unsigned) { @@ -9484,7 +9484,7 @@ convert_variant_range (struct obstack *obstack, const variant_field &variant, } else { - gdb::array_view data (variant.discr_list_data->data, + gdb::span data (variant.discr_list_data->data, variant.discr_list_data->size); while (!data.empty ()) { @@ -9536,10 +9536,10 @@ convert_variant_range (struct obstack *obstack, const variant_field &variant, discriminant_range *result = XOBNEWVEC (obstack, discriminant_range, ranges.size ()); std::copy (ranges.begin (), ranges.end (), result); - return gdb::array_view (result, ranges.size ()); + return gdb::span (result, ranges.size ()); } -static const gdb::array_view create_variant_parts +static const gdb::span create_variant_parts (struct obstack *obstack, const offset_map_type &offset_map, struct field_info *fi, @@ -9599,7 +9599,7 @@ create_one_variant_part (variant_part &result, create_one_variant (output[i], obstack, offset_map, fi, builder.variants[i], result.is_unsigned); - result.variants = gdb::array_view (output, n); + result.variants = gdb::span (output, n); } /* Create a vector of variant parts that can be attached to a type. @@ -9608,7 +9608,7 @@ create_one_variant_part (variant_part &result, describes the fields of the type we're processing. VARIANT_PARTS is the vector to convert. */ -static const gdb::array_view +static const gdb::span create_variant_parts (struct obstack *obstack, const offset_map_type &offset_map, struct field_info *fi, @@ -9623,7 +9623,7 @@ create_variant_parts (struct obstack *obstack, create_one_variant_part (result[i], obstack, offset_map, fi, variant_parts[i]); - return gdb::array_view (result, n); + return gdb::span (result, n); } /* Compute the variant part vector for FIP, attaching it to TYPE when @@ -9641,12 +9641,12 @@ add_variant_property (struct field_info *fip, struct type *type, offset_map[fip->fields[i].offset] = i; struct objfile *objfile = cu->per_objfile->objfile; - gdb::array_view parts + gdb::span parts = create_variant_parts (&objfile->objfile_obstack, offset_map, fip, fip->variant_parts); struct dynamic_prop prop; - prop.set_variant_parts ((gdb::array_view *) + prop.set_variant_parts ((gdb::span *) obstack_copy (&objfile->objfile_obstack, &parts, sizeof (parts))); @@ -13749,7 +13749,7 @@ cutu_reader::read_full_die (int num_extra_attrs, bool allow_reprocess) child, next, and parent fields. */ die_info * -cutu_reader::read_toplevel_die (gdb::array_view extra_attrs) +cutu_reader::read_toplevel_die (gdb::span extra_attrs) { m_cu->per_objfile->per_bfd->nr_toplevel_dies_read++; const gdb_byte *begin_info_ptr = m_info_ptr; @@ -16919,7 +16919,7 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, dwarf2_per_cu *per_cu, if (!attr) { /* DWARF: "If there is no such attribute, then there is no effect.". */ - retval.set_expr (gdb::array_view ()); + retval.set_expr (gdb::span ()); } else if (attr->form_is_section_offset ()) { diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 0ea86943ae3..ade39a38d9b 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -1123,7 +1123,7 @@ class cutu_reader /* Helpers to build the in-memory DIE tree. */ - die_info *read_toplevel_die (gdb::array_view extra_attrs = {}); + die_info *read_toplevel_die (gdb::span extra_attrs = {}); die_info *read_die_and_siblings (die_info *parent); diff --git a/gdb/elfread.c b/gdb/elfread.c index fcbd0176d08..2f4d326f20a 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1106,7 +1106,7 @@ elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags, /* Process the normal ELF symbol table first. */ - gdb::array_view symbol_table + gdb::span symbol_table = gdb_bfd_canonicalize_symtab (objfile->obfd.get ()); elf_symtab_read (reader, objfile, ST_REGULAR, symbol_table.size (), diff --git a/gdb/eval.c b/gdb/eval.c index c784ef686f0..cd1c6eceafe 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -582,7 +582,7 @@ evaluate_var_msym_value (enum noside noside, value * evaluate_subexp_do_call (expression *exp, enum noside noside, value *callee, - gdb::array_view argvec, + gdb::span argvec, const char *function_name, type *default_return_type) { @@ -771,7 +771,7 @@ scope_operation::evaluate_funcall (struct type *expect_type, for (int i = 0; i < args.size (); ++i) argvec[i + 1] = args[i]->evaluate_with_coercion (exp, noside); - gdb::array_view arg_view = argvec; + gdb::span arg_view = argvec; value *callee = nullptr; if (function_name != nullptr) @@ -820,7 +820,7 @@ structop_member_base::evaluate_funcall (struct type *expect_type, lhs = std::get<0> (m_storage)->evaluate (nullptr, exp, noside); std::vector vals (args.size () + 1); - gdb::array_view val_view = vals; + gdb::span val_view = vals; /* If the function is a virtual function, then the aggregate value (providing the structure) plays its part by providing the vtable. Otherwise, it is just along for the ride: call @@ -926,8 +926,8 @@ structop_base_operation::evaluate_funcall for (int i = 0; i < args.size (); ++i) vals[i + 1] = args[i]->evaluate_with_coercion (exp, noside); - /* The array view includes the `this' pointer. */ - gdb::array_view arg_view (vals); + /* The span includes the `this' pointer. */ + gdb::span arg_view (vals); int static_memfuncp; value *callee; @@ -1914,7 +1914,7 @@ eval_binop_assign_modify (struct type *expect_type, struct expression *exp, static struct value * eval_multi_subscript (struct type *expect_type, struct expression *exp, enum noside noside, value *arg1, - gdb::array_view args) + gdb::span args) { for (value *arg2 : args) { diff --git a/gdb/expression.h b/gdb/expression.h index ce8abb4380e..29c1d3a9bbe 100644 --- a/gdb/expression.h +++ b/gdb/expression.h @@ -366,7 +366,7 @@ extern expression_up parse_exp_1 (const char **, CORE_ADDR pc, extern struct value *evaluate_subexp_do_call (expression *exp, enum noside noside, value *callee, - gdb::array_view argvec, + gdb::span argvec, const char *function_name, type *default_return_type); diff --git a/gdb/extension.c b/gdb/extension.c index de3b3eb69a5..cf8b23abc33 100644 --- a/gdb/extension.c +++ b/gdb/extension.c @@ -994,7 +994,7 @@ xmethod_worker::get_arg_types () /* See extension.h. */ struct type * -xmethod_worker::get_result_type (value *object, gdb::array_view args) +xmethod_worker::get_result_type (value *object, gdb::span args) { type *result_type; diff --git a/gdb/extension.h b/gdb/extension.h index cefb7edb267..694b367f2ea 100644 --- a/gdb/extension.h +++ b/gdb/extension.h @@ -198,7 +198,7 @@ struct xmethod_worker /* Invoke the xmethod encapsulated in this worker and return the result. The method is invoked on OBJ with arguments in the ARGS array. */ - virtual value *invoke (value *obj, gdb::array_view args) = 0; + virtual value *invoke (value *obj, gdb::span args) = 0; /* Return the arg types of the xmethod encapsulated in this worker. The type of the 'this' object is returned as the first element of @@ -209,7 +209,7 @@ struct xmethod_worker /* Return the type of the result of the xmethod encapsulated in this worker. OBJECT and ARGS are the same as for invoke. */ - type *get_result_type (value *object, gdb::array_view args); + type *get_result_type (value *object, gdb::span args); private: @@ -224,7 +224,7 @@ struct xmethod_worker The result type is stored in *RESULT_TYPE. */ virtual enum ext_lang_rc do_get_result_type - (struct value *obj, gdb::array_view args, + (struct value *obj, gdb::span args, struct type **result_type_ptr) = 0; /* The language the xmethod worker is implemented in. */ diff --git a/gdb/extract-store-integer.c b/gdb/extract-store-integer.c index 67e4534a27d..2232aa70f51 100644 --- a/gdb/extract-store-integer.c +++ b/gdb/extract-store-integer.c @@ -22,7 +22,7 @@ template T -extract_integer (gdb::array_view buf, enum bfd_endian byte_order) +extract_integer (gdb::span buf, enum bfd_endian byte_order) { typename std::make_unsigned::type retval = 0; @@ -115,10 +115,10 @@ extract_integer (gdb::array_view buf, enum bfd_endian byte_order } /* Explicit instantiations. */ -template LONGEST extract_integer (gdb::array_view buf, +template LONGEST extract_integer (gdb::span buf, enum bfd_endian byte_order); template ULONGEST extract_integer - (gdb::array_view buf, enum bfd_endian byte_order); + (gdb::span buf, enum bfd_endian byte_order); /* Treat the bytes at BUF as a pointer of type TYPE, and return the address it represents. */ @@ -133,7 +133,7 @@ extract_typed_address (const gdb_byte *buf, struct type *type) template void -store_integer (gdb::array_view dst, enum bfd_endian byte_order, +store_integer (gdb::span dst, enum bfd_endian byte_order, T val) { gdb_byte *p; @@ -161,10 +161,10 @@ store_integer (gdb::array_view dst, enum bfd_endian byte_order, } /* Explicit instantiations. */ -template void store_integer (gdb::array_view dst, +template void store_integer (gdb::span dst, bfd_endian byte_order, LONGEST val); -template void store_integer (gdb::array_view dst, +template void store_integer (gdb::span dst, bfd_endian byte_order, ULONGEST val); /* Store the address ADDR as a pointer of type TYPE at BUF, in target diff --git a/gdb/extract-store-integer.h b/gdb/extract-store-integer.h index b6f734d23a7..bdb5a45433e 100644 --- a/gdb/extract-store-integer.h +++ b/gdb/extract-store-integer.h @@ -21,10 +21,10 @@ #include template> -T extract_integer (gdb::array_view, enum bfd_endian byte_order); +T extract_integer (gdb::span, enum bfd_endian byte_order); static inline LONGEST -extract_signed_integer (gdb::array_view buf, +extract_signed_integer (gdb::span buf, enum bfd_endian byte_order) { return extract_integer (buf, byte_order); @@ -34,12 +34,12 @@ static inline LONGEST extract_signed_integer (const gdb_byte *addr, int len, enum bfd_endian byte_order) { - return extract_signed_integer (gdb::array_view (addr, len), + return extract_signed_integer (gdb::span (addr, len), byte_order); } static inline ULONGEST -extract_unsigned_integer (gdb::array_view buf, +extract_unsigned_integer (gdb::span buf, enum bfd_endian byte_order) { return extract_integer (buf, byte_order); @@ -49,7 +49,7 @@ static inline ULONGEST extract_unsigned_integer (const gdb_byte *addr, int len, enum bfd_endian byte_order) { - return extract_unsigned_integer (gdb::array_view (addr, len), + return extract_unsigned_integer (gdb::span (addr, len), byte_order); } @@ -60,7 +60,7 @@ extern CORE_ADDR extract_typed_address (const gdb_byte *buf, DST. */ template> -extern void store_integer (gdb::array_view dst, +extern void store_integer (gdb::span dst, bfd_endian byte_order, T val); /* Take host-format integer VAL and store it as target-format integer at @@ -77,7 +77,7 @@ store_integer (gdb_byte *addr, int len, bfd_endian byte_order, T val) signed integer at DST. */ static inline void -store_signed_integer (gdb::array_view dst, bfd_endian byte_order, +store_signed_integer (gdb::span dst, bfd_endian byte_order, LONGEST val) { return store_integer (dst, byte_order, val); @@ -98,7 +98,7 @@ store_signed_integer (gdb_byte *addr, int len, bfd_endian byte_order, unsigned integer at DST. */ static inline void -store_unsigned_integer (gdb::array_view dst, bfd_endian byte_order, +store_unsigned_integer (gdb::span dst, bfd_endian byte_order, ULONGEST val) { return store_integer (dst, byte_order, val); diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 19ea1645970..a6566b23e88 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -1619,7 +1619,7 @@ fortran_structop_operation::evaluate (struct type *expect_type, { const gdb_byte *valaddr = elt->contents_for_printing ().data (); CORE_ADDR address = elt->address (); - gdb::array_view view + gdb::span view = gdb::make_array_view (valaddr, elt_type->length ()); elt_type = resolve_dynamic_type (elt_type, view, address); } diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index cf59ae21efc..8f3ba89c8d9 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -2302,7 +2302,7 @@ fbsd_nat_target::remove_exec_catchpoint (int pid) int fbsd_nat_target::set_syscall_catchpoint (int pid, bool needed, int any_count, - gdb::array_view syscall_counts) + gdb::span syscall_counts) { /* Ignore the arguments. inf-ptrace.c will use PT_SYSCALL which diff --git a/gdb/fbsd-nat.h b/gdb/fbsd-nat.h index 9db5fb200a8..3113238f335 100644 --- a/gdb/fbsd-nat.h +++ b/gdb/fbsd-nat.h @@ -114,7 +114,7 @@ class fbsd_nat_target : public inf_ptrace_target int remove_exec_catchpoint (int) override; #ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE - int set_syscall_catchpoint (int, bool, int, gdb::array_view) + int set_syscall_catchpoint (int, bool, int, gdb::span) override; #endif diff --git a/gdb/findvar.c b/gdb/findvar.c index 9a7858e4f17..afa3409be14 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -320,7 +320,7 @@ language_defn::read_var_value (struct symbol *var, store_unsigned_integer (bytes, len, type_byte_order (type), var->value_longest ()); - gdb::array_view view (bytes, len); + gdb::span view (bytes, len); /* Value is a constant byte-sequence. */ type = resolve_dynamic_type (type, view, /* Unused address. */ 0); @@ -363,7 +363,7 @@ language_defn::read_var_value (struct symbol *var, case LOC_CONST_BYTES: if (is_dynamic_type (type)) { - gdb::array_view view (var->value_bytes (), + gdb::span view (var->value_bytes (), type->length ()); /* Value is a constant byte-sequence. */ diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index 91a3cbe7eeb..b4497af1f70 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -338,13 +338,13 @@ frame_unwind_got_constant (const frame_info_ptr &frame, int regnum, struct value * frame_unwind_got_bytes (const frame_info_ptr &frame, int regnum, - gdb::array_view buf) + gdb::span buf) { struct gdbarch *gdbarch = frame_unwind_arch (frame); struct value *reg_val; reg_val = value::zero (register_type (gdbarch, regnum), not_lval); - gdb::array_view val_contents = reg_val->contents_raw (); + gdb::span val_contents = reg_val->contents_raw (); /* The value's contents buffer is zeroed on allocation so if buf is smaller, the remaining space will be filled with zero. diff --git a/gdb/frame-unwind.h b/gdb/frame-unwind.h index a1edb92a4ad..972da134d8b 100644 --- a/gdb/frame-unwind.h +++ b/gdb/frame-unwind.h @@ -377,7 +377,7 @@ value *frame_unwind_got_constant (const frame_info_ptr &frame, int regnum, inside BUF. */ value *frame_unwind_got_bytes (const frame_info_ptr &frame, int regnum, - gdb::array_view buf); + gdb::span buf); /* Return a value which indicates that FRAME's saved version of REGNUM has a known constant (computed) value of ADDR. Convert the diff --git a/gdb/frame.c b/gdb/frame.c index 6b02c5f559a..2da31ed3b6b 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1184,7 +1184,7 @@ get_frame_func (const frame_info_ptr &this_frame) std::unique_ptr frame_save_as_regcache (const frame_info_ptr &this_frame) { - auto cooked_read = [this_frame] (int regnum, gdb::array_view buf) + auto cooked_read = [this_frame] (int regnum, gdb::span buf) { if (!deprecated_frame_register_read (this_frame, regnum, buf)) return REG_UNAVAILABLE; @@ -1252,7 +1252,7 @@ frame_register_unwind (const frame_info_ptr &next_frame, int regnum, bool *optimizedp, bool *unavailablep, enum lval_type *lvalp, CORE_ADDR *addrp, int *realnump, - gdb::array_view buffer) + gdb::span buffer) { struct value *value; @@ -1294,7 +1294,7 @@ frame_register_unwind (const frame_info_ptr &next_frame, int regnum, void frame_unwind_register (const frame_info_ptr &next_frame, int regnum, - gdb::array_view buf) + gdb::span buf) { bool optimized; bool unavailable; @@ -1315,7 +1315,7 @@ frame_unwind_register (const frame_info_ptr &next_frame, int regnum, void get_frame_register (const frame_info_ptr &frame, - int regnum, gdb::array_view buf) + int regnum, gdb::span buf) { frame_unwind_register (frame_info_ptr (frame->next), regnum, buf); } @@ -1396,7 +1396,7 @@ frame_unwind_register_value (const frame_info_ptr &next_frame, int regnum) else if (value->entirely_available ()) { int i; - gdb::array_view buf = value->contents (); + gdb::span buf = value->contents (); gdb_printf (&debug_file, " bytes="); gdb_printf (&debug_file, "["); @@ -1511,7 +1511,7 @@ read_frame_register_unsigned (const frame_info_ptr &frame, int regnum, void put_frame_register (const frame_info_ptr &next_frame, int regnum, - gdb::array_view buf) + gdb::span buf) { gdbarch *gdbarch = frame_unwind_arch (next_frame); int realnum; @@ -1559,7 +1559,7 @@ put_frame_register (const frame_info_ptr &next_frame, int regnum, bool deprecated_frame_register_read (const frame_info_ptr &frame, int regnum, - gdb::array_view myaddr) + gdb::span myaddr) { bool optimized; bool unavailable; @@ -1576,7 +1576,7 @@ deprecated_frame_register_read (const frame_info_ptr &frame, int regnum, bool get_frame_register_bytes (const frame_info_ptr &next_frame, int regnum, - CORE_ADDR offset, gdb::array_view buffer, + CORE_ADDR offset, gdb::span buffer, bool *optimizedp, bool *unavailablep) { gdbarch *gdbarch = frame_unwind_arch (next_frame); @@ -1654,7 +1654,7 @@ get_frame_register_bytes (const frame_info_ptr &next_frame, int regnum, void put_frame_register_bytes (const frame_info_ptr &next_frame, int regnum, CORE_ADDR offset, - gdb::array_view buffer) + gdb::span buffer) { gdbarch *gdbarch = frame_unwind_arch (next_frame); @@ -3094,7 +3094,7 @@ get_frame_address_space (const frame_info_ptr &frame) void get_frame_memory (const frame_info_ptr &this_frame, CORE_ADDR addr, - gdb::array_view buffer) + gdb::span buffer) { read_memory (addr, buffer.data (), buffer.size ()); } @@ -3121,7 +3121,7 @@ get_frame_memory_unsigned (const frame_info_ptr &this_frame, CORE_ADDR addr, bool safe_frame_unwind_memory (const frame_info_ptr &this_frame, - CORE_ADDR addr, gdb::array_view buffer) + CORE_ADDR addr, gdb::span buffer) { /* NOTE: target_read_memory returns zero on success! */ return target_read_memory (addr, buffer.data (), buffer.size ()) == 0; diff --git a/gdb/frame.h b/gdb/frame.h index b64650f3215..78df8f7ca53 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -698,7 +698,7 @@ extern void frame_register_unwind (const frame_info_ptr &frame, int regnum, bool *optimizedp, bool *unavailablep, enum lval_type *lvalp, CORE_ADDR *addrp, int *realnump, - gdb::array_view value = {}); + gdb::span value = {}); /* Fetch a register from this, or unwind a register from the next frame. Note that the get_frame methods are wrappers to @@ -707,9 +707,9 @@ extern void frame_register_unwind (const frame_info_ptr &frame, int regnum, do return a lazy value. */ extern void frame_unwind_register (const frame_info_ptr &next_frame, - int regnum, gdb::array_view buf); + int regnum, gdb::span buf); extern void get_frame_register (const frame_info_ptr &frame, - int regnum, gdb::array_view buf); + int regnum, gdb::span buf); struct value *frame_unwind_register_value (const frame_info_ptr &next_frame, int regnum); @@ -737,7 +737,7 @@ extern bool read_frame_register_unsigned (const frame_info_ptr &frame, Note: this call makes the frame's state undefined. The register and frame caches must be flushed. */ extern void put_frame_register (const frame_info_ptr &next_frame, int regnum, - gdb::array_view buf); + gdb::span buf); /* Read LEN bytes from one or multiple registers starting with REGNUM in NEXT_FRAME's previous frame, starting at OFFSET, into BUF. If the register @@ -745,14 +745,14 @@ extern void put_frame_register (const frame_info_ptr &next_frame, int regnum, accordingly. */ extern bool get_frame_register_bytes (const frame_info_ptr &next_frame, int regnum, CORE_ADDR offset, - gdb::array_view buffer, + gdb::span buffer, bool *optimizedp, bool *unavailablep); /* Write bytes from BUFFER to one or multiple registers starting with REGNUM in NEXT_FRAME's previous frame, starting at OFFSET. */ extern void put_frame_register_bytes (const frame_info_ptr &next_frame, int regnum, CORE_ADDR offset, - gdb::array_view buffer); + gdb::span buffer); /* Unwind the PC. Strictly speaking return the resume address of the calling frame. For GDB, `pc' is the resume address and not a @@ -778,7 +778,7 @@ extern void frame_pop (const frame_info_ptr &frame); adaptor frames this should be ok. */ extern void get_frame_memory (const frame_info_ptr &this_frame, CORE_ADDR addr, - gdb::array_view buffer); + gdb::span buffer); extern LONGEST get_frame_memory_signed (const frame_info_ptr &this_frame, CORE_ADDR memaddr, int len); extern ULONGEST get_frame_memory_unsigned (const frame_info_ptr &this_frame, @@ -787,7 +787,7 @@ extern ULONGEST get_frame_memory_unsigned (const frame_info_ptr &this_frame, /* Same as above, but return true zero when the entire memory read succeeds, false otherwise. */ extern bool safe_frame_unwind_memory (const frame_info_ptr &this_frame, CORE_ADDR addr, - gdb::array_view buffer); + gdb::span buffer); /* Return this frame's architecture. */ extern gdbarch *get_frame_arch (const frame_info_ptr &this_frame); @@ -910,7 +910,7 @@ extern void print_frame_info (const frame_print_options &fp_opts, extern frame_info_ptr block_innermost_frame (const struct block *); extern bool deprecated_frame_register_read (const frame_info_ptr &frame, int regnum, - gdb::array_view buf); + gdb::span buf); /* From stack.c. */ diff --git a/gdb/gdb-gdb.gdb b/gdb/gdb-gdb.gdb index 1ce90b9b4e0..3b4f15fd3e8 100644 --- a/gdb/gdb-gdb.gdb +++ b/gdb/gdb-gdb.gdb @@ -40,6 +40,6 @@ end # Trivial and uninteresting functions to skip. skip -rfu "^enum_flags<.*>::enum_flags" -skip -rfu "^gdb::array_view<.*>::array_view" +skip -rfu "^gdb::span<.*>::span" skip -rfu "^gdb::function_view<.*>::function_view" skip -rfu "^gdb::ref_ptr<.*>::get" diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c index 5def8093138..c20228f8633 100644 --- a/gdb/gdb_bfd.c +++ b/gdb/gdb_bfd.c @@ -1154,7 +1154,7 @@ gdb_bfd_errmsg (bfd_error_type error_tag, char **matching) /* See gdb_bfd.h. */ -gdb::array_view +gdb::span gdb_bfd_canonicalize_symtab (bfd *abfd, bool should_throw) { struct gdb_bfd_data *gdata = (struct gdb_bfd_data *) bfd_usrdata (abfd); @@ -1194,7 +1194,7 @@ gdb_bfd_canonicalize_symtab (bfd *abfd, bool should_throw) return {}; /* bfd_canonicalize_symtab adds a trailing NULL, but don't include - this in the array view. */ + this in the span. */ gdb_assert (symbol_table.back () == nullptr); return gdb::make_array_view (symbol_table.data (), symbol_table.size () - 1); diff --git a/gdb/gdb_bfd.h b/gdb/gdb_bfd.h index b1b295f22e0..4f56a9dc616 100644 --- a/gdb/gdb_bfd.h +++ b/gdb/gdb_bfd.h @@ -286,7 +286,7 @@ extern void gdb_bfd_init (); exception if symbols could not be read. When SHOULD_THROW is false, an empty view is returned instead. */ -extern gdb::array_view gdb_bfd_canonicalize_symtab +extern gdb::span gdb_bfd_canonicalize_symtab (bfd *abfd, bool should_throw = true); /* A wrapper for bfd_check_format that acquires the BFD lock. */ diff --git a/gdb/gdbarch-gen.c b/gdb/gdbarch-gen.c index 71ff31ea56e..dd907237774 100644 --- a/gdb/gdbarch-gen.c +++ b/gdb/gdbarch-gen.c @@ -1874,7 +1874,7 @@ gdbarch_pseudo_register_write_p (struct gdbarch *gdbarch) } void -gdbarch_pseudo_register_write (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int pseudo_reg_num, gdb::array_view buf) +gdbarch_pseudo_register_write (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int pseudo_reg_num, gdb::span buf) { gdb_assert (gdbarch != nullptr); gdb_assert (gdbarch->pseudo_register_write != nullptr); diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index e38d7ab61c5..06674c310c3 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -211,8 +211,8 @@ void set_gdbarch_pseudo_register_read_value (struct gdbarch *gdbarch, gdbarch_ps bool gdbarch_pseudo_register_write_p (struct gdbarch *gdbarch); -using gdbarch_pseudo_register_write_ftype = void (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int pseudo_reg_num, gdb::array_view buf); -void gdbarch_pseudo_register_write (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int pseudo_reg_num, gdb::array_view buf); +using gdbarch_pseudo_register_write_ftype = void (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int pseudo_reg_num, gdb::span buf); +void gdbarch_pseudo_register_write (struct gdbarch *gdbarch, const frame_info_ptr &next_frame, int pseudo_reg_num, gdb::span buf); void set_gdbarch_pseudo_register_write (struct gdbarch *gdbarch, gdbarch_pseudo_register_write_ftype *pseudo_register_write); /* Write bytes to a pseudo register. diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py index f2ad61e5a23..24199842339 100644 --- a/gdb/gdbarch_components.py +++ b/gdb/gdbarch_components.py @@ -439,7 +439,7 @@ NEXT_FRAME. params=[ ("const frame_info_ptr &", "next_frame"), ("int", "pseudo_reg_num"), - ("gdb::array_view", "buf"), + ("gdb::span", "buf"), ], predicate=True, ) diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 51e9ae1b3f0..5561ec22b42 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -774,7 +774,7 @@ struct thread_info *find_thread_global_id (int global_id); /* Find thread by thread library specific handle in inferior INF. */ struct thread_info *find_thread_by_handle - (gdb::array_view handle, struct inferior *inf); + (gdb::span handle, struct inferior *inf); /* Finds the first thread of the specified inferior. */ extern struct thread_info *first_thread_of_inferior (inferior *inf); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index f86549aca88..ded4cb2dfee 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1378,7 +1378,7 @@ smash_to_methodptr_type (struct type *type, struct type *to_type) void smash_to_method_type (struct type *type, struct type *self_type, - struct type *to_type, gdb::array_view args, + struct type *to_type, gdb::span args, int varargs) { smash_type (type); @@ -2492,7 +2492,7 @@ static void compute_variant_fields (struct type *type, struct type *resolved_type, const property_addr_info *addr_stack, - const gdb::array_view &parts) + const gdb::span &parts) { /* Assume all fields are included by default. */ std::vector flags (resolved_type->num_fields (), true); @@ -2828,7 +2828,7 @@ resolve_dynamic_type_internal (struct type *type, struct type * resolve_dynamic_type (struct type *type, - gdb::array_view valaddr, + gdb::span valaddr, CORE_ADDR addr, const frame_info_ptr *in_frame) { @@ -3846,8 +3846,8 @@ compare_badness (const badness_vector &a, const badness_vector &b) has ARGS.size() + 1 entries. */ badness_vector -rank_function (gdb::array_view parms, - gdb::array_view args, +rank_function (gdb::span parms, + gdb::span args, bool varargs) { /* add 1 for the length-match rank. */ @@ -4714,7 +4714,7 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value) situation. */ static void -print_args (gdb::array_view args, int spaces) +print_args (gdb::span args, int spaces) { for (auto [i, arg] : gdb::ranges::views::enumerate (args)) { diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index edae58754f7..c9c157d3e8d 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -218,7 +218,7 @@ struct variant_part; struct variant : allocate_on_obstack { /* The discriminant ranges for this variant. */ - gdb::array_view discriminants; + gdb::span discriminants; /* The fields controlled by this variant. This is inclusive on the low end and exclusive on the high end. A variant may not @@ -228,7 +228,7 @@ struct variant : allocate_on_obstack int last_field; /* Variant parts controlled by this variant. */ - gdb::array_view parts; + gdb::span parts; /* Return true if this is the default variant. The default variant can be recognized because it has no associated @@ -261,7 +261,7 @@ struct variant_part : allocate_on_obstack /* The variants that are controlled by this variant part. Note that these will always be sorted by field number. */ - gdb::array_view variants; + gdb::span variants; }; @@ -295,7 +295,7 @@ union dynamic_prop_data used to control which fields end up in the final type during dynamic type resolution. */ - const gdb::array_view *variant_parts; + const gdb::span *variant_parts; /* Once a variant type is resolved, we may want to be able to go from the resolved type to the original type. In this case we @@ -380,14 +380,14 @@ struct dynamic_prop m_data.baton = baton; } - const gdb::array_view *variant_parts () const + const gdb::span *variant_parts () const { gdb_assert (m_kind == PROP_VARIANT_PARTS); return m_data.variant_parts; } - void set_variant_parts (gdb::array_view *variant_parts) + void set_variant_parts (gdb::span *variant_parts) { m_kind = PROP_VARIANT_PARTS; m_data.variant_parts = variant_parts; @@ -1109,8 +1109,8 @@ struct type return this->fields ()[idx]; } - /* Return an array view of the fields. */ - gdb::array_view fields () const + /* Return a span of the fields. */ + gdb::span fields () const { return gdb::make_array_view (this->main_type->flds_bnds.fields, num_fields ()); @@ -2511,7 +2511,7 @@ extern struct type *lookup_methodptr_type (struct type *); extern void smash_to_method_type (struct type *type, struct type *self_type, struct type *to_type, - gdb::array_view args, + gdb::span args, int varargs); extern void smash_to_methodptr_type (struct type *, struct type *); @@ -2686,7 +2686,7 @@ extern CORE_ADDR get_pointer_type_max (struct type *); memory). In this situation, 'is_dynamic_type' will still return true for the return value of this function. */ extern struct type *resolve_dynamic_type - (struct type *type, gdb::array_view valaddr, + (struct type *type, gdb::span valaddr, CORE_ADDR addr, const frame_info_ptr *frame = nullptr); /* Predicate if the type has dynamic values, which are not resolved yet. @@ -2856,8 +2856,8 @@ extern int compare_ranks (struct rank a, struct rank b); extern int compare_badness (const badness_vector &, const badness_vector &); -extern badness_vector rank_function (gdb::array_view parms, - gdb::array_view args, +extern badness_vector rank_function (gdb::span parms, + gdb::span args, bool varargs = false); extern struct rank rank_one_type (struct type *, struct type *, diff --git a/gdb/gmp-utils.c b/gdb/gmp-utils.c index 6438a4615d4..a3a9712f07b 100644 --- a/gdb/gmp-utils.c +++ b/gdb/gmp-utils.c @@ -56,7 +56,7 @@ debug (const gdb_mpz &val) /* See gmp-utils.h. */ void -gdb_mpz::read (gdb::array_view buf, enum bfd_endian byte_order, +gdb_mpz::read (gdb::span buf, enum bfd_endian byte_order, bool unsigned_p) { mpz_import (m_val, 1 /* count */, -1 /* order */, buf.size () /* size */, @@ -79,7 +79,7 @@ gdb_mpz::read (gdb::array_view buf, enum bfd_endian byte_order, /* See gmp-utils.h. */ void -gdb_mpz::export_bits (gdb::array_view buf, int endian, bool unsigned_p, +gdb_mpz::export_bits (gdb::span buf, int endian, bool unsigned_p, bool safe) const { int sign = mpz_sgn (m_val); @@ -207,7 +207,7 @@ gdb_mpq::get_rounded () const /* See gmp-utils.h. */ void -gdb_mpq::read_fixed_point (gdb::array_view buf, +gdb_mpq::read_fixed_point (gdb::span buf, enum bfd_endian byte_order, bool unsigned_p, const gdb_mpq &scaling_factor) { @@ -221,7 +221,7 @@ gdb_mpq::read_fixed_point (gdb::array_view buf, /* See gmp-utils.h. */ void -gdb_mpq::write_fixed_point (gdb::array_view buf, +gdb_mpq::write_fixed_point (gdb::span buf, enum bfd_endian byte_order, bool unsigned_p, const gdb_mpq &scaling_factor) const { diff --git a/gdb/gmp-utils.h b/gdb/gmp-utils.h index 04f8d0c83dc..56bd66e441f 100644 --- a/gdb/gmp-utils.h +++ b/gdb/gmp-utils.h @@ -135,14 +135,14 @@ struct gdb_mpz the byte array's size. UNSIGNED_P indicates whether the number has an unsigned type. */ - void read (gdb::array_view buf, enum bfd_endian byte_order, + void read (gdb::span buf, enum bfd_endian byte_order, bool unsigned_p); /* Write VAL into BUF as a number whose byte size is the size of BUF, using the given BYTE_ORDER. UNSIGNED_P indicates whether the number has an unsigned type. */ - void write (gdb::array_view buf, enum bfd_endian byte_order, + void write (gdb::span buf, enum bfd_endian byte_order, bool unsigned_p) const { export_bits (buf, byte_order == BFD_ENDIAN_BIG ? 1 : -1 /* endian */, @@ -151,7 +151,7 @@ struct gdb_mpz /* Like write, but truncates the value to the desired number of bytes. */ - void truncate (gdb::array_view buf, enum bfd_endian byte_order, + void truncate (gdb::span buf, enum bfd_endian byte_order, bool unsigned_p) const { export_bits (buf, byte_order == BFD_ENDIAN_BIG ? 1 : -1 /* endian */, @@ -410,7 +410,7 @@ struct gdb_mpz If SAFE is true, an error is raised if BUF is not large enough to contain the value being exported. If SAFE is false, the value is truncated to fit in BUF. */ - void export_bits (gdb::array_view buf, int endian, bool unsigned_p, + void export_bits (gdb::span buf, int endian, bool unsigned_p, bool safe) const; friend struct gdb_mpq; @@ -566,7 +566,7 @@ struct gdb_mpq UNSIGNED_P indicates whether the number has an unsigned type. SCALING_FACTOR is the scaling factor to apply after having read the unscaled value from our buffer. */ - void read_fixed_point (gdb::array_view buf, + void read_fixed_point (gdb::span buf, enum bfd_endian byte_order, bool unsigned_p, const gdb_mpq &scaling_factor); @@ -576,7 +576,7 @@ struct gdb_mpq UNSIGNED_P indicates whether the number has an unsigned type. SCALING_FACTOR is the scaling factor to apply before writing the unscaled value to our buffer. */ - void write_fixed_point (gdb::array_view buf, + void write_fixed_point (gdb::span buf, enum bfd_endian byte_order, bool unsigned_p, const gdb_mpq &scaling_factor) const; @@ -609,7 +609,7 @@ struct gdb_mpf UNSIGNED_P indicates whether the number has an unsigned type. SCALING_FACTOR is the scaling factor to apply after having read the unscaled value from our buffer. */ - void read_fixed_point (gdb::array_view buf, + void read_fixed_point (gdb::span buf, enum bfd_endian byte_order, bool unsigned_p, const gdb_mpq &scaling_factor) { diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index e2333d10ca9..b80ac9a56a3 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -3348,7 +3348,7 @@ i386_pseudo_register_read_value (gdbarch *gdbarch, const frame_info_ptr &next_fr void i386_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, const int pseudo_reg_num, - gdb::array_view buf) + gdb::span buf) { if (i386_mmx_regnum_p (gdbarch, pseudo_reg_num)) { diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index bdafd523834..8cecf445395 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -408,7 +408,7 @@ extern value *i386_pseudo_register_read_value (gdbarch *gdbarch, extern void i386_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame, int regnum, - gdb::array_view buf); + gdb::span buf); extern void i386_ax_pseudo_register_collect (struct gdbarch *gdbarch, struct agent_expr *ax, diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c index b8db0b9d5fb..96834e596bb 100644 --- a/gdb/i386-windows-tdep.c +++ b/gdb/i386-windows-tdep.c @@ -169,7 +169,7 @@ static const gdb_byte i386_sigbe_bytes[] = { /* 4 bytes for tls::stackptr operand. */ }; -static const gdb::array_view i386_sig_patterns[] { +static const gdb::span i386_sig_patterns[] { { i386_sigbe_bytes }, }; diff --git a/gdb/infcall.c b/gdb/infcall.c index 4c40f6cb06e..91df4d45066 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -463,7 +463,7 @@ find_function_addr (struct value *function, static CORE_ADDR push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, - gdb::array_view args, + gdb::span args, struct type *value_type, CORE_ADDR *real_pc, CORE_ADDR *bp_addr, struct regcache *regcache) @@ -1038,7 +1038,7 @@ call_destructors (const std::list &dtors_to_invoke, struct value * call_function_by_hand (struct value *function, type *default_return_type, - gdb::array_view args) + gdb::span args) { return call_function_by_hand_dummy (function, default_return_type, args, NULL, NULL); @@ -1065,7 +1065,7 @@ call_function_by_hand (struct value *function, struct value * call_function_by_hand_dummy (struct value *function, type *default_return_type, - gdb::array_view args, + gdb::span args, dummy_frame_dtor_ftype *dummy_dtor, void *dummy_dtor_data) { diff --git a/gdb/infcall.h b/gdb/infcall.h index 58e40db3509..205cffff591 100644 --- a/gdb/infcall.h +++ b/gdb/infcall.h @@ -51,7 +51,7 @@ extern CORE_ADDR find_function_addr (struct value *function, extern struct value *call_function_by_hand (struct value *function, type *default_return_type, - gdb::array_view args); + gdb::span args); /* Similar to call_function_by_hand and additional call register_dummy_frame_dtor with DUMMY_DTOR and DUMMY_DTOR_DATA for the @@ -60,7 +60,7 @@ extern struct value *call_function_by_hand (struct value *function, extern struct value * call_function_by_hand_dummy (struct value *function, type *default_return_type, - gdb::array_view args, + gdb::span args, dummy_frame_dtor_ftype *dummy_dtor, void *dummy_dtor_data); diff --git a/gdb/inferior.h b/gdb/inferior.h index accd36740c3..2bb3f8d8655 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -558,7 +558,7 @@ class inferior : public refcounted_object, escaped, When false only the characters that GDB sees as special will be escaped. See construct_inferior_arguments for more details. */ template - void set_args (gdb::array_view args, bool escape_shell_char) + void set_args (gdb::span args, bool escape_shell_char) { this->set_args (construct_inferior_arguments (args, escape_shell_char)); } diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 8840dbe3f75..ab9f6ade55d 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -637,7 +637,7 @@ linux_nat_target::remove_exec_catchpoint (int pid) int linux_nat_target::set_syscall_catchpoint (int pid, bool needed, int any_count, - gdb::array_view syscall_counts) + gdb::span syscall_counts) { /* On GNU/Linux, we ignore the arguments. It means that we only enable the syscall catchpoints, but do not disable them. @@ -778,7 +778,7 @@ static sigset_t pass_mask; /* Update signals to pass to the inferior. */ void linux_nat_target::pass_signals - (gdb::array_view pass_signals) + (gdb::span pass_signals) { int signo; diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 180059a9496..3fe2715b604 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -48,7 +48,7 @@ class linux_nat_target : public inf_ptrace_target ptid_t wait (ptid_t, struct target_waitstatus *, target_wait_flags) override; - void pass_signals (gdb::array_view) override; + void pass_signals (gdb::span) override; enum target_xfer_status xfer_partial (enum target_object object, const char *annex, @@ -124,7 +124,7 @@ class linux_nat_target : public inf_ptrace_target int remove_exec_catchpoint (int) override; int set_syscall_catchpoint (int pid, bool needed, int any_count, - gdb::array_view syscall_counts) override; + gdb::span syscall_counts) override; const char *pid_to_exec_file (int pid) override; diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 5a7c39b9cef..94bdb978dbd 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -105,7 +105,7 @@ class thread_db_target final : public target_ops thread_info *thread_handle_to_thread_info (const gdb_byte *thread_handle, int handle_len, inferior *inf) override; - gdb::array_view thread_info_to_thread_handle (struct thread_info *) override; + gdb::span thread_info_to_thread_handle (struct thread_info *) override; }; static std::string libthread_db_search_path = LIBTHREAD_DB_SEARCH_PATH; @@ -1717,7 +1717,7 @@ thread_db_target::thread_handle_to_thread_info (const gdb_byte *thread_handle, /* Return the thread handle associated the thread_info pointer TP. */ -gdb::array_view +gdb::span thread_db_target::thread_info_to_thread_handle (struct thread_info *tp) { thread_db_thread_info *priv = get_thread_db_thread_info (tp); diff --git a/gdb/main.c b/gdb/main.c index b9a11cc0f47..d2df3560385 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -1112,7 +1112,7 @@ captured_main_1 (struct captured_main_args *context) symarg = argv[optind]; execarg = argv[optind]; ++optind; - gdb::array_view arg_view (&argv[optind], argc - optind); + gdb::span arg_view (&argv[optind], argc - optind); current_inferior ()->set_args (arg_view, (set_args == SET_ESC_ARGS)); } else diff --git a/gdb/minsyms.c b/gdb/minsyms.c index ad63e9d5eaf..788a430c887 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1326,7 +1326,7 @@ class minimal_symbol_install_worker public: minimal_symbol_install_worker (minimal_symbol *msymbols, - gdb::array_view hash_values, + gdb::span hash_values, objfile_per_bfd_storage *per_bfd, gdb::mutex &demangled_mutex) : m_time_it ("minsym install worker"), @@ -1387,7 +1387,7 @@ class minimal_symbol_install_worker private: scoped_time_it m_time_it; minimal_symbol *m_msymbols; - gdb::array_view m_hash_values; + gdb::span m_hash_values; objfile_per_bfd_storage *m_per_bfd; gdb::mutex &m_demangled_mutex; }; @@ -1461,7 +1461,7 @@ minimal_symbol_reader::install () gdb::parallel_for_each<1000, minimal_symbol *, minimal_symbol_install_worker> (&msymbols[0], &msymbols[mcount], msymbols, - gdb::array_view (hash_values), + gdb::span (hash_values), m_objfile->per_bfd, demangled_mutex); diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 0bbb39d5619..870d1195a06 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -950,8 +950,8 @@ mips_register_to_value (const frame_info_ptr &frame, int regnum, if (mips_convert_register_float_case_p (gdbarch, regnum, type)) { - gdb::array_view first_half = gdb::make_array_view (to, 4); - gdb::array_view second_half = gdb::make_array_view (to + 4, 4); + gdb::span first_half = gdb::make_array_view (to, 4); + gdb::span second_half = gdb::make_array_view (to + 4, 4); get_frame_register (frame, regnum + 0, second_half); get_frame_register (frame, regnum + 1, first_half); @@ -6249,7 +6249,7 @@ mips_o64_return_value (struct gdbarch *gdbarch, struct value *function, static void mips_read_fp_register_single (const frame_info_ptr &frame, int regno, - gdb::array_view rare_buffer) + gdb::span rare_buffer) { struct gdbarch *gdbarch = get_frame_arch (frame); int raw_size = register_size (gdbarch, regno); @@ -6283,7 +6283,7 @@ mips_read_fp_register_single (const frame_info_ptr &frame, int regno, static void mips_read_fp_register_double (const frame_info_ptr &frame, int regno, - gdb::array_view rare_buffer) + gdb::span rare_buffer) { struct gdbarch *gdbarch = get_frame_arch (frame); int raw_size = register_size (gdbarch, regno); diff --git a/gdb/nat/x86-linux.c b/gdb/nat/x86-linux.c index 838ca70fb9d..98917714813 100644 --- a/gdb/nat/x86-linux.c +++ b/gdb/nat/x86-linux.c @@ -188,7 +188,7 @@ x86_check_ssp_support (const int tid) /* See nat/x86-linux.h. */ bool -i386_ptrace_get_tls_data (int pid, gdb::array_view buffer) +i386_ptrace_get_tls_data (int pid, gdb::span buffer) { gdb_assert (buffer.size () == 3); @@ -200,7 +200,7 @@ i386_ptrace_get_tls_data (int pid, gdb::array_view buffer) /* See nat/x86-linux.h. */ bool -i386_ptrace_set_tls_data (int pid, gdb::array_view buffer) +i386_ptrace_set_tls_data (int pid, gdb::span buffer) { gdb_assert (buffer.size () == 3); diff --git a/gdb/nat/x86-linux.h b/gdb/nat/x86-linux.h index f12f90c5db6..1e7395ab610 100644 --- a/gdb/nat/x86-linux.h +++ b/gdb/nat/x86-linux.h @@ -85,13 +85,13 @@ extern bool x86_check_ssp_support (const int tid); length 3. */ extern bool i386_ptrace_get_tls_data - (int pid, gdb::array_view buffer); + (int pid, gdb::span buffer); /* Store the three TLS related GDT (Global Descriptor Table) entries held in BUFFER back into the kernel for thread PID. BUFFER must have a length of three. */ extern bool i386_ptrace_set_tls_data - (int pid, gdb::array_view buffer); + (int pid, gdb::span buffer); #endif /* GDB_NAT_X86_LINUX_H */ diff --git a/gdb/netbsd-nat.c b/gdb/netbsd-nat.c index 9eb1e3081f8..df22c878c83 100644 --- a/gdb/netbsd-nat.c +++ b/gdb/netbsd-nat.c @@ -713,7 +713,7 @@ nbsd_nat_target::remove_exec_catchpoint (int pid) int nbsd_nat_target::set_syscall_catchpoint (int pid, bool needed, int any_count, - gdb::array_view syscall_counts) + gdb::span syscall_counts) { /* Ignore the arguments. inf-ptrace.c will use PT_SYSCALL which will catch all system call entries and exits. The system calls diff --git a/gdb/netbsd-nat.h b/gdb/netbsd-nat.h index 3470fe103c8..af6d504b87b 100644 --- a/gdb/netbsd-nat.h +++ b/gdb/netbsd-nat.h @@ -44,7 +44,7 @@ struct nbsd_nat_target : public inf_ptrace_target int insert_exec_catchpoint (int pid) override; int remove_exec_catchpoint (int pid) override; int set_syscall_catchpoint (int pid, bool needed, int any_count, - gdb::array_view syscall_counts) + gdb::span syscall_counts) override; bool supports_multi_process () override; diff --git a/gdb/objfiles.c b/gdb/objfiles.c index c6be324af6d..8ad69c523c0 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -478,7 +478,7 @@ objfile::~objfile () static int objfile_relocate1 (struct objfile *objfile, - gdb::array_view new_offsets) + gdb::span new_offsets) { std::vector delta (objfile->section_offsets.size ()); @@ -531,7 +531,7 @@ objfile_relocate1 (struct objfile *objfile, void objfile_relocate (struct objfile *objfile, - gdb::array_view new_offsets) + gdb::span new_offsets) { int changed = 0; diff --git a/gdb/objfiles.h b/gdb/objfiles.h index fa265f83b79..ae928fedd17 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -923,7 +923,7 @@ extern void build_objfile_section_table (struct objfile *); extern void free_objfile_separate_debug (struct objfile *); extern void objfile_relocate (struct objfile *, - gdb::array_view); + gdb::span); extern void objfile_rebase (struct objfile *, CORE_ADDR); extern void objfile_set_sym_fns (struct objfile *objfile, diff --git a/gdb/procfs.c b/gdb/procfs.c index 615b92006a8..459a9f3154b 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -118,7 +118,7 @@ class procfs_target final : public inf_child_target ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) override; - void pass_signals (gdb::array_view) override; + void pass_signals (gdb::span) override; void files_info () override; @@ -2501,7 +2501,7 @@ procfs_target::resume (ptid_t scope_ptid, int step, enum gdb_signal signo) /* Set up to trace signals in the child process. */ void -procfs_target::pass_signals (gdb::array_view pass_signals) +procfs_target::pass_signals (gdb::span pass_signals) { sigset_t signals; procinfo *pi = find_procinfo_or_die (inferior_ptid.pid (), 0); diff --git a/gdb/python/py-connection.c b/gdb/python/py-connection.c index 313a5202ee3..8e771f620a1 100644 --- a/gdb/python/py-connection.c +++ b/gdb/python/py-connection.c @@ -285,7 +285,7 @@ struct py_send_packet_callbacks : public send_remote_packet_callbacks /* There's nothing to do when the packet is sent. */ - void sending (gdb::array_view &buf) override + void sending (gdb::span &buf) override { /* Nothing. */ } /* When the result is returned create a Python object and assign @@ -294,7 +294,7 @@ struct py_send_packet_callbacks : public send_remote_packet_callbacks the result we got back from the remote is empty then set the result to None. */ - void received (gdb::array_view &buf) override + void received (gdb::span &buf) override { if (buf.size () > 0 && buf.data ()[0] != '\0') m_result = gdbpy_bytes_from_string_and_size (buf); @@ -362,7 +362,7 @@ connection_object::send_packet (gdbpy_borrowed_ref<> args, scoped_restore_current_thread restore_thread; switch_to_target_no_thread (target); - gdb::array_view view (packet_str, packet_len); + gdb::span view (packet_str, packet_len); py_send_packet_callbacks callbacks; send_remote_packet (view, &callbacks); return callbacks.result (); diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index 84a4b1ae6ee..01aa1d754a3 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -745,7 +745,7 @@ infpy_thread_from_thread_handle (PyObject *self, PyObject *args, PyObject *kw) struct thread_info *thread_info; thread_info = find_thread_by_handle - (gdb::array_view (bytes, bytes_len), + (gdb::span (bytes, bytes_len), inf_obj->inferior); if (thread_info != NULL) return thread_to_thread_object (thread_info).release (); @@ -894,7 +894,7 @@ infpy_set_args (PyObject *self, PyObject *value, void *closure) return -1; args.push_back (std::move (str)); } - gdb::array_view const> args_view (args); + gdb::span const> args_view (args); inf->inferior->set_args (args_view, true); } else diff --git a/gdb/python/py-infthread.c b/gdb/python/py-infthread.c index eff181c939b..b82c8181f60 100644 --- a/gdb/python/py-infthread.c +++ b/gdb/python/py-infthread.c @@ -320,7 +320,7 @@ thpy_thread_handle (PyObject *self, PyObject *args) thread_object *thread_obj = (thread_object *) self; THPY_REQUIRE_VALID (thread_obj); - gdb::array_view hv; + gdb::span hv; try { diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 65bbd406510..cf05c939d29 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -966,7 +966,7 @@ frame_unwind_python::sniff (const frame_info_ptr &this_frame, cached_reg_t *cached = new (&cached_frame->reg[i]) cached_reg_t (); cached->num = reg->number; cached->data.resize (data_size); - gdb::array_view contents = value->contents (); + gdb::span contents = value->contents (); cached->data.assign (contents.begin (), contents.end ()); } } diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 9d5986d3767..390a2233d9b 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -1347,7 +1347,7 @@ valpy_get_bytes (PyObject *self, void *closure) return value_obj->content_bytes; } - gdb::array_view contents; + gdb::span contents; try { contents = value->contents (); @@ -1881,7 +1881,7 @@ valpy_long (PyObject *self) && type->code () != TYPE_CODE_PTR) error (_("Cannot convert value to long.")); - gdb::array_view contents = value->contents (); + gdb::span contents = value->contents (); #if PY_VERSION_HEX >= 0x030d0000 int flags = (type_byte_order (type) == BFD_ENDIAN_BIG ? Py_ASNATIVEBYTES_BIG_ENDIAN diff --git a/gdb/python/py-wrappers.h b/gdb/python/py-wrappers.h index 9832a4e71ad..09ece45261b 100644 --- a/gdb/python/py-wrappers.h +++ b/gdb/python/py-wrappers.h @@ -109,7 +109,7 @@ gdbpy_bytes_from_string (const char *str) /* Wrapper for PyBytes_FromStringAndSize. */ template gdbpy_ref<> -gdbpy_bytes_from_string_and_size (gdb::array_view data) +gdbpy_bytes_from_string_and_size (gdb::span data) { /* Python allows STR==nullptr but it leaves the object uninitialized, and I think we should avoid this in gdb. */ diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c index bda9071b216..e6ca1cda0bb 100644 --- a/gdb/python/py-xmethods.c +++ b/gdb/python/py-xmethods.c @@ -44,7 +44,7 @@ struct python_xmethod_worker : xmethod_worker /* Implementation of xmethod_worker::invoke for Python. */ - value *invoke (value *obj, gdb::array_view args) override; + value *invoke (value *obj, gdb::span args) override; /* Implementation of xmethod_worker::do_get_arg_types for Python. */ @@ -56,7 +56,7 @@ struct python_xmethod_worker : xmethod_worker result type, if the get_result_type operation is not provided by WORKER then EXT_LANG_RC_OK is returned and NULL is returned in *RESULT_TYPE. */ - ext_lang_rc do_get_result_type (value *obj, gdb::array_view args, + ext_lang_rc do_get_result_type (value *obj, gdb::span args, type **result_type_ptr) override; private: @@ -402,7 +402,7 @@ python_xmethod_worker::do_get_arg_types (std::vector *arg_types) ext_lang_rc python_xmethod_worker::do_get_result_type (value *obj, - gdb::array_view args, + gdb::span args, type **result_type_ptr) { struct type *obj_type, *this_type; @@ -508,7 +508,7 @@ python_xmethod_worker::do_get_result_type (value *obj, struct value * python_xmethod_worker::invoke (struct value *obj, - gdb::array_view args) + gdb::span args) { gdbpy_enter enter_py; diff --git a/gdb/python/python.c b/gdb/python/python.c index 5ad478cf2e3..d6a14a90424 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -993,7 +993,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args) std::vector decoded_sals; symtab_and_line def_sal; - gdb::array_view sals; + gdb::span sals; try { if (locspec != NULL) diff --git a/gdb/ravenscar-thread.h b/gdb/ravenscar-thread.h index e65733a069c..564b0463e69 100644 --- a/gdb/ravenscar-thread.h +++ b/gdb/ravenscar-thread.h @@ -24,7 +24,7 @@ struct ravenscar_arch_ops { - ravenscar_arch_ops (gdb::array_view offsets_, + ravenscar_arch_ops (gdb::span offsets_, int first_stack = -1, int last_stack = -1, int v_init = -1, @@ -90,7 +90,7 @@ struct ravenscar_arch_ops are offsets. The offsets are either in the thread descriptor or the stack, depending on the other fields. An offset of -1 means that the corresponding register is not stored. */ - const gdb::array_view offsets; + const gdb::span offsets; /* If these are -1, then all registers for this architecture are stored in the thread descriptor. Otherwise, these mark a range diff --git a/gdb/regcache.c b/gdb/regcache.c index abdd49190ee..2440fc1d8a1 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -220,7 +220,7 @@ regcache::regcache (inferior *inf_for_target_calls, gdbarch *gdbarch) readonly_detached_regcache::readonly_detached_regcache (regcache &src) : readonly_detached_regcache (src.arch (), [&src] (int regnum, - gdb::array_view buf) + gdb::span buf) { return src.cooked_read (regnum, buf); }) { } @@ -234,18 +234,18 @@ reg_buffer::arch () const /* Helper for reg_buffer::register_buffer. */ template -gdb::array_view +gdb::span reg_buffer::register_buffer (int regnum) const { assert_regnum (regnum); ElemType *start = &m_registers[m_descr->register_offset[regnum]]; int size = m_descr->sizeof_register[regnum]; - return gdb::array_view (start, size); + return gdb::span (start, size); } /* See regcache.h. */ -gdb::array_view +gdb::span reg_buffer::register_buffer (int regnum) const { return register_buffer (regnum); @@ -253,7 +253,7 @@ reg_buffer::register_buffer (int regnum) const /* See regcache.h. */ -gdb::array_view +gdb::span reg_buffer::register_buffer (int regnum) { return register_buffer (regnum); @@ -277,7 +277,7 @@ reg_buffer::save (register_read_ftype cooked_read) { if (gdbarch_register_reggroup_p (gdbarch, regnum, save_reggroup)) { - gdb::array_view dst_buf = register_buffer (regnum); + gdb::span dst_buf = register_buffer (regnum); register_status status = cooked_read (regnum, dst_buf); gdb_assert (status != REG_UNKNOWN); @@ -612,7 +612,7 @@ regcache::raw_update (int regnum) } register_status -readable_regcache::raw_read (int regnum, gdb::array_view dst) +readable_regcache::raw_read (int regnum, gdb::span dst) { assert_regnum (regnum); gdb_assert (dst.size () == m_descr->sizeof_register[regnum]); @@ -713,7 +713,7 @@ regcache_raw_get_signed (struct regcache *regcache, int regnum) /* See regcache.h. */ register_status -readable_regcache::cooked_read (int regnum, gdb::array_view dst) +readable_regcache::cooked_read (int regnum, gdb::span dst) { gdb_assert (regnum >= 0); gdb_assert (regnum < m_descr->nr_cooked_registers); @@ -858,7 +858,7 @@ regcache_cooked_write_unsigned (struct regcache *regcache, int regnum, } void -regcache::raw_write (int regnum, gdb::array_view src) +regcache::raw_write (int regnum, gdb::span src) { assert_regnum (regnum); gdb_assert (src.size () == m_descr->sizeof_register[regnum]); @@ -907,7 +907,7 @@ regcache::raw_write (int regnum, const gdb_byte *src) /* See regcache.h. */ void -regcache::cooked_write (int regnum, gdb::array_view src) +regcache::cooked_write (int regnum, gdb::span src) { gdb_assert (regnum >= 0); gdb_assert (regnum < m_descr->nr_cooked_registers); @@ -939,7 +939,7 @@ regcache::cooked_write (int regnum, const gdb_byte *src) register_status readable_regcache::read_part (int regnum, int offset, - gdb::array_view dst, bool is_raw) + gdb::span dst, bool is_raw) { int reg_size = register_size (regnum); @@ -983,7 +983,7 @@ readable_regcache::read_part (int regnum, int offset, void reg_buffer::raw_collect_part (int regnum, int offset, - gdb::array_view dst) const + gdb::span dst) const { int reg_size = register_size (regnum); @@ -1013,7 +1013,7 @@ reg_buffer::raw_collect_part (int regnum, int offset, register_status regcache::write_part (int regnum, int offset, - gdb::array_view src, bool is_raw) + gdb::span src, bool is_raw) { int reg_size = register_size (regnum); @@ -1065,7 +1065,7 @@ regcache::write_part (int regnum, int offset, void reg_buffer::raw_supply_part (int regnum, int offset, - gdb::array_view src) + gdb::span src) { int reg_size = register_size (regnum); @@ -1096,7 +1096,7 @@ reg_buffer::raw_supply_part (int regnum, int offset, register_status readable_regcache::raw_read_part (int regnum, int offset, - gdb::array_view dst) + gdb::span dst) { assert_regnum (regnum); return read_part (regnum, offset, dst, true); @@ -1106,7 +1106,7 @@ readable_regcache::raw_read_part (int regnum, int offset, void regcache::raw_write_part (int regnum, int offset, - gdb::array_view src) + gdb::span src) { assert_regnum (regnum); write_part (regnum, offset, src, true); @@ -1116,7 +1116,7 @@ regcache::raw_write_part (int regnum, int offset, register_status readable_regcache::cooked_read_part (int regnum, int offset, - gdb::array_view dst) + gdb::span dst) { gdb_assert (regnum >= 0 && regnum < m_descr->nr_cooked_registers); return read_part (regnum, offset, dst, false); @@ -1126,7 +1126,7 @@ readable_regcache::cooked_read_part (int regnum, int offset, void regcache::cooked_write_part (int regnum, int offset, - gdb::array_view src) + gdb::span src) { gdb_assert (regnum >= 0 && regnum < m_descr->nr_cooked_registers); write_part (regnum, offset, src, false); @@ -1135,9 +1135,9 @@ regcache::cooked_write_part (int regnum, int offset, /* See gdbsupport/common-regcache.h. */ void -reg_buffer::raw_supply (int regnum, gdb::array_view src) +reg_buffer::raw_supply (int regnum, gdb::span src) { - gdb::array_view dst = register_buffer (regnum); + gdb::span dst = register_buffer (regnum); if (src.data () != nullptr) { @@ -1171,7 +1171,7 @@ void reg_buffer::raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len, bool is_signed) { - gdb::array_view dst = register_buffer (regnum); + gdb::span dst = register_buffer (regnum); bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch); copy_integer_to_size (dst.data (), dst.size (), addr, addr_len, is_signed, @@ -1184,7 +1184,7 @@ reg_buffer::raw_supply_integer (int regnum, const gdb_byte *addr, int addr_len, void reg_buffer::raw_supply_zeroed (int regnum) { - gdb::array_view dst = register_buffer (regnum); + gdb::span dst = register_buffer (regnum); memset (dst.data (), 0, dst.size ()); m_register_status[regnum] = REG_VALID; } @@ -1194,7 +1194,7 @@ reg_buffer::raw_supply_zeroed (int regnum) void reg_buffer::raw_supply_part_zeroed (int regnum, int offset, size_t size) { - gdb::array_view dst = register_buffer (regnum).slice (offset, size); + gdb::span dst = register_buffer (regnum).slice (offset, size); memset (dst.data (), 0, dst.size ()); m_register_status[regnum] = REG_VALID; } @@ -1202,9 +1202,9 @@ reg_buffer::raw_supply_part_zeroed (int regnum, int offset, size_t size) /* See gdbsupport/common-regcache.h. */ void -reg_buffer::raw_collect (int regnum, gdb::array_view dst) const +reg_buffer::raw_collect (int regnum, gdb::span dst) const { - gdb::array_view src = register_buffer (regnum); + gdb::span src = register_buffer (regnum); copy (src, dst); } @@ -1225,7 +1225,7 @@ void reg_buffer::raw_collect_integer (int regnum, gdb_byte *addr, int addr_len, bool is_signed) const { - gdb::array_view dst = register_buffer (regnum); + gdb::span dst = register_buffer (regnum); bfd_endian byte_order = gdbarch_byte_order (m_descr->gdbarch); copy_integer_to_size (addr, addr_len, dst.data (), dst.size (), is_signed, byte_order); @@ -1396,7 +1396,7 @@ reg_buffer::raw_compare (int regnum, const void *buf, int offset) const { gdb_assert (buf != NULL); - gdb::array_view regbuf = register_buffer (regnum); + gdb::span regbuf = register_buffer (regnum); gdb_assert (offset <= regbuf.size ()); regbuf = regbuf.slice (offset); @@ -1488,7 +1488,7 @@ regcache::register_debug_string (int regno) if (regno >= 0 && regno < gdbarch_num_regs (gdbarch)) { - gdb::array_view buf = register_buffer (regno); + gdb::span buf = register_buffer (regno); string_appendf (s, " = "); diff --git a/gdb/regcache.h b/gdb/regcache.h index adc1e473630..f136f7275a8 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -171,7 +171,7 @@ extern struct type *register_type (struct gdbarch *gdbarch, int regnum); extern int register_size (struct gdbarch *gdbarch, int regnum); using register_read_ftype - = gdb::function_view)>; + = gdb::function_view)>; /* A (register_number, register_value) pair. */ @@ -197,7 +197,7 @@ class reg_buffer : public reg_buffer_common enum register_status get_register_status (int regnum) const override; /* See gdbsupport/common-regcache.h. */ - void raw_collect (int regnum, gdb::array_view dst) const override; + void raw_collect (int regnum, gdb::span dst) const override; /* Deprecated overload of the above. */ void raw_collect (int regnum, void *dst) const; @@ -213,14 +213,14 @@ class reg_buffer : public reg_buffer_common /* Collect part of register REGNUM from this register buffer. Start at OFFSET in register. The size is given by the size of DST. */ void raw_collect_part (int regnum, int offset, - gdb::array_view dst) const; + gdb::span dst) const; /* Deprecated overload of the above. */ void raw_collect_part (int regnum, int offset, int len, gdb_byte *dst) const { raw_collect_part (regnum, offset, gdb::make_array_view (dst, len)); } /* See gdbsupport/common-regcache.h. */ - void raw_supply (int regnum, gdb::array_view src) override; + void raw_supply (int regnum, gdb::span src) override; /* Deprecated overload of the above. */ void raw_supply (int regnum, const void *src); @@ -248,7 +248,7 @@ class reg_buffer : public reg_buffer_common the register. The size is given by the size of SRC. The rest of the register left untouched. */ void raw_supply_part (int regnum, int offset, - gdb::array_view src); + gdb::span src); void invalidate (int regnum); @@ -268,9 +268,9 @@ class reg_buffer : public reg_buffer_common /* Return a view on register REGNUM's buffer cache. */ template - gdb::array_view register_buffer (int regnum) const; - gdb::array_view register_buffer (int regnum) const; - gdb::array_view register_buffer (int regnum); + gdb::span register_buffer (int regnum) const; + gdb::span register_buffer (int regnum) const; + gdb::span register_buffer (int regnum); /* Save a register cache. The set of registers saved into the regcache determined by the save_reggroup. COOKED_READ returns @@ -300,7 +300,7 @@ class readable_regcache : public reg_buffer /* Transfer a raw register [0..NUM_REGS) from core-gdb to this regcache, return its value in *BUF and return its availability status. */ - register_status raw_read (int regnum, gdb::array_view dst); + register_status raw_read (int regnum, gdb::span dst); /* Deprecated overload of the above. */ register_status raw_read (int regnum, gdb_byte *dst); @@ -310,7 +310,7 @@ class readable_regcache : public reg_buffer /* Partial transfer of raw registers. Return the status of the register. */ register_status raw_read_part (int regnum, int offset, - gdb::array_view dst); + gdb::span dst); /* Deprecated overload of the above. */ register_status raw_read_part (int regnum, int offset, int len, @@ -322,7 +322,7 @@ class readable_regcache : public reg_buffer /* Transfer a raw register [0..NUM_REGS+NUM_PSEUDO_REGS) from core-gdb to this regcache, return its value in DST and return its availability status. */ - register_status cooked_read (int regnum, gdb::array_view dst); + register_status cooked_read (int regnum, gdb::span dst); register_status cooked_read (int regnum, gdb_byte *dst); template> @@ -330,7 +330,7 @@ class readable_regcache : public reg_buffer /* Partial transfer of a cooked register. */ register_status cooked_read_part (int regnum, int offset, - gdb::array_view dst); + gdb::span dst); /* Deprecated overload of the above. */ register_status cooked_read_part (int regnum, int offset, int len, gdb_byte *src) @@ -345,7 +345,7 @@ class readable_regcache : public reg_buffer /* Perform a partial register transfer using a read, modify, write operation. Will fail if register is currently invalid. */ register_status read_part (int regnum, int offset, - gdb::array_view dst, bool is_raw); + gdb::span dst, bool is_raw); }; /* Buffer of registers, can be read and written. */ @@ -381,7 +381,7 @@ class regcache : public detached_regcache /* Update the value of raw register REGNUM (in the range [0..NUM_REGS)) and transfer its value to core-gdb. */ - void raw_write (int regnum, gdb::array_view src); + void raw_write (int regnum, gdb::span src); /* Deprecated overload of the above. */ void raw_write (int regnum, const gdb_byte *src); @@ -390,7 +390,7 @@ class regcache : public detached_regcache void raw_write (int regnum, T val); /* Transfer of pseudo-registers. */ - void cooked_write (int regnum, gdb::array_view src); + void cooked_write (int regnum, gdb::span src); /* Deprecated overload of the above. */ void cooked_write (int regnum, const gdb_byte *src); @@ -403,7 +403,7 @@ class regcache : public detached_regcache /* Partial transfer of raw registers. Perform read, modify, write style operations. */ void raw_write_part (int regnum, int offset, - gdb::array_view src); + gdb::span src); /* Deprecated overload of the above. */ void raw_write_part (int regnum, int offset, int len, const gdb_byte *src) @@ -412,7 +412,7 @@ class regcache : public detached_regcache /* Partial transfer of a cooked register. Perform read, modify, write style operations. */ void cooked_write_part (int regnum, int offset, - gdb::array_view src); + gdb::span src); /* Deprecated overload of the above. */ void cooked_write_part (int regnum, int offset, int len, const gdb_byte *src) @@ -483,7 +483,7 @@ class regcache : public detached_regcache /* Perform a partial register transfer using a read, modify, write operation. */ register_status write_part (int regnum, int offset, - gdb::array_view src, + gdb::span src, bool is_raw); /* The inferior to switch to, to make target calls. diff --git a/gdb/remote.c b/gdb/remote.c index a728d57df6e..7dfe86cebbe 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1018,12 +1018,12 @@ class remote_target : public process_stratum_target void mourn_inferior () override; - void pass_signals (gdb::array_view) override; + void pass_signals (gdb::span) override; int set_syscall_catchpoint (int, bool, int, - gdb::array_view) override; + gdb::span) override; - void program_signals (gdb::array_view) override; + void program_signals (gdb::span) override; bool thread_alive (ptid_t ptid) override; @@ -1039,7 +1039,7 @@ class remote_target : public process_stratum_target int handle_len, inferior *inf) override; - gdb::array_view thread_info_to_thread_handle (struct thread_info *tp) + gdb::span thread_info_to_thread_handle (struct thread_info *tp) override; void stop (ptid_t) override; @@ -3324,7 +3324,7 @@ record_currthread (struct remote_state *rs, ptid_t currthread) it can simply pass through to the inferior without reporting. */ void -remote_target::pass_signals (gdb::array_view pass_signals) +remote_target::pass_signals (gdb::span pass_signals) { if (m_features.packet_support (PACKET_QPassSignals) != PACKET_DISABLE) { @@ -3374,7 +3374,7 @@ remote_target::pass_signals (gdb::array_view pass_signals) int remote_target::set_syscall_catchpoint (int pid, bool needed, int any_count, - gdb::array_view syscall_counts) + gdb::span syscall_counts) { const char *catch_packet; int n_sysno = 0; @@ -3443,7 +3443,7 @@ remote_target::set_syscall_catchpoint (int pid, bool needed, int any_count, signals it should pass through to the inferior when detaching. */ void -remote_target::program_signals (gdb::array_view signals) +remote_target::program_signals (gdb::span signals) { if (m_features.packet_support (PACKET_QProgramSignals) != PACKET_DISABLE) { @@ -12617,7 +12617,7 @@ struct cli_packet_command_callbacks : public send_remote_packet_callbacks /* Called before the packet is sent. BUF is the packet content before the protocol specific prefix, suffix, and escaping is added. */ - void sending (gdb::array_view &buf) override + void sending (gdb::span &buf) override { gdb_puts ("sending: "); print_packet (buf); @@ -12626,7 +12626,7 @@ struct cli_packet_command_callbacks : public send_remote_packet_callbacks /* Called with BUF, the reply from the remote target. */ - void received (gdb::array_view &buf) override + void received (gdb::span &buf) override { gdb_puts ("received: \""); print_packet (buf); @@ -12639,7 +12639,7 @@ struct cli_packet_command_callbacks : public send_remote_packet_callbacks '\x??' with '??' replaced by the hexadecimal value of the byte. */ static void - print_packet (gdb::array_view &buf) + print_packet (gdb::span &buf) { string_file stb; @@ -12659,7 +12659,7 @@ struct cli_packet_command_callbacks : public send_remote_packet_callbacks /* See remote.h. */ void -send_remote_packet (gdb::array_view &buf, +send_remote_packet (gdb::span &buf, send_remote_packet_callbacks *callbacks) { if (buf.size () == 0 || buf.data ()[0] == '\0') @@ -12678,7 +12678,7 @@ send_remote_packet (gdb::array_view &buf, if (bytes < 0) error (_("error while fetching packet from remote target")); - gdb::array_view view (&rs->buf[0], bytes); + gdb::span view (&rs->buf[0], bytes); callbacks->received (view); } @@ -12688,7 +12688,7 @@ static void cli_packet_command (const char *args, int from_tty) { cli_packet_command_callbacks cb; - gdb::array_view view + gdb::span view = gdb::make_array_view (args, args == nullptr ? 0 : strlen (args)); send_remote_packet (view, &cb); } @@ -15870,7 +15870,7 @@ remote_target::thread_handle_to_thread_info (const gdb_byte *thread_handle, return NULL; } -gdb::array_view +gdb::span remote_target::thread_info_to_thread_handle (struct thread_info *tp) { remote_thread_info *priv = get_remote_thread_info (tp); diff --git a/gdb/remote.h b/gdb/remote.h index 4e61c9c88e3..52253803137 100644 --- a/gdb/remote.h +++ b/gdb/remote.h @@ -92,7 +92,7 @@ struct send_remote_packet_callbacks (before any of the protocol specific prefix, suffix, or escaping is applied). */ - virtual void sending (gdb::array_view &buf) = 0; + virtual void sending (gdb::span &buf) = 0; /* The RECEIVED callback is called once a reply has been received from the remote target. The content of the reply is in BUF which can't be @@ -100,7 +100,7 @@ struct send_remote_packet_callbacks RECEIVED call has returned. If you need to preserve the contents of BUF then a copy should be taken. */ - virtual void received (gdb::array_view &buf) = 0; + virtual void received (gdb::span &buf) = 0; }; /* Send BUF to the current remote target. If BUF points to an empty @@ -112,7 +112,7 @@ struct send_remote_packet_callbacks target, and calls CALLBACKS->received() with the reply once this is received from the remote target. */ -extern void send_remote_packet (gdb::array_view &buf, +extern void send_remote_packet (gdb::span &buf, send_remote_packet_callbacks *callbacks); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 9c2a4c4c811..1df3740d39d 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -648,7 +648,7 @@ rust_language::print_enum (struct value *val, struct ui_file *stream, opts.deref_ref = false; gdb_assert (rust_enum_p (type)); - gdb::array_view view + gdb::span view (val->contents_for_printing ().data (), val->type ()->length ()); type = resolve_dynamic_type (type, view, val->address ()); diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c index 464135717b2..3aa7609ca26 100644 --- a/gdb/solib-darwin.c +++ b/gdb/solib-darwin.c @@ -170,7 +170,7 @@ lookup_symbol_from_bfd (bfd *abfd, const char *symname) { CORE_ADDR symaddr = 0; - gdb::array_view symbol_table + gdb::span symbol_table = gdb_bfd_canonicalize_symtab (abfd, false); for (const asymbol *sym : symbol_table) diff --git a/gdb/solib.c b/gdb/solib.c index 4d5e136ba03..7670aef6f84 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1605,7 +1605,7 @@ gdb_bfd_lookup_symbol_from_symtab ( bfd *abfd, gdb::function_view match_sym) { CORE_ADDR symaddr = 0; - gdb::array_view symbol_table + gdb::span symbol_table = gdb_bfd_canonicalize_symtab (abfd, false); for (asymbol *sym : symbol_table) diff --git a/gdb/source.c b/gdb/source.c index 31a0e5d6f13..a0584847451 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1472,7 +1472,7 @@ info_line_command (const char *arg, int from_tty) std::vector decoded_sals; symtab_and_line curr_sal; - gdb::array_view sals; + gdb::span sals; if (arg == 0) { diff --git a/gdb/symtab.c b/gdb/symtab.c index f8a44f60bcb..dc40fbfadf6 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6521,7 +6521,7 @@ static struct symbol_impl symbol_impl[MAX_SYMBOL_IMPLS]; /* The globally visible pointer. This is separate from 'symbol_impl' so that it can be const. */ -gdb::array_view symbol_impls (symbol_impl); +gdb::span symbol_impls (symbol_impl); /* Make sure we saved enough room in struct symbol. */ @@ -6678,7 +6678,7 @@ symbol::value_block () const /* See symtab.h. */ void -symbol::relocate (gdb::array_view delta) +symbol::relocate (gdb::span delta) { if ((loc_class () == LOC_LABEL || loc_class () == LOC_STATIC) && section_index () >= 0) diff --git a/gdb/symtab.h b/gdb/symtab.h index 0e823d03487..884dce45d38 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -1154,7 +1154,7 @@ struct symbol_block_ops /* Return the DWARF block data of function FRAMEFUNC valid for inferior context address PC. Return an empty view if no such location is valid for PC. */ - gdb::array_view (*find_frame_base_location) + gdb::span (*find_frame_base_location) (struct symbol *framefunc, CORE_ADDR pc); /* Return the frame base address. FRAME is the frame for which we want to @@ -1222,7 +1222,7 @@ enum symbol_subclass_kind SYMBOL_RUST_VTABLE }; -extern gdb::array_view symbol_impls; +extern gdb::span symbol_impls; /* This structure is space critical. See space comments at the top. */ @@ -1443,7 +1443,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack /* Relocate this symbol. OFFSETS is the relocation offsets to use. */ - void relocate (gdb::array_view offsets); + void relocate (gdb::span offsets); /* Data type of value */ diff --git a/gdb/target-debug.h b/gdb/target-debug.h index 949847b181c..4af0b5b71b5 100644 --- a/gdb/target-debug.h +++ b/gdb/target-debug.h @@ -277,8 +277,8 @@ target_debug_print_traceframe_info_up (std::unique_ptr &info) { return host_address_to_string (info.get ()); } static std::string -target_debug_print_gdb_array_view_const_int - (const gdb::array_view &view) +target_debug_print_gdb_span_const_int + (const gdb::span &view) { return host_address_to_string (view.data ()); } static std::string @@ -325,7 +325,7 @@ target_debug_print_target_wait_flags (target_wait_flags options) { return target_options_to_string (options); } static std::string -target_debug_print_signals (gdb::array_view sigs) +target_debug_print_signals (gdb::span sigs) { std::string s = "{"; @@ -346,7 +346,7 @@ target_debug_print_size_t (size_t size) } static std::string -target_debug_print_gdb_array_view_const_gdb_byte (gdb::array_view vector) +target_debug_print_gdb_span_const_gdb_byte (gdb::span vector) { std::string s = "{"; @@ -360,7 +360,7 @@ target_debug_print_gdb_array_view_const_gdb_byte (gdb::array_view arg3) override; + int set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::span arg3) override; void mourn_inferior () override; - void pass_signals (gdb::array_view arg0) override; - void program_signals (gdb::array_view arg0) override; + void pass_signals (gdb::span arg0) override; + void program_signals (gdb::span arg0) override; bool thread_alive (ptid_t arg0) override; void update_thread_list () override; std::string pid_to_str (ptid_t arg0) override; const char *extra_thread_info (thread_info *arg0) override; const char *thread_name (thread_info *arg0) override; thread_info *thread_handle_to_thread_info (const gdb_byte *arg0, int arg1, inferior *arg2) override; - gdb::array_view thread_info_to_thread_handle (struct thread_info *arg0) override; + gdb::span thread_info_to_thread_handle (struct thread_info *arg0) override; void stop (ptid_t arg0) override; void interrupt () override; void pass_ctrlc () override; @@ -261,17 +261,17 @@ struct debug_target : public target_ops int insert_exec_catchpoint (int arg0) override; int remove_exec_catchpoint (int arg0) override; void follow_exec (inferior *arg0, ptid_t arg1, const char *arg2) override; - int set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_view arg3) override; + int set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::span arg3) override; void mourn_inferior () override; - void pass_signals (gdb::array_view arg0) override; - void program_signals (gdb::array_view arg0) override; + void pass_signals (gdb::span arg0) override; + void program_signals (gdb::span arg0) override; bool thread_alive (ptid_t arg0) override; void update_thread_list () override; std::string pid_to_str (ptid_t arg0) override; const char *extra_thread_info (thread_info *arg0) override; const char *thread_name (thread_info *arg0) override; thread_info *thread_handle_to_thread_info (const gdb_byte *arg0, int arg1, inferior *arg2) override; - gdb::array_view thread_info_to_thread_handle (struct thread_info *arg0) override; + gdb::span thread_info_to_thread_handle (struct thread_info *arg0) override; void stop (ptid_t arg0) override; void interrupt () override; void pass_ctrlc () override; @@ -1588,19 +1588,19 @@ debug_target::follow_exec (inferior *arg0, ptid_t arg1, const char *arg2) } int -target_ops::set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_view arg3) +target_ops::set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::span arg3) { return this->beneath ()->set_syscall_catchpoint (arg0, arg1, arg2, arg3); } int -dummy_target::set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_view arg3) +dummy_target::set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::span arg3) { return 1; } int -debug_target::set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_view arg3) +debug_target::set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::span arg3) { target_debug_printf_nofunc ("-> %s->set_syscall_catchpoint (...)", this->beneath ()->shortname ()); int result @@ -1610,7 +1610,7 @@ debug_target::set_syscall_catchpoint (int arg0, bool arg1, int arg2, gdb::array_ target_debug_print_int (arg0).c_str (), target_debug_print_bool (arg1).c_str (), target_debug_print_int (arg2).c_str (), - target_debug_print_gdb_array_view_const_int (arg3).c_str (), + target_debug_print_gdb_span_const_int (arg3).c_str (), target_debug_print_int (result).c_str ()); return result; } @@ -1637,18 +1637,18 @@ debug_target::mourn_inferior () } void -target_ops::pass_signals (gdb::array_view arg0) +target_ops::pass_signals (gdb::span arg0) { this->beneath ()->pass_signals (arg0); } void -dummy_target::pass_signals (gdb::array_view arg0) +dummy_target::pass_signals (gdb::span arg0) { } void -debug_target::pass_signals (gdb::array_view arg0) +debug_target::pass_signals (gdb::span arg0) { target_debug_printf_nofunc ("-> %s->pass_signals (...)", this->beneath ()->shortname ()); this->beneath ()->pass_signals (arg0); @@ -1658,18 +1658,18 @@ debug_target::pass_signals (gdb::array_view arg0) } void -target_ops::program_signals (gdb::array_view arg0) +target_ops::program_signals (gdb::span arg0) { this->beneath ()->program_signals (arg0); } void -dummy_target::program_signals (gdb::array_view arg0) +dummy_target::program_signals (gdb::span arg0) { } void -debug_target::program_signals (gdb::array_view arg0) +debug_target::program_signals (gdb::span arg0) { target_debug_printf_nofunc ("-> %s->program_signals (...)", this->beneath ()->shortname ()); this->beneath ()->program_signals (arg0); @@ -1825,28 +1825,28 @@ debug_target::thread_handle_to_thread_info (const gdb_byte *arg0, int arg1, infe return result; } -gdb::array_view +gdb::span target_ops::thread_info_to_thread_handle (struct thread_info *arg0) { return this->beneath ()->thread_info_to_thread_handle (arg0); } -gdb::array_view +gdb::span dummy_target::thread_info_to_thread_handle (struct thread_info *arg0) { - return gdb::array_view (); + return gdb::span (); } -gdb::array_view +gdb::span debug_target::thread_info_to_thread_handle (struct thread_info *arg0) { target_debug_printf_nofunc ("-> %s->thread_info_to_thread_handle (...)", this->beneath ()->shortname ()); - gdb::array_view result + gdb::span result = this->beneath ()->thread_info_to_thread_handle (arg0); target_debug_printf_nofunc ("<- %s->thread_info_to_thread_handle (%s) = %s", this->beneath ()->shortname (), target_debug_print_thread_info_p (arg0).c_str (), - target_debug_print_gdb_array_view_const_gdb_byte (result).c_str ()); + target_debug_print_gdb_span_const_gdb_byte (result).c_str ()); return result; } diff --git a/gdb/target.c b/gdb/target.c index 56a5f78c4c0..64e4e7f95e4 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -329,7 +329,7 @@ target_remove_exec_catchpoint (int pid) int target_set_syscall_catchpoint (int pid, bool needed, int any_count, - gdb::array_view syscall_counts) + gdb::span syscall_counts) { target_ops *target = current_inferior ()->top_target (); @@ -2646,7 +2646,7 @@ target_thread_handle_to_thread_info (const gdb_byte *thread_handle, /* See target.h. */ -gdb::array_view +gdb::span target_thread_info_to_thread_handle (struct thread_info *tip) { target_ops *target = current_inferior ()->top_target (); @@ -2696,13 +2696,13 @@ target_has_pending_events () } void -target_pass_signals (gdb::array_view pass_signals) +target_pass_signals (gdb::span pass_signals) { current_inferior ()->top_target ()->pass_signals (pass_signals); } void -target_program_signals (gdb::array_view program_signals) +target_program_signals (gdb::span program_signals) { current_inferior ()->top_target ()->program_signals (program_signals); } diff --git a/gdb/target.h b/gdb/target.h index 38bdc68f6a3..1037aefc3bb 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -666,7 +666,7 @@ struct target_ops virtual void follow_exec (inferior *, ptid_t, const char *) TARGET_DEFAULT_IGNORE (); virtual int set_syscall_catchpoint (int, bool, int, - gdb::array_view) + gdb::span) TARGET_DEFAULT_RETURN (1); virtual void mourn_inferior () TARGET_DEFAULT_FUNC (default_mourn_inferior); @@ -678,12 +678,12 @@ struct target_ops /* Documentation of this routine is provided with the corresponding target_* macro. */ - virtual void pass_signals (gdb::array_view TARGET_DEBUG_PRINTER (target_debug_print_signals)) + virtual void pass_signals (gdb::span TARGET_DEBUG_PRINTER (target_debug_print_signals)) TARGET_DEFAULT_IGNORE (); /* Documentation of this routine is provided with the corresponding target_* function. */ - virtual void program_signals (gdb::array_view TARGET_DEBUG_PRINTER (target_debug_print_signals)) + virtual void program_signals (gdb::span TARGET_DEBUG_PRINTER (target_debug_print_signals)) TARGET_DEFAULT_IGNORE (); virtual bool thread_alive (ptid_t ptid) @@ -701,8 +701,8 @@ struct target_ops inferior *inf) TARGET_DEFAULT_RETURN (NULL); /* See target_thread_info_to_thread_handle. */ - virtual gdb::array_view thread_info_to_thread_handle (struct thread_info *) - TARGET_DEFAULT_RETURN (gdb::array_view ()); + virtual gdb::span thread_info_to_thread_handle (struct thread_info *) + TARGET_DEFAULT_RETURN (gdb::span ()); virtual void stop (ptid_t) TARGET_DEFAULT_IGNORE (); virtual void interrupt () @@ -1832,7 +1832,7 @@ extern int target_remove_exec_catchpoint (int pid); extern int target_set_syscall_catchpoint (int pid, bool needed, int any_count, - gdb::array_view syscall_counts); + gdb::span syscall_counts); /* The debugger has completed a blocking wait() call. There is now some process event that must be processed. This function should @@ -1858,7 +1858,7 @@ extern int target_can_run (); if mentioned in a previous target_pass_signals call. */ extern void target_pass_signals - (gdb::array_view pass_signals); + (gdb::span pass_signals); /* Set list of signals the target may pass to the inferior. This directly maps to the "handle SIGNAL pass/nopass" setting. @@ -1875,7 +1875,7 @@ extern void target_pass_signals pending signals not reported to GDB). */ extern void target_program_signals - (gdb::array_view program_signals); + (gdb::span program_signals); /* Check to see if a thread is still alive. */ @@ -2015,7 +2015,7 @@ extern struct thread_info *target_thread_handle_to_thread_info /* Given a thread, return the thread handle, a target-specific sequence of bytes which serves as a thread identifier within the program being debugged. */ -extern gdb::array_view target_thread_info_to_thread_handle +extern gdb::span target_thread_info_to_thread_handle (struct thread_info *); /* Attempts to find the pathname of the executable file diff --git a/gdb/thread.c b/gdb/thread.c index e2b89afc118..e9ef77228b1 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -592,7 +592,7 @@ find_thread_id (struct inferior *inf, int thr_num) /* See gdbthread.h. */ struct thread_info * -find_thread_by_handle (gdb::array_view handle, +find_thread_by_handle (gdb::span handle, struct inferior *inf) { return target_thread_handle_to_thread_info (handle.data (), diff --git a/gdb/trad-frame.c b/gdb/trad-frame.c index 48d73f0ef97..749832e7df3 100644 --- a/gdb/trad-frame.c +++ b/gdb/trad-frame.c @@ -171,7 +171,7 @@ trad_frame_set_reg_regmap (struct trad_frame_cache *this_trad_cache, void trad_frame_set_reg_value_bytes (struct trad_frame_cache *this_trad_cache, int regnum, - gdb::array_view bytes) + gdb::span bytes) { /* External interface for users of trad_frame_cache (who cannot access the prev_regs object directly). */ diff --git a/gdb/trad-frame.h b/gdb/trad-frame.h index 5026a14f735..7c30c17f5ae 100644 --- a/gdb/trad-frame.h +++ b/gdb/trad-frame.h @@ -56,7 +56,7 @@ void trad_frame_set_reg_value (struct trad_frame_cache *this_cache, contained in BYTES with size SIZE. */ void trad_frame_set_reg_value_bytes (struct trad_frame_cache *this_trad_cache, int regnum, - gdb::array_view bytes); + gdb::span bytes); struct value *trad_frame_get_register (struct trad_frame_cache *this_trad_cache, const frame_info_ptr &this_frame, @@ -114,7 +114,7 @@ struct trad_frame_saved_reg /* Encode that the saved register's value is stored as a sequence of bytes. This is useful when the value is larger than what primitive types can hold. */ - void set_value_bytes (gdb::array_view bytes) + void set_value_bytes (gdb::span bytes) { /* Allocate the space and copy the data bytes. */ auto *data = frame_obstack_calloc (bytes.size ()); @@ -145,7 +145,7 @@ struct trad_frame_saved_reg return m_reg.addr; } - gdb::array_view value_bytes () const + gdb::span value_bytes () const { gdb_assert (m_kind == trad_frame_saved_reg_kind::VALUE_BYTES); return { m_reg.value_bytes, m_reg.bytes_len }; diff --git a/gdb/unittests/intrusive_list-selftests.c b/gdb/unittests/intrusive_list-selftests.c index aa68b7d21ec..89695374857 100644 --- a/gdb/unittests/intrusive_list-selftests.c +++ b/gdb/unittests/intrusive_list-selftests.c @@ -81,7 +81,7 @@ struct item_with_member template static void verify_items (const ListType &list, - gdb::array_view expected) + gdb::span expected) { using item_type = typename ListType::value_type; diff --git a/gdb/unittests/ranges-selftests.c b/gdb/unittests/ranges-selftests.c index d21f321dc36..5432a242cbb 100644 --- a/gdb/unittests/ranges-selftests.c +++ b/gdb/unittests/ranges-selftests.c @@ -44,7 +44,7 @@ run_tests () /* With non-owning container. */ { std::array array = {1, 2, 3, 2}; - gdb::array_view view = array; + gdb::span view = array; gdb::ranges::replace (view, 2, 1); SELF_CHECK (array[0] == 1); SELF_CHECK (array[1] == 1); diff --git a/gdb/unittests/span-selftests.c b/gdb/unittests/span-selftests.c index 760fecf9ddc..cb1e25976f3 100644 --- a/gdb/unittests/span-selftests.c +++ b/gdb/unittests/span-selftests.c @@ -1,4 +1,4 @@ -/* Self tests for array_view for GDB, the GNU debugger. +/* Self tests for span for GDB, the GNU debugger. Copyright (C) 2017-2026 Free Software Foundation, Inc. @@ -23,11 +23,11 @@ #include namespace selftests { -namespace array_view_tests { +namespace span_tests { /* Triviality checks. */ #define CHECK_TRAIT(TRAIT) \ - static_assert (std::TRAIT>::value, "") + static_assert (std::TRAIT>::value, "") CHECK_TRAIT (is_trivially_copyable); CHECK_TRAIT (is_trivially_move_assignable); @@ -52,26 +52,26 @@ static constexpr bool check_convertible () { using T = gdb_byte; - using gdb::array_view; + using gdb::span; return (true - /* immutable array_view */ - && is_convertible> () - && is_convertible> () - && is_convertible> () - && is_convertible> () - - /* mutable array_view */ - && is_convertible> () - && !is_convertible> () - && is_convertible> () - && !is_convertible> () + /* immutable span */ + && is_convertible> () + && is_convertible> () + && is_convertible> () + && is_convertible> () + + /* mutable span */ + && is_convertible> () + && !is_convertible> () + && is_convertible> () + && !is_convertible> () /* While float is implicitly convertible to gdb_byte, we - don't want implicit float->array_view + don't want implicit float->span conversion. */ - && !is_convertible> () - && !is_convertible> ()); + && !is_convertible> () + && !is_convertible> ()); } static_assert (check_convertible (), ""); @@ -87,29 +87,29 @@ struct C : A { int l; }; static constexpr bool check () { - using gdb::array_view; + using gdb::span; return (true /* array->view */ - && is_convertible > () - && !is_convertible > () - && !is_convertible > () + && is_convertible > () + && !is_convertible > () + && !is_convertible > () - && !is_convertible > () - && is_convertible > () - && !is_convertible > () + && !is_convertible > () + && is_convertible > () + && !is_convertible > () /* elem->view */ - && is_convertible > () - && !is_convertible > () - && !is_convertible > () + && is_convertible > () + && !is_convertible > () + && !is_convertible > () - && !is_convertible > () - && is_convertible > () - && !is_convertible > ()); + && !is_convertible > () + && is_convertible > () + && !is_convertible > ()); } /* Check that there's no container->view conversion for containers of derived @@ -119,15 +119,15 @@ template class Container> static constexpr bool check_ctor_from_container () { - using gdb::array_view; + using gdb::span; - return ( is_convertible , array_view> () - && !is_convertible , array_view> () - && !is_convertible , array_view> () + return ( is_convertible , span> () + && !is_convertible , span> () + && !is_convertible , span> () - && !is_convertible , array_view> () - && is_convertible , array_view> () - && !is_convertible , array_view> ()); + && !is_convertible , span> () + && is_convertible , span> () + && !is_convertible , span> ()); } } /* namespace no_slicing */ @@ -139,40 +139,40 @@ template using StdArray1 = std::array; static_assert (no_slicing::check (), ""); static_assert (no_slicing::check_ctor_from_container (), ""); static_assert (no_slicing::check_ctor_from_container (), ""); -static_assert (no_slicing::check_ctor_from_container (), ""); +static_assert (no_slicing::check_ctor_from_container (), ""); -/* Check that array_view implicitly converts from std::vector. */ +/* Check that span implicitly converts from std::vector. */ static constexpr bool check_convertible_from_std_vector () { - using gdb::array_view; + using gdb::span; using T = gdb_byte; /* Note there's no such thing as std::vector. */ return (true - && is_convertible , array_view> () - && is_convertible , array_view> ()); + && is_convertible , span> () + && is_convertible , span> ()); } static_assert (check_convertible_from_std_vector (), ""); -/* Check that array_view implicitly converts from std::array. */ +/* Check that span implicitly converts from std::array. */ static constexpr bool check_convertible_from_std_array () { - using gdb::array_view; + using gdb::span; using T = gdb_byte; /* Note: a non-const T view can't refer to a const T array. */ return (true - && is_convertible , array_view> () - && is_convertible , array_view> () - && !is_convertible , array_view> () - && is_convertible , array_view> ()); + && is_convertible , span> () + && is_convertible , span> () + && !is_convertible , span> () + && is_convertible , span> ()); } static_assert (check_convertible_from_std_array (), ""); @@ -250,7 +250,7 @@ check_ptr_size_ctor () { T data[] = {0x11, 0x22, 0x33, 0x44}; - gdb::array_view view (data + 1, 2); + gdb::span view (data + 1, 2); SELF_CHECK (!view.empty ()); SELF_CHECK (view.size () == 2); @@ -258,7 +258,7 @@ check_ptr_size_ctor () SELF_CHECK (view[0] == data[1]); SELF_CHECK (view[1] == data[2]); - gdb::array_view cview (data + 1, 2); + gdb::span cview (data + 1, 2); SELF_CHECK (!cview.empty ()); SELF_CHECK (cview.size () == 2); SELF_CHECK (cview.data () == &data[1]); @@ -278,7 +278,7 @@ require_not_constructible () return true; }; -/* Check the array_view(PTR, SIZE) ctor, when T is a pointer. */ +/* Check the span(PTR, SIZE) ctor, when T is a pointer. */ static void check_ptr_size_ctor2 () @@ -289,12 +289,12 @@ check_ptr_size_ctor2 () A *array[] = { &an_a }; const A * const carray[] = { &an_a }; - gdb::array_view v1 = {array, ARRAY_SIZE (array)}; - gdb::array_view v2 = {array, (char) ARRAY_SIZE (array)}; - gdb::array_view v3 = {array, ARRAY_SIZE (array)}; - gdb::array_view cv1 = {carray, ARRAY_SIZE (carray)}; + gdb::span v1 = {array, ARRAY_SIZE (array)}; + gdb::span v2 = {array, (char) ARRAY_SIZE (array)}; + gdb::span v3 = {array, ARRAY_SIZE (array)}; + gdb::span cv1 = {carray, ARRAY_SIZE (carray)}; - require_not_constructible, decltype (carray), size_t> (); + require_not_constructible, decltype (carray), size_t> (); SELF_CHECK (v1[0] == array[0]); SELF_CHECK (v2[0] == array[0]); @@ -320,7 +320,7 @@ check_ptr_ptr_ctor () { T data[] = {0x11, 0x22, 0x33, 0x44}; - gdb::array_view view (data + 1, data + 3); + gdb::span view (data + 1, data + 3); SELF_CHECK (!view.empty ()); SELF_CHECK (view.size () == 2); @@ -331,7 +331,7 @@ check_ptr_ptr_ctor () gdb_byte array[] = {0x11, 0x22, 0x33, 0x44}; const gdb_byte *p1 = array; gdb_byte *p2 = array + ARRAY_SIZE (array); - gdb::array_view view2 (p1, p2); + gdb::span view2 (p1, p2); } /* Check construction with a pair of pointers of mixed constness. */ @@ -342,8 +342,8 @@ check_ptr_ptr_mixed_cv () gdb_byte array[] = {0x11, 0x22, 0x33, 0x44}; const gdb_byte *cp = array; gdb_byte *p = array; - gdb::array_view view1 (cp, p); - gdb::array_view view2 (p, cp); + gdb::span view1 (cp, p); + gdb::span view2 (p, cp); SELF_CHECK (view1.empty ()); SELF_CHECK (view2.empty ()); } @@ -356,7 +356,7 @@ static void check_range_for () { T data[] = {1, 2, 3, 4}; - gdb::array_view view (data); + gdb::span view (data); typename std::decay::type sum = 0; for (auto &elem : view) @@ -369,10 +369,10 @@ static void check_iterator () { T data[] = {1, 2, 3, 4}; - gdb::array_view view (data); + gdb::span view (data); typename std::decay::type sum = 0; - for (typename gdb::array_view::iterator it = view.begin (); + for (typename gdb::span::iterator it = view.begin (); it != view.end (); it++) { *it *= 2; @@ -387,10 +387,10 @@ static void check_const_iterator () { T data[] = {1, 2, 3, 4}; - gdb::array_view view (data); + gdb::span view (data); typename std::decay::type sum = 0; - for (typename gdb::array_view::const_iterator it = view.cbegin (); + for (typename gdb::span::const_iterator it = view.cbegin (); it != view.cend (); it++) sum += *it; @@ -404,8 +404,8 @@ run_tests () { /* Empty views. */ { - constexpr gdb::array_view view1; - constexpr gdb::array_view view2; + constexpr gdb::span view1; + constexpr gdb::span view2; static_assert (view1.empty (), ""); static_assert (view1.data () == nullptr, ""); @@ -420,23 +420,23 @@ run_tests () /* Various tests of views over std::vector. */ { - gdb::array_view view = vec; + gdb::span view = vec; SELF_CHECK (check_container_view (view, vec)); - gdb::array_view cview = vec; + gdb::span cview = vec; SELF_CHECK (check_container_view (cview, vec)); } /* Likewise, over std::array. */ { - gdb::array_view view = array; + gdb::span view = array; SELF_CHECK (check_container_view (view, array)); - gdb::array_view cview = array; + gdb::span cview = array; SELF_CHECK (check_container_view (cview, array)); } /* op=(std::vector/std::array/elem) */ { - gdb::array_view view; + gdb::span view; view = vec; SELF_CHECK (check_container_view (view, vec)); @@ -458,12 +458,12 @@ run_tests () /* Test copy/move ctor and mutable->immutable conversion. */ { gdb_byte data[] = {0x11, 0x22, 0x33, 0x44}; - gdb::array_view view1 = data; - gdb::array_view view2 = view1; - gdb::array_view view3 = std::move (view1); - gdb::array_view cview1 = data; - gdb::array_view cview2 = cview1; - gdb::array_view cview3 = std::move (cview1); + gdb::span view1 = data; + gdb::span view2 = view1; + gdb::span view3 = std::move (view1); + gdb::span cview1 = data; + gdb::span cview2 = cview1; + gdb::span cview3 = std::move (cview1); SELF_CHECK (view1[0] == data[0]); SELF_CHECK (view2[0] == data[0]); SELF_CHECK (view3[0] == data[0]); @@ -475,12 +475,12 @@ run_tests () /* Same, but op=(view). */ { gdb_byte data[] = {0x55, 0x66, 0x77, 0x88}; - gdb::array_view view1; - gdb::array_view view2; - gdb::array_view view3; - gdb::array_view cview1; - gdb::array_view cview2; - gdb::array_view cview3; + gdb::span view1; + gdb::span view2; + gdb::span view3; + gdb::span cview1; + gdb::span cview2; + gdb::span cview3; view1 = data; view2 = view1; @@ -499,8 +499,8 @@ run_tests () /* op[] */ { std::vector vec2 = {0x11, 0x22}; - gdb::array_view view = vec2; - gdb::array_view cview = vec2; + gdb::span view = vec2; + gdb::span cview = vec2; /* Check that op[] on a non-const view of non-const T returns a mutable reference. */ @@ -533,11 +533,11 @@ run_tests () using Vec = std::vector; Vec vecs[3]; - gdb::array_view view_array = vecs; + gdb::span view_array = vecs; SELF_CHECK (view_array.size () == 3); Vec elem; - gdb::array_view view_elem = elem; + gdb::span view_elem = elem; SELF_CHECK (view_elem.size () == 1); } @@ -570,7 +570,7 @@ run_tests () /* Test slicing. */ { gdb_byte data[] = {0x55, 0x66, 0x77, 0x88, 0x99}; - gdb::array_view view = data; + gdb::span view = data; { auto slc = view.slice (1, 3); @@ -600,14 +600,14 @@ run_copy_test () std::vector dest_v (4, -1); SELF_CHECK (dest_v != src_v); - copy (gdb::array_view (src_v), gdb::array_view (dest_v)); + copy (gdb::span (src_v), gdb::span (dest_v)); SELF_CHECK (dest_v == src_v); } /* Test overlapping copy, where the source is before the destination. */ { std::vector vec = {1, 2, 3, 4, 5, 6, 7, 8}; - gdb::array_view v = vec; + gdb::span v = vec; copy (v.slice (1, 4), v.slice (2, 4)); @@ -619,7 +619,7 @@ run_copy_test () /* Test overlapping copy, where the source is after the destination. */ { std::vector vec = {1, 2, 3, 4, 5, 6, 7, 8}; - gdb::array_view v = vec; + gdb::span v = vec; copy (v.slice (2, 4), v.slice (1, 4)); @@ -631,7 +631,7 @@ run_copy_test () /* Test overlapping copy, where the source is the same as the destination. */ { std::vector vec = {1, 2, 3, 4, 5, 6, 7, 8}; - gdb::array_view v = vec; + gdb::span v = vec; copy (v.slice (2, 4), v.slice (2, 4)); @@ -642,12 +642,12 @@ run_copy_test () } /* Class with a non-trivial copy assignment operator, used to test the - array_view copy function. */ + span copy function. */ struct foo { /* Can be implicitly constructed from an int, such that we can use the same - templated test function to test against array_view and - array_view. */ + templated test function to test against span and + span. */ foo (int n) : n (n) {} @@ -675,7 +675,7 @@ struct foo int foo::n_assign_op_called = 0; -/* Test the array_view copy free function. */ +/* Test the span copy free function. */ static void run_copy_tests () @@ -692,13 +692,13 @@ run_copy_tests () SELF_CHECK (foo::n_assign_op_called == 12); } -} /* namespace array_view_tests */ +} /* namespace span_tests */ } /* namespace selftests */ INIT_GDB_FILE (span_selftests) { - selftests::register_test ("array_view", - selftests::array_view_tests::run_tests); - selftests::register_test ("array_view-copy", - selftests::array_view_tests::run_copy_tests); + selftests::register_test ("span", + selftests::span_tests::run_tests); + selftests::register_test ("span-copy", + selftests::span_tests::run_copy_tests); } diff --git a/gdb/utils.c b/gdb/utils.c index aa3f4d7ded4..d39e4a97f48 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -3234,7 +3234,7 @@ gdb_argv_as_array_view_test () { gdb_argv argv; - gdb::array_view view = argv.as_array_view (); + gdb::span view = argv.as_array_view (); SELF_CHECK (view.data () == nullptr); SELF_CHECK (view.size () == 0); @@ -3242,7 +3242,7 @@ gdb_argv_as_array_view_test () { gdb_argv argv ("une bonne 50"); - gdb::array_view view = argv.as_array_view (); + gdb::span view = argv.as_array_view (); SELF_CHECK (view.size () == 3); SELF_CHECK (streq (view[0], "une")); diff --git a/gdb/valarith.c b/gdb/valarith.c index 0f66207fa17..946ba845316 100644 --- a/gdb/valarith.c +++ b/gdb/valarith.c @@ -336,7 +336,7 @@ unop_user_defined_p (enum exp_opcode op, struct value *arg1) situations or combinations thereof. */ static struct value * -value_user_defined_cpp_op (gdb::array_view args, char *oper, +value_user_defined_cpp_op (gdb::span args, char *oper, int *static_memfuncp, enum noside noside) { @@ -367,7 +367,7 @@ value_user_defined_cpp_op (gdb::array_view args, char *oper, function, otherwise return NULL. */ static struct value * -value_user_defined_op (struct value **argp, gdb::array_view args, +value_user_defined_op (struct value **argp, gdb::span args, char *name, int *static_memfuncp, enum noside noside) { struct value *result = NULL; @@ -411,7 +411,7 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op, error (_("Can't do that binary op on that type")); /* FIXME be explicit */ value *argvec_storage[3]; - gdb::array_view argvec = argvec_storage; + gdb::span argvec = argvec_storage; argvec[1] = value_addr (arg1); argvec[2] = arg2; @@ -587,7 +587,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside) error (_("Can't do that unary op on that type")); /* FIXME be explicit */ value *argvec_storage[3]; - gdb::array_view argvec = argvec_storage; + gdb::span argvec = argvec_storage; argvec[1] = value_addr (arg1); argvec[2] = 0; @@ -732,9 +732,9 @@ value_concat (struct value *arg1, struct value *arg2) lowbound + n_elts - 1); struct value *result = value::allocate (atype); - gdb::array_view contents = result->contents_raw (); - gdb::array_view lhs_contents = arg1->contents (); - gdb::array_view rhs_contents = arg2->contents (); + gdb::span contents = result->contents_raw (); + gdb::span lhs_contents = arg1->contents (); + gdb::span rhs_contents = arg2->contents (); gdb::copy (lhs_contents, contents.slice (0, lhs_contents.size ())); gdb::copy (rhs_contents, contents.slice (lhs_contents.size ())); @@ -1415,7 +1415,7 @@ value_vector_widen (struct value *scalar_value, struct type *vector_type) error (_("conversion of scalar to vector involves truncation")); value *val = value::allocate (vector_type); - gdb::array_view val_contents = val->contents_writeable (); + gdb::span val_contents = val->contents_writeable (); int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) @@ -1462,7 +1462,7 @@ vector_binop (struct value *val1, struct value *val2, enum exp_opcode op) error (_("Cannot perform operation on vectors with different types")); value *val = value::allocate (type1); - gdb::array_view val_contents = val->contents_writeable (); + gdb::span val_contents = val->contents_writeable (); scoped_value_mark mark; for (i = 0; i < high_bound1 - low_bound1 + 1; i++) { @@ -1757,7 +1757,7 @@ value_neg (struct value *arg1) if (!get_array_bounds (type, &low_bound, &high_bound)) error (_("Could not determine the vector bounds")); - gdb::array_view val_contents = val->contents_writeable (); + gdb::span val_contents = val->contents_writeable (); int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) @@ -1808,7 +1808,7 @@ value_complement (struct value *arg1) error (_("Could not determine the vector bounds")); val = value::allocate (type); - gdb::array_view val_contents = val->contents_writeable (); + gdb::span val_contents = val->contents_writeable (); int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) diff --git a/gdb/valops.c b/gdb/valops.c index 3f1eda84f43..e0a29580057 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -48,22 +48,22 @@ static struct value *search_struct_field (const char *, struct value *, struct type *, int); static struct value *search_struct_method (const char *, struct value **, - std::optional>, + std::optional>, LONGEST, int *, struct type *); -static int find_oload_champ_namespace (gdb::array_view args, +static int find_oload_champ_namespace (gdb::span args, const char *, const char *, std::vector *oload_syms, badness_vector *, const int no_adl); -static int find_oload_champ_namespace_loop (gdb::array_view args, +static int find_oload_champ_namespace_loop (gdb::span args, const char *, const char *, int, std::vector *oload_syms, badness_vector *, int *, const int no_adl); -static int find_oload_champ (gdb::array_view args, +static int find_oload_champ (gdb::span args, size_t num_fns, fn_field *methods, xmethod_worker_up *xmethods, @@ -977,7 +977,7 @@ value_one (struct type *type) error (_("Could not determine the vector bounds")); val = value::allocate (type); - gdb::array_view val_contents = val->contents_writeable (); + gdb::span val_contents = val->contents_writeable (); int elt_len = eltype->length (); for (i = 0; i < high_bound - low_bound + 1; i++) @@ -1698,7 +1698,7 @@ value_ind (struct value *arg1) don't currently enforce any restriction on their types). */ struct value * -value_array (int lowbound, gdb::array_view elemvec) +value_array (int lowbound, gdb::span elemvec) { int idx; ULONGEST typelength; @@ -1779,7 +1779,7 @@ value_string (const gdb_byte *ptr, ssize_t count, struct type *char_type) /* See if we can pass arguments in T2 to a function which takes arguments - of types T1. T1 is an array_view of arguments, and T2 is an array_view + of types T1. T1 is a span of arguments, and T2 is a span of the values we're trying to pass. If some arguments need coercion of some sort, then the coerced values are written into T2. Return value is 0 if the arguments could be matched, or the position at which they @@ -1797,7 +1797,7 @@ value_string (const gdb_byte *ptr, ssize_t count, struct type *char_type) static int typecmp (bool staticp, bool varargs, - gdb::array_view t1, gdb::array_view t2) + gdb::span t1, gdb::span t2) { int i; @@ -2205,7 +2205,7 @@ search_struct_field (const char *name, struct value *arg1, static struct value * search_struct_method (const char *name, struct value **arg1p, - std::optional> args, + std::optional> args, LONGEST offset, int *static_memfuncp, struct type *type) { @@ -2339,7 +2339,7 @@ search_struct_method (const char *name, struct value **arg1p, struct value * value_struct_elt (struct value **argp, - std::optional> args, + std::optional> args, const char *name, int *static_memfuncp, const char *err) { struct type *t; @@ -2494,7 +2494,7 @@ value_struct_elt_bitpos (struct value *val, int bitpos, struct type *ftype) static void find_method_list (struct value **argp, const char *method, LONGEST offset, struct type *type, - gdb::array_view *methods, + gdb::span *methods, std::vector *xmethods, struct type **basetype, LONGEST *boffset) { @@ -2583,7 +2583,7 @@ find_method_list (struct value **argp, const char *method, static void value_find_oload_method_list (struct value **argp, const char *method, LONGEST offset, - gdb::array_view *methods, + gdb::span *methods, std::vector *xmethods, struct type **basetype, LONGEST *boffset) { @@ -2623,7 +2623,7 @@ value_find_oload_method_list (struct value **argp, const char *method, If no incomplete types are present, an empty string is returned. */ static std::string -incomplete_type_hint (gdb::array_view args) +incomplete_type_hint (gdb::span args) { int incomplete_types = 0; std::string incomplete_arg_names; @@ -2706,7 +2706,7 @@ incomplete_type_hint (gdb::array_view args) resolution is permitted. */ int -find_overload_match (gdb::array_view args, +find_overload_match (gdb::span args, const char *name, enum oload_search_type method, struct value **objp, struct symbol *fsym, struct value **valp, struct symbol **symp, @@ -2729,7 +2729,7 @@ find_overload_match (gdb::array_view args, struct value *temp = obj; /* For methods, the list of overloaded methods. */ - gdb::array_view methods; + gdb::span methods; /* For non-methods, the list of overloaded function symbols. */ std::vector functions; /* For xmethods, the vector of xmethod workers. */ @@ -3058,7 +3058,7 @@ find_overload_match (gdb::array_view args, argument dependent lookup is not performed. */ static int -find_oload_champ_namespace (gdb::array_view args, +find_oload_champ_namespace (gdb::span args, const char *func_name, const char *qualified_name, std::vector *oload_syms, @@ -3084,7 +3084,7 @@ find_oload_champ_namespace (gdb::array_view args, find_oload_champ_namespace. */ static int -find_oload_champ_namespace_loop (gdb::array_view args, +find_oload_champ_namespace_loop (gdb::span args, const char *func_name, const char *qualified_name, int namespace_len, @@ -3200,7 +3200,7 @@ find_oload_champ_namespace_loop (gdb::array_view args, quality of the match in OLOAD_CHAMP_BV. */ static int -find_oload_champ (gdb::array_view args, +find_oload_champ (gdb::span args, size_t num_fns, fn_field *methods, xmethod_worker_up *xmethods, diff --git a/gdb/value.c b/gdb/value.c index 22e35ec20d8..f96fad207b4 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1056,7 +1056,7 @@ value::allocate_optimized_out (struct type *type) /* Accessor methods. */ -gdb::array_view +gdb::span value::contents_raw () { int unit_size = gdbarch_addressable_memory_unit_size (arch ()); @@ -1068,7 +1068,7 @@ value::contents_raw () (m_contents.get () + m_embedded_offset * unit_size, length); } -gdb::array_view +gdb::span value::contents_all_raw () { allocate_contents (true); @@ -1151,7 +1151,7 @@ value::require_available () const error_value_not_available (); } -gdb::array_view +gdb::span value::contents_for_printing () { if (m_lazy) @@ -1161,7 +1161,7 @@ value::contents_for_printing () return gdb::make_array_view (m_contents.get (), length); } -gdb::array_view +gdb::span value::contents_for_printing () const { gdb_assert (!m_lazy); @@ -1170,10 +1170,10 @@ value::contents_for_printing () const return gdb::make_array_view (m_contents.get (), length); } -gdb::array_view +gdb::span value::contents_all () { - gdb::array_view result = contents_for_printing (); + gdb::span result = contents_for_printing (); require_not_optimized_out (); require_available (); return result; @@ -1247,10 +1247,10 @@ value::contents_copy_raw (struct value *dst, LONGEST dst_offset, error (_("access outside bounds of object")); /* Copy the data. */ - gdb::array_view dst_contents + gdb::span dst_contents = dst->contents_all_raw ().slice (dst_offset * unit_size, copy_length * unit_size); - gdb::array_view src_contents + gdb::span src_contents = contents_all_raw ().slice (src_offset * unit_size, copy_length * unit_size); gdb::copy (src_contents, dst_contents); @@ -1293,8 +1293,8 @@ value::contents_copy_raw_bitwise (struct value *dst, LONGEST dst_bit_offset, bit_length)); /* Copy the data. */ - gdb::array_view dst_contents = dst->contents_all_raw (); - gdb::array_view src_contents = contents_all_raw (); + gdb::span dst_contents = dst->contents_all_raw (); + gdb::span src_contents = contents_all_raw (); copy_bitwise (dst_contents.data (), dst_bit_offset, src_contents.data (), src_bit_offset, copy_bit_length, @@ -1316,16 +1316,16 @@ value::contents_copy (struct value *dst, LONGEST dst_offset, contents_copy_raw (dst, dst_offset, src_offset, length); } -gdb::array_view +gdb::span value::contents () { - gdb::array_view result = contents_writeable (); + gdb::span result = contents_writeable (); require_not_optimized_out (); require_available (); return result; } -gdb::array_view +gdb::span value::contents_writeable () { if (m_lazy) @@ -1576,7 +1576,7 @@ value::copy () const = gdb::make_array_view (m_contents.get (), length); val->allocate_contents (false); - gdb::array_view val_contents + gdb::span val_contents = val->contents_all_raw ().slice (0, length); gdb::copy (arg_view, val_contents); @@ -2622,7 +2622,7 @@ value::from_xmethod (xmethod_worker_up &&worker) /* See value.h. */ struct type * -value::result_type_of_xmethod (gdb::array_view argv) +value::result_type_of_xmethod (gdb::span argv) { gdb_assert (type ()->code () == TYPE_CODE_XMETHOD && m_lval == lval_xcallable && !argv.empty ()); @@ -2633,7 +2633,7 @@ value::result_type_of_xmethod (gdb::array_view argv) /* See value.h. */ struct value * -value::call_xmethod (gdb::array_view argv) +value::call_xmethod (gdb::span argv) { gdb_assert (type ()->code () == TYPE_CODE_XMETHOD && m_lval == lval_xcallable && !argv.empty ()); @@ -2679,7 +2679,7 @@ value_as_mpz (struct value *val) gdb_mpz result; - gdb::array_view valbytes = val->contents (); + gdb::span valbytes = val->contents (); enum bfd_endian byte_order = type_byte_order (type); /* Handle integers that are either not a multiple of the word size, @@ -3652,7 +3652,7 @@ value_from_contents_and_address (struct type *type, CORE_ADDR address, const frame_info_ptr &frame) { - gdb::array_view view; + gdb::span view; if (valaddr != nullptr) view = gdb::make_array_view (valaddr, type->length ()); struct type *resolved_type = resolve_dynamic_type (type, view, address, @@ -3840,7 +3840,7 @@ readjust_indirect_value_type (struct value *value, struct type *enc_type, gdb_assert (original_type->is_pointer_or_reference ()); struct type *original_target_type = original_type->target_type (); - gdb::array_view view; + gdb::span view; struct type *resolved_original_target_type = resolve_dynamic_type (original_target_type, view, original_value_address); @@ -4085,7 +4085,7 @@ value::fetch_lazy_register () if (new_val->entirely_available ()) { int i; - gdb::array_view buf = new_val->contents (); + gdb::span buf = new_val->contents (); gdb_printf (&debug_file, " bytes="); gdb_printf (&debug_file, "["); @@ -4154,7 +4154,7 @@ pseudo_from_raw_part (const frame_info_ptr &next_frame, int pseudo_reg_num, void pseudo_to_raw_part (const frame_info_ptr &next_frame, - gdb::array_view pseudo_buf, + gdb::span pseudo_buf, int raw_reg_num, int raw_offset) { int raw_reg_size @@ -4196,7 +4196,7 @@ pseudo_from_concat_raw (const frame_info_ptr &next_frame, int pseudo_reg_num, void pseudo_to_concat_raw (const frame_info_ptr &next_frame, - gdb::array_view pseudo_buf, + gdb::span pseudo_buf, int raw_reg_1_num, int raw_reg_2_num) { int src_offset = 0; @@ -4250,7 +4250,7 @@ pseudo_from_concat_raw (const frame_info_ptr &next_frame, int pseudo_reg_num, void pseudo_to_concat_raw (const frame_info_ptr &next_frame, - gdb::array_view pseudo_buf, + gdb::span pseudo_buf, int raw_reg_1_num, int raw_reg_2_num, int raw_reg_3_num) { int src_offset = 0; @@ -4384,8 +4384,8 @@ test_ranges_contain () /* Check that RANGES contains the same ranges as EXPECTED. */ static bool -check_ranges_vector (gdb::array_view ranges, - gdb::array_view expected) +check_ranges_vector (gdb::span ranges, + gdb::span expected) { return ranges == expected; } diff --git a/gdb/value.h b/gdb/value.h index 598d252abac..bc9146a2c21 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -414,31 +414,31 @@ struct value Note: The contents pointer is adjusted by the offset required to get to the real subobject, if the value happens to represent something embedded in a larger run-time object. */ - gdb::array_view contents_raw (); + gdb::span contents_raw (); /* Actual contents of the value. For use of this value; setting it uses the stuff above. Not valid if lazy is nonzero. Target byte-order. We force it to be aligned properly for any possible value. Note that a value therefore extends beyond what is declared here. */ - gdb::array_view contents (); + gdb::span contents (); /* The ALL variants of the above two methods do not adjust the returned pointer by the embedded_offset value. */ - gdb::array_view contents_all (); - gdb::array_view contents_all_raw (); + gdb::span contents_all (); + gdb::span contents_all_raw (); - gdb::array_view contents_writeable (); + gdb::span contents_writeable (); /* Like contents_all, but does not require that the returned bits be valid. This should only be used in situations where you plan to check the validity manually. */ - gdb::array_view contents_for_printing (); + gdb::span contents_for_printing (); /* Like contents_for_printing, but accepts a constant value pointer. Unlike contents_for_printing however, the pointed value must _not_ be lazy. */ - gdb::array_view contents_for_printing () const; + gdb::span contents_for_printing () const; /* Load the actual content of a lazy value. Fetch the data from the user's process and clear the lazy flag to indicate that the data in @@ -592,11 +592,11 @@ struct value static struct value *from_xmethod (xmethod_worker_up &&worker); /* Return the type of the result of TYPE_CODE_XMETHOD value METHOD. */ - struct type *result_type_of_xmethod (gdb::array_view argv); + struct type *result_type_of_xmethod (gdb::span argv); /* Call the xmethod corresponding to the TYPE_CODE_XMETHOD value METHOD. */ - struct value *call_xmethod (gdb::array_view argv); + struct value *call_xmethod (gdb::span argv); /* Update this value before discarding OBJFILE. COPIED_TYPES is used to prevent cycles / duplicates. */ @@ -1284,7 +1284,7 @@ inline struct value *value_string (const char *ptr, ssize_t count, } extern struct value *value_array (int lowbound, - gdb::array_view elemvec); + gdb::span elemvec); extern struct value *value_concat (struct value *arg1, struct value *arg2); @@ -1327,7 +1327,7 @@ extern struct value *value_neg (struct value *arg1); extern struct value *value_complement (struct value *arg1); extern struct value *value_struct_elt (struct value **argp, - std::optional> args, + std::optional> args, const char *name, int *static_memfuncp, const char *err); @@ -1345,7 +1345,7 @@ extern struct value *value_static_field (struct type *type, int fieldno); enum oload_search_type { NON_METHOD, METHOD, BOTH }; -extern int find_overload_match (gdb::array_view args, +extern int find_overload_match (gdb::span args, const char *name, enum oload_search_type method, struct value **objp, struct symbol *fsym, @@ -1758,7 +1758,7 @@ value *pseudo_from_raw_part (const frame_info_ptr &next_frame, int pseudo_reg_nu RAW_REG_NUM starting at RAW_OFFSET. */ void pseudo_to_raw_part (const frame_info_ptr &next_frame, - gdb::array_view pseudo_buf, + gdb::span pseudo_buf, int raw_reg_num, int raw_offset); /* Create a value for pseudo register PSEUDO_REG_NUM by concatenating raw @@ -1774,7 +1774,7 @@ value *pseudo_from_concat_raw (const frame_info_ptr &next_frame, int pseudo_reg_ RAW_REG_1_NUM and RAW_REG_2_NUM. */ void pseudo_to_concat_raw (const frame_info_ptr &next_frame, - gdb::array_view pseudo_buf, + gdb::span pseudo_buf, int raw_reg_1_num, int raw_reg_2_num); /* Same as the above, but with three raw registers. */ @@ -1787,7 +1787,7 @@ value *pseudo_from_concat_raw (const frame_info_ptr &next_frame, int pseudo_reg_ registers RAW_REG_1_NUM, RAW_REG_2_NUM and RAW_REG_3_NUM. */ void pseudo_to_concat_raw (const frame_info_ptr &next_frame, - gdb::array_view pseudo_buf, + gdb::span pseudo_buf, int raw_reg_1_num, int raw_reg_2_num, int raw_reg_3_num); diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index e9bf4398d83..86e7ea6dd59 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -1284,7 +1284,7 @@ struct cygwin_sigwrapper_frame_cache static bool insns_match_pattern (CORE_ADDR pc, - const gdb::array_view pattern) + const gdb::span pattern) { for (size_t i = 0; i < pattern.size (); i++) { @@ -1306,7 +1306,7 @@ static void cygwin_sigwrapper_frame_analyze (struct gdbarch *gdbarch, CORE_ADDR start, CORE_ADDR end, - gdb::array_view> patterns_list, + gdb::span> patterns_list, int *tlsoffset) { enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); @@ -1449,7 +1449,7 @@ cygwin_sigwrapper_frame_unwind::sniff (const frame_info_ptr &this_frame, /* Cygwin sigwapper unwinder. */ cygwin_sigwrapper_frame_unwind::cygwin_sigwrapper_frame_unwind - (gdb::array_view> patterns_list) + (gdb::span> patterns_list) : frame_unwind ("cygwin sigwrapper", NORMAL_FRAME, FRAME_UNWIND_GDB, nullptr), patterns_list (patterns_list) { diff --git a/gdb/windows-tdep.h b/gdb/windows-tdep.h index 7cbc6ea9334..6f71ce5ce4d 100644 --- a/gdb/windows-tdep.h +++ b/gdb/windows-tdep.h @@ -66,7 +66,7 @@ class cygwin_sigwrapper_frame_unwind : public frame_unwind { public: explicit cygwin_sigwrapper_frame_unwind - (gdb::array_view> patterns_list); + (gdb::span> patterns_list); /* Architecture-specific list of instruction patterns to match. It's a list of patterns instead of single pattern because some @@ -75,7 +75,7 @@ class cygwin_sigwrapper_frame_unwind : public frame_unwind sequence is assumed to be followed by 4 bytes for tls::stackptr. If any pattern in the list matches, then the frame is assumed to be a sigwrapper frame. */ - gdb::array_view> patterns_list; + gdb::span> patterns_list; /* Calculate the frame ID of a cygwin wrapper. */ void this_id (const frame_info_ptr &this_frame, void **this_prologue_cache, diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c index 9c49b3bed47..e64069ef70d 100644 --- a/gdb/x86-linux-nat.c +++ b/gdb/x86-linux-nat.c @@ -259,7 +259,7 @@ x86_linux_store_ssp (const regcache *regcache, const int tid) static void i386_supply_tls_regs (regcache *regcache, int regnum, - gdb::array_view buffer) + gdb::span buffer) { gdb_assert (buffer.size () == 3); @@ -276,7 +276,7 @@ i386_supply_tls_regs (regcache *regcache, int regnum, static void i386_collect_tls_regs (regcache *regcache, int regnum, - gdb::array_view buffer) + gdb::span buffer) { gdb_assert (buffer.size () == 3); diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 08d5d810c6f..f92f4f703aa 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -249,7 +249,7 @@ read_xcoff_minimal_symbols (objfile *objfile) { bfd *abfd = objfile->obfd.get (); - gdb::array_view symbol_table + gdb::span symbol_table = gdb_bfd_canonicalize_symtab (abfd, false); /* Get the number of symbols we need. */ int number_of_symbols = symbol_table.size (); diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index f893821fa48..e867f98036e 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -114,7 +114,7 @@ public: bool supports_z_point_type (char z_type) override; - void process_qsupported (gdb::array_view features) override; + void process_qsupported (gdb::span features) override; bool supports_tracepoints () override; @@ -1068,7 +1068,7 @@ x86_target::update_xmltarget () PTRACE_GETREGSET. */ void -x86_target::process_qsupported (gdb::array_view features) +x86_target::process_qsupported (gdb::span features) { /* Return if gdb doesn't support XML. If gdb sends "xmlRegisters=" with "i386" in qSupported query, it supports x86 XML target diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 7e1fd9a82e0..0879fa4559a 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -278,7 +278,7 @@ regcache::register_size (int regnum) const return ::register_size (tdesc, regnum); } -static gdb::array_view +static gdb::span register_data (const struct regcache *regcache, int n) { const gdb::reg ® = find_register_by_number (regcache->tdesc, n); @@ -297,7 +297,7 @@ supply_register (struct regcache *regcache, int n, const void *vbuf) /* See gdbsupport/common-regcache.h. */ void -regcache::raw_supply (int n, gdb::array_view src) +regcache::raw_supply (int n, gdb::span src) { auto dst = register_data (this, n); @@ -390,7 +390,7 @@ collect_register (struct regcache *regcache, int n, void *vbuf) /* See gdbsupport/common-regcache.h. */ void -regcache::raw_collect (int n, gdb::array_view dst) const +regcache::raw_collect (int n, gdb::span dst) const { auto src = register_data (this, n); copy (src, dst); @@ -501,7 +501,7 @@ regcache::raw_compare (int regnum, const void *buf, int offset) const { gdb_assert (buf != NULL); - gdb::array_view regbuf = register_data (this, regnum); + gdb::span regbuf = register_data (this, regnum); gdb_assert (offset <= regbuf.size ()); regbuf = regbuf.slice (offset); diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h index 2f0fac6e7d0..094f6d1afdf 100644 --- a/gdbserver/regcache.h +++ b/gdbserver/regcache.h @@ -75,13 +75,13 @@ struct regcache : public reg_buffer_common int register_size (int regnum) const override; /* See gdbsupport/common-regcache.h. */ - void raw_supply (int regnum, gdb::array_view src) override; + void raw_supply (int regnum, gdb::span src) override; /* See gdbsupport/common-regcache.h. */ void raw_supply_part_zeroed (int regnum, int offset, size_t size) override; /* See gdbsupport/common-regcache.h. */ - void raw_collect (int regnum, gdb::array_view dst) const override; + void raw_collect (int regnum, gdb::span dst) const override; /* See gdbsupport/common-regcache.h. */ bool raw_compare (int regnum, const void *buf, int offset) const override; diff --git a/gdbserver/server.cc b/gdbserver/server.cc index 74774fcde7c..7bd725f81ed 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -4573,7 +4573,7 @@ captured_main (int argc, char *argv[]) error (_("No program to debug")); int n = argc - (next_arg - argv); - gdb::array_view args_view (&next_arg[1], &next_arg[n]); + gdb::span args_view (&next_arg[1], &next_arg[n]); program_args = construct_inferior_arguments (args_view, escape_args); /* Wait till we are at first instruction in program. */ diff --git a/gdbserver/target.cc b/gdbserver/target.cc index 43ef421df74..7fea01e4540 100644 --- a/gdbserver/target.cc +++ b/gdbserver/target.cc @@ -578,7 +578,7 @@ process_stratum_target::read_loadmap (const char *annex, void process_stratum_target::process_qsupported - (gdb::array_view features) + (gdb::span features) { /* Nop. */ } diff --git a/gdbserver/target.h b/gdbserver/target.h index 2fe5896a9ff..b6fdfb674c6 100644 --- a/gdbserver/target.h +++ b/gdbserver/target.h @@ -303,7 +303,7 @@ class process_stratum_target /* Target specific qSupported support. FEATURES is an array of features unsupported by the core of GDBserver. */ virtual void process_qsupported - (gdb::array_view features); + (gdb::span features); /* Return true if the target supports tracepoints, false otherwise. */ virtual bool supports_tracepoints (); diff --git a/gdbsupport/buildargv.h b/gdbsupport/buildargv.h index 788c1e38730..d49f5aa8273 100644 --- a/gdbsupport/buildargv.h +++ b/gdbsupport/buildargv.h @@ -126,14 +126,14 @@ class gdb_argv /* Return the arguments array as an array view. */ - gdb::array_view as_array_view () + gdb::span as_array_view () { - return gdb::array_view (this->get (), this->count ()); + return gdb::span (this->get (), this->count ()); } - gdb::array_view as_array_view () const + gdb::span as_array_view () const { - return gdb::array_view (this->get (), this->count ()); + return gdb::span (this->get (), this->count ()); } /* Append arguments to this array. */ diff --git a/gdbsupport/common-inferior.cc b/gdbsupport/common-inferior.cc index e8783e55bc8..5aebbc2160b 100644 --- a/gdbsupport/common-inferior.cc +++ b/gdbsupport/common-inferior.cc @@ -156,7 +156,7 @@ to_char_ptr (const std::string &arg) template std::string -construct_inferior_arguments (gdb::array_view argv, +construct_inferior_arguments (gdb::span argv, bool escape_shell_char) { /* Select the desired escape function. */ @@ -182,19 +182,19 @@ construct_inferior_arguments (gdb::array_view argv, template std::string construct_inferior_arguments - (gdb::array_view const> argv, + (gdb::span const> argv, bool escape_shell_char); /* Instantiate for T = 'char *'. */ template std::string -construct_inferior_arguments (gdb::array_view argv, +construct_inferior_arguments (gdb::span argv, bool escape_shell_char); /* Instantiate for T = 'std::string'. */ template std::string -construct_inferior_arguments (gdb::array_view argv, +construct_inferior_arguments (gdb::span argv, bool escape_shell_char); diff --git a/gdbsupport/common-inferior.h b/gdbsupport/common-inferior.h index 53d78b7bc23..87a6971cabe 100644 --- a/gdbsupport/common-inferior.h +++ b/gdbsupport/common-inferior.h @@ -64,6 +64,6 @@ extern bool startup_with_shell; template extern std::string construct_inferior_arguments - (gdb::array_view argv, bool escape_shell_char); + (gdb::span argv, bool escape_shell_char); #endif /* GDBSUPPORT_COMMON_INFERIOR_H */ diff --git a/gdbsupport/common-regcache.h b/gdbsupport/common-regcache.h index d944bd5254d..c9ca493689e 100644 --- a/gdbsupport/common-regcache.h +++ b/gdbsupport/common-regcache.h @@ -78,7 +78,7 @@ struct reg_buffer_common /* Supply register REGNUM, whose contents are stored in SRC, to this register buffer. */ - virtual void raw_supply (int regnum, gdb::array_view src) + virtual void raw_supply (int regnum, gdb::span src) = 0; void raw_supply (int regnum, const uint64_t *src) @@ -98,7 +98,7 @@ struct reg_buffer_common /* Collect register REGNUM from this register buffer and store its contents in DST. */ - virtual void raw_collect (int regnum, gdb::array_view dst) const + virtual void raw_collect (int regnum, gdb::span dst) const = 0; void raw_collect (int regnum, uint64_t *dst) const diff --git a/gdbsupport/common-utils.cc b/gdbsupport/common-utils.cc index f31699be13a..8d6606dd3f5 100644 --- a/gdbsupport/common-utils.cc +++ b/gdbsupport/common-utils.cc @@ -484,7 +484,7 @@ hex2bin (const char *hex) /* See gdbsupport/common-utils.h. */ std::string -bytes_to_string (gdb::array_view bytes) +bytes_to_string (gdb::span bytes) { std::string ret; diff --git a/gdbsupport/common-utils.h b/gdbsupport/common-utils.h index c6077fd3196..a4c79eaff15 100644 --- a/gdbsupport/common-utils.h +++ b/gdbsupport/common-utils.h @@ -236,10 +236,10 @@ gdb::byte_vector hex2bin (const char *hex); represented as a 2 character hex string, with spaces separating each individual byte. */ -extern std::string bytes_to_string (gdb::array_view bytes); +extern std::string bytes_to_string (gdb::span bytes); /* See bytes_to_string above. This takes a BUFFER pointer and LENGTH - rather than an array view. */ + rather than a span. */ static inline std::string bytes_to_string (const gdb_byte *buffer, size_t length) diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc index d301c6fe5c2..fe0152b52bc 100644 --- a/gdbsupport/pathstuff.cc +++ b/gdbsupport/pathstuff.cc @@ -193,7 +193,7 @@ child_path (const char *parent, const char *child) /* See gdbsupport/pathstuff.h. */ std::string -path_join (gdb::array_view paths) +path_join (gdb::span paths) { std::string ret; diff --git a/gdbsupport/pathstuff.h b/gdbsupport/pathstuff.h index 0d8f7b8a1f9..12049733232 100644 --- a/gdbsupport/pathstuff.h +++ b/gdbsupport/pathstuff.h @@ -93,7 +93,7 @@ extern const char *child_path (const char *parent, const char *child); with a directory separator, or an element starts with a directory separator, then these will be collapsed into a single separator. */ -extern std::string path_join (gdb::array_view paths); +extern std::string path_join (gdb::span paths); /* Same as the above, but accept paths as distinct parameters. */ @@ -107,7 +107,7 @@ path_join (Args... paths) std::array path_array { paths... }; - return path_join (gdb::array_view (path_array)); + return path_join (gdb::span (path_array)); } /* Return whether PATH contains a directory separator character. */ diff --git a/gdbsupport/remote-args.h b/gdbsupport/remote-args.h index b39eb20eeb7..c700471619d 100644 --- a/gdbsupport/remote-args.h +++ b/gdbsupport/remote-args.h @@ -62,7 +62,7 @@ template inline std::string join (const std::vector &args) { - return construct_inferior_arguments (gdb::array_view (args), false); + return construct_inferior_arguments (gdb::span (args), false); } } /* namespace remote_args */ diff --git a/gdbsupport/rsp-low.cc b/gdbsupport/rsp-low.cc index 9ad8d98d484..5635d3456bc 100644 --- a/gdbsupport/rsp-low.cc +++ b/gdbsupport/rsp-low.cc @@ -143,7 +143,7 @@ bin2hex (const gdb_byte *bin, char *hex, int count) /* See rsp-low.h. */ int -bin2hex (gdb::array_view bin, char *hex) +bin2hex (gdb::span bin, char *hex) { return bin2hex (bin.data (), hex, bin.size ()); } diff --git a/gdbsupport/rsp-low.h b/gdbsupport/rsp-low.h index 1a68cb4567f..6f4faecbc6b 100644 --- a/gdbsupport/rsp-low.h +++ b/gdbsupport/rsp-low.h @@ -54,7 +54,7 @@ extern std::string hex2str (const char *hex, int count); extern int bin2hex (const gdb_byte *bin, char *hex, int count); -extern int bin2hex (gdb::array_view bin, char *hex); +extern int bin2hex (gdb::span bin, char *hex); /* Overloaded version of bin2hex that returns a std::string. */ diff --git a/gdbsupport/selftest.cc b/gdbsupport/selftest.cc index 611bb990a0e..d4120f5c4c6 100644 --- a/gdbsupport/selftest.cc +++ b/gdbsupport/selftest.cc @@ -69,7 +69,7 @@ run_verbose () /* See selftest.h. */ void -run_tests (gdb::array_view filters, bool verbose) +run_tests (gdb::span filters, bool verbose) { int ran = 0; run_verbose_ = verbose; diff --git a/gdbsupport/selftest.h b/gdbsupport/selftest.h index d8a1e106594..7b537184d0d 100644 --- a/gdbsupport/selftest.h +++ b/gdbsupport/selftest.h @@ -78,7 +78,7 @@ extern void add_lazy_generator (selftests_generator generator); If FILTERS is not empty, only run tests with names containing one of the element of FILTERS. */ -extern void run_tests (gdb::array_view filters, +extern void run_tests (gdb::span filters, bool verbose = false); /* Reset GDB or GDBserver's internal state. */ diff --git a/gdbsupport/span.h b/gdbsupport/span.h index 9708020b06a..3dcf839bc5b 100644 --- a/gdbsupport/span.h +++ b/gdbsupport/span.h @@ -23,14 +23,14 @@ #include #include "gdbsupport/gdb_assert.h" -/* An array_view is an abstraction that provides a non-owning view +/* A span is an abstraction that provides a non-owning view over a sequence of contiguous objects. - A way to put it is that array_view is to std::vector (and + A way to put it is that span is to std::vector (and std::array and built-in arrays with rank==1) like std::string_view is to std::string. - The main intent of array_view is to use it as function input + The main intent of span is to use it as function input parameter type, making it possible to pass in any sequence of contiguous objects, irrespective of whether the objects live on the stack or heap and what actual container owns them. Implicit @@ -39,7 +39,7 @@ have one element (usually on the stack). For example: struct A { .... }; - void function (gdb::array_view as); + void function (gdb::span as); std::vector std_vec = ...; std::array std_array = ...; @@ -52,13 +52,13 @@ function (elem); Views can be either mutable or const. A const view is simply - created by specifying a const T as array_view template parameter, - in which case operator[] of non-const array_view objects ends up - returning const references. Making the array_view itself const is + created by specifying a const T as span template parameter, + in which case operator[] of non-const span objects ends up + returning const references. Making the span itself const is analogous to making a pointer itself be const. I.e., disables re-seating the view/pointer. - Since array_view objects are small (pointer plus size), and + Since span objects are small (pointer plus size), and designed to be trivially copyable, they should generally be passed around by value. @@ -68,7 +68,7 @@ namespace gdb { template -class array_view +class span { /* True iff decayed T is the same as decayed U. E.g., we want to say that 'T&' is the same as 'const T'. */ @@ -92,53 +92,53 @@ class array_view using iterator = T *; /* Default construction creates an empty view. */ - constexpr array_view () noexcept + constexpr span () noexcept : m_array (nullptr), m_size (0) {} - /* Create an array view over a single object of the type of an - array_view element. The created view as size==1. This is - templated on U to allow constructing a array_view over a + /* Create a span over a single object of the type of an + span element. The created view as size==1. This is + templated on U to allow constructing a span over a (non-const) T. The "convertible" requirement makes sure that you - can't create an array_view over a const T. */ + can't create a span over a const T. */ template>> - constexpr array_view (U &elem) noexcept + constexpr span (U &elem) noexcept : m_array (&elem), m_size (1) {} /* Same as above, for rvalue references. */ template>> - constexpr array_view (U &&elem) noexcept + constexpr span (U &&elem) noexcept : m_array (&elem), m_size (1) {} - /* Create an array view from a pointer to an array and an element + /* Create a span from a pointer to an array and an element count. */ template>> - constexpr array_view (U *array, size_t size) noexcept + constexpr span (U *array, size_t size) noexcept : m_array (array), m_size (size) {} - /* Create an array view from a range. This is templated on both U + /* Create a span from a range. This is templated on both U an V to allow passing in a mix of 'const T *' and 'T *'. */ template>, typename = Requires>> - constexpr array_view (U *begin, V *end) noexcept + constexpr span (U *begin, V *end) noexcept : m_array (begin), m_size (end - begin) {} - /* Create an array view from an array. */ + /* Create a span from an array. */ template>> - constexpr array_view (U (&array)[Size]) noexcept + constexpr span (U (&array)[Size]) noexcept : m_array (array), m_size (Size) {} - /* Create an array view from a contiguous container. E.g., + /* Create a span from a contiguous container. E.g., std::vector and std::array. */ template>>, @@ -151,7 +151,7 @@ class array_view = Requires ().size ()), size_type>>> - constexpr array_view (Container &&c) noexcept + constexpr span (Container &&c) noexcept : m_array (c.data ()), m_size (c.size ()) {} @@ -183,11 +183,11 @@ class array_view constexpr size_type size () const noexcept { return m_size; } constexpr bool empty () const noexcept { return m_size == 0; } - /* Slice an array view. */ + /* Slice a span. */ - /* Return a new array view over SIZE elements starting at START. */ + /* Return a new span over SIZE elements starting at START. */ [[nodiscard]] - constexpr array_view slice (size_type start, size_type size) const noexcept + constexpr span slice (size_type start, size_type size) const noexcept { #if defined(_GLIBCXX_DEBUG) gdb_assert (start + size <= m_size); @@ -195,10 +195,10 @@ class array_view return {m_array + start, size}; } - /* Return a new array view over all the elements after START, + /* Return a new span over all the elements after START, inclusive. */ [[nodiscard]] - constexpr array_view slice (size_type start) const noexcept + constexpr span slice (size_type start) const noexcept { #if defined(_GLIBCXX_DEBUG) gdb_assert (start <= m_size); @@ -211,12 +211,12 @@ class array_view size_type m_size; }; -/* Copy the contents referenced by the array view SRC to the array view DEST. +/* Copy the contents referenced by the span SRC to the span DEST. - The two array views must have the same length. */ + The two spans must have the same length. */ template -void copy (gdb::array_view src, gdb::array_view dest) +void copy (gdb::span src, gdb::span dest) { gdb_assert (dest.size () == src.size ()); if (dest.data () < src.data ()) @@ -231,7 +231,7 @@ void copy (gdb::array_view src, gdb::array_view dest) template bool -operator== (const gdb::array_view &lhs, const gdb::array_view &rhs) +operator== (const gdb::span &lhs, const gdb::span &rhs) { if (lhs.size () != rhs.size ()) return false; @@ -243,26 +243,26 @@ operator== (const gdb::array_view &lhs, const gdb::array_view &rhs) return true; } -/* Compare two array_views for inequality. */ +/* Compare two spans for inequality. */ template bool -operator!= (const gdb::array_view &lhs, const gdb::array_view &rhs) +operator!= (const gdb::span &lhs, const gdb::span &rhs) { return !(lhs == rhs); } -/* Create an array view from a pointer to an array and an element +/* Create a span from a pointer to an array and an element count. - This is useful as alternative to constructing an array_view using + This is useful as alternative to constructing a span using brace initialization when the size variable you have handy is of signed type, since otherwise without an explicit cast the code would be ill-formed. For example, with: - extern void foo (int, int, gdb::array_view); + extern void foo (int, int, gdb::span); value *args[2]; int nargs; @@ -277,27 +277,27 @@ operator!= (const gdb::array_view &lhs, const gdb::array_view &rhs) foo (1, 2, {values, (size_t) nargs}); - Or by instantiating an array_view explicitly: + Or by instantiating a span explicitly: - foo (1, 2, gdb::array_view(values, nargs)); + foo (1, 2, gdb::span(values, nargs)); - Or, better, using make_array_view, which has the advantage of - inferring the array_view element's type: + Or, better, using make_span, which has the advantage of + inferring the span element's type: - foo (1, 2, gdb::make_array_view (values, nargs)); + foo (1, 2, gdb::make_span (values, nargs)); */ template -constexpr inline array_view +constexpr inline span make_array_view (U *array, size_t size) noexcept { return {array, size}; } -/* Create an array view from an array. */ +/* Create a span from an array. */ template -constexpr inline array_view +constexpr inline span make_array_view (U (&array)[Size]) { return {array}; -- 2.56.0