Commit d9e4c610 by Nicolas Capens

Add an attach debugger dialog.

Bug 15759123 Change-Id: I363524a191d319e03ce2b874cfc853c7330b684f Reviewed-on: https://swiftshader-review.googlesource.com/3735Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 8d31422d
...@@ -99,6 +99,43 @@ namespace D3D9 ...@@ -99,6 +99,43 @@ namespace D3D9
} }
} }
static INT_PTR CALLBACK DebuggerWaitDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
RECT rect;
switch(uMsg)
{
case WM_INITDIALOG:
GetWindowRect(GetDesktopWindow(), &rect);
SetWindowPos(hwnd, HWND_TOP, rect.right / 2, rect.bottom / 2, 0, 0, SWP_NOSIZE);
SetTimer(hwnd, 1, 100, NULL);
return TRUE;
case WM_COMMAND:
if(LOWORD(wParam) == IDCANCEL)
{
EndDialog(hwnd, 0);
}
break;
case WM_TIMER:
if(IsDebuggerPresent())
{
EndDialog(hwnd, 0);
}
}
return FALSE;
}
static void WaitForDebugger(HINSTANCE instance)
{
if(!IsDebuggerPresent())
{
HRSRC dialog = FindResource(instance, MAKEINTRESOURCE(IDD_DIALOG1), RT_DIALOG);
DLGTEMPLATE *dialogTemplate = (DLGTEMPLATE*)LoadResource(instance, dialog);
DialogBoxIndirect(instance, dialogTemplate, NULL, DebuggerWaitDialogProc);
}
}
using namespace D3D9; using namespace D3D9;
extern "C" extern "C"
...@@ -111,7 +148,7 @@ extern "C" ...@@ -111,7 +148,7 @@ extern "C"
if(dllInstance == 0) if(dllInstance == 0)
{ {
FILE *file = fopen("debug.txt", "w"); // Clear debug log FILE *file = fopen("debug.txt", "w"); // Clear debug log
fclose(file); if(file) fclose(file);
} }
#endif #endif
...@@ -124,6 +161,9 @@ extern "C" ...@@ -124,6 +161,9 @@ extern "C"
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
break; break;
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
#ifndef NDEBUG
WaitForDebugger(instance);
#endif
DisableThreadLibraryCalls(instance); DisableThreadLibraryCalls(instance);
break; break;
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
......
...@@ -84,6 +84,40 @@ BEGIN ...@@ -84,6 +84,40 @@ BEGIN
END END
END END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG1 DIALOGEX 0, 0, 129, 47
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Waiting for debugger"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Cancel",IDCANCEL,72,26,50,14
LTEXT "Attach a debugger or ESC to cancel",IDC_STATIC,7,7,115,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_DIALOG1, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 122
TOPMARGIN, 7
BOTTOMMARGIN, 40
END
END
#endif // APSTUDIO_INVOKED
#endif // English (United States) resources #endif // English (United States) resources
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
......
//{{NO_DEPENDENCIES}} //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file. // Microsoft Visual C++ generated include file.
// Used by D3D9.rc // Used by D3D9.rc
#define IDD_DIALOG1 101
#define IDC_STATIC -1
// Next default values for new objects // Next default values for new objects
// //
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment