annotate gcc/ada/libgnat/g-excact.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- G N A T . E X C E P T I O N _ A C T I O N S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 2002-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
32 -- This package provides support for callbacks on exceptions as well as
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
33 -- exception-related utility subprograms of possible interest together with
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
34 -- exception actions or more generally.
111
kono
parents:
diff changeset
35
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
36 -- The callbacks are called immediately when either a specific exception,
111
kono
parents:
diff changeset
37 -- or any exception, is raised, before any other actions taken by raise, in
kono
parents:
diff changeset
38 -- particular before any unwinding of the stack occurs.
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 -- Callbacks for specific exceptions are registered through calls to
kono
parents:
diff changeset
41 -- Register_Id_Action. Here is an example of code that uses this package to
kono
parents:
diff changeset
42 -- automatically core dump when the exception Constraint_Error is raised.
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 -- Register_Id_Action (Constraint_Error'Identity, Core_Dump'Access);
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 -- Subprograms are also provided to list the currently registered exceptions,
kono
parents:
diff changeset
47 -- or to convert from a string to an exception id.
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 -- This package can easily be extended, for instance to provide a callback
kono
parents:
diff changeset
50 -- whenever an exception matching a regular expression is raised. The idea
kono
parents:
diff changeset
51 -- is to register a global action, called whenever any exception is raised.
kono
parents:
diff changeset
52 -- Dispatching can then be done directly in this global action callback.
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 with Ada.Exceptions; use Ada.Exceptions;
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 package GNAT.Exception_Actions is
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 type Exception_Action is access
kono
parents:
diff changeset
59 procedure (Occurrence : Exception_Occurrence);
kono
parents:
diff changeset
60 -- General callback type whenever an exception is raised. The callback
kono
parents:
diff changeset
61 -- procedure must not propagate an exception (execution of the program
kono
parents:
diff changeset
62 -- is erroneous if such an exception is propagated).
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 procedure Register_Global_Action (Action : Exception_Action);
kono
parents:
diff changeset
65 -- Action will be called whenever an exception is raised. Only one such
kono
parents:
diff changeset
66 -- action can be registered at any given time, and registering a new action
kono
parents:
diff changeset
67 -- will override any previous action that might have been registered.
kono
parents:
diff changeset
68 --
kono
parents:
diff changeset
69 -- Action is called before the exception is propagated to user's code.
kono
parents:
diff changeset
70 -- If Action is null, this will in effect cancel all exception actions.
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 procedure Register_Id_Action
kono
parents:
diff changeset
73 (Id : Exception_Id;
kono
parents:
diff changeset
74 Action : Exception_Action);
kono
parents:
diff changeset
75 -- Action will be called whenever an exception of type Id is raised. Only
kono
parents:
diff changeset
76 -- one such action can be registered for each exception id, and registering
kono
parents:
diff changeset
77 -- a new action will override any previous action registered for this
kono
parents:
diff changeset
78 -- Exception_Id. Program_Error is raised if Id is Null_Id.
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 function Name_To_Id (Name : String) return Exception_Id;
kono
parents:
diff changeset
81 -- Convert an exception name to an exception id. Null_Id is returned
kono
parents:
diff changeset
82 -- if no such exception exists. Name must be an all upper-case string,
kono
parents:
diff changeset
83 -- or the exception will not be found. The exception name must be fully
kono
parents:
diff changeset
84 -- qualified (but not including Standard). It is not possible to convert
kono
parents:
diff changeset
85 -- an exception that is declared within an unlabeled block.
kono
parents:
diff changeset
86 --
kono
parents:
diff changeset
87 -- Note: All non-predefined exceptions will return Null_Id for programs
kono
parents:
diff changeset
88 -- compiled with pragma Restriction (No_Exception_Registration)
kono
parents:
diff changeset
89
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
90 function Is_Foreign_Exception (E : Exception_Occurrence) return Boolean;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
91 -- Tell whether the exception occurrence E represents a foreign exception,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
92 -- such as one raised in C++ and caught by a when others choice in Ada.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
93
111
kono
parents:
diff changeset
94 function Registered_Exceptions_Count return Natural;
kono
parents:
diff changeset
95 -- Return the number of exceptions that have been registered so far.
kono
parents:
diff changeset
96 -- Exceptions declared locally will not appear in this list until their
kono
parents:
diff changeset
97 -- block has been executed at least once.
kono
parents:
diff changeset
98 --
kono
parents:
diff changeset
99 -- Note: The count includes only predefined exceptions for programs
kono
parents:
diff changeset
100 -- compiled with pragma Restrictions (No_Exception_Registration).
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 type Exception_Id_Array is array (Natural range <>) of Exception_Id;
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 procedure Get_Registered_Exceptions
kono
parents:
diff changeset
105 (List : out Exception_Id_Array;
kono
parents:
diff changeset
106 Last : out Integer);
kono
parents:
diff changeset
107 -- Return the list of registered exceptions.
kono
parents:
diff changeset
108 -- Last is the index in List of the last exception returned.
kono
parents:
diff changeset
109 --
kono
parents:
diff changeset
110 -- An exception is registered the first time the block containing its
kono
parents:
diff changeset
111 -- declaration is elaborated. Exceptions defined at library-level are
kono
parents:
diff changeset
112 -- therefore immediately visible, whereas exceptions declared in local
kono
parents:
diff changeset
113 -- blocks will not be visible until the block is executed at least once.
kono
parents:
diff changeset
114 --
kono
parents:
diff changeset
115 -- Note: The list contains only the predefined exceptions if the program
kono
parents:
diff changeset
116 -- is compiled with pragma Restrictions (No_Exception_Registration);
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 procedure Core_Dump (Occurrence : Exception_Occurrence);
kono
parents:
diff changeset
119 -- Dump memory (called a core dump in some systems) if supported by the
kono
parents:
diff changeset
120 -- OS (most unix systems), and abort execution of the application. Under
kono
parents:
diff changeset
121 -- Windows this procedure will not dump the memory, it will only abort
kono
parents:
diff changeset
122 -- execution.
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 end GNAT.Exception_Actions;