1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Fix MinGW build

This commit is contained in:
mncat77 2024-10-20 16:20:00 +02:00
parent 3dc68bcb76
commit 809a578ad5

View File

@ -10,6 +10,9 @@
# include <inttypes.h> # include <inttypes.h>
# include <intrin.h> # include <intrin.h>
# include "../common/TracyUwp.hpp" # include "../common/TracyUwp.hpp"
# ifndef _MSC_VER
# include <excpt.h>
# endif
#else #else
# include <sys/time.h> # include <sys/time.h>
# include <sys/param.h> # include <sys/param.h>
@ -905,6 +908,13 @@ LONG WINAPI CrashFilter( PEXCEPTION_POINTERS pExp )
} }
#endif #endif
#if defined _WIN32 && !defined _MSC_VER
LONG WINAPI CrashFilterExecute( PEXCEPTION_POINTERS pExp )
{
return EXCEPTION_EXECUTE_HANDLER;
}
#endif
static Profiler* s_instance = nullptr; static Profiler* s_instance = nullptr;
static Thread* s_thread; static Thread* s_thread;
#ifndef TRACY_NO_FRAME_IMAGE #ifndef TRACY_NO_FRAME_IMAGE
@ -1507,7 +1517,7 @@ void Profiler::InstallCrashHandler()
#if defined _WIN32 && !defined TRACY_UWP && !defined TRACY_NO_CRASH_HANDLER #if defined _WIN32 && !defined TRACY_UWP && !defined TRACY_NO_CRASH_HANDLER
// We cannot use Vectored Exception handling because it catches application-wide frame-based SEH blocks. We only // We cannot use Vectored Exception handling because it catches application-wide frame-based SEH blocks. We only
// want to catch unhandled exceptions. // want to catch unhandled exceptions.
m_prevHandler = SetUnhandledExceptionFilter( CrashFilter ); m_prevHandler = reinterpret_cast<void*>( SetUnhandledExceptionFilter( CrashFilter ) );
#endif #endif
#ifndef TRACY_NO_CRASH_HANDLER #ifndef TRACY_NO_CRASH_HANDLER
@ -3109,6 +3119,7 @@ char* Profiler::SafeCopyProlog( const char* data, size_t size )
if( size > SafeSendBufferSize ) buf = (char*)tracy_malloc( size ); if( size > SafeSendBufferSize ) buf = (char*)tracy_malloc( size );
#ifdef _WIN32 #ifdef _WIN32
# ifdef _MSC_VER
__try __try
{ {
memcpy( buf, data, size ); memcpy( buf, data, size );
@ -3117,6 +3128,16 @@ char* Profiler::SafeCopyProlog( const char* data, size_t size )
{ {
success = false; success = false;
} }
# else
__try1( CrashFilterExecute )
{
memcpy( buf, data, size );
}
__except1
{
success = false;
}
# endif
#else #else
// Send through the pipe to ensure safe reads // Send through the pipe to ensure safe reads
for( size_t offset = 0; offset != size; /*in loop*/ ) for( size_t offset = 0; offset != size; /*in loop*/ )