]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.ada/mi_catch_ex_hand.exp
Use gnat_runtime_has_debug_info in Ada catchpoint tests
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.ada / mi_catch_ex_hand.exp
1 # Copyright 2011-2023 Free Software Foundation, Inc.
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 load_lib "ada.exp"
17
18 require allow_ada_tests gnat_runtime_has_debug_info
19
20 standard_ada_testfile foo
21
22 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug additional_flags=-gnata ]] != "" } {
23 return -1
24 }
25
26 load_lib mi-support.exp
27 set MIFLAGS "-i=mi"
28
29 mi_clean_restart $binfile
30
31 #############################################
32 # 1. Try catching all exceptions handlers. #
33 #############################################
34
35 with_test_prefix "scenario 1" {
36 if {[mi_runto_main] < 0} {
37 return 0
38 }
39 }
40
41 mi_gdb_test "-catch-handlers" \
42 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"all Ada exceptions handlers\",.*}" \
43 "catch all exceptions handlers"
44
45 # Continue to exception handler.
46
47 proc continue_to_exception_handler { test line } {
48
49 global decimal
50
51 mi_send_resuming_command "exec-continue" "$test"
52
53 # Now MI stream output.
54 mi_expect_stop \
55 "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"" \
56 "foo" "" ".*" "$line" \
57 ".*" \
58 $test
59 }
60
61 # We don't have the exception name info when stopping at the exception handlers
62 # catchpoints so we use source line to check if the inferior stops at the
63 # right location.
64
65 set bp_ce_location [gdb_get_line_number "BREAK1" ${testdir}/foo.adb]
66 continue_to_exception_handler \
67 "continue until CE handling caught by all-exceptions handlers catchpoint" \
68 "$bp_ce_location"
69
70 set bp_pe_location [gdb_get_line_number "BREAK2" ${testdir}/foo.adb]
71 continue_to_exception_handler \
72 "continue until PE handling caught by all-exceptions handlers catchpoint" \
73 "$bp_pe_location"
74
75 ##########################################################
76 # 2. Try catching only some of the exceptions handlers. #
77 ##########################################################
78
79 # Here is the scenario:
80 # - Restart the debugger from scratch, runto_main
81 # - We'll catch only "Constraint_Error handlers"
82 # - continue, we should stop at the Constraint_Error exception handler
83 # - continue, we should not stop at the Program_Error exception handler
84 # but exit instead.
85
86 with_test_prefix "scenario 2" {
87 mi_delete_breakpoints
88 if {[mi_runto_main] < 0} {
89 return 0
90 }
91 }
92
93 mi_gdb_test "-catch-handlers -e Constraint_Error" \
94 "\\^done,bkptno=\"$decimal\",bkpt={.*disp=\"keep\",enabled=\"y\",what=\"`Constraint_Error' Ada exception handlers\",.*}" \
95 "catch Constraint_Error"
96
97 mi_execute_to "exec-continue" \
98 "\"breakpoint-hit\",disp=\"keep\",bkptno=\"$decimal\",exception-name=\"exception\"" \
99 "foo" "" ".*" "$bp_ce_location" \
100 ".*" \
101 "continue to exception catchpoint hit"
102
103 # Exit the inferior.
104 mi_send_resuming_command "exec-continue" "continuing to inferior exit"
105 mi_expect_stop "exited-normally" "" "" "" "" "" "exit normally"
106
107 mi_gdb_exit