From 7100bf4ea5db29e56e7a23008abeb4398ed78e5b Mon Sep 17 00:00:00 2001 From: Alexandre Mutel Date: Mon, 16 Dec 2024 18:54:27 +0100 Subject: [PATCH] Add parser support for compressed frames --- src/Ultra.Core/Parser/UltraSamplerParser.cs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Ultra.Core/Parser/UltraSamplerParser.cs b/src/Ultra.Core/Parser/UltraSamplerParser.cs index 1851b4c..54fafe6 100644 --- a/src/Ultra.Core/Parser/UltraSamplerParser.cs +++ b/src/Ultra.Core/Parser/UltraSamplerParser.cs @@ -68,6 +68,9 @@ public sealed class UltraNativeCallstackTraceEvent : TraceEvent private static readonly string[] _payloadNames = [ nameof(FrameThreadId), + nameof(ThreadState), + nameof(ThreadCpuUsage), + nameof(PreviousFrameCount), nameof(FrameSize), nameof(FrameAddresses) ]; @@ -81,9 +84,15 @@ internal UltraNativeCallstackTraceEvent(Action? public ulong FrameThreadId => (ulong)GetInt64At(0); - public int FrameSize => GetInt32At(8); + public UltraSamplerThreadState ThreadState => (UltraSamplerThreadState)GetInt32At(8); - public unsafe ReadOnlySpan FrameAddresses => new((byte*)DataStart + 12, FrameSize / sizeof(ulong)); + public double ThreadCpuUsage => GetInt32At(12) / 1000.0; + + public int PreviousFrameCount => GetInt32At(16); + + public int FrameSize => GetInt32At(20); + + public unsafe ReadOnlySpan FrameAddresses => new((byte*)DataStart + 24, FrameSize / sizeof(ulong)); /// @@ -94,8 +103,14 @@ public override object PayloadValue(int index) case 0: return FrameThreadId; case 1: - return FrameSize; + return (int)ThreadState; case 2: + return GetInt32At(12); + case 3: + return PreviousFrameCount; + case 4: + return FrameSize; + case 5: return FrameAddresses.ToArray(); default: throw new ArgumentOutOfRangeException(nameof(index));