WeixiangYan/CodeTransOcean huggingface dataset:
Task: Find limit of recursion

C: #include <stdio.h>

void recurse(unsigned int i)
{
  printf("%d\n", i);
  recurse(i+1); 
}

int main()
{
  recurse(0);
  return 0;
}










Fortran: program recursion_depth

  implicit none

  call recurse (1)

contains

  recursive subroutine recurse (i)

    implicit none
    integer, intent (in) :: i

    write (*, '(i0)') i
    call recurse (i + 1)

  end subroutine recurse

end program recursion_depth
Task: Find limit of recursion





Java: public class RecursionTest {
	
    private static void recurse(int i) {
        try {
	    recurse(i+1);
	} catch (StackOverflowError e) {
	    System.out.print("Recursion depth on this system is " + i + ".");
	}
    }
	
    public static void main(String[] args) {
        recurse(0);
    }
}






Fortran: program recursion_depth

  implicit none

  call recurse (1)

contains

  recursive subroutine recurse (i)

    implicit none
    integer, intent (in) :: i

    write (*, '(i0)') i
    call recurse (i + 1)

  end subroutine recurse

end program recursion_depth
Task: Find limit of recursion







Python: import sys
print(sys.getrecursionlimit())




Fortran: program recursion_depth

  implicit none

  call recurse (1)

contains

  recursive subroutine recurse (i)

    implicit none
    integer, intent (in) :: i

    write (*, '(i0)') i
    call recurse (i + 1)

  end subroutine recurse

end program recursion_depth
Task: Find limit of recursion








VB: Option Explicit

Sub Main()
    Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub

Function Limite_Recursivite(Cpt As Long) As Long
    Cpt = Cpt + 1               
    On Error Resume Next
    Limite_Recursivite Cpt      
    On Error GoTo 0
    Limite_Recursivite = Cpt    
End Function



Fortran: program recursion_depth

  implicit none

  call recurse (1)

contains

  recursive subroutine recurse (i)

    implicit none
    integer, intent (in) :: i

    write (*, '(i0)') i
    call recurse (i + 1)

  end subroutine recurse

end program recursion_depth
Task: Find limit of recursion






PHP: <?php
function a() {
    static $i = 0;
    print ++$i . "\n";
    a();
}
a();





Fortran: program recursion_depth

  implicit none

  call recurse (1)

contains

  recursive subroutine recurse (i)

    implicit none
    integer, intent (in) :: i

    write (*, '(i0)') i
    call recurse (i + 1)

  end subroutine recurse

end program recursion_depth
Task: Find limit of recursion

C: #include <stdio.h>

void recurse(unsigned int i)
{
  printf("%d\n", i);
  recurse(i+1); 
}

int main()
{
  recurse(0);
  return 0;
}









COBOL: identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter	pic 9(3).
01  install-address   	usage is procedure-pointer.
01  install-flag      	pic x comp-x value 0.
01  status-code       	pic x(2) comp-5.
01  ind               	pic s9(9) comp-5.


linkage section.
01  err-msg           	pic x(325).

procedure division.
100-main.

	set install-address to entry "300-err".
	
	call "CBL_ERROR_PROC" using install-flag
		install-address
		returning status-code.

	if status-code not = 0
		display "ERROR INSTALLING ERROR PROC"
		stop run
        end-if

 	move 0 to depth-counter.
	display 'Mung until no good.'.
	perform 200-mung.
	display 'No good.'.
	stop run.

200-mung.
	add 1 to depth-counter.
	display depth-counter.
	perform 200-mung.
300-err.
	entry "300-err" using err-msg.
	perform varying ind from 1 by 1
		until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
			continue
	end-perform

	display err-msg(1:ind).


	
	exit program.
Task: Find limit of recursion



C#: using System;
class RecursionLimit
{
  static void Main(string[] args)
  {
    Recur(0);
  }
 
  private static void Recur(int i) 
  {
    Console.WriteLine(i);
    Recur(i + 1);
  }
}







COBOL: identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter	pic 9(3).
01  install-address   	usage is procedure-pointer.
01  install-flag      	pic x comp-x value 0.
01  status-code       	pic x(2) comp-5.
01  ind               	pic s9(9) comp-5.


linkage section.
01  err-msg           	pic x(325).

