|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * Redistribution and use in source and binary forms, with or without |
|
6 * modification, are permitted provided that the following conditions are met: |
|
7 * |
|
8 * - Redistributions of source code must retain the above copyright notice, |
|
9 * this list of conditions and the following disclaimer. |
|
10 * - Redistributions in binary form must reproduce the above copyright notice, |
|
11 * this list of conditions and the following disclaimer in the documentation |
|
12 * and/or other materials provided with the distribution. |
|
13 * - Neither the name of Nokia Corporation nor the names of its contributors |
|
14 * may be used to endorse or promote products derived from this software |
|
15 * without specific prior written permission. |
|
16 * |
|
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 * POSSIBILITY OF SUCH DAMAGE. |
|
28 * |
|
29 * Initial Contributors: |
|
30 * Nokia Corporation - initial contribution. |
|
31 * |
|
32 * Contributors: |
|
33 * |
|
34 * Description: |
|
35 * |
|
36 */ |
|
37 |
|
38 using System; |
|
39 using System.Text; |
|
40 using System.Collections; |
|
41 using System.Collections.Generic; |
|
42 using MemAnalysisLib.MemoryOperations.Functions; |
|
43 using MemAnalysisLib.MemoryOperations.Class; |
|
44 using SymbolLib.Generics; |
|
45 using SymbolLib.Engines; |
|
46 |
|
47 namespace MemAnalysisLib.MemoryOperations.Operations |
|
48 { |
|
49 public abstract class MemOpBase |
|
50 { |
|
51 #region Constructors & destructor |
|
52 public MemOpBase() |
|
53 { |
|
54 } |
|
55 #endregion |
|
56 |
|
57 #region From System.Object |
|
58 public override string ToString() |
|
59 { |
|
60 string ret = "[" + LineNumber.ToString( "d8" ) + "] 0x" + CellAddress.ToString( "x8" ) + " " + FunctionName; |
|
61 return ret; |
|
62 } |
|
63 #endregion |
|
64 |
|
65 #region Type-related properties |
|
66 public bool IsAllocationType |
|
67 { |
|
68 get |
|
69 { |
|
70 return ( Class == TClass.EAllocation || Class == TClass.EReallocation ); |
|
71 } |
|
72 } |
|
73 |
|
74 public bool IsDeallocationType |
|
75 { |
|
76 get |
|
77 { |
|
78 return ( Class == TClass.EDeallocation ); |
|
79 } |
|
80 } |
|
81 |
|
82 public bool IsReallocationType |
|
83 { |
|
84 get |
|
85 { |
|
86 return ( Class == TClass.EReallocation ); |
|
87 } |
|
88 } |
|
89 #endregion |
|
90 |
|
91 #region General properties |
|
92 public string FunctionName |
|
93 { |
|
94 get { return Function.ToString(); } |
|
95 } |
|
96 |
|
97 internal MemOpFnBase Function |
|
98 { |
|
99 get { return iFunction; } |
|
100 set { iFunction = value; } |
|
101 } |
|
102 |
|
103 public TClass Class |
|
104 { |
|
105 get |
|
106 { |
|
107 TClass ret = TClass.ENotApplicable; |
|
108 // |
|
109 if ( Function != null ) |
|
110 { |
|
111 ret = Function.Class; |
|
112 } |
|
113 // |
|
114 return ret; |
|
115 } |
|
116 } |
|
117 |
|
118 public uint LineNumber |
|
119 { |
|
120 get { return iLineNumber; } |
|
121 set { iLineNumber = value; } |
|
122 } |
|
123 |
|
124 public uint CellAddress |
|
125 { |
|
126 get { return iCellAddress; } |
|
127 set { iCellAddress = value; } |
|
128 } |
|
129 |
|
130 public uint CellSize |
|
131 { |
|
132 get { return iCellSize; } |
|
133 set { iCellSize = value; } |
|
134 } |
|
135 |
|
136 public uint AllocationNumber |
|
137 { |
|
138 get { return iAllocationNumber; } |
|
139 set { iAllocationNumber = value; } |
|
140 } |
|
141 |
|
142 public uint HeapSize |
|
143 { |
|
144 get { return iHeapSize; } |
|
145 set { iHeapSize = value; } |
|
146 } |
|
147 |
|
148 public uint ChunkSize |
|
149 { |
|
150 get { return iChunkSize; } |
|
151 set { iChunkSize = value; } |
|
152 } |
|
153 |
|
154 public uint VTable |
|
155 { |
|
156 get { return iVTable; } |
|
157 set { iVTable = value; } |
|
158 } |
|
159 |
|
160 public int OperationIndex |
|
161 { |
|
162 get { return iOperationIndex; } |
|
163 set { iOperationIndex = value; } |
|
164 } |
|
165 |
|
166 public MemOpBase Link |
|
167 { |
|
168 get { return iLink; } |
|
169 set { iLink = value; } |
|
170 } |
|
171 |
|
172 public object Collection |
|
173 { |
|
174 get { return iCollection; } |
|
175 set { iCollection = value; } |
|
176 } |
|
177 |
|
178 public uint LinkRegisterAddress |
|
179 { |
|
180 get { return iLinkRegisterAddress; } |
|
181 set { iLinkRegisterAddress = value; } |
|
182 } |
|
183 |
|
184 public GenericSymbol LinkRegisterSymbol |
|
185 { |
|
186 get { return iLinkRegisterSymbol; } |
|
187 } |
|
188 |
|
189 public GenericSymbol VTableSymbol |
|
190 { |
|
191 get { return iVTableSymbol; } |
|
192 } |
|
193 #endregion |
|
194 |
|
195 #region Abstract API |
|
196 public virtual void Finalise( SymbolLib.Engines.SymbolManager aSymbolManager ) |
|
197 { |
|
198 iLinkRegisterSymbol = SymbolForAddress( LinkRegisterAddress, aSymbolManager ); |
|
199 iVTableSymbol = SymbolForAddress( VTable, aSymbolManager ); |
|
200 } |
|
201 #endregion |
|
202 |
|
203 #region Internal methods |
|
204 private GenericSymbol SymbolForAddress( uint aAddress, SymbolManager aSymbolManager ) |
|
205 { |
|
206 System.Diagnostics.Debug.Assert( aSymbolManager != null ); |
|
207 |
|
208 // Try and find a matching collection / symbol entry |
|
209 GenericSymbolCollection collection; |
|
210 GenericSymbol symbol = aSymbolManager.EntryByAddress( aAddress, out collection ); |
|
211 return symbol; |
|
212 } |
|
213 #endregion |
|
214 |
|
215 #region Data members |
|
216 private int iOperationIndex; |
|
217 private uint iCellAddress; |
|
218 private uint iHeapSize; |
|
219 private uint iChunkSize; |
|
220 private uint iAllocationNumber; |
|
221 private uint iAllocationSize; |
|
222 private uint iCellSize; |
|
223 private uint iLineNumber; |
|
224 private uint iVTable; |
|
225 private MemOpFnBase iFunction = null; |
|
226 private MemOpBase iLink = null; |
|
227 private object iCollection = null; |
|
228 private uint iLinkRegisterAddress; |
|
229 private GenericSymbol iLinkRegisterSymbol; |
|
230 private GenericSymbol iVTableSymbol; |
|
231 #endregion |
|
232 } |
|
233 } |