From a72c06fdfbf4a18bc8fc9728113f5a99ee25d6eb Mon Sep 17 00:00:00 2001
From: Tristan Gingold <tgingold@free.fr>
Date: Sat, 14 Jan 2023 18:52:27 +0100
Subject: synth: add Debug_Backtrace debug procedure

---
 src/synth/elab-vhdl_context-debug.adb | 13 +++++++++++++
 src/synth/elab-vhdl_values-debug.adb  |  6 ++++++
 2 files changed, 19 insertions(+)

diff --git a/src/synth/elab-vhdl_context-debug.adb b/src/synth/elab-vhdl_context-debug.adb
index 79b59187a..2ce44425a 100644
--- a/src/synth/elab-vhdl_context-debug.adb
+++ b/src/synth/elab-vhdl_context-debug.adb
@@ -73,4 +73,17 @@ package body Elab.Vhdl_Context.Debug is
    begin
       Debug_Elab_Tree_1 (Inst, 0);
    end Debug_Elab_Tree;
+
+   procedure Debug_Backtrace (First : Synth_Instance_Acc)
+   is
+      Inst : Synth_Instance_Acc;
+   begin
+      Inst := First;
+      while Inst /= null loop
+         Debug_Synth_Instance (Inst);
+         Inst := Inst.Caller;
+      end loop;
+   end Debug_Backtrace;
+
+   pragma Unreferenced (Debug_Backtrace);
 end Elab.Vhdl_Context.Debug;
diff --git a/src/synth/elab-vhdl_values-debug.adb b/src/synth/elab-vhdl_values-debug.adb
index 76e8caa0a..63718b55d 100644
--- a/src/synth/elab-vhdl_values-debug.adb
+++ b/src/synth/elab-vhdl_values-debug.adb
@@ -297,6 +297,12 @@ package body Elab.Vhdl_Values.Debug is
 
    procedure Debug_Valtyp (V : Valtyp) is
    begin
+      if V.Val = null then
+         Put ("*null*");
+         New_Line;
+         return;
+      end if;
+
       case V.Val.Kind is
          when Value_Memory
            | Value_Const =>
-- 
cgit v1.2.3