mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
tst: winfsp-tests: UnhandledExceptionFilter
This commit is contained in:
parent
e1b1284153
commit
28ac5a1cfe
@ -107,7 +107,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<AdditionalDependencies>ntdll.lib;netapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ntdll.lib;netapi32.lib;dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
@ -123,7 +123,7 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<AdditionalDependencies>ntdll.lib;netapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ntdll.lib;netapi32.lib;dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
@ -143,7 +143,7 @@
|
|||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>ntdll.lib;netapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ntdll.lib;netapi32.lib;dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
@ -163,7 +163,7 @@
|
|||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>ntdll.lib;netapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>ntdll.lib;netapi32.lib;dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <dbghelp.h>
|
||||||
#include <lm.h>
|
#include <lm.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <tlib/testsuite.h>
|
#include <tlib/testsuite.h>
|
||||||
@ -177,12 +178,32 @@ LONG WINAPI UnhandledExceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo)
|
|||||||
{
|
{
|
||||||
if (0 != ExceptionInfo && 0 != ExceptionInfo->ExceptionRecord)
|
if (0 != ExceptionInfo && 0 != ExceptionInfo->ExceptionRecord)
|
||||||
{
|
{
|
||||||
static CHAR Buf[64];
|
static CHAR OutBuf[128];
|
||||||
static DWORD Bytes;
|
static union
|
||||||
wsprintfA(Buf, "\nEXCEPTION 0x%lx at 0x%p\n",
|
{
|
||||||
|
SYMBOL_INFO V;
|
||||||
|
UINT8 Buf[sizeof(SYMBOL_INFO) + 64];
|
||||||
|
} Info;
|
||||||
|
LARGE_INTEGER Large;
|
||||||
|
Info.V.SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||||
|
Info.V.MaxNameLen = 64;
|
||||||
|
if (SymFromAddr(GetCurrentProcess(),
|
||||||
|
(DWORD64)ExceptionInfo->ExceptionRecord->ExceptionAddress,
|
||||||
|
&Large.QuadPart,
|
||||||
|
&Info.V))
|
||||||
|
{
|
||||||
|
wsprintfA(OutBuf, "\nEXCEPTION 0x%lX at %s+0x%lX\n",
|
||||||
|
ExceptionInfo->ExceptionRecord->ExceptionCode,
|
||||||
|
Info.V.Name,
|
||||||
|
Large.LowPart);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wsprintfA(OutBuf, "\nEXCEPTION 0x%lX at 0x%p\n",
|
||||||
ExceptionInfo->ExceptionRecord->ExceptionCode,
|
ExceptionInfo->ExceptionRecord->ExceptionCode,
|
||||||
ExceptionInfo->ExceptionRecord->ExceptionAddress);
|
ExceptionInfo->ExceptionRecord->ExceptionAddress);
|
||||||
WriteFile(GetStdHandle(STD_ERROR_HANDLE), Buf, lstrlenA(Buf), &Bytes, 0);
|
}
|
||||||
|
WriteFile(GetStdHandle(STD_ERROR_HANDLE), OutBuf, lstrlenA(OutBuf), &Large.LowPart, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
exiting();
|
exiting();
|
||||||
@ -226,6 +247,8 @@ int main(int argc, char *argv[])
|
|||||||
TESTSUITE(wsl_tests);
|
TESTSUITE(wsl_tests);
|
||||||
TESTSUITE(volpath_tests);
|
TESTSUITE(volpath_tests);
|
||||||
|
|
||||||
|
SymInitialize(GetCurrentProcess(), 0, TRUE);
|
||||||
|
|
||||||
atexit(exiting);
|
atexit(exiting);
|
||||||
signal(SIGABRT, abort_handler);
|
signal(SIGABRT, abort_handler);
|
||||||
SetUnhandledExceptionFilter(UnhandledExceptionHandler);
|
SetUnhandledExceptionFilter(UnhandledExceptionHandler);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user