mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-21 02:24:17 +08:00
Fix argv[] in programs invoked by gdbserver on MS-Windows
gdbserver/ChangeLog 2020-02-14 Eli Zaretskii <eliz@gnu.org> * win32-low.c (create_process): Prepend PROGRAM to ARGS when preparing the command line for CreateProcess. (win32_create_inferior): Reflect the program name in debugging output that shows the process and its command line.
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
2020-02-14 Eli Zaretskii <eliz@gnu.org>
|
||||||
|
|
||||||
|
* win32-low.c (create_process): Prepend PROGRAM to ARGS when
|
||||||
|
preparing the command line for CreateProcess.
|
||||||
|
(win32_create_inferior): Reflect the program name in debugging
|
||||||
|
output that shows the process and its command line.
|
||||||
|
|
||||||
2020-02-13 Simon Marchi <simon.marchi@efficios.com>
|
2020-02-13 Simon Marchi <simon.marchi@efficios.com>
|
||||||
|
|
||||||
* Makefile.in: Rename source files from .c to .cc.
|
* Makefile.in: Rename source files from .c to .cc.
|
||||||
|
@ -559,21 +559,25 @@ create_process (const char *program, char *args,
|
|||||||
{
|
{
|
||||||
const char *inferior_cwd = get_inferior_cwd ();
|
const char *inferior_cwd = get_inferior_cwd ();
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
size_t argslen, proglen;
|
||||||
|
|
||||||
|
proglen = strlen (program) + 1;
|
||||||
|
argslen = strlen (args) + proglen;
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
#ifdef _WIN32_WCE
|
||||||
wchar_t *p, *wprogram, *wargs, *wcwd = NULL;
|
wchar_t *p, *wprogram, *wargs, *wcwd = NULL;
|
||||||
size_t argslen;
|
|
||||||
|
|
||||||
wprogram = alloca ((strlen (program) + 1) * sizeof (wchar_t));
|
wprogram = (wchar_t *) alloca (proglen * sizeof (wchar_t));
|
||||||
mbstowcs (wprogram, program, strlen (program) + 1);
|
mbstowcs (wprogram, program, proglen);
|
||||||
|
|
||||||
for (p = wprogram; *p; ++p)
|
for (p = wprogram; *p; ++p)
|
||||||
if (L'/' == *p)
|
if (L'/' == *p)
|
||||||
*p = L'\\';
|
*p = L'\\';
|
||||||
|
|
||||||
argslen = strlen (args);
|
|
||||||
wargs = alloca ((argslen + 1) * sizeof (wchar_t));
|
wargs = alloca ((argslen + 1) * sizeof (wchar_t));
|
||||||
mbstowcs (wargs, args, argslen + 1);
|
wcscpy (wargs, wprogram);
|
||||||
|
wcscat (wargs, L" ");
|
||||||
|
mbstowcs (wargs + proglen, args, argslen + 1 - proglen);
|
||||||
|
|
||||||
if (inferior_cwd != NULL)
|
if (inferior_cwd != NULL)
|
||||||
{
|
{
|
||||||
@ -601,20 +605,24 @@ Could not convert the expanded inferior cwd to wide-char."));
|
|||||||
pi); /* proc info */
|
pi); /* proc info */
|
||||||
#else
|
#else
|
||||||
STARTUPINFOA si = { sizeof (STARTUPINFOA) };
|
STARTUPINFOA si = { sizeof (STARTUPINFOA) };
|
||||||
|
char *program_and_args = (char *) alloca (argslen + 1);
|
||||||
|
|
||||||
ret = CreateProcessA (program, /* image name */
|
strcpy (program_and_args, program);
|
||||||
args, /* command line */
|
strcat (program_and_args, " ");
|
||||||
NULL, /* security */
|
strcat (program_and_args, args);
|
||||||
NULL, /* thread */
|
ret = CreateProcessA (program, /* image name */
|
||||||
TRUE, /* inherit handles */
|
program_and_args, /* command line */
|
||||||
flags, /* start flags */
|
NULL, /* security */
|
||||||
NULL, /* environment */
|
NULL, /* thread */
|
||||||
|
TRUE, /* inherit handles */
|
||||||
|
flags, /* start flags */
|
||||||
|
NULL, /* environment */
|
||||||
/* current directory */
|
/* current directory */
|
||||||
(inferior_cwd == NULL
|
(inferior_cwd == NULL
|
||||||
? NULL
|
? NULL
|
||||||
: gdb_tilde_expand (inferior_cwd).c_str()),
|
: gdb_tilde_expand (inferior_cwd).c_str()),
|
||||||
&si, /* start info */
|
&si, /* start info */
|
||||||
pi); /* proc info */
|
pi); /* proc info */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -665,7 +673,7 @@ win32_create_inferior (const char *program,
|
|||||||
program = real_path;
|
program = real_path;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OUTMSG2 (("Command line is \"%s\"\n", args));
|
OUTMSG2 (("Command line is \"%s %s\"\n", program, args));
|
||||||
|
|
||||||
#ifdef CREATE_NEW_PROCESS_GROUP
|
#ifdef CREATE_NEW_PROCESS_GROUP
|
||||||
flags |= CREATE_NEW_PROCESS_GROUP;
|
flags |= CREATE_NEW_PROCESS_GROUP;
|
||||||
@ -688,12 +696,12 @@ win32_create_inferior (const char *program,
|
|||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
error ("Error creating process \"%s%s\", (error %d): %s\n",
|
error ("Error creating process \"%s %s\", (error %d): %s\n",
|
||||||
program, args, (int) err, strwinerror (err));
|
program, args, (int) err, strwinerror (err));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OUTMSG2 (("Process created: %s\n", (char *) args));
|
OUTMSG2 (("Process created: %s %s\n", program, (char *) args));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32_WCE
|
#ifndef _WIN32_WCE
|
||||||
|
Reference in New Issue
Block a user