[RFC,9] Revert basenames_may_differ patch

Message ID 20200205095515.335-1-tromey@adacore.com
State New
Headers show
Series
  • [RFC,9] Revert basenames_may_differ patch
Related show

Commit Message

Tom Tromey Feb. 5, 2020, 9:55 a.m.
Commit a0c1ffedc regressed certain cases coming from Eclipse.
See PR breakpoints/24915.

This patch reverts the commit for the gdb 9 release.

gdb/ChangeLog
2020-02-05  Tom Tromey  <tromey@adacore.com>

	PR breakpoints/24915:
	* source.c (find_and_open_source): Do not check basenames_may_differ.

gdb/testsuite/ChangeLog
2020-02-05  Tom Tromey  <tromey@adacore.com>

	PR breakpoints/24915:
	* gdb.base/annotate-symlink.exp: Use setup_xfail.

Change-Id: Iadbf42f35eb40c95ad32b2108ae25d8f199998bd
---
 gdb/ChangeLog                               |  5 +++++
 gdb/source.c                                | 19 +++++++------------
 gdb/testsuite/ChangeLog                     |  5 +++++
 gdb/testsuite/gdb.base/annotate-symlink.exp |  3 +++
 4 files changed, 20 insertions(+), 12 deletions(-)

-- 
2.21.1

Comments

Joel Brobecker Feb. 7, 2020, 3:44 a.m. | #1
Hi Tom,

On Wed, Feb 05, 2020 at 10:55:15AM +0100, Tom Tromey wrote:
> Commit a0c1ffedc regressed certain cases coming from Eclipse.

> See PR breakpoints/24915.

> 

> This patch reverts the commit for the gdb 9 release.

> 

> gdb/ChangeLog

> 2020-02-05  Tom Tromey  <tromey@adacore.com>

> 

> 	PR breakpoints/24915:

> 	* source.c (find_and_open_source): Do not check basenames_may_differ.

> 

> gdb/testsuite/ChangeLog

> 2020-02-05  Tom Tromey  <tromey@adacore.com>

> 

> 	PR breakpoints/24915:

> 	* gdb.base/annotate-symlink.exp: Use setup_xfail.


Thanks for the patch. I think this is the most reasonable thing
to do. Can you apply it?

> 

> Change-Id: Iadbf42f35eb40c95ad32b2108ae25d8f199998bd

> ---

>  gdb/ChangeLog                               |  5 +++++

>  gdb/source.c                                | 19 +++++++------------

>  gdb/testsuite/ChangeLog                     |  5 +++++

>  gdb/testsuite/gdb.base/annotate-symlink.exp |  3 +++

>  4 files changed, 20 insertions(+), 12 deletions(-)

> 

> diff --git a/gdb/source.c b/gdb/source.c

> index 2497e7f750e..a737c95e7a4 100644

> --- a/gdb/source.c

> +++ b/gdb/source.c

> @@ -1025,10 +1025,7 @@ find_and_open_source (const char *filename,

>        result = gdb_open_cloexec (fullname->get (), OPEN_MODE, 0);

>        if (result >= 0)

>  	{

> -	  if (basenames_may_differ)

> -	    *fullname = gdb_realpath (fullname->get ());

> -	  else

> -	    *fullname = gdb_abspath (fullname->get ());

> +	  *fullname = gdb_realpath (fullname->get ());

>  	  return scoped_fd (result);

>  	}

>  

> @@ -1072,12 +1069,9 @@ find_and_open_source (const char *filename,

>    if (rewritten_filename != NULL)

>      filename = rewritten_filename.get ();

>  

> -  openp_flags flags = OPF_SEARCH_IN_PATH;

> -  if (basenames_may_differ)

> -    flags |= OPF_RETURN_REALPATH;

> -

>    /* Try to locate file using filename.  */

> -  result = openp (path, flags, filename, OPEN_MODE, fullname);

> +  result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, filename,

> +		  OPEN_MODE, fullname);

>    if (result < 0 && dirname != NULL)

>      {

>        /* Remove characters from the start of PATH that we don't need when

> @@ -1098,15 +1092,16 @@ find_and_open_source (const char *filename,

>        cdir_filename.append (SLASH_STRING);

>        cdir_filename.append (filename_start);

>  

> -      result = openp (path, flags, cdir_filename.c_str (), OPEN_MODE,

> -		      fullname);

> +      result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH,

> +		      cdir_filename.c_str (), OPEN_MODE, fullname);

>      }

>    if (result < 0)

>      {

>        /* Didn't work.  Try using just the basename.  */

>        p = lbasename (filename);

>        if (p != filename)

> -	result = openp (path, flags, p, OPEN_MODE, fullname);

> +	result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, p,

> +			OPEN_MODE, fullname);

>      }

>  

>    return scoped_fd (result);

> diff --git a/gdb/testsuite/gdb.base/annotate-symlink.exp b/gdb/testsuite/gdb.base/annotate-symlink.exp

