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=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Last chance handler on a PC Date: Thu, 30 Jan 2020 22:26:38 +0200 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net mfcskUiI6hUU1BqFi7pirAukv2GzM5OJzs7qiUmZuLw009hxQy Cancel-Lock: sha1:HAUzHrBJeFJZqmZBfxlY5Cj3KeM= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 In-Reply-To: Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:57992 Date: 2020-01-30T22:26:38+02:00 List-Id: On 2020-01-30 22:02, Jeffrey R. Carter wrote: > On 1/30/20 8:35 PM, ahlan@marriott.org wrote: >> >> To catch unhandled exceptions you only need to write a simple >> procedure and export it as __gnat_last_chance_handler. >> This is linked into the program in preference to the default last >> chance handler provided by GNAT. >> This procedure is called if nothing catches a raised exception. >> Including those raised during package elaboration. > > Doing > > Ada.Task_Termination.Set_Specific_Handler >    (T       => Ada.Task_Identification.Environment_Task, >     Handler => Last_Chance'access); > > should do the same thing more portably. It will be called when the > environment task terminates for any reason; you would only want it to > actually do something when Cause = Unhandled_Exception. Looks good, but to catch all elaboration-time exceptions (in other packages) the package that executes that call, in its own elaboration code, must be elaborated before all other packages. Do you have some easy way to ensure that, without inserting elaboration pragmas in all other packages? I had a similar elaboration problem some time ago in an embedded application, where I wanted to set up some HW error-trap handlers that I would like to be active also during elaboration, but I found no easy way to ensure that the trap-handling package would be elaborated before all other packages. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .