This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][gdb/testsuite] Test skip_libstdcxx_probe_tests in mi-catch-cpp-exceptions.exp


Hi,

On a system without SDT probes in libstdc++, we run into:
...
FAIL: gdb.mi/mi-catch-cpp-exceptions.exp: all with invalid regexp: run until \
  breakpoint in main (unknown output after running)
...

The test-case uses a regexp argument for the catch throw/rethrow/catch
command, which is only supported on systems with SDT probes in libstdc++.

Fix this by marking the portions of the test-case that use a regexp argument
as unsupported on a system without SDT probes.

Tested on x86_64-linux.

OK for trunk?

Thanks,
- Tom

[gdb/testsuite] Test skip_libstdcxx_probe_tests in mi-catch-cpp-exceptions.exp

gdb/testsuite/ChangeLog:

2019-07-25  Tom de Vries  <tdevries@suse.de>

	PR testsuite/24830
	* gdb.mi/mi-catch-cpp-exceptions.exp: Call
	mi_skip_libstdcxx_probe_tests, and skip unsupported tests.
	* lib/gdb.exp (skip_libstdcxx_probe_tests_prompt): Factor out of ...
	(skip_libstdcxx_probe_tests): ... here.
	* lib/mi-support.exp (mi_skip_libstdcxx_probe_tests): New proc.

---
 gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp | 99 +++++++++++++++---------
 gdb/testsuite/lib/gdb.exp                        | 17 ++--
 gdb/testsuite/lib/mi-support.exp                 |  7 ++
 3 files changed, 79 insertions(+), 44 deletions(-)

diff --git a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
index 9b64fb14f2..029dc1bd02 100644
--- a/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
+++ b/gdb/testsuite/gdb.mi/mi-catch-cpp-exceptions.exp
@@ -27,6 +27,17 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
     return -1
 }
 
+if [mi_gdb_start] {
+    continue
+}
+mi_delete_breakpoints
+mi_gdb_reinitialize_dir $srcdir/$subdir
+mi_gdb_load ${binfile}
+if {![mi_run_to_main]} {
+    return -1
+}
+set libstdcxx_probe_tests_supported [mi_skip_libstdcxx_probe_tests]
+
 # Grab some line numbers we'll need.
 set catch_1_lineno [gdb_get_line_number "Catch 1"]
 set catch_2_lineno [gdb_get_line_number "Catch 2"]
@@ -123,36 +134,44 @@ with_test_prefix "-catch-catch" {
     continue_to_breakpoint_in_main
 }
 
