public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [pushed 1/3] [gdb/testsuite] Handle gdb.cp/*.exp with older compiler
@ 2023-08-28 11:47 Tom de Vries
  2023-08-28 11:47 ` [pushed 2/3] [gdb/testsuite] Refactor gdb.cp/subtypes.exp Tom de Vries
  2023-08-28 11:47 ` [pushed 3/3] [gdb/testsuite] Add xfail in gdb.cp/subtypes.exp Tom de Vries
  0 siblings, 2 replies; 3+ messages in thread
From: Tom de Vries @ 2023-08-28 11:47 UTC (permalink / raw)
  To: gdb-patches

When running test-cases gdb.cp/*.exp with gcc 4.8.4, I run into compilation
failures due to the test-cases requiring c++11 and the compiler defaulting
to less than that.

Fix this by compiling with -std=c++11.

This exposes two FAILs in gdb/testsuite/gdb.cp/empty-enum.exp due to
gcc PR debug/16063, so xfail those.

Also require have_compile_flag -std=c++17 in gdb.cp/constexpr-field.exp to
prevent compilation failure.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.cp/casts.exp            |  7 ++++-
 gdb/testsuite/gdb.cp/constexpr-field.exp  |  1 +
 gdb/testsuite/gdb.cp/empty-enum.exp       | 35 +++++++++++++++++++++--
 gdb/testsuite/gdb.cp/koenig.exp           |  9 ++++--
 gdb/testsuite/gdb.cp/method-call-in-c.exp |  6 +++-
 gdb/testsuite/gdb.cp/paramless.exp        |  7 ++++-
 gdb/testsuite/gdb.cp/templates.exp        |  2 ++
 gdb/testsuite/gdb.cp/typed-enum.exp       |  7 ++++-
 8 files changed, 65 insertions(+), 9 deletions(-)

diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp
index ac798f9070f..41bb1259270 100644
--- a/gdb/testsuite/gdb.cp/casts.exp
+++ b/gdb/testsuite/gdb.cp/casts.exp
@@ -29,7 +29,12 @@ require allow_cplus_tests
 
 standard_testfile .cc casts03.cc
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+set opts {}
+lappend opts debug
+lappend opts c++
+lappend opts additional_flags=-std=c++11
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.cp/constexpr-field.exp b/gdb/testsuite/gdb.cp/constexpr-field.exp
index 18dcb0e91b7..dd8bf9a2e5d 100644
--- a/gdb/testsuite/gdb.cp/constexpr-field.exp
+++ b/gdb/testsuite/gdb.cp/constexpr-field.exp
@@ -16,6 +16,7 @@
 # This file is part of the gdb testsuite.
 
 require allow_cplus_tests
+require {have_compile_flag -std=c++17}
 
 standard_testfile .cc
 
diff --git a/gdb/testsuite/gdb.cp/empty-enum.exp b/gdb/testsuite/gdb.cp/empty-enum.exp
index 83cb8cb3973..9ab3abf14b7 100644
--- a/gdb/testsuite/gdb.cp/empty-enum.exp
+++ b/gdb/testsuite/gdb.cp/empty-enum.exp
@@ -29,7 +29,11 @@
 
 standard_testfile .cc
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} {
+set opts {}
+lappend opts debug
+lappend opts additional_flags=-std=c++11
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
     return -1
 }
 
@@ -44,5 +48,30 @@ gdb_continue_to_breakpoint "stop in breakpt"
 gdb_test "print arg1" " = 8"
 gdb_test "print arg2" " = 4"
 
-gdb_test "ptype arg1" "type = enum enum1 : unsigned int \\{\\}"
-gdb_test "ptype arg2" "type = enum class enum2 : unsigned char \\{\\}"
+
+# Xfail for missing DW_AT_type in DW_TAG_enumeration_type, gcc PR debug/16063.
+set have_xfail [expr [test_compiler_info gcc-*] && [gcc_major_version] < 5]
+
+gdb_test_multiple "ptype arg1" "" {
+    -re -wrap "type = enum enum1 : unsigned int \\{\\}" {
+	pass $gdb_test_name
+    }
+    -re -wrap "type = enum enum1 \\{\\}" {
+	if { $have_xfail } {
+	    setup_xfail *-*-* gcc/16063
+	}
+	fail $gdb_test_name
+    }
+}
+
+gdb_test_multiple "ptype arg2" "" {
+    -re -wrap "type = enum class enum2 : unsigned char \\{\\}" {
+	pass $gdb_test_name
+    }
+    -re -wrap "type = enum class enum2 \\{\\}" {
+	if { $have_xfail } {
+	    setup_xfail *-*-* gcc/16063
+	}
+	fail $gdb_test_name
+    }
+}
diff --git a/gdb/testsuite/gdb.cp/koenig.exp b/gdb/testsuite/gdb.cp/koenig.exp
index 5343f2cbf06..dbec6d2e7f2 100644
--- a/gdb/testsuite/gdb.cp/koenig.exp
+++ b/gdb/testsuite/gdb.cp/koenig.exp
@@ -15,8 +15,13 @@
 
 standard_testfile .cc
 
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
-      {debug c++ additional_flags=-Wno-unused-comparison}] } {
+set opts {}
+lappend opts debug
+lappend opts c++
+lappend opts additional_flags=-Wno-unused-comparison
+lappend opts additional_flags=-std=c++11
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
      return -1
 }
 
diff --git a/gdb/testsuite/gdb.cp/method-call-in-c.exp b/gdb/testsuite/gdb.cp/method-call-in-c.exp
index 269657068cf..1c18d81104e 100644
--- a/gdb/testsuite/gdb.cp/method-call-in-c.exp
+++ b/gdb/testsuite/gdb.cp/method-call-in-c.exp
@@ -20,7 +20,11 @@
 
 standard_testfile .cc
 
-if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
+set opts {}
+lappend opts debug
+lappend opts additional_flags=-std=c++11
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile $opts] } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.cp/paramless.exp b/gdb/testsuite/gdb.cp/paramless.exp
index 579f363d6a0..895b449f146 100644
--- a/gdb/testsuite/gdb.cp/paramless.exp
+++ b/gdb/testsuite/gdb.cp/paramless.exp
@@ -21,7 +21,12 @@ require allow_cplus_tests
 
 standard_testfile .cc
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+set opts {}
+lappend opts debug
+lappend opts c++
+lappend opts additional_flags=-std=c++11
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.cp/templates.exp b/gdb/testsuite/gdb.cp/templates.exp
index ba21c4727d3..7603d89572a 100644
--- a/gdb/testsuite/gdb.cp/templates.exp
+++ b/gdb/testsuite/gdb.cp/templates.exp
@@ -22,6 +22,8 @@ require allow_cplus_tests
 standard_testfile .cc
 
 set flags [list debug c++]
+lappend flags additional_flags=-std=c++11
+
 if { [test_compiler_info gcc-*] && [gcc_major_version] >= 10 } {
     # Work around PR gcc/101452.
     lappend flags additional_flags=-DGCC_BUG
diff --git a/gdb/testsuite/gdb.cp/typed-enum.exp b/gdb/testsuite/gdb.cp/typed-enum.exp
index 1d11fb5a302..6a1df7053c6 100644
--- a/gdb/testsuite/gdb.cp/typed-enum.exp
+++ b/gdb/testsuite/gdb.cp/typed-enum.exp
@@ -19,7 +19,12 @@ require allow_cplus_tests
 
 standard_testfile .cc
 
-if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} {
+set opts {}
+lappend opts debug
+lappend opts c++
+lappend opts additional_flags=-std=c++11
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile $opts]} {
     return -1
 }
 

base-commit: 025e84f93566c8ced594ef48ddee1dec7e5b4cdd
-- 
2.35.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pushed 2/3] [gdb/testsuite] Refactor gdb.cp/subtypes.exp
  2023-08-28 11:47 [pushed 1/3] [gdb/testsuite] Handle gdb.cp/*.exp with older compiler Tom de Vries
@ 2023-08-28 11:47 ` Tom de Vries
  2023-08-28 11:47 ` [pushed 3/3] [gdb/testsuite] Add xfail in gdb.cp/subtypes.exp Tom de Vries
  1 sibling, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2023-08-28 11:47 UTC (permalink / raw)
  To: gdb-patches

Make test-case gdb.cp/subtypes.exp less repetitive by using foreach.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.cp/subtypes.exp | 40 +++++++++++++++++--------------
 1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/gdb/testsuite/gdb.cp/subtypes.exp b/gdb/testsuite/gdb.cp/subtypes.exp
index afad478cba3..48c9784dd68 100644
--- a/gdb/testsuite/gdb.cp/subtypes.exp
+++ b/gdb/testsuite/gdb.cp/subtypes.exp
@@ -33,23 +33,27 @@ if {[prepare_for_testing "failed to prepare" $testfile \
 gdb_test "ptype Outer::Inner::InnerInner" \
     "type = struct Outer::Inner::InnerInner.*"
 gdb_test "ptype Outer::Inner" "type = struct Outer::Inner.*"
-gdb_test "ptype main::Foo" "type = struct Foo.*"
-gdb_test "ptype main::Bar" "type = struct Bar.*"
-gdb_test "ptype main::Baz" "type = struct Baz.*"
+
+foreach s { Foo Bar Baz } {
+    gdb_test "ptype main::$s" "type = struct $s.*"
+}
+
 gdb_test "ptype Outer::Oenum" "type = enum class Outer::Oenum.*"
-gdb_test "ptype foobar<int>::Foo" "type = struct Foo.*"
-gdb_test "ptype foobar<int>::Bar" "type = struct Bar.*"
-gdb_test "ptype foobar<int>::Baz" "type = struct Baz.*"
-gdb_test "ptype foobar<char>::Foo" "type = struct Foo.*"
-gdb_test "ptype foobar<char>::Bar" "type = struct Bar.*"
-gdb_test "ptype foobar<char>::Baz" "type = struct Baz.*"
+
+foreach t { int char } {
+    foreach s { Foo Bar Baz } {
+	gdb_test "ptype foobar<$t>::$s" "type = struct $s.*"
+    }
+}
+
 gdb_breakpoint "Outer::Inner::doit" message
-gdb_breakpoint "main::Foo::doit" message
-gdb_breakpoint "main::Bar::doit" message
-gdb_breakpoint "main::Baz::doit" message
-gdb_breakpoint "foobar<int>(int)::Foo::doit" message
-gdb_breakpoint "foobar<int>(int)::Bar::doit" message
-gdb_breakpoint "foobar<int>(int)::Baz::doit" message
-gdb_breakpoint "foobar<char>(int)::Foo::doit" message
-gdb_breakpoint "foobar<char>(int)::Bar::doit" message
-gdb_breakpoint "foobar<char>(int)::Baz::doit" message
+
+foreach s { Foo Bar Baz } {
+    gdb_breakpoint "main::${s}::doit" message
+}
+
+foreach t { int char } {
+    foreach s { Foo Bar Baz } {
+	gdb_breakpoint "foobar<$t>(int)::${s}::doit" message
+    }
+}
-- 
2.35.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pushed 3/3] [gdb/testsuite] Add xfail in gdb.cp/subtypes.exp
  2023-08-28 11:47 [pushed 1/3] [gdb/testsuite] Handle gdb.cp/*.exp with older compiler Tom de Vries
  2023-08-28 11:47 ` [pushed 2/3] [gdb/testsuite] Refactor gdb.cp/subtypes.exp Tom de Vries
@ 2023-08-28 11:47 ` Tom de Vries
  1 sibling, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2023-08-28 11:47 UTC (permalink / raw)
  To: gdb-patches

When running test-case gdb.cp/subtypes.exp with gcc 4.8.4, we run into:
...
FAIL: gdb.cp/subtypes.exp: ptype main::Foo
FAIL: gdb.cp/subtypes.exp: ptype main::Bar
FAIL: gdb.cp/subtypes.exp: ptype main::Baz
FAIL: gdb.cp/subtypes.exp: ptype foobar<int>::Foo
FAIL: gdb.cp/subtypes.exp: ptype foobar<int>::Bar
FAIL: gdb.cp/subtypes.exp: ptype foobar<int>::Baz
FAIL: gdb.cp/subtypes.exp: ptype foobar<char>::Foo
FAIL: gdb.cp/subtypes.exp: ptype foobar<char>::Bar
FAIL: gdb.cp/subtypes.exp: ptype foobar<char>::Baz
...

The problem is gcc PR debug/55541, which generates a superfluous
DW_TAG_lexical_block.

Add a corresponding xfail.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.cp/subtypes.exp | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.cp/subtypes.exp b/gdb/testsuite/gdb.cp/subtypes.exp
index 48c9784dd68..11acd75029a 100644
--- a/gdb/testsuite/gdb.cp/subtypes.exp
+++ b/gdb/testsuite/gdb.cp/subtypes.exp
@@ -30,19 +30,43 @@ if {[prepare_for_testing "failed to prepare" $testfile \
     return -1
 }
 
+# Xfail for superfluous DW_TAG_lexical_block, gcc PR debug/55541.
+set have_xfail [expr [test_compiler_info gcc-*] && [gcc_major_version] < 5]
+
 gdb_test "ptype Outer::Inner::InnerInner" \
     "type = struct Outer::Inner::InnerInner.*"
 gdb_test "ptype Outer::Inner" "type = struct Outer::Inner.*"
 
 foreach s { Foo Bar Baz } {
-    gdb_test "ptype main::$s" "type = struct $s.*"
+    gdb_test_multiple "ptype main::$s" "" {
+	-re -wrap "type = struct $s.*" {
+	    pass $gdb_test_name
+	}
+	-re -wrap "No symbol \"$s\" in specified context\\." {
+	    if { $have_xfail } {
+		setup_xfail *-*-* gcc/55541
+	    }
+	    fail $gdb_test_name
+	}
+
+    }
 }
 
 gdb_test "ptype Outer::Oenum" "type = enum class Outer::Oenum.*"
 
 foreach t { int char } {
     foreach s { Foo Bar Baz } {
-	gdb_test "ptype foobar<$t>::$s" "type = struct $s.*"
+	gdb_test_multiple "ptype foobar<$t>::$s" "" {
+	    -re -wrap "type = struct $s.*" {
+		pass $gdb_test_name
+	    }
+	    -re -wrap "No symbol \"$s\" in specified context\\." {
+		if { $have_xfail } {
+		    setup_xfail *-*-* gcc/55541
+		}
+		fail $gdb_test_name
+	    }
+	}
     }
 }
 
-- 
2.35.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-28 11:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-28 11:47 [pushed 1/3] [gdb/testsuite] Handle gdb.cp/*.exp with older compiler Tom de Vries
2023-08-28 11:47 ` [pushed 2/3] [gdb/testsuite] Refactor gdb.cp/subtypes.exp Tom de Vries
2023-08-28 11:47 ` [pushed 3/3] [gdb/testsuite] Add xfail in gdb.cp/subtypes.exp Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).