Skip to content

Commit f2d50cc

Browse files
committed
Fix sampler
1 parent 6128140 commit f2d50cc

5 files changed

+12
-7
lines changed

src/Ultra.Sampler/MacOS/MacOSUltraSampler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ private static unsafe void Sample(MacOS.MacOSLibSystem.mach_port_t rootTask, ulo
293293

294294
//Console.WriteLine($"sp: 0x{armThreadState.__sp:X8}, fp: 0x{armThreadState.__fp:X8}, lr: 0x{armThreadState.__lr:X8}");
295295
int frameCount = WalkNativeCallStack(armThreadState.__sp, armThreadState.__fp, armThreadState.__lr, pFrames);
296-
nativeCallstack(threadInfo.thread_id, frameCount, (ulong)pFrames);
296+
nativeCallstack(threadInfo.thread_id, frameCount, (byte*)pFrames);
297297
}
298298
finally
299299
{

src/Ultra.Sampler/MacOS/NativeCallstackDelegate.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
namespace Ultra.Sampler.MacOS;
66

7-
internal unsafe delegate void NativeCallstackDelegate(ulong threadId, int frameCount, ulong pFrames);
7+
internal unsafe delegate void NativeCallstackDelegate(ulong threadId, int frameCount, byte* pFrames);

src/Ultra.Sampler/UltraSamplerSource.cs

+10-5
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ private UltraSamplerSource()
2020

2121
[Event(UltraSamplerConstants.NativeCallStackEventId, Level = EventLevel.Informational)]
2222
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
23-
public unsafe void OnNativeCallstack(ulong threadId, int frameCount, ulong frames) // frames is last to allow perfview to visualize previous fixed size arguments and also, it is an ulong otherwise the EventSource will silently fail to register!
23+
public unsafe void OnNativeCallstack(ulong threadId, int frameCount, byte* frames) // frames is last to allow perfview to visualize previous fixed size arguments and also, it is an ulong otherwise the EventSource will silently fail to register!
2424
{
2525
var evt = stackalloc EventData[3];
2626
evt[0].DataPointer = (nint)(void*)&threadId;
2727
evt[0].Size = sizeof(ulong);
28-
evt[1].DataPointer = (int) &frameCount;
28+
evt[1].DataPointer = (nint)(void*)&frameCount;
2929
evt[1].Size = sizeof(int);
30-
evt[2].DataPointer = (nint)frames;
30+
evt[2].DataPointer = (nint)(void*)&frames;
3131
evt[2].Size = frameCount * sizeof(ulong);
3232
WriteEventCore(UltraSamplerConstants.NativeCallStackEventId, 3, evt);
3333
}
@@ -56,8 +56,13 @@ private UltraSamplerSource()
5656
evt[5].DataPointer = (nint)evtPathPtr;
5757
evt[5].Size = modulePathUtf8Length;
5858
}
59-
60-
WriteEventCore(UltraSamplerConstants.NativeModuleEventId, modulePathUtf8Length > 0 ? 6 : 5, evt);
59+
else
60+
{
61+
evt[5].DataPointer = (nint)(void*)&loadAddress;
62+
evt[5].Size = 0;
63+
}
64+
65+
WriteEventCore(UltraSamplerConstants.NativeModuleEventId, 6, evt);
6166
}
6267
}
6368

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)