From d1b040680160cde679469ccad655baaaeea717d9 Mon Sep 17 00:00:00 2001 From: "Trevor L. McDonell" Date: Tue, 15 Oct 2024 16:38:23 +0200 Subject: [PATCH] Add option to ignore memory free faults This replaces the IsApple flag, which was previously only used for this purpose. --- CMakeLists.txt | 1 + meson.build | 4 ++++ meson.options | 3 ++- public/client/TracyProfiler.cpp | 4 ++-- public/common/TracyProtocol.hpp | 2 +- server/TracyWorker.cpp | 2 +- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f82a665..1ebe5748 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,7 @@ set_option(TRACY_LIBUNWIND_BACKTRACE "Use libunwind backtracing where supported" set_option(TRACY_SYMBOL_OFFLINE_RESOLVE "Instead of full runtime symbol resolution, only resolve the image path and offset to enable offline symbol resolution" OFF) set_option(TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT "Enable libbacktrace to support dynamically loaded elfs in symbol resolution resolution after the first symbol resolve operation" OFF) set_option(TRACY_DEBUGINFOD "Enable debuginfod support" OFF) +set_option(TRACY_IGNORE_MEMORY_FAULTS "Ignore instrumentation errors from memory free events that do not have a matching allocation" OFF) # advanced set_option(TRACY_VERBOSE "[advanced] Verbose output from the profiler" OFF) diff --git a/meson.build b/meson.build index e3ba71b9..96fbb9e1 100644 --- a/meson.build +++ b/meson.build @@ -119,6 +119,10 @@ if get_option('debuginfod') tracy_public_deps += dependency('libdebuginfod') endif +if get_option('ignore_memory_faults') + tracy_common_args += ['-DTRACY_IGNORE_MEMORY_FAULTS'] +endif + tracy_shared_libs = get_option('default_library') == 'shared' if tracy_shared_libs diff --git a/meson.options b/meson.options index 4355aed9..6527c917 100644 --- a/meson.options +++ b/meson.options @@ -24,4 +24,5 @@ option('manual_lifetime', type : 'boolean', value : false, description : 'Enable option('fibers', type : 'boolean', value : false, description : 'Enable fibers support') option('no_crash_handler', type : 'boolean', value : false, description : 'Disable crash handling') option('verbose', type : 'boolean', value : false, description : 'Enable verbose logging') -option('debuginfod', type : 'boolean', value : false, description : 'Enable debuginfod support') \ No newline at end of file +option('debuginfod', type : 'boolean', value : false, description : 'Enable debuginfod support') +option('ignore_memory_faults', type : 'boolean', value : false, description : 'Ignore instrumentation errors from memory free events that do not have a matching allocation') diff --git a/public/client/TracyProfiler.cpp b/public/client/TracyProfiler.cpp index 34caedf0..762fd9a7 100644 --- a/public/client/TracyProfiler.cpp +++ b/public/client/TracyProfiler.cpp @@ -1765,8 +1765,8 @@ void Profiler::Worker() #ifdef TRACY_ON_DEMAND flags |= WelcomeFlag::OnDemand; #endif -#ifdef __APPLE__ - flags |= WelcomeFlag::IsApple; +#if defined TRACY_IGNORE_MEMORY_FAULTS || defined __APPLE__ + flags |= WelcomeFlag::IgnoreMemFaults; #endif #ifndef TRACY_NO_CODE_TRANSFER flags |= WelcomeFlag::CodeTransfer; diff --git a/public/common/TracyProtocol.hpp b/public/common/TracyProtocol.hpp index ff38686f..8174d932 100644 --- a/public/common/TracyProtocol.hpp +++ b/public/common/TracyProtocol.hpp @@ -83,7 +83,7 @@ struct WelcomeFlag enum _t : uint8_t { OnDemand = 1 << 0, - IsApple = 1 << 1, + IgnoreMemFaults = 1 << 1, CodeTransfer = 1 << 2, CombineSamples = 1 << 3, IdentifySamples = 1 << 4, diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index b1dffe1a..d94a1ab5 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -2792,7 +2792,7 @@ void Worker::Exec() m_captureProgram = welcome.programName; m_captureTime = welcome.epoch; m_executableTime = welcome.exectime; - m_ignoreMemFreeFaults = ( welcome.flags & WelcomeFlag::OnDemand ) || ( welcome.flags & WelcomeFlag::IsApple ); + m_ignoreMemFreeFaults = ( welcome.flags & WelcomeFlag::OnDemand ) || ( welcome.flags & WelcomeFlag::IgnoreMemFaults ); m_ignoreFrameEndFaults = welcome.flags & WelcomeFlag::OnDemand; m_data.cpuArch = (CpuArchitecture)welcome.cpuArch; m_codeTransfer = welcome.flags & WelcomeFlag::CodeTransfer;