diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-05-06 14:26:20 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-05-06 14:26:20 +0200 |
commit | e0de01190f8ccd460d2c7925b1e22cace2708928 (patch) | |
tree | 916c410965b1c036df4e7d412b1c64b0f26f9fbb /src/libs/utils/process_stub_win.c | |
parent | 9ae53e49ca7ebb13d2f347657fbb85e87e10a1f8 (diff) |
Started Console process handling for CDB.
Introduced "Suspend" mode for the process stub and corresponding
mode enumeration in console process (Windows).
Diffstat (limited to 'src/libs/utils/process_stub_win.c')
-rw-r--r-- | src/libs/utils/process_stub_win.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/libs/utils/process_stub_win.c b/src/libs/utils/process_stub_win.c index 961f1d5ae0..ed64260ab8 100644 --- a/src/libs/utils/process_stub_win.c +++ b/src/libs/utils/process_stub_win.c @@ -39,6 +39,8 @@ static FILE *qtcFd; static wchar_t *sleepMsg; +enum RunMode { Run, Debug, Suspend }; + /* Print some "press enter" message, wait for that, exit. */ static void doExit(int code) { @@ -112,6 +114,7 @@ int main() STARTUPINFOW si; PROCESS_INFORMATION pi; DEBUG_EVENT dbev; + enum RunMode mode = Run; argv = CommandLineToArgvW(GetCommandLine(), &argc); @@ -158,8 +161,20 @@ int main() si.cb = sizeof(si); creationFlags = CREATE_UNICODE_ENVIRONMENT; - if (!wcscmp(argv[ArgAction], L"debug")) + if (!wcscmp(argv[ArgAction], L"debug")) { + mode = Debug; + } else if (!wcscmp(argv[ArgAction], L"suspend")) { + mode = Suspend; + } + + switch (mode) { + case Debug: creationFlags |= DEBUG_ONLY_THIS_PROCESS; + break; + case Suspend: + creationFlags |= CREATE_SUSPENDED; + break; + } if (!CreateProcessW(0, argv[ArgCmdLine], 0, 0, FALSE, creationFlags, env, 0, &si, &pi)) { /* Only expected error: no such file or direcotry, i.e. executable not found */ sendMsg("err:exec %d\n", GetLastError()); @@ -172,7 +187,7 @@ int main() So instead we start a debugged process, eat all the initial debug events, suspend the process and detach from it. If gdb tries to attach *now*, everything goes smoothly. Yay. */ - if (creationFlags & DEBUG_ONLY_THIS_PROCESS) { + if (mode == Debug) { do { if (!WaitForDebugEvent (&dbev, INFINITE)) systemError("Cannot fetch debug event, error %d\n"); |