From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Test more branches in ada_convert_actual
Date: Thu, 27 Aug 2026 10:23:22 -0600 [thread overview]
Message-ID: <20260827162322.1256735-1-tromey@adacore.com> (raw)
Coverage testing showed that some parts of ada_convert_actual are
never tested.
This patch adds a test for one of these, namely the handling of a
formal parameter whose type is an "aligner" type.
This test is written largely in C, because actually getting the
compiler to emit this seems tricky. Eric pointed out some code in
GNAT explaining why:
/* Either for foreign conventions, or if the underlying type is not passed
by reference and is as large and aligned as the original type, strip off
a possible padding type. */
if (TYPE_IS_PADDING_P (gnu_param_type))
...
---
gdb/testsuite/gdb.ada/padded-formal.c | 38 ++++++++++++++++++++++
gdb/testsuite/gdb.ada/padded-formal.exp | 42 +++++++++++++++++++++++++
2 files changed, 80 insertions(+)
create mode 100644 gdb/testsuite/gdb.ada/padded-formal.c
create mode 100644 gdb/testsuite/gdb.ada/padded-formal.exp
diff --git a/gdb/testsuite/gdb.ada/padded-formal.c b/gdb/testsuite/gdb.ada/padded-formal.c
new file mode 100644
index 00000000000..7f882483c4c
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/padded-formal.c
@@ -0,0 +1,38 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2026 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/>. */
+
+
+typedef unsigned short pkg__myint;
+
+typedef struct {
+ pkg__myint F;
+} __attribute__ ((aligned (8))) pkg__myint___PAD;
+
+pkg__myint
+call (pkg__myint___PAD padded)
+{
+ return padded.F + 7;
+}
+
+pkg__myint value = 16;
+pkg__myint___PAD pdv = { 16 };
+
+int
+main()
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.ada/padded-formal.exp b/gdb/testsuite/gdb.ada/padded-formal.exp
new file mode 100644
index 00000000000..c51a56d29b5
--- /dev/null
+++ b/gdb/testsuite/gdb.ada/padded-formal.exp
@@ -0,0 +1,42 @@
+# Copyright 2026 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/>.
+
+# Test that a value can be passed to a function expecting a padded
+# type.
+
+load_lib "ada.exp"
+
+require allow_ada_tests
+
+# This is written in C because actually constructing such a test case
+# is difficult or maybe even impossible with recent versions of GNAT.
+# Originally padding was used when passing Long_Long_Float types; see
+# commit 8344af1e ("[Ada] error trying to call function when parameter
+# is aligner type."), but this no longer happens.
+standard_testfile
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
+ return
+}
+
+if {![runto_main]} {
+ return
+}
+
+gdb_test "set language ada" \
+ [quotemeta {Warning: the current language does not match this frame.}]
+
+gdb_test "print call(value)" [quotemeta {@DECIMAL = 23}]
+gdb_test "print call(pdv)" [quotemeta {@DECIMAL = 23}]
base-commit: 1ad761d978807cdd3a9972e32db6e3899de2115d
--
2.55.0
reply other threads:[~2026-08-27 16:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260827162322.1256735-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