aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/vla-optimized-out.c34
-rw-r--r--gdb/testsuite/gdb.base/vla-optimized-out.exp40
3 files changed, 79 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index ec7a819..dbd659d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-07-18 Tom de Vries <tdevries@suse.de>
+
+ * gdb.base/vla-optimized-out.c: New test.
+ * gdb.base/vla-optimized-out.exp: New file.
+
2018-07-13 Sergio Durigan Junior <sergiodj@redhat.com>
* lib/gdbserver-support.exp (gdbserver_start): Expect for the
diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.c b/gdb/testsuite/gdb.base/vla-optimized-out.c
new file mode 100644
index 0000000..913e8ea
--- /dev/null
+++ b/gdb/testsuite/gdb.base/vla-optimized-out.c
@@ -0,0 +1,34 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2018 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/>. */
+
+int __attribute__((noinline, noclone))
+f1 (int i)
+{
+ char a[i + 1];
+ a[0] = 5;
+ return a[0];
+}
+
+int
+main (void)
+{
+ volatile int j;
+ int i = 5;
+ asm volatile ("" : "=r" (i) : "0" (i));
+ j = f1 (i);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.exp b/gdb/testsuite/gdb.base/vla-optimized-out.exp
new file mode 100644
index 0000000..39abb79
--- /dev/null
+++ b/gdb/testsuite/gdb.base/vla-optimized-out.exp
@@ -0,0 +1,40 @@
+# Copyright 2018 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/>.
+
+# Check whether we can determine the size of an optimized-out vla.
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
+ {debug optimize=-O1}] } {
+ return -1
+}
+
+proc vla_optimized_out { } {
+ if ![runto f1] {
+ fail "can't run to f1"
+ return
+ }
+
+ gdb_test "p a" \
+ { = <optimized out>} \
+ "printed optimized out vla"
+
+ gdb_test "p sizeof (a)" \
+ { = 6} \
+ "printed size of optimized out vla"
+}
+
+vla_optimized_out