1139749Simp# Copyright 2017-2023 Free Software Foundation, Inc.
2126177Srik#
3126177Srik# This program is free software; you can redistribute it and/or modify
4126177Srik# it under the terms of the GNU General Public License as published by
5126177Srik# the Free Software Foundation; either version 3 of the License, or
6126177Srik# (at your option) any later version.
7126177Srik#
8126177Srik# This program is distributed in the hope that it will be useful,
9126177Srik# but WITHOUT ANY WARRANTY; without even the implied warranty of
10126177Srik# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11126177Srik# GNU General Public License for more details.
12126177Srik#
13126177Srik# You should have received a copy of the GNU General Public License
14126177Srik# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15126177Srik
16126177Srikload_lib "ada.exp"
17126177Srik
18126177Srikif { [skip_ada_tests] } { return -1 }
19126177Srik
20126177Srikstandard_ada_testfile foo_p708_025
21126177Srik
22126177Srikif {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
23126177Srik    return -1
24126177Srik}
25126177Srik
26126177Srikclean_restart ${testfile}
27126177Srik
28126177Srikset bp_location [gdb_get_line_number "START" ${testdir}/pck.adb]
29126177Srikrunto "pck.adb:$bp_location"
30126177Srik
31126177Srik# Insert a watchpoint on local variable "result"
32126177Srik
33126177Srikgdb_test "watch result" \
34126177Srik         ".*atchpoint \[0-9\]+: result"
35126177Srik
36126177Srik# Insert a breakpoint we'll reach after returning from the current
37126177Srik# function.
38126177Srik
39126177Srikset bp_location [gdb_get_line_number "Do_Nothing" ${testdir}/foo_p708_025.adb]
40126177Srikgdb_test "break foo_p708_025.adb:$bp_location" \
41126177Srik         "Breakpoint \[0-9\]+ at.*: file .*foo_p708_025.adb, line \[0-9\]+."
42126177Srik
43126177Srik# This breakpoint will be there to stop us after we test what happens
44126177Srik# during a continue (see below...)
45126177Srik
46126177Srikgdb_test "break pck.increment" \
47126177Srik         "Breakpoint \[0-9\]+ at.*: file .*pck.adb, line \[0-9\]+."
48126177Srik
49126177Srik# Continue until we reach our watchpoint.  It isn't strictly necessary
50126177Srik# for our purpose that the watchpoint actually triggers, but this shows
51126177Srik# that the watchpoint exists and is active.
52126177Srikgdb_test "cont" \
53126177Srik         ".*atchpoint \[0-9\]+: result.*Old value = 8.*New value = 64.*" \
54126177Srik         "continuing to watchpoint hit"
55126177Srik
56126177Srik# Continue again.  We should be stopped at the (internal) breakpoint
57126177Srik# that we setup to delete the watchpoint as soon as the program leaves
58126177Srik# the current scope.
59126177Srik
60126177Srikgdb_test \
61126177Srik    "cont" \
62126177Srik    ".*atchpoint \[0-9\]+ deleted because the program has left the block.*" \
63126177Srik    "continuing until watchpoint automatic deletion"
64126177Srik
65126177Srik# Continue one more time.  We should be reaching one of the breakpoints
66126177Srik# (on the call to Do_Nothing) we set earlier.
67126177Srik
68126177Srikgdb_test "cont" \
69126177Srik         "Breakpoint \[0-9\]+.*Do_Nothing.*" \
70126177Srik         "continuing to breakpoint on call to Do_Nothing"
71126177Srik
72126177Srik# Do a next, to verify that it works...
73126177Srik
74126177Srikgdb_test "next" \
75126177Srik         ".* Call_Me;" \
76126177Srik         "next to call to Call_Me"
77126177Srik
78126177Srik# And finally, one more continue.
79126177Srik
80126177Srik
81126177Srikgdb_test "cont" \
82126177Srik         "Breakpoint \[0-9\]+.*pck\\.increment.*" \
83126177Srik         "continuing to breakpoint in pck.increment"
84126177Srik