2014-11-18 Christophe Lyon <christophe.lyon@linaro.org>
[official-gcc.git] / gcc / ada / s-traceb.ads
blobdbfea6a6f6f32b24dee72cfccafe3f60d53b1b8f
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-2014, 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 ------------------------------------------------------------------------------
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;
38 pragma Polling (Off);
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
46 ----------------
47 -- Call_Chain --
48 ----------------
50 procedure Call_Chain
51 (Traceback : in out System.Traceback_Entries.Tracebacks_Array;
52 Max_Len : Natural;
53 Len : out Natural;
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
75 -- caller, ...
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.
81 procedure Call_Chain
82 (Traceback : System.Address;
83 Max_Len : Natural;
84 Len : out Natural;
85 Exclude_Min : System.Address := System.Null_Address;
86 Exclude_Max : System.Address := System.Null_Address;
87 Skip_Frames : Natural := 1);
88 -- Same as the previous version, but takes Traceback as an Address. The
89 -- previous version is preferred. ???This version should be removed from
90 -- this spec, and calls replaced with calls to the previous version. This
91 -- declaration can be moved to the bodies (s-traceb.adb, s-traceb-hpux.adb,
92 -- and s-traceb-mastop.adb), but it should not be visible to clients.
94 function C_Call_Chain
95 (Traceback : System.Address;
96 Max_Len : Natural) return Natural;
97 pragma Export (C, C_Call_Chain, "system__traceback__c_call_chain");
98 -- Version that can be used directly from C
100 end System.Traceback;