Ada Bare Bones: Difference between revisions

[unchecked revision][unchecked revision]
Line 213:
===Last chance handler===
 
The Ada runtime requires the presence of a <tt>Last_Chance_Handler</tt> subprogram. This subprogram is used as a handler for any exceptions that are not explicitly handled within their subprogram. These calls to the <tt>Last_Chance_Handler</tt> procedure in the case of unhandled exceptions will be automatically generated by the compiler.
When you start to write and compile Ada using this custom environment, the compiler will automatically place calls from the runtime into your final binary (this is what the compiler normally does, but we've restricted it a lot). One of these calls is to '''Last_Chance_Handler''' so create 2 new files and place into ''rts/boards/'''<arch>'''/adainclude'', as follows.
 
In order to facilitate this the last chance handler procedure must be defined somewhere within the program. Typically this is defined within the runtime. The last chance handler procedure may have any name, however the compiler will search for a procedure with external linkage with the name <tt>__gnat_last_chance_handler</tt>.
 
Create the following files in the <tt>rts/boards/${arch}/adainclude</tt>:
 
====last_chance_handler.ads====
Line 232 ⟶ 236:
pragma Unreferenced (Source_Location, Line);
begin
-- TODO: Add in board-specific code to dump theexception infoinformation to serial/screen which.
-- is obviously board specific.
loop
null;
Line 240 ⟶ 243:
</source>
 
The contents of the <tt>Last_Chance_Handler</tt> procedure will need to be tailored to the specific platform of the kernel. Typically this procedure will dump information regarding the exception to output media such as a [[Serial_Ports|serial port]].
As you can see, the meat of the handler is actualy a null loop at the moment, this is something you need to complete for your OS kernel and also, per platform.
 
===Compiling the runtime===
Anonymous user