add pdb
generation for d2cs and d2dbs
This commit is contained in:
parent
90fa311a18
commit
0d1c09e918
5 changed files with 64 additions and 57 deletions
|
@ -88,7 +88,9 @@
|
|||
#include "handle_apireg.h"
|
||||
#include "i18n.h"
|
||||
#include "userlog.h"
|
||||
#ifdef WIN32
|
||||
#include "win32/windump.h"
|
||||
#endif
|
||||
#include "common/setup_after.h"
|
||||
|
||||
#ifdef WITH_LUA
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
#ifdef WIN32_GUI
|
||||
# include "win32/winmain.h"
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
# include "win32/windump.h"
|
||||
#endif
|
||||
|
||||
#include "compat/stdfileno.h"
|
||||
#include "compat/pgetpid.h"
|
||||
|
@ -253,6 +256,11 @@ extern int main(int argc, char ** argv)
|
|||
{
|
||||
int pid;
|
||||
|
||||
#ifdef WIN32
|
||||
// create a dump file whenever the gateway crashes
|
||||
SetUnhandledExceptionFilter(unhandled_handler);
|
||||
#endif
|
||||
|
||||
eventlog_set(stderr);
|
||||
if (!((pid = config_init(argc, argv)) == 0)) {
|
||||
// if (pid==1) pid=0;
|
||||
|
|
|
@ -38,6 +38,9 @@
|
|||
#ifdef WIN32_GUI
|
||||
# include "win32/winmain.h"
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
# include "win32/windump.h"
|
||||
#endif
|
||||
|
||||
#include "compat/stdfileno.h"
|
||||
#include "compat/pgetpid.h"
|
||||
|
@ -233,6 +236,11 @@ extern int main(int argc, char ** argv)
|
|||
int pid;
|
||||
char * pidfile;
|
||||
|
||||
#ifdef WIN32
|
||||
// create a dump file whenever the gateway crashes
|
||||
SetUnhandledExceptionFilter(unhandled_handler);
|
||||
#endif
|
||||
|
||||
eventlog_set(stderr);
|
||||
pid = config_init(argc, argv);
|
||||
if (!(pid == 0)) {
|
||||
|
|
|
@ -19,59 +19,53 @@
|
|||
|
||||
#include <windows.h>
|
||||
#include <Dbghelp.h>
|
||||
#include "windump.h"
|
||||
|
||||
namespace pvpgn
|
||||
void make_minidump(struct _EXCEPTION_POINTERS* e)
|
||||
{
|
||||
namespace bnetd
|
||||
auto hDbgHelp = LoadLibraryA("dbghelp");
|
||||
if (hDbgHelp == nullptr)
|
||||
return;
|
||||
auto pMiniDumpWriteDump = (decltype(&MiniDumpWriteDump))GetProcAddress(hDbgHelp, "MiniDumpWriteDump");
|
||||
if (pMiniDumpWriteDump == nullptr)
|
||||
return;
|
||||
|
||||
char name[MAX_PATH];
|
||||
{
|
||||
void make_minidump(struct _EXCEPTION_POINTERS* e)
|
||||
{
|
||||
auto hDbgHelp = LoadLibraryA("dbghelp");
|
||||
if (hDbgHelp == nullptr)
|
||||
return;
|
||||
auto pMiniDumpWriteDump = (decltype(&MiniDumpWriteDump))GetProcAddress(hDbgHelp, "MiniDumpWriteDump");
|
||||
if (pMiniDumpWriteDump == nullptr)
|
||||
return;
|
||||
|
||||
char name[MAX_PATH];
|
||||
{
|
||||
auto nameEnd = name + GetModuleFileNameA(GetModuleHandleA(0), name, MAX_PATH);
|
||||
SYSTEMTIME t;
|
||||
GetSystemTime(&t);
|
||||
wsprintfA(nameEnd - strlen(".exe"),
|
||||
"_%4d%02d%02d_%02d%02d%02d.dmp",
|
||||
t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond);
|
||||
}
|
||||
|
||||
auto hFile = CreateFileA(name, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
|
||||
MINIDUMP_EXCEPTION_INFORMATION exceptionInfo;
|
||||
exceptionInfo.ThreadId = GetCurrentThreadId();
|
||||
exceptionInfo.ExceptionPointers = e;
|
||||
exceptionInfo.ClientPointers = FALSE;
|
||||
|
||||
auto dumped = pMiniDumpWriteDump(
|
||||
GetCurrentProcess(),
|
||||
GetCurrentProcessId(),
|
||||
hFile,
|
||||
MINIDUMP_TYPE(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory),
|
||||
e ? &exceptionInfo : nullptr,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
LONG WINAPI unhandled_handler(struct _EXCEPTION_POINTERS* e)
|
||||
{
|
||||
make_minidump(e);
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
auto nameEnd = name + GetModuleFileNameA(GetModuleHandleA(0), name, MAX_PATH);
|
||||
SYSTEMTIME t;
|
||||
GetSystemTime(&t);
|
||||
wsprintfA(nameEnd - strlen(".exe"),
|
||||
"_%4d%02d%02d_%02d%02d%02d.dmp",
|
||||
t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond);
|
||||
}
|
||||
|
||||
auto hFile = CreateFileA(name, GENERIC_WRITE, FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
if (hFile == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
|
||||
MINIDUMP_EXCEPTION_INFORMATION exceptionInfo;
|
||||
exceptionInfo.ThreadId = GetCurrentThreadId();
|
||||
exceptionInfo.ExceptionPointers = e;
|
||||
exceptionInfo.ClientPointers = FALSE;
|
||||
|
||||
auto dumped = pMiniDumpWriteDump(
|
||||
GetCurrentProcess(),
|
||||
GetCurrentProcessId(),
|
||||
hFile,
|
||||
MINIDUMP_TYPE(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory),
|
||||
e ? &exceptionInfo : nullptr,
|
||||
nullptr,
|
||||
nullptr);
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
LONG WINAPI unhandled_handler(struct _EXCEPTION_POINTERS* e)
|
||||
{
|
||||
make_minidump(e);
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -16,13 +16,8 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifdef WIN32
|
||||
#include "windows.h""
|
||||
|
||||
namespace pvpgn
|
||||
{
|
||||
namespace bnetd
|
||||
{
|
||||
LONG WINAPI unhandled_handler(struct _EXCEPTION_POINTERS* e);
|
||||
}
|
||||
}
|
||||
LONG WINAPI unhandled_handler(struct _EXCEPTION_POINTERS* e);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue