diff options
author | Vladislav Vaintroub <wlad@montyprogram.com> | 2011-05-26 00:37:08 +0200 |
---|---|---|
committer | Vladislav Vaintroub <wlad@montyprogram.com> | 2011-05-26 00:37:08 +0200 |
commit | 79afbf7646979be2ca4c90690de5e7875001b3f1 (patch) | |
tree | af6a5574734398f9fdefbec66b2f318b55bde2ed /sql/mysqld.cc | |
parent | c102ab13bce5931e0e40aef4f74ef7d2da42b5b1 (diff) | |
download | mariadb-git-79afbf7646979be2ca4c90690de5e7875001b3f1.tar.gz |
On Windows, collect mysql error log with Windows Error Reporting.
This simplifies postmortem analysis for crashes reported via Winqual.
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r-- | sql/mysqld.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d5caad7fed5..50c01ae5aa0 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -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 } } |