1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT COMPILER COMPONENTS                         --
4--                                                                          --
5--                     S Y S T E M . T R A C E B A C K                      --
6--                                                                          --
7--                                 S p e c                                  --
8--                                                                          --
9--          Copyright (C) 1999-2013, 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-- 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.               --
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 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.
35
36pragma Compiler_Unit_Warning;
37
38pragma Polling (Off);
39--  We must turn polling off for this unit, because otherwise we get
40--  elaboration circularities with System.Exception_Tables.
41
42package System.Traceback is
43
44   ----------------
45   -- Call_Chain --
46   ----------------
47
48   procedure Call_Chain
49     (Traceback   : System.Address;
50      Max_Len     : Natural;
51      Len         : out Natural;
52      Exclude_Min : System.Address := System.Null_Address;
53      Exclude_Max : System.Address := System.Null_Address;
54      Skip_Frames : Natural := 1);
55   --  Store up to Max_Len code locations in Traceback, corresponding to
56   --  the current call chain.
57   --
58   --    Traceback is the address of an array of addresses where the
59   --    result will be stored.
60   --
61   --    Max_Len is the length of the Traceback array. If the call chain is
62   --    longer than this, then additional entries are discarded, and the
63   --    traceback is missing some of the highest level entries.
64   --
65   --    Len is the returned number of addresses stored in the Traceback array
66   --
67   --    Exclude_Min/Exclude_Max, if non null, provide a range of addresses
68   --    to ignore from the computation of the traceback.
69   --
70   --    Skip_Frames says how many of the most recent calls should at least
71   --    be excluded from the result, regardless of the exclusion bounds and
72   --    starting with this procedure itself: 1 means exclude the frame for
73   --    this procedure, 2 means 1 + exclude the frame for this procedure's
74   --    caller, ...
75   --
76   --  On return, the Traceback array is filled in, and Len indicates the
77   --  number of stored entries. The first entry is the most recent call,
78   --  and the last entry is the highest level call.
79
80   function C_Call_Chain
81     (Traceback : System.Address;
82      Max_Len   : Natural)
83      return      Natural;
84   pragma Export (C, C_Call_Chain, "system__traceback__c_call_chain");
85   --  Version that can be used directly from C
86
87end System.Traceback;
88