aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/elab-debugger.ads
blob: 5a046c7bbb119a398683194ef503ab6df890590f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
--  Debugging during synthesis.
--  Copyright (C) 2019 Tristan Gingold
--
--  This file is part of GHDL.
--
--  This program is free software: you can redistribute it and/or modify
--  it under the terms of the GNU General Public License as published by
--  the Free Software Foundation, either version 2 of the License, or
--  (at your option) any later version.
--
--  This program is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--  GNU General Public License for more details.
--
--  You should have received a copy of the GNU General Public License
--  along with this program.  If not, see <gnu.org/licenses>.

with Types; use Types;

with Vhdl.Nodes; use Vhdl.Nodes;

with Elab.Vhdl_Context; use Elab.Vhdl_Context;

package Elab.Debugger is
   --  True to start debugger on error.
   Flag_Debug_Enable : Boolean := False;

   --  If true, debugging is enabled:
   --  * call Debug_Break() before executing the next sequential statement
   --  * call Debug_Leave when a frame is destroyed.
   Flag_Need_Debug : Boolean := False;

   procedure Debug_Init (Top : Node);

   --  Debug after elaboration.  TOP is the top-level unit.
   procedure Debug_Elab (Top : Synth_Instance_Acc);

   procedure Debug_Break (Inst : Synth_Instance_Acc; Stmt : Node);

   procedure Debug_Leave (Inst : Synth_Instance_Acc);

   --  Debug on a time breakpoint.
   procedure Debug_Time (Top : Synth_Instance_Acc);

   --  To be called in case of execution error, like:
   --  * index out of bounds.
   --  * assertion failuere
   procedure Debug_Error (Inst : Synth_Instance_Acc; Expr : Node);

   --  Hook called in case of fatal error.
   type Error_Hook_Type is access procedure;
   pragma Convention (C, Error_Hook_Type);
   Error_Hook : Error_Hook_Type;

   --  Get the current location.
   procedure Get_Debug_Loc (Inst : out Synth_Instance_Acc;
                            Loc : out Node);

   type Menu_Procedure is access procedure (Line : String);
   type Cst_String_Acc is access constant String;

   --  Append a command to the main menu.
   procedure Append_Menu_Command (Name : Cst_String_Acc;
                                  Help : Cst_String_Acc;
                                  Proc : Menu_Procedure);

   --  Append a command to the info menu.
   procedure Append_Info_Command (Name : Cst_String_Acc;
                                  Help : Cst_String_Acc;
                                  Proc : Menu_Procedure);

   --  Prepare resume execution.
   procedure Prepare_Continue;

   --  Utilities for menu commands.

   --  Return the position of the first non-blank character.
   function Skip_Blanks (S : String) return Positive;
   function Skip_Blanks (S : String; F : Positive) return Positive;

   --  Return the position of the last character of the word (the last
   --  non-blank character).
   function Get_Word (S : String) return Positive;
   function Get_Word (S : String; F : Positive) return Positive;

   --  Convert STR to number RES, set VALID to true iff the conversion is ok.
   procedure To_Num (Str : String; Res : out Uns32; Valid : out Boolean);
end Elab.Debugger;