Skip to content

Commit

Permalink
Fix pinning of frames
Browse files Browse the repository at this point in the history
  • Loading branch information
xoofx committed Dec 15, 2024
1 parent 151eef6 commit 72791be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Ultra.Core/Parser/UltraSamplerParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public sealed class UltraNativeCallstackTraceEvent : TraceEvent
private static readonly string[] _payloadNames =
[
nameof(FrameThreadId),
nameof(FrameCount),
nameof(FrameSize),
nameof(FrameAddresses)
];

Expand All @@ -80,9 +80,9 @@ internal UltraNativeCallstackTraceEvent(Action<UltraNativeCallstackTraceEvent>?

public ulong FrameThreadId => (ulong)GetInt64At(0);

public int FrameCount => GetInt32At(8);
public int FrameSize => GetInt32At(8);

public unsafe ReadOnlySpan<ulong> FrameAddresses => new((byte*)DataStart + 12, FrameCount);
public unsafe ReadOnlySpan<ulong> FrameAddresses => new((byte*)DataStart + 12, FrameSize / sizeof(ulong));

/// <inheritdoc />

Expand All @@ -93,7 +93,7 @@ public override object PayloadValue(int index)
case 0:
return FrameThreadId;
case 1:
return FrameCount;
return FrameSize;
case 2:
return FrameAddresses.ToArray();
default:
Expand Down
3 changes: 2 additions & 1 deletion src/Ultra.Sampler/MacOS/MacOSUltraSampler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal unsafe class MacOSUltraSampler : UltraSampler
private readonly AutoResetEvent _resumeCaptureThread;

private const int MaximumFrames = 4096;
private readonly ulong[] _frames = new ulong[MaximumFrames];
private readonly ulong[] _frames;

private const int DefaultImageCount = 1024;
private UnsafeList<NativeModuleEvent> _moduleEvents = new(DefaultImageCount);
Expand All @@ -33,6 +33,7 @@ internal unsafe class MacOSUltraSampler : UltraSampler

public MacOSUltraSampler()
{
_frames = GC.AllocateArray<ulong>(4096, true);
_resumeCaptureThread = new AutoResetEvent(false);

_callbackDyldAdded = new MacOSLibSystem.dyld_register_callback(CallbackDyldAdded);
Expand Down

0 comments on commit 72791be

Please sign in to comment.