aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.cp')
-rw-r--r--gdb/testsuite/gdb.cp/step-and-next-inline.cc66
-rw-r--r--gdb/testsuite/gdb.cp/step-and-next-inline.exp119
-rw-r--r--gdb/testsuite/gdb.cp/step-and-next-inline.h38
3 files changed, 223 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/step-and-next-inline.cc b/gdb/testsuite/gdb.cp/step-and-next-inline.cc
new file mode 100644
index 0000000..d923cc5
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/step-and-next-inline.cc
@@ -0,0 +1,66 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2019-2020 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/>. */
+
+#ifdef USE_NEXT_INLINE_H
+
+#include "step-and-next-inline.h"
+
+#else /* USE_NEXT_INLINE_H */
+
+/* The code below must remain identical to the code in
+ step-and-next-inline.h. */
+
+#include <stdlib.h>
+
+struct tree
+{
+ volatile int x;
+ volatile int z;
+};
+
+#define TREE_TYPE(NODE) (*tree_check (NODE, 0))
+
+inline tree *
+tree_check (tree *t, int i)
+{
+ if (t->x != i)
+ abort();
+ tree *x = t;
+ return x;
+}
+
+#endif /* USE_NEXT_INLINE_H */
+
+int __attribute__((noinline, noclone))
+get_alias_set (tree *t)
+{
+ if (t != NULL
+ && TREE_TYPE (t).z != 1
+ && TREE_TYPE (t).z != 2
+ && TREE_TYPE (t).z != 3)
+ return 0;
+ return 1;
+}
+
+tree xx;
+
+int
+main()
+{
+ get_alias_set (&xx);
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.cp/step-and-next-inline.exp b/gdb/testsuite/gdb.cp/step-and-next-inline.exp
new file mode 100644
index 0000000..acec48b
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/step-and-next-inline.exp
@@ -0,0 +1,119 @@
+# Copyright 2019-2020 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/>.
+
+standard_testfile .cc
+
+# Compile the test source with USE_NEXT_INLINE_H defined (when
+# use_header is true), or not defined.
+proc do_test { use_header } {
+ global srcfile testfile
+
+ set options {c++ debug nowarnings optimize=-O2\ -gstatement-frontiers}
+ if { $use_header } {
+ lappend options additional_flags=-DUSE_NEXT_INLINE_H
+ set executable "$testfile-with-header"
+ set hdrfile "step-and-next-inline.h"
+ set prefix "use_header"
+ } else {
+ set executable "$testfile-no-header"
+ set hdrfile "$srcfile"
+ set prefix "no_header"
+ }
+
+ if { [prepare_for_testing "failed to prepare" $executable \
+ $srcfile $options] } {
+ return -1
+ }
+
+ with_test_prefix $prefix {
+
+ if ![runto_main] {
+ fail "can't run to main"
+ return
+ }
+
+ gdb_test "bt" "\\s*\\#0\\s+main.*" "in main"
+ gdb_test "step" ".*" "step into get_alias_set"
+ gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
+ "not in inline 1"
+ # It's possible that this first failure (when not using a header
+ # file) is GCC's fault, though the remaining failures would best
+ # be fixed by adding location views support (though it could be
+ # that some easier heuristic could be figured out). Still, it is
+ # not certain that the first failure wouldn't also be fixed by
+ # having location view support, so for now it is tagged as such.
+ if {!$use_header} { setup_kfail "*-*-*" symtab/25507 }
+ gdb_test "next" ".*TREE_TYPE.*" "next step 1"
+ gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
+ "not in inline 2"
+ gdb_test "next" ".*TREE_TYPE.*" "next step 2"
+ gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
+ "not in inline 3"
+ if {!$use_header} { setup_kfail "*-*-*" symtab/25507 }
+ gdb_test "next" ".*TREE_TYPE.*" "next step 3"
+ gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
+ "not in inline 4"
+ if {!$use_header} { setup_kfail "*-*-*" symtab/25507 }
+ gdb_test "next" "return 0.*" "next step 4"
+ gdb_test "bt" \
+ "\\s*\\#0\\s+(main|get_alias_set)\[^\r\]*${srcfile}:.*" \
+ "not in inline 5"
+
+ if {!$use_header} {
+ # With the debug from GCC 10.x (and earlier) GDB is currently
+ # unable to successfully complete the following tests when we
+ # are not using a header file.
+ kfail symtab/25507 "stepping tests"
+ return
+ }
+
+ clean_restart ${executable}
+
+ if ![runto_main] {
+ fail "can't run to main pass 2"
+ return
+ }
+
+ gdb_test "bt" "\\s*\\#0\\s+main.*" "in main pass 2"
+ gdb_test "step" ".*" "step into get_alias_set pass 2"
+ gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
+ "in get_alias_set pass 2"
+ gdb_test "step" ".*TREE_TYPE.*" "step 1"
+ gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
+ "not in inline 1 pass 2"
+ gdb_test "step" ".*if \\(t->x != i\\).*" "step 2"
+ gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
+ "in inline 1 pass 2"
+ gdb_test "step" ".*TREE_TYPE.*" "step 3"
+ gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
+ "not in inline 2 pass 2"
+ gdb_test "step" ".*if \\(t->x != i\\).*" "step 4"
+ gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
+ "in inline 2 pass 2"
+ gdb_test "step" ".*TREE_TYPE.*" "step 5"
+ gdb_test "bt" "\\s*\\#0\\s+get_alias_set\[^\r\]*${srcfile}:.*" \
+ "not in inline 3 pass 2"
+ gdb_test "step" ".*if \\(t->x != i\\).*" "step 6"
+ gdb_test "bt" "\\s*\\#0\\s+\[^\r\]*tree_check\[^\r\]*${hdrfile}:.*" \
+ "in inline 3 pass 2"
+ gdb_test "step" "return 0.*" "step 7"
+ gdb_test "bt" \
+ "\\s*\\#0\\s+(main|get_alias_set)\[^\r\]*${srcfile}:.*" \
+ "not in inline 4 pass 2"
+ }
+}
+
+do_test 0
+do_test 1
diff --git a/gdb/testsuite/gdb.cp/step-and-next-inline.h b/gdb/testsuite/gdb.cp/step-and-next-inline.h
new file mode 100644
index 0000000..6c6d90a
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/step-and-next-inline.h
@@ -0,0 +1,38 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2019-2020 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/>. */
+
+/* The code below must remain identical to the block of code in
+ step-and-next-inline.cc. */
+
+#include <stdlib.h>
+
+struct tree
+{
+ volatile int x;
+ volatile int z;
+};
+
+#define TREE_TYPE(NODE) (*tree_check (NODE, 0))
+
+inline tree *
+tree_check (tree *t, int i)
+{
+ if (t->x != i)
+ abort();
+ tree *x = t;
+ return x;
+}