This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v5 2/3] Implement "set cwd" command on GDB
- From: Pedro Alves <palves at redhat dot com>
- To: Sergio Durigan Junior <sergiodj at redhat dot com>
- Cc: GDB Patches <gdb-patches at sourceware dot org>, Eli Zaretskii <eliz at gnu dot org>
- Date: Tue, 3 Oct 2017 17:44:10 +0100
- Subject: Re: [PATCH v5 2/3] Implement "set cwd" command on GDB
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx02.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 7632A914F4
- References: <20170912042325.14927-1-sergiodj@redhat.com> <20170929225852.21872-1-sergiodj@redhat.com> <20170929225852.21872-3-sergiodj@redhat.com> <bcd35803-a7c2-8e49-e33c-fd8e807cab95@redhat.com> <874lrg5goz.fsf@redhat.com>
On 10/03/2017 05:39 PM, Sergio Durigan Junior wrote:
>> But what if inferior_cwd _is_ NULL, when ...
>>
>>
>>> memset (&si, 0, sizeof (si));
>>> si.cb = sizeof (si);
>>>
>>> @@ -2514,6 +2527,10 @@ windows_create_inferior (struct target_ops *ops, const char *exec_file,
>>> flags |= DEBUG_PROCESS;
>>> }
>>>
>>> + if (cygwin_conv_path (CCP_POSIX_TO_WIN_W, inferior_cwd,
>>> + infcwd, strlen (inferior_cwd)) < 0)
>>> + error (_("Error converting inferior cwd: %d"), errno);
>>
>> ... we get here? It looks to me like this conversion should
>> skipped here then, and ...
>
> You're right, this should be skipped.
>
>>> +
>>> #ifdef __USEWIDE
>>> args = (cygwin_buf_t *) alloca ((wcslen (toexec) + wcslen (cygallargs) + 2)
>>> * sizeof (wchar_t));
>>> @@ -2574,7 +2591,7 @@ windows_create_inferior (struct target_ops *ops, const char *exec_file,
>>> TRUE, /* inherit handles */
>>> flags, /* start flags */
>>> w32_env, /* environment */
>>> - NULL, /* current directory */
>>> + infcwd, /* current directory */
>>
>> ... here still pass NULL.
>
> Here we pass NULL because that was the old behaviour when we did not
> care about the inferior's cwd. This is the same approach that we use on
> fork_inferior: if the user hasn't provided any paths via "set cwd", then
> we don't do anything.
Exactly, I'm saying that you _should_ pass NULL iff
inferior_cwd is NULL. That's what msdn's documentation of
CreateProcess says you should pass in order to have the
process inherit its parent's cwd.
Thanks,
Pedro Alves