Пример #1
0
        internal void AddOstTraces(CIContainer aContainer)
        {
            CITraceData traceData = aContainer.Traces;

            //
            if (traceData != null && traceData.Lines.Length > 0)
            {
                foreach (CITrace ciTrace in traceData)
                {
                    System.Text.StringBuilder line = new System.Text.StringBuilder();

                    TraceLine trace = ciTrace;

                    // Type
                    string type = string.Empty;
                    switch (trace.Type)
                    {
                    case TraceLine.TType.ETypeBinary:
                        type = "Bin";
                        break;

                    case TraceLine.TType.ETypeRaw:
                        type = "Raw";
                        break;

                    case TraceLine.TType.ETypeText:
                        type = "Text";
                        break;

                    default:
                        type = "Unknown";
                        break;
                    }
                    if (string.IsNullOrEmpty(type) == false)
                    {
                        line.Append(type);
                    }

                    // Context id
                    if (trace.ContextId != 0)
                    {
                        line.Append(" " + "0x" + trace.ContextId.ToString("x8"));
                    }

                    // Time stamp
                    line.Append(" " + trace.TimeStamp.ToString());

                    // Prefix
                    string prefix = trace.Prefix;
                    if (string.IsNullOrEmpty(prefix) == false)
                    {
                        line.Append(" " + prefix);
                    }

                    // Suffix
                    string suffix = trace.Suffix;
                    if (string.IsNullOrEmpty(suffix) == false)
                    {
                        line.Append(" " + suffix);
                    }

                    if (trace.HasIdentifier)
                    {
                        // Component/group/id triplet
                        TraceIdentifier identifier = trace.Identifier;
                        line.Append(" C:" + "0x" + identifier.Component.ToString("x8"));
                        line.Append(" G:" + identifier.Group.ToString());
                        line.Append(" I:" + identifier.Id.ToString());
                        // File & line
                        TraceLocation location = identifier.Location;
                        //
                        string file       = location.File;
                        string lineNumber = location.Line.ToString();
                        //
                        if (string.IsNullOrEmpty(file) == false && string.IsNullOrEmpty(lineNumber) == false)
                        {
                            line.Append(" " + file);
                            line.Append(":" + lineNumber);
                        }
                    }

                    // Payload
                    string payload = trace.Payload;
                    line.Append(" " + payload);
                    iOstTraces.Add(line.ToString());
                }
            }
        }
Пример #2
0
        protected override void XmlSerializeChildren(CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters)
        {
            System.Diagnostics.Debug.Assert(iTraceData != null);
            foreach (CITrace ciTrace in iTraceData)
            {
                aParameters.Writer.WriteStartElement(SegConstants.Traces_Line);
                //
                TraceLine trace = ciTrace;

                // Type
                string type = string.Empty;
                switch (trace.Type)
                {
                case TraceLine.TType.ETypeBinary:
                    type = SegConstants.Traces_Type_Binary;
                    break;

                case TraceLine.TType.ETypeRaw:
                    type = SegConstants.Traces_Type_Raw;
                    break;

                case TraceLine.TType.ETypeText:
                    type = SegConstants.Traces_Type_Text;
                    break;

                default:
                    type = SegConstants.Traces_Type_Unknown;
                    break;
                }
                if (string.IsNullOrEmpty(type) == false)
                {
                    aParameters.Writer.WriteAttributeString(SegConstants.CmnType, type);
                }

                // Context id
                if (trace.ContextId != 0)
                {
                    aParameters.Writer.WriteAttributeString(SegConstants.Traces_ContextId, "0x" + trace.ContextId.ToString("x8"));
                }

                // Time stamp
                aParameters.Writer.WriteAttributeString(SegConstants.Traces_TimeStamp, trace.TimeStamp.ToString());

                // Prefix
                string prefix = trace.Prefix;
                if (string.IsNullOrEmpty(prefix) == false)
                {
                    aParameters.Writer.WriteAttributeString(SegConstants.Traces_Prefix, prefix);
                }

                // Suffix
                string suffix = trace.Suffix;
                if (string.IsNullOrEmpty(suffix) == false)
                {
                    aParameters.Writer.WriteAttributeString(SegConstants.Traces_Suffix, suffix);
                }

                if (trace.HasIdentifier)
                {
                    // Component/group/id triplet
                    TraceIdentifier identifier = trace.Identifier;
                    aParameters.Writer.WriteAttributeString(SegConstants.Traces_ComponentId, "0x" + identifier.Component.ToString("x8"));
                    aParameters.Writer.WriteAttributeString(SegConstants.Traces_GroupId, identifier.Group.ToString());
                    aParameters.Writer.WriteAttributeString(SegConstants.Traces_InstanceId, identifier.Id.ToString());

                    // File & line
                    TraceLocation location = identifier.Location;
                    //
                    string file       = location.File;
                    string lineNumber = location.Line.ToString();
                    //
                    if (string.IsNullOrEmpty(file) == false && string.IsNullOrEmpty(lineNumber) == false)
                    {
                        aParameters.Writer.WriteAttributeString(SegConstants.Traces_File, file);
                        aParameters.Writer.WriteAttributeString(SegConstants.Traces_LineNumber, lineNumber);
                    }
                }

                // Payload
                string payload = trace.Payload;
                aParameters.Writer.WriteValue(payload);

                aParameters.Writer.WriteEndElement();
            }
        }