|
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 SymbianUtils.Range; |
|
21 using SymbianDebugLib.Engine; |
|
22 using SymbianDebugLib.PluginAPI.Types; |
|
23 using SymbianDebugLib.PluginAPI.Types.Symbol; |
|
24 using SymbianStructuresLib.Debug.Symbols; |
|
25 using CrashItemLib.Crash; |
|
26 using CrashItemLib.Crash.Base; |
|
27 using CrashItemLib.Crash.Processes; |
|
28 using CrashItemLib.Crash.Container; |
|
29 using CrashItemLib.Crash.Symbols; |
|
30 using CrashItemLib.Crash.Registers; |
|
31 using CrashItemLib.Crash.Stacks; |
|
32 using CrashItemLib.Crash.CodeSegs; |
|
33 using CrashItemLib.Crash.Threads; |
|
34 using CrashItemLib.Crash.Summarisable; |
|
35 |
|
36 namespace CrashItemLib.Crash.Symbols |
|
37 { |
|
38 public class CISymbol : CIElement |
|
39 { |
|
40 #region Constructors |
|
41 internal CISymbol( CIContainer aContainer, uint aAddress ) |
|
42 : base( aContainer ) |
|
43 { |
|
44 iAddress = aAddress; |
|
45 } |
|
46 |
|
47 internal CISymbol( CIContainer aContainer, Symbol aSymbol ) |
|
48 : this( aContainer, aSymbol.Address ) |
|
49 { |
|
50 AssignPermanentSymbol( aSymbol ); |
|
51 } |
|
52 #endregion |
|
53 |
|
54 #region API |
|
55 internal CISymbolDictionary Dictionary |
|
56 { |
|
57 get |
|
58 { |
|
59 CISymbolDictionary ret = base.Container.Symbols; |
|
60 CIProcess owningProcess = this.OwningProcess; |
|
61 // |
|
62 if ( owningProcess != null ) |
|
63 { |
|
64 ret = owningProcess.Symbols; |
|
65 } |
|
66 // |
|
67 return ret; |
|
68 } |
|
69 } |
|
70 |
|
71 internal void AssignPermanentSymbol( Symbol aSymbol ) |
|
72 { |
|
73 iSymbol = aSymbol; |
|
74 iSymbolLocked = true; |
|
75 } |
|
76 |
|
77 internal int ReferenceCountIncrement() |
|
78 { |
|
79 return ++iRefCount; |
|
80 } |
|
81 |
|
82 internal int ReferenceCountDecrement() |
|
83 { |
|
84 return --iRefCount; |
|
85 } |
|
86 #endregion |
|
87 |
|
88 #region Properties |
|
89 public override string Name |
|
90 { |
|
91 get |
|
92 { |
|
93 string ret = string.Empty; |
|
94 // |
|
95 if ( !IsNull ) |
|
96 { |
|
97 ret = Symbol.Name; |
|
98 } |
|
99 // |
|
100 return ret; |
|
101 } |
|
102 set { } |
|
103 } |
|
104 |
|
105 public uint Address |
|
106 { |
|
107 get { return iAddress; } |
|
108 } |
|
109 |
|
110 public bool IsNull |
|
111 { |
|
112 get |
|
113 { |
|
114 return iSymbol == null; |
|
115 } |
|
116 } |
|
117 |
|
118 public CICodeSeg CodeSegment |
|
119 { |
|
120 get |
|
121 { |
|
122 CICodeSeg ret = null; |
|
123 // |
|
124 CIProcess process = OwningProcess; |
|
125 if ( process != null ) |
|
126 { |
|
127 ret = process.CodeSegments[ Address ]; |
|
128 } |
|
129 // |
|
130 return ret; |
|
131 } |
|
132 } |
|
133 |
|
134 public Symbol Symbol |
|
135 { |
|
136 get { return iSymbol; } |
|
137 } |
|
138 #endregion |
|
139 |
|
140 #region Operators |
|
141 public static implicit operator Symbol( CISymbol aSelf ) |
|
142 { |
|
143 return aSelf.Symbol; |
|
144 } |
|
145 #endregion |
|
146 |
|
147 #region From CIElement |
|
148 internal override void OnFinalize( CIElementFinalizationParameters aParams ) |
|
149 { |
|
150 try |
|
151 { |
|
152 base.OnFinalize( aParams ); |
|
153 } |
|
154 finally |
|
155 { |
|
156 if ( iAddress != 0 ) |
|
157 { |
|
158 if ( iSymbolLocked == false ) |
|
159 { |
|
160 iSymbol = aParams.DebugEngineView.Symbols[ iAddress ]; |
|
161 base.Trace( string.Format( "[CISymbol] OnFinalize() - address: 0x{0:x8}, id: {1}, iSymbol: {2}", iAddress, base.Id, iSymbol ) ); |
|
162 } |
|
163 } |
|
164 } |
|
165 } |
|
166 #endregion |
|
167 |
|
168 #region From System.Object |
|
169 public override string ToString() |
|
170 { |
|
171 if ( iSymbol != null ) |
|
172 { |
|
173 return iSymbol.ToString(); |
|
174 } |
|
175 // |
|
176 return "0x" + iAddress.ToString( "x8" ); |
|
177 } |
|
178 #endregion |
|
179 |
|
180 #region Internal methods |
|
181 private CIProcess OwningProcess |
|
182 { |
|
183 get |
|
184 { |
|
185 CIProcess ret = null; |
|
186 // |
|
187 CIElement parent = this.Parent; |
|
188 while ( parent != null ) |
|
189 { |
|
190 if ( parent is CIProcess ) |
|
191 { |
|
192 ret = (CIProcess) parent; |
|
193 break; |
|
194 } |
|
195 else if ( parent is CIStack ) |
|
196 { |
|
197 CIStack entity = (CIStack) parent; |
|
198 ret = entity.OwningProcess; |
|
199 break; |
|
200 } |
|
201 else if ( parent is CIThread ) |
|
202 { |
|
203 CIThread entity = (CIThread) parent; |
|
204 ret = entity.OwningProcess; |
|
205 break; |
|
206 } |
|
207 else if ( parent is CISummarisableEntity ) |
|
208 { |
|
209 CISummarisableEntity entity = (CISummarisableEntity) parent; |
|
210 ret = entity.Process; |
|
211 break; |
|
212 } |
|
213 else |
|
214 { |
|
215 parent = parent.Parent; |
|
216 } |
|
217 } |
|
218 // |
|
219 return ret; |
|
220 } |
|
221 } |
|
222 #endregion |
|
223 |
|
224 #region Data members |
|
225 private readonly uint iAddress; |
|
226 private int iRefCount = 0; |
|
227 private bool iSymbolLocked = false; |
|
228 private Symbol iSymbol = null; |
|
229 #endregion |
|
230 } |
|
231 } |