From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Fix type of imported variable for arraydim.exp
Date: Thu, 30 Jul 2026 10:59:33 -0600 [thread overview]
Message-ID: <20260730165933.2515411-1-tromey@adacore.com> (raw)
The test code for gdb.ada/arraydim.exp imports a variable using a
dummy type. Then the test tries to print the type of this variable.
This works ok with GCC, because the import is emitted as a
declaration; but this fails with gnat-llvm, where a definition is
emitted.
This seems to be a test bug to me. This patch fixes the problem by
using the correct type here.
---
gdb/testsuite/gdb.ada/arraydim.exp | 7 ++++++-
gdb/testsuite/gdb.ada/arraydim/foo.adb | 7 ++-----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/gdb.ada/arraydim.exp b/gdb/testsuite/gdb.ada/arraydim.exp
index 7b84a7af9b7..815a91ffa82 100644
--- a/gdb/testsuite/gdb.ada/arraydim.exp
+++ b/gdb/testsuite/gdb.ada/arraydim.exp
@@ -52,8 +52,13 @@ gdb_test "print m'first(3)" " = 4"
gdb_test "print m'last(3)" " = 6"
gdb_test "print m'length(3)" " = 3"
+# With GCC the test shows "int" as the element type, but with
+# gnat-llvm it shows "integer"; both of these are reasonable enough so
+# we accept either. The difference here is because GCC emits a
+# declaration in the DWARF for foo.o, but gnat-llvm emits a
+# definition.
gdb_test "ptype global_3dim_for_gdb_testing" \
- "array \\(0 \\.\\. 0, 0 \\.\\. 1, 0 \\.\\. 2\\) of int"
+ [quotemeta "array (0 .. 0, 0 .. 1, 0 .. 2) of @/(int|integer)/"]
gdb_test "print global_3dim_for_gdb_testing'first" " = 0"
gdb_test "print global_3dim_for_gdb_testing'last" " = 0"
diff --git a/gdb/testsuite/gdb.ada/arraydim/foo.adb b/gdb/testsuite/gdb.ada/arraydim/foo.adb
index 86204956d00..8da63e1af93 100644
--- a/gdb/testsuite/gdb.ada/arraydim/foo.adb
+++ b/gdb/testsuite/gdb.ada/arraydim/foo.adb
@@ -18,11 +18,8 @@ procedure Foo is
type Multi is array (1 .. 1, 2 .. 3, 4 .. 6) of Integer;
M : Multi := (others => (others => (others => 0)));
- -- Use a fake type for importing our C multi-dimensional array.
- -- It's only to make sure the C unit gets linked in, regardless
- -- of possible optimizations.
- type Void_Star is access integer;
- E : Void_Star;
+ type C_Multi is array (0 .. 0, 0 .. 1, 0 .. 2) of Integer;
+ E : C_Multi;
pragma Import (C, E, "global_3dim_for_gdb_testing");
begin
Do_Nothing (M'Address); -- STOP
base-commit: 6d1be0b90e837e4c82eaaf6f9e8c7da7227902e1
--
2.55.0
next reply other threads:[~2026-07-30 17:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 16:59 Tom Tromey [this message]
2026-07-31 12:01 ` Tom de Vries
2026-08-03 13:29 ` 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=20260730165933.2515411-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