[Ada] Allow debugging finalization-related expanded code
authorArnaud Charlet <charlet@adacore.com>
Mon, 12 Oct 2020 07:50:53 +0000 (03:50 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Wed, 25 Nov 2020 13:22:26 +0000 (08:22 -0500)
gcc/ada/

* exp_ch7.adb (Build_Finalization_Master, Build_Finalizer,
Build_Object_Declarations, Make_Deep_Array_Body,
Wrap_Transient_Expression): Call Set_Debug_Info_Needed on
temporaries when Debug_Generated_Code is True.

gcc/ada/exp_ch7.adb

index b58a3c1..411df73 100644 (file)
@@ -1273,6 +1273,10 @@ package body Exp_Ch7 is
              Object_Definition   =>
                New_Occurrence_Of (RTE (RE_Finalization_Master), Loc)));
 
+         if Debug_Generated_Code then
+            Set_Debug_Info_Needed (Fin_Mas_Id);
+         end if;
+
          --  Set the associated pool and primitive Finalize_Address of the new
          --  finalization master.
 
@@ -1616,6 +1620,10 @@ package body Exp_Ch7 is
 
             Set_Etype (Counter_Id, Counter_Typ);
 
+            if Debug_Generated_Code then
+               Set_Debug_Info_Needed (Counter_Id);
+            end if;
+
             --  The counter and its type are inserted before the source
             --  declarations of N.
 
@@ -1778,7 +1786,11 @@ package body Exp_Ch7 is
             --  exactly twice (once on the normal path, and once for
             --  exceptions/abort), so this won't bloat the code too much.
 
-            Set_Is_Inlined  (Fin_Id);
+            Set_Is_Inlined (Fin_Id);
+         end if;
+
+         if Debug_Generated_Code then
+            Set_Debug_Info_Needed (Fin_Id);
          end if;
 
          --  Step 2: Creation of the finalizer specification
@@ -1969,6 +1981,10 @@ package body Exp_Ch7 is
 
          Body_Id := Make_Defining_Identifier (Loc, Chars (Fin_Id));
 
+         if Debug_Generated_Code then
+            Set_Debug_Info_Needed (Body_Id);
+         end if;
+
          if For_Package then
             Set_Has_Qualified_Name       (Body_Id);
             Set_Has_Fully_Qualified_Name (Body_Id);
@@ -2648,6 +2664,10 @@ package body Exp_Ch7 is
             Set_Finalization_Master     (Ptr_Typ, Fin_Mas_Id);
             Set_Associated_Storage_Pool (Ptr_Typ, Pool_Id);
 
+            if Debug_Generated_Code then
+               Set_Debug_Info_Needed (Pool_Id);
+            end if;
+
             --  Create an explicit free statement. Note that the free uses the
             --  caller's pool expressed as a renaming.
 
@@ -3741,6 +3761,10 @@ package body Exp_Ch7 is
           Defining_Identifier => Data.Raised_Id,
           Object_Definition   => New_Occurrence_Of (Standard_Boolean, Loc),
           Expression          => New_Occurrence_Of (Standard_False, Loc)));
+
+      if Debug_Generated_Code then
+         Set_Debug_Info_Needed (Data.Raised_Id);
+      end if;
    end Build_Object_Declarations;
 
    ---------------------------
@@ -6906,6 +6930,10 @@ package body Exp_Ch7 is
                  Make_Handled_Sequence_Of_Statements (Loc,
                    Statements => New_List (Init_Loop)));
 
+            if Debug_Generated_Code then
+               Set_Debug_Info_Needed (Counter_Id);
+            end if;
+
          --  Otherwise previous errors or a missing full view may prevent the
          --  proper freezing of the component type. If this is the case, there
          --  is no [Deep_]Initialize primitive to call.
@@ -9681,6 +9709,10 @@ package body Exp_Ch7 is
               Expression => Expr),
           Par    => Parent (N))));
 
+      if Debug_Generated_Code then
+         Set_Debug_Info_Needed (Temp);
+      end if;
+
       Rewrite (N, New_Occurrence_Of (Temp, Loc));
       Analyze_And_Resolve (N, Typ);
    end Wrap_Transient_Expression;