internal CtfTraceDescriptor(CtfPropertyBag bag, ICtfStructDescriptor packetHeader) { Debug.Assert(bag != null); // According to CTF specification 1.8.2 section C.Examples."Minimal Examples", the packetHeader // isn't required if the entire trace consists of a single packet - so no null check here. // According to CTF specification 1.8.2 section C.Examples."Minimal Examples", the fields // "major", "minor", and "byte_order" are required. if (!bag.ContainsKey("major")) { throw new ArgumentException("Trace declaration does not contain 'major' field."); } if (!bag.ContainsKey("minor")) { throw new ArgumentException("Trace declaration does not contain 'major' field."); } if (!bag.ContainsKey("byte_order")) { throw new ArgumentException("Trace declaration does not contains 'byte_order' field."); } this.Major = bag.GetShort("major"); this.Minor = bag.GetShort("minor"); this.ByteOrder = bag.GetString("byte_order").Replace("\"", string.Empty); Guid id = Guid.Empty; if (bag.TryGetString("uuid", out string uuid)) { uuid = uuid.Replace("\"", string.Empty); if (!Guid.TryParse(uuid, out id)) { throw new ArgumentException($"Unable to parse the uuid value: {bag.GetString("uuid")}."); } } this.Uuid = id; this.PacketHeader = packetHeader; }
internal CtfClockDescriptor(CtfPropertyBag bag) { Debug.Assert(bag != null); this.Name = bag.GetString("name"); if (bag.ContainsKey("uuid")) { string uuid = bag.GetString("uuid").Replace("\"", string.Empty); if (!Guid.TryParse(uuid, out var id)) { throw new ArgumentException($"Unable to parse the uuid value: {bag.GetString("uuid")}."); } this.Uuid = id; } this.Description = bag.GetString("description"); // According to CTF specification 1.8.2 section 8, if the 'freq' field is not present, // it will default to 1 ns. this.Frequency = bag.ContainsKey("freq") ? bag.GetUlong("freq") : (ulong)1000000000; if (bag.ContainsKey("offset")) { this.Offset = bag.GetUlong("offset"); } else if (bag.ContainsKey("offset_s")) { // todo:this might not be the best approach from an overflow perspective. // leaving for now until we have reason to change it ulong offsetInSeconds = bag.GetUlong("offset_s"); this.Offset = offsetInSeconds * this.Frequency; } if (bag.ContainsKey("precision")) { this.Precision = bag.GetUlong("precision"); } if (bag.ContainsKey("absolute")) { this.Absolute = bag.GetBoolean("absolute"); } }