This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] Add support for locally modified environment variables for windows-nat.c
- From: Corinna Vinschen <vinschen at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 20 Apr 2011 14:30:09 +0200
- Subject: Re: [RFC] Add support for locally modified environment variables for windows-nat.c
- References: <000601cbff45$66fa5820$34ef0860$@muller@ics-cnrs.unistra.fr> <20110420115528.GA5842@calimero.vinschen.de> <001501cbff53$465030a0$d2f091e0$@muller@ics-cnrs.unistra.fr>
- Reply-to: gdb-patches at sourceware dot org
[Please do not CC me. I'm subscribed to gdb-patches anyway. Thanks.]
On Apr 20 14:05, Pierre Muller wrote:
> > owner@sourceware.org] De la part de Corinna Vinschen
> > On Apr 20 12:26, Pierre Muller wrote:
> > > Nevertheless, I suspect that his patch would not have worked for Cygwin,
> > > because Cygwin converts several environment variables
> > > from windows style to POSIX style.
> >
> > Do you suspect or did you actually test it? What you're trying to
> > accomplish is actually the task of the
> >
> > cygwin_internal (CW_SYNC_WINENV);
> >
> > call right before calling CreateProcess. This allows to keep the actual
> > underlying details of the environment handling entirely in the hands of
> > Cygwin. Especially copying an internal list of env vars from Cygwin
> > into GDB makes me very uncomfortable since this is bound to break as
> > soon as we decide to handle things a bit different in Cygwin.
>
> The problem is that this does not handle
> (gdb) set environment TEST=My dummy test
> which is supposed to be passed to the inferior.
> after the commands above the in_env char * vector
> will have an additional entry "TEST=My dummy test"
> but the internal environment variables of GDB itself
> are not changed.
> I suspect that cygwin_internal (CW_SYNC_WINENV);
> only acts on the environment variables of GDB itself.
Yes.
> Does that mean that we should instead copy this in_env
> array using cygwin set_env function before calling cygwin_internal?
> If this is true, do we need to restore the environment state of GDB
> after?
A pity that we still don't have the ptrace API in Cygwin. But, anyway,
what about this:
cygwin_internal (CW_SYNC_WINENV);
for (all env vars set in GDB)
SetEnvironmentVariableW (wide char representation of var);
LPWCH out_env = GetEnvironmentStrings ();
CreateProcess (..., CREATE_UNICODE_ENVIRONMENT, ..., out_env, ...);
FreeEnvironmentStringsW ();
IMO the environment variables set by the user should *not* be tweaked
in any way. It's entirely up to the user to set the correct value.
As a Cygwin application GDB doesn't care for its Windows environment
anyway, so there's no reason to revert the changes after the call to
CreateProcess.
> If you think that the proposal above is the right track for
> Cygwin, I will try to implement this.
I guess we should wait for cgf to express his opinion first.
Corinna
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat