2
2
// Licensed under the BSD-Clause 2 license.
3
3
// See license.txt file in the project root for full license information.
4
4
5
+ using Microsoft . Diagnostics . Tracing ;
6
+ using Microsoft . Diagnostics . Tracing . StackSources ;
5
7
using Ultra . Core ;
8
+ using Ultra . Core . Model ;
6
9
using Ultra . Sampler ;
7
10
using Ultra . Sampler . MacOS ;
8
11
@@ -32,4 +35,99 @@ public void TestEventSource()
32
35
Assert . AreEqual ( UltraSamplerConstants . ProviderName , sampler . Name ) ;
33
36
Assert . AreEqual ( UltraSamplerConstants . ProviderGuid , sampler . Guid ) ;
34
37
}
38
+
39
+ [ TestMethod ]
40
+ public void TestProcessor ( )
41
+ {
42
+ return ; // Disabled
43
+
44
+ using var samplerEventSource = new EventPipeEventSource ( @"C:\code\Captures\ultra_Ultra_2024-12-22_15_00_14_2860_sampler.nettrace" ) ;
45
+ using var clrEventSource = new EventPipeEventSource ( @"C:\code\Captures\ultra_Ultra_2024-12-22_15_00_14_2860_clr.nettrace" ) ;
46
+
47
+ var processor = new UltraEventPipeProcessor ( samplerEventSource , clrEventSource ) ;
48
+
49
+ var session = processor . Run ( ) ;
50
+
51
+ Console . WriteLine ( "----------------------------------------------------------------------------------------" ) ;
52
+ Console . WriteLine ( "Modules" ) ;
53
+ Console . WriteLine ( "----------------------------------------------------------------------------------------" ) ;
54
+
55
+ var process = session . Processes [ 0 ] ;
56
+ foreach ( var traceModule in process . Modules . Items )
57
+ {
58
+ Console . WriteLine ( traceModule ) ;
59
+ }
60
+
61
+ Console . WriteLine ( $ "CodeAddresses: { process . CodeAddresses . Items . Length } items") ;
62
+ Console . WriteLine ( $ "CallStacks: { process . CallStacks . Items . Length } items") ;
63
+
64
+ Console . WriteLine ( "----------------------------------------------------------------------------------------" ) ;
65
+ Console . WriteLine ( $ "Threads { process . Threads . Items . Length } items") ;
66
+ Console . WriteLine ( "----------------------------------------------------------------------------------------" ) ;
67
+
68
+ foreach ( var thread in process . Threads . Items )
69
+ {
70
+ Console . WriteLine ( thread ) ;
71
+ }
72
+
73
+ //return;
74
+
75
+ var modules = process . Modules ;
76
+ var managedMethods = process . ManagedMethods ;
77
+
78
+ foreach ( var thread in process . Threads )
79
+ {
80
+ Console . WriteLine ( thread ) ;
81
+
82
+
83
+ foreach ( var callstack in thread . Samples )
84
+ {
85
+ Console . WriteLine ( $ " CallStack: { callstack } ") ;
86
+
87
+ UCallStackIndex parentIndex = callstack . CallStackIndex ;
88
+ while ( true )
89
+ {
90
+ var frameInfo = process . CallStacks [ parentIndex ] ;
91
+ parentIndex = frameInfo . ParentCallStackIndex ;
92
+ if ( parentIndex == UCallStackIndex . Invalid )
93
+ {
94
+ break ;
95
+ }
96
+
97
+ var frame = process . CodeAddresses [ frameInfo . CodeAddressIndex ] ;
98
+ if ( modules . TryFindNativeModuleByAddress ( frame , out var module ) )
99
+ {
100
+ Console . WriteLine ( $ " { module . ModuleFile . FilePath } +{ frame - module . BaseAddress } (Module: { module . BaseAddress } Address: { frame } )") ;
101
+ }
102
+ else
103
+ {
104
+ if ( managedMethods . TryFindMethodByAddress ( frame , out var method ) )
105
+ {
106
+ Console . WriteLine ( $ " { method . MethodNamespace } .{ method . MethodName } +{ frame - method . MethodStartAddress } (Method: { method . MethodStartAddress } Address: { frame } )") ;
107
+ }
108
+ else
109
+ {
110
+ Console . WriteLine ( $ " { frame } ") ;
111
+ }
112
+ }
113
+ //Console.WriteLine($" {addressIndex}");
114
+ }
115
+ }
116
+ }
117
+
118
+ //EventPipeEventSource
119
+ //TraceLog.CreateFromEventPipeDataFile(@"C:\code\Captures\ultra_Ultra_2024-12-17_08_13_37_34101_sampler.nettrace");
120
+ //TraceLog.CreateFromEventPipeDataFile(@"C:\code\Captures\ultra_Ultra_2024-12-17_08_13_37_34101_clr.nettrace");
121
+
122
+
123
+
124
+ //TraceEventSession.Merge([@"C:\code\Captures\ultra_Ultra_2024-12-17_08_13_37_34101_sampler.nettrace.etlx", @"C:\code\Captures\ultra_Ultra_2024-12-17_08_13_37_34101_sampler.nettrace.etlx"], @"C:\code\Captures\test.etlx");
125
+ //TraceLog.M
126
+
127
+ //UAddress x = (UAddress)0x15;
128
+
129
+ //Console.WriteLine(x);
130
+
131
+
132
+ }
35
133
}
0 commit comments