Skip to content

Commit facb393

Browse files
committed
Fix event layout for decoding in perfview
1 parent 69b76b3 commit facb393

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/Ultra.Sampler/MacOS/MacOSUltraSampler.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private void NotifyPendingNativeModuleEvents()
170170
for(; _nextModuleEventIndexToLog < events.Length; _nextModuleEventIndexToLog++)
171171
{
172172
var evt = events[_nextModuleEventIndexToLog];
173-
UltraSamplerSource.Log.OnNativeModuleEvent(evt.Kind, evt.LoadAddress, evt.Size, evt.Path, evt.TimestampUtc.Ticks);
173+
UltraSamplerSource.Log.OnNativeModuleEvent((int)evt.Kind, evt.LoadAddress, evt.Size, evt.Path, evt.TimestampUtc);
174174
}
175175
}
176176
}
@@ -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, (nint)pFrames, frameCount);
296+
nativeCallstack(threadInfo.thread_id, (ulong)pFrames, frameCount);
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, nint pFrames, int frameCount);
7+
internal unsafe delegate void NativeCallstackDelegate(ulong threadId, ulong pFrames, int frameCount);

src/Ultra.Sampler/UltraSamplerSource.cs

+12-9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
using System.Diagnostics.CodeAnalysis;
66
using System.Diagnostics.Tracing;
7-
using System.Runtime.CompilerServices;
8-
using Ultra.Sampler.MacOS;
97

108
namespace Ultra.Sampler;
119

@@ -20,19 +18,21 @@ private UltraSamplerSource()
2018

2119
[Event(UltraSamplerParser.NativeCallStackEvent, Level = EventLevel.Informational)]
2220
[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, nint pFrames, int count)
21+
public unsafe void OnNativeCallstack(ulong threadId, ulong pFrames, int count)
2422
{
25-
EventData2 evt = default;
23+
EventData3 evt = default;
2624
evt.Data1.DataPointer = (nint)(void*)&threadId;
2725
evt.Data1.Size = sizeof(ulong);
2826
evt.Data2.DataPointer = (nint)pFrames;
2927
evt.Data2.Size = count * sizeof(ulong);
30-
WriteEventCore(UltraSamplerParser.NativeCallStackEvent, 2, &evt.Data1);
28+
evt.Data3.DataPointer = (int) &count;
29+
evt.Data3.Size = sizeof(int);
30+
WriteEventCore(UltraSamplerParser.NativeCallStackEvent, 3, &evt.Data1);
3131
}
3232

3333
[Event(UltraSamplerParser.NativeModuleEvent, Level = EventLevel.Informational)]
3434
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
35-
public unsafe void OnNativeModuleEvent(NativeModuleEventKind nativeModuleEventKind, ulong loadAddress, ulong size, byte[]? modulePathUtf8, long timestampUtc)
35+
public unsafe void OnNativeModuleEvent(int nativeModuleEventKind, ulong loadAddress, ulong size, byte[]? modulePathUtf8, DateTime timestampUtc)
3636
{
3737
EventData5 evt = default;
3838
evt.Data1.DataPointer = (nint)(void*)&nativeModuleEventKind;
@@ -45,9 +45,10 @@ public unsafe void OnNativeModuleEvent(NativeModuleEventKind nativeModuleEventKi
4545
{
4646
evt.Data4.DataPointer = (nint)evtPathPtr;
4747
evt.Data4.Size = modulePathUtf8?.Length ?? 0;
48-
evt.Data5.DataPointer = (nint)(void*)&timestampUtc;
48+
var utcFileTime = timestampUtc.ToFileTimeUtc();
49+
evt.Data5.DataPointer = (nint)(void*)&utcFileTime;
4950
evt.Data5.Size = sizeof(long);
50-
WriteEventCore(UltraSamplerParser.NativeModuleEvent, 4, &evt.Data1);
51+
WriteEventCore(UltraSamplerParser.NativeModuleEvent, 5, &evt.Data1);
5152
}
5253
}
5354

@@ -67,11 +68,13 @@ protected override void OnEventCommand(EventCommandEventArgs command)
6768
}
6869
}
6970

70-
private struct EventData2
71+
private struct EventData3
7172
{
7273
public EventData Data1;
7374

7475
public EventData Data2;
76+
77+
public EventData Data3;
7578
}
7679

7780
private struct EventData5

0 commit comments

Comments
 (0)