File : a-elchha-xi-cert.adb
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT RUN-TIME COMPONENTS --
4 -- --
5 -- A D A . E X C E P T I O N S . L A S T _ C H A N C E _ H A N D L E R --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 2003-2012, Free Software Foundation, Inc. --
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 3, 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. --
17 -- --
18 -- --
19 -- --
20 -- --
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/>. --
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
32 -- Default last chance handler for use with the Cert run-time library on
33 -- generic platforms (such as native ones).
34
35 -- Dump exception name and non-symbolic stack backtrace, then exit
36
37 with GNAT.IO; use GNAT.IO;
38 with GNAT.Debug_Utilities; use GNAT.Debug_Utilities;
39
40 procedure Ada.Exceptions.Last_Chance_Handler (Except : Exception_Occurrence) is
41 procedure OS_Exit;
42 pragma Import (C, OS_Exit, "exit");
43 pragma No_Return (OS_Exit);
44
45 begin
46 Put_Line ("In last chance handler");
47 Put_Line ("Unhandled Ada Exception: " & Exception_Name (Except));
48 Put_Line ("Call stack traceback locations:");
49
50 -- Dump backtrace PC values
51
52 for J in 1 .. Except.Num_Tracebacks loop
53 Put (Image_C (Except.Tracebacks (J)));
54 Put (" ");
55 end loop;
56
57 New_Line;
58
59 -- We finish the application here. We do not support multiple threads
60 -- of execution here.
61
62 OS_Exit;
63 end Ada.Exceptions.Last_Chance_Handler;