|
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.Registers; |
|
22 using CrashItemLib.Crash.Registers.Special; |
|
23 using CrashItemLib.Crash.Registers.Visualization; |
|
24 using CrashItemLib.Crash.Registers.Visualization.Bits; |
|
25 using CrashItemLib.Crash.Symbols; |
|
26 using CrashXmlPlugin.FileFormat.Node; |
|
27 using CrashXmlPlugin.FileFormat.Segment.Entries.Symbols; |
|
28 using SymbianUtils.Enum; |
|
29 |
|
30 namespace CrashXmlPlugin.FileFormat.Segment.Entries.Registers |
|
31 { |
|
32 internal class CXmlRegister : CXmlNode |
|
33 { |
|
34 #region Constructors |
|
35 public CXmlRegister( CIRegister aRegister ) |
|
36 : base( SegConstants.Registers_RegisterSet_Register ) |
|
37 { |
|
38 iRegister = aRegister; |
|
39 } |
|
40 #endregion |
|
41 |
|
42 #region From CXmlNode |
|
43 protected override void XmlSerializeContent( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
44 { |
|
45 CXmlNode.WriteId( iRegister, aParameters.Writer ); |
|
46 |
|
47 // Map the ArmRegister name onto the register names we expose via XML. In reality, the only register names |
|
48 // that need remapping are R13, R14 and R15. |
|
49 string regName = RemapRegisterName(); |
|
50 aParameters.Writer.WriteElementString( SegConstants.CmnName, regName ); |
|
51 aParameters.Writer.WriteElementString( SegConstants.CmnValue, iRegister.Value.ToString("x8") ); |
|
52 |
|
53 if ( iRegister.Symbol != null && CXmlSymbol.IsSerializable( iRegister.Symbol ) ) |
|
54 { |
|
55 CXmlNode.WriteLink( iRegister.Symbol.Id, SegConstants.Symbols, aParameters.Writer ); |
|
56 } |
|
57 |
|
58 // Write any messages |
|
59 CXmlSegBase.XmlSerializeMessages( aParameters, iRegister ); |
|
60 } |
|
61 |
|
62 protected override void XmlSerializeChildren( CrashXmlPlugin.FileFormat.Document.CXmlDocumentSerializationParameters aParameters ) |
|
63 { |
|
64 CIElementList<CIRegisterVisualization> visList = iRegister.ChildrenByType<CIRegisterVisualization>(); |
|
65 foreach ( CIRegisterVisualization vis in visList ) |
|
66 { |
|
67 CXmlNode.WriteLink( vis.Id, SegConstants.ValueInterpretation, aParameters.Writer ); |
|
68 } |
|
69 } |
|
70 #endregion |
|
71 |
|
72 #region Properties |
|
73 #endregion |
|
74 |
|
75 #region Internal methods |
|
76 private string RemapRegisterName() |
|
77 { |
|
78 string ret = iRegister.Name; |
|
79 // |
|
80 switch ( iRegister.Type ) |
|
81 { |
|
82 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_SP: |
|
83 ret = "R13"; |
|
84 break; |
|
85 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_LR: |
|
86 ret = "R14"; |
|
87 break; |
|
88 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_PC: |
|
89 ret = "R15"; |
|
90 break; |
|
91 default: |
|
92 break; |
|
93 } |
|
94 // |
|
95 return ret; |
|
96 } |
|
97 #endregion |
|
98 |
|
99 #region Data members |
|
100 private readonly CIRegister iRegister; |
|
101 #endregion |
|
102 } |
|
103 } |