3
3
4
4
import { SessionId } from "./common" ;
5
5
6
+ export const advert1 = [ 65 , 68 , 86 , 82 , 95 ] ;
7
+ export const dotnet_IPC_V1 = [ 68 , 79 , 84 , 78 , 69 , 84 , 95 , 73 , 80 , 67 , 95 , 86 , 49 , 0 ] ;
8
+
6
9
7
10
// this file contains the IPC commands that are sent by client (like dotnet-trace) to the diagnostic server (like Mono VM in the browser)
8
- // just formatting bytes, no sessions here
11
+ // just formatting bytes, no sessions management here
9
12
10
13
export function commandStopTracing ( sessionID :SessionId ) {
11
14
return Uint8Array . from ( [
@@ -14,16 +17,26 @@ export function commandStopTracing (sessionID:SessionId) {
14
17
] ) ;
15
18
}
16
19
17
- export function createGcHeapDumpCommand ( ) {
20
+ export function commandResumeRuntime ( ) {
21
+ return Uint8Array . from ( [
22
+ ...serializeHeader ( CommandSetId . Process , ProcessCommandId . ResumeRuntime , computeMessageByteLength ( 0 ) ) ,
23
+ ] ) ;
24
+ }
25
+
26
+ export function commandGcHeapDump ( ) {
18
27
return commandCollectTracing2 ( {
19
- circularBufferMB : 256 * 1024 * 1024 ,
28
+ circularBufferMB : 256 ,
20
29
format : 1 ,
21
30
requestRundown : true ,
22
31
providers : [
23
32
{
24
33
keywords : [
25
34
0x0000_0000 ,
26
- Keywords . GCHeapSnapshot ,
35
+ Keywords . GCHeapSnapshot , // 0x1980001
36
+ // GC_HEAP_DUMP_VTABLE_CLASS_REF_KEYWORD 0x8000000
37
+ // GC_FINALIZATION_KEYWORD 0x1000000
38
+ // GC_HEAP_COLLECT_KEYWORD 0x0800000
39
+ // GC_KEYWORD 0x0000001
27
40
] ,
28
41
logLevel : 5 ,
29
42
provider_name : "Microsoft-Windows-DotNETRuntime" ,
@@ -33,15 +46,23 @@ export function createGcHeapDumpCommand () {
33
46
} ) ;
34
47
}
35
48
36
- const enum CommandSetId {
37
- Reserved = 0 ,
38
- Dump = 1 ,
39
- EventPipe = 2 ,
40
- Profiler = 3 ,
41
- Process = 4 ,
42
-
43
- // replies
44
- Server = 0xFF ,
49
+ function commandCollectTracing2 ( payload2 :PayloadV2 ) {
50
+ const payloadLength = computeCollectTracing2PayloadByteLength ( payload2 ) ;
51
+ const messageLength = computeMessageByteLength ( payloadLength ) ;
52
+ const message = [
53
+ ...serializeHeader ( CommandSetId . EventPipe , EventPipeCommandId . CollectTracing2 , messageLength ) ,
54
+ ...serializeUint32 ( payload2 . circularBufferMB ) ,
55
+ ...serializeUint32 ( payload2 . format ) ,
56
+ ...serializeUint8 ( payload2 . requestRundown ? 1 : 0 ) ,
57
+ ...serializeUint32 ( payload2 . providers . length ) ,
58
+ ] ;
59
+ for ( const provider of payload2 . providers ) {
60
+ message . push ( ...serializeUint64 ( provider . keywords ) ) ;
61
+ message . push ( ...serializeUint32 ( provider . logLevel ) ) ;
62
+ message . push ( ...serializeString ( provider . provider_name ) ) ;
63
+ message . push ( ...serializeString ( provider . filter_data ) ) ;
64
+ }
65
+ return Uint8Array . from ( message ) ;
45
66
}
46
67
47
68
const enum Keywords {
@@ -225,6 +246,17 @@ const enum Keywords {
225
246
GCHeapSnapshot = 0x1980001
226
247
}
227
248
249
+ export const enum CommandSetId {
250
+ Reserved = 0 ,
251
+ Dump = 1 ,
252
+ EventPipe = 2 ,
253
+ Profiler = 3 ,
254
+ Process = 4 ,
255
+
256
+ // replies
257
+ Server = 0xFF ,
258
+ }
259
+
228
260
const enum EventPipeCommandId {
229
261
StopTracing = 1 ,
230
262
CollectTracing = 2 ,
@@ -238,13 +270,13 @@ const enum ProcessCommandId {
238
270
ProcessInfo2 = 4 ,
239
271
}
240
272
241
- const enum ServerCommandId {
273
+ export const enum ServerCommandId {
242
274
OK = 0 ,
243
275
Error = 0xFF ,
244
276
}
245
277
246
278
function serializeMagic ( ) {
247
- return Uint8Array . from ( "DOTNET_IPC_V1\0" , ( c ) => c . codePointAt ( 0 ) ?? 0 ) ;
279
+ return Uint8Array . from ( dotnet_IPC_V1 ) ;
248
280
}
249
281
250
282
function serializeUint8 ( value :number ) {
@@ -321,33 +353,14 @@ function computeCollectTracing2PayloadByteLength (payload2:PayloadV2) {
321
353
return len ;
322
354
}
323
355
324
- export function commandCollectTracing2 ( payload2 :PayloadV2 ) {
325
- const payloadLength = computeCollectTracing2PayloadByteLength ( payload2 ) ;
326
- const messageLength = computeMessageByteLength ( payloadLength ) ;
327
- const message = [
328
- ...serializeHeader ( CommandSetId . EventPipe , EventPipeCommandId . CollectTracing2 , messageLength ) ,
329
- ...serializeUint32 ( payload2 . circularBufferMB ) ,
330
- ...serializeUint32 ( payload2 . format ) ,
331
- ...serializeUint8 ( payload2 . requestRundown ? 1 : 0 ) ,
332
- ...serializeUint32 ( payload2 . providers . length ) ,
333
- ] ;
334
- for ( const provider of payload2 . providers ) {
335
- message . push ( ...serializeUint64 ( provider . keywords ) ) ;
336
- message . push ( ...serializeUint32 ( provider . logLevel ) ) ;
337
- message . push ( ...serializeString ( provider . provider_name ) ) ;
338
- message . push ( ...serializeString ( provider . filter_data ) ) ;
339
- }
340
- return Uint8Array . from ( message ) ;
341
- }
342
-
343
- export type ProviderV2 = {
356
+ type ProviderV2 = {
344
357
keywords : [ 0 , Keywords , ] ,
345
358
logLevel : number ,
346
359
provider_name : string ,
347
360
filter_data : string | null
348
361
}
349
362
350
- export type PayloadV2 = {
363
+ type PayloadV2 = {
351
364
circularBufferMB : number ,
352
365
format : number ,
353
366
requestRundown : boolean ,
0 commit comments