From: Eli Zaretskii <eliz@gnu.org>
To: brobecker@adacore.com, gdb-patches@sourceware.org
Subject: Re: [RFA] Environment variables passed to inferior by MinGW build (PR 10989)
Date: Wed, 28 Sep 2011 09:39:00 -0000 [thread overview]
Message-ID: <83d3elf2oh.fsf@gnu.org> (raw)
In-Reply-To: <8339fjgqy3.fsf@gnu.org>
> Date: Mon, 26 Sep 2011 20:21:24 +0300
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: gdb-patches@sourceware.org
>
> > Date: Mon, 26 Sep 2011 10:15:11 -0700
> > From: Joel Brobecker <brobecker@adacore.com>
> > Cc: gdb-patches@sourceware.org
> >
> > Just a few comments:
>
> Thanks, I will fix all of these. (They came from the original code.)
Done. The actual patch I committed is below.
I replaced env_sort with envvar_cmp.
The last comment, viz.:
> > >>>+ for (envlen = 0, i = 0; in_env[i]&& *in_env[i]; i++)
> ^^^ formatting of the `&&' ?
>
didn't need any change, because there's no such problem in the patch I
sent. Joel, you were replying to Stan's mail, so I'm guessing that
Stan's mail software tried to be overly smart about the formatting of
the patch.
Thanks for the review and the approval.
Could someone with the appropriate authority please close bug #10989,
or instruct me how to do that?
Index: gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.13362
retrieving revision 1.13363
diff -u -r1.13362 -r1.13363
--- gdb/ChangeLog 27 Sep 2011 15:30:12 -0000 1.13362
+++ gdb/ChangeLog 28 Sep 2011 09:07:54 -0000 1.13363
@@ -1,3 +1,11 @@
+2011-09-28 Eli Zaretskii <eliz@gnu.org>
+
+ * windows-nat.c (env_sort) [!__CYGWIN__]: Function restored from
+ before the change on 2006-12-09.
+ (windows_create_inferior) [!__CYGWIN__]: Restore code that
+ generates the environment block for CreateProcessA, modulo the
+ Cygwin-specific parts that are not needed here.
+
2011-09-27 Tristan Gingold <gingold@adacore.com>
* target.h (enum target_object): Add TARGET_OBJECT_DARWIN_DYLD_INFO.
Index: gdb/windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -p -r1.218 -r1.219
--- gdb/windows-nat.c 9 May 2011 14:25:37 -0000 1.218
+++ gdb/windows-nat.c 28 Sep 2011 09:07:54 -0000 1.219
@@ -1951,6 +1951,18 @@ windows_set_console_info (STARTUPINFO *s
*flags |= CREATE_NEW_CONSOLE;
}
+#ifndef __CYGWIN__
+/* Function called by qsort to sort environment strings. */
+
+static int
+envvar_cmp (const void *a, const void *b)
+{
+ const char **p = (const char **) a;
+ const char **q = (const char **) b;
+ return strcasecmp (*p, *q);
+}
+#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.
@@ -1977,6 +1989,12 @@ windows_create_inferior (struct target_o
char *toexec;
char *args;
HANDLE tty;
+ char *w32env;
+ char *temp;
+ size_t envlen;
+ int i;
+ size_t envsize;
+ char **env;
#endif
PROCESS_INFORMATION pi;
BOOL ret;
@@ -2124,6 +2142,31 @@ windows_create_inferior (struct target_o
}
}
+ /* CreateProcess takes the environment list as a null terminated set of
+ strings (i.e. two nulls terminate the list). */
+
+ /* Get total size for env strings. */
+ for (envlen = 0, i = 0; in_env[i] && *in_env[i]; i++)
+ envlen += strlen (in_env[i]) + 1;
+
+ envsize = sizeof (in_env[0]) * (i + 1);
+ env = (char **) alloca (envsize);
+ memcpy (env, in_env, envsize);
+ /* Windows programs expect the environment block to be sorted. */
+ qsort (env, i, sizeof (char *), envvar_cmp);
+
+ w32env = alloca (envlen + 1);
+
+ /* Copy env strings into new buffer. */
+ for (temp = w32env, i = 0; env[i] && *env[i]; i++)
+ {
+ strcpy (temp, env[i]);
+ temp += strlen (temp) + 1;
+ }
+
+ /* Final nil string to terminate new env. */
+ *temp = 0;
+
windows_init_thread_list ();
ret = CreateProcessA (0,
args, /* command line */
@@ -2131,7 +2174,7 @@ windows_create_inferior (struct target_o
NULL, /* thread */
TRUE, /* inherit handles */
flags, /* start flags */
- NULL, /* environment */
+ w32env, /* environment */
NULL, /* current directory */
&si,
&pi);
next prev parent reply other threads:[~2011-09-28 9:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-11 13:24 Eli Zaretskii
2011-09-11 22:03 ` asmwarrior
2011-09-19 8:04 ` Eli Zaretskii
2011-09-25 23:56 ` Eli Zaretskii
2011-09-26 5:22 ` Stan Shebs
2011-09-26 17:22 ` Joel Brobecker
2011-09-26 18:23 ` Eli Zaretskii
2011-09-28 9:39 ` Eli Zaretskii [this message]
2011-10-03 18:18 ` Tom Tromey
2011-10-03 18:25 ` Eli Zaretskii
2011-10-04 7:54 ` Corinna Vinschen
2011-10-04 9:29 ` Eli Zaretskii
2011-10-04 11:13 ` Corinna Vinschen
2011-10-04 9:56 ` [RFC] Environment variables passed to inferior for Cygwin build ( follow up on mingw fix for PR 10989) Pierre Muller
2011-10-04 10:40 ` Eli Zaretskii
2011-10-04 11:16 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83d3elf2oh.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox