Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Sergio Durigan Junior <sergiodj@redhat.com>
Cc: GDB Patches <gdb-patches@sourceware.org>,
	Simon Marchi <simon.marchi@ericsson.com>
Subject: Re: [PATCH 1/2] Create new common/pathstuff.[ch]
Date: Wed, 21 Feb 2018 07:56:00 -0000	[thread overview]
Message-ID: <20180221075605.dujv7xwx45soccnc@adacore.com> (raw)
In-Reply-To: <20180210014241.19278-2-sergiodj@redhat.com>

Hi Sergio,


On Fri, Feb 09, 2018 at 08:42:40PM -0500, Sergio Durigan Junior wrote:
> This commit moves the path manipulation routines found on utils.c to a
> new common/pathstuff.c, and updates the Makefile.in's accordingly.
> The routines moved are "gdb_realpath", "gdb_realpath_keepfile" and
> "gdb_abspath".
> 
> This will be needed because gdbserver will have to call "gdb_abspath"
> on my next patch, which implements a way to expand the path of the
> inferior provided by the user in order to allow specifying just the
> binary name when starting gdbserver, like:
> 
>   $ gdbserver :1234 a.out
> 
> With the recent addition of the startup-with-shell feature on
> gdbserver, this scenario doesn't work anymore if the user doesn't have
> the current directory listed in the PATH variable.
> 
> I had to do a minor adjustment on "gdb_abspath" because we don't have
> access to "tilde_expand" on gdbserver, so now the function is using
> "gdb_tilde_expand" instead.  Otherwise, the code is the same.
> 
> Regression tested on the BuildBot, without regressions.
> 
> gdb/ChangeLog:
> 2018-02-09  Sergio Durigan Junior  <sergiodj@redhat.com>
> 
> 	* Makefile.in (SFILES): Add "common/pathstuff.c".
> 	(HFILES_NO_SRCDIR): Add "common/pathstuff.h".
> 	(COMMON_OBS): Add "pathstuff.o".
> 	* common/pathstuff.c: New file.
> 	* common/pathstuff.h: New file.
> 	* utils.c (gdb_realpath): Move to "common/pathstuff.c".
> 	(gdb_realpath_keepfile): Likewise.
> 	(gdb_abspath): Likewise.
> 	* utils.h: Include "common/pathstuff.h".
> 	(gdb_realpath): Move to "common/pathstuff.h".
> 	(gdb_realpath_keepfile): Likewise.
> 	(gdb_abspath): Likewise.
> 
> gdb/gdbserver/ChangeLog:
> 2018-02-09  Sergio Durigan Junior  <sergiodj@redhat.com>

Thanks for doing this work!

> 	* Makefile.in (SFILES): Add "$(srcdir)/common/pathstuff.c".
> 	(OBJS): Add "pathstuff.o".
> +++ b/gdb/common/pathstuff.c
> @@ -0,0 +1,144 @@
[...]
> +gdb::unique_xmalloc_ptr<char>
> +gdb_realpath (const char *filename)

I realize you are just moving the function, but the function's missing
some documentation. I think it would be useful to add.

What lead me to this is the fact that there is one particularly
important element, is that this function used the current working
directory to expand relative paths. In the case of GDB, I verified
that when the user does a "cd DIR", GDB updates both current_directory
and its actual current working directory (in other words, we always
maintain the property current_directory == getcwd ().

In GDBserver, however, it doesn't seem to be the case. So I think
we need to be explicit about that, because calls to gdb_realpath
and gdb_abspath with the same filename  might actually return
the path to two different files if the conditions are right!

Ideally, I think we would want gdb_realpath and gdb_abspath to
return the same value. But, if we are interested, I suggest we
discuss that separately from this thread. This is potentially
disruptive (and potentially in a good way ;-)).

> +/* Return PATH in absolute form, performing tilde-expansion if necessary.
> +   PATH cannot be NULL or the empty string.
> +   This does not resolve symlinks however, use gdb_realpath for that.  */
> +
> +extern gdb::unique_xmalloc_ptr<char> gdb_abspath (const char *path);

