From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18567 invoked by alias); 6 Oct 2011 14:51:28 -0000 Received: (qmail 18530 invoked by uid 22791); 6 Oct 2011 14:51:24 -0000 X-SWARE-Spam-Status: No, hits=1.1 required=5.0 tests=AWL,BAYES_50,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from nm17.access.bullet.mail.mud.yahoo.com (HELO nm17.access.bullet.mail.mud.yahoo.com) (66.94.237.218) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Thu, 06 Oct 2011 14:51:08 +0000 Received: from [66.94.237.127] by nm17.access.bullet.mail.mud.yahoo.com with NNFMP; 06 Oct 2011 14:51:07 -0000 Received: from [66.94.237.101] by tm2.access.bullet.mail.mud.yahoo.com with NNFMP; 06 Oct 2011 14:51:07 -0000 Received: from [127.0.0.1] by omp1006.access.mail.mud.yahoo.com with NNFMP; 06 Oct 2011 14:51:07 -0000 Received: (qmail 96423 invoked from network); 6 Oct 2011 14:51:07 -0000 X-Yahoo-SMTP: jenXL62swBAWhMTL3wnej93oaS0ClBQOAKs8jbEbx_o- Received: from cgf.cx (cgf@173.76.45.30 with login) by smtp101.vzn.mail.bf1.yahoo.com with SMTP; 06 Oct 2011 07:51:06 -0700 PDT Received: from localhost (ednor.casa.cgf.cx [192.168.187.5]) by cgf.cx (Postfix) with ESMTP id 3AB4713C0D4 for ; Thu, 6 Oct 2011 10:51:06 -0400 (EDT) Date: Thu, 06 Oct 2011 14:51:00 -0000 From: Christopher Faylor To: gdb-patches@sourceware.org Subject: Re: [RFA] testsuite: Add a test for passing of environment variables to inferior Message-ID: <20111006145106.GA21790@ednor.casa.cgf.cx> Mail-Followup-To: gdb-patches@sourceware.org References: <006301cc8292$367539b0$a35fad10$@muller@ics-cnrs.unistra.fr> <20111004134506.GB24369@calimero.vinschen.de> <000901cc82a4$dfba7cd0$9f2f7670$@muller@ics-cnrs.unistra.fr> <20111004151236.GC15757@calimero.vinschen.de> <003901cc82b0$471e3a00$d55aae00$@muller@ics-cnrs.unistra.fr> <20111005113941.GA13366@calimero.vinschen.de> <004401cc8357$74fd1c00$5ef75400$@muller@ics-cnrs.unistra.fr> <20111005125157.GA24105@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111005125157.GA24105@calimero.vinschen.de> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-10/txt/msg00161.txt.bz2 On Wed, Oct 05, 2011 at 02:51:57PM +0200, Corinna Vinschen wrote: >On Oct 5 14:08, Pierre Muller wrote: >> Hi Corinna, >> I didn't know about the charset problem... >> >> > Here's my proposal, based on your patch. I'll work on using the >> > yet-to-be-created new cygwin_internal call after I implemented it in >> > Cygwin. >> >> I think that your approach is OK, >> I checked that it does also pass all >> the tests in my gdb.base/testenv.exp >> (11 passes instead of 7 passes/4 failures for current Cygwin GDB 7.3.50 20110821cvs). >> >> Your patch proposal thus supersedes mine. >> >> We just need an approval from Christopher Faylor... > >Right. Here's a new version of the patch which uses the new >cygwin_internal(CW_CVT_ENV_TO_WINENV) which will be available starting >with the next Cygwin 1.7.10. The patch allows to build GDB under older >versions of Cygwin and it will fallback to the CW_SYNC_WINENV method if >the cygwin_internal (CW_CVT_ENV_TO_WINENV) call returns with an error. >That allows to run a GDB built under 1.7.10 to run under older Cygwin >versions (provided all other DLL dependencies still work). Tested under >Cygwin 1.7.9 and current CVS. > > >Corinna > > > * windows-nat.c: Include wchar.h to avoid compiler warnings. > Include cygwin/version.h to get version information. > (clear_win32_environment): New function for Cygwin to clear out > Win32 environment. > (windows_create_inferior): Prepare new environment from in_env > for Cygwin, too. Use cygwin_internal (CW_CVT_ENV_TO_WINENV) call > to get a Win32 copy of the desired POSIX environment if available, > fall back to changing the GDB environment otherwise. > >Index: windows-nat.c >=================================================================== >RCS file: /cvs/src/src/gdb/windows-nat.c,v >retrieving revision 1.219 >diff -u -p -r1.219 windows-nat.c >--- windows-nat.c 28 Sep 2011 09:07:54 -0000 1.219 >+++ windows-nat.c 5 Oct 2011 12:47:40 -0000 >@@ -40,7 +40,9 @@ > #include > #include > #ifdef __CYGWIN__ >+#include > #include >+#include > #endif > #include > >@@ -1963,6 +1965,28 @@ envvar_cmp (const void *a, const void *b > } > #endif > >+#ifdef __CYGWIN__ >+static void >+clear_win32_environment (char **env) >+{ >+ int i; >+ size_t len; >+ wchar_t *copy = NULL, *equalpos; >+ >+ for (i = 0; env[i] && *env[i]; i++) >+ { >+ len = mbstowcs (NULL, env[i], 0) + 1; >+ copy = (wchar_t *) xrealloc (copy, len * sizeof (wchar_t)); >+ mbstowcs (copy, env[i], len); >+ equalpos = wcschr (copy, L'='); >+ if (equalpos) >+ *equalpos = L'\0'; >+ SetEnvironmentVariableW (copy, NULL); >+ } >+ xfree (copy); >+} >+#endif >+ > /* Start an inferior windows child process and sets inferior_ptid to its pid. > EXEC_FILE is the file to run. > ALLARGS is a string containing the arguments to the program. >@@ -1980,6 +2004,8 @@ windows_create_inferior (struct target_o > cygwin_buf_t *toexec; > cygwin_buf_t *cygallargs; > cygwin_buf_t *args; >+ char **old_env; >+ PWCHAR w32_env; > size_t len; > int tty; > int ostdin, ostdout, ostderr; >@@ -2066,8 +2092,23 @@ windows_create_inferior (struct target_o > strcat (args, cygallargs); > #endif > >- /* Prepare the environment vars for CreateProcess. */ >- cygwin_internal (CW_SYNC_WINENV); >+#if CYGWIN_VERSION_API_MAJOR > 0 || CYGWIN_VERSION_API_MINOR >= 252 Why not just check if CW_CVT_ENV_TO_WINENV is defined rather than checking specifically for a version number? Checking arbitrary versions like this should be a last resort. Otherwise, the patch is fine. cgf