]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/ada/a-exexpr.adb
Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[thirdparty/gcc.git] / gcc / ada / a-exexpr.adb
CommitLineData
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-- --
748086b7 9-- Copyright (C) 1992-2009, 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- --
748086b7 13-- ware Foundation; either version 3, or (at your option) any later ver- --
fbf5a39b
AC
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 --
748086b7
JJ
16-- or FITNESS FOR A PARTICULAR PURPOSE. --
17-- --
18-- As a special exception under Section 7 of GPL version 3, you are granted --
19-- additional permissions described in the GCC Runtime Library Exception, --
20-- version 3.1, as published by the Free Software Foundation. --
21-- --
22-- You should have received a copy of the GNU General Public License and --
23-- a copy of the GCC Runtime Library Exception along with this program; --
24-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25-- <http://www.gnu.org/licenses/>. --
fbf5a39b
AC
26-- --
27-- GNAT was originally developed by the GNAT team at New York University. --
28-- Extensive contributions were provided by Ada Core Technologies Inc. --
29-- --
30------------------------------------------------------------------------------
31
982f26e4
AC
32-- This is the default version, using the __builtin_setjmp/longjmp EH
33-- mechanism.
fbf5a39b 34
5453d5bd
AC
35with System.Storage_Elements; use System.Storage_Elements;
36
fbf5a39b
AC
37pragma Warnings (Off);
38-- Since several constructs give warnings in 3.14a1, including unreferenced
39-- variables and pragma Unreferenced itself.
40
41separate (Ada.Exceptions)
42package body Exception_Propagation is
43
982f26e4
AC
44 procedure builtin_longjmp (buffer : Address; Flag : Integer);
45 pragma No_Return (builtin_longjmp);
46 pragma Import (C, builtin_longjmp, "_gnat_builtin_longjmp");
5453d5bd 47
fbf5a39b
AC
48 ---------------------
49 -- Setup_Exception --
50 ---------------------
51
fbf5a39b
AC
52 procedure Setup_Exception
53 (Excep : EOA;
54 Current : EOA;
55 Reraised : Boolean := False)
56 is
982f26e4 57 pragma Unreferenced (Excep, Current, Reraised);
fbf5a39b 58 begin
8fc789c8 59 -- In the GNAT-SJLJ case this "stack" only exists implicitly, by way of
982f26e4
AC
60 -- local occurrence declarations together with save/restore operations
61 -- generated by the front-end, and this routine has nothing to do.
0da2c8ac 62
fbf5a39b 63 null;
982f26e4 64 end Setup_Exception;
fbf5a39b
AC
65
66 -------------------------
67 -- Propagate_Exception --
68 -------------------------
69
6f301919
AC
70 procedure Propagate_Exception
71 (E : Exception_Id;
72 From_Signal_Handler : Boolean)
73 is
74 pragma Inspection_Point (E);
75
982f26e4
AC
76 Jumpbuf_Ptr : constant Address := Get_Jmpbuf_Address.all;
77 Excep : constant EOA := Get_Current_Excep.all;
fbf5a39b 78 begin
982f26e4
AC
79 -- Compute the backtrace for this occurrence if corresponding binder
80 -- option has been set. Call_Chain takes care of the reraise case.
fbf5a39b 81
982f26e4 82 Call_Chain (Excep);
fbf5a39b 83
982f26e4 84 -- Note on above call to Call_Chain:
fbf5a39b 85
982f26e4
AC
86 -- We used to only do this if From_Signal_Handler was not set,
87 -- based on the assumption that backtracing from a signal handler
88 -- would not work due to stack layout oddities. However, since
fbf5a39b 89
982f26e4
AC
90 -- 1. The flag is never set in tasking programs (Notify_Exception
91 -- performs regular raise statements), and
fbf5a39b 92
982f26e4
AC
93 -- 2. No problem has shown up in tasking programs around here so
94 -- far, this turned out to be too strong an assumption.
fbf5a39b 95
982f26e4 96 -- As, in addition, the test was
fbf5a39b 97
982f26e4
AC
98 -- 1. preventing the production of backtraces in non-tasking
99 -- programs, and
fbf5a39b 100
982f26e4
AC
101 -- 2. introducing a behavior inconsistency between
102 -- the tasking and non-tasking cases,
fbf5a39b 103
982f26e4 104 -- we have simply removed it
fbf5a39b 105
982f26e4
AC
106 -- If the jump buffer pointer is non-null, transfer control using
107 -- it. Otherwise announce an unhandled exception (note that this
108 -- means that we have no finalizations to do other than at the outer
109 -- level). Perform the necessary notification tasks in both cases.
fbf5a39b 110
982f26e4
AC
111 if Jumpbuf_Ptr /= Null_Address then
112 if not Excep.Exception_Raised then
113 Excep.Exception_Raised := True;
114 Exception_Traces.Notify_Handled_Exception;
115 end if;
fbf5a39b 116
982f26e4 117 builtin_longjmp (Jumpbuf_Ptr, 1);
fbf5a39b 118
982f26e4
AC
119 else
120 Exception_Traces.Notify_Unhandled_Exception;
121 Exception_Traces.Unhandled_Exception_Terminate;
fbf5a39b 122 end if;
fbf5a39b
AC
123 end Propagate_Exception;
124
fbf5a39b 125end Exception_Propagation;