From 655324f9dab084d47263f7510288ee3938d7f2e4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 2 Aug 2013 19:08:33 +0000 Subject: /debug command line option to disable built-in exception handlers git-svn-id: http://svn.miranda-ng.org/main/trunk@5553 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/mir_core/cmdline.cpp | 3 +++ src/mir_core/miranda.cpp | 1 + src/mir_core/miranda.h | 1 + src/mir_core/threads.cpp | 30 +++++++++++++++++++++--------- 4 files changed, 26 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mir_core/cmdline.cpp b/src/mir_core/cmdline.cpp index 6e112b7e14..acda692e0f 100644 --- a/src/mir_core/cmdline.cpp +++ b/src/mir_core/cmdline.cpp @@ -79,6 +79,9 @@ MIR_CORE_DLL(void) CmdLine_Parse(LPTSTR ptszCmdLine) p--; // the cycle will wipe this space automatically } + + if ( CmdLine_GetOption( _T("debug"))) + g_bDebugMode = true; } MIR_CORE_DLL(LPCTSTR) CmdLine_GetOption(const TCHAR* ptszParameter) diff --git a/src/mir_core/miranda.cpp b/src/mir_core/miranda.cpp index 73c5c9d0be..571bbb811a 100644 --- a/src/mir_core/miranda.cpp +++ b/src/mir_core/miranda.cpp @@ -34,6 +34,7 @@ HINSTANCE hInst = 0; HANDLE hStackMutex, hThreadQueueEmpty; DWORD mir_tls = 0; +bool g_bDebugMode = false; ///////////////////////////////////////////////////////////////////////////////////////// // module init diff --git a/src/mir_core/miranda.h b/src/mir_core/miranda.h index 93c7201e6a..1525c1b792 100644 --- a/src/mir_core/miranda.h +++ b/src/mir_core/miranda.h @@ -40,6 +40,7 @@ void UninitProtocols(); extern HINSTANCE hInst; extern HWND hAPCWindow; extern HANDLE hStackMutex, hThreadQueueEmpty; +extern bool g_bDebugMode; /**** modules.cpp **********************************************************************/ diff --git a/src/mir_core/threads.cpp b/src/mir_core/threads.cpp index ddce70df8b..af61aa82f9 100644 --- a/src/mir_core/threads.cpp +++ b/src/mir_core/threads.cpp @@ -110,12 +110,16 @@ void __cdecl forkthread_r(void *arg) void *cookie = fa->arg; Thread_Push((HINSTANCE)callercode); SetEvent(fa->hEvent); - __try - { + if (g_bDebugMode) callercode(cookie); - } - __except(pMirandaExceptFilter(GetExceptionCode(), GetExceptionInformation())) - { + else { + __try + { + callercode(cookie); + } + __except(pMirandaExceptFilter(GetExceptionCode(), GetExceptionInformation())) + { + } } SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); @@ -150,15 +154,23 @@ unsigned __stdcall forkthreadex_r(void * arg) Thread_Push((HINSTANCE)threadcode, fa->owner); SetEvent(fa->hEvent); - __try - { + if (g_bDebugMode) { if (owner) rc = threadcodeex(owner, cookie); else rc = threadcode(cookie); } - __except(pMirandaExceptFilter(GetExceptionCode(), GetExceptionInformation())) - { + else { + __try + { + if (owner) + rc = threadcodeex(owner, cookie); + else + rc = threadcode(cookie); + } + __except(pMirandaExceptFilter(GetExceptionCode(), GetExceptionInformation())) + { + } } SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); -- cgit v1.2.3