]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.ada/task_watch.exp
Automatic Copyright Year update after running gdb/copyright.py
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.ada / task_watch.exp
1 # Copyright 2009-2022 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 # Test task-specific watchpoints.
17
18 load_lib "ada.exp"
19
20 if { [skip_ada_tests] } { return -1 }
21
22 standard_ada_testfile foo
23
24 if {[gdb_compile_ada "${srcfile}" "${binfile}" executable {debug}] != ""} {
25 return -1
26 }
27
28 clean_restart ${testfile}
29
30 set bp_location [gdb_get_line_number "STOP_HERE" ${testdir}/foo.adb]
31 runto "foo.adb:$bp_location"
32
33 # Make sure that all tasks appear in the "info tasks" listing, and
34 # that the active task is the environment task.
35 gdb_test "info tasks" \
36 [join {" +ID +TID P-ID Pri State +Name" \
37 "\\* +1 .* main_task" \
38 " +2 .* task_list\\(1\\)" \
39 " +3 .* task_list\\(2\\)" \
40 " +4 .* task_list\\(3\\)"} \
41 "\r\n"] \
42 "info tasks before inserting breakpoint"
43
44 # Insert a watchpoint that should stop only if task 3 stops, and
45 # extract its number.
46 set bp_number -1
47 set test "watch -location value task 3"
48 gdb_test_multiple $test $test {
49 -re "atchpoint ($decimal): -location value\r\n$gdb_prompt $" {
50 set bp_number $expect_out(1,string)
51 pass $test
52 }
53 }
54
55 if {$bp_number < 0} {
56 return
57 }
58
59 # Continue to that watchpoint. Task 2 should hit it first, and GDB
60 # is expected to ignore that hit and resume the execution. Only then
61 # task 3 will hit our watchpoint, and GDB is expected to stop at that
62 # point. Also make sure that GDB reports the correct watchpoint number.
63 gdb_test "continue" \
64 ".* hit .*atchpoint $bp_number: -location value.*Old value = 1.*New value = 2.*" \
65 "continue to watchpoint"
66
67 # Check that it is indeed task 3 that hit the watchpoint by checking
68 # which is the active task.
69 gdb_test "info tasks" \
70 [join {" +ID +TID P-ID Pri State +Name" \
71 " +1 .* main_task" \
72 " +2 .* task_list\\(1\\)" \
73 "\\* +3 .* task_list\\(2\\)" \
74 " +4 .* task_list\\(3\\)"} \
75 "\r\n"] \
76 "info tasks after hitting watchpoint"
77
78 # Now, resume the execution and make sure that GDB does not stop when
79 # task 4 hits the watchpoint. Continuing thus results in our program
80 # running to completion.
81 set bp_location [gdb_get_line_number "STOP_HERE_2" ${testdir}/foo.adb]
82 gdb_breakpoint foo.adb:$bp_location
83 gdb_continue_to_breakpoint second ".*foo.adb:$bp_location.*null; -- STOP_HERE_2"