From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by sourceware.org (Postfix) with ESMTPS id DFFD93858C41 for ; Tue, 5 Sep 2023 19:47:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFFD93858C41 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-77ac14ff51bso120805439f.3 for ; Tue, 05 Sep 2023 12:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1693943225; x=1694548025; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Q8fwSHzpASs/0TLhcTPSWKLUSkvzkDF4y5epZBVCbfw=; b=W/KolpQM3LGZtvNZgaaL5L87SSwF7YfWeoiWjseX43Jq5ofUSv6Cl+S+HD0T9JT9XB wwI0I6qDL6r4Vn8TR/+Ywvg7q0kG3jyFq8Yi5IkjP1egxgNswKJxMvJEwUFB/VzZTu22 /COiyBs4536OEGxfB45BLrzfwdjG+RJS05CQQVZVFbdSRKC5uGTgoF0tYS8tjWpPU9cP xEwf+6999dszaJPUv+yf4DVGNe/noHEXYkW79ykhtmtRhbhzl2lyoKsVDx6JWftUTu/8 nVrbHEPxDA0P/y/K6CvgFv5ROzGJaT5N9gzCcxkK/ZzB0BpnAlZ0ZVO+Ve2Pqnt8uD0t gPbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693943225; x=1694548025; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q8fwSHzpASs/0TLhcTPSWKLUSkvzkDF4y5epZBVCbfw=; b=H++JyaFu3qmd1yJa4WQe2Wmho9HGzgpN1NEz+wY7yvIO5KbVhwNgZ0WOZDQXjpkBmf UoznrFiPBtGnywGZEOeKENbn4sv3sLkQrLE8PKWP+CrdrtirvEW7Z4CpfLDM2J+ejKGj ESHkpY1jt5wVRg3jNeGk1TzUvkUrpTqepnMB6ZOydq2qA8Egj8MOC1TAArZ4xpuvdhF6 KD0RrTDcfjvZkJsJ72+2e2arvVqblQ+GIvkPJkTqYNJ+rlE+DtA01hliV0nMb6+vGCQr HBlLfy9sPH6snCLiOlC7OJ5zW/pWQHdn4DNK3EBaDL5gAVpXF/Wzbr/asnAEic/5sHdK zVyQ== X-Gm-Message-State: AOJu0Yz/b4Nlxu/2PgsE+14y6njJGsvfTHtQuuVyLeUEWNntlD9vqmSj HYKX73l0l0AoMIQu6R8XqyrSYdR/vod6MqLbDoRBhQ== X-Google-Smtp-Source: AGHT+IH3wS+Kzf2pJPGwoFkFGLT9elDHMulDyuQDVUihoZGtXpp+ZAHvYTsQFOkPSNCcyNvjdLhcbQ== X-Received: by 2002:a5e:c705:0:b0:790:a905:5fbf with SMTP id f5-20020a5ec705000000b00790a9055fbfmr15501412iop.11.1693943225143; Tue, 05 Sep 2023 12:47:05 -0700 (PDT) Received: from localhost.localdomain (75-166-150-212.hlrn.qwest.net. [75.166.150.212]) by smtp.gmail.com with ESMTPSA id y9-20020a02a389000000b0042b144abf71sm4294910jak.179.2023.09.05.12.47.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 12:47:04 -0700 (PDT) From: Tom Tromey Date: Tue, 05 Sep 2023 13:47:03 -0600 Subject: [PATCH 3/5] Add is_array_like and to_array to language_defn MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230905-dap-30821-pointers-v1-3-0d7323327678@adacore.com> References: <20230905-dap-30821-pointers-v1-0-0d7323327678@adacore.com> In-Reply-To: <20230905-dap-30821-pointers-v1-0-0d7323327678@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.3 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This adds new is_array_like and to_array methods to language_defn. This will be used in a subsequent patch that generalizes the new Python array- and string-handling code. --- gdb/ada-lang.c | 13 +++++++++++++ gdb/language.h | 11 +++++++++++ gdb/rust-lang.h | 10 ++++++++++ 3 files changed, 34 insertions(+) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index c0cc512bfa3..b03ed53d11c 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13810,6 +13810,19 @@ class ada_language : public language_defn /* See language.h. */ + bool is_array_like (struct type *type) const override + { + return (ada_is_constrained_packed_array_type (type) + || ada_is_array_descriptor_type (type)); + } + + /* See language.h. */ + + struct value *to_array (struct value *val) const override + { return ada_coerce_to_simple_array (val); } + + /* See language.h. */ + const char *struct_too_deep_ellipsis () const override { return "(...)"; } diff --git a/gdb/language.h b/gdb/language.h index 9fd2fb6f387..6ee8f6160e1 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -568,6 +568,17 @@ struct language_defn /* Return true if TYPE is a string type. */ virtual bool is_string_type_p (struct type *type) const; + /* Return true if TYPE is array-like. */ + virtual bool is_array_like (struct type *type) const + { return false; } + + /* Underlying implementation of value_to_array. Return a value of + array type that corresponds to VAL. The caller must ensure that + is_array_like is true for VAL's type. Return nullptr if the type + cannot be handled. */ + virtual struct value *to_array (struct value *val) const + { return nullptr; } + /* Return a string that is used by the 'set print max-depth' setting. When GDB replaces a struct or union (during value printing) that is "too deep" this string is displayed instead. The default value here diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h index 2c7ccb93bcf..ce1dff211b6 100644 --- a/gdb/rust-lang.h +++ b/gdb/rust-lang.h @@ -196,6 +196,16 @@ class rust_language : public language_defn /* See language.h. */ + bool is_array_like (struct type *type) const override + { return rust_slice_type_p (type); } + + /* See language.h. */ + + struct value *to_array (struct value *val) const override + { return rust_slice_to_array (val); } + + /* See language.h. */ + bool range_checking_on_by_default () const override { return true; } -- 2.40.1