> index d22593ca364..830949daa42 100644

> --- a/gdb/testsuite/gdb.base/annotate-symlink.exp

> +++ b/gdb/testsuite/gdb.base/annotate-symlink.exp

> @@ -47,5 +47,8 @@ gdb_breakpoint func message

>  

>  gdb_test_no_output "set annotate 1"

>  

> +# The patch to cause this output was reverted.

> +# See PR breakpoints/24915.

> +setup_xfail *-*-* 24915

>  gdb_test "continue" \

>      "Breakpoint .* func .*realname-expand-link.c:$decimal\r\n\032\032.*realname-expand-link.c:.*"

> -- 

> 2.21.1


-- 
Joel
Tom Tromey Feb. 7, 2020, 7:38 p.m. | #2
>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:


Joel> Thanks for the patch. I think this is the most reasonable thing
Joel> to do. Can you apply it?

I'm going to apply it to the gdb 9 branch shortly.  I suppose I will
apply to master as well and then open a bug about the problem.

Tom
Simon Marchi Feb. 7, 2020, 8:53 p.m. | #3
On 2020-02-07 2:38 p.m., Tom Tromey wrote:
>>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

> 

> Joel> Thanks for the patch. I think this is the most reasonable thing

> Joel> to do. Can you apply it?

> 

> I'm going to apply it to the gdb 9 branch shortly.  I suppose I will

> apply to master as well and then open a bug about the problem.

> 

> Tom


I had a prototype of a fix here:

  https://github.com/simark/binutils-gdb/commits/symtab-realpath

My idea is simply that we should keep both versions of the symtab path:

- an absolute path where we have not resovled the symlinks and all (i.e. a
  non-canonical version)
- a path passed through realpath, so where the symlinks and ".." have been resolved
  (i.e a canonical version)

Different parts of GDB would use the one they prefer.  It is described in more
details here:

https://sourceware.org/ml/gdb-patches/2020-02/msg00008.html

If you think this is a good direction, I could clean up the patch and submit
it for real (after some more testing to make sure it actually does what we
want).

I don't remember exactly, but I think that my patch ends up removing your
change anyway, because it goes back to always computing the realpath, regardless
of basenames_may_differ (on top of also keeping the non-real absolute path around).

Simon

Patch

diff --git a/gdb/source.c b/gdb/source.c
index 2497e7f750e..a737c95e7a4 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -1025,10 +1025,7 @@  find_and_open_source (const char *filename,
       result = gdb_open_cloexec (fullname->get (), OPEN_MODE, 0);
       if (result >= 0)
 	{
-	  if (basenames_may_differ)
-	    *fullname = gdb_realpath (fullname->get ());
-	  else
-	    *fullname = gdb_abspath (fullname->get ());
+	  *fullname = gdb_realpath (fullname->get ());
 	  return scoped_fd (result);
 	}
 
@@ -1072,12 +1069,9 @@  find_and_open_source (const char *filename,
   if (rewritten_filename != NULL)
     filename = rewritten_filename.get ();
 
-  openp_flags flags = OPF_SEARCH_IN_PATH;
-  if (basenames_may_differ)
-    flags |= OPF_RETURN_REALPATH;
-
   /* Try to locate file using filename.  */
-  result = openp (path, flags, filename, OPEN_MODE, fullname);
+  result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, filename,
+		  OPEN_MODE, fullname);
   if (result < 0 && dirname != NULL)
     {
       /* Remove characters from the start of PATH that we don't need when
@@ -1098,15 +1092,16 @@  find_and_open_source (const char *filename,
       cdir_filename.append (SLASH_STRING);
       cdir_filename.append (filename_start);
 
-      result = openp (path, flags, cdir_filename.c_str (), OPEN_MODE,
-		      fullname);
+      result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH,
+		      cdir_filename.c_str (), OPEN_MODE, fullname);
     }
   if (result < 0)
     {
       /* Didn't work.  Try using just the basename.  */
       p = lbasename (filename);
       if (p != filename)
-	result = openp (path, flags, p, OPEN_MODE, fullname);
+	result = openp (path, OPF_SEARCH_IN_PATH | OPF_RETURN_REALPATH, p,
+			OPEN_MODE, fullname);
     }
 
   return scoped_fd (result);
diff --git a/gdb/testsuite/gdb.base/annotate-symlink.exp b/gdb/testsuite/gdb.base/annotate-symlink.exp
index d22593ca364..830949daa42 100644
--- a/gdb/testsuite/gdb.base/annotate-symlink.exp
+++ b/gdb/testsuite/gdb.base/annotate-symlink.exp
@@ -47,5 +47,8 @@  gdb_breakpoint func message
 
 gdb_test_no_output "set annotate 1"
 
+# The patch to cause this output was reverted.
+# See PR breakpoints/24915.
+setup_xfail *-*-* 24915
 gdb_test "continue" \
     "Breakpoint .* func .*realname-expand-link.c:$decimal\r\n\032\032.*realname-expand-link.c:.*"