1 |
281 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT RUN-TIME COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- G N A T . 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-2008, 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 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 --
|
19 |
|
|
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
|
20 |
|
|
-- Boston, MA 02110-1301, USA. --
|
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 |
|
|
|
34 |
|
|
-- This package provides an interface allowing to control *automatic* output
|
35 |
|
|
-- to standard error upon exception occurrences (as opposed to explicit
|
36 |
|
|
-- generation of traceback information using GNAT.Traceback).
|
37 |
|
|
|
38 |
|
|
-- This output includes the basic information associated with the exception
|
39 |
|
|
-- (name, message) as well as a backtrace of the call chain at the point
|
40 |
|
|
-- where the exception occurred. This backtrace is only output if the call
|
41 |
|
|
-- chain information is available, depending if the binder switch dedicated
|
42 |
|
|
-- to that purpose has been used or not.
|
43 |
|
|
|
44 |
|
|
-- The default backtrace is in the form of absolute code locations which may
|
45 |
|
|
-- be converted to corresponding source locations using the addr2line utility
|
46 |
|
|
-- or from within GDB. Please refer to GNAT.Traceback for information about
|
47 |
|
|
-- what is necessary to be able to exploit this possibility.
|
48 |
|
|
|
49 |
|
|
-- The backtrace output can also be customized by way of a "decorator" which
|
50 |
|
|
-- may return any string output in association with a provided call chain.
|
51 |
|
|
-- The decorator replaces the default backtrace mentioned above.
|
52 |
|
|
|
53 |
|
|
with GNAT.Traceback; use GNAT.Traceback;
|
54 |
|
|
|
55 |
|
|
package GNAT.Exception_Traces is
|
56 |
|
|
|
57 |
|
|
-- The following defines the exact situations in which raises will
|
58 |
|
|
-- cause automatic output of trace information.
|
59 |
|
|
|
60 |
|
|
type Trace_Kind is
|
61 |
|
|
(Every_Raise,
|
62 |
|
|
-- Denotes the initial raise event for any exception occurrence, either
|
63 |
|
|
-- explicit or due to a specific language rule, within the context of a
|
64 |
|
|
-- task or not.
|
65 |
|
|
|
66 |
|
|
Unhandled_Raise
|
67 |
|
|
-- Denotes the raise events corresponding to exceptions for which there
|
68 |
|
|
-- is no user defined handler, in particular, when a task dies due to an
|
69 |
|
|
-- unhandled exception.
|
70 |
|
|
);
|
71 |
|
|
|
72 |
|
|
-- The following procedures can be used to activate and deactivate
|
73 |
|
|
-- traces identified by the above trace kind values.
|
74 |
|
|
|
75 |
|
|
procedure Trace_On (Kind : Trace_Kind);
|
76 |
|
|
-- Activate the traces denoted by Kind
|
77 |
|
|
|
78 |
|
|
procedure Trace_Off;
|
79 |
|
|
-- Stop the tracing requested by the last call to Trace_On.
|
80 |
|
|
-- Has no effect if no such call has ever occurred.
|
81 |
|
|
|
82 |
|
|
-- The following provide the backtrace decorating facilities
|
83 |
|
|
|
84 |
|
|
type Traceback_Decorator is access
|
85 |
|
|
function (Traceback : Tracebacks_Array) return String;
|
86 |
|
|
-- A backtrace decorator is a function which returns the string to be
|
87 |
|
|
-- output for a call chain provided by way of a tracebacks array.
|
88 |
|
|
|
89 |
|
|
procedure Set_Trace_Decorator (Decorator : Traceback_Decorator);
|
90 |
|
|
-- Set the decorator to be used for future automatic outputs. Restore
|
91 |
|
|
-- the default behavior (output of raw addresses) if the provided
|
92 |
|
|
-- access value is null.
|
93 |
|
|
--
|
94 |
|
|
-- Note: GNAT.Traceback.Symbolic.Symbolic_Traceback may be used as the
|
95 |
|
|
-- Decorator, to get a symbolic traceback. This will cause a significant
|
96 |
|
|
-- cpu and memory overhead.
|
97 |
|
|
|
98 |
|
|
end GNAT.Exception_Traces;
|