Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MinGW build #914

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion public/client/TracyProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
# include <inttypes.h>
# include <intrin.h>
# include "../common/TracyUwp.hpp"
# ifndef _MSC_VER
# include <excpt.h>
# endif
#else
# include <sys/time.h>
# include <sys/param.h>
Expand Down Expand Up @@ -905,6 +908,13 @@ LONG WINAPI CrashFilter( PEXCEPTION_POINTERS pExp )
}
#endif

#if defined _WIN32 && !defined _MSC_VER
LONG WINAPI CrashFilterExecute( PEXCEPTION_POINTERS pExp )
{
return EXCEPTION_EXECUTE_HANDLER;
}
#endif

static Profiler* s_instance = nullptr;
static Thread* s_thread;
#ifndef TRACY_NO_FRAME_IMAGE
Expand Down Expand Up @@ -1507,7 +1517,7 @@ void Profiler::InstallCrashHandler()
#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
// want to catch unhandled exceptions.
m_prevHandler = SetUnhandledExceptionFilter( CrashFilter );
m_prevHandler = reinterpret_cast<void*>( SetUnhandledExceptionFilter( CrashFilter ) );
#endif

#ifndef TRACY_NO_CRASH_HANDLER
Expand Down Expand Up @@ -3109,6 +3119,7 @@ char* Profiler::SafeCopyProlog( const char* data, size_t size )
if( size > SafeSendBufferSize ) buf = (char*)tracy_malloc( size );

#ifdef _WIN32
# ifdef _MSC_VER
__try
{
memcpy( buf, data, size );
Expand All @@ -3117,6 +3128,16 @@ char* Profiler::SafeCopyProlog( const char* data, size_t size )
{
success = false;
}
# else
__try1( CrashFilterExecute )
{
memcpy( buf, data, size );
}
__except1
{
success = false;
}
# endif
#else
// Send through the pipe to ensure safe reads
for( size_t offset = 0; offset != size; /*in loop*/ )
Expand Down
Loading