Similar to the above, I think we should be clear that the expansion
of relative path is done relative to the current_directory (or
the current working directory if NULL). Something like that.


-- 
Joel


  parent reply	other threads:[~2018-02-21  7:56 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-10  1:42 [PATCH 0/2] Make gdbserver work with filename-only binaries Sergio Durigan Junior
2018-02-10  1:42 ` [PATCH 1/2] Create new common/pathstuff.[ch] Sergio Durigan Junior
2018-02-11 22:14   ` Simon Marchi
2018-02-12 19:01     ` Sergio Durigan Junior
2018-02-21  7:56   ` Joel Brobecker [this message]
2018-02-22 18:43     ` Sergio Durigan Junior
2018-02-10  1:42 ` [PATCH 2/2] Make gdbserver work with filename-only binaries Sergio Durigan Junior
2018-02-12  4:18   ` Simon Marchi
2018-02-12 19:16     ` Sergio Durigan Junior
2018-02-21  8:05       ` Joel Brobecker
2018-02-12 19:57   ` [PATCH 0/2] " Sergio Durigan Junior
2018-02-12 19:57     ` [PATCH v2 2/2] " Sergio Durigan Junior
2018-02-13  4:35       ` Simon Marchi
2018-02-22 18:37         ` Sergio Durigan Junior
2018-02-21 12:29       ` Pedro Alves
2018-02-27  0:20         ` Sergio Durigan Junior
2018-02-28  3:32           ` Sergio Durigan Junior
2018-02-12 19:57     ` [PATCH v2 1/2] Create new common/pathstuff.[ch] Sergio Durigan Junior
2018-02-28  3:27   ` [PATCH v3 0/2] Make gdbserver work with filename-only binaries Sergio Durigan Junior
2018-02-28  3:27     ` [PATCH v3 2/2] " Sergio Durigan Junior
2018-02-28  3:58       ` Sergio Durigan Junior
2018-02-28  5:33         ` Simon Marchi
2018-02-28  7:09           ` Metzger, Markus T
2018-02-28 16:30             ` Sergio Durigan Junior
2018-02-28  5:46       ` Simon Marchi
2018-02-28 16:29         ` Sergio Durigan Junior
2018-02-28 16:40           ` Sergio Durigan Junior
2018-02-28  3:27     ` [PATCH v3 1/2] Create new common/pathstuff.[ch] Sergio Durigan Junior
2018-02-28  5:02       ` Simon Marchi
2018-02-28 16:46         ` Sergio Durigan Junior
2018-02-28 16:39       ` Sergio Durigan Junior
2018-03-01  2:23     ` [PATCH v3 0/2] Make gdbserver work with filename-only binaries Sergio Durigan Junior
2018-03-01  2:55       ` Joel Brobecker
2018-03-01 13:08         ` Christophe Lyon
2018-03-01 13:18           ` Simon Marchi
2018-03-01 19:50           ` Sergio Durigan Junior
2018-03-01 20:20           ` [PATCH] Conditionally include "<windows.h>" on common/pathstuff.c (and unbreak build on mingw*) Sergio Durigan Junior
2018-03-01 20:47             ` Simon Marchi
2018-03-02 11:46               ` Christophe Lyon
2018-03-02 12:35                 ` Sergio Durigan Junior
2018-03-02 11:11             ` Yao Qi
2018-03-02 12:29               ` Sergio Durigan Junior
2018-03-02 12:37                 ` Sergio Durigan Junior
2018-03-05 12:07                   ` Yao Qi
2018-03-02 13:32             ` Eli Zaretskii
2018-03-02 15:15               ` Simon Marchi
2018-03-02 18:20                 ` Sergio Durigan Junior
2018-03-03  7:36                   ` Eli Zaretskii
2018-03-01 17:37         ` [PATCH v3 0/2] Make gdbserver work with filename-only binaries Sergio Durigan Junior
2018-03-02  3:20           ` Joel Brobecker
2018-02-28 16:47   ` [obvious/pushed] Change order of error message printed when gdbserver can't find CWD Sergio Durigan Junior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180221075605.dujv7xwx45soccnc@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sergiodj@redhat.com \
    --cc=simon.marchi@ericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox