1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- S Y S T E M . T R A C E B A C K --
9 -- Copyright (C) 1999-2018, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- This package provides a method for generating a traceback of the current
33 -- execution location. The traceback shows the locations of calls in the call
34 -- chain, up to either the top or a designated number of levels.
36 pragma Compiler_Unit_Warning
;
39 -- We must turn polling off for this unit, because otherwise we get
40 -- elaboration circularities with System.Exception_Tables.
42 with System
.Traceback_Entries
;
44 package System
.Traceback
is
51 (Traceback
: in out System
.Traceback_Entries
.Tracebacks_Array
;
54 Exclude_Min
: System
.Address
:= System
.Null_Address
;
55 Exclude_Max
: System
.Address
:= System
.Null_Address
;
56 Skip_Frames
: Natural := 1);
57 -- Store up to Max_Len code locations in Traceback, corresponding to the
58 -- current call chain.
60 -- Traceback is an array of addresses where the result will be stored.
62 -- Max_Len is the length of the Traceback array. If the call chain is
63 -- longer than this, then additional entries are discarded, and the
64 -- traceback is missing some of the highest level entries.
66 -- Len is the number of addresses returned in the Traceback array
68 -- Exclude_Min/Exclude_Max, if non null, provide a range of addresses
69 -- to ignore from the computation of the traceback.
71 -- Skip_Frames says how many of the most recent calls should at least
72 -- be excluded from the result, regardless of the exclusion bounds and
73 -- starting with this procedure itself: 1 means exclude the frame for
74 -- this procedure, 2 means 1 + exclude the frame for this procedure's
77 -- On return, the Traceback array is filled in, and Len indicates the
78 -- number of stored entries. The first entry is the most recent call,
79 -- and the last entry is the highest level call.
82 (Traceback
: System
.Address
;
83 Max_Len
: Natural) return Natural;
84 pragma Export
(C
, C_Call_Chain
, "system__traceback__c_call_chain");
85 -- Version that can be used directly from C