File : a-elchha-xi.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-2015, 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 with System.IO;                use System.IO;
  33 with GNAT.Debug_Utilities;     use GNAT.Debug_Utilities;
  34 with System;
  35 with System.OS_Interface;
  36 
  37 --  Default last chance handler for use with full run-time library on bare
  38 --  board targets.
  39 
  40 --  It dumps the exception identity and the non-symbolic traceback from the
  41 --  point where the exception was triggered.
  42 
  43 procedure Ada.Exceptions.Last_Chance_Handler (Except : Exception_Occurrence) is
  44 begin
  45    Put_Line ("In last chance handler");
  46    Put_Line ("Unhandled Ada Exception: " & Exception_Name (Except));
  47    Put_Line ("Message: " & Exception_Message (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    --  Suspend forever
  60 
  61    System.OS_Interface.Sleep;
  62 
  63    --  The following junk raise of Program_Error is required because
  64    --  this is a No_Return function, and unfortunately Suspend can
  65    --  return (although this particular call won't).
  66 
  67    raise Program_Error;
  68 
  69 end Ada.Exceptions.Last_Chance_Handler;