|
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 * The class CCrashInfoRegisterStorage is part of CrashAnalyser CrashInfoFile plugin. |
|
16 * Temporary container for arm register list information conversion from |
|
17 * CrashAnalyser data to CrashInfoFile document. |
|
18 * Reads register info from CIRegisterList structures and outputs formatted |
|
19 * CrashInfo file rows. |
|
20 * |
|
21 */ |
|
22 |
|
23 using System; |
|
24 using System.Collections.Generic; |
|
25 using System.Text; |
|
26 using CrashItemLib.Crash.Registers; |
|
27 |
|
28 namespace CrashInfoFilePlugin.PluginImplementations.FileFormat |
|
29 { |
|
30 internal class CCrashInfoRegisterStorage |
|
31 { |
|
32 #region Constructors |
|
33 public CCrashInfoRegisterStorage() |
|
34 { |
|
35 |
|
36 } |
|
37 #endregion |
|
38 |
|
39 public void ReadRegisterData(CIRegisterList aRegList) |
|
40 { |
|
41 //If long enough reglist starts with R0, it is assumed to be the "basic" register list (R0-R15) |
|
42 if (aRegList.Count > 15 && aRegList[0].Type == SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_00) |
|
43 { |
|
44 iBasicRegs.Name = aRegList.Name; |
|
45 foreach (CIRegister register in aRegList) |
|
46 { |
|
47 string regName = GetRegisterName(register); |
|
48 |
|
49 CCrasInfoRegisterItem regItem = new CCrasInfoRegisterItem(regName, register.Value); |
|
50 |
|
51 if (register.Symbol != null && CCrashInfoFileUtilities.IsSymbolSerializable(register.Symbol)) |
|
52 { |
|
53 regItem.Symbol = register.Symbol.Name; |
|
54 } |
|
55 |
|
56 iBasicRegs.Registers.Add(regItem); |
|
57 |
|
58 //Check if this is PC and save it separately |
|
59 if (register.Type == SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_PC) |
|
60 { |
|
61 iProgramCounter.Value = register.Value; |
|
62 iProgramCounter.Symbol = register.Symbol.Name; |
|
63 } |
|
64 } |
|
65 } |
|
66 else //all other registers as their own list |
|
67 { |
|
68 CCrashInfoRegisterList regs = new CCrashInfoRegisterList(); |
|
69 regs.Name = aRegList.Name; |
|
70 bool hasRealData = false; |
|
71 foreach (CIRegister register in aRegList) |
|
72 { |
|
73 string regName = GetRegisterName(register); |
|
74 CCrasInfoRegisterItem regItem = new CCrasInfoRegisterItem(regName, register.Value); |
|
75 if (register.Symbol != null && CCrashInfoFileUtilities.IsSymbolSerializable(register.Symbol)) |
|
76 { |
|
77 regItem.Symbol = register.Symbol.Name; |
|
78 } |
|
79 |
|
80 regs.Registers.Add(regItem); |
|
81 |
|
82 if (register.Value != 0) |
|
83 { |
|
84 hasRealData = true; |
|
85 } |
|
86 } |
|
87 |
|
88 if (hasRealData) |
|
89 { |
|
90 iOtherRegLists.Add(regs); |
|
91 } |
|
92 } |
|
93 } |
|
94 |
|
95 public void WriteBasicRegisters(System.IO.StreamWriter aOutput) |
|
96 { |
|
97 aOutput.Write(CCrashInfoFileUtilities.BlockStartMarker(CrashInfoConsts.Kregister)); |
|
98 if (iBasicRegs.Registers.Count == 0) |
|
99 { |
|
100 aOutput.Write("NotFound|"); |
|
101 |
|
102 } |
|
103 else |
|
104 { |
|
105 aOutput.Write(iBasicRegs.Name); |
|
106 foreach (CCrasInfoRegisterItem reg in iBasicRegs.Registers) |
|
107 { |
|
108 aOutput.Write(CrashInfoConsts.KSeparator); |
|
109 aOutput.Write(reg.Name); |
|
110 aOutput.Write(CrashInfoConsts.KSeparator); |
|
111 aOutput.Write(reg.Value); |
|
112 if (reg.Symbol != string.Empty) |
|
113 { |
|
114 aOutput.Write(":" +reg.Symbol); |
|
115 } |
|
116 } |
|
117 } |
|
118 aOutput.Write(CCrashInfoFileUtilities.BlockEndMarker(CrashInfoConsts.Kregister)); |
|
119 } |
|
120 |
|
121 internal void WriteOtherRegisters(System.IO.StreamWriter aOutput) |
|
122 { |
|
123 if (iOtherRegLists.Count > 0) |
|
124 { |
|
125 aOutput.Write(CCrashInfoFileUtilities.BlockStartMarker(CrashInfoConsts.Kregister_extra)); |
|
126 foreach (CCrashInfoRegisterList regList in iOtherRegLists) |
|
127 { |
|
128 |
|
129 aOutput.Write(regList.Name); |
|
130 foreach (CCrasInfoRegisterItem reg in regList.Registers) |
|
131 { |
|
132 aOutput.Write(CrashInfoConsts.KSeparator); |
|
133 aOutput.Write(reg.Name); |
|
134 aOutput.Write(CrashInfoConsts.KSeparator); |
|
135 aOutput.Write(reg.Value); |
|
136 if (reg.Symbol != string.Empty) |
|
137 { |
|
138 aOutput.Write(":" + reg.Symbol); |
|
139 } |
|
140 } |
|
141 aOutput.Write(CrashInfoConsts.KEOL); |
|
142 |
|
143 } |
|
144 aOutput.Write(CCrashInfoFileUtilities.BlockEndMarker(CrashInfoConsts.Kregister_extra)); |
|
145 |
|
146 } |
|
147 } |
|
148 |
|
149 internal void WriteProgramCounter(System.IO.StreamWriter aOutput) |
|
150 { |
|
151 aOutput.Write(CCrashInfoFileUtilities.BlockStartMarker(CrashInfoConsts.Kprogram_counter)); |
|
152 aOutput.Write(iProgramCounter.Value); |
|
153 aOutput.Write(CrashInfoConsts.KSeparator); |
|
154 if (iProgramCounter.Symbol != string.Empty) |
|
155 { |
|
156 aOutput.Write(iProgramCounter.Symbol); |
|
157 } |
|
158 else |
|
159 { |
|
160 aOutput.Write("-"); //missing pc symbol is marked with - in ci file. |
|
161 } |
|
162 |
|
163 |
|
164 aOutput.Write(CCrashInfoFileUtilities.BlockEndMarker(CrashInfoConsts.Kprogram_counter)); |
|
165 } |
|
166 |
|
167 /** Return CrashInfo compatible register name - R0-R15 in short numeric form, other as they are */ |
|
168 public static string GetRegisterName(CIRegister aRegister) |
|
169 { |
|
170 string ret = aRegister.Name; |
|
171 // |
|
172 switch (aRegister.Type) |
|
173 { |
|
174 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_00: |
|
175 ret = "R0"; |
|
176 break; |
|
177 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_01: |
|
178 ret = "R1"; |
|
179 break; |
|
180 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_02: |
|
181 ret = "R2"; |
|
182 break; |
|
183 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_03: |
|
184 ret = "R3"; |
|
185 break; |
|
186 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_04: |
|
187 ret = "R4"; |
|
188 break; |
|
189 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_05: |
|
190 ret = "R5"; |
|
191 break; |
|
192 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_06: |
|
193 ret = "R6"; |
|
194 break; |
|
195 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_07: |
|
196 ret = "R7"; |
|
197 break; |
|
198 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_08: |
|
199 ret = "R8"; |
|
200 break; |
|
201 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_09: |
|
202 ret = "R9"; |
|
203 break; |
|
204 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_10: |
|
205 ret = "R10"; |
|
206 break; |
|
207 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_11: |
|
208 ret = "R11"; |
|
209 break; |
|
210 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_12: |
|
211 ret = "R12"; |
|
212 break; |
|
213 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_SP: |
|
214 ret = "R13"; |
|
215 break; |
|
216 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_LR: |
|
217 ret = "R14"; |
|
218 break; |
|
219 case SymbianStructuresLib.Arm.Registers.TArmRegisterType.EArmReg_PC: |
|
220 ret = "R15"; |
|
221 break; |
|
222 default: |
|
223 break; |
|
224 } |
|
225 // |
|
226 return ret; |
|
227 } |
|
228 |
|
229 #region Data Members |
|
230 private CCrashInfoRegisterList iBasicRegs = new CCrashInfoRegisterList(); //R0-R15 |
|
231 private List<CCrashInfoRegisterList> iOtherRegLists = new List<CCrashInfoRegisterList>(); //Other registers |
|
232 private CCrasInfoRegisterItem iProgramCounter = new CCrasInfoRegisterItem("PC"); |
|
233 |
|
234 #endregion |
|
235 |
|
236 #region Nested Classes |
|
237 private class CCrashInfoRegisterList |
|
238 { |
|
239 #region Constructors |
|
240 public CCrashInfoRegisterList() |
|
241 { |
|
242 |
|
243 } |
|
244 #endregion |
|
245 |
|
246 #region Properties |
|
247 public List<CCrasInfoRegisterItem> Registers |
|
248 { |
|
249 get { return iRegisters; } |
|
250 set { iRegisters = value; } |
|
251 } |
|
252 public string Name |
|
253 { |
|
254 get { return iName; } |
|
255 set { iName = value; } |
|
256 } |
|
257 |
|
258 #endregion |
|
259 |
|
260 private List<CCrasInfoRegisterItem> iRegisters = new List<CCrasInfoRegisterItem>(); |
|
261 private string iName; |
|
262 |
|
263 |
|
264 } |
|
265 |
|
266 private class CCrasInfoRegisterItem |
|
267 { |
|
268 #region Constructors |
|
269 public CCrasInfoRegisterItem(string aName) |
|
270 { |
|
271 iName = aName; |
|
272 } |
|
273 |
|
274 public CCrasInfoRegisterItem(string aName, uint aValue) |
|
275 { |
|
276 iName = aName; |
|
277 iValue = aValue; |
|
278 } |
|
279 |
|
280 #endregion |
|
281 |
|
282 #region Properties |
|
283 public string Name |
|
284 { |
|
285 get { return iName; } |
|
286 set { iName = value; } |
|
287 } |
|
288 |
|
289 public uint Value |
|
290 { |
|
291 get { return iValue; } |
|
292 set { iValue = value; } |
|
293 } |
|
294 |
|
295 public string Symbol |
|
296 { |
|
297 get { return iSymbol; } |
|
298 set { iSymbol = value; } |
|
299 } |
|
300 |
|
301 #endregion |
|
302 |
|
303 |
|
304 #region Data Members |
|
305 |
|
306 private uint iValue = 0; |
|
307 private string iName = string.Empty; |
|
308 private string iSymbol = string.Empty; |
|
309 |
|
310 #endregion |
|
311 } |
|
312 |
|
313 #endregion |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
319 } |
|
320 |
|
321 |
|
322 } |