File : s-traceb-zfp.ads


   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 --                                                                          --
  19 --                                                                          --
  20 --                                                                          --
  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 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  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 
  36 --  This is the bare board/ZFP version of this package
  37 
  38 pragma Polling (Off);
  39 --  We must turn polling off for this unit, because otherwise we get
  40 --  elaboration circularities with System.Exception_Tables.
  41 
  42 with System.Traceback_Entries;
  43 
  44 package System.Traceback is
  45 
  46    ----------------
  47    -- Call_Chain --
  48    ----------------
  49 
  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.
  59    --
  60    --    Traceback is an array of addresses where the result will be stored.
  61    --
  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.
  65    --
  66    --    Len is the number of addresses returned in the Traceback array
  67    --
  68    --    Exclude_Min/Exclude_Max, if non null, provide a range of addresses
  69    --    to ignore from the computation of the traceback.
  70    --
  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, ...
  76    --
  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.
  80 
  81    procedure Call_Chain
  82      (Frame_Pointer : System.Address;
  83       Traceback     : in out System.Traceback_Entries.Tracebacks_Array;
  84       Len           : out Natural;
  85       Exclude_Min   : System.Address := System.Null_Address;
  86       Exclude_Max   : System.Address := System.Null_Address;
  87       Skip_Frames   : Natural := 0);
  88    --  Same as above, but compute a call stack given a frame pointer. This
  89    --  version is more flexible, as it allows computing call stack of e.g.
  90    --  other threads.
  91    --
  92    --  Under the PPC ABI, Frame_Pointer corresponds typically to r1 (sp) for a
  93    --  given thread.
  94    --
  95    --  Since the frame pointer is already computed, Skip_Frames in general
  96    --  should not be used, and defaults to 0.
  97 
  98    function C_Call_Chain
  99      (Frame_Pointer : System.Address;
 100       Traceback     : System.Address;
 101       Traceback_Len : Integer) return Integer;
 102    pragma Export (C, C_Call_Chain, "__gnat_call_chain");
 103    --  Version that can be called from C code directly.
 104    --
 105    --  Traceback is the address of an array of void*, e.g. void *traceback[64];
 106    --  Traceback_Len is the number of elements of Traceback
 107    --
 108    --  This function returns the number of elements stored in Traceback
 109    --  C profile:
 110    --    int __gnat_call_chain (void *fp, void **traceback, int len);
 111 
 112 end System.Traceback;