|
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 SymbianDebugLib.Engine; |
|
21 using SymbianDebugLib.PluginAPI.Types.Symbol; |
|
22 using SymbianStructuresLib.Arm.Registers; |
|
23 using CrashItemLib.Crash; |
|
24 using CrashItemLib.Crash.Base; |
|
25 using CrashItemLib.Crash.Base.DataBinding; |
|
26 using CrashItemLib.Crash.Registers; |
|
27 using CrashItemLib.Crash.Symbols; |
|
28 using CrashItemLib.Crash.Threads; |
|
29 using CrashItemLib.Crash.Processes; |
|
30 |
|
31 namespace CrashItemLib.Crash.Registers |
|
32 { |
|
33 public class CIRegister : CIElement |
|
34 { |
|
35 #region Constructors |
|
36 public CIRegister( CIRegisterList aList, TArmRegisterType aType, uint aValue ) |
|
37 : this( aList, aType, ArmRegister.GetTypeName( aType ), aValue ) |
|
38 { |
|
39 } |
|
40 |
|
41 public CIRegister( CIRegisterList aList, TArmRegisterType aType, string aName, uint aValue ) |
|
42 : base( aList.Container ) |
|
43 { |
|
44 iList = aList; |
|
45 |
|
46 // Create register and observe when it changes value |
|
47 iRegister = new ArmRegister( aType, aName, aValue ); |
|
48 iRegister.Tag = this; |
|
49 |
|
50 // Prepare non-resolved symbol. I.e. this saves the address |
|
51 // but doesn't actually do any symbolic look up at this stage. |
|
52 ICISymbolManager symbolManager = this.SymbolManager; |
|
53 CISymbol symbol = symbolManager.SymbolDictionary.Register( iRegister.Value ); |
|
54 base.AddChild( symbol ); |
|
55 } |
|
56 #endregion |
|
57 |
|
58 #region API |
|
59 #endregion |
|
60 |
|
61 #region Properties |
|
62 public override string Name |
|
63 { |
|
64 get { return TypeName; } |
|
65 } |
|
66 |
|
67 public TArmRegisterType Type |
|
68 { |
|
69 get { return Register.RegType; } |
|
70 } |
|
71 |
|
72 public TArmRegisterBank Bank |
|
73 { |
|
74 get { return iList.Bank; } |
|
75 } |
|
76 |
|
77 public string TypeName |
|
78 { |
|
79 get { return Register.OriginalName; } |
|
80 } |
|
81 |
|
82 public uint Value |
|
83 { |
|
84 get { return Register.Value; } |
|
85 set |
|
86 { |
|
87 // Update register value and also symbol |
|
88 iRegister.Value = value; |
|
89 |
|
90 // Refresh symbol registration |
|
91 ICISymbolManager symbolManager = this.SymbolManager; |
|
92 symbolManager.SymbolDictionary.RefreshRegistration( this, value, this.Symbol ); |
|
93 } |
|
94 } |
|
95 |
|
96 public ArmRegister Register |
|
97 { |
|
98 get { return iRegister; } |
|
99 } |
|
100 |
|
101 public CISymbol Symbol |
|
102 { |
|
103 get { return base.ChildByType( typeof( CISymbol ) ) as CISymbol; } |
|
104 } |
|
105 |
|
106 public CIThread OwningThread |
|
107 { |
|
108 get |
|
109 { |
|
110 CIThread ret = null; |
|
111 // |
|
112 if ( iList.OwningThread != null ) |
|
113 { |
|
114 ret = iList.OwningThread; |
|
115 } |
|
116 // |
|
117 return ret; |
|
118 } |
|
119 } |
|
120 |
|
121 public CIProcess OwningProcess |
|
122 { |
|
123 get |
|
124 { |
|
125 CIProcess ret = null; |
|
126 // |
|
127 if ( OwningThread != null ) |
|
128 { |
|
129 ret = OwningThread.OwningProcess; |
|
130 } |
|
131 // |
|
132 return ret; |
|
133 } |
|
134 } |
|
135 |
|
136 internal ICISymbolManager SymbolManager |
|
137 { |
|
138 get |
|
139 { |
|
140 ICISymbolManager ret = base.Container; |
|
141 // |
|
142 CIProcess process = this.OwningProcess; |
|
143 if ( process != null ) |
|
144 { |
|
145 ret = process; |
|
146 } |
|
147 // |
|
148 return ret; |
|
149 } |
|
150 } |
|
151 #endregion |
|
152 |
|
153 #region Operators |
|
154 public static implicit operator ArmRegister( CIRegister aRegister ) |
|
155 { |
|
156 return aRegister.Register; |
|
157 } |
|
158 |
|
159 public static implicit operator uint( CIRegister aRegister ) |
|
160 { |
|
161 return aRegister.Register.Value; |
|
162 } |
|
163 |
|
164 public static implicit operator CIDBRow( CIRegister aRegister ) |
|
165 { |
|
166 CIDBRow row = new CIDBRow(); |
|
167 |
|
168 // To ensure that the register and cells are correctly associated |
|
169 row.Element = aRegister; |
|
170 |
|
171 row.Add( new CIDBCell( aRegister.TypeName ) ); |
|
172 row.Add( new CIDBCell( aRegister.Value.ToString("x8") ) ); |
|
173 row.Add( new CIDBCell( aRegister.Symbol.Name ) ); |
|
174 // |
|
175 return row; |
|
176 } |
|
177 #endregion |
|
178 |
|
179 #region From System.Object |
|
180 public override string ToString() |
|
181 { |
|
182 return iRegister.ToString(); |
|
183 } |
|
184 #endregion |
|
185 |
|
186 #region From CIElement |
|
187 internal override void DoFinalize( CIElementFinalizationParameters aParams, Queue<CIElement> aCallBackLast, bool aForceFinalize ) |
|
188 { |
|
189 base.DoFinalize( aParams, aCallBackLast, aForceFinalize ); |
|
190 } |
|
191 #endregion |
|
192 |
|
193 #region Data members |
|
194 private readonly CIRegisterList iList; |
|
195 private readonly ArmRegister iRegister; |
|
196 #endregion |
|
197 } |
|
198 } |