Commit | Line | Data |
---|---|---|
3666a048 | 1 | # Copyright 2009-2021 Free Software Foundation, Inc. |
02d9a9ce JB |
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 | ||
02d9a9ce JB |
16 | load_lib "ada.exp" |
17 | ||
7a82e903 PA |
18 | if { [skip_ada_tests] } { return -1 } |
19 | ||
8223e12c | 20 | standard_ada_testfile foo |
02d9a9ce | 21 | |
02d9a9ce JB |
22 | if {[gdb_compile_ada "${srcfile}" "${binfile}" executable [list debug ]] != "" } { |
23 | return -1 | |
24 | } | |
25 | ||
09050809 | 26 | clean_restart ${testfile} |
02d9a9ce JB |
27 | |
28 | set bp_location [gdb_get_line_number "STOP_HERE" ${testdir}/foo.adb] | |
29 | runto "foo.adb:$bp_location" | |
30 | ||
31 | # Make sure that all tasks appear in the "info tasks" listing, and | |
32 | # that the active task is the environment task. | |
33 | gdb_test "info tasks" \ | |
a8123151 JB |
34 | [join {" +ID +TID P-ID Pri State +Name" \ |
35 | "\\* +1 .* main_task" \ | |
36 | " +2 .* task_list\\(1\\)" \ | |
37 | " +3 .* task_list\\(2\\)" \ | |
38 | " +4 .* task_list\\(3\\)"} \ | |
02d9a9ce JB |
39 | "\r\n"] \ |
40 | "info tasks before inserting breakpoint" | |
41 | ||
12ab52e9 PA |
42 | # Insert a breakpoint that should stop only if task 1 stops. Since |
43 | # task 1 never calls break_me, this shouldn't actually ever trigger. | |
44 | # The fact that this breakpoint is created _before_ the next one | |
45 | # matters. GDB used to have a bug where it would report the first | |
46 | # breakpoint in the list that matched the triggered-breakpoint's | |
47 | # address, no matter which task it was specific to. | |
48 | gdb_test "break break_me task 1" "Breakpoint .* at .*" | |
49 | ||
50 | # Now, insert a breakpoint that should stop only if task 3 stops, and | |
51 | # extract its number. | |
52 | set bp_number -1 | |
53 | set test "break break_me task 3" | |
54 | gdb_test_multiple $test $test { | |
55 | -re "Breakpoint (.*) at .*$gdb_prompt $" { | |
56 | set bp_number $expect_out(1,string) | |
57 | pass $test | |
58 | } | |
59 | } | |
60 | ||
61 | if {$bp_number < 0} { | |
62 | return | |
63 | } | |
02d9a9ce JB |
64 | |
65 | # Continue to that breakpoint. Task 2 should hit it first, and GDB | |
66 | # is expected to ignore that hit and resume the execution. Only then | |
67 | # task 3 will hit our breakpoint, and GDB is expected to stop at that | |
12ab52e9 | 68 | # point. Also make sure that GDB reports the correct breakpoint number. |
02d9a9ce | 69 | gdb_test "continue" \ |
12ab52e9 | 70 | ".*Breakpoint $bp_number, foo.break_me \\(\\).*" \ |
02d9a9ce JB |
71 | "continue to breakpoint" |
72 | ||
73 | # Check that it is indeed task 3 that hit the breakpoint by checking | |
74 | # which is the active task. | |
75 | gdb_test "info tasks" \ | |
a8123151 JB |
76 | [join {" +ID +TID P-ID Pri State +Name" \ |
77 | " +1 .* main_task" \ | |
78 | " +2 .* task_list\\(1\\)" \ | |
79 | "\\* +3 .* task_list\\(2\\)" \ | |
80 | " +4 .* task_list\\(3\\)"} \ | |
02d9a9ce JB |
81 | "\r\n"] \ |
82 | "info tasks after hitting breakpoint" | |
83 | ||
84 | # Now, resume the execution and make sure that GDB does not stop when | |
85 | # task 4 hits the breakpoint. Continuing thus results in our program | |
86 | # running to completion. | |
c83d8d32 TT |
87 | set bp_location [gdb_get_line_number "STOP_HERE_2" ${testdir}/foo.adb] |
88 | gdb_breakpoint foo.adb:$bp_location | |
89 | gdb_continue_to_breakpoint second ".*foo.adb:$bp_location.*null; -- STOP_HERE_2" | |
90 | ||
91 | # A regression test for a crash caused by trying to find the thread | |
92 | # for a terminated task. | |
93 | gdb_test "interpreter-exec mi \"-ada-task-info\"" ".*" |