aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorWeimin Pan <weimin.pan@oracle.com>2021-09-18 20:41:29 -0400
committerWeimin Pan <weimin.pan@oracle.com>2021-09-18 20:41:29 -0400
commitffb3f587933f20bf9e6e9a26ac547a8589fac081 (patch)
treefd933456aeadd7e7608c4bc93d233724d5a50675 /gdb/testsuite
parent3733650765bf40c8be16fe0a7b8adc0831cbfe22 (diff)
downloadbinutils-ffb3f587933f20bf9e6e9a26ac547a8589fac081.zip
binutils-ffb3f587933f20bf9e6e9a26ac547a8589fac081.tar.gz
binutils-ffb3f587933f20bf9e6e9a26ac547a8589fac081.tar.bz2
CTF: multi-CU and archive support
Now gdb is capable of debugging executable, which consists of multiple compilation units (CUs) with the CTF debug info. An executable could potentially have one or more archives, which, in CTF context, contain conflicting types. all changes were made in ctfread.c in which elfctf_build_psymtabs was modified to handle archives, via the ctf archive iterator and its callback build_ctf_archive_member and scan_partial_symbols was modified to scan archives, which are treated as subfiles, to build the psymtabs. Also changes were made to handle CTF's data object section and function info section which now share the same format of their contents - an array of type IDs. New functions ctf_psymtab_add_stt_entries, which is called by ctf_psymtab_add_stt_obj and ctf_psymtab_add_stt_func, and add_stt_entries, which is called by add_stt_obj and add_stt_func when setting up psymtabs and full symtab, respectively.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.base/ctf-constvars.exp4
-rw-r--r--gdb/testsuite/gdb.base/ctf-ptype.exp4
-rw-r--r--gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c18
-rw-r--r--gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c16
-rw-r--r--gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c3
-rw-r--r--gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c4
-rw-r--r--gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp43
-rw-r--r--gdb/testsuite/gdb.ctf/ctf-a.c32
-rw-r--r--gdb/testsuite/gdb.ctf/ctf-a.h22
-rw-r--r--gdb/testsuite/gdb.ctf/ctf-b.c25
-rw-r--r--gdb/testsuite/gdb.ctf/ctf-b.h22
-rw-r--r--gdb/testsuite/gdb.ctf/ctf-c.c25
-rw-r--r--gdb/testsuite/gdb.ctf/ctf-c.h21
-rw-r--r--gdb/testsuite/gdb.ctf/funcreturn.exp4
-rw-r--r--gdb/testsuite/gdb.ctf/multi.exp42
-rw-r--r--gdb/testsuite/lib/gdb.exp4
16 files changed, 281 insertions, 8 deletions
diff --git a/gdb/testsuite/gdb.base/ctf-constvars.exp b/gdb/testsuite/gdb.base/ctf-constvars.exp
index 6e9210f..2e57ea0 100644
--- a/gdb/testsuite/gdb.base/ctf-constvars.exp
+++ b/gdb/testsuite/gdb.base/ctf-constvars.exp
@@ -31,8 +31,8 @@ if [skip_ctf_tests] {
standard_testfile .c
-# Using `-gt` generates full-fledged CTF debug information.
-set opts "additional_flags=-gt"
+# Using `-gctf` generates full-fledged CTF debug information.
+set opts "additional_flags=-gctf"
if { [prepare_for_testing "failed to prepare" ${testfile} \
[list $srcfile] [list $opts nowarnings]] } {
return 0
diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/ctf-ptype.exp
index 7dd6d95..a756edc 100644
--- a/gdb/testsuite/gdb.base/ctf-ptype.exp
+++ b/gdb/testsuite/gdb.base/ctf-ptype.exp
@@ -22,8 +22,8 @@ if [skip_ctf_tests] {
standard_testfile .c
-# Using `-gt` generates full-fledged CTF debug information.
-set opts "additional_flags=-gt"
+# Using `-gctf` generates full-fledged CTF debug information.
+set opts "additional_flags=-gctf"
if { [prepare_for_testing "failed to prepare" ${testfile} \
[list $srcfile] [list $opts nowarnings]] } {
diff --git a/gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c
new file mode 100644
index 0000000..fe52b9e
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-1.c
@@ -0,0 +1,18 @@
+struct A;
+struct B
+{
+ int foo;
+ struct A *bar;
+};
+
+struct A
+{
+ long a;
+ struct B *foo;
+};
+
+static struct A *foo __attribute__((used));
+
+int main()
+{
+}
diff --git a/gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c
new file mode 100644
index 0000000..aa2d177
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-2.c
@@ -0,0 +1,16 @@
+struct B;
+struct A
+{
+ long a;
+ struct B *foo;
+ struct C *bar;
+};
+
+struct C
+{
+ struct B *foo;
+ int b;
+};
+
+static struct C *foo __attribute__((used));
+static struct A *bar __attribute__((used));
diff --git a/gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c
new file mode 100644
index 0000000..19947e8
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-3.c
@@ -0,0 +1,3 @@
+struct A { struct B *foo; };
+static struct A *a __attribute__((__used__));
+static struct A *conflicty __attribute__((__used__));
diff --git a/gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c
new file mode 100644
index 0000000..6e0c957
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/cross-tu-cyclic-4.c
@@ -0,0 +1,4 @@
+struct A { struct B *foo; };
+struct B { struct B *next; };
+static struct A *a __attribute__((__used__));
+static struct B *conflicty __attribute__((__used__));
diff --git a/gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp b/gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp
new file mode 100644
index 0000000..f617f1b
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/cross-tu-cyclic.exp
@@ -0,0 +1,43 @@
+# Copyright 2021 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/>.
+
+# This file is a subset of ptype.exp written by Rob Savoye. (rob@cygnus.com)
+
+if [skip_ctf_tests] {
+ unsupported "no CTF debug format support, or CTF disabled in GDB"
+ return 0
+}
+
+standard_testfile cross-tu-cyclic-1.c cross-tu-cyclic-2.c \
+ cross-tu-cyclic-3.c cross-tu-cyclic-4.c
+
+# Using `-gctf` generates full-fledged CTF debug information.
+set opts "additional_flags=-gctf -Wl,--export-dynamic"
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $srcfile2 $srcfile3 $srcfile4] \
+ [list $opts nowarnings]] } {
+ return 0
+}
+
+# Create and source the file that provides information about the compiler
+# used to compile the test case.
+if [get_compiler_info] {
+ return -1
+}
+
+# Same thing with struct and union.
+gdb_test "ptype struct A" "type = struct A \{\[\r\n\]+\[ \t\]+struct B \\*foo;\[\r\n\]+\}.*" "ptype structure A"
+gdb_test "ptype struct B" "type = struct B \{\[\r\n\]+\[ \t\]+struct B \\*next;\[\r\n\]+\}.*" "ptype structure B"
+gdb_test "ptype struct C" "type = struct C \{\[\r\n\]+\[ \t\]+struct B \\*foo;\[\r\n\]+\[ \t\]+int b;\[\r\n\]+\}.*" "ptype structure C"
diff --git a/gdb/testsuite/gdb.ctf/ctf-a.c b/gdb/testsuite/gdb.ctf/ctf-a.c
new file mode 100644
index 0000000..9aa2a8f
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/ctf-a.c
@@ -0,0 +1,32 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2021 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/>. */
+
+#include "ctf-a.h"
+
+static struct A a __attribute__((used));
+
+extern struct C *foo ();
+extern int bar ();
+
+int main ()
+{
+ struct C *cp;
+ cp = foo ();
+ if (cp)
+ return bar ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.ctf/ctf-a.h b/gdb/testsuite/gdb.ctf/ctf-a.h
new file mode 100644
index 0000000..297d740
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/ctf-a.h
@@ -0,0 +1,22 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2021 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/>. */
+
+struct A {
+ struct B *b;
+ struct A *next;
+};
+
diff --git a/gdb/testsuite/gdb.ctf/ctf-b.c b/gdb/testsuite/gdb.ctf/ctf-b.c
new file mode 100644
index 0000000..c3a8ce5
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/ctf-b.c
@@ -0,0 +1,25 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2021 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/>. */
+
+#include "ctf-b.h"
+
+static struct B b __attribute__((used));
+
+int bar ()
+{
+ return b.wombat;
+}
diff --git a/gdb/testsuite/gdb.ctf/ctf-b.h b/gdb/testsuite/gdb.ctf/ctf-b.h
new file mode 100644
index 0000000..9dbdd7d
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/ctf-b.h
@@ -0,0 +1,22 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2021 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/>. */
+
+struct B {
+ struct C *c;
+ int wombat;
+};
+
diff --git a/gdb/testsuite/gdb.ctf/ctf-c.c b/gdb/testsuite/gdb.ctf/ctf-c.c
new file mode 100644
index 0000000..b4051b3
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/ctf-c.c
@@ -0,0 +1,25 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2021 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/>. */
+
+#include "ctf-c.h"
+
+static struct C c __attribute__((used));
+
+struct C * foo ()
+{
+ return &c;
+}
diff --git a/gdb/testsuite/gdb.ctf/ctf-c.h b/gdb/testsuite/gdb.ctf/ctf-c.h
new file mode 100644
index 0000000..fb18157
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/ctf-c.h
@@ -0,0 +1,21 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2021 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/>. */
+
+struct C {
+ struct A *a;
+ int b;
+};
diff --git a/gdb/testsuite/gdb.ctf/funcreturn.exp b/gdb/testsuite/gdb.ctf/funcreturn.exp
index 874160e..4443c2d 100644
--- a/gdb/testsuite/gdb.ctf/funcreturn.exp
+++ b/gdb/testsuite/gdb.ctf/funcreturn.exp
@@ -26,8 +26,8 @@ if [target_info exists no_long_long] {
standard_testfile whatis.c
-# Using `-gt` generates full-fledged CTF debug information.
-set opts "additional_flags=-gt -Wl,--export-dynamic"
+# Using `-gctf` generates full-fledged CTF debug information.
+set opts "additional_flags=-gctf -Wl,--export-dynamic"
if { [prepare_for_testing "failed to prepare" ${testfile} \
[list $srcfile] [list $opts nowarnings]] } {
diff --git a/gdb/testsuite/gdb.ctf/multi.exp b/gdb/testsuite/gdb.ctf/multi.exp
new file mode 100644
index 0000000..fbed20e
--- /dev/null
+++ b/gdb/testsuite/gdb.ctf/multi.exp
@@ -0,0 +1,42 @@
+# Copyright 2021 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/>.
+
+# This file is a subset of ptype.exp written by Rob Savoye. (rob@cygnus.com)
+
+if [skip_ctf_tests] {
+ unsupported "no CTF debug format support, or CTF disabled in GDB"
+ return 0
+}
+
+standard_testfile ctf-a.c ctf-b.c ctf-c.c
+
+# Using `-gctf` generates full-fledged CTF debug information.
+set opts "additional_flags=-gctf -Wl,--export-dynamic"
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $srcfile2 $srcfile3] \
+ [list $opts nowarnings]] } {
+ return 0
+}
+
+# Create and source the file that provides information about the compiler
+# used to compile the test case.
+if [get_compiler_info] {
+ return -1
+}
+
+# Same thing with struct and union.
+gdb_test "ptype struct A" "type = struct A \{\[\r\n\]+\[ \t\]+struct B \\*b;\[\r\n\]+\[ \t\]+struct A \\*next;\[\r\n\]+\}.*" "ptype structure A"
+gdb_test "ptype struct B" "type = struct B \{\[\r\n\]+\[ \t\]+struct C \\*c;\[\r\n\]+\[ \t\]+int \\wombat;\[\r\n\]+\}.*" "ptype structure B"
+gdb_test "ptype struct C" "type = struct C \{\[\r\n\]+\[ \t\]+struct A \\*a;\[\r\n\]+\[ \t\]+int b;\[\r\n\]+\}.*" "ptype structure C"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 929e6b1..b7f3a57 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -7737,7 +7737,7 @@ proc cmp_file_string { file str msg } {
}
}
-# Does the compiler support CTF debug output using '-gt' compiler
+# Does the compiler support CTF debug output using '-gctf' compiler
# flag? If not then we should skip these tests. We should also
# skip them if libctf was explicitly disabled.
@@ -7752,7 +7752,7 @@ gdb_caching_proc skip_ctf_tests {
int main () {
return 0;
}
- } executable "additional_flags=-gt"]
+ } executable "additional_flags=-gctf"]
return [expr {!$can_ctf}]
}