diff mbox

[Ada] Fix back-and-forth issue in debugger

Message ID 2100700.HsR2anTZri@polaris
State New
Headers show

Commit Message

Eric Botcazou Feb. 24, 2017, 10:07 a.m. UTC
This is a small regression present on the mainline: under some circumstances, 
the debugger may go back and forth when stepping over a call, if the arguments 
contain string concatenations.

Tested on x86_64-suse-linux, applied on the mainline.


2017-02-24  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (Handled_Sequence_Of_Statements_to_gnu): If
	there is no end label, put the location of the At_End procedure on
	the call to the procedure.
diff mbox

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 245625)
+++ gcc-interface/trans.c	(working copy)
@@ -6,7 +6,7 @@ 
  *                                                                          *
  *                          C Implementation File                           *
  *                                                                          *
- *          Copyright (C) 1992-2016, Free Software Foundation, Inc.         *
+ *          Copyright (C) 1992-2017, 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- *
@@ -4965,10 +4965,6 @@  Handled_Sequence_Of_Statements_to_gnu (N
   tree gnu_result;
   tree gnu_expr;
   Node_Id gnat_temp;
-  /* Node providing the sloc for the cleanup actions.  */
-  Node_Id gnat_cleanup_loc_node = (Present (End_Label (gnat_node)) ?
-                                   End_Label (gnat_node) :
-                                   gnat_node);
 
   /* The GCC exception handling mechanism can handle both ZCX and SJLJ schemes
      and we have our own SJLJ mechanism.  To call the GCC mechanism, we call
@@ -5018,7 +5014,8 @@  Handled_Sequence_Of_Statements_to_gnu (N
 
       /* When we exit this block, restore the saved value.  */
       add_cleanup (build_call_n_expr (set_jmpbuf_decl, 1, gnu_jmpsave_decl),
-		   gnat_cleanup_loc_node);
+		   Present (End_Label (gnat_node))
+		   ? End_Label (gnat_node) : gnat_node);
     }
 
   /* If we are to call a function when exiting this block, add a cleanup
@@ -5027,11 +5024,18 @@  Handled_Sequence_Of_Statements_to_gnu (N
   if (at_end)
     {
       tree proc_decl = gnat_to_gnu (At_End_Proc (gnat_node));
+
       /* When not optimizing, disable inlining of finalizers as this can
 	 create a more complex CFG in the parent function.  */
       if (!optimize)
 	DECL_DECLARED_INLINE_P (proc_decl) = 0;
-      add_cleanup (build_call_n_expr (proc_decl, 0), gnat_cleanup_loc_node);
+
+      /* If there is no end label attached, we use the location of the At_End
+	 procedure because Expand_Cleanup_Actions might reset the location of
+	 the enclosing construct to that of an inner statement.  */
+      add_cleanup (build_call_n_expr (proc_decl, 0),
+		   Present (End_Label (gnat_node))
+		   ? End_Label (gnat_node) : At_End_Proc (gnat_node));
     }
 
   /* Now build the tree for the declarations and statements inside this block.