-# Copyright 2011-2017 Free Software Foundation, Inc.
+# Copyright 2011-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
load_lib "ada.exp"
+if { [skip_ada_tests] } { return -1 }
+
standard_ada_testfile foo
if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } {
# 1. Try catching all exceptions. #
####################################
-if ![mi_run_to_main] then {
- fail "cannot run to main, testcase aborted"
- return 0
+with_test_prefix "scenario 1" {
+ if ![mi_run_to_main] then {
+ fail "cannot run to main, testcase aborted"
+ return 0
+ }
}
mi_gdb_test "-catch-exception" \
- "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"all Ada exceptions\",.*}" \
+ "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"all Ada exceptions\",.*}" \
"catch all exceptions"
# Continue to caught exception.
-proc continue_to_exception { exception_name test } {
+proc continue_to_exception { exception_name exception_message test } {
global hex any_nb
mi_send_resuming_command "exec-continue" "$test"
# Match console stream output.
gdb_expect {
- -re " $exception_name at $hex in foo " {
+ -re " $exception_name\( \\($exception_message\\)\)? at $hex in foo " {
}
timeout {
fail "$test (timeout)"
# Now MI stream output.
mi_expect_stop \
- "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"$exception_name" \
+ "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"$exception_name\(\",exception-message=\"$exception_message\)?" \
"foo" "" ".*" ".*" \
".*" \
$test
}
continue_to_exception \
- "CONSTRAINT_ERROR" \
+ "CONSTRAINT_ERROR" "foo\\.adb:$decimal explicit raise" \
"continue until CE caught by all-exceptions catchpoint"
continue_to_exception \
- "PROGRAM_ERROR" \
+ "PROGRAM_ERROR" "foo\\.adb:$decimal explicit raise" \
"continue until PE caught by all-exceptions catchpoint"
################################################
# - continue, we should see the unhandled Constrait_Error exception
# - continue, the program exits.
-if ![mi_run_to_main] then {
- fail "cannot run to main, testcase aborted"
- return 0
+with_test_prefix "scenario 2" {
+ if ![mi_run_to_main] then {
+ fail "cannot run to main, testcase aborted"
+ return 0
+ }
}
mi_gdb_test "-catch-exception -e Program_Error" \
- "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"`Program_Error' Ada exception\",.*}" \
+ "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"`Program_Error' Ada exception\",.*}" \
"catch Program_Error"
mi_gdb_test "-catch-assert" \
- "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"failed Ada assertions\",.*}" \
+ "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"failed Ada assertions\",.*}" \
"catch assert failures"
mi_gdb_test "-catch-exception -u" \
- "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",addr=\"$hex\",what=\"unhandled Ada exceptions\",.*}" \
+ "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"unhandled Ada exceptions\",.*}" \
"catch unhandled exceptions"
mi_execute_to "exec-continue" \
- "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"PROGRAM_ERROR" \
+ "breakpoint-hit\",disp=\"keep\",bkptno=\"$any_nb\",exception-name=\"PROGRAM_ERROR(\",exception-message=\"foo\\.adb:$decimal explicit raise)?" \
"foo" "" ".*" ".*" \
".*" \
"continue to exception catchpoint hit"