diff --git a/src/Ultra.Sampler/MacOS/MacOSUltraSampler.cs b/src/Ultra.Sampler/MacOS/MacOSUltraSampler.cs index f586efc..074e163 100644 --- a/src/Ultra.Sampler/MacOS/MacOSUltraSampler.cs +++ b/src/Ultra.Sampler/MacOS/MacOSUltraSampler.cs @@ -75,15 +75,6 @@ protected override void EnableImpl() { _nextModuleEventIndexToLog = 0; _captureEnabled = true; - // Make sure to always send the manifest before resuming the capture thread - try - { - EventSource.SendCommand(UltraSamplerSource.Log, EventCommand.SendManifest, null); - } - catch - { - // Ignore - } _resumeCaptureThread.Set(); } @@ -103,10 +94,18 @@ private unsafe void RunImpl() MacOS.MacOSLibSystem.pthread_threadid_np(0, out var currentThreadId) .ThrowIfError("pthread_threadid_np"); + bool sendManifest = true; + while (!_stopped) { if (_captureEnabled) { + if (sendManifest) + { + SendManifest(); + sendManifest = false; + } + // Load all pending native module events before sampling NotifyPendingNativeModuleEvents(); @@ -119,6 +118,7 @@ private unsafe void RunImpl() else { _resumeCaptureThread.WaitOne(); + sendManifest = true; } } } @@ -128,6 +128,19 @@ private unsafe void RunImpl() } } + private static void SendManifest() + { + // Make sure to always send the manifest before resuming the capture thread + try + { + EventSource.SendCommand(UltraSamplerSource.Log, EventCommand.SendManifest, null); + } + catch + { + // Ignore + } + } + private void CallbackDyldAdded(MacOSLibSystem.mach_header* header, nint slideVmAddr) { AddModuleEvent(_initializingModules ? NativeModuleEventKind.AlreadyLoaded : NativeModuleEventKind.Loaded, (nint)header); @@ -245,7 +258,7 @@ private static ulong GetDyldCodeSize(nint headerPtr) } } } - + return size; } diff --git a/src/Ultra.Sampler/libUltraSampler.dylib b/src/Ultra.Sampler/libUltraSampler.dylib index 1e6e63a..09f626f 100644 Binary files a/src/Ultra.Sampler/libUltraSampler.dylib and b/src/Ultra.Sampler/libUltraSampler.dylib differ