]>
Commit | Line | Data |
---|---|---|
fbf5a39b AC |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3 | -- GNAT COMPILER COMPONENTS -- | |
4 | -- -- | |
9f4fd324 | 5 | -- A D A . E X C E P T I O N S . E X C E P T I O N _ P R O P A G A T I O N -- |
fbf5a39b AC |
6 | -- -- |
7 | -- B o d y -- | |
8 | -- -- | |
982f26e4 | 9 | -- Copyright (C) 1992-2005 Free Software Foundation, Inc. -- |
fbf5a39b AC |
10 | -- -- |
11 | -- GNAT is free software; you can redistribute it and/or modify it under -- | |
12 | -- terms of the GNU General Public License as published by the Free Soft- -- | |
13 | -- ware Foundation; either version 2, or (at your option) any later ver- -- | |
14 | -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | |
15 | -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- | |
16 | -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- | |
17 | -- for more details. You should have received a copy of the GNU General -- | |
18 | -- Public License distributed with GNAT; see file COPYING. If not, write -- | |
cb5fee25 KC |
19 | -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- |
20 | -- Boston, MA 02110-1301, USA. -- | |
fbf5a39b AC |
21 | -- -- |
22 | -- As a special exception, if other files instantiate generics from this -- | |
23 | -- unit, or you link this unit with other files to produce an executable, -- | |
24 | -- this unit does not by itself cause the resulting executable to be -- | |
25 | -- covered by the GNU General Public License. This exception does not -- | |
26 | -- however invalidate any other reasons why the executable file might be -- | |
27 | -- covered by the GNU Public License. -- | |
28 | -- -- | |
29 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
30 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- | |
31 | -- -- | |
32 | ------------------------------------------------------------------------------ | |
33 | ||
982f26e4 AC |
34 | -- This is the default version, using the __builtin_setjmp/longjmp EH |
35 | -- mechanism. | |
fbf5a39b | 36 | |
5453d5bd AC |
37 | with System.Storage_Elements; use System.Storage_Elements; |
38 | ||
fbf5a39b AC |
39 | pragma Warnings (Off); |
40 | -- Since several constructs give warnings in 3.14a1, including unreferenced | |
41 | -- variables and pragma Unreferenced itself. | |
42 | ||
43 | separate (Ada.Exceptions) | |
44 | package body Exception_Propagation is | |
45 | ||
982f26e4 AC |
46 | procedure builtin_longjmp (buffer : Address; Flag : Integer); |
47 | pragma No_Return (builtin_longjmp); | |
48 | pragma Import (C, builtin_longjmp, "_gnat_builtin_longjmp"); | |
5453d5bd | 49 | |
fbf5a39b AC |
50 | --------------------- |
51 | -- Setup_Exception -- | |
52 | --------------------- | |
53 | ||
fbf5a39b AC |
54 | procedure Setup_Exception |
55 | (Excep : EOA; | |
56 | Current : EOA; | |
57 | Reraised : Boolean := False) | |
58 | is | |
982f26e4 | 59 | pragma Unreferenced (Excep, Current, Reraised); |
fbf5a39b | 60 | begin |
982f26e4 AC |
61 | -- In the GNAT-SJLJ case this "stack" only exists implicitely, by way of |
62 | -- local occurrence declarations together with save/restore operations | |
63 | -- generated by the front-end, and this routine has nothing to do. | |
0da2c8ac | 64 | |
fbf5a39b | 65 | null; |
982f26e4 | 66 | end Setup_Exception; |
fbf5a39b AC |
67 | |
68 | ------------------------- | |
69 | -- Propagate_Exception -- | |
70 | ------------------------- | |
71 | ||
fbf5a39b | 72 | procedure Propagate_Exception (From_Signal_Handler : Boolean) is |
982f26e4 AC |
73 | Jumpbuf_Ptr : constant Address := Get_Jmpbuf_Address.all; |
74 | Excep : constant EOA := Get_Current_Excep.all; | |
fbf5a39b | 75 | begin |
982f26e4 AC |
76 | -- Compute the backtrace for this occurrence if corresponding binder |
77 | -- option has been set. Call_Chain takes care of the reraise case. | |
fbf5a39b | 78 | |
982f26e4 | 79 | Call_Chain (Excep); |
fbf5a39b | 80 | |
982f26e4 | 81 | -- Note on above call to Call_Chain: |
fbf5a39b | 82 | |
982f26e4 AC |
83 | -- We used to only do this if From_Signal_Handler was not set, |
84 | -- based on the assumption that backtracing from a signal handler | |
85 | -- would not work due to stack layout oddities. However, since | |
fbf5a39b | 86 | |
982f26e4 AC |
87 | -- 1. The flag is never set in tasking programs (Notify_Exception |
88 | -- performs regular raise statements), and | |
fbf5a39b | 89 | |
982f26e4 AC |
90 | -- 2. No problem has shown up in tasking programs around here so |
91 | -- far, this turned out to be too strong an assumption. | |
fbf5a39b | 92 | |
982f26e4 | 93 | -- As, in addition, the test was |
fbf5a39b | 94 | |
982f26e4 AC |
95 | -- 1. preventing the production of backtraces in non-tasking |
96 | -- programs, and | |
fbf5a39b | 97 | |
982f26e4 AC |
98 | -- 2. introducing a behavior inconsistency between |
99 | -- the tasking and non-tasking cases, | |
fbf5a39b | 100 | |
982f26e4 | 101 | -- we have simply removed it |
fbf5a39b | 102 | |
982f26e4 AC |
103 | -- If the jump buffer pointer is non-null, transfer control using |
104 | -- it. Otherwise announce an unhandled exception (note that this | |
105 | -- means that we have no finalizations to do other than at the outer | |
106 | -- level). Perform the necessary notification tasks in both cases. | |
fbf5a39b | 107 | |
982f26e4 AC |
108 | if Jumpbuf_Ptr /= Null_Address then |
109 | if not Excep.Exception_Raised then | |
110 | Excep.Exception_Raised := True; | |
111 | Exception_Traces.Notify_Handled_Exception; | |
112 | end if; | |
fbf5a39b | 113 | |
982f26e4 | 114 | builtin_longjmp (Jumpbuf_Ptr, 1); |
fbf5a39b | 115 | |
982f26e4 AC |
116 | else |
117 | Exception_Traces.Notify_Unhandled_Exception; | |
118 | Exception_Traces.Unhandled_Exception_Terminate; | |
fbf5a39b | 119 | end if; |
fbf5a39b AC |
120 | end Propagate_Exception; |
121 | ||
fbf5a39b | 122 | end Exception_Propagation; |