mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 04:00:07 +08:00
* win32-low.c (create_process): New.
(win32_create_inferior): Use create_process instead of CreateProcess. If create_process failed retry appending an ".exe" suffix. Store the GetLastError result immediatelly after create_process calls and use it on the call to error.
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
2007-09-03 Pedro Alves <pedro_alves@portugalmail.pt>
|
||||||
|
|
||||||
|
* win32-low.c (create_process): New.
|
||||||
|
(win32_create_inferior): Use create_process instead of
|
||||||
|
CreateProcess. If create_process failed retry appending an ".exe"
|
||||||
|
suffix. Store the GetLastError result immediatelly after
|
||||||
|
create_process calls and use it on the call to error.
|
||||||
|
|
||||||
2007-09-03 Pedro Alves <pedro_alves@portugalmail.pt>
|
2007-09-03 Pedro Alves <pedro_alves@portugalmail.pt>
|
||||||
|
|
||||||
* win32-low.c (handle_load_dll): Don't use toolhelp when waiting.
|
* win32-low.c (handle_load_dll): Don't use toolhelp when waiting.
|
||||||
|
@ -373,6 +373,55 @@ strwinerror (DWORD error)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL
|
||||||
|
create_process (const char *program, char *args,
|
||||||
|
DWORD flags, PROCESS_INFORMATION *pi)
|
||||||
|
{
|
||||||
|
BOOL ret;
|
||||||
|
|
||||||
|
#ifdef _WIN32_WCE
|
||||||
|
wchar_t *p, *wprogram, *wargs;
|
||||||
|
size_t argslen;
|
||||||
|
|
||||||
|
wprogram = alloca ((strlen (program) + 1) * sizeof (wchar_t));
|
||||||
|
mbstowcs (wprogram, program, strlen (program) + 1);
|
||||||
|
|
||||||
|
for (p = wprogram; *p; ++p)
|
||||||
|
if (L'/' == *p)
|
||||||
|
*p = L'\\';
|
||||||
|
|
||||||
|
argslen = strlen (args);
|
||||||
|
wargs = alloca ((argslen + 1) * sizeof (wchar_t));
|
||||||
|
mbstowcs (wargs, args, argslen + 1);
|
||||||
|
|
||||||
|
ret = CreateProcessW (wprogram, /* image name */
|
||||||
|
wargs, /* command line */
|
||||||
|
NULL, /* security, not supported */
|
||||||
|
NULL, /* thread, not supported */
|
||||||
|
FALSE, /* inherit handles, not supported */
|
||||||
|
flags, /* start flags */
|
||||||
|
NULL, /* environment, not supported */
|
||||||
|
NULL, /* current directory, not supported */
|
||||||
|
NULL, /* start info, not supported */
|
||||||
|
pi); /* proc info */
|
||||||
|
#else
|
||||||
|
STARTUPINFOA si = { sizeof (STARTUPINFOA) };
|
||||||
|
|
||||||
|
ret = CreateProcessA (program, /* image name */
|
||||||
|
args, /* command line */
|
||||||
|
NULL, /* security */
|
||||||
|
NULL, /* thread */
|
||||||
|
TRUE, /* inherit handles */
|
||||||
|
flags, /* start flags */
|
||||||
|
NULL, /* environment */
|
||||||
|
NULL, /* current directory */
|
||||||
|
&si, /* start info */
|
||||||
|
pi); /* proc info */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/* Start a new process.
|
/* Start a new process.
|
||||||
PROGRAM is a path to the program to execute.
|
PROGRAM is a path to the program to execute.
|
||||||
ARGS is a standard NULL-terminated array of arguments,
|
ARGS is a standard NULL-terminated array of arguments,
|
||||||
@ -392,12 +441,7 @@ win32_create_inferior (char *program, char **program_args)
|
|||||||
int argslen;
|
int argslen;
|
||||||
int argc;
|
int argc;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
#ifndef __MINGW32CE__
|
DWORD err;
|
||||||
STARTUPINFOA si = { sizeof (STARTUPINFOA) };
|
|
||||||
char *winenv = NULL;
|
|
||||||
#else
|
|
||||||
wchar_t *wargs, *wprogram;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!program)
|
if (!program)
|
||||||
error ("No executable specified, specify executable to debug.\n");
|
error ("No executable specified, specify executable to debug.\n");
|
||||||
@ -437,34 +481,15 @@ win32_create_inferior (char *program, char **program_args)
|
|||||||
flags |= CREATE_NEW_PROCESS_GROUP;
|
flags |= CREATE_NEW_PROCESS_GROUP;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __MINGW32CE__
|
ret = create_process (program, args, flags, &pi);
|
||||||
to_back_slashes (program);
|
err = GetLastError ();
|
||||||
wargs = alloca (argslen * sizeof (wchar_t));
|
if (!ret && err == ERROR_FILE_NOT_FOUND)
|
||||||
mbstowcs (wargs, args, argslen);
|
{
|
||||||
wprogram = alloca ((strlen (program) + 1) * sizeof (wchar_t));
|
char *exename = alloca (strlen (program) + 5);
|
||||||
mbstowcs (wprogram, program, strlen (program) + 1);
|
strcat (strcpy (exename, program), ".exe");
|
||||||
ret = CreateProcessW (wprogram, /* image name */
|
ret = create_process (exename, args, flags, &pi);
|
||||||
wargs, /* command line */
|
err = GetLastError ();
|
||||||
NULL, /* security, not supported */
|
}
|
||||||
NULL, /* thread, not supported */
|
|
||||||
FALSE, /* inherit handles, not supported */
|
|
||||||
flags, /* start flags */
|
|
||||||
NULL, /* environment, not supported */
|
|
||||||
NULL, /* current directory, not supported */
|
|
||||||
NULL, /* start info, not supported */
|
|
||||||
&pi); /* proc info */
|
|
||||||
#else
|
|
||||||
ret = CreateProcessA (program, /* image name */
|
|
||||||
args, /* command line */
|
|
||||||
NULL, /* security */
|
|
||||||
NULL, /* thread */
|
|
||||||
TRUE, /* inherit handles */
|
|
||||||
flags, /* start flags */
|
|
||||||
winenv, /* environment */
|
|
||||||
NULL, /* current directory */
|
|
||||||
&si, /* start info */
|
|
||||||
&pi); /* proc info */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef USE_WIN32API
|
#ifndef USE_WIN32API
|
||||||
if (orig_path)
|
if (orig_path)
|
||||||
@ -473,7 +498,6 @@ win32_create_inferior (char *program, char **program_args)
|
|||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
DWORD err = GetLastError ();
|
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user