Merge pull request #5636 from BrzVlad/fix-xmm-scan
[mono.git] / mcs / class / Mono.Profiler.Log / Mono.Profiler.Log / LogStreamHeader.cs
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 using System;
6
7 namespace Mono.Profiler.Log {
8
9         public sealed class LogStreamHeader {
10                 
11                 const int MinVersion = 13;
12                 const int MaxVersion = 14;
13
14                 const int Id = 0x4d505a01;
15
16                 public Version Version { get; }
17
18                 public int FormatVersion { get; }
19
20                 public byte PointerSize { get; }
21
22                 public ulong StartupTime { get; }
23
24                 public int TimerOverhead { get; }
25
26                 public int Flags { get; }
27
28                 public int ProcessId { get; }
29
30                 public int Port { get; }
31
32                 public string Arguments { get; }
33
34                 public string Architecture { get; }
35
36                 public string OperatingSystem { get; }
37
38                 internal LogStreamHeader (LogReader reader)
39                 {
40                         var id = reader.ReadInt32 ();
41
42                         if (id != Id)
43                                 throw new LogException ($"Invalid stream header ID (0x{id:X}).");
44
45                         Version = new Version (reader.ReadByte (), reader.ReadByte ());
46                         FormatVersion = reader.ReadByte ();
47
48                         if (FormatVersion < MinVersion || FormatVersion > MaxVersion)
49                                 throw new LogException ($"Unsupported MLPD version {FormatVersion}. Should be >= {MinVersion} and <= {MaxVersion}.");
50                         
51                         PointerSize = reader.ReadByte ();
52                         StartupTime = reader.ReadUInt64 ();
53                         TimerOverhead = reader.ReadInt32 ();
54                         Flags = reader.ReadInt32 ();
55                         ProcessId = reader.ReadInt32 ();
56                         Port = reader.ReadUInt16 ();
57                         Arguments = reader.ReadHeaderString ();
58                         Architecture = reader.ReadHeaderString ();
59                         OperatingSystem = reader.ReadHeaderString ();
60                 }
61         }
62 }