|
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.Symbols; |
|
22 using CrashItemLib.Crash.CodeSegs; |
|
23 using SymbianStructuresLib.Debug.Symbols; |
|
24 using CrashXmlPlugin.FileFormat.Node; |
|
25 |
|
26 namespace CrashXmlPlugin.FileFormat.Segment.Entries.Symbols |
|
27 { |
|
28 internal class CXmlSymbol : CXmlNode |
|
29 { |
|
30 #region Constructors |
|
31 public CXmlSymbol( CISymbol aSymbol ) |
|
32 : base( SegConstants.Symbols_SymbolSet_Symbol ) |
|
33 { |
|
34 iSymbol = aSymbol; |
|
35 } |
|
36 #endregion |
|
37 |
|
38 #region API |
|
39 public static bool IsSerializable( CISymbol aSymbol ) |
|
40 { |
|
41 bool ret = true; |
|
42 // |
|
43 if ( aSymbol.IsNull ) |
|
44 { |
|
45 ret = false; |
|
46 } |
|
47 else |
|
48 { |
|
49 Symbol symbol = aSymbol.Symbol; |
|
50 TSymbolType type = symbol.Type; |
|
51 // |
|
52 ret = ( type != TSymbolType.EUnknown ); |
|
53 } |
|
54 // |
|
55 return ret; |
|
56 } |
|
57 #endregion |
|
58 |
|
59 #region From CXmlNode |
|
60 protected override void XmlSerializeContent( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
61 { |
|
62 CXmlNode.WriteId( iSymbol, aParameters.Writer ); |
|
63 |
|
64 aParameters.Writer.WriteElementString( SegConstants.CmnAddress, iSymbol.Symbol.Address.ToString("x8") ); |
|
65 aParameters.Writer.WriteElementString( SegConstants.CmnSize, iSymbol.Symbol.Size.ToString( "x8" ) ); |
|
66 aParameters.Writer.WriteElementString( SegConstants.CmnName, iSymbol.Symbol.Name ); |
|
67 aParameters.Writer.WriteElementString( SegConstants.Symbols_SymbolSet_Symbol_Object, iSymbol.Symbol.Object ); |
|
68 |
|
69 // If there is a link to a code code segment, then write that too. |
|
70 CICodeSeg correspondingCodeSeg = iSymbol.CodeSegment; |
|
71 if ( correspondingCodeSeg != null ) |
|
72 { |
|
73 CXmlNode.WriteLink( correspondingCodeSeg.Id, SegConstants.CodeSegs, aParameters.Writer ); |
|
74 } |
|
75 } |
|
76 |
|
77 protected override void XmlSerializeChildren( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
78 { |
|
79 aParameters.Writer.WriteStartElement( SegConstants.CmnAttributes ); |
|
80 |
|
81 // XIP vs RAM |
|
82 bool isLoadedFromRAM = this.IsFromRAMLoadedCode; |
|
83 if ( isLoadedFromRAM ) |
|
84 { |
|
85 aParameters.Writer.WriteElementString( SegConstants.CmnRAM, string.Empty ); |
|
86 } |
|
87 else |
|
88 { |
|
89 aParameters.Writer.WriteElementString( SegConstants.CmnXIP, string.Empty ); |
|
90 } |
|
91 |
|
92 // MAP vs SYMBOL |
|
93 TSymbolSource source = this.SymbolSource; |
|
94 switch( source ) |
|
95 { |
|
96 case TSymbolSource.ESourceWasMapFile: |
|
97 aParameters.Writer.WriteElementString( SegConstants.Symbols_SymbolSet_Symbol_Attribute_Map, string.Empty ); |
|
98 break; |
|
99 case TSymbolSource.ESourceWasSymbolFile: |
|
100 aParameters.Writer.WriteElementString( SegConstants.Symbols_SymbolSet_Symbol_Attribute_Symbol, string.Empty ); |
|
101 break; |
|
102 default: |
|
103 case TSymbolSource.ESourceWasUnknown: |
|
104 break; |
|
105 } |
|
106 |
|
107 aParameters.Writer.WriteEndElement(); |
|
108 } |
|
109 #endregion |
|
110 |
|
111 #region Properties |
|
112 public bool IsFromRAMLoadedCode |
|
113 { |
|
114 get |
|
115 { |
|
116 bool ret = false; |
|
117 // |
|
118 if ( iSymbol.Symbol != null ) |
|
119 { |
|
120 ret = iSymbol.Symbol.IsFromRAMLoadedCode; |
|
121 } |
|
122 // |
|
123 return ret; |
|
124 } |
|
125 } |
|
126 |
|
127 public TSymbolSource SymbolSource |
|
128 { |
|
129 get |
|
130 { |
|
131 TSymbolSource ret = TSymbolSource.ESourceWasUnknown; |
|
132 // |
|
133 if ( iSymbol.Symbol != null ) |
|
134 { |
|
135 ret = iSymbol.Symbol.Source; |
|
136 } |
|
137 // |
|
138 return ret; |
|
139 } |
|
140 } |
|
141 #endregion |
|
142 |
|
143 #region Data members |
|
144 private readonly CISymbol iSymbol; |
|
145 #endregion |
|
146 } |
|
147 } |