diff mbox

[RFC] PR debug/49951 - jumpy stepping at end of scope in C++

Message ID m3zke6dpl3.fsf@redhat.com
State New
Headers show

Commit Message

Dodji Seketeli Jan. 2, 2012, 4:41 p.m. UTC
Jason Merrill <jason@redhat.com> writes:

> OK.

I'd like to apply this patch to 4.5 and 4.6 as I find the jumpy stepping
behaviour very annoying while using 4.6 myself.

I have bootstrapped and tested the patch on these branches
for x86_64-unknown-linux-gnu successfully.

Would this be OK?

For the record, here is the commit I have tested on these branches.

commit 399ff82d2ff78acb066b91e5940e815fcdc82ed7
Author: dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Dec 20 13:36:04 2011 +0000

    PR debug/49951 - jumpy stepping at end of scope in C++
    
    gcc/cp/
    
    	PR debug/49951
    	* decl.c (cxx_maybe_build_cleanup): Don't set location of the call
    	to the destructor.
    
    gcc/testsuite/
    
    	PR debug/49951
    	* g++.dg/gcov/gcov-2.C: Adjust.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@182532 138bc75d-0d04-0410-961f-82ee72b054a4

Comments

Jakub Jelinek Jan. 2, 2012, 4:43 p.m. UTC | #1
On Mon, Jan 02, 2012 at 05:41:28PM +0100, Dodji Seketeli wrote:
> I'd like to apply this patch to 4.5 and 4.6 as I find the jumpy stepping
> behaviour very annoying while using 4.6 myself.
> 
> I have bootstrapped and tested the patch on these branches
> for x86_64-unknown-linux-gnu successfully.
> 
> Would this be OK?

Yes.

	Jakub
diff mbox

Patch

--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13363,8 +13363,17 @@  cxx_maybe_build_cleanup (tree decl)
 	cleanup = call;
     }
 
+  /* build_delete sets the location of the destructor call to the
+     current location, even though the destructor is going to be
+     called later, at the end of the current scope.  This can lead to
+     a "jumpy" behaviour for users of debuggers when they step around
+     the end of the block.  So let's unset the location of the
+     destructor call instead.  */
+  if (cleanup != NULL && EXPR_P (cleanup))
+    SET_EXPR_LOCATION (cleanup, UNKNOWN_LOCATION);
   return cleanup;
 }
 
 /* When a stmt has been parsed, this function is called.  */
 
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-2.C b/gcc/testsuite/g++.dg/gcov/gcov-2.C
index 6d002f5..66d8af3 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov-2.C
+++ b/gcc/testsuite/g++.dg/gcov/gcov-2.C
@@ -20,7 +20,7 @@  private:
 
 void foo()
 {
-  C c;					/* count(2) */
+  C c;					/* count(1) */
   c.seti (1);				/* count(1) */
 }