This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 0/4] New "set cwd" command
- From: Pedro Alves <palves at redhat dot com>
- To: Sergio Durigan Junior <sergiodj at redhat dot com>, Eli Zaretskii <eliz at gnu dot org>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 13 Sep 2017 15:59:52 +0100
- Subject: Re: [PATCH 0/4] New "set cwd" command
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0ACD4356CC
- References: <20170912042325.14927-1-sergiodj@redhat.com> <83fubsq84f.fsf@gnu.org> <87zi9zeud6.fsf@redhat.com> <83o9qfq2i1.fsf@gnu.org> <87poaverfb.fsf@redhat.com>
On 09/12/2017 06:51 PM, Sergio Durigan Junior wrote:
> On Tuesday, September 12 2017, Eli Zaretskii wrote:
>
>>> From: Sergio Durigan Junior <sergiodj@redhat.com>
>>> Cc: gdb-patches@sourceware.org, palves@redhat.com
>>> Date: Tue, 12 Sep 2017 12:48:05 -0400
>>>
>>> The new "set cwd" command also uses chdir (i.e., no shell involved), but
>>> because it is shared code between GDB and gdbserver, and because
>>> gdbserver doesn't link against readline, it cannot use tilde_expand.
>>> Therefore I had to import the "glob" module from gnulib. And also, this
>>> specific chdir is only invoked after the call to fork/vfork on
>>> fork_inferior, but before we actually execute the binary.
>>
>> Thanks.
>>
>> The last bit means that this will only work for targets that use
>> fork/vfork, i.e. only for Posix targets. Right?
>
> Well, the way it's implemented, yes. AFAIK there's nothing preventing
> this feature to be implemented in non-vfork targets like Windows, except
> the fact that I don't have access to those targets to test.
I think that to make "set cwd" work on Windows, gdb would be adjusted to
pass the desired current directory as argument to CreateProcess, here:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/windows-nat.c;h=ab5582d46cf3a0873ab32d9c955e95ee75371d4e;hb=HEAD#l2570
(and the equivalent in gdbserver).
>From <https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx>:
~~~
lpCurrentDirectory [in, optional]
The full path to the current directory for the process. The string can also specify a UNC path.
If this parameter is NULL, the new process will have the same current drive and directory as the calling process. (This feature is provided primarily for shells that need to start an application and specify its initial drive and working directory.)
~~~
Thanks,
Pedro Alves