1# Copyright 2023-2024 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
16load_lib ada.exp
17load_lib dap-support.exp
18
19require allow_cplus_tests allow_dap_tests
20
21standard_testfile .cc
22
23if {[build_executable ${testfile}.exp $testfile $srcfile {debug c++}] == -1} {
24    return
25}
26
27if {[dap_initialize] == ""} {
28    return
29}
30
31set obj [dap_check_request_and_response "set exception catchpoints" \
32	     setExceptionBreakpoints \
33	     {o filters [a [s throw] [s rethrow] [s catch]]}]
34
35set bps [dict get [lindex $obj 0] body breakpoints]
36# We should get three responses, because we requested three
37# breakpoints.
38gdb_assert {[llength $bps] == 3} "three breakpoints"
39
40dap_check_request_and_response "configurationDone" configurationDone
41
42if {[dap_launch $testfile] == ""} {
43    return
44}
45dap_wait_for_event_and_check "stopped at throw" stopped \
46    "body reason" breakpoint \
47    "body hitBreakpointIds" 1
48
49dap_check_request_and_response "continue to catch" continue \
50    {o threadId [i 1]}
51dap_wait_for_event_and_check "stopped at catch" stopped \
52    "body reason" breakpoint \
53    "body hitBreakpointIds" 3
54
55dap_check_request_and_response "continue to rethrow" continue \
56    {o threadId [i 1]}
57dap_wait_for_event_and_check "stopped at rethrow" stopped \
58    "body reason" breakpoint \
59    "body hitBreakpointIds" 2
60
61dap_shutdown
62