Patchwork [Ada] Save occurrence on the stack before calling last chance handler

login
register
mail settings
Submitter Arnaud Charlet
Date May 15, 2012, 10:22 a.m.
Message ID <20120515102233.GA13595@adacore.com>
Download mbox | patch
Permalink /patch/159285/
State New
Headers show

Comments

Arnaud Charlet - May 15, 2012, 10:22 a.m.
The occurrence was already saved but in dynamically allocated memory.
This patch saves it on the stack to avoid the allocation, which useful
in case of Storage_Error.
No functional change in normal conditions.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-05-15  Tristan Gingold  <gingold@adacore.com>

	* a-exextr.adb (Unhandled_Exception_Terminate): Save occurrence
	on the stack to avoid a dynamic memory allocation.

Patch

Index: a-exextr.adb
===================================================================
--- a-exextr.adb	(revision 187501)
+++ a-exextr.adb	(working copy)
@@ -6,7 +6,7 @@ 
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2012, Free Software Foundation, Inc.         --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -162,14 +162,15 @@ 
    -----------------------------------
 
    procedure Unhandled_Exception_Terminate is
-      Excep : constant EOA := Save_Occurrence (Get_Current_Excep.all.all);
+      Excep : Exception_Occurrence;
       --  This occurrence will be used to display a message after finalization.
       --  It is necessary to save a copy here, or else the designated value
       --  could be overwritten if an exception is raised during finalization
       --  (even if that exception is caught).
 
    begin
-      Last_Chance_Handler (Excep.all);
+      Save_Occurrence (Excep, Get_Current_Excep.all.all);
+      Last_Chance_Handler (Excep);
    end Unhandled_Exception_Terminate;
 
    ------------------------------------