procedure division.
100-main.

	set install-address to entry "300-err".
	
	call "CBL_ERROR_PROC" using install-flag
		install-address
		returning status-code.

	if status-code not = 0
		display "ERROR INSTALLING ERROR PROC"
		stop run
        end-if

 	move 0 to depth-counter.
	display 'Mung until no good.'.
	perform 200-mung.
	display 'No good.'.
	stop run.

200-mung.
	add 1 to depth-counter.
	display depth-counter.
	perform 200-mung.
300-err.
	entry "300-err" using err-msg.
	perform varying ind from 1 by 1
		until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
			continue
	end-perform

	display err-msg(1:ind).


	
	exit program.
Task: Find limit of recursion


C++: #include <iostream>
 
void recurse(unsigned int i)
{
  std::cout<<i<<"\n";
  recurse(i+1);
}
 
int main()
{
  recurse(0);
}








COBOL: identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter	pic 9(3).
01  install-address   	usage is procedure-pointer.
01  install-flag      	pic x comp-x value 0.
01  status-code       	pic x(2) comp-5.
01  ind               	pic s9(9) comp-5.


linkage section.
01  err-msg           	pic x(325).

procedure division.
100-main.

	set install-address to entry "300-err".
	
	call "CBL_ERROR_PROC" using install-flag
		install-address
		returning status-code.

	if status-code not = 0
		display "ERROR INSTALLING ERROR PROC"
		stop run
        end-if

 	move 0 to depth-counter.
	display 'Mung until no good.'.
	perform 200-mung.
	display 'No good.'.
	stop run.

200-mung.
	add 1 to depth-counter.
	display depth-counter.
	perform 200-mung.
300-err.
	entry "300-err" using err-msg.
	perform varying ind from 1 by 1
		until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
			continue
	end-perform

	display err-msg(1:ind).


	
	exit program.
Task: Find limit of recursion





Java: public class RecursionTest {
	
    private static void recurse(int i) {
        try {
	    recurse(i+1);
	} catch (StackOverflowError e) {
	    System.out.print("Recursion depth on this system is " + i + ".");
	}
    }
	
    public static void main(String[] args) {
        recurse(0);
    }
}





COBOL: identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter	pic 9(3).
01  install-address   	usage is procedure-pointer.
01  install-flag      	pic x comp-x value 0.
01  status-code       	pic x(2) comp-5.
01  ind               	pic s9(9) comp-5.


linkage section.
01  err-msg           	pic x(325).

procedure division.
100-main.

	set install-address to entry "300-err".
	
	call "CBL_ERROR_PROC" using install-flag
		install-address
		returning status-code.

	if status-code not = 0
		display "ERROR INSTALLING ERROR PROC"
		stop run
        end-if

 	move 0 to depth-counter.
	display 'Mung until no good.'.
	perform 200-mung.
	display 'No good.'.
	stop run.

200-mung.
	add 1 to depth-counter.
	display depth-counter.
	perform 200-mung.
300-err.
	entry "300-err" using err-msg.
	perform varying ind from 1 by 1
		until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
			continue
	end-perform

	display err-msg(1:ind).


	
	exit program.
Task: Find limit of recursion







Python: import sys
print(sys.getrecursionlimit())



COBOL: identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter	pic 9(3).
01  install-address   	usage is procedure-pointer.
01  install-flag      	pic x comp-x value 0.
01  status-code       	pic x(2) comp-5.
01  ind               	pic s9(9) comp-5.


linkage section.
01  err-msg           	pic x(325).

procedure division.
100-main.

	set install-address to entry "300-err".
	
	call "CBL_ERROR_PROC" using install-flag
		install-address
		returning status-code.

	if status-code not = 0
		display "ERROR INSTALLING ERROR PROC"
		stop run
        end-if

 	move 0 to depth-counter.
	display 'Mung until no good.'.
	perform 200-mung.
	display 'No good.'.
	stop run.

200-mung.
	add 1 to depth-counter.
	display depth-counter.
	perform 200-mung.
300-err.
	entry "300-err" using err-msg.
	perform varying ind from 1 by 1
		until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
			continue
	end-perform

	display err-msg(1:ind).


	
	exit program.
Task: Find limit of recursion








VB: Option Explicit

Sub Main()
    Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub

Function Limite_Recursivite(Cpt As Long) As Long
    Cpt = Cpt + 1               
    On Error Resume Next
    Limite_Recursivite Cpt      
    On Error GoTo 0
    Limite_Recursivite = Cpt    
