public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Preserve name of range types
Date: Mon, 20 Mar 2023 10:17:01 -0600	[thread overview]
Message-ID: <20230320161701.1493641-1-tromey@adacore.com> (raw)

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 <http://www.gnu.org/licenses/>.
+
+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 <http://www.gnu.org/licenses/>.
+
+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 <http://www.gnu.org/licenses/>.
+
+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 <http://www.gnu.org/licenses/>.
+
+with System;
+package Pck is
+   function Ident (I : Integer) return Integer;
+   procedure Do_Nothing (A : System.Address);
+end Pck;
-- 
2.39.1


             reply	other threads:[~2023-03-20 16:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 16:17 Tom Tromey [this message]
2023-03-23 16:19 ` Bruno Larsen
2023-03-24 16:20   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230320161701.1493641-1-tromey@adacore.com \
    --to=tromey@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).