|
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: Class representing a memory address and its details. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "../inc/CATMemoryAddress.h" |
|
20 #include "../inc/CATBase.h" |
|
21 |
|
22 // ----------------------------------------------------------------------------- |
|
23 // CATMemoryAddress::CATMemoryAddress |
|
24 // Constructor |
|
25 // ----------------------------------------------------------------------------- |
|
26 CATMemoryAddress::CATMemoryAddress(string& sAddress, unsigned long iOffSet) |
|
27 { |
|
28 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::CATMemoryAddress"); |
|
29 m_sAddress = sAddress; |
|
30 m_sFileName = ""; |
|
31 m_sFunctionName = ""; |
|
32 m_sModuleName = ""; |
|
33 m_iAddress = CATBase::_httoi( sAddress.c_str() ); |
|
34 m_iDllLoadinfoIndex = -1; |
|
35 m_iModuleStartAddress = 0; |
|
36 m_iOffSetFromModuleStart = 0; |
|
37 m_iExactLineNumber = -1; |
|
38 m_iFunctionLineNumber = -1; |
|
39 m_ePinPointState = OUT_OF_PROCESS; |
|
40 m_iOffSet = iOffSet; |
|
41 } |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CATMemoryAddress::~CATMemoryAddress |
|
45 // Destructor. |
|
46 // ----------------------------------------------------------------------------- |
|
47 CATMemoryAddress::~CATMemoryAddress() |
|
48 { |
|
49 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::~CATMemoryAddress"); |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CATMemoryAddress::FindSetModuleName |
|
54 // Find which binary this address belongs to. |
|
55 // Sets also the offsetfrommodulestart. |
|
56 // ----------------------------------------------------------------------------- |
|
57 bool CATMemoryAddress::FindSetModuleName(vector<DLL_LOAD_INFO>* vDlls) |
|
58 { |
|
59 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::FindSetModuleName"); |
|
60 vector<DLL_LOAD_INFO>::iterator it; |
|
61 for ( it = vDlls->begin() ; |
|
62 it != vDlls->end(); it++ ) |
|
63 { |
|
64 // Is modules load time defined? |
|
65 if ( (*it).iLoadTime > 0 ) |
|
66 { |
|
67 // Check that load time is earlier or same as allocation |
|
68 if ( m_iTime >= (*it).iLoadTime |
|
69 && m_iAddress >= (*it).iStartAddress |
|
70 && m_iAddress < (*it).iEndAddress ) |
|
71 { |
|
72 // Module is loaded until process end. |
|
73 if ( (*it).iUnloadTime == 0 ) |
|
74 break; |
|
75 // Check is allocation done before module was unloaded. |
|
76 else if ( (*it).iUnloadTime >= m_iTime ) |
|
77 break; |
|
78 } |
|
79 } |
|
80 // Module has no time defined use only code segments. |
|
81 else |
|
82 { |
|
83 if ( m_iAddress >= (*it).iStartAddress |
|
84 && m_iAddress < (*it).iEndAddress ) |
|
85 break; |
|
86 } |
|
87 } |
|
88 |
|
89 // Did we not find module where address is? |
|
90 if ( it == vDlls->end() ) |
|
91 return false; |
|
92 |
|
93 m_ePinPointState = OUT_OF_RANGE; |
|
94 m_sModuleName = (*it).sModuleName; |
|
95 m_iModuleStartAddress = (*it).iStartAddress; |
|
96 m_iOffSetFromModuleStart = m_iAddress - m_iModuleStartAddress; |
|
97 m_iOffSetFromModuleStart += m_iOffSet; |
|
98 m_iDllLoadinfoIndex = distance( vDlls->begin(), it ) ; |
|
99 return true; |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CATMemoryAddress::SetModuleStartAddress |
|
104 // Set start address of the binary in which address resides. |
|
105 // Note, this also sets the offset from start value. |
|
106 // ----------------------------------------------------------------------------- |
|
107 void CATMemoryAddress::SetModuleStartAddress(unsigned long iAddress) |
|
108 { |
|
109 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetModuleStartAddress"); |
|
110 m_iModuleStartAddress = iAddress; |
|
111 m_iOffSetFromModuleStart = m_iAddress - m_iModuleStartAddress; |
|
112 m_iOffSetFromModuleStart += m_iOffSet; |
|
113 } |
|
114 |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CATMemoryAddress::GetOffSetFromModuleStart |
|
118 // Note return value includes the set offset. |
|
119 // So this value is not binary start - address. |
|
120 // Instead it is. |
|
121 // memory address - binary start address + offset |
|
122 // ----------------------------------------------------------------------------- |
|
123 unsigned long CATMemoryAddress::GetOffSetFromModuleStart() |
|
124 { |
|
125 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetOffSetFromModuleStart"); |
|
126 return m_iOffSetFromModuleStart; |
|
127 } |
|
128 |
|
129 int CATMemoryAddress::GetDllLoadInfoIndex() |
|
130 { |
|
131 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetDllLoadInfo"); |
|
132 return m_iDllLoadinfoIndex; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CATMemoryAddress::SetTime |
|
137 // ----------------------------------------------------------------------------- |
|
138 void CATMemoryAddress::SetTime( unsigned long long& ullTime ) |
|
139 { |
|
140 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetTime"); |
|
141 m_iTime = ullTime; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CATMemoryAddress::GetTIme |
|
146 // ----------------------------------------------------------------------------- |
|
147 unsigned long long CATMemoryAddress::GetTime() |
|
148 { |
|
149 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetTime"); |
|
150 return m_iTime; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CATMemoryAddress::SetAddress |
|
155 // ----------------------------------------------------------------------------- |
|
156 void CATMemoryAddress::SetAddress(string& sAddress) |
|
157 { |
|
158 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetAddress"); |
|
159 m_sAddress = sAddress; |
|
160 m_iAddress = CATBase::_httoi( sAddress.c_str() ); |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CATMemoryAddress::GetAddressString |
|
165 // ----------------------------------------------------------------------------- |
|
166 string CATMemoryAddress::GetAddressString() |
|
167 { |
|
168 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetAddressString"); |
|
169 return m_sAddress; |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CATMemoryAddress::SetAddress |
|
174 // ----------------------------------------------------------------------------- |
|
175 void CATMemoryAddress::SetAddress(unsigned long iAddress) |
|
176 { |
|
177 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetAddress"); |
|
178 m_iAddress = iAddress; |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CATMemoryAddress::GetAddress |
|
183 // ----------------------------------------------------------------------------- |
|
184 unsigned long CATMemoryAddress::GetAddress() |
|
185 { |
|
186 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetAddress"); |
|
187 return m_iAddress; |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CATMemoryAddress::SetModuleName |
|
192 // ----------------------------------------------------------------------------- |
|
193 void CATMemoryAddress::SetModuleName(string& sModuleName) |
|
194 { |
|
195 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetModuleName"); |
|
196 m_sModuleName = sModuleName; |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CATMemoryAddress::GetModuleName |
|
201 // ----------------------------------------------------------------------------- |
|
202 string CATMemoryAddress::GetModuleName() |
|
203 { |
|
204 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetModuleName"); |
|
205 return m_sModuleName; |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CATMemoryAddress::SetAddressToLineState |
|
210 // ----------------------------------------------------------------------------- |
|
211 void CATMemoryAddress::SetAddressToLineState( ADDRESS_TO_LINE_STATE eState ) |
|
212 { |
|
213 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetAddressToLineState"); |
|
214 m_ePinPointState = eState; |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CATMemoryAddress::GetAddressToLineState |
|
219 // ----------------------------------------------------------------------------- |
|
220 int CATMemoryAddress::GetAddressToLineState() |
|
221 { |
|
222 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetAddressToLineState"); |
|
223 return m_ePinPointState; |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CATMemoryAddress::SetFileName |
|
228 // ----------------------------------------------------------------------------- |
|
229 void CATMemoryAddress::SetFileName(string& sFileName) |
|
230 { |
|
231 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetFileName"); |
|
232 m_sFileName = sFileName; |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CATMemoryAddress::GetFileName |
|
237 // ----------------------------------------------------------------------------- |
|
238 string CATMemoryAddress::GetFileName() |
|
239 { |
|
240 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetFileName"); |
|
241 return m_sFileName; |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CATMemoryAddress::SetFunctionName |
|
246 // ----------------------------------------------------------------------------- |
|
247 void CATMemoryAddress::SetFunctionName(string& sFunctionName) |
|
248 { |
|
249 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetFunctionName"); |
|
250 m_sFunctionName = sFunctionName; |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // CATMemoryAddress::GetFunctionName |
|
255 // ----------------------------------------------------------------------------- |
|
256 string CATMemoryAddress::GetFunctionName() |
|
257 { |
|
258 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetFunctionName"); |
|
259 return m_sFunctionName; |
|
260 } |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // CATMemoryAddress::SetFunctionLineNumber |
|
264 // ----------------------------------------------------------------------------- |
|
265 void CATMemoryAddress::SetFunctionLineNumber(int iFunctionLineNumber) |
|
266 { |
|
267 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetFunctionLineNumber"); |
|
268 m_iFunctionLineNumber = iFunctionLineNumber; |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CATMemoryAddress::GetFunctionLineNumber |
|
273 // ----------------------------------------------------------------------------- |
|
274 int CATMemoryAddress::GetFunctionLineNumber() |
|
275 { |
|
276 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetFunctionLineNumber"); |
|
277 return m_iFunctionLineNumber; |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // CATMemoryAddress::SetExactLineNumber |
|
282 // ----------------------------------------------------------------------------- |
|
283 void CATMemoryAddress::SetExactLineNumber(int iExactLineNumber) |
|
284 { |
|
285 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetExactLineNumber"); |
|
286 m_iExactLineNumber = iExactLineNumber; |
|
287 } |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // CATMemoryAddress::GetExactLineNumber |
|
291 // ----------------------------------------------------------------------------- |
|
292 int CATMemoryAddress::GetExactLineNumber() |
|
293 { |
|
294 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetExactLineNumber"); |
|
295 return m_iExactLineNumber; |
|
296 } |
|
297 |
|
298 // ----------------------------------------------------------------------------- |
|
299 // CATMemoryAddress::GetModuleStartAddress |
|
300 // ----------------------------------------------------------------------------- |
|
301 unsigned long CATMemoryAddress::GetModuleStartAddress() const |
|
302 { |
|
303 LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetModuleStartAddress"); |
|
304 return m_iModuleStartAddress; |
|
305 } |
|
306 |
|
307 //EOF |