End Function


COBOL: identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter	pic 9(3).
01  install-address   	usage is procedure-pointer.
01  install-flag      	pic x comp-x value 0.
01  status-code       	pic x(2) comp-5.
01  ind               	pic s9(9) comp-5.


linkage section.
01  err-msg           	pic x(325).

procedure division.
100-main.

	set install-address to entry "300-err".
	
	call "CBL_ERROR_PROC" using install-flag
		install-address
		returning status-code.

	if status-code not = 0
		display "ERROR INSTALLING ERROR PROC"
		stop run
        end-if

 	move 0 to depth-counter.
	display 'Mung until no good.'.
	perform 200-mung.
	display 'No good.'.
	stop run.

200-mung.
	add 1 to depth-counter.
	display depth-counter.
	perform 200-mung.
300-err.
	entry "300-err" using err-msg.
	perform varying ind from 1 by 1
		until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
			continue
	end-perform

	display err-msg(1:ind).


	
	exit program.
Task: Find limit of recursion




Go: package main

import (
	"flag"
	"fmt"
	"runtime/debug"
)

func main() {
	stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
	flag.Parse()
	if *stack > 0 {
		debug.SetMaxStack(*stack)
	}
	r(1)
}

func r(l int) {
	if l%1000 == 0 {
		fmt.Println(l)
	}
	r(l + 1)
}






COBOL: identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter	pic 9(3).
01  install-address   	usage is procedure-pointer.
01  install-flag      	pic x comp-x value 0.
01  status-code       	pic x(2) comp-5.
01  ind               	pic s9(9) comp-5.


linkage section.
01  err-msg           	pic x(325).

procedure division.
100-main.

	set install-address to entry "300-err".
	
	call "CBL_ERROR_PROC" using install-flag
		install-address
		returning status-code.

	if status-code not = 0
		display "ERROR INSTALLING ERROR PROC"
		stop run
        end-if

 	move 0 to depth-counter.
	display 'Mung until no good.'.
	perform 200-mung.
	display 'No good.'.
	stop run.

200-mung.
	add 1 to depth-counter.
	display depth-counter.
	perform 200-mung.
300-err.
	entry "300-err" using err-msg.
	perform varying ind from 1 by 1
		until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
			continue
	end-perform

	display err-msg(1:ind).


	
	exit program.
Task: Find limit of recursion






PHP: <?php
function a() {
    static $i = 0;
    print ++$i . "\n";
    a();
}
a();
Task: Find limit of recursion






PHP: <?php
function a() {
    static $i = 0;
    print ++$i . "\n";
    a();
}
a();






Ada: with Ada.Text_IO;  use Ada.Text_IO;

procedure Test_Recursion_Depth is
   function Recursion (Depth : Positive) return Positive is
   begin
      return Recursion (Depth + 1);
   exception
      when Storage_Error =>
         return Depth;
   end Recursion;
