This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 0/4] New "set cwd" command


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]