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

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.

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.
This commit is contained in:
Tom de Vries
2019-07-25 18:39:31 +02:00
parent d079b9c04a
commit 297989a10c
4 changed files with 88 additions and 44 deletions

View File

@ -1,3 +1,12 @@
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.
2019-07-24 Tom de Vries <tdevries@suse.de>
PR testsuite/24807

View File

@ -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"
}

View File

@ -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.

View File

@ -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.