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-2023, 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 with System
.Traceback_Entries
;
38 package System
.Traceback
is
45 (Traceback
: in out System
.Traceback_Entries
.Tracebacks_Array
;
48 Exclude_Min
: System
.Address
:= System
.Null_Address
;
49 Exclude_Max
: System
.Address
:= System
.Null_Address
;
50 Skip_Frames
: Natural := 1);
51 -- Store up to Max_Len code locations in Traceback, corresponding to the
52 -- current call chain.
54 -- Traceback is an array of addresses where the result will be stored.
56 -- Max_Len is the length of the Traceback array. If the call chain is
57 -- longer than this, then additional entries are discarded, and the
58 -- traceback is missing some of the highest level entries.
60 -- Len is the number of addresses returned in the Traceback array
62 -- Exclude_Min/Exclude_Max, if non null, provide a range of addresses
63 -- to ignore from the computation of the traceback.
65 -- Skip_Frames says how many of the most recent calls should at least
66 -- be excluded from the result, regardless of the exclusion bounds and
67 -- starting with this procedure itself: 1 means exclude the frame for
68 -- this procedure, 2 means 1 + exclude the frame for this procedure's
71 -- On return, the Traceback array is filled in, and Len indicates the
72 -- number of stored entries. The first entry is the most recent call,
73 -- and the last entry is the highest level call.
76 (Traceback
: System
.Address
;
77 Max_Len
: Natural) return Natural;
78 pragma Export
(C
, C_Call_Chain
, "system__traceback__c_call_chain");
79 -- Version that can be used directly from C