Test more branches in ada_convert_actual
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
Commit Message
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
base-commit: 1ad761d978807cdd3a9972e32db6e3899de2115d
new file mode 100644
@@ -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;
+}
new file mode 100644
@@ -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}]