29#ifndef STATUS_DEBUGGER_INACTIVE
30#define STATUS_DEBUGGER_INACTIVE ((NTSTATUS) 0xC0000354)
33#define child_ok (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_child_ok
136 ok(0,
"unable to open '%s'\n", logfile);
142 ok(
read ==
size,
"wrong size for '%s': read=%d\n", logfile,
read);
168 trace(
"child: crashing...\n");
225 trace(
"debugger: waiting for the start signal...\n");
242 blackbox.
detach_rc=pDebugActiveProcessStop(blackbox.
pid);
253 trace(
"debugger: done debugging...\n");
262 static BOOL skip_crash_and_debug =
FALSE;
276 if (skip_crash_and_debug)
278 win_skip(
"Skipping crash_and_debug\n");
285 skip_crash_and_debug =
TRUE;
286 skip(
"No write access to change the debugger\n");
295 sprintf(
cmd,
"%s debugger %s \"%s\" %%ld %%ld",
argv0, dbgtasks, dbglog);
314 trace(
"waiting for child exit...\n");
316#if defined(_WIN64) && defined(__MINGW32__)
319 if (skip_crash_and_debug)
326 win_skip(
"Giving up on child process\n");
330 ok(wait_code ==
WAIT_OBJECT_0,
"Timed out waiting for the child to crash\n");
333 if (
strstr(dbgtasks,
"code2"))
350 if (
strstr(dbgtasks,
"order"))
353 trace(
"waiting for the debugger...\n");
355#if defined(_WIN64) && defined(__MINGW32__)
358 if (skip_crash_and_debug)
362 win_skip(
"Giving up on debugger\n");
366 ok(wait_code ==
WAIT_OBJECT_0,
"Timed out waiting for the debugger\n");
368 ok(
load_blackbox(childlog, &crash_blackbox,
sizeof(crash_blackbox)),
"failed to open: %s\n", childlog);
369 ok(
load_blackbox(dbglog, &dbg_blackbox,
sizeof(dbg_blackbox)),
"failed to open: %s\n", dbglog);
371 ok(dbg_blackbox.
argc == 6,
"wrong debugger argument count: %d\n", dbg_blackbox.
argc);
372 ok(dbg_blackbox.
pid == crash_blackbox.
pid,
"the child and debugged pids don't match: %d != %d\n", crash_blackbox.
pid, dbg_blackbox.
pid);
373 ok(dbg_blackbox.
debug_rc,
"debugger: SetEvent(debug_event) failed err=%d\n", dbg_blackbox.
debug_err);
375 ok(dbg_blackbox.
nokill_rc,
"DebugSetProcessKillOnExit(FALSE) failed err=%d\n", dbg_blackbox.
nokill_err);
376 ok(dbg_blackbox.
detach_rc,
"DebugActiveProcessStop(%d) failed err=%d\n", dbg_blackbox.
pid, dbg_blackbox.
detach_err);
406 trace(
"waiting for child exit...\n");
416 static const char* AeDebug=
"Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug";
417 static const char* WineDbg=
"Software\\Wine\\WineDbg";
430 ok(0,
"could not find the test executable '%s'\n", test_exe);
438 save_value(hkey,
"debugger", &debugger_value);
439 trace(
"HKLM\\%s\\debugger is set to '%s'\n", AeDebug, debugger_value.
data);
443 skip(
"not enough privileges to change the debugger\n");
448 ok(0,
"could not open the AeDebug key: %d\n",
ret);
454 strstr((
char*)debugger_value.
data,
"winedbg --auto"))
462 save_value(hkeyWinedbg,
"ShowCrashDialog", &crash_dlg_value);
469 ok(0,
"Couldn't access WineDbg Key - error %u\n",
ret);
478 skip(
"\"none\" debugger test needs user interaction\n");
482 if (pDebugSetProcessKillOnExit)
485 win_skip(
"DebugSetProcessKillOnExit is not available\n");
486 if (pDebugActiveProcessStop)
489 win_skip(
"DebugActiveProcessStop is not available\n");
507 if(!pCheckRemoteDebuggerPresent)
509 win_skip(
"CheckRemoteDebuggerPresent is not available\n");
515 ok(bret ,
"expected CheckRemoteDebuggerPresent to succeed\n");
521 bret = pCheckRemoteDebuggerPresent(
NULL,&present);
522 ok(!bret ,
"expected CheckRemoteDebuggerPresent to fail\n");
523 ok(present,
"expected parameter to be unchanged\n");
529 ok(!bret ,
"expected CheckRemoteDebuggerPresent to fail\n");
542 const char *blackbox_file;
548 blackbox_file =
argv[4];
565 ret = pDebugActiveProcessStop(ppid);
575 ret = pIsDebuggerPresent();
583 ret = pIsDebuggerPresent();
597 const char *arguments =
" debugger child ";
607 if (!pDebugActiveProcessStop || !pCheckRemoteDebuggerPresent)
609 win_skip(
"DebugActiveProcessStop or CheckRemoteDebuggerPresent not available, skipping test.\n");
615 ok(!
ret,
"DebugActiveProcess() succeeded on own process.\n");
621 memset(&si, 0,
sizeof(si));
628 ret = pCheckRemoteDebuggerPresent(
pi.hProcess, &
debug);
661 const char *arguments =
"debugger children last";
663 const char *blackbox_file, *
p;
673 blackbox_file =
argv[3];
676 p =
p ?
p+1 : blackbox_file;
678 strcat(event_name,
"_init");
685 p =
p ?
p+1 : blackbox_file;
687 strcat(event_name,
"_attach");
696 memset(&si, 0,
sizeof(si));
702 "Timed out waiting for the child to exit\n");
717 const char *arguments =
"debugger children";
723 HANDLE event_init, event_attach;
728 if (!pDebugActiveProcessStop || !pCheckRemoteDebuggerPresent)
730 win_skip(
"DebugActiveProcessStop or CheckRemoteDebuggerPresent not available, skipping test.\n");
739 p =
p ?
p+1 : blackbox_file;
741 strcat(event_name,
"_init");
746 p =
p ?
p+1 : blackbox_file;
748 strcat(event_name,
"_attach");
752 memset(&si, 0,
sizeof(si));
767 ret = pCheckRemoteDebuggerPresent(
pi.hProcess, &
debug);
787 ok(got_child_event,
"didn't get any child events (flag: %x).\n",
flag);
789 ok(!got_child_event,
"got child event (flag: %x).\n",
flag);
810 pCheckRemoteDebuggerPresent=(
void*)
GetProcAddress(
hdll,
"CheckRemoteDebuggerPresent");
char * strcat(char *DstString, const char *SrcString)
int strcmp(const char *String1, const char *String2)
char * strstr(char *String1, char *String2)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strcpy(char *DstString, const char *SrcString)
static void startup(void)
#define RegCloseKey(hKey)
LONG WINAPI RegCreateKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
LONG WINAPI RegDeleteValueA(HKEY hKey, LPCSTR lpValueName)
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
LONG WINAPI RegCreateKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD Reserved, _In_ LPSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_ LPDWORD lpdwDisposition)
LONG WINAPI RegDeleteKeyA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey)
#define ERROR_INVALID_PARAMETER
#define ReadFile(a, b, c, d, e)
#define GetProcAddress(x, y)
#define INVALID_HANDLE_VALUE
#define CreateFileA(a, b, c, d, e, f, g)
#define GetCurrentProcess()
#define HeapFree(x, y, z)
#define ERROR_ACCESS_DENIED
BOOL WINAPI ContinueDebugEvent(IN DWORD dwProcessId, IN DWORD dwThreadId, IN DWORD dwContinueStatus)
BOOL WINAPI DebugActiveProcess(IN DWORD dwProcessId)
BOOL WINAPI WaitForDebugEvent(IN LPDEBUG_EVENT lpDebugEvent, IN DWORD dwMilliseconds)
UINT WINAPI SetErrorMode(IN UINT uMode)
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI DECLSPEC_HOTPATCH SetUnhandledExceptionFilter(IN LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter)
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
VOID WINAPI ExitProcess(IN UINT uExitCode)
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
static void basename(LPCWSTR path, LPWSTR name)
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
#define PROCESS_QUERY_INFORMATION
#define ERROR_FILE_NOT_FOUND
#define sprintf(buf, format,...)
#define STATUS_DEBUGGER_INACTIVE
static LONG child_failures
static void crash_and_winedbg(HKEY hkey, const char *argv0)
static void test_ExitCode(void)
static void test_debug_loop(int argc, char **argv)
static void get_events(const char *name, HANDLE *start_event, HANDLE *done_event)
static void crash_and_debug(HKEY hkey, const char *argv0, const char *dbgtasks)
static void doChildren(int argc, char **argv)
static void doDebugger(int argc, char **argv)
static DWORD save_value(HKEY hkey, const char *value, reg_save_value *saved)
static void doCrash(int argc, char **argv)
static void save_blackbox(const char *logfile, void *blackbox, int size)
static void restore_value(HKEY hkey, reg_save_value *saved)
struct tag_reg_save_value reg_save_value
static int load_blackbox(const char *logfile, void *blackbox, int size)
static void doChild(int argc, char **argv)
static void test_debug_children(char *name, DWORD flag, BOOL debug_child)
static void test_RemoteDebugger(void)
static HANDLE start_event
static __ms_va_list valist
#define REG_OPTION_NON_VOLATILE
#define REG_CREATED_NEW_KEY
#define REG_OPENED_EXISTING_KEY
#define STATUS_ACCESS_VIOLATION
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
int winetest_get_mainargs(char ***pargv)
int winetest_vok(int condition, const char *msg, __winetest_va_list ap)
#define WINETEST_PRINTF_ATTR(fmt, args)
static char argv0[MAX_PATH]
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
HANDLE WINAPI DECLSPEC_HOTPATCH OpenEventA(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN LPCSTR lpName)
#define INVALID_FILE_ATTRIBUTES
DWORD WINAPI GetLastError(void)
#define STARTF_USESHOWWINDOW
DWORD WINAPI GetCurrentProcessId(void)
#define EXIT_PROCESS_DEBUG_EVENT
#define DEBUG_ONLY_THIS_PROCESS
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
#define HKEY_LOCAL_MACHINE
#define HKEY_CURRENT_USER