Add flag to disable crash handler

This commit is contained in:
Blake Taylor 2022-04-26 21:19:56 -07:00
parent afd4cdec63
commit 8c5120ee5a
5 changed files with 13 additions and 5 deletions

View File

@ -53,6 +53,7 @@ set_option(TRACY_NO_SYS_TRACE "Disable systrace sampling" OFF)
set_option(TRACY_DELAYED_INIT "Enable delayed initialization of the library (init on first call)" OFF)
set_option(TRACY_MANUAL_LIFETIME "Enable the manual lifetime management of the profile" OFF)
set_option(TRACY_FIBERS "Enable fibers support" OFF)
set_option(TRACY_NO_CRASH_HANDLER, "Disable crash handling" OFF)
if(BUILD_SHARED_LIBS)
target_compile_definitions(TracyClient PRIVATE TRACY_EXPORTS)

View File

@ -738,7 +738,7 @@ static BroadcastMessage& GetBroadcastMessage( const char* procname, size_t pnsz,
return msg;
}
#if defined _WIN32 && !defined TRACY_UWP
#if defined _WIN32 && !defined TRACY_UWP && !defined TRACY_NO_CRASH_HANDLER
static DWORD s_profilerThreadId = 0;
static char s_crashText[1024];
@ -847,7 +847,7 @@ LONG WINAPI CrashFilter( PEXCEPTION_POINTERS pExp )
}
#endif
#ifdef __linux__
#ifdef __linux__ && !defined TRACY_NO_CRASH_HANDLER
# ifndef TRACY_CRASH_SIGNAL
# define TRACY_CRASH_SIGNAL SIGPWR
# endif
@ -1416,12 +1416,12 @@ void Profiler::SpawnWorkerThreads()
new(s_symbolThread) Thread( LaunchSymbolWorker, this );
#endif
#if defined _WIN32 && !defined TRACY_UWP
#if defined _WIN32 && !defined TRACY_UWP && !defined TRACY_NO_CRASH_HANDLER
s_profilerThreadId = GetThreadId( s_thread->Handle() );
m_exceptionHandler = AddVectoredExceptionHandler( 1, CrashFilter );
#endif
#ifdef __linux__
#if defined __linux__ && !defined TRACY_NO_CRASH_HANDLER
struct sigaction threadFreezer = {};
threadFreezer.sa_handler = ThreadFreezer;
sigaction( TRACY_CRASH_SIGNAL, &threadFreezer, &m_prevSignal.pwr );
@ -1437,7 +1437,9 @@ void Profiler::SpawnWorkerThreads()
sigaction( SIGABRT, &crashHandler, &m_prevSignal.abrt );
#endif
#ifndef TRACY_NO_CRASH_HANDLER
m_crashHandlerInstalled = true;
#endif
#ifdef TRACY_HAS_CALLSTACK
InitCallstack();

View File

@ -803,7 +803,7 @@ Tracy will try to capture thread names through operating system data if context
On selected platforms (see section~\ref{featurematrix}) Tracy will intercept application crashes\footnote{For example, invalid memory accesses ('segmentation faults', 'null pointer exceptions'), divisions by zero, etc.}. This serves two purposes. First, the client application will be able to send the remaining profiling data to the server. Second, the server will receive a crash report with the crash reason, call stack at the time of the crash, etc.
This is an automatic process, and it doesn't require user interaction.
This is an automatic process, and it doesn't require user interaction. If you are experiencing issues with crash handling you may want to try defining the \texttt{TRACY\_NO\_CRASH\_HANDLER} macro to disable the built in crash handling.
\begin{bclogo}[
noborder=true,

View File

@ -81,6 +81,10 @@ if tracy_shared_libs
add_project_arguments('-DTRACY_EXPORTS', language : 'cpp')
endif
if get_option('tracy_no_crash_handler')
add_project_arguments('-DTRACY_NO_CRASH_HANDLER', language : 'cpp')
endif
threads_dep = dependency('threads')
includes = [

View File

@ -18,3 +18,4 @@ option('tracy_delayed_init', type : 'boolean', value : false, description : 'Ena
option('tracy_manual_lifetime', type : 'boolean', value : false, description : 'Enable the manual lifetime management of the profile')
option('tracy_fibers', type : 'boolean', value : false, description : 'Enable fibers support')
option('tracy_shared_libs', type : 'boolean', value : false, description : 'Builds Tracy as a shared object')
option('tracy_no_crash_handler', type : 'boolean', value : false, description : 'Disable crash handling')