aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.ctf
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.ctf')
-rw-r--r--gdb/testsuite/gdb.ctf/dwarf2-and-ctf-2.c24
-rw-r--r--gdb/testsuite/gdb.ctf/dwarf2-and-ctf.c26
-rw-r--r--gdb/testsuite/gdb.ctf/dwarf2-and-ctf.exp54
3 files changed, 104 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.ctf/dwarf2-and-ctf-2.c b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf-2.c
new file mode 100644
index 0000000..daa45be
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf-2.c
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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/>. */
+
+int var_ctf = 2;
+
+int
+foo (void)
+{
+ return var_ctf;
+}
diff --git a/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.c b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.c
new file mode 100644
index 0000000..436ebcc
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.c
@@ -0,0 +1,26 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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/>. */
+
+int var_dwarf = 1;
+
+extern int foo ();
+
+int
+main (void)
+{
+ return var_dwarf + foo ();
+}
diff --git a/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.exp b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.exp
new file mode 100644
index 0000000..22162cf
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/dwarf2-and-ctf.exp
@@ -0,0 +1,54 @@
+# 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/>.
+
+require allow_ctf_tests
+
+standard_testfile .c -2.c
+
+set objfile [standard_output_file ${testfile}.o]
+set objfile2 [standard_output_file ${testfile}-2.o]
+
+set s1 ${srcdir}/${subdir}/${srcfile}
+set s2 ${srcdir}/${subdir}/${srcfile2}
+
+set opts {}
+lappend opts debug
+if { [gdb_compile $s1 ${objfile} object $opts] != "" } {
+ untested "failed to compile"
+ return -1
+}
+
+set opts {}
+lappend opts "additional_flags=-gctf"
+if { [gdb_compile $s2 ${objfile2} object $opts] != "" } {
+ untested "failed to compile"
+ return -1
+}
+
+set opts {}
+lappend opts "additional_flags=-Wl,-ctf-variables"
+if { [gdb_compile [list ${objfile} ${objfile2}] $binfile executable $opts] != "" } {
+ unsupported "failed to link"
+ return -1
+}
+
+clean_restart
+
+gdb_test_no_output "set always-read-ctf on"
+
+gdb_load $binfile
+
+gdb_test "print var_dwarf" " = 1"
+gdb_test "print var_ctf" " = 2"