File : s-exctra.ads


   1 ------------------------------------------------------------------------------
   2 --                                                                          --
   3 --                         GNAT RUN-TIME COMPONENTS                         --
   4 --                                                                          --
   5 --                S Y S T E M . E X C E P T I O N _ T R A C E S             --
   6 --                                                                          --
   7 --                                 S p e c                                  --
   8 --                                                                          --
   9 --                     Copyright (C) 2000-2015, AdaCore                     --
  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 --  This package provides an interface allowing to control *automatic* output
  33 --  to standard error upon exception occurrences (as opposed to explicit
  34 --  generation of traceback information using System.Traceback).
  35 
  36 --  This output includes the basic information associated with the exception
  37 --  (name, message) as well as a backtrace of the call chain at the point
  38 --  where the exception occurred. This backtrace is only output if the call
  39 --  chain information is available, depending if the binder switch dedicated
  40 --  to that purpose has been used or not.
  41 
  42 --  The default backtrace is in the form of absolute code locations which may
  43 --  be converted to corresponding source locations using the addr2line utility
  44 --  or from within GDB. Please refer to System.Traceback for information about
  45 --  what is necessary to be able to exploit this possibility.
  46 
  47 --  The backtrace output can also be customized by way of a "decorator" which
  48 --  may return any string output in association with a provided call chain.
  49 --  The decorator replaces the default backtrace mentioned above.
  50 
  51 --  On systems that use DWARF debugging output, then if the "-g" compiler
  52 --  switch and the "-Es" binder switch are used, the decorator is automatically
  53 --  set to Symbolic_Traceback.
  54 
  55 with System.Traceback_Entries;
  56 
  57 package System.Exception_Traces is
  58 
  59    --  The following defines the exact situations in which raises will
  60    --  cause automatic output of trace information.
  61 
  62    type Trace_Kind is
  63      (Every_Raise,
  64       --  Denotes the initial raise event for any exception occurrence, either
  65       --  explicit or due to a specific language rule, within the context of a
  66       --  task or not.
  67 
  68       Unhandled_Raise,
  69       --  Denotes the raise events corresponding to exceptions for which there
  70       --  is no user defined handler. This includes unhandled exceptions in
  71       --  task bodies.
  72 
  73       Unhandled_Raise_In_Main
  74       --  Same as Unhandled_Raise, except exceptions in task bodies are not
  75       --  included.
  76      );
  77 
  78    --  The following procedures can be used to activate and deactivate
  79    --  traces identified by the above trace kind values.
  80 
  81    procedure Trace_On (Kind : Trace_Kind);
  82    --  Activate the traces denoted by Kind
  83 
  84    procedure Trace_Off;
  85    --  Stop the tracing requested by the last call to Trace_On.
  86    --  Has no effect if no such call has ever occurred.
  87 
  88    --  The following provide the backtrace decorating facilities
  89 
  90    type Traceback_Decorator is access
  91      function (Traceback : Traceback_Entries.Tracebacks_Array) return String;
  92    --  A backtrace decorator is a function which returns the string to be
  93    --  output for a call chain provided by way of a tracebacks array.
  94 
  95    procedure Set_Trace_Decorator (Decorator : Traceback_Decorator);
  96    --  Set the decorator to be used for future automatic outputs. Restore the
  97    --  default behavior if the provided access value is null.
  98    --
  99    --  Note: System.Traceback.Symbolic.Symbolic_Traceback may be used as the
 100    --  Decorator, to get a symbolic traceback. This will cause a significant
 101    --  cpu and memory overhead on some platforms.
 102    --
 103    --  Note: The Decorator is called when constructing the
 104    --  Exception_Information; that needs to be taken into account
 105    --  if the Decorator has any side effects.
 106 
 107 end System.Exception_Traces;