This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
New "set cwd" command
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Pedro Alves <palves at redhat dot com>
- Date: Thu, 21 Sep 2017 18:59:21 -0400
- Subject: New "set cwd" command
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=sergiodj at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 696BEC04B954
- References: <20170912042325.14927-1-sergiodj@redhat.com>
v1: https://sourceware.org/ml/gdb-patches/2017-09/msg00321.html
v2: https://sourceware.org/ml/gdb-patches/2017-09/msg00458.html
Changes from v2:
* Patch #1:
- Mention that "getcwd (NULL, 0)" is a GNU extension on the commit
log.
- Rewrite ChangeLog to explicitly say "New file"/"Regenerate"
instead of "Likewise".
- Do not remove definition of "close" on gdb/ser-tcp.c; instead,
"#undef close" before (re)defining it as "closesocket".
* Patch #2:
- Fix s/target/host/ on commit log.
- Remove call to '.get ()' method on "gdb::unique_xmalloc_ptr<char>"
when checking to see if it was initialized correctly.
* Patch #3:
- This now introduces "gdb_tilde_expand" instead of "gdb_chdir".
- Improve cases when using a "gdb::unique_xmalloc_ptr<char>" would
be better.
- Fix method declaration format inside classes.
* Patch #4:
- Add sentence on "cd" command's help text explaining what the GDB's
cwd affects.
- Improve documentation and explain that cwd changes via "set cwd"
only take effect the next time the inferior is started.
- Remove implementation details that explained how UNIX-like targets
change the inferior's cwd from a few comments.
- Declare "cwd" field from "struct inferior" as
"gdb::unique_xmalloc_ptr<char>".
- Improve message displayed by "show cwd" when the user hasn't set
the cwd.
- Improve way that "fork_inferior" changes the directory before
executing the inferior, obeying the async-signal-safe restriction
of the function.
- Update Windows code to deal with wide strings.
- Remove BUFSIZ from the testcase C file.
- Fix/improve the way we detect if the testcase is running on a
remote debugging scenario.
- Based on a private conversation I had with Pedro, the
"test_tilde_expansion" method has also been rewritten to avoid
problems when we're dealing with a remote host.
- Implement failure detection when gathering information about the
cwd before/after running the inferior.
- Use gdb_assert.
* Patch #5:
- Update text on gdb/NEWS.
- Remove target-specific implementation detail from
"set_inferior_cwd"'s comment.
- Remove sentence explicitly saying that "set cwd" works for both
native and remote debugging.
- Update text of "QSetWorkingDir" packet description and make it
target-independent, as well as update a few references.
- Update Windows code to deal with wide strings.
- s/extended_remote_handle_inferior_cwd/extended_remote_set_inferior_cwd/
- Use packet_ok.
- Again, update the testcase in order to better detect when we're
dealing with gdbserver test.
This patch series is a followup of the discussion that happened at:
https://sourceware.org/ml/gdb-patches/2017-09/msg00160.html
It implements a new GDB command, "set cwd", which is used to set the
current working directory of the inferior that will be started. This
command works for both native and remote debugging scenarios.
The idea here is that "set cwd" will become the de facto way of
setting the inferior's cwd. Currently, the user can use "cd" for
that, but there are side effects: with "cd", GDB also switches to
another directory, and that can impact the loading of scripts and
other files. With "set cwd", we separate the logic into a new
command.
To maintain backward compatibility, if the user issues a "cd" command
but doesn't use "set cwd", then the inferior's cwd will still be
changed according to what the user specified. However, "set cwd" has
precedence over "cd", so it can always be used to override it.