From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id 206483850851 for ; Mon, 20 Mar 2023 16:17:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 206483850851 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-il1-x130.google.com with SMTP id r4so6712679ilt.8 for ; Mon, 20 Mar 2023 09:17:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1679329031; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ZRmv5xu620baC5LCSXLsLqwRba1l581xdFPhCLCqnqs=; b=ljnhnvTFwLB4N3F4ot1eAq/uHIbgtt+rfzC+DTGizYIhiUCwTqV0DDjs5IcfPJrB0m q985ygHfW3G3q0TI7RT90gud2Tk5UZteN8ePG6S8Tbq3LlwyZ59o8aMqPIQ1WjCUZwnx O7aTBmaFn0WsA4nX59Ylv40L/pOT0aNDinvMP+a2OmiQS293U1kPGPAv7SHhZH8RL9BF f7EBHLD/hE5QGDHmOwl7FrvDsEiCxOazlAiWNGFF4UgRw9bpxAMs7HI8qanhfHSgFEpz Yj/gJAJ+oXdkLL0PNTtdQPOvvDlDGb0bi/Hko6qc+bxgMyYU7tHRrbeiC5w1NZBjUtu+ aw2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679329031; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZRmv5xu620baC5LCSXLsLqwRba1l581xdFPhCLCqnqs=; b=lbKxrigDBKyBvcM2vC9t08XSp1EmSF0HMjzVPyJgCysBLx9qqonSc8WKmjRL/rHOdL EiKiNFp4eUY8Z+/8HA+rfhjBgHkfee8975uIqCD5JMTSTCOsuB+xHI2DC75VBbwXDeKU OQMYMzoONKueMqMal+t5Uy46IEAypvdY+ZJqpTNNZLNbCA/gCsVkMO0iSrijZ2mBRa4h p7YynL5iYocxTRaCNxEof9x73IlnmGA5MTbCeaMvYj1WgTzAO+rU3JBIwxRZgVXZVkLG nWPD/nuaznOA6AWVhgNejVdD5k4bhRfkbm0sLGNF5AZO0mRz/qcHvw5lSl8a74ux2eBW G35A== X-Gm-Message-State: AO0yUKXan/k0fH7tj5D9MzcWUvdFG+JGGAUMvin4Ctd99CpiK/6JSqxB IFzw+MMMGR2gYkqgLhF4UlvbYi9RifaYqhe++EuOkw== X-Google-Smtp-Source: AK7set8OR1uNG/LwqZeVYKiW8gZuJAkiyXnhrWO9rCdY+IXBfK5b4IbXo+RBlcfdHXqivuLU5Vdlew== X-Received: by 2002:a92:d583:0:b0:323:70c:ba96 with SMTP id a3-20020a92d583000000b00323070cba96mr85204iln.0.1679329031306; Mon, 20 Mar 2023 09:17:11 -0700 (PDT) Received: from localhost.localdomain (71-211-185-113.hlrn.qwest.net. [71.211.185.113]) by smtp.gmail.com with ESMTPSA id v13-20020a02b08d000000b004063fa63e31sm3072810jah.118.2023.03.20.09.17.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 09:17:11 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Preserve name of range types Date: Mon, 20 Mar 2023 10:17:01 -0600 Message-Id: <20230320161701.1493641-1-tromey@adacore.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,KAM_SHORT,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: The type-allocation patches introduced a small regression that was picked up by the AdaCore internal test suite. Previously, the name of a range type was preserved by resolve_dynamic_range, but now it is not. This patch changes this code to preserve the name. --- gdb/gdbtypes.c | 1 + gdb/testsuite/gdb.ada/dyn-range.exp | 33 +++++++++++++++++++++++++ gdb/testsuite/gdb.ada/dyn-range/dyn.adb | 24 ++++++++++++++++++ gdb/testsuite/gdb.ada/dyn-range/pck.adb | 26 +++++++++++++++++++ gdb/testsuite/gdb.ada/dyn-range/pck.ads | 20 +++++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 gdb/testsuite/gdb.ada/dyn-range.exp create mode 100644 gdb/testsuite/gdb.ada/dyn-range/dyn.adb create mode 100644 gdb/testsuite/gdb.ada/dyn-range/pck.adb create mode 100644 gdb/testsuite/gdb.ada/dyn-range/pck.ads diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b25b0ce2e34..44b06921387 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2230,6 +2230,7 @@ resolve_dynamic_range (struct type *dyn_range_type, static_range_type = create_range_type_with_stride (alloc, static_target_type, &low_bound, &high_bound, bias, &stride, byte_stride_p); + static_range_type->set_name (dyn_range_type->name ()); static_range_type->bounds ()->flag_bound_evaluated = 1; return static_range_type; } diff --git a/gdb/testsuite/gdb.ada/dyn-range.exp b/gdb/testsuite/gdb.ada/dyn-range.exp new file mode 100644 index 00000000000..be217d15a61 --- /dev/null +++ b/gdb/testsuite/gdb.ada/dyn-range.exp @@ -0,0 +1,33 @@ +# Copyright 2023 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +load_lib "ada.exp" + +require allow_ada_tests + +standard_ada_testfile dyn + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "STOP" ${testdir}/dyn.adb] +if {![runto "dyn.adb:$bp_location"]} { + return -1 +} + +gdb_test "whatis d" "type = dyn.dyn_range" diff --git a/gdb/testsuite/gdb.ada/dyn-range/dyn.adb b/gdb/testsuite/gdb.ada/dyn-range/dyn.adb new file mode 100644 index 00000000000..d071bf92132 --- /dev/null +++ b/gdb/testsuite/gdb.ada/dyn-range/dyn.adb @@ -0,0 +1,24 @@ +-- Copyright 2023 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with Pck; use Pck; + +procedure Dyn is + type Dyn_Range is new Integer range Ident (1) .. Ident (100); + + D : Dyn_Range := 45; +begin + Do_Nothing (D'Address); -- STOP +end Dyn; diff --git a/gdb/testsuite/gdb.ada/dyn-range/pck.adb b/gdb/testsuite/gdb.ada/dyn-range/pck.adb new file mode 100644 index 00000000000..91fef4e5dff --- /dev/null +++ b/gdb/testsuite/gdb.ada/dyn-range/pck.adb @@ -0,0 +1,26 @@ +-- Copyright 2023 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +package body Pck is + function Ident (I : Integer) return Integer is + begin + return I; + end Ident; + + procedure Do_Nothing (A : System.Address) is + begin + null; + end Do_Nothing; +end Pck; diff --git a/gdb/testsuite/gdb.ada/dyn-range/pck.ads b/gdb/testsuite/gdb.ada/dyn-range/pck.ads new file mode 100644 index 00000000000..c96f9d4ab82 --- /dev/null +++ b/gdb/testsuite/gdb.ada/dyn-range/pck.ads @@ -0,0 +1,20 @@ +-- Copyright 2023 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . + +with System; +package Pck is + function Ident (I : Integer) return Integer; + procedure Do_Nothing (A : System.Address); +end Pck; -- 2.39.1