[Ada] GNAT.Traceback: add a Call_Chain function
authorDmitriy Anisimkov <anisimko@adacore.com>
Fri, 5 Jul 2019 07:01:40 +0000 (07:01 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Fri, 5 Jul 2019 07:01:40 +0000 (07:01 +0000)
2019-07-05  Dmitriy Anisimkov  <anisimko@adacore.com>

gcc/ada/

* libgnat/g-traceb.ads, libgnat/g-traceb.adb (Call_Chain): New
function.

From-SVN: r273101

gcc/ada/ChangeLog
gcc/ada/libgnat/g-traceb.adb
gcc/ada/libgnat/g-traceb.ads

index bc6f2e0..aac81ea 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-05  Dmitriy Anisimkov  <anisimko@adacore.com>
+
+       * libgnat/g-traceb.ads, libgnat/g-traceb.adb (Call_Chain): New
+       function.
+
 2019-07-04  James Clarke <jrtc27@debian.org>
 
        * libgnarl/s-osinte__kfreebsd-gnu.ads (clockid_t): Make type
index cc52e57..f40d84e 100644 (file)
@@ -41,10 +41,20 @@ package body GNAT.Traceback is
 
    procedure Call_Chain
      (Traceback : out Tracebacks_Array;
-      Len       : out Natural)
-   is
+      Len       : out Natural) is
    begin
       System.Traceback.Call_Chain (Traceback, Traceback'Length, Len);
    end Call_Chain;
 
+   function Call_Chain
+     (Max_Len : Positive; Skip_Frames : Natural := 1) return Tracebacks_Array
+   is
+      Traceback : Tracebacks_Array (1 .. Max_Len);
+      Len       : Natural;
+   begin
+      System.Traceback.Call_Chain
+        (Traceback, Max_Len, Len, Skip_Frames => Skip_Frames + 1);
+      return Traceback (1 .. Len);
+   end Call_Chain;
+
 end GNAT.Traceback;
index aeb3b0a..bdd46b2 100644 (file)
@@ -98,4 +98,13 @@ package GNAT.Traceback is
    --  shorter, in which case positions in Traceback past the Len position
    --  are undefined on return.
 
+   function Call_Chain
+     (Max_Len : Positive; Skip_Frames : Natural := 1) return Tracebacks_Array;
+   --  Returns up to Max_Len tracebacks corresponding to the current call
+   --  chain. Result array order is the same as in above procedure Call_Chain
+   --  except that Skip_Frames says how many of the most recent calls should be
+   --  excluded from the result, starting with this procedure itself: 1 means
+   --  exclude the frame for this procedure, 2 means 1 + exclude the frame for
+   --  this procedure's caller, ...
+
 end GNAT.Traceback;