diff options
Diffstat (limited to 'src/synth/elab-debugger.adb')
-rw-r--r-- | src/synth/elab-debugger.adb | 102 |
1 files changed, 68 insertions, 34 deletions
diff --git a/src/synth/elab-debugger.adb b/src/synth/elab-debugger.adb index e9f372dc3..f1138904f 100644 --- a/src/synth/elab-debugger.adb +++ b/src/synth/elab-debugger.adb @@ -33,8 +33,6 @@ with Elab.Vhdl_Context.Debug; use Elab.Vhdl_Context.Debug; with Elab.Vhdl_Debug; use Elab.Vhdl_Debug; package body Elab.Debugger is - Flag_Enabled : Boolean := False; - Current_Instance : Synth_Instance_Acc; Current_Loc : Node; @@ -42,9 +40,15 @@ package body Elab.Debugger is ( Reason_Init, Reason_Break, + Reason_Time, Reason_Error ); + function Debug_Current_Instance return Synth_Instance_Acc is + begin + return Current_Instance; + end Debug_Current_Instance; + package Breakpoints is new Tables (Table_Index_Type => Natural, Table_Component_Type => Node, @@ -491,6 +495,47 @@ package body Elab.Debugger is Prepare_Continue; end Cont_Proc; + procedure Disp_A_Frame (Inst: Synth_Instance_Acc) + is + Src : Node; + begin + if Inst = Root_Instance then + Put_Line ("root instance"); + return; + end if; + + Src := Get_Source_Scope (Inst); + Put (Vhdl.Errors.Disp_Node (Src)); + Put (" at "); + Put (Files_Map.Image (Get_Location (Src))); + New_Line; + end Disp_A_Frame; + + procedure Debug_Bt (Instance : Synth_Instance_Acc) + is + Inst : Synth_Instance_Acc; + begin + Inst := Instance; + while Inst /= null loop + Disp_A_Frame (Inst); + Inst := Get_Caller_Instance (Inst); + end loop; + end Debug_Bt; + pragma Unreferenced (Debug_Bt); + + procedure Where_Proc (Line : String) + is + pragma Unreferenced (Line); + Inst : Synth_Instance_Acc; + begin + -- Check_Current_Process; + Inst := Current_Instance; + while Inst /= null loop + Disp_A_Frame (Inst); + Inst := Get_Caller_Instance (Inst); + end loop; + end Where_Proc; + procedure List_Proc (Line : String) is pragma Unreferenced (Line); @@ -654,11 +699,18 @@ package body Elab.Debugger is Next => Menu_Step'Access, Proc => Break_Proc'Access); + Menu_Where : aliased Menu_Entry := + (Kind => Menu_Command, + Name => new String'("w*here"), + Help => new String'("disp call stack"), + Next => Menu_Break'Access, + Proc => Where_Proc'Access); + Menu_Help2 : aliased Menu_Entry := (Kind => Menu_Command, Name => new String'("?"), Help => new String'("print help"), - Next => Menu_Break'Access, -- Menu_Help1'Access, + Next => Menu_Where'Access, Proc => Help_Proc'Access); Menu_Top : aliased Menu_Entry := @@ -836,7 +888,8 @@ package body Elab.Debugger is end case; -- Default state. Exec_State := Exec_Run; - + when Reason_Time => + Exec_State := Exec_Run; end case; case Reason is @@ -921,7 +974,7 @@ package body Elab.Debugger is procedure Debug_Init (Top : Node) is begin - Flag_Enabled := True; + Flag_Debug_Enable := True; Current_Instance := null; Current_Loc := Top; @@ -937,7 +990,7 @@ package body Elab.Debugger is begin Current_Instance := Top; Current_Loc := Get_Source_Scope (Top); - Flag_Enabled := True; + Flag_Debug_Enable := True; -- To avoid warnings. Exec_Statement := Null_Node; @@ -954,6 +1007,14 @@ package body Elab.Debugger is Debug (Reason_Break); end Debug_Break; + procedure Debug_Time is + begin + Current_Instance := Root_Instance; + Current_Loc := Null_Node; + + Debug (Reason_Time); + end Debug_Time; + procedure Debug_Leave (Inst : Synth_Instance_Acc) is begin if Exec_Instance = Inst then @@ -975,38 +1036,11 @@ package body Elab.Debugger is procedure Debug_Error (Inst : Synth_Instance_Acc; Expr : Node) is begin - if Flag_Enabled then + if Flag_Debug_Enable then Current_Instance := Inst; Current_Loc := Expr; Debug (Reason_Error); end if; end Debug_Error; - procedure Disp_A_Frame (Inst: Synth_Instance_Acc) is - begin - if Inst = Root_Instance then - Put_Line ("root instance"); - return; - end if; - - Put (Vhdl.Errors.Disp_Node (Get_Source_Scope (Inst))); --- if Inst.Stmt /= Null_Iir then --- Put (" at "); --- Put (Files_Map.Image (Get_Location (Inst.Stmt))); --- end if; - New_Line; - end Disp_A_Frame; - - procedure Debug_Bt (Instance : Synth_Instance_Acc) - is - Inst : Synth_Instance_Acc; - begin - Inst := Instance; - while Inst /= null loop - Disp_A_Frame (Inst); - Inst := Get_Caller_Instance (Inst); - end loop; - end Debug_Bt; - pragma Unreferenced (Debug_Bt); - end Elab.Debugger; |