Commit 79afbf76 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

On Windows, collect mysql error log with Windows Error Reporting.

This simplifies postmortem analysis for crashes reported via Winqual.
parent c102ab13
......@@ -3984,6 +3984,32 @@ static void end_ssl()
#endif /* EMBEDDED_LIBRARY */
#ifdef _WIN32
/**
Registers a file to be collected when Windows Error Reporting creates a crash
report.
@note only works on Vista and later, since WerRegisterFile() is not available
on earlier Windows.
*/
#include <werapi.h>
static void add_file_to_crash_report(char *file)
{
/* Load WerRegisterFile function dynamically.*/
HRESULT (WINAPI *pWerRegisterFile)(PCWSTR, WER_REGISTER_FILE_TYPE, DWORD)
=(HRESULT (WINAPI *) (PCWSTR, WER_REGISTER_FILE_TYPE, DWORD))
GetProcAddress(GetModuleHandle("kernel32"),"WerRegisterFile");
if (pWerRegisterFile)
{
wchar_t wfile[MAX_PATH+1]= {0};
if (mbstowcs(wfile, file, MAX_PATH) != (size_t)-1)
{
pWerRegisterFile(wfile, WerRegFileTypeOther, WER_FILE_ANONYMOUS_DATA);
}
}
}
#endif
static int init_server_components()
{
......@@ -4036,6 +4062,11 @@ static int init_server_components()
if (!res)
setbuf(stderr, NULL);
#ifdef _WIN32
/* Add error log to windows crash reporting. */
add_file_to_crash_report(log_error_file);
#endif
}
}
......
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