begin
   Put_Line ("Recursion depth on this system is" & Integer'Image (Recursion (1)));
end Test_Recursion_Depth;
Task: Find limit of recursion






PHP: <?php
function a() {
    static $i = 0;
    print ++$i . "\n";
    a();
}
a();




COBOL: identification division.
program-id. recurse.
data division.
working-storage section.
01 depth-counter	pic 9(3).
01  install-address   	usage is procedure-pointer.
01  install-flag      	pic x comp-x value 0.
01  status-code       	pic x(2) comp-5.
01  ind               	pic s9(9) comp-5.


linkage section.
01  err-msg           	pic x(325).

procedure division.
100-main.

	set install-address to entry "300-err".
	
	call "CBL_ERROR_PROC" using install-flag
		install-address
		returning status-code.

	if status-code not = 0
		display "ERROR INSTALLING ERROR PROC"
		stop run
        end-if

 	move 0 to depth-counter.
	display 'Mung until no good.'.
	perform 200-mung.
	display 'No good.'.
	stop run.

200-mung.
	add 1 to depth-counter.
	display depth-counter.
	perform 200-mung.
300-err.
	entry "300-err" using err-msg.
	perform varying ind from 1 by 1
		until (err-msg(ind:1) = x"00") or (ind = length of err-msg)
			continue
	end-perform

	display err-msg(1:ind).


	
	exit program.
Task: Stack traces



C#: using System;
using System.Diagnostics;

class Program
{
    static void Inner()
    {
        Console.WriteLine(new StackTrace());
    }

    static void Middle()
    {
        Inner();
    }

    static void Outer()
    {
        Middle();
    }

    static void Main()
    {
        Outer();
    }
}









Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Traceback;
with 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; 

   procedure Inner (K : Integer) is
   begin
      Call_Stack;
   end Inner;
 
   procedure Middle (X, Y : Integer) is
   begin
      Inner (X * Y);
   end Middle;
 
   procedure Outer (A, B, C : Integer) is
   begin
     Middle (A + B, B + C);
   end Outer;
   
begin
  Outer (2,3,5);
end Test_Stack_Trace;
Task: Stack traces

C: #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <execinfo.h>

#define MAX_BT 200

void print_stack_trace()
{
  void *buffer[MAX_BT];
  int n;

  n = backtrace(buffer, MAX_BT);
  fprintf(stderr, "--- (depth %d) ---\n", n);
  backtrace_symbols_fd(buffer, n, STDERR_FILENO);
}


void inner(int k)
{
  print_stack_trace();
}

void middle(int x, int y)
{
  inner(x*y);
}

void outer(int a, int b, int c)
{
  middle(a+b, b+c);
}

int main()
{
  outer(2,3,5);
  return EXIT_SUCCESS;
}











Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Traceback;
with 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; 

   procedure Inner (K : Integer) is
   begin
      Call_Stack;
   end Inner;
 
   procedure Middle (X, Y : Integer) is
   begin
      Inner (X * Y);
   end Middle;
 
   procedure Outer (A, B, C : Integer) is
   begin
     Middle (A + B, B + C);
   end Outer;
   
begin
  Outer (2,3,5);
end Test_Stack_Trace;
Task: Stack traces




Go: package main

import (
    "fmt"
    "runtime"
)

func main() {
    stackTrace := make([]byte, 1024)
    n := runtime.Stack(stackTrace, true)
    stackTrace = stackTrace[:n]
    fmt.Printf("%s\n", stackTrace)
    fmt.Printf("(%d bytes)\n", len(stackTrace))
}








Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Traceback;
with 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; 

   procedure Inner (K : Integer) is
   begin
      Call_Stack;
   end Inner;
 
   procedure Middle (X, Y : Integer) is
   begin
      Inner (X * Y);
   end Middle;
 
   procedure Outer (A, B, C : Integer) is
   begin
     Middle (A + B, B + C);
   end Outer;
   
begin
  Outer (2,3,5);
end Test_Stack_Trace;
Task: Stack traces





Java: public class StackTracer {
    public static void printStackTrace() {
	StackTraceElement[] elems = Thread.currentThread().getStackTrace();

	System.out.println("Stack trace:");
	for (int i = elems.length-1, j = 2 ; i >= 3 ; i--, j+=2) {
	    System.out.printf("%" + j + "s%s.%s%n", "",
		    elems[i].getClassName(), elems[i].getMethodName());
	}
    }
}







Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Traceback;
with 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; 

   procedure Inner (K : Integer) is
   begin
      Call_Stack;
   end Inner;
 
   procedure Middle (X, Y : Integer) is
   begin
      Inner (X * Y);
   end Middle;
 
   procedure Outer (A, B, C : Integer) is
   begin
     Middle (A + B, B + C);
   end Outer;
   
begin
  Outer (2,3,5);
end Test_Stack_Trace;
Task: Stack traces







Python: import traceback

def f(): return g()
def g(): traceback.print_stack()

f()





Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Traceback;
with 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; 

   procedure Inner (K : Integer) is
   begin
      Call_Stack;
   end Inner;
 
   procedure Middle (X, Y : Integer) is
   begin
      Inner (X * Y);
   end Middle;
 
   procedure Outer (A, B, C : Integer) is
   begin
     Middle (A + B, B + C);
   end Outer;
   
begin
  Outer (2,3,5);
end Test_Stack_Trace;
Task: Stack traces








VB: #include "windows.bi"

Private Function Fn2() As Long
    Dim frames(0 To 60) As Any Ptr
    Dim framesPtr As Any Ptr Ptr = @frames(0)
    Dim hash As DWORD
    Dim As Long caught = CaptureStackBackTrace(0, 61, framesPtr, @hash)
    Print Using "Caught & frames using stack capture"; caught
    For i As Long = 0 To caught - 1
        Print Using "&) &"; caught - i; Hex(frames(i))
    Next
    Return caught
End Function

Private Sub Fn1(num As Ulong)
    Dim As Long numFn2 = Fn2()
    Print Using "Fn2 returned & with num = &"; numFn2; num
End Sub

Fn1(87)
Sleep




Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Traceback;
with 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; 

   procedure Inner (K : Integer) is
   begin
      Call_Stack;
   end Inner;
 
   procedure Middle (X, Y : Integer) is
   begin
      Inner (X * Y);
   end Middle;
 
   procedure Outer (A, B, C : Integer) is
   begin
     Middle (A + B, B + C);
   end Outer;
   
begin
  Outer (2,3,5);
end Test_Stack_Trace;
Task: Stack traces

C: #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <execinfo.h>

#define MAX_BT 200

void print_stack_trace()
{
  void *buffer[MAX_BT];
  int n;

  n = backtrace(buffer, MAX_BT);
  fprintf(stderr, "--- (depth %d) ---\n", n);
  backtrace_symbols_fd(buffer, n, STDERR_FILENO);
}


void inner(int k)
{
  print_stack_trace();
}

void middle(int x, int y)
{
  inner(x*y);
}

void outer(int a, int b, int c)
{
  middle(a+b, b+c);
}

int main()
{
  outer(2,3,5);
  return EXIT_SUCCESS;
}
Task: Stack traces



C#: using System;
using System.Diagnostics;

class Program
{
    static void Inner()
    {
        Console.WriteLine(new StackTrace());
    }

    static void Middle()
    {
        Inner();
    }

    static void Outer()
    {
        Middle();
    }

    static void Main()
    {
        Outer();
    }
}
Task: Stack traces





Java: public class StackTracer {
    public static void printStackTrace() {
	StackTraceElement[] elems = Thread.currentThread().getStackTrace();

	System.out.println("Stack trace:");
	for (int i = elems.length-1, j = 2 ; i >= 3 ; i--, j+=2) {
	    System.out.printf("%" + j + "s%s.%s%n", "",
		    elems[i].getClassName(), elems[i].getMethodName());
	}
    }
}
Task: Stack traces







Python: import traceback

def f(): return g()
def g(): traceback.print_stack()

f()
Task: Stack traces








VB: #include "windows.bi"

Private Function Fn2() As Long
    Dim frames(0 To 60) As Any Ptr
    Dim framesPtr As Any Ptr Ptr = @frames(0)
    Dim hash As DWORD
    Dim As Long caught = CaptureStackBackTrace(0, 61, framesPtr, @hash)
    Print Using "Caught & frames using stack capture"; caught
    For i As Long = 0 To caught - 1
        Print Using "&) &"; caught - i; Hex(frames(i))
    Next
    Return caught
End Function

Private Sub Fn1(num As Ulong)
    Dim As Long numFn2 = Fn2()
    Print Using "Fn2 returned & with num = &"; numFn2; num
End Sub

Fn1(87)
Sleep
Task: Stack traces




Go: package main

import (
    "fmt"
    "runtime"
)

func main() {
    stackTrace := make([]byte, 1024)
    n := runtime.Stack(stackTrace, true)
    stackTrace = stackTrace[:n]
    fmt.Printf("%s\n", stackTrace)
    fmt.Printf("(%d bytes)\n", len(stackTrace))
}
Task: Stack traces






PHP: <?php
class StackTraceDemo {
    static function inner() {
        debug_print_backtrace();
    }
    static function middle() {
        self::inner();
    }
    static function outer() {
        self::middle();
    }
}

StackTraceDemo::outer();
?>






Ada: with Ada.Text_IO;  use Ada.Text_IO;
with GNAT.Traceback;
with 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; 

   procedure Inner (K : Integer) is
   begin
      Call_Stack;
   end Inner;
 
   procedure Middle (X, Y : Integer) is
   begin
      Inner (X * Y);
   end Middle;
 
   procedure Outer (A, B, C : Integer) is
   begin
     Middle (A + B, B + C);
   end Outer;
   
begin
  Outer (2,3,5);
end Test_Stack_Trace;
Task: Stack traces






PHP: <?php
class StackTraceDemo {
    static function inner() {
        debug_print_backtrace();
    }
    static function middle() {
        self::inner();
    }
    static function outer() {
        self::middle();
    }
}

StackTraceDemo::outer();
?>