comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Last chance handler on a PC
Date: Thu, 30 Jan 2020 22:26:38 +0200
Date: 2020-01-30T22:26:38+02:00	[thread overview]
Message-ID: <h9gsfuF64cjU1@mid.individual.net> (raw)
In-Reply-To: <r0vcob$ddf$1@dont-email.me>

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
       .      @       .


  reply	other threads:[~2020-01-30 20:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30  8:55 Last chance handler on a PC ahlan
2020-01-30  9:15 ` J-P. Rosen
2020-01-30  9:17 ` Egil H H
2020-01-30 19:27   ` ahlan
2020-01-31  5:53     ` J-P. Rosen
2020-01-31  7:00       ` Jeffrey R. Carter
2020-01-31  8:51         ` J-P. Rosen
2020-01-30  9:25 ` Dmitry A. Kazakov
2020-01-30 19:10 ` Lucretia
2020-01-30 19:35 ` ahlan
2020-01-30 20:02   ` Jeffrey R. Carter
2020-01-30 20:26     ` Niklas Holsti [this message]
2020-01-30 20:51       ` Jeffrey R. Carter
2020-01-30 21:32         ` Niklas Holsti
2020-01-31 11:12       ` Simon Wright
2020-01-31 11:19         ` Simon Wright
2020-01-31 12:30           ` Niklas Holsti
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox