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 <memspy/driver/memspydriverclient.h> |
|
19 |
|
20 // System includes |
|
21 #include <e32svr.h> |
|
22 |
|
23 // User includes |
|
24 #include "MemSpyDriverOpCodes.h" |
|
25 #include <memspy/driver/memspydriverconstants.h> |
|
26 #include <memspy/driver/memspydriverobjectsshared.h> |
|
27 #include "MemSpyDriverStreamReaderImp.h" |
|
28 #include "MemSpyDriverObjectsInternal.h" |
|
29 #include "heaputils.h" |
|
30 |
|
31 // Constants |
|
32 const TInt KMemSpyClientBufferGrowSize = 0x1000 * 8; // 32kb |
|
33 |
|
34 // Forward declarations |
|
35 static void PrintHeapInfo( const TMemSpyHeapInfo& aInfo ); |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 EXPORT_C TInt RMemSpyDriverClient::Open() |
|
41 { |
|
42 TInt err = iBuffer.Create( KMemSpyClientBufferGrowSize ); |
|
43 if ( err == KErrNone ) |
|
44 { |
|
45 err = User::LoadLogicalDevice( KMemSpyDriverDeviceName ); |
|
46 if ( err == KErrNone || err == KErrAlreadyExists ) |
|
47 { |
|
48 err = DoCreate( KMemSpyDriverDeviceName, KMemSpyDriverVersion(), KNullUnit, NULL, NULL, EOwnerThread ); |
|
49 if ( err == KErrNone ) |
|
50 { |
|
51 TUint heapVTable = RHeapVTable(); |
|
52 err = DoControl( EMemSpyDriverOpCodeMiscSetRHeapVTable, (TAny*) heapVTable ); |
|
53 } |
|
54 } |
|
55 } |
|
56 // |
|
57 if ( err != KErrNone ) |
|
58 { |
|
59 RDebug::Printf( "[MemSpy] RMemSpyDriverClient::Open() - END - err: %d", err ); |
|
60 } |
|
61 // |
|
62 return err; |
|
63 } |
|
64 |
|
65 |
|
66 |
|
67 EXPORT_C void RMemSpyDriverClient::Close() |
|
68 { |
|
69 RBusLogicalChannel::Close(); |
|
70 const TInt err = User::FreeLogicalDevice( KMemSpyDriverDeviceName ); |
|
71 // |
|
72 if ( err != KErrNone ) |
|
73 { |
|
74 RDebug::Printf( "[MemSpy] RMemSpyDriverClient::Close() - free logical device error: %d", err ); |
|
75 } |
|
76 // |
|
77 iBuffer.Close(); |
|
78 (void) err; |
|
79 } |
|
80 |
|
81 |
|
82 EXPORT_C void RMemSpyDriverClient::GetVersion( TVersion& aVersion ) |
|
83 { |
|
84 TVersion v = KMemSpyDriverVersion(); |
|
85 Mem::Copy( (TAny*)&aVersion, (TAny*)&v, sizeof( TVersion ) ); |
|
86 } |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 EXPORT_C TInt RMemSpyDriverClient::ReadMemory( TUint aTid, TLinAddr aSrc, TDes8& aDest ) |
|
107 { |
|
108 TMemSpyDriverInternalReadMemParams params; |
|
109 params.iTid = aTid; |
|
110 params.iAddr = aSrc; |
|
111 params.iDes = &aDest; |
|
112 aDest.Zero(); |
|
113 // |
|
114 TInt r = DoControl( EMemSpyDriverOpCodeRawMemoryRead, ¶ms, NULL ); |
|
115 if ( r >= KErrNone ) |
|
116 { |
|
117 aDest.SetLength( r ); |
|
118 r = KErrNone; |
|
119 } |
|
120 // |
|
121 return r; |
|
122 } |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 EXPORT_C TInt RMemSpyDriverClient::GetCodeSegs( TAny** aHandleArray, TInt& aHandleCount, TBool aOnlyRamLoaded ) |
|
138 { |
|
139 TMemSpyDriverInternalCodeSnapshotParams params; |
|
140 params.iFilter = aOnlyRamLoaded; |
|
141 params.iHandles = aHandleArray; |
|
142 params.iCountPtr = &aHandleCount; |
|
143 params.iMaxCount = aHandleCount; |
|
144 // |
|
145 aHandleCount = 0; |
|
146 // |
|
147 return DoControl( EMemSpyDriverOpCodeCodeSegsGetAll, ¶ms, NULL ); |
|
148 } |
|
149 |
|
150 |
|
151 EXPORT_C TInt RMemSpyDriverClient::GetCodeSegs( TUint aPid, TAny** aHandleArray, TInt& aHandleCount ) |
|
152 { |
|
153 TMemSpyDriverInternalCodeSnapshotParams params; |
|
154 params.iFilter = aPid; |
|
155 params.iHandles = aHandleArray; |
|
156 params.iCountPtr = &aHandleCount; |
|
157 params.iMaxCount = aHandleCount; |
|
158 // |
|
159 aHandleCount = 0; |
|
160 // |
|
161 return DoControl( EMemSpyDriverOpCodeCodeSegsGetCodeSegsForProcess, ¶ms, NULL ); |
|
162 } |
|
163 |
|
164 |
|
165 EXPORT_C TInt RMemSpyDriverClient::GetCodeSegInfo( TAny* aHandle, TUint aPid, TMemSpyDriverCodeSegInfo& aInfo ) |
|
166 { |
|
167 TMemSpyDriverInternalCodeSegParams params; |
|
168 params.iPid = aPid; |
|
169 params.iHandle = aHandle; |
|
170 params.iInfoPointer = &aInfo; |
|
171 // |
|
172 const TInt r = DoControl( EMemSpyDriverOpCodeCodeSegsGetCodeSegInfo, ¶ms, NULL ); |
|
173 return r; |
|
174 } |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 EXPORT_C TInt RMemSpyDriverClient::GetChunkHandles( TAny** aHandleArray, TInt& aHandleCount ) |
|
203 { |
|
204 TMemSpyDriverInternalChunkHandleParams params; |
|
205 params.iId = 0; |
|
206 params.iType = EMemSpyDriverPrivateObjectTypeAll; |
|
207 params.iHandles = aHandleArray; |
|
208 params.iCountPtr = &aHandleCount; |
|
209 params.iMaxCount = aHandleCount; |
|
210 // |
|
211 aHandleCount = 0; |
|
212 // |
|
213 const TInt err = DoControl( EMemSpyDriverOpCodeChunkGetHandles, ¶ms, NULL ); |
|
214 return err; |
|
215 } |
|
216 |
|
217 |
|
218 EXPORT_C TInt RMemSpyDriverClient::GetChunkInfo( TAny* aHandle, TMemSpyDriverChunkInfo& aInfo ) |
|
219 { |
|
220 TMemSpyDriverInternalChunkInfoParams params; |
|
221 TBuf8<KMaxFullName> name; |
|
222 params.iHandle = aHandle; |
|
223 const TInt r = DoControl( EMemSpyDriverOpCodeChunkGetInfo, ¶ms, NULL ); |
|
224 // |
|
225 if ( r == KErrNone ) |
|
226 { |
|
227 aInfo.iHandle = aHandle; |
|
228 aInfo.iBaseAddress = params.iBaseAddress; |
|
229 aInfo.iSize = params.iSize; |
|
230 aInfo.iMaxSize = params.iMaxSize; |
|
231 aInfo.iOwnerId = params.iOwnerId; |
|
232 aInfo.iType = params.iType; |
|
233 aInfo.iAttributes = params.iAttributes; |
|
234 aInfo.iName.Copy( params.iName ); |
|
235 } |
|
236 // |
|
237 return r; |
|
238 } |
|
239 |
|
240 |
|
241 EXPORT_C TInt RMemSpyDriverClient::GetChunkInfo( TAny* aHandle, TMemSpyDriverChunkInfoWithoutName& aInfo ) |
|
242 { |
|
243 TMemSpyDriverChunkInfo info; |
|
244 // |
|
245 const TInt r = GetChunkInfo( aHandle, info ); |
|
246 if ( r == KErrNone ) |
|
247 { |
|
248 aInfo = info; |
|
249 } |
|
250 // |
|
251 return r; |
|
252 } |
|
253 |
|
254 |
|
255 EXPORT_C TInt RMemSpyDriverClient::GetChunkHandlesForProcess( TUint aPid, TAny** aHandleArray, TInt& aHandleCount ) |
|
256 { |
|
257 TMemSpyDriverInternalChunkHandleParams params; |
|
258 params.iId = aPid; |
|
259 params.iType = EMemSpyDriverPrivateObjectTypeProcess; |
|
260 params.iHandles = aHandleArray; |
|
261 params.iCountPtr = &aHandleCount; |
|
262 params.iMaxCount = aHandleCount; |
|
263 // |
|
264 aHandleCount = 0; |
|
265 // |
|
266 return DoControl( EMemSpyDriverOpCodeChunkGetHandles, ¶ms, NULL ); |
|
267 } |
|
268 |
|
269 |
|
270 EXPORT_C TInt RMemSpyDriverClient::GetChunkHandlesForThread( TUint aTid, TAny** aHandleArray, TInt& aHandleCount ) |
|
271 { |
|
272 TMemSpyDriverInternalChunkHandleParams params; |
|
273 params.iId = aTid; |
|
274 params.iType = EMemSpyDriverPrivateObjectTypeThread; |
|
275 params.iHandles = aHandleArray; |
|
276 params.iCountPtr = &aHandleCount; |
|
277 params.iMaxCount = aHandleCount; |
|
278 // |
|
279 aHandleCount = 0; |
|
280 // |
|
281 return DoControl( EMemSpyDriverOpCodeChunkGetHandles, ¶ms, NULL ); |
|
282 } |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 EXPORT_C TInt RMemSpyDriverClient::GetThreadInfo( TUint aTid, TMemSpyDriverThreadInfo& aInfo ) |
|
305 { |
|
306 TMemSpyDriverInternalThreadInfoParams params; |
|
307 params.iRHeapVTable = RHeapVTable(); |
|
308 params.iDebugAllocator = DebugEUser(); |
|
309 // |
|
310 TInt r = DoControl( EMemSpyDriverOpCodeThreadAndProcessGetInfoThread, (TAny*)aTid, ¶ms); |
|
311 // |
|
312 if ( r == KErrNone ) |
|
313 { |
|
314 // Copy common properties |
|
315 Mem::Copy( &aInfo, ¶ms, sizeof( TMemSpyDriverThreadInfoBase ) ); |
|
316 |
|
317 // Copy name |
|
318 aInfo.iFullName.Copy( params.iFullName ); |
|
319 |
|
320 // Get other basic properties via RThread |
|
321 RThread thread; |
|
322 r = OpenThread( aTid, thread ); |
|
323 if ( r == KErrNone ) |
|
324 { |
|
325 RProcess process; |
|
326 r = thread.Process( process ); |
|
327 if ( r == KErrNone ) |
|
328 { |
|
329 aInfo.iPid = process.Id(); |
|
330 process.Close(); |
|
331 } |
|
332 |
|
333 aInfo.iThreadPriority = thread.Priority(); |
|
334 aInfo.iExitReason = thread.ExitReason(); |
|
335 aInfo.iExitType = thread.ExitType(); |
|
336 aInfo.iExitCategory = thread.ExitCategory(); |
|
337 |
|
338 thread.Close(); |
|
339 } |
|
340 } |
|
341 |
|
342 return r; |
|
343 } |
|
344 |
|
345 EXPORT_C TInt RMemSpyDriverClient::GetProcessInfo( TUint aPid, TMemSpyDriverProcessInfo& aInfo ) |
|
346 { |
|
347 TInt r = DoControl( EMemSpyDriverOpCodeThreadAndProcessGetInfoProcess, (TAny*)aPid, &aInfo); |
|
348 |
|
349 // Get other properties via RProcess. |
|
350 if ( r == KErrNone ) |
|
351 { |
|
352 RProcess process; |
|
353 r = OpenProcess( aPid, process ); |
|
354 if ( r == KErrNone ) |
|
355 { |
|
356 aInfo.iUids = process.Type(); |
|
357 aInfo.iPriority = process.Priority(); |
|
358 // |
|
359 process.Close(); |
|
360 } |
|
361 } |
|
362 |
|
363 return r; |
|
364 } |
|
365 |
|
366 |
|
367 EXPORT_C TInt RMemSpyDriverClient::ProcessThreadsSuspend( TUint aPid ) |
|
368 { |
|
369 return DoControl( EMemSpyDriverOpCodeThreadAndProcessSuspendAllThreads, (TAny*) aPid, NULL ); |
|
370 } |
|
371 |
|
372 |
|
373 EXPORT_C TInt RMemSpyDriverClient::ProcessThreadsResume( TUint aPid ) |
|
374 { |
|
375 return DoControl( EMemSpyDriverOpCodeThreadAndProcessResumeAllThreads, (TAny*) aPid, NULL ); |
|
376 } |
|
377 |
|
378 |
|
379 EXPORT_C TInt RMemSpyDriverClient::ThreadEnd( TUint aId, TExitType aType ) |
|
380 { |
|
381 TInt err = KErrNone; |
|
382 // |
|
383 if ( aType == EExitPending ) |
|
384 { |
|
385 err = KErrArgument; |
|
386 } |
|
387 else |
|
388 { |
|
389 err = DoControl( EMemSpyDriverOpCodeThreadAndProcessEndThread, (TAny*) aId, (TAny*) aType ); |
|
390 } |
|
391 // |
|
392 return err; |
|
393 } |
|
394 |
|
395 |
|
396 EXPORT_C TInt RMemSpyDriverClient::OpenThread( TUint aId, RThread& aThread ) |
|
397 { |
|
398 TInt ret = KErrNone; |
|
399 aThread.Close(); |
|
400 // |
|
401 const TInt err = DoControl( EMemSpyDriverOpCodeThreadAndProcessOpenThread, (TAny*) aId ); |
|
402 if ( err > 0 ) |
|
403 { |
|
404 aThread.SetHandle( err ); |
|
405 ret = KErrNone; |
|
406 } |
|
407 else |
|
408 { |
|
409 ret = err; |
|
410 } |
|
411 // |
|
412 return ret; |
|
413 } |
|
414 |
|
415 |
|
416 EXPORT_C TInt RMemSpyDriverClient::OpenProcess( TUint aId, RProcess& aProcess ) |
|
417 { |
|
418 TInt ret = KErrNone; |
|
419 aProcess.Close(); |
|
420 // |
|
421 const TInt err = DoControl( EMemSpyDriverOpCodeThreadAndProcessOpenProcess, (TAny*) aId ); |
|
422 if ( err > 0 ) |
|
423 { |
|
424 aProcess.SetHandle( err ); |
|
425 ret = KErrNone; |
|
426 } |
|
427 else |
|
428 { |
|
429 ret = err; |
|
430 } |
|
431 // |
|
432 return ret; |
|
433 } |
|
434 |
|
435 |
|
436 EXPORT_C void RMemSpyDriverClient::GetThreadsL( const TProcessId& aId, RArray<TThreadId>& aThreads ) |
|
437 { |
|
438 aThreads.Reset(); |
|
439 // |
|
440 ResetStreamBuffer(); |
|
441 const TInt err = DoControl( EMemSpyDriverOpCodeThreadAndProcessGetThreads, (TAny*) (TUint) aId, (TAny*) &iBuffer ); |
|
442 User::LeaveIfError( err ); |
|
443 |
|
444 // Open stream |
|
445 RMemSpyMemStreamReader stream = StreamOpenL(); |
|
446 CleanupClosePushL( stream ); |
|
447 |
|
448 // Extract thread ids |
|
449 const TInt threadCount = stream.ReadInt32L(); |
|
450 for( TInt i=0; i<threadCount; i++ ) |
|
451 { |
|
452 const TThreadId id( stream.ReadUint32L() ); |
|
453 aThreads.AppendL( id ); |
|
454 } |
|
455 |
|
456 // Tidy up |
|
457 CleanupStack::PopAndDestroy( &stream ); |
|
458 } |
|
459 |
|
460 |
|
461 EXPORT_C TInt RMemSpyDriverClient::SetPriority( TUint aId, TThreadPriority aPriority ) |
|
462 { |
|
463 // The kernel side API to set thread priority expects a value in the range of 0-63, i.e. an absolute |
|
464 // NThread priority. In order to support process-relative thread priorities, we'd need to duplicate |
|
465 // the kernel priority mapping tables - not a good idea - therefore we'll only support absolute values. |
|
466 TInt err = KErrNone; |
|
467 if ( aPriority < EPriorityAbsoluteVeryLow ) |
|
468 { |
|
469 err = KErrArgument; |
|
470 } |
|
471 else |
|
472 { |
|
473 err = DoControl( EMemSpyDriverOpCodeThreadAndProcessSetPriorityThread, (TAny*) aId, (TAny*) aPriority ); |
|
474 } |
|
475 // |
|
476 return err; |
|
477 } |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 EXPORT_C TInt RMemSpyDriverClient::GetHeapInfoUser( TMemSpyHeapInfo& aInfo, TUint aTid ) |
|
494 { |
|
495 TMemSpyDriverInternalHeapRequestParameters params; |
|
496 // |
|
497 params.iTid = aTid; |
|
498 params.iRHeapVTable = RHeapVTable(); |
|
499 params.iDebugAllocator = DebugEUser(); |
|
500 params.iMasterInfo = &aInfo; |
|
501 // |
|
502 TInt r = DoControl( EMemSpyDriverOpCodeHeapInfoGetUser, ¶ms, NULL ); |
|
503 // |
|
504 if ( r == KErrNone ) |
|
505 { |
|
506 PrintHeapInfo( aInfo ); |
|
507 |
|
508 // Need to do this on the user-side |
|
509 if ( aInfo.Type() == TMemSpyHeapInfo::ETypeRHeap ) |
|
510 { |
|
511 TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap(); |
|
512 TMemSpyHeapMetaDataRHeap& metaData = rHeapInfo.MetaData(); |
|
513 metaData.SetVTable( RHeapVTable() ); |
|
514 //metaData.SetClassSize( sizeof( RHeap ) ); |
|
515 } |
|
516 } |
|
517 else if ( r == KErrNotSupported ) |
|
518 { |
|
519 aInfo.SetType( TMemSpyHeapInfo::ETypeUnknown ); |
|
520 r = KErrNone; |
|
521 } |
|
522 // |
|
523 return r; |
|
524 } |
|
525 |
|
526 EXPORT_C TInt RMemSpyDriverClient::GetHeapInfoUser( TMemSpyHeapInfo& aInfo, TUint aTid, RArray< TMemSpyDriverFreeCell >& aFreeCells ) |
|
527 { |
|
528 return GetHeapInfoUser(aInfo, aTid, aFreeCells, EFalse); |
|
529 } |
|
530 |
|
531 // For the record I don't think this function should be exported, but since the one above was I'm going with the flow. -TomS |
|
532 EXPORT_C TInt RMemSpyDriverClient::GetHeapInfoUser(TMemSpyHeapInfo& aInfo, TUint aTid, RArray<TMemSpyDriverCell>& aCells, TBool aCollectAllocatedCellsAsWellAsFree) |
|
533 { |
|
534 TMemSpyDriverInternalHeapRequestParameters params; |
|
535 // |
|
536 params.iTid = aTid; |
|
537 params.iRHeapVTable = RHeapVTable(); |
|
538 params.iDebugAllocator = DebugEUser(); |
|
539 params.iMasterInfo = &aInfo; |
|
540 params.iBuildFreeCellList = ETrue; |
|
541 params.iBuildAllocCellList = aCollectAllocatedCellsAsWellAsFree; |
|
542 |
|
543 // |
|
544 aCells.Reset(); |
|
545 ResetStreamBuffer(); |
|
546 TInt r = DoControl( EMemSpyDriverOpCodeHeapInfoGetUser, ¶ms ); |
|
547 // |
|
548 if ( r >= KErrNone ) |
|
549 { |
|
550 PrintHeapInfo( aInfo ); |
|
551 |
|
552 // Need to do this on the user-side |
|
553 if ( aInfo.Type() == TMemSpyHeapInfo::ETypeRHeap ) |
|
554 { |
|
555 TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap(); |
|
556 TMemSpyHeapMetaDataRHeap& metaData = rHeapInfo.MetaData(); |
|
557 metaData.SetVTable( RHeapVTable() ); |
|
558 //metaData.SetClassSize( sizeof( RHeap ) ); |
|
559 } |
|
560 |
|
561 // Resize transfer buffer to make room for free cells. We only make the buffer |
|
562 // bigger, not smaller. |
|
563 if ( iBuffer.Size() < r ) |
|
564 { |
|
565 r = iBuffer.ReAlloc( r ); |
|
566 } |
|
567 |
|
568 // Now fetch the heap data |
|
569 if ( r == KErrNone ) |
|
570 { |
|
571 r = DoControl( EMemSpyDriverOpCodeHeapInfoFetchCellList, &iBuffer ); |
|
572 if ( r == KErrNone ) |
|
573 { |
|
574 TRAP( r, ReadHeapInfoFreeCellsFromXferBufferL( aCells ) ); |
|
575 } |
|
576 } |
|
577 } |
|
578 else if ( r == KErrNotSupported ) |
|
579 { |
|
580 aInfo.SetType( TMemSpyHeapInfo::ETypeUnknown ); |
|
581 r = KErrNone; |
|
582 } |
|
583 // |
|
584 return r; |
|
585 } |
|
586 |
|
587 |
|
588 EXPORT_C TInt RMemSpyDriverClient::GetHeapInfoKernel( TMemSpyHeapInfo& aInfo ) |
|
589 { |
|
590 TMemSpyDriverInternalHeapRequestParameters params; |
|
591 params.iTid = KMemSpyDriverGetKernelHeapDataPseudoThreadId; |
|
592 params.iRHeapVTable = NULL; |
|
593 params.iMasterInfo = &aInfo; |
|
594 TInt r = DoControl( EMemSpyDriverOpCodeHeapInfoGetKernel, ¶ms, NULL ); |
|
595 // |
|
596 if ( r == KErrNone ) |
|
597 { |
|
598 PrintHeapInfo( aInfo ); |
|
599 } |
|
600 else if ( r == KErrNotSupported ) |
|
601 { |
|
602 aInfo.SetType( TMemSpyHeapInfo::ETypeUnknown ); |
|
603 r = KErrNone; |
|
604 } |
|
605 // |
|
606 return r; |
|
607 } |
|
608 |
|
609 |
|
610 EXPORT_C TInt RMemSpyDriverClient::GetHeapInfoKernel( TMemSpyHeapInfo& aInfo, RArray< TMemSpyDriverFreeCell >& aFreeCells ) |
|
611 { |
|
612 TMemSpyDriverInternalHeapRequestParameters params; |
|
613 params.iTid = KMemSpyDriverGetKernelHeapDataPseudoThreadId; |
|
614 params.iRHeapVTable = NULL; |
|
615 params.iMasterInfo = &aInfo; |
|
616 // |
|
617 aFreeCells.Reset(); |
|
618 ResetStreamBuffer(); |
|
619 TInt r = DoControl( EMemSpyDriverOpCodeHeapInfoGetKernel, ¶ms, (TAny*) &iBuffer ); |
|
620 // |
|
621 if ( r == KErrNone ) |
|
622 { |
|
623 PrintHeapInfo( aInfo ); |
|
624 TRAP( r, ReadHeapInfoFreeCellsFromXferBufferL( aFreeCells ) ); |
|
625 } |
|
626 else if ( r == KErrNotSupported ) |
|
627 { |
|
628 aInfo.SetType( TMemSpyHeapInfo::ETypeUnknown ); |
|
629 r = KErrNone; |
|
630 } |
|
631 // |
|
632 return r; |
|
633 } |
|
634 |
|
635 |
|
636 EXPORT_C TBool RMemSpyDriverClient::IsDebugKernel() |
|
637 { |
|
638 TBool isDebugKernel = EFalse; |
|
639 DoControl( EMemSpyDriverOpCodeHeapInfoGetIsDebugKernel, (TAny*) &isDebugKernel ); |
|
640 return isDebugKernel; |
|
641 } |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 EXPORT_C TInt RMemSpyDriverClient::GetHeapData( TUint aTid, TUint32 aFreeCellChecksum, TDes8& aDest, TUint& aReadAddress, TUint& aAmountRemaining ) |
|
665 { |
|
666 TMemSpyDriverInternalHeapDataParams params; |
|
667 params.iTid = aTid; |
|
668 params.iRHeapVTable = RHeapVTable(); |
|
669 params.iDebugAllocator = DebugEUser(); |
|
670 params.iDes = &aDest; |
|
671 params.iChecksum = aFreeCellChecksum; |
|
672 params.iRemaining = -1; |
|
673 params.iReadAddress = 0; |
|
674 aDest.Zero(); |
|
675 // |
|
676 TInt r = DoControl( EMemSpyDriverOpCodeHeapDataGetUser, ¶ms, NULL ); |
|
677 // |
|
678 if ( r >= KErrNone ) |
|
679 { |
|
680 aDest.SetLength( r ); |
|
681 aReadAddress = params.iReadAddress; |
|
682 aAmountRemaining = params.iRemaining; |
|
683 r = KErrNone; |
|
684 } |
|
685 // |
|
686 return r; |
|
687 } |
|
688 |
|
689 |
|
690 EXPORT_C TInt RMemSpyDriverClient::GetHeapDataNext( TUint aTid, TDes8& aDest, TUint& aReadAddress, TUint& aAmountRemaining ) |
|
691 { |
|
692 TMemSpyDriverInternalHeapDataParams params; |
|
693 params.iTid = aTid; |
|
694 params.iRHeapVTable = RHeapVTable(); |
|
695 params.iDebugAllocator = DebugEUser(); |
|
696 params.iDes = &aDest; |
|
697 params.iChecksum = 0; |
|
698 params.iRemaining = aAmountRemaining; |
|
699 params.iReadAddress = aReadAddress; |
|
700 aDest.Zero(); |
|
701 // |
|
702 TInt r = DoControl( EMemSpyDriverOpCodeHeapDataGetUser, ¶ms, NULL ); |
|
703 // |
|
704 if ( r >= KErrNone ) |
|
705 { |
|
706 aDest.SetLength( r ); |
|
707 aReadAddress = params.iReadAddress; |
|
708 aAmountRemaining = params.iRemaining; |
|
709 r = KErrNone; |
|
710 } |
|
711 // |
|
712 return r; |
|
713 } |
|
714 |
|
715 |
|
716 |
|
717 EXPORT_C HBufC8* RMemSpyDriverClient::GetHeapDataKernelLC( TMemSpyHeapInfo& aInfo, RArray<TMemSpyDriverFreeCell>& aFreeCells ) |
|
718 { |
|
719 HBufC8* data = NULL; |
|
720 |
|
721 // Going to fetch free cells via stream buffer... |
|
722 ResetStreamBuffer(); |
|
723 |
|
724 // First pass is to preallocate buffer for kernel heap, and fetch metadata and free cells |
|
725 TInt sizeOrError = DoControl( EMemSpyDriverOpCodeHeapDataGetKernelInit, (TAny*) &aInfo, (TAny*) &iBuffer ); |
|
726 if ( sizeOrError >= KErrNone ) |
|
727 { |
|
728 const TInt kernelHeapSize = sizeOrError; |
|
729 if ( aInfo.Type() != TMemSpyHeapInfo::ETypeRHeap ) |
|
730 { |
|
731 User::Leave( KErrNotSupported ); |
|
732 } |
|
733 else |
|
734 { |
|
735 // Extract free cells |
|
736 ReadHeapInfoFreeCellsFromXferBufferL( aFreeCells ); |
|
737 |
|
738 // It's okay to treat the heap info as an RHeap |
|
739 PrintHeapInfo( aInfo ); |
|
740 |
|
741 // Allocate data sink and do fetch |
|
742 data = HBufC8::NewLC( kernelHeapSize ); |
|
743 TPtr8 pBuffer( data->Des() ); |
|
744 |
|
745 sizeOrError = DoControl( EMemSpyDriverOpCodeHeapDataGetKernelFetch, &pBuffer, NULL ); |
|
746 } |
|
747 } |
|
748 |
|
749 User::LeaveIfError( sizeOrError ); |
|
750 return data; |
|
751 } |
|
752 |
|
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 |
|
767 |
|
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 |
|
786 |
|
787 |
|
788 EXPORT_C TInt RMemSpyDriverClient::WalkHeapInit( TUint aTid ) |
|
789 { |
|
790 TMemSpyDriverInternalWalkHeapParamsInit params; |
|
791 params.iTid = aTid; |
|
792 params.iRHeapVTable = RHeapVTable(); |
|
793 params.iDebugAllocator = DebugEUser(); |
|
794 // |
|
795 const TInt r = DoControl( EMemSpyDriverOpCodeWalkHeapInit, ¶ms, NULL ); |
|
796 return r; |
|
797 } |
|
798 |
|
799 |
|
800 EXPORT_C TInt RMemSpyDriverClient::WalkHeapNextCell( TUint aTid, TMemSpyDriverCellType& aCellType, TAny*& aCellAddress, TInt& aLength, TInt& aNestingLevel, TInt& aAllocNumber, TInt& aCellHeaderSize, TAny*& aCellPayloadAddress ) |
|
801 { |
|
802 aCellType = EMemSpyDriverBadCellMask; |
|
803 aCellAddress = NULL; |
|
804 aLength = 0; |
|
805 aNestingLevel = 0; |
|
806 aAllocNumber = 0; |
|
807 aCellHeaderSize = 0; |
|
808 aCellPayloadAddress = NULL; |
|
809 // |
|
810 TMemSpyDriverInternalWalkHeapParamsCell params; |
|
811 const TInt r = DoControl( EMemSpyDriverOpCodeWalkHeapNextCell, (TAny*) aTid, ¶ms ); |
|
812 // |
|
813 if ( r == KErrNone ) |
|
814 { |
|
815 aCellType = (TMemSpyDriverCellType) params.iCellType; |
|
816 aCellAddress = params.iCellAddress; |
|
817 aLength = params.iLength; |
|
818 aNestingLevel = params.iNestingLevel; |
|
819 aAllocNumber = params.iAllocNumber; |
|
820 aCellPayloadAddress = ((TUint8*) aCellAddress) + aCellHeaderSize; |
|
821 } |
|
822 // |
|
823 return r; |
|
824 } |
|
825 |
|
826 |
|
827 EXPORT_C TInt RMemSpyDriverClient::WalkHeapReadCellData( TAny* aCellAddress, TDes8& aDest, TInt aReadLen ) |
|
828 { |
|
829 TMemSpyDriverInternalWalkHeapCellDataReadParams params; |
|
830 params.iCellAddress = aCellAddress; |
|
831 params.iReadLen = aReadLen; |
|
832 params.iDes = &aDest; |
|
833 aDest.Zero(); |
|
834 // |
|
835 TInt r = DoControl( EMemSpyDriverOpCodeWalkHeapReadCellData, ¶ms, NULL ); |
|
836 if ( r >= KErrNone ) |
|
837 { |
|
838 aDest.SetLength( r ); |
|
839 r = KErrNone; |
|
840 } |
|
841 // |
|
842 return r; |
|
843 } |
|
844 |
|
845 |
|
846 EXPORT_C TInt RMemSpyDriverClient::WalkHeapGetCellInfo( TAny*& aCellAddress, TMemSpyDriverCellType& aCellType, TInt& aLength, TInt& aNestingLevel, TInt& aAllocNumber, TInt& aCellHeaderSize, TAny*& aCellPayloadAddress ) |
|
847 { |
|
848 aCellType = EMemSpyDriverBadCellMask; |
|
849 aLength = 0; |
|
850 aNestingLevel = 0; |
|
851 aAllocNumber = 0; |
|
852 aCellHeaderSize = 0; |
|
853 aCellPayloadAddress = NULL; |
|
854 // |
|
855 TMemSpyDriverInternalWalkHeapParamsCell params; |
|
856 const TInt r = DoControl( EMemSpyDriverOpCodeWalkHeapGetCellInfo, aCellAddress, ¶ms ); |
|
857 // |
|
858 if ( r == KErrNone ) |
|
859 { |
|
860 aCellAddress = params.iCellAddress; |
|
861 aCellType = (TMemSpyDriverCellType) params.iCellType; |
|
862 aLength = params.iLength; |
|
863 aNestingLevel = params.iNestingLevel; |
|
864 aAllocNumber = params.iAllocNumber; |
|
865 aCellPayloadAddress = ((TUint8*) aCellAddress) + aCellHeaderSize; |
|
866 } |
|
867 // |
|
868 return r; |
|
869 } |
|
870 |
|
871 |
|
872 EXPORT_C void RMemSpyDriverClient::WalkHeapClose() |
|
873 { |
|
874 DoControl( EMemSpyDriverOpCodeWalkHeapClose, NULL, NULL ); |
|
875 } |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 |
|
888 |
|
889 |
|
890 |
|
891 |
|
892 |
|
893 |
|
894 |
|
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 |
|
903 EXPORT_C TInt RMemSpyDriverClient::GetStackInfo( TUint aTid, TMemSpyDriverStackInfo& aInfo ) |
|
904 { |
|
905 TMemSpyDriverStackInfo params; |
|
906 const TInt r = DoControl( EMemSpyDriverOpCodeStackGetInfo, (TAny*)aTid, ¶ms ); |
|
907 if (r==KErrNone) |
|
908 { |
|
909 aInfo.iUserStackPointer = params.iUserStackPointer; |
|
910 aInfo.iUserStackBase = params.iUserStackBase; |
|
911 aInfo.iUserStackSize = params.iUserStackSize; |
|
912 aInfo.iUserStackHighWatermark = params.iUserStackHighWatermark; |
|
913 aInfo.iSupervisorStackPointer = params.iSupervisorStackPointer; |
|
914 aInfo.iSupervisorStackBase = params.iSupervisorStackBase; |
|
915 aInfo.iSupervisorStackSize = params.iSupervisorStackSize; |
|
916 aInfo.iSupervisorStackHighWatermark = params.iSupervisorStackHighWatermark; |
|
917 } |
|
918 // |
|
919 return r; |
|
920 } |
|
921 |
|
922 |
|
923 EXPORT_C TInt RMemSpyDriverClient::GetStackData( TUint aTid, TDes8& aDest, TUint& aAmountRemaining, TMemSpyDriverDomainType aDomain, TBool aEntireStack ) |
|
924 { |
|
925 TMemSpyDriverInternalStackDataParams params; |
|
926 params.iTid = aTid; |
|
927 params.iDes = &aDest; |
|
928 params.iDomain = aDomain; |
|
929 params.iEntireStack = aEntireStack; |
|
930 params.iRemaining = -1; |
|
931 aDest.Zero(); |
|
932 // |
|
933 TInt r = DoControl( EMemSpyDriverOpCodeStackGetData, ¶ms, NULL ); |
|
934 // |
|
935 if ( r >= KErrNone ) |
|
936 { |
|
937 aDest.SetLength( r ); |
|
938 aAmountRemaining = params.iRemaining; |
|
939 r = KErrNone; |
|
940 } |
|
941 // |
|
942 return r; |
|
943 } |
|
944 |
|
945 |
|
946 EXPORT_C TInt RMemSpyDriverClient::GetStackDataNext( TUint aTid, TDes8& aDest, TUint& aAmountRemaining, TMemSpyDriverDomainType aDomain, TBool aEntireStack ) |
|
947 { |
|
948 TMemSpyDriverInternalStackDataParams params; |
|
949 params.iTid = aTid; |
|
950 params.iDes = &aDest; |
|
951 params.iDomain = aDomain; |
|
952 params.iEntireStack = aEntireStack; |
|
953 params.iRemaining = aAmountRemaining; |
|
954 // |
|
955 TInt r = DoControl( EMemSpyDriverOpCodeStackGetData, ¶ms, NULL ); |
|
956 // |
|
957 if ( r >= KErrNone ) |
|
958 { |
|
959 aDest.SetLength( r ); |
|
960 aAmountRemaining = params.iRemaining; |
|
961 r = KErrNone; |
|
962 } |
|
963 // |
|
964 return r; |
|
965 } |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 |
|
976 |
|
977 |
|
978 |
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 |
|
1008 |
|
1009 |
|
1010 |
|
1011 |
|
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 EXPORT_C TInt RMemSpyDriverClient::EventMonitorOpen( TUint& aHandle ) |
|
1030 { |
|
1031 const TInt error = DoControl( EMemSpyDriverOpCodeEventMonitorOpen, (TAny*) &aHandle ); |
|
1032 return error; |
|
1033 } |
|
1034 |
|
1035 |
|
1036 EXPORT_C TInt RMemSpyDriverClient::EventMonitorClose( TUint aHandle ) |
|
1037 { |
|
1038 const TInt error = DoControl( EMemSpyDriverOpCodeEventMonitorClose, (TAny*) aHandle ); |
|
1039 return error; |
|
1040 } |
|
1041 |
|
1042 |
|
1043 EXPORT_C void RMemSpyDriverClient::EventMonitorNotify( TUint aHandle, TRequestStatus& aStatus, TUint& aContext ) |
|
1044 { |
|
1045 aStatus = KRequestPending; |
|
1046 // |
|
1047 TMemSpyDriverInternalEventMonitorParams params; |
|
1048 params.iHandle = aHandle; |
|
1049 params.iStatus = &aStatus; |
|
1050 params.iContext = (TAny*) &aContext; |
|
1051 // |
|
1052 const TInt err = DoControl( EMemSpyDriverOpCodeEventMonitorNotify, (TAny*) ¶ms ); |
|
1053 if ( err != KErrNone ) |
|
1054 { |
|
1055 TRequestStatus* status = &aStatus; |
|
1056 User::RequestComplete( status, err ); |
|
1057 } |
|
1058 } |
|
1059 |
|
1060 |
|
1061 EXPORT_C void RMemSpyDriverClient::EventMonitorNotifyCancel( TUint aHandle ) |
|
1062 { |
|
1063 const TInt error = DoControl( EMemSpyDriverOpCodeEventMonitorNotifyCancel, (TAny*) aHandle ); |
|
1064 (void) error; |
|
1065 } |
|
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 |
|
1081 |
|
1082 |
|
1083 |
|
1084 |
|
1085 EXPORT_C TInt RMemSpyDriverClient::ProcessInspectionOpen( TUint aPid ) |
|
1086 { |
|
1087 const TInt error = DoControl( EMemSpyDriverOpCodeProcessInspectOpen, (TAny*) aPid ); |
|
1088 return error; |
|
1089 } |
|
1090 |
|
1091 |
|
1092 EXPORT_C TInt RMemSpyDriverClient::ProcessInspectionClose( TUint aPid ) |
|
1093 { |
|
1094 const TInt error = DoControl( EMemSpyDriverOpCodeProcessInspectClose, (TAny*) aPid ); |
|
1095 return error; |
|
1096 } |
|
1097 |
|
1098 |
|
1099 EXPORT_C void RMemSpyDriverClient::ProcessInspectionRequestChanges( TUint aPid, TRequestStatus& aStatus, TMemSpyDriverProcessInspectionInfo& aInfo ) |
|
1100 { |
|
1101 aInfo.iProcessId = aPid; |
|
1102 aStatus = KRequestPending; |
|
1103 const TInt err = DoControl( EMemSpyDriverOpCodeProcessInspectRequestChanges, (TAny*) &aStatus, (TAny*) &aInfo ); |
|
1104 if ( err != KErrNone ) |
|
1105 { |
|
1106 TRequestStatus* status = &aStatus; |
|
1107 User::RequestComplete( status, err ); |
|
1108 } |
|
1109 } |
|
1110 |
|
1111 |
|
1112 EXPORT_C void RMemSpyDriverClient::ProcessInspectionRequestChangesCancel( TUint aPid ) |
|
1113 { |
|
1114 const TInt error = DoControl( EMemSpyDriverOpCodeProcessInspectRequestChangesCancel, (TAny*) aPid ); |
|
1115 (void) error; |
|
1116 } |
|
1117 |
|
1118 |
|
1119 EXPORT_C void RMemSpyDriverClient::ProcessInspectionAutoStartItemsReset() |
|
1120 { |
|
1121 const TInt error = DoControl( EMemSpyDriverOpCodeProcessInspectAutoStartListReset ); |
|
1122 (void) error; |
|
1123 } |
|
1124 |
|
1125 |
|
1126 EXPORT_C TInt RMemSpyDriverClient::ProcessInspectionAutoStartItemsAdd( TUint aSID ) |
|
1127 { |
|
1128 const TInt error = DoControl( EMemSpyDriverOpCodeProcessInspectAutoStartListAdd, (TAny*) aSID ); |
|
1129 return error; |
|
1130 } |
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 |
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 |
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 EXPORT_C TInt RMemSpyDriverClient::GetContainerHandles( TMemSpyDriverContainerType aContainer, TAny** aHandleArray, TInt& aHandleCount ) |
|
1154 { |
|
1155 TMemSpyDriverInternalContainerHandleParams params; |
|
1156 params.iTidOrPid = KMemSpyDriverEnumerateContainerHandles; |
|
1157 params.iContainer = aContainer; |
|
1158 params.iHandles = aHandleArray; |
|
1159 params.iCountPtr = &aHandleCount; |
|
1160 params.iMaxCount = aHandleCount; |
|
1161 params.iHandleSource = EMemSpyDriverThreadOrProcessTypeThread; // Not used |
|
1162 // |
|
1163 aHandleCount = 0; |
|
1164 // |
|
1165 return DoControl( EMemSpyDriverOpCodeContainersGetHandles, ¶ms, NULL ); |
|
1166 } |
|
1167 |
|
1168 |
|
1169 EXPORT_C TInt RMemSpyDriverClient::GetThreadHandlesByType( TInt aTid, TMemSpyDriverContainerType aType, TAny** aHandleArray, TInt& aHandleCount ) |
|
1170 { |
|
1171 TMemSpyDriverInternalContainerHandleParams params; |
|
1172 params.iTidOrPid = aTid; |
|
1173 params.iContainer = aType; |
|
1174 params.iHandles = aHandleArray; |
|
1175 params.iCountPtr = &aHandleCount; |
|
1176 params.iMaxCount = aHandleCount; |
|
1177 params.iHandleSource = EMemSpyDriverThreadOrProcessTypeThread; |
|
1178 // |
|
1179 aHandleCount = 0; |
|
1180 // |
|
1181 return DoControl( EMemSpyDriverOpCodeContainersGetHandles, ¶ms, NULL ); |
|
1182 } |
|
1183 |
|
1184 |
|
1185 EXPORT_C TInt RMemSpyDriverClient::GetProcessHandlesByType( TInt aPid, TMemSpyDriverContainerType aType, TAny** aHandleArray, TInt& aHandleCount ) |
|
1186 { |
|
1187 TMemSpyDriverInternalContainerHandleParams params; |
|
1188 params.iTidOrPid = aPid; |
|
1189 params.iContainer = aType; |
|
1190 params.iHandles = aHandleArray; |
|
1191 params.iCountPtr = &aHandleCount; |
|
1192 params.iMaxCount = aHandleCount; |
|
1193 params.iHandleSource = EMemSpyDriverThreadOrProcessTypeProcess; |
|
1194 // |
|
1195 aHandleCount = 0; |
|
1196 // |
|
1197 return DoControl( EMemSpyDriverOpCodeContainersGetHandles, ¶ms, NULL ); |
|
1198 } |
|
1199 |
|
1200 |
|
1201 EXPORT_C TInt RMemSpyDriverClient::GetGenericHandleInfo( TInt aTid, TMemSpyDriverContainerType aType, TAny* aHandle, TMemSpyDriverHandleInfoGeneric& aParams ) |
|
1202 { |
|
1203 aParams.iType = aType; |
|
1204 aParams.iHandle = aHandle; |
|
1205 // |
|
1206 const TInt r = DoControl( EMemSpyDriverOpCodeContainersGetHandleInfo, (TAny*) aTid, &aParams ); |
|
1207 return r; |
|
1208 } |
|
1209 |
|
1210 |
|
1211 EXPORT_C TInt RMemSpyDriverClient::GetApproximateKernelObjectSize( TMemSpyDriverContainerType aType ) |
|
1212 { |
|
1213 TInt size = 0; |
|
1214 const TInt error = DoControl( EMemSpyDriverOpCodeContainersGetApproxSize, (TAny*) aType, (TAny*) &size ); |
|
1215 (void) error; |
|
1216 // |
|
1217 return size; |
|
1218 } |
|
1219 |
|
1220 |
|
1221 EXPORT_C TInt RMemSpyDriverClient::GetReferencesToMyThread( TUint aTid ) |
|
1222 { |
|
1223 ResetStreamBuffer(); |
|
1224 return DoControl( EMemSpyDriverOpCodeContainersGetReferencesToMyThread, (TAny*) aTid, (TAny*) &iBuffer ); |
|
1225 } |
|
1226 |
|
1227 |
|
1228 EXPORT_C TInt RMemSpyDriverClient::GetReferencesToMyProcess( TUint aPid ) |
|
1229 { |
|
1230 ResetStreamBuffer(); |
|
1231 return DoControl( EMemSpyDriverOpCodeContainersGetReferencesToMyProcess, (TAny*) aPid, (TAny*) &iBuffer ); |
|
1232 } |
|
1233 |
|
1234 |
|
1235 EXPORT_C TInt RMemSpyDriverClient::GetPAndSInfo( TAny* aHandle, TMemSpyDriverPAndSInfo& aInfo ) |
|
1236 { |
|
1237 const TInt r = DoControl( EMemSpyDriverOpCodeContainersGetPAndSInfo, (TAny*) aHandle, &aInfo ); |
|
1238 return r; |
|
1239 } |
|
1240 |
|
1241 |
|
1242 EXPORT_C TInt RMemSpyDriverClient::GetCondVarSuspendedThreads( TAny* aCondVarHandle, TAny** aThreadHandleArray, TInt& aThreadCount ) |
|
1243 { |
|
1244 TMemSpyDriverInternalCondVarSuspendedThreadParams params; |
|
1245 params.iCondVarHandle = aCondVarHandle; |
|
1246 params.iThrHandles = aThreadHandleArray; |
|
1247 params.iThrCountPtr = &aThreadCount; |
|
1248 params.iMaxCount = aThreadCount; |
|
1249 // |
|
1250 aThreadCount = 0; |
|
1251 // |
|
1252 return DoControl( EMemSpyDriverOpCodeContainersGetCondVarSuspendedThreads, ¶ms, NULL ); |
|
1253 } |
|
1254 |
|
1255 |
|
1256 EXPORT_C TInt RMemSpyDriverClient::GetCondVarSuspendedThreadInfo( TAny* aHandle, TMemSpyDriverCondVarSuspendedThreadInfo& aParams ) |
|
1257 { |
|
1258 return DoControl( EMemSpyDriverOpCodeContainersGetCondVarSuspendedThreadInfo, aHandle, &aParams ); |
|
1259 } |
|
1260 |
|
1261 |
|
1262 |
|
1263 |
|
1264 |
|
1265 |
|
1266 |
|
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 |
|
1273 |
|
1274 |
|
1275 |
|
1276 |
|
1277 EXPORT_C TInt RMemSpyDriverClient::GetServerSessionHandles( TAny* aServerHandle, TAny** aSessionHandleArray, TInt& aSessionHandleCount ) |
|
1278 { |
|
1279 TMemSpyDriverInternalServerSessionHandleParams params; |
|
1280 params.iServerHandle = aServerHandle; |
|
1281 params.iSessionHandles = aSessionHandleArray; |
|
1282 params.iSessionCountPtr = &aSessionHandleCount; |
|
1283 params.iMaxCount = aSessionHandleCount; |
|
1284 // |
|
1285 aSessionHandleCount = 0; |
|
1286 // |
|
1287 return DoControl( EMemSpyDriverOpCodeClientServerGetServerSessionHandles, ¶ms, NULL ); |
|
1288 } |
|
1289 |
|
1290 |
|
1291 EXPORT_C TInt RMemSpyDriverClient::GetServerSessionInfo( TAny* aSessionHandle, TMemSpyDriverServerSessionInfo& aParams ) |
|
1292 { |
|
1293 return DoControl( EMemSpyDriverOpCodeClientServerGetServerSessionInfo, aSessionHandle, &aParams ); |
|
1294 } |
|
1295 |
|
1296 |
|
1297 |
|
1298 |
|
1299 |
|
1300 |
|
1301 |
|
1302 |
|
1303 |
|
1304 |
|
1305 |
|
1306 EXPORT_C RMemSpyMemStreamReader RMemSpyDriverClient::StreamOpenL() |
|
1307 { |
|
1308 CMemSpyMemStreamReader* imp = new(ELeave) CMemSpyMemStreamReader( iBuffer ); |
|
1309 RMemSpyMemStreamReader ret( imp ); |
|
1310 CleanupClosePushL( ret ); |
|
1311 imp->ConstructL(); |
|
1312 CleanupStack::Pop( &ret ); |
|
1313 return ret; |
|
1314 } |
|
1315 |
|
1316 |
|
1317 |
|
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 EXPORT_C TMemSpyMemoryModelType RMemSpyDriverClient::MemoryModelType() |
|
1329 { |
|
1330 TMemSpyMemoryModelType ret = EMemSpyMemoryModelTypeUnknown; |
|
1331 // |
|
1332 const TInt err = DoControl( EMemSpyDriverOpCodeMiscGetMemoryModelType ); |
|
1333 switch( err ) |
|
1334 { |
|
1335 default: |
|
1336 case EMemSpyMemoryModelTypeUnknown: |
|
1337 ret = EMemSpyMemoryModelTypeUnknown; |
|
1338 break; |
|
1339 case EMemSpyMemoryModelTypeMoving: |
|
1340 ret = EMemSpyMemoryModelTypeMoving; |
|
1341 break; |
|
1342 case EMemSpyMemoryModelTypeMultiple: |
|
1343 ret = EMemSpyMemoryModelTypeMultiple; |
|
1344 break; |
|
1345 case EMemSpyMemoryModelTypeEmulator: |
|
1346 ret = EMemSpyMemoryModelTypeEmulator; |
|
1347 break; |
|
1348 } |
|
1349 // |
|
1350 return ret; |
|
1351 } |
|
1352 |
|
1353 |
|
1354 EXPORT_C TUint32 RMemSpyDriverClient::RoundToPageSize( TUint32 aValue ) |
|
1355 { |
|
1356 TUint32 temp = aValue; |
|
1357 TAny* pValue = (TAny*) &temp; |
|
1358 DoControl( EMemSpyDriverOpCodeMiscGetRoundToPageSize, pValue ); |
|
1359 return temp; |
|
1360 } |
|
1361 |
|
1362 |
|
1363 EXPORT_C TInt RMemSpyDriverClient::Impersonate( TUint32 aValue ) |
|
1364 { |
|
1365 return DoControl( EMemSpyDriverOpCodeMiscImpersonate, (TAny*) aValue ); |
|
1366 } |
|
1367 |
|
1368 |
|
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 TUint RMemSpyDriverClient::RHeapVTable() |
|
1394 { |
|
1395 RHeap* heap = (RHeap*) &User::Allocator(); |
|
1396 // |
|
1397 TUint* pHeap = (TUint*) heap; |
|
1398 const TUint heapVTable = *pHeap; |
|
1399 // |
|
1400 ////RDebug::Printf( "[MemSpy] RMemSpyDriverClient::RHeapVTable() - ret: 0x%08x", heapVTable ); |
|
1401 return heapVTable; |
|
1402 } |
|
1403 |
|
1404 |
|
1405 TBool RMemSpyDriverClient::DebugEUser() |
|
1406 { |
|
1407 LtkUtils::RAllocatorHelper allocHelper; |
|
1408 TBool result = EFalse; |
|
1409 TInt err = allocHelper.Open(&User::Allocator()); |
|
1410 if (!err) |
|
1411 { |
|
1412 result = allocHelper.AllocatorIsUdeb(); |
|
1413 allocHelper.Close(); |
|
1414 } |
|
1415 return result; |
|
1416 } |
|
1417 |
|
1418 |
|
1419 void RMemSpyDriverClient::ResetStreamBuffer() |
|
1420 { |
|
1421 iBuffer.Zero(); |
|
1422 } |
|
1423 |
|
1424 |
|
1425 void RMemSpyDriverClient::ReadHeapInfoFreeCellsFromXferBufferL( RArray<TMemSpyDriverFreeCell>& aFreeCells ) |
|
1426 { |
|
1427 aFreeCells.Reset(); |
|
1428 |
|
1429 #ifdef _DEBUG |
|
1430 RDebug::Printf( "[MemSpy] RMemSpyDriverClient::ReadHeapInfoFreeCellsFromXferBufferL() - buf len: %d", iBuffer.Length() ); |
|
1431 #endif |
|
1432 |
|
1433 if ( iBuffer.Length() ) |
|
1434 { |
|
1435 RMemSpyMemStreamReader stream = StreamOpenL(); |
|
1436 CleanupClosePushL( stream ); |
|
1437 |
|
1438 const TInt count = stream.ReadInt32L(); |
|
1439 #ifdef _DEBUG |
|
1440 RDebug::Printf( "[MemSpy] RMemSpyDriverClient::ReadHeapInfoFreeCellsFromXferBufferL() - count: %d", count ); |
|
1441 #endif |
|
1442 |
|
1443 for( TInt i=0; i<count; i++ ) |
|
1444 { |
|
1445 TMemSpyDriverFreeCell entry; |
|
1446 entry.iType = (TMemSpyDriverCellType)stream.ReadInt32L(); |
|
1447 entry.iAddress = reinterpret_cast< TAny* >( stream.ReadUint32L() ); |
|
1448 entry.iLength = stream.ReadInt32L(); |
|
1449 aFreeCells.AppendL( entry ); |
|
1450 } |
|
1451 |
|
1452 CleanupStack::PopAndDestroy( &stream ); |
|
1453 } |
|
1454 |
|
1455 ResetStreamBuffer(); |
|
1456 } |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 |
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 static void PrintHeapInfo( const TMemSpyHeapInfo& aInfo ) |
|
1470 { |
|
1471 #if defined( _DEBUG ) && !defined( __WINS__ ) |
|
1472 const TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap(); |
|
1473 //const TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData(); |
|
1474 const TMemSpyHeapStatisticsRHeap& rHeapStats = rHeapInfo.Statistics(); |
|
1475 const TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData(); |
|
1476 |
|
1477 /* |
|
1478 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------"); |
|
1479 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RAllocator -"); |
|
1480 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------"); |
|
1481 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RAllocator::iAccessCount: %d", rHeapObjectData.iAccessCount); |
|
1482 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RAllocator::iHandleCount: %d", rHeapObjectData.iHandleCount); |
|
1483 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RAllocator::iHandles: 0x%08x", rHeapObjectData.iHandles); |
|
1484 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RAllocator::iFlags: 0x%08x", rHeapObjectData.iFlags); |
|
1485 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RAllocator::iCellCount: %d", rHeapObjectData.iCellCount); |
|
1486 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RAllocator::iTotalAllocSize: %d", rHeapObjectData.iTotalAllocSize); |
|
1487 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - "); |
|
1488 |
|
1489 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------"); |
|
1490 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap -"); |
|
1491 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------"); |
|
1492 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iMinLength: %d", rHeapObjectData.iMinLength); |
|
1493 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iMaxLength: %d", rHeapObjectData.iMaxLength); |
|
1494 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iOffset: %d", rHeapObjectData.iOffset); |
|
1495 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iGrowBy: %d", rHeapObjectData.iGrowBy); |
|
1496 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iChunkHandle: 0x%08x", rHeapObjectData.iChunkHandle); |
|
1497 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iBase: 0x%08x", rHeapObjectData.iBase); |
|
1498 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iTop: 0x%08x", rHeapObjectData.iTop); |
|
1499 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iAlign: %d", rHeapObjectData.iAlign); |
|
1500 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iMinCell: %d", rHeapObjectData.iAlign); |
|
1501 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iPageSize: %d", rHeapObjectData.iAlign); |
|
1502 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iFree.next: 0x%08x", rHeapObjectData.iFree.next); |
|
1503 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iFree.len: %d", rHeapObjectData.iFree.len); |
|
1504 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iNestingLevel: %d", rHeapObjectData.iNestingLevel); |
|
1505 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iAllocCount: %d", rHeapObjectData.iAllocCount); |
|
1506 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iFailType: %d", rHeapObjectData.iFailType); |
|
1507 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iFailRate: %d", rHeapObjectData.iFailRate); |
|
1508 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iFailed: %d", rHeapObjectData.iFailed); |
|
1509 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iFailAllocCount: %d", rHeapObjectData.iFailAllocCount); |
|
1510 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iRand: %d", rHeapObjectData.iRand); |
|
1511 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iTestData: 0x%08x", rHeapObjectData.iTestData); |
|
1512 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - "); |
|
1513 */ |
|
1514 |
|
1515 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------"); |
|
1516 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - Stats (Free) -"); |
|
1517 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------"); |
|
1518 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell count: %d", rHeapStats.StatsFree().TypeCount()); |
|
1519 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell size: %d", rHeapStats.StatsFree().TypeSize()); |
|
1520 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell largest: 0x%08x", rHeapStats.StatsFree().LargestCellAddress()); |
|
1521 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell largest size: %d", rHeapStats.StatsFree().LargestCellSize()); |
|
1522 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - slack: 0x%08x", rHeapStats.StatsFree().SlackSpaceCellAddress()); |
|
1523 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - slack size: %d", rHeapStats.StatsFree().SlackSpaceCellSize()); |
|
1524 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - checksum: 0x%08x", rHeapStats.StatsFree().Checksum()); |
|
1525 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - "); |
|
1526 |
|
1527 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------"); |
|
1528 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - Stats (Alloc) -"); |
|
1529 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------"); |
|
1530 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell count: %d", rHeapStats.StatsAllocated().TypeCount()); |
|
1531 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell size: %d", rHeapStats.StatsAllocated().TypeSize()); |
|
1532 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell largest: 0x%08x", rHeapStats.StatsAllocated().LargestCellAddress()); |
|
1533 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell largest size: %d", rHeapStats.StatsAllocated().LargestCellSize()); |
|
1534 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - "); |
|
1535 |
|
1536 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------"); |
|
1537 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - Misc. Info -"); |
|
1538 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------"); |
|
1539 const TPtrC chunkName( rHeapMetaData.ChunkName() ); |
|
1540 RDebug::Print(_L("RMemSpyDriverClient::PrintHeapInfo() - chunk name: [%S]"), &chunkName ); |
|
1541 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - chunk size: %d", rHeapMetaData.ChunkSize()); |
|
1542 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - chunk handle: 0x%08x", rHeapMetaData.ChunkHandle()); |
|
1543 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - chunk base address: 0x%08x", rHeapMetaData.ChunkBaseAddress()); |
|
1544 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - debug allocator: %d", rHeapMetaData.IsDebugAllocator()); |
|
1545 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - shared heap: %d", rHeapMetaData.IsSharedHeap() ); |
|
1546 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - user thread: %d", rHeapMetaData.IsUserThread() ); |
|
1547 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - thread id: %d", aInfo.Tid() ); |
|
1548 RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - process id: %d", aInfo.Pid() ); |
|
1549 //RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell header size (free): %d", rHeapMetaData.HeaderSizeFree()); |
|
1550 //RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell header size (alloc): %d", rHeapMetaData.HeaderSizeAllocated()); |
|
1551 #else |
|
1552 (void) aInfo; |
|
1553 #endif |
|
1554 } |
|
1555 |
|