|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 using System; |
|
18 using System.Text; |
|
19 using System.Collections.Generic; |
|
20 using CrashItemLib.Crash.Base; |
|
21 using CrashItemLib.Crash.Traces; |
|
22 using CrashItemLib.Crash.Utils; |
|
23 using CrashXmlPlugin.FileFormat.Versions; |
|
24 using SymbianStructuresLib.Debug.Trace; |
|
25 |
|
26 namespace CrashXmlPlugin.FileFormat.Segment.Entries.Traces |
|
27 { |
|
28 internal class CXmlSegTraces : CXmlSegBase |
|
29 { |
|
30 #region Constructors |
|
31 public CXmlSegTraces() |
|
32 : base( SegConstants.Traces ) |
|
33 { |
|
34 } |
|
35 #endregion |
|
36 |
|
37 #region From CXmlSegBase |
|
38 public override int SegmentPriority |
|
39 { |
|
40 get { return 150; } |
|
41 } |
|
42 #endregion |
|
43 |
|
44 #region From CXmlNode |
|
45 public override void XmlSerialize( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
46 { |
|
47 iTraceData = aParameters.Container.Traces; |
|
48 // |
|
49 if ( iTraceData != null && iTraceData.Lines.Length > 0 ) |
|
50 { |
|
51 base.XmlSerialize( aParameters ); |
|
52 } |
|
53 // |
|
54 iTraceData = null; |
|
55 } |
|
56 |
|
57 protected override void XmlSerializeChildren( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
58 { |
|
59 System.Diagnostics.Debug.Assert( iTraceData != null ); |
|
60 foreach ( CITrace ciTrace in iTraceData ) |
|
61 { |
|
62 aParameters.Writer.WriteStartElement( SegConstants.Traces_Line ); |
|
63 // |
|
64 TraceLine trace = ciTrace; |
|
65 |
|
66 // Type |
|
67 string type = string.Empty; |
|
68 switch ( trace.Type ) |
|
69 { |
|
70 case TraceLine.TType.ETypeBinary: |
|
71 type = SegConstants.Traces_Type_Binary; |
|
72 break; |
|
73 case TraceLine.TType.ETypeRaw: |
|
74 type = SegConstants.Traces_Type_Raw; |
|
75 break; |
|
76 case TraceLine.TType.ETypeText: |
|
77 type = SegConstants.Traces_Type_Text; |
|
78 break; |
|
79 default: |
|
80 type = SegConstants.Traces_Type_Unknown; |
|
81 break; |
|
82 } |
|
83 if ( string.IsNullOrEmpty( type ) == false ) |
|
84 { |
|
85 aParameters.Writer.WriteAttributeString( SegConstants.CmnType, type ); |
|
86 } |
|
87 |
|
88 // Context id |
|
89 if ( trace.ContextId != 0 ) |
|
90 { |
|
91 aParameters.Writer.WriteAttributeString( SegConstants.Traces_ContextId, "0x" + trace.ContextId.ToString( "x8" ) ); |
|
92 } |
|
93 |
|
94 // Time stamp |
|
95 aParameters.Writer.WriteAttributeString( SegConstants.Traces_TimeStamp, trace.TimeStamp.ToString() ); |
|
96 |
|
97 // Prefix |
|
98 string prefix = trace.Prefix; |
|
99 if ( string.IsNullOrEmpty( prefix ) == false ) |
|
100 { |
|
101 aParameters.Writer.WriteAttributeString( SegConstants.Traces_Prefix, prefix ); |
|
102 } |
|
103 |
|
104 // Suffix |
|
105 string suffix = trace.Suffix; |
|
106 if ( string.IsNullOrEmpty( suffix ) == false ) |
|
107 { |
|
108 aParameters.Writer.WriteAttributeString( SegConstants.Traces_Suffix, suffix ); |
|
109 } |
|
110 |
|
111 if ( trace.HasIdentifier ) |
|
112 { |
|
113 // Component/group/id triplet |
|
114 TraceIdentifier identifier = trace.Identifier; |
|
115 aParameters.Writer.WriteAttributeString( SegConstants.Traces_ComponentId, "0x" + identifier.Component.ToString( "x8" ) ); |
|
116 aParameters.Writer.WriteAttributeString( SegConstants.Traces_GroupId, identifier.Group.ToString() ); |
|
117 aParameters.Writer.WriteAttributeString( SegConstants.Traces_InstanceId, identifier.Id.ToString() ); |
|
118 |
|
119 // File & line |
|
120 TraceLocation location = identifier.Location; |
|
121 // |
|
122 string file = location.File; |
|
123 string lineNumber = location.Line.ToString(); |
|
124 // |
|
125 if ( string.IsNullOrEmpty( file ) == false && string.IsNullOrEmpty( lineNumber ) == false ) |
|
126 { |
|
127 aParameters.Writer.WriteAttributeString( SegConstants.Traces_File, file ); |
|
128 aParameters.Writer.WriteAttributeString( SegConstants.Traces_LineNumber, lineNumber ); |
|
129 } |
|
130 } |
|
131 |
|
132 // Payload |
|
133 string payload = trace.Payload; |
|
134 aParameters.Writer.WriteValue( payload ); |
|
135 |
|
136 aParameters.Writer.WriteEndElement(); |
|
137 } |
|
138 } |
|
139 #endregion |
|
140 |
|
141 #region Properties |
|
142 #endregion |
|
143 |
|
144 #region From SegBase |
|
145 #endregion |
|
146 |
|
147 #region Data members |
|
148 private CITraceData iTraceData = null; |
|
149 #endregion |
|
150 } |
|
151 } |