-# Now check that all of the command with a regexp that doesn't match,
-# don't trigger.
-with_test_prefix "all with invalid regexp" {
-    restart_for_test
-    setup_catchpoint "throw" "-r blahblah"
-    setup_catchpoint "rethrow" "-r woofwoof"
-    setup_catchpoint "catch" "-r miowmiow"
-    continue_to_breakpoint_in_main
+if { $libstdcxx_probe_tests_supported  == 1 } {
+    # Now check that all of the command with a regexp that doesn't match,
+    # don't trigger.
+    with_test_prefix "all with invalid regexp" {
+	restart_for_test
+	setup_catchpoint "throw" "-r blahblah"
+	setup_catchpoint "rethrow" "-r woofwoof"
+	setup_catchpoint "catch" "-r miowmiow"
+	continue_to_breakpoint_in_main
+    }
+} else {
+    unsupported "all with invalid regexp"
 }
 
-# Now check that all of the commands with a regexp that does match,
-# still trigger.
-with_test_prefix "all with valid regexp" {
-    restart_for_test
-    setup_catchpoint "throw" "-r my_ex"
-    setup_catchpoint "rethrow" "-r _except"
-    setup_catchpoint "catch" "-r my_exception"
-    continue_to_next_exception "bar" "${throw_1_lineno}" "throw 1"
-    continue_to_next_exception "foo" "${catch_1_lineno}" "catch 1"
-    continue_to_next_exception "bar" "${throw_1_lineno}" "throw 2"
-    continue_to_next_exception "foo" "${catch_1_lineno}" "catch 2"
-    continue_to_next_exception "foo" "${throw_2_lineno}" "rethrow 1"
-    continue_to_next_exception "main" "${catch_2_lineno}" "catch 3"
-    continue_to_next_exception "bar" "${throw_1_lineno}" "throw 3"
-    continue_to_next_exception "foo" "${catch_1_lineno}" "catch 4"
-    continue_to_next_exception "bar" "${throw_1_lineno}" "throw 4"
-    continue_to_next_exception "foo" "${catch_1_lineno}" "catch 5"
-    continue_to_next_exception "foo" "${throw_2_lineno}" "rethrow 2"
-    continue_to_next_exception "main" "${catch_2_lineno}" "catch 6"
-    continue_to_breakpoint_in_main
+if { $libstdcxx_probe_tests_supported  == 1 } {
+    # Now check that all of the commands with a regexp that does match,
+    # still trigger.
+    with_test_prefix "all with valid regexp" {
+	restart_for_test
+	setup_catchpoint "throw" "-r my_ex"
+	setup_catchpoint "rethrow" "-r _except"
+	setup_catchpoint "catch" "-r my_exception"
+	continue_to_next_exception "bar" "${throw_1_lineno}" "throw 1"
+	continue_to_next_exception "foo" "${catch_1_lineno}" "catch 1"
+	continue_to_next_exception "bar" "${throw_1_lineno}" "throw 2"
+	continue_to_next_exception "foo" "${catch_1_lineno}" "catch 2"
+	continue_to_next_exception "foo" "${throw_2_lineno}" "rethrow 1"
+	continue_to_next_exception "main" "${catch_2_lineno}" "catch 3"
+	continue_to_next_exception "bar" "${throw_1_lineno}" "throw 3"
+	continue_to_next_exception "foo" "${catch_1_lineno}" "catch 4"
+	continue_to_next_exception "bar" "${throw_1_lineno}" "throw 4"
+	continue_to_next_exception "foo" "${catch_1_lineno}" "catch 5"
+	continue_to_next_exception "foo" "${throw_2_lineno}" "rethrow 2"
+	continue_to_next_exception "main" "${catch_2_lineno}" "catch 6"
+	continue_to_breakpoint_in_main
+    }
+} else {
+    unsupported "all with valid regexp"
 }
 
 # Check that the temporary switch works on its own.
@@ -167,14 +186,18 @@ with_test_prefix "all with -t" {
     continue_to_breakpoint_in_main
 }
 
-# Check that the temporary switch works when used with a regexp.
-restart_for_test
-with_test_prefix "all with -t and regexp" {
-    setup_catchpoint "throw" "-t -r my_ex"
-    setup_catchpoint "rethrow" "-t -r _except"
-    setup_catchpoint "catch" "-t -r my_exception"
-    continue_to_next_exception "bar" "${throw_1_lineno}" "throw 1"
-    continue_to_next_exception "foo" "${catch_1_lineno}" "catch 1"
-    continue_to_next_exception "foo" "${throw_2_lineno}" "rethrow 1"
-    continue_to_breakpoint_in_main
+if { $libstdcxx_probe_tests_supported  == 1 } {
+    # Check that the temporary switch works when used with a regexp.
+    restart_for_test
+    with_test_prefix "all with -t and regexp" {
+	setup_catchpoint "throw" "-t -r my_ex"
+	setup_catchpoint "rethrow" "-t -r _except"
+	setup_catchpoint "catch" "-t -r my_exception"
+	continue_to_next_exception "bar" "${throw_1_lineno}" "throw 1"
+	continue_to_next_exception "foo" "${catch_1_lineno}" "catch 1"
+	continue_to_next_exception "foo" "${throw_2_lineno}" "rethrow 1"
+	continue_to_breakpoint_in_main
+    }
+} else {
+    unsupported "all with -t and regexp"
 }
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 49ec8b2a55..54cee2ec41 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3104,22 +3104,27 @@ proc skip_unwinder_tests {} {
 
 # Return 0 if we should skip tests that require the libstdc++ stap
 # probes.  This must be invoked while gdb is running, after shared
-# libraries have been loaded.
-
-proc skip_libstdcxx_probe_tests {} {
-    global gdb_prompt
+# libraries have been loaded.  PROMPT_REGEXP is the expected prompt.
 
+proc skip_libstdcxx_probe_tests_prompt { prompt_regexp } {
     set ok 0
     gdb_test_multiple "info probe" "check for stap probe in libstdc++" {
-	-re ".*libstdcxx.*catch.*\r\n$gdb_prompt $" {
+	-re ".*libstdcxx.*catch.*\r\n$prompt_regexp" {
 	    set ok 1
 	}
-	-re "\r\n$gdb_prompt $" {
+	-re "\r\n$prompt_regexp" {
 	}
     }
     return $ok
 }
 
+# As skip_libstdcxx_probe_tests_prompt, with gdb_prompt.
+
+proc skip_libstdcxx_probe_tests {} {
+    global gdb_prompt
+    return [skip_libstdcxx_probe_tests_prompt "$gdb_prompt $"]
+}
+
 # Return 1 if we should skip tests of the "compile" feature.
 # This must be invoked after the inferior has been started.
 
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 8c2c7c84ed..dcb472b1d6 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -2601,6 +2601,13 @@ proc mi_skip_python_tests {} {
     return [skip_python_tests_prompt "$mi_gdb_prompt$"]
 }
 
+# As skip_libstdcxx_probe_tests_prompt, with mi_gdb_prompt.
+
+proc mi_skip_libstdcxx_probe_tests {} {
+    global mi_gdb_prompt
+    return [skip_libstdcxx_probe_tests_prompt "$mi_gdb_prompt$"]
+}
+
 # Check whether we're testing with the remote or extended-remote
 # targets.
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]