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

login
register
mail settings
Submitter Dodji Seketeli
Date Dec. 19, 2011, 10:54 p.m.
Message ID <m339cgp3yr.fsf@redhat.com>
Download mbox | patch
Permalink /patch/132332/
State New
Headers show

Comments

Dodji Seketeli - Dec. 19, 2011, 10:54 p.m.
Jason Merrill <jason@redhat.com> writes:

> I think it might be simpler to have cxx_maybe_build_cleanup avoid
> setting EXPR_LOCATION on the call in the first place.

I have bootstrapped and tested the below on x86_64-unknown-linux-gnu
against trunk.

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: New test.
---
 gcc/cp/decl.c                      |    9 +++++++++
 gcc/testsuite/g++.dg/gcov/gcov-2.C |    2 +-
 2 files changed, 10 insertions(+), 1 deletions(-)
Jakub Jelinek - Dec. 19, 2011, 10:58 p.m.
On Mon, Dec 19, 2011 at 11:54:36PM +0100, Dodji Seketeli wrote:
> 	PR debug/49951
> 	* g++.dg/gcov/gcov-2.C: New test.

This change doesn't look like New test, just an adjustment to it...

> 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) */
>  }
>  

	Jakub

Patch

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 0a43fb8..2fc794b 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13805,8 +13805,17 @@  cxx_maybe_build_cleanup (tree decl, tsubst_flags_t complain)
 	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) */
 }