From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,91c5b958fecf5eff X-Google-Attributes: gid103376,public From: Martin Kristensson Subject: Re: GNAT exception traceback Date: 1997/06/14 Message-ID: <33A287A6.7C16@dtek.chalmers.se>#1/1 X-Deja-AN: 248329173 References: <339EFAE3.26C@ccis.adisys.com.au> Organization: Chalmers University of Technology, Sweden Reply-To: d95krima@dtek.chalmers.se Newsgroups: comp.lang.ada Date: 1997-06-14T00:00:00+00:00 List-Id: Steve Gibson wrote: (snip) > My question is, without running gdb or adding additional exception > handlers, is it possible to generate traceback information to determine > which line of code in which package generated the exception, and if so > how ? > > For example: > CONSTRAINT_ERROR exception raised in package XXX line i > CONSTRAINT_ERROR exception propagated out of package YYY line j > CONSTRAINT_ERROR exception propagated out of package Main line k (snip) Why not simply add an exception handler to each subprogram, which will store the name of the subprogram (or simply echo the name to the terminal) and then re-raise the exception. ... exception when others => Trace_Exception(Package_Name, Subprogram_Name); raise; end Subprogram; The final handler (i.e. the main program) can print/store the name of the raised exception (using Ada.Exceptions.Name), together with a message to the user. If it seems like to much work, use a script to insert the extra lines, or only add the handler to routines that are "at the start of" the call chain. We use this approach at work, since our customers use classified (military) input files, so we generally can't recreate the error. The exception trace file provides at least a clue to what went wrong. /Martin.