From 9328056ba3cbc5cddef1d7ef6b57ae97bbefb808 Mon Sep 17 00:00:00 2001 From: Dmitriy Anisimkov Date: Fri, 5 Jul 2019 07:01:40 +0000 Subject: [PATCH] [Ada] GNAT.Traceback: add a Call_Chain function 2019-07-05 Dmitriy Anisimkov gcc/ada/ * libgnat/g-traceb.ads, libgnat/g-traceb.adb (Call_Chain): New function. From-SVN: r273101 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/libgnat/g-traceb.adb | 14 ++++++++++++-- gcc/ada/libgnat/g-traceb.ads | 9 +++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index bc6f2e0ac33..aac81ea1f93 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-07-05 Dmitriy Anisimkov + + * libgnat/g-traceb.ads, libgnat/g-traceb.adb (Call_Chain): New + function. + 2019-07-04 James Clarke * libgnarl/s-osinte__kfreebsd-gnu.ads (clockid_t): Make type diff --git a/gcc/ada/libgnat/g-traceb.adb b/gcc/ada/libgnat/g-traceb.adb index cc52e5789c6..f40d84ef66e 100644 --- a/gcc/ada/libgnat/g-traceb.adb +++ b/gcc/ada/libgnat/g-traceb.adb @@ -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; diff --git a/gcc/ada/libgnat/g-traceb.ads b/gcc/ada/libgnat/g-traceb.ads index aeb3b0a24e9..bdd46b25cce 100644 --- a/gcc/ada/libgnat/g-traceb.ads +++ b/gcc/ada/libgnat/g-traceb.ads @@ -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; -- 2.30.2