Imported Upstream version 7.9
[platform/upstream/gdb.git] / gdb / testsuite / gdb.ada / bad-task-bp-keyword / foo.adb
1 --  Copyright 2009-2015 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 procedure Foo is
17
18    task type Caller is
19       entry Initialize;
20       entry Call_Break_Me;
21       entry Finalize;
22    end Caller;
23    type Caller_Ptr is access Caller;
24
25    procedure Break_Me is
26    begin
27       null;
28    end Break_Me;
29
30    task body Caller is
31    begin
32       accept Initialize do
33          null;
34       end Initialize;
35       accept Call_Break_Me do
36          Break_Me;
37       end Call_Break_Me;
38       accept Finalize do
39          null;
40       end Finalize;
41    end Caller;
42
43    Task_List : array (1 .. 3) of Caller_Ptr;
44
45 begin
46
47    --  Start all our tasks, and call the "Initialize" entry to make
48    --  sure all of them have now been started.  We call that entry
49    --  immediately after having created the task in order to make sure
50    --  that we wait for that task to be created before we try to create
51    --  another one.  That way, we know that the order in our Task_List
52    --  corresponds to the order in the GNAT runtime.
53    for J in Task_List'Range loop
54       Task_List (J) := new Caller;
55       Task_List (J).Initialize;
56    end loop;
57
58    --  Next, call their Call_Break_Me entry of each task, using the same
59    --  order as the order used to create them.
60    for J in Task_List'Range loop  -- STOP_HERE
61       Task_List (J).Call_Break_Me;
62    end loop;
63
64    --  And finally, let all the tasks die...
65    for J in Task_List'Range loop
66       Task_List (J).Finalize;
67    end loop;
68 end Foo;