1--  GHDL Run Time (GRT) - Error handling during execution (backtrace).
2--  Copyright (C) 2002 - 2014 Tristan Gingold
3--
4--  This program is free software: you can redistribute it and/or modify
5--  it under the terms of the GNU General Public License as published by
6--  the Free Software Foundation, either version 2 of the License, or
7--  (at your option) any later version.
8--
9--  This program is distributed in the hope that it will be useful,
10--  but WITHOUT ANY WARRANTY; without even the implied warranty of
11--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12--  GNU General Public License for more details.
13--
14--  You should have received a copy of the GNU General Public License
15--  along with this program.  If not, see <gnu.org/licenses>.
16--
17--  As a special exception, if other files instantiate generics from this
18--  unit, or you link this unit with other files to produce an executable,
19--  this unit does not by itself cause the resulting executable to be
20--  covered by the GNU General Public License. This exception does not
21--  however invalidate any other reasons why the executable file might be
22--  covered by the GNU Public License.
23with Grt.Types; use Grt.Types;
24
25package Grt.Errors_Exec is
26   --  Complete error message with a call stack.  SKIP is the number of
27   --  frame to skip, 0 means the caller of this procedure is displayed.
28   procedure Error_Call_Stack (Str : String; Skip : Natural);
29
30   --  Backtrace used to report call stack in case of error.
31   --  Note: for simplicity we assume that a PC is enough to display the
32   --  corresponding file name, line number and routine name.  Might not be
33   --  true on some platforms.
34   --  There is a C version of this record in grt_itf.h
35   type Integer_Address_Array is array (Natural range <>) of Integer_Address;
36   type Backtrace_Addrs is record
37      Size : Natural;
38      Skip : Natural;
39      Addrs : Integer_Address_Array (0 .. 31);
40   end record;
41   pragma Convention (C, Backtrace_Addrs);
42
43   type Backtrace_Addrs_Acc is access Backtrace_Addrs;
44
45   --  Save the current backtrace to BT, but skip SKIP frame.  0 means that
46   --  the caller of this procedure will be in the backtrace.
47   procedure Save_Backtrace (Bt : out Backtrace_Addrs; Skip : Natural);
48   pragma Import (C, Save_Backtrace, "grt_save_backtrace");
49
50   --  Finish error message with a call stack.
51   procedure Error_E_Call_Stack (Bt : Backtrace_Addrs);
52   pragma No_Return (Error_E_Call_Stack);
53
54   procedure Error_E_Call_Stack (Bt : Backtrace_Addrs_Acc);
55   pragma No_Return (Error_E_Call_Stack);
56
57   --  Display an error message for an overflow.
58   procedure Grt_Overflow_Error (Bt : Backtrace_Addrs_Acc);
59   pragma No_Return (Grt_Overflow_Error);
60
61   --  Display an error message for a NULL access dereference.
62   procedure Grt_Null_Access_Error (Bt : Backtrace_Addrs_Acc);
63   pragma No_Return (Grt_Null_Access_Error);
64private
65   pragma Export (C, Grt_Overflow_Error, "grt_overflow_error");
66   pragma Export (C, Grt_Null_Access_Error, "grt_null_access_error");
67end Grt.Errors_Exec;
68