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 |
|
18 #include "MemSpyDriverLogChanHeapWalk.h" |
|
19 |
|
20 // System includes |
|
21 #include <u32hal.h> |
|
22 #include <e32rom.h> |
|
23 #include <memspy/driver/memspydriverconstants.h> |
|
24 #include <memspy/driver/memspydriverobjectsshared.h> |
|
25 |
|
26 // Shared includes |
|
27 #include "MemSpyDriverOpCodes.h" |
|
28 #include "MemSpyDriverObjectsInternal.h" |
|
29 |
|
30 // User includes |
|
31 #include "MemSpyDriverHeap.h" |
|
32 #include "MemSpyDriverUtils.h" |
|
33 #include "MemSpyDriverDevice.h" |
|
34 #include "MemSpyDriverOSAdaption.h" |
|
35 #include "MemSpyDriverSuspensionManager.h" |
|
36 |
|
37 |
|
38 |
|
39 DMemSpyDriverLogChanHeapWalk::DMemSpyDriverLogChanHeapWalk( DMemSpyDriverDevice& aDevice, DThread& aThread ) |
|
40 : DMemSpyDriverLogChanHeapBase( aDevice, aThread ), iWalkHeap( aDevice.OSAdaption() ) |
|
41 { |
|
42 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::DMemSpyDriverLogChanHeapWalk() - this: 0x%08x", this )); |
|
43 } |
|
44 |
|
45 |
|
46 DMemSpyDriverLogChanHeapWalk::~DMemSpyDriverLogChanHeapWalk() |
|
47 { |
|
48 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::~DMemSpyDriverLogChanHeapWalk() - START - this: 0x%08x", this )); |
|
49 |
|
50 NKern::ThreadEnterCS(); |
|
51 |
|
52 WalkHeapClose(); |
|
53 |
|
54 NKern::ThreadLeaveCS(); |
|
55 |
|
56 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::~DMemSpyDriverLogChanHeapWalk() - END - this: 0x%08x", this )); |
|
57 } |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 TInt DMemSpyDriverLogChanHeapWalk::Request( TInt aFunction, TAny* a1, TAny* a2 ) |
|
66 { |
|
67 TInt r = DMemSpyDriverLogChanBase::Request( aFunction, a1, a2 ); |
|
68 if ( r == KErrNone ) |
|
69 { |
|
70 switch( aFunction ) |
|
71 { |
|
72 case EMemSpyDriverOpCodeWalkHeapInit: |
|
73 r = WalkHeapInit( (TMemSpyDriverInternalWalkHeapParamsInit*) a1 ); |
|
74 break; |
|
75 case EMemSpyDriverOpCodeWalkHeapGetCellInfo: |
|
76 r = WalkHeapGetCellInfo( (TAny*) a1, (TMemSpyDriverInternalWalkHeapParamsCell*) a2 ); |
|
77 break; |
|
78 case EMemSpyDriverOpCodeWalkHeapReadCellData: |
|
79 r = WalkHeapReadCellData( (TMemSpyDriverInternalWalkHeapCellDataReadParams*) a1 ); |
|
80 break; |
|
81 case EMemSpyDriverOpCodeWalkHeapNextCell: |
|
82 r = WalkHeapNextCell( (TUint) a1, (TMemSpyDriverInternalWalkHeapParamsCell*) a2 ); |
|
83 break; |
|
84 case EMemSpyDriverOpCodeWalkHeapClose: |
|
85 r = WalkHeapClose(); |
|
86 break; |
|
87 |
|
88 default: |
|
89 r = KErrNotSupported; |
|
90 break; |
|
91 } |
|
92 } |
|
93 // |
|
94 return r; |
|
95 } |
|
96 |
|
97 |
|
98 TBool DMemSpyDriverLogChanHeapWalk::IsHandler( TInt aFunction ) const |
|
99 { |
|
100 return ( aFunction > EMemSpyDriverOpCodeWalkHeapBase && aFunction < EMemSpyDriverOpCodeWalkHeapEnd ); |
|
101 } |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 TInt DMemSpyDriverLogChanHeapWalk::WalkHeapInit( TMemSpyDriverInternalWalkHeapParamsInit* aParams ) |
|
125 { |
|
126 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit() - START")); |
|
127 __ASSERT_ALWAYS( !iHeapWalkInitialised && iWalkHeap.Helper() == NULL, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkPending ) ); |
|
128 |
|
129 TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, &iHeapWalkInitialParameters, sizeof(TMemSpyDriverInternalWalkHeapParamsInit) ); |
|
130 if ( r == KErrNone ) |
|
131 { |
|
132 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - thread id: %d, vtable: 0x%08x, debugAllocator: %d", iHeapWalkInitialParameters.iTid, iHeapWalkInitialParameters.iRHeapVTable, iHeapWalkInitialParameters.iDebugAllocator)); |
|
133 |
|
134 r = OpenTempObject( iHeapWalkInitialParameters.iTid, EThread ); |
|
135 if ( r == KErrNone ) |
|
136 { |
|
137 // Find the chunk with the correct handle |
|
138 DThread* thread = (DThread*) TempObject(); |
|
139 if ( SuspensionManager().IsSuspended( *thread ) ) |
|
140 { |
|
141 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - thread: %O", thread)); |
|
142 |
|
143 // Open client's heap |
|
144 r = iWalkHeap.OpenUserHeap(*thread, iHeapWalkInitialParameters.iDebugAllocator); |
|
145 |
|
146 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - opening client heap returned: %d", r) ); |
|
147 |
|
148 if ( r == KErrNone ) |
|
149 { |
|
150 // Indicates that we've initiated a walk - so we can tell whether to close |
|
151 // the chunk later on. |
|
152 iHeapWalkInitialised = ETrue; |
|
153 iWalkHeapCellIndex = 0; |
|
154 |
|
155 // Walk the client's heap |
|
156 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - calling heap walker constructor...")); |
|
157 RMemSpyDriverHeapWalker heapWalker(iWalkHeap); |
|
158 |
|
159 TMemSpyDriverLogChanHeapWalkObserver observer( *this ); |
|
160 heapWalker.SetObserver( &observer ); |
|
161 |
|
162 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - starting traversal...")); |
|
163 r = heapWalker.Traverse(); |
|
164 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - finished traversal - err: %d", r)); |
|
165 } |
|
166 |
|
167 // If the initialise process didn't complete successfully, then we must be sure |
|
168 // to release the associated heap chunk |
|
169 if ( r < KErrNone ) |
|
170 { |
|
171 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - error scenario - releasing kernel heap chunk copy" )); |
|
172 iWalkHeap.Close(); |
|
173 } |
|
174 } |
|
175 else |
|
176 { |
|
177 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - parent process not suspended => KErrAccessDenied")); |
|
178 r = KErrAccessDenied; |
|
179 } |
|
180 |
|
181 CloseTempObject(); |
|
182 } |
|
183 else |
|
184 { |
|
185 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - thread not found")); |
|
186 } |
|
187 } |
|
188 else |
|
189 { |
|
190 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - params read error: %d", r)); |
|
191 } |
|
192 |
|
193 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit() - END - ret: %d", r)); |
|
194 return r; |
|
195 } |
|
196 |
|
197 |
|
198 TInt DMemSpyDriverLogChanHeapWalk::WalkHeapNextCell( TUint aTid, TMemSpyDriverInternalWalkHeapParamsCell* aParams ) |
|
199 { |
|
200 const TInt walkedHeapCellCount = iWalkHeapCells.Count(); |
|
201 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapNextCell() - START - current cell count: %d", walkedHeapCellCount)); |
|
202 __ASSERT_ALWAYS( iHeapWalkInitialised && iWalkHeap.Helper(), MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkNotInitialised ) ); |
|
203 |
|
204 // Open the original thread |
|
205 TInt r = OpenTempObject( aTid, EThread ); |
|
206 if ( r == KErrNone ) |
|
207 { |
|
208 // Get the thread handle and that we have suspended the process' threads |
|
209 DThread* thread = (DThread*) TempObject(); |
|
210 if ( SuspensionManager().IsSuspended( *thread ) ) |
|
211 { |
|
212 NKern::ThreadEnterCS(); |
|
213 |
|
214 if ( walkedHeapCellCount > 0 && iWalkHeapCellIndex >= 0 && iWalkHeapCellIndex < walkedHeapCellCount ) |
|
215 { |
|
216 // Write back head cell to user-space |
|
217 TMemSpyDriverInternalWalkHeapParamsCell cell( iWalkHeapCells[ iWalkHeapCellIndex++ ] ); |
|
218 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapNextCell - returning... cellType: %1d, addr: 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d", cell.iCellType, cell.iCellAddress, cell.iLength, cell.iNestingLevel, cell.iAllocNumber )); |
|
219 |
|
220 r = Kern::ThreadRawWrite( &ClientThread(), aParams, &cell, sizeof(TMemSpyDriverInternalWalkHeapParamsCell) ); |
|
221 if ( r != KErrNone ) |
|
222 { |
|
223 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapNextCell - params read error: %d", r)); |
|
224 } |
|
225 } |
|
226 else |
|
227 { |
|
228 r = KErrEof; |
|
229 } |
|
230 |
|
231 NKern::ThreadLeaveCS(); |
|
232 } |
|
233 else |
|
234 { |
|
235 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapNextCell - parent process not suspended => KErrAccessDenied")); |
|
236 r = KErrAccessDenied; |
|
237 } |
|
238 |
|
239 CloseTempObject(); |
|
240 } |
|
241 else |
|
242 { |
|
243 Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapNextCell - thread not found"); |
|
244 } |
|
245 // |
|
246 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapNextCell() - END - ret: %d", r)); |
|
247 return r; |
|
248 } |
|
249 |
|
250 |
|
251 TInt DMemSpyDriverLogChanHeapWalk::WalkHeapClose() |
|
252 { |
|
253 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapClose() - START")); |
|
254 // |
|
255 if ( iHeapWalkInitialised ) |
|
256 { |
|
257 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapClose - heap walk was still open...")); |
|
258 NKern::ThreadEnterCS(); |
|
259 |
|
260 iWalkHeap.Close(); |
|
261 |
|
262 // Discard handled cells |
|
263 iWalkHeapCells.Reset(); |
|
264 |
|
265 iHeapWalkInitialised = EFalse; |
|
266 |
|
267 NKern::ThreadLeaveCS(); |
|
268 } |
|
269 // |
|
270 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapClose() - END")); |
|
271 return KErrNone; |
|
272 } |
|
273 |
|
274 |
|
275 TInt DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData(TMemSpyDriverInternalWalkHeapCellDataReadParams* aParams) |
|
276 { |
|
277 __ASSERT_ALWAYS( iHeapWalkInitialised && iWalkHeap.Helper(), MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkNotInitialised ) ); |
|
278 // |
|
279 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData() - START - thread id: %d, vtable: 0x%08x", iHeapWalkInitialParameters.iTid, iHeapWalkInitialParameters.iRHeapVTable)); |
|
280 // |
|
281 TMemSpyDriverInternalWalkHeapCellDataReadParams params; |
|
282 TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverInternalWalkHeapCellDataReadParams) ); |
|
283 if ( r != KErrNone ) |
|
284 { |
|
285 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData() - END - params read error: %d", r)); |
|
286 return r; |
|
287 } |
|
288 |
|
289 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - cell: 0x%08x, readLen: %8d, writeAddr: 0x%08x", params.iCellAddress, params.iReadLen, params.iDes)); |
|
290 |
|
291 // Open the original thread |
|
292 r = OpenTempObject( iHeapWalkInitialParameters.iTid, EThread ); |
|
293 if ( r == KErrNone ) |
|
294 { |
|
295 // Get the thread handle |
|
296 DThread* thread = (DThread*) TempObject(); |
|
297 |
|
298 // Check the threads in the process are suspended |
|
299 if ( SuspensionManager().IsSuspended( *thread ) ) |
|
300 { |
|
301 // Check we can find the cell in the cell list... |
|
302 const TMemSpyDriverInternalWalkHeapParamsCell* cell = CellInfoForSpecificAddress( params.iCellAddress ); |
|
303 |
|
304 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - cell: 0x%08x for address: 0x%08x", cell, params.iCellAddress )); |
|
305 |
|
306 if ( cell ) |
|
307 { |
|
308 const TInt cellLen = cell->iLength; |
|
309 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - cellLen: %d", cellLen )); |
|
310 |
|
311 if ( params.iReadLen <= cellLen ) |
|
312 { |
|
313 |
|
314 // Get user side descriptor length info |
|
315 TInt destLen = 0; |
|
316 TInt destMax = 0; |
|
317 TUint8* destPtr = NULL; |
|
318 |
|
319 r = Kern::ThreadGetDesInfo( &ClientThread(), params.iDes, destLen, destMax, destPtr, ETrue ); |
|
320 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - user side descriptor: 0x%08x (0x%08x), len: %8d, maxLen: %8d, r: %d", params.iDes, destPtr, destLen, destMax, r )); |
|
321 |
|
322 // Work out the start offset for the data... |
|
323 if ( r == KErrNone && destMax >= params.iReadLen ) |
|
324 { |
|
325 const TAny* srcPos = ((TUint8*) cell->iCellAddress); |
|
326 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - srcPos: 0x%08x", srcPos )); |
|
327 |
|
328 // Read some data |
|
329 r = Kern::ThreadRawRead( thread, srcPos, destPtr, params.iReadLen ); |
|
330 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - read from thread returned: %d", r)); |
|
331 |
|
332 if ( r == KErrNone ) |
|
333 { |
|
334 // Client will update descriptor length in this situation. |
|
335 r = params.iReadLen; |
|
336 } |
|
337 } |
|
338 else |
|
339 { |
|
340 if ( r != KErrBadDescriptor ) |
|
341 { |
|
342 r = KErrArgument; |
|
343 Kern::Printf( "DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - error - user-descriptor isnt big enough for requested data" ); |
|
344 } |
|
345 else |
|
346 { |
|
347 Kern::Printf( "DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - error - bad or non-writable user-side descriptor" ); |
|
348 } |
|
349 } |
|
350 } |
|
351 else |
|
352 { |
|
353 r = KErrArgument; |
|
354 Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - error - read length is bigger than cell length"); |
|
355 } |
|
356 } |
|
357 else |
|
358 { |
|
359 r = KErrArgument; |
|
360 Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - no cell at user supplied address!"); |
|
361 } |
|
362 } |
|
363 else |
|
364 { |
|
365 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - parent process not suspended => KErrAccessDenied")); |
|
366 r = KErrAccessDenied; |
|
367 } |
|
368 |
|
369 CloseTempObject(); |
|
370 } |
|
371 else |
|
372 { |
|
373 Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - thread not found"); |
|
374 } |
|
375 // |
|
376 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData() - END result=%d", r)); |
|
377 return r; |
|
378 } |
|
379 |
|
380 |
|
381 TInt DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo( TAny* aCellAddress, TMemSpyDriverInternalWalkHeapParamsCell* aParams ) |
|
382 { |
|
383 __ASSERT_ALWAYS( iHeapWalkInitialised && iWalkHeap.Helper(), MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkNotInitialised ) ); |
|
384 // |
|
385 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo() - START - thread id: %d, vtable: 0x%08x", iHeapWalkInitialParameters.iTid, iHeapWalkInitialParameters.iRHeapVTable)); |
|
386 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - cell: 0x%08x", aCellAddress)); |
|
387 |
|
388 // Open the original thread |
|
389 TInt r = OpenTempObject( iHeapWalkInitialParameters.iTid, EThread ); |
|
390 if (r != KErrNone) |
|
391 { |
|
392 Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo() - END - thread not found"); |
|
393 return r; |
|
394 } |
|
395 |
|
396 // Get the thread handle |
|
397 DThread* thread = (DThread*) TempObject(); |
|
398 |
|
399 // Check the threads in the process are suspended |
|
400 if ( !SuspensionManager().IsSuspended( *thread ) ) |
|
401 { |
|
402 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - END - parent process not suspended => KErrAccessDenied")); |
|
403 CloseTempObject(); |
|
404 return KErrAccessDenied; |
|
405 } |
|
406 |
|
407 // Check we can find the cell in the cell list... |
|
408 const TMemSpyDriverInternalWalkHeapParamsCell* cell = CellInfoForSpecificAddress( aCellAddress ); |
|
409 if ( cell == NULL ) |
|
410 { |
|
411 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - no exact match for address: 0x%08x...", aCellAddress)); |
|
412 |
|
413 // If the cell still wasn't found, then let's look for any heap cell that contains |
|
414 // the client-specified address (i.e. find the heap cell that contains the specified |
|
415 // address). |
|
416 if ( cell == NULL ) |
|
417 { |
|
418 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - still couldnt find cell by exact address. Searching for the cell that contains the specified address...")); |
|
419 cell = CellInfoForAddressWithinCellRange( aCellAddress ); |
|
420 } |
|
421 } |
|
422 |
|
423 if ( cell ) |
|
424 { |
|
425 // Have enough info to write back to client now |
|
426 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - returning... cellType: %1d, addr: 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d", cell->iCellType, cell->iCellAddress, cell->iLength, cell->iNestingLevel, cell->iAllocNumber )); |
|
427 r = Kern::ThreadRawWrite( &ClientThread(), aParams, cell, sizeof(TMemSpyDriverInternalWalkHeapParamsCell) ); |
|
428 } |
|
429 else |
|
430 { |
|
431 r = KErrArgument; |
|
432 Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - no cell at user supplied address!"); |
|
433 } |
|
434 |
|
435 CloseTempObject(); |
|
436 // |
|
437 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo() - END result=%d", r)); |
|
438 return r; |
|
439 } |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 const TMemSpyDriverInternalWalkHeapParamsCell* DMemSpyDriverLogChanHeapWalk::CellInfoForAddressWithinCellRange( TAny* aAddress ) const |
|
468 { |
|
469 const TMemSpyDriverInternalWalkHeapParamsCell* ret = NULL; |
|
470 // |
|
471 const TInt count = iWalkHeapCells.Count(); |
|
472 for(TInt i=0; i<count; i++) |
|
473 { |
|
474 const TMemSpyDriverInternalWalkHeapParamsCell& item = iWalkHeapCells[i]; |
|
475 const TAny* cellExtent = (TAny*) (TUint32( item.iCellAddress ) + item.iLength); |
|
476 // |
|
477 if ( aAddress >= item.iCellAddress && aAddress < cellExtent ) |
|
478 { |
|
479 ret = &item; |
|
480 } |
|
481 } |
|
482 // |
|
483 return ret; |
|
484 } |
|
485 |
|
486 |
|
487 const TMemSpyDriverInternalWalkHeapParamsCell* DMemSpyDriverLogChanHeapWalk::CellInfoForSpecificAddress( TAny* aAddress ) const |
|
488 { |
|
489 const TMemSpyDriverInternalWalkHeapParamsCell* ret = NULL; |
|
490 // |
|
491 const TInt count = iWalkHeapCells.Count(); |
|
492 for(TInt i=0; i<count; i++) |
|
493 { |
|
494 const TMemSpyDriverInternalWalkHeapParamsCell& item = iWalkHeapCells[i]; |
|
495 if ( item.iCellAddress == aAddress ) |
|
496 { |
|
497 ret = &item; |
|
498 } |
|
499 } |
|
500 // |
|
501 return ret; |
|
502 } |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 TBool DMemSpyDriverLogChanHeapWalk::WalkerHandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber ) |
|
520 { |
|
521 TInt error = KErrNone; |
|
522 // |
|
523 if ( iHeapWalkInitialised ) |
|
524 { |
|
525 TMemSpyDriverInternalWalkHeapParamsCell cell; |
|
526 cell.iCellType = aCellType; |
|
527 cell.iCellAddress = aCellAddress; |
|
528 cell.iLength = aLength; |
|
529 cell.iNestingLevel = aNestingLevel; |
|
530 cell.iAllocNumber = aAllocNumber; |
|
531 // |
|
532 NKern::ThreadEnterCS(); |
|
533 error = iWalkHeapCells.Append( cell ); |
|
534 NKern::ThreadLeaveCS(); |
|
535 } |
|
536 // |
|
537 return ( error == KErrNone ); |
|
538 } |
|