Stack traces: Difference between revisions

Line 8:
=={{header|Ada}}==
{{works with|GNAT}}
 
<!-- This code should not use "use". It makes the code hard to understand. -->
 
The provided solution is specific to the [[GNAT]] Ada compiler. Further it is restricted to some platforms. See the description of the package GNAT.Traceback supplied with [[GNAT]]. The switch -g must be used in order to include debug information into the executable.
<lang Ada>with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Traceback; use GNAT.Traceback;
with GNAT.Traceback.Symbolic; use GNAT.Traceback.Symbolic;
 
procedure Test_Stack_Trace is
procedure Call_Stack is
Trace : GNAT.Traceback.Tracebacks_Array (1..1_000);
Length : Natural;
begin
GNAT.Traceback.Call_Chain (Trace, Length);
Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (Trace (1..Length)));
end Call_Stack;