|
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 "MemSpyDriverLogChanContainers.h" |
|
19 |
|
20 // System includes |
|
21 #include <memspy/driver/memspydriverconstants.h> |
|
22 #include <memspy/driver/memspydriverobjectsshared.h> |
|
23 |
|
24 // Shared includes |
|
25 #include "MemSpyDriverOpCodes.h" |
|
26 #include "MemSpyDriverObjectsInternal.h" |
|
27 |
|
28 // User includes |
|
29 #include "MemSpyDriverUtils.h" |
|
30 #include "MemSpyDriverUserEventMonitor.h" |
|
31 #include "MemSpyDriverSuspensionManager.h" |
|
32 #include "MemSpyDriverOSAdaption.h" |
|
33 |
|
34 // Constants |
|
35 const TInt KMemSpyDriverLogChanContainersXferBufferSize = 1024 * 4; |
|
36 |
|
37 |
|
38 DMemSpyDriverLogChanContainers::DMemSpyDriverLogChanContainers( DMemSpyDriverDevice& aDevice, DThread& aThread ) |
|
39 : DMemSpyDriverLogChanContainerBase( aDevice, aThread ) |
|
40 { |
|
41 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::DMemSpyDriverLogChanContainers() - this: 0x%08x", this )); |
|
42 } |
|
43 |
|
44 |
|
45 DMemSpyDriverLogChanContainers::~DMemSpyDriverLogChanContainers() |
|
46 { |
|
47 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::~DMemSpyDriverLogChanContainers() - START - this: 0x%08x", this )); |
|
48 |
|
49 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::~DMemSpyDriverLogChanContainers() - END - this: 0x%08x", this )); |
|
50 } |
|
51 |
|
52 |
|
53 TInt DMemSpyDriverLogChanContainers::Construct() |
|
54 { |
|
55 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::Construct() - START - this: 0x%08x", this )); |
|
56 |
|
57 const TInt ret = BaseConstruct( KMemSpyDriverLogChanContainersXferBufferSize ); |
|
58 |
|
59 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::Construct() - END - this: 0x%08x, err: %d", this, ret )); |
|
60 return ret; |
|
61 } |
|
62 |
|
63 |
|
64 TInt DMemSpyDriverLogChanContainers::Request( TInt aFunction, TAny* a1, TAny* a2 ) |
|
65 { |
|
66 TInt r = DMemSpyDriverLogChanContainerBase::Request( aFunction, a1, a2 ); |
|
67 if ( r == KErrNone ) |
|
68 { |
|
69 switch( aFunction ) |
|
70 { |
|
71 case EMemSpyDriverOpCodeContainersGetHandles: |
|
72 r = GetContainerHandles( (TMemSpyDriverInternalContainerHandleParams*) a1 ); |
|
73 break; |
|
74 case EMemSpyDriverOpCodeContainersGetHandleInfo: |
|
75 r = GetGenericHandleInfo( (TInt) a1, (TMemSpyDriverHandleInfoGeneric*) a2 ); |
|
76 break; |
|
77 case EMemSpyDriverOpCodeContainersGetApproxSize: |
|
78 r = GetKernelObjectSizeApproximation( (TMemSpyDriverContainerType) ((TInt) a1), (TInt*) a2 ); |
|
79 break; |
|
80 case EMemSpyDriverOpCodeContainersGetReferencesToMyThread: |
|
81 r = GetReferencesToMyThread( (TUint) a1, (TDes8*) a2 ); |
|
82 break; |
|
83 case EMemSpyDriverOpCodeContainersGetReferencesToMyProcess: |
|
84 r = GetReferencesToMyProcess( (TUint) a1, (TDes8*) a2 ); |
|
85 break; |
|
86 case EMemSpyDriverOpCodeContainersGetPAndSInfo: |
|
87 r = GetPAndSInfo( (DObject*) a1, (TMemSpyDriverPAndSInfo*) a2 ); |
|
88 break; |
|
89 case EMemSpyDriverOpCodeContainersGetCondVarSuspendedThreads: |
|
90 r = GetCondVarSuspendedThreads( (TMemSpyDriverInternalCondVarSuspendedThreadParams*)a1 ); |
|
91 break; |
|
92 case EMemSpyDriverOpCodeContainersGetCondVarSuspendedThreadInfo: |
|
93 r = GetCondVarSuspendedThreadInfo( a1, (TMemSpyDriverCondVarSuspendedThreadInfo*)a2 ); |
|
94 break; |
|
95 |
|
96 default: |
|
97 r = KErrNotSupported; |
|
98 break; |
|
99 } |
|
100 } |
|
101 // |
|
102 return r; |
|
103 } |
|
104 |
|
105 |
|
106 TBool DMemSpyDriverLogChanContainers::IsHandler( TInt aFunction ) const |
|
107 { |
|
108 return ( aFunction > EMemSpyDriverOpCodeContainersBase && aFunction < EMemSpyDriverOpCodeContainersEnd ); |
|
109 } |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 TInt DMemSpyDriverLogChanContainers::GetContainerHandles( TMemSpyDriverInternalContainerHandleParams* aParams ) |
|
122 { |
|
123 TMemSpyDriverInternalContainerHandleParams params; |
|
124 TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverInternalContainerHandleParams) ); |
|
125 if ( r != KErrNone ) |
|
126 { |
|
127 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles() - END - params read error: %d", r)); |
|
128 return r; |
|
129 } |
|
130 |
|
131 const TInt maxCount = params.iMaxCount; |
|
132 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles() - START - tid or pid: %d, maxCount: %d, container: %d, handleSource: %d", params.iTidOrPid, maxCount, params.iContainer, params.iHandleSource )); |
|
133 |
|
134 DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread(); |
|
135 DMemSpyDriverOSAdaptionDProcess& processAdaption = OSAdaption().DProcess(); |
|
136 |
|
137 ResetTempHandles(); |
|
138 |
|
139 if ( params.iTidOrPid == KMemSpyDriverEnumerateContainerHandles ) |
|
140 { |
|
141 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - enumerating container handles... " )); |
|
142 NKern::ThreadEnterCS(); |
|
143 |
|
144 // We are enumerating an entire container - not a thread-specific request |
|
145 const TObjectType type = ObjectTypeFromMemSpyContainerType( params.iContainer ); |
|
146 |
|
147 DObjectCon* container = Kern::Containers()[type]; |
|
148 container->Wait(); |
|
149 |
|
150 const TInt count = container->Count(); |
|
151 for(TInt i=0; i<count; i++) |
|
152 { |
|
153 DObject* object = (*container)[ i ]; |
|
154 if ( object != NULL ) |
|
155 { |
|
156 AddTempHandle( object ); |
|
157 } |
|
158 } |
|
159 |
|
160 container->Signal(); |
|
161 NKern::ThreadLeaveCS(); |
|
162 } |
|
163 else |
|
164 { |
|
165 // Are we dealing with threads or processes? |
|
166 const TObjectType sourceContainerType = (TObjectType) params.iHandleSource; |
|
167 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - sourceContainerType: %d", sourceContainerType )); |
|
168 |
|
169 // We need to open the process or thread in order to get its handle |
|
170 r = OpenTempObject( params.iTidOrPid, sourceContainerType ); |
|
171 if ( r == KErrNone ) |
|
172 { |
|
173 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - handle source object: %O", TempObject() )); |
|
174 |
|
175 // This is the source for the handles we want to check. Its either the process or thread's handle index... |
|
176 MemSpyObjectIx* handles = NULL; |
|
177 |
|
178 // Check that the process' thread's are suspended and get handle index |
|
179 if ( params.iHandleSource == EMemSpyDriverThreadOrProcessTypeThread ) |
|
180 { |
|
181 DThread* thread = (DThread*) TempObject(); |
|
182 if ( !SuspensionManager().IsSuspended( *thread ) ) |
|
183 { |
|
184 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - parent process not suspended => KErrAccessDenied")); |
|
185 r = KErrAccessDenied; |
|
186 } |
|
187 else |
|
188 { |
|
189 handles = threadAdaption.GetHandles( *thread ); |
|
190 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - checking handles for thread: %O", thread )); |
|
191 } |
|
192 } |
|
193 else if ( params.iHandleSource == EMemSpyDriverThreadOrProcessTypeProcess ) |
|
194 { |
|
195 DProcess* process = (DProcess*) TempObject(); |
|
196 if ( !SuspensionManager().IsSuspended( *process ) ) |
|
197 { |
|
198 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - process not suspended => KErrAccessDenied")); |
|
199 r =KErrAccessDenied; |
|
200 } |
|
201 else |
|
202 { |
|
203 handles = processAdaption.GetHandles( *process ); |
|
204 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - checking handles for process: %O", process )); |
|
205 } |
|
206 } |
|
207 |
|
208 if ( handles ) |
|
209 { |
|
210 NKern::ThreadEnterCS(); |
|
211 |
|
212 // Iterate through each handle in the thread/process and add it to the temp handles container if |
|
213 // the handle is of the correct type. |
|
214 |
|
215 MemSpyObjectIx_HandleLookupLock(); |
|
216 const TInt handleCount = handles->Count(); |
|
217 MemSpyObjectIx_HandleLookupUnlock(); |
|
218 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - %d handles in index...", handleCount )); |
|
219 |
|
220 for( TInt handleIndex=0; handleIndex<handleCount; handleIndex++ ) |
|
221 { |
|
222 // Get a handle from the container... |
|
223 MemSpyObjectIx_HandleLookupLock(); |
|
224 if (handleIndex >= handles->Count()) break; // Count may have changed in the meantime |
|
225 DObject* objectToSearchFor = (*handles)[ handleIndex ]; |
|
226 if (objectToSearchFor && objectToSearchFor->Open() != KErrNone) objectToSearchFor = NULL; |
|
227 MemSpyObjectIx_HandleLookupUnlock(); |
|
228 |
|
229 if (objectToSearchFor && OSAdaption().DThread().GetObjectType(*objectToSearchFor) == ObjectTypeFromMemSpyContainerType(params.iContainer)) |
|
230 { |
|
231 // Found a match in the specified container. Write the object's handle (aka the object address) |
|
232 // back to the client address space |
|
233 AddTempHandle( objectToSearchFor ); |
|
234 } |
|
235 if (objectToSearchFor) objectToSearchFor->Close(NULL); |
|
236 } |
|
237 |
|
238 NKern::ThreadLeaveCS(); |
|
239 } |
|
240 |
|
241 // Done with this now. |
|
242 CloseTempObject(); |
|
243 } |
|
244 else |
|
245 { |
|
246 Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - thread / process not found"); |
|
247 } |
|
248 } |
|
249 |
|
250 // Write back handles to client |
|
251 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - trying to write %d handles to client...", TempHandleCount() )); |
|
252 r = WriteToClient( params.iHandles, params.iCountPtr, maxCount ); |
|
253 |
|
254 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles() - END - r: %d", r)); |
|
255 return r; |
|
256 } |
|
257 |
|
258 |
|
259 TInt DMemSpyDriverLogChanContainers::GetGenericHandleInfo( TInt aTid, TMemSpyDriverHandleInfoGeneric* aParams ) |
|
260 { |
|
261 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - START" )); |
|
262 |
|
263 TMemSpyDriverHandleInfoGeneric params; |
|
264 TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverHandleInfoGeneric) ); |
|
265 if ( r != KErrNone ) |
|
266 { |
|
267 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - END - params read error: %d", r)); |
|
268 return r; |
|
269 } |
|
270 |
|
271 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo - tid: %d, handle: 0x%08x", aTid, params.iHandle )); |
|
272 |
|
273 if ( aTid == KMemSpyDriverEnumerateContainerHandles ) |
|
274 { |
|
275 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo - getting info for non-thread specific handle...")); |
|
276 } |
|
277 else |
|
278 { |
|
279 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo - thread-specific request...")); |
|
280 |
|
281 r = OpenTempObject( aTid, EThread ); |
|
282 if (r != KErrNone) |
|
283 { |
|
284 Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - END - thread not found"); |
|
285 return r; |
|
286 } |
|
287 |
|
288 // Check that the process' thread's are suspended |
|
289 DThread* thread = (DThread*) TempObject(); |
|
290 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo - opened thread: %O", thread)); |
|
291 if ( !SuspensionManager().IsSuspended( *thread ) ) |
|
292 { |
|
293 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - END - parent process not suspended => KErrAccessDenied")); |
|
294 CloseTempObject(); |
|
295 return KErrAccessDenied; |
|
296 } |
|
297 } |
|
298 |
|
299 NKern::ThreadEnterCS(); |
|
300 |
|
301 // First, locate the specific DObject in question. Cast the handle, but don't use the object... |
|
302 DObject* handleAsObject = (DObject*) params.iHandle; |
|
303 handleAsObject = CheckedOpen(params.iType, handleAsObject); |
|
304 if ( handleAsObject != NULL ) |
|
305 { |
|
306 // We found the right object. First get generic info. |
|
307 handleAsObject->FullName( params.iName ); |
|
308 handleAsObject->Name( params.iNameDetail ); |
|
309 |
|
310 // Using threadAddaption to fetch generic info. |
|
311 // Implementations of following get functions are actually in DMemSpyDriverOSAdaptionDObject |
|
312 // so it does not matter what adaption to use for generic info. |
|
313 DMemSpyDriverOSAdaptionDThread& threadAddaption = OSAdaption().DThread(); |
|
314 params.iAccessCount = threadAddaption.GetAccessCount( *handleAsObject ); |
|
315 params.iUniqueID = threadAddaption.GetUniqueID( *handleAsObject ); |
|
316 params.iProtection = threadAddaption.GetProtection( *handleAsObject ); |
|
317 params.iAddressOfKernelOwner = threadAddaption.GetAddressOfKernelOwner( *handleAsObject ); |
|
318 |
|
319 // Get type-specific info. |
|
320 if ( params.iType == EMemSpyDriverContainerTypeThread ) |
|
321 { |
|
322 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeThread" )); |
|
323 |
|
324 DThread* object = (DThread*) handleAsObject; |
|
325 DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread(); |
|
326 // |
|
327 params.iId = threadAdaption.GetId( *object ); |
|
328 params.iPriority = threadAdaption.GetPriority( *object ); |
|
329 params.iAddressOfOwningProcess = threadAdaption.GetAddressOfOwningProcess( *object ); |
|
330 threadAdaption.GetNameOfOwningProcess( *object, params.iNameOfOwner ); |
|
331 } |
|
332 else if ( params.iType == EMemSpyDriverContainerTypeProcess ) |
|
333 { |
|
334 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeProcess" )); |
|
335 |
|
336 DProcess* object = (DProcess*) handleAsObject; |
|
337 DMemSpyDriverOSAdaptionDProcess& processAdaption = OSAdaption().DProcess(); |
|
338 // |
|
339 params.iId = processAdaption.GetId( *object ); |
|
340 // |
|
341 params.iPriority = processAdaption.GetPriority( *object ); |
|
342 params.iAddressOfOwningProcess = processAdaption.GetAddressOfOwningProcess( *object ); |
|
343 params.iCreatorId = processAdaption.GetCreatorId( *object ); |
|
344 params.iSecurityZone = processAdaption.GetSecurityZone( *object ); |
|
345 params.iAttributes = processAdaption.GetAttributes( *object ); |
|
346 params.iAddressOfDataBssStackChunk = processAdaption.GetAddressOfDataBssStackChunk( *object ); |
|
347 } |
|
348 else if ( params.iType == EMemSpyDriverContainerTypeChunk ) |
|
349 { |
|
350 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeChunk" )); |
|
351 |
|
352 DChunk* object = (DChunk*) handleAsObject; |
|
353 DMemSpyDriverOSAdaptionDChunk& ca = OSAdaption().DChunk(); |
|
354 // |
|
355 params.iSize = ca.GetSize( *object ); |
|
356 params.iId = ca.GetOwningProcessId( *object ); |
|
357 params.iAddressOfOwningProcess = ca.GetAddressOfOwningProcess( *object ); |
|
358 params.iMaxSize = ca.GetMaxSize( *object ); |
|
359 params.iBottom = ca.GetBottom( *object ); |
|
360 params.iTop = ca.GetTop( *object ); |
|
361 params.iAttributes = ca.GetAttributes( *object ); |
|
362 params.iStartPos = ca.GetStartPos( *object ); |
|
363 params.iControllingOwner = ca.GetControllingOwnerId( *object ); |
|
364 params.iRestrictions = ca.GetRestrictions( *object ); |
|
365 params.iMapAttr = ca.GetMapAttr( *object ); |
|
366 params.iChunkType = ca.GetType( *object ); |
|
367 ca.GetNameOfOwningProcess( *object, params.iNameOfOwner ); |
|
368 } |
|
369 else if ( params.iType == EMemSpyDriverContainerTypeLibrary ) |
|
370 { |
|
371 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeLibrary" )); |
|
372 |
|
373 Kern::AccessCode(); |
|
374 // |
|
375 DLibrary* object = (DLibrary*) handleAsObject; |
|
376 DMemSpyDriverOSAdaptionDCodeSeg& csa = OSAdaption().DCodeSeg(); |
|
377 DCodeSeg* codeSeg = csa.GetCodeSeg( *object ); |
|
378 params.iAddressOfCodeSeg = (TUint8*)codeSeg; |
|
379 params.iMapCount = csa.GetMapCount( *object ); |
|
380 params.iState = csa.GetState( *object ); |
|
381 // |
|
382 if ( codeSeg ) |
|
383 { |
|
384 params.iSize = csa.GetSize( *codeSeg ); |
|
385 } |
|
386 else |
|
387 { |
|
388 r = KErrNotFound; |
|
389 } |
|
390 // |
|
391 Kern::EndAccessCode(); |
|
392 } |
|
393 else if ( params.iType == EMemSpyDriverContainerTypeSemaphore ) |
|
394 { |
|
395 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeSemaphore" )); |
|
396 |
|
397 DSemaphore* object = (DSemaphore*) handleAsObject; |
|
398 DMemSpyDriverOSAdaptionDSemaphore& sa = OSAdaption().DSemaphore(); |
|
399 params.iCount = sa.GetCount( *object ); |
|
400 params.iResetting = sa.GetResetting( *object ); |
|
401 } |
|
402 else if ( params.iType == EMemSpyDriverContainerTypeMutex ) |
|
403 { |
|
404 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeMutex" )); |
|
405 |
|
406 DMutex* object = (DMutex*) handleAsObject; |
|
407 DMemSpyDriverOSAdaptionDMutex& ma = OSAdaption().DMutex(); |
|
408 // |
|
409 params.iCount = ma.GetHoldCount( *object ); |
|
410 params.iWaitCount = ma.GetWaitCount( *object ); |
|
411 params.iResetting = ma.GetResetting( *object ); |
|
412 params.iOrder = ma.GetOrder( *object ); |
|
413 } |
|
414 else if ( params.iType == EMemSpyDriverContainerTypeTimer ) |
|
415 { |
|
416 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeTimer" )); |
|
417 |
|
418 // Get timer properties |
|
419 DTimer* object = (DTimer*) handleAsObject; |
|
420 DMemSpyDriverOSAdaptionDTimer& ta = OSAdaption().DTimer(); |
|
421 // |
|
422 params.iTimerType = MapToMemSpyTimerType( ta.GetType( *object ) ); |
|
423 params.iTimerState = MapToMemSpyTimerState( ta.GetState( *object ) ); |
|
424 } |
|
425 else if ( params.iType == EMemSpyDriverContainerTypeServer ) |
|
426 { |
|
427 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeServer" )); |
|
428 |
|
429 DServer* object = (DServer*) handleAsObject; |
|
430 DMemSpyDriverOSAdaptionDServer& sa = OSAdaption().DServer(); |
|
431 // |
|
432 params.iCount = sa.GetSessionCount( *object ); |
|
433 params.iId = sa.GetOwningThreadId( *object ); |
|
434 params.iSessionType = sa.GetSessionType( *object ); |
|
435 params.iAddressOfOwningThread = sa.GetAddressOfOwningThread( *object ); |
|
436 sa.GetNameOfOwningThread( *object, params.iNameOfOwner ); |
|
437 } |
|
438 else if ( params.iType == EMemSpyDriverContainerTypeSession ) |
|
439 { |
|
440 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeSession" )); |
|
441 |
|
442 DSession* object = (DSession*) handleAsObject; |
|
443 DMemSpyDriverOSAdaptionDServer& serverAdaption = OSAdaption().DServer(); |
|
444 DMemSpyDriverOSAdaptionDSession& sessionAdaption = OSAdaption().DSession(); |
|
445 |
|
446 params.iName.Zero(); |
|
447 |
|
448 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting session type..." )); |
|
449 params.iSessionType = sessionAdaption.GetSessionType( *object ); |
|
450 params.iAddressOfServer = sessionAdaption.GetAddressOfServer( *object ); |
|
451 params.iTotalAccessCount = sessionAdaption.GetTotalAccessCount( *object ); |
|
452 params.iSvrSessionType = sessionAdaption.GetSessionType( *object ); |
|
453 params.iMsgCount = sessionAdaption.GetMsgCount( *object ); |
|
454 params.iMsgLimit = sessionAdaption.GetMsgLimit( *object ); |
|
455 |
|
456 // Its more useful in this instance, if the name object |
|
457 // points to the server which the session is connected to |
|
458 // (rather than displaying a process-local name). |
|
459 DServer* server = (DServer*)CheckedOpen(EMemSpyDriverContainerTypeServer, sessionAdaption.GetServer( *object )); |
|
460 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting full name, server: 0x%08x", server )); |
|
461 // |
|
462 if ( server ) |
|
463 { |
|
464 server->FullName( params.iName ); |
|
465 |
|
466 // Continue as normal for other items |
|
467 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - server: 0x%08x, server->iOwningThread: 0x%08x", server, server->iOwningThread )); |
|
468 DThread* owningThread = serverAdaption.GetOwningThread( *server ); |
|
469 if ( owningThread ) |
|
470 { |
|
471 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting server thread id..." )); |
|
472 params.iId = serverAdaption.GetOwningThreadId( *server ); |
|
473 } |
|
474 |
|
475 server->Close(NULL); |
|
476 } |
|
477 } |
|
478 else if ( params.iType == EMemSpyDriverContainerTypeLogicalDevice ) |
|
479 { |
|
480 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeLogicalDevice" )); |
|
481 |
|
482 DLogicalDevice* object = (DLogicalDevice*) handleAsObject; |
|
483 DMemSpyDriverOSAdaptionDLogicalDevice& lda = OSAdaption().DLogicalDevice(); |
|
484 params.iOpenChannels = lda.GetOpenChannels( *object ); |
|
485 params.iVersion = lda.GetVersion( *object ); |
|
486 params.iParseMask = lda.GetParseMask( *object ); |
|
487 params.iUnitsMask = lda.GetUnitsMask( *object ); |
|
488 } |
|
489 else if ( params.iType == EMemSpyDriverContainerTypePhysicalDevice ) |
|
490 { |
|
491 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypePhysicalDevice" )); |
|
492 |
|
493 DPhysicalDevice* object = (DPhysicalDevice*) handleAsObject; |
|
494 DMemSpyDriverOSAdaptionDPhysicalDevice& pda = OSAdaption().DPhysicalDevice(); |
|
495 params.iVersion = pda.GetVersion( *object ); |
|
496 params.iUnitsMask = pda.GetUnitsMask( *object ); |
|
497 params.iAddressOfCodeSeg = pda.GetAddressOfCodeSeg( *object ); |
|
498 } |
|
499 else if ( params.iType == EMemSpyDriverContainerTypeLogicalChannel ) |
|
500 { |
|
501 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeLogicalChannel" )); |
|
502 } |
|
503 else if ( params.iType == EMemSpyDriverContainerTypeChangeNotifier ) |
|
504 { |
|
505 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeChangeNotifier" )); |
|
506 |
|
507 DChangeNotifier* object = (DChangeNotifier*) handleAsObject; |
|
508 DMemSpyDriverOSAdaptionDChangeNotifier& cna = OSAdaption().DChangeNotifier(); |
|
509 params.iChanges = cna.GetChanges( *object ); |
|
510 params.iAddressOfOwningThread = cna.GetAddressOfOwningThread( *object ); |
|
511 cna.GetNameOfOwningThread( *object, params.iNameOfOwner ); |
|
512 } |
|
513 else if ( params.iType == EMemSpyDriverContainerTypeUndertaker ) |
|
514 { |
|
515 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeUndertaker" )); |
|
516 |
|
517 DUndertaker* object = (DUndertaker*) handleAsObject; |
|
518 DMemSpyDriverOSAdaptionDUndertaker& uta = OSAdaption().DUndertaker(); |
|
519 params.iAddressOfOwningThread = uta.GetAddressOfOwningThread( *object ); |
|
520 uta.GetNameOfOwningThread( *object, params.iNameOfOwner ); |
|
521 } |
|
522 else if ( params.iType == EMemSpyDriverContainerTypeMsgQueue ) |
|
523 { |
|
524 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeMsgQueue" )); |
|
525 } |
|
526 else if ( params.iType == EMemSpyDriverContainerTypePropertyRef ) |
|
527 { |
|
528 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypePropertyRef" )); |
|
529 } |
|
530 else if ( params.iType == EMemSpyDriverContainerTypeCondVar ) |
|
531 { |
|
532 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeCondVar" )); |
|
533 |
|
534 DCondVar* object = (DCondVar*) handleAsObject; |
|
535 DMemSpyDriverOSAdaptionDCondVar& cva = OSAdaption().DCondVar(); |
|
536 params.iResetting = cva.GetResetting( *object ); |
|
537 params.iAddressOfOwningThread = cva.GetAddressOfMutex( *object ); |
|
538 cva.GetNameOfMutex( *object, params.iNameOfOwner ); |
|
539 params.iWaitCount = cva.GetWaitCount( *object ); |
|
540 } |
|
541 else |
|
542 { |
|
543 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - KErrNotSupported" )); |
|
544 r = KErrNotSupported; |
|
545 } |
|
546 handleAsObject->Close(NULL); |
|
547 } |
|
548 else |
|
549 { |
|
550 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo - couldn not find object => KErrNotFound")); |
|
551 r = KErrNotFound; |
|
552 } |
|
553 |
|
554 NKern::ThreadLeaveCS(); |
|
555 |
|
556 if ( r == KErrNone ) |
|
557 { |
|
558 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo - writing back to client thread...")); |
|
559 r = Kern::ThreadRawWrite( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverHandleInfoGeneric) ); |
|
560 } |
|
561 if ( TempObject() != NULL ) |
|
562 { |
|
563 CloseTempObject(); |
|
564 } |
|
565 |
|
566 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - END - r: %d", r)); |
|
567 return r; |
|
568 } |
|
569 |
|
570 |
|
571 TInt DMemSpyDriverLogChanContainers::GetKernelObjectSizeApproximation( TMemSpyDriverContainerType aType, TInt* aSize ) |
|
572 { |
|
573 TInt r = KErrNone; |
|
574 // |
|
575 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetKernelObjectSizeApproximation() - START - aType: %d", aType)); |
|
576 const TObjectType objectType = ObjectTypeFromMemSpyContainerType( aType ); |
|
577 // |
|
578 TInt size = 0; |
|
579 // |
|
580 switch( objectType ) |
|
581 { |
|
582 case EThread: |
|
583 size = sizeof(DThread); |
|
584 break; |
|
585 case EProcess: |
|
586 size = sizeof(DProcess); |
|
587 break; |
|
588 case EChunk: |
|
589 size = sizeof(DChunk); |
|
590 break; |
|
591 case ELibrary: |
|
592 size = sizeof(DLibrary); |
|
593 break; |
|
594 case ESemaphore: |
|
595 size = sizeof(DSemaphore); |
|
596 break; |
|
597 case EMutex: |
|
598 size = sizeof(DMutex); |
|
599 break; |
|
600 case ETimer: |
|
601 size = sizeof(DTimer); |
|
602 break; |
|
603 case EServer: |
|
604 size = sizeof(DServer); |
|
605 break; |
|
606 case ESession: |
|
607 size = sizeof(DSession); |
|
608 break; |
|
609 case ELogicalDevice: |
|
610 size = sizeof(DLogicalDevice); |
|
611 break; |
|
612 case EPhysicalDevice: |
|
613 size = sizeof(DPhysicalDevice); |
|
614 break; |
|
615 case ELogicalChannel: |
|
616 size = sizeof(DLogicalChannel); |
|
617 break; |
|
618 case EChangeNotifier: |
|
619 size = sizeof(DChangeNotifier); |
|
620 break; |
|
621 case EUndertaker: |
|
622 size = sizeof(DUndertaker); |
|
623 break; |
|
624 case EMsgQueue: |
|
625 size = sizeof(DObject); // best we can do! |
|
626 break; |
|
627 case EPropertyRef: |
|
628 size = sizeof(DObject); // best we can do! |
|
629 break; |
|
630 case ECondVar: |
|
631 size = sizeof(DCondVar); |
|
632 break; |
|
633 default: |
|
634 break; |
|
635 } |
|
636 // |
|
637 NKern::ThreadEnterCS(); |
|
638 r = Kern::ThreadRawWrite( &ClientThread(), aSize, &size, sizeof(TInt) ); |
|
639 NKern::ThreadLeaveCS(); |
|
640 |
|
641 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetKernelObjectSizeApproximation() - END - r: %d, size; %d", r, size)); |
|
642 return r; |
|
643 } |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 |
|
658 TInt DMemSpyDriverLogChanContainers::GetReferencesToMyThread( TUint aTid, TDes8* aBufferSink ) |
|
659 { |
|
660 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetReferencesToMyThread() - START - aTid: %d", aTid )); |
|
661 |
|
662 // We open the source thread or process, just to ensure it doesn't die underneath us... |
|
663 TInt r = OpenTempObject( aTid, EThread ); |
|
664 if ( r == KErrNone ) |
|
665 { |
|
666 TInt count = 0; |
|
667 |
|
668 // Open stream |
|
669 RMemSpyMemStreamWriter stream = OpenXferStream(); |
|
670 |
|
671 // Get references to this thread by searching the handles of other threads |
|
672 TInt32* pCountMarkerThread = stream.WriteInt32( 0 ); |
|
673 count = SearchThreadsFor( TempObject(), stream ); |
|
674 *pCountMarkerThread = count; |
|
675 |
|
676 // Get references to this thread by searching the handles of other processes |
|
677 TInt32* pCountMarkerProcess = stream.WriteInt32( 0 ); |
|
678 count = SearchProcessFor( TempObject(), stream ); |
|
679 *pCountMarkerProcess = count; |
|
680 |
|
681 // Tidy up |
|
682 r = stream.WriteAndClose( aBufferSink ); |
|
683 |
|
684 CloseTempObject(); |
|
685 } |
|
686 |
|
687 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetReferencesToMyThread() - END - r: %d", r)); |
|
688 return r; |
|
689 } |
|
690 |
|
691 |
|
692 TInt DMemSpyDriverLogChanContainers::GetReferencesToMyProcess( TUint aPid, TDes8* aBufferSink ) |
|
693 { |
|
694 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetReferencesToMyProcess() - START - aPid: %d", aPid )); |
|
695 |
|
696 // We open the source thread or process, just to ensure it doesn't die underneath us... |
|
697 TInt r = OpenTempObject( aPid, EProcess ); |
|
698 if ( r == KErrNone ) |
|
699 { |
|
700 TInt count = 0; |
|
701 |
|
702 // Open stream |
|
703 RMemSpyMemStreamWriter stream = OpenXferStream(); |
|
704 |
|
705 // Get references to this thread by searching the handles of other threads |
|
706 TInt32* pCountMarkerThread = stream.WriteInt32( 0 ); |
|
707 count = SearchThreadsFor( TempObject(), stream ); |
|
708 *pCountMarkerThread = count; |
|
709 |
|
710 // Get references to this thread by searching the handles of other processes |
|
711 TInt32* pCountMarkerProcess = stream.WriteInt32( 0 ); |
|
712 count = SearchProcessFor( TempObject(), stream ); |
|
713 *pCountMarkerProcess = count; |
|
714 |
|
715 // Tidy up |
|
716 r = stream.WriteAndClose( aBufferSink ); |
|
717 |
|
718 CloseTempObject(); |
|
719 } |
|
720 |
|
721 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetReferencesToMyProcess() - END - r: %d", r)); |
|
722 return r; |
|
723 } |
|
724 |
|
725 |
|
726 TInt DMemSpyDriverLogChanContainers::GetPAndSInfo( DObject* aHandle, TMemSpyDriverPAndSInfo* aInfo ) |
|
727 { |
|
728 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetPAndSInfo() - START - aHandle: 0x%08x", aHandle )); |
|
729 |
|
730 TInt r = KErrNotFound; |
|
731 NKern::ThreadEnterCS(); |
|
732 |
|
733 // First, locate the specific DObject in question. Cast the handle, but don't use the object... |
|
734 DObject* object = CheckedOpen(EMemSpyDriverContainerTypePropertyRef, aHandle); |
|
735 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetPAndSInfo() - handle search returned: 0x%08x", object )); |
|
736 |
|
737 if ( object != NULL ) |
|
738 { |
|
739 NKern::LockSystem(); // Keep this, the DPropertyRef APIs use it -TomS |
|
740 |
|
741 DMemSpyDriverOSAdaptionDPropertyRef& pra = OSAdaption().DPropertyRef(); |
|
742 const TBool isReady = pra.GetIsReady( *object ); |
|
743 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetPAndSInfo() - isReady: %d", isReady )); |
|
744 |
|
745 if ( isReady ) |
|
746 { |
|
747 TMemSpyDriverPAndSInfo params; |
|
748 // |
|
749 params.iType = pra.GetType( *object ); |
|
750 params.iCategory = pra.GetCategory( *object ); |
|
751 params.iKey = pra.GetKey( *object ); |
|
752 params.iRefCount = pra.GetRefCount( *object ); |
|
753 params.iTid = pra.GetThreadId( *object ); |
|
754 params.iCreatorSID = pra.GetCreatorSID( *object ); |
|
755 // |
|
756 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetPAndSInfo - writing back to client thread...")); |
|
757 r = Kern::ThreadRawWrite( &ClientThread(), aInfo, ¶ms, sizeof( TMemSpyDriverPAndSInfo ) ); |
|
758 } |
|
759 else |
|
760 { |
|
761 r = KErrNotReady; |
|
762 } |
|
763 |
|
764 NKern::UnlockSystem(); |
|
765 object->Close(NULL); |
|
766 } |
|
767 |
|
768 NKern::ThreadLeaveCS(); |
|
769 |
|
770 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetPAndSInfo() - END - r: %d", r)); |
|
771 return r; |
|
772 } |
|
773 |
|
774 |
|
775 TInt DMemSpyDriverLogChanContainers::GetCondVarSuspendedThreads( TMemSpyDriverInternalCondVarSuspendedThreadParams* aParams ) |
|
776 { |
|
777 |
|
778 TMemSpyDriverInternalCondVarSuspendedThreadParams params; |
|
779 TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverInternalCondVarSuspendedThreadParams) ); |
|
780 if ( r != KErrNone ) |
|
781 { |
|
782 TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs() - END - params read error: %d", r)); |
|
783 return r; |
|
784 } |
|
785 |
|
786 DMemSpyDriverOSAdaptionDCondVar& condVarAdaption = OSAdaption().DCondVar(); |
|
787 |
|
788 const TInt maxCount = params.iMaxCount; |
|
789 NKern::ThreadEnterCS(); |
|
790 |
|
791 DObject* condVarHandle = (DObject*) params.iCondVarHandle; |
|
792 condVarHandle = CheckedOpen(EMemSpyDriverContainerTypeCondVar, condVarHandle); |
|
793 if ( condVarHandle == NULL ) |
|
794 { |
|
795 Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs() - END - condVar not found"); |
|
796 NKern::ThreadLeaveCS(); |
|
797 return KErrNotFound; |
|
798 } |
|
799 |
|
800 ResetTempHandles(); |
|
801 |
|
802 DCondVar* condVar = (DCondVar*) condVarHandle; |
|
803 |
|
804 NKern::LockSystem(); // Keep this, needed for iterating suspended queue -TomS |
|
805 |
|
806 // Iterate through suspended threads, writing back thread pointer (handle) |
|
807 // to client |
|
808 SDblQue& suspQueue = condVarAdaption.GetSuspendedQ( *condVar ); |
|
809 SDblQueLink* anchor = &suspQueue.iA; |
|
810 SDblQueLink* link = suspQueue.First(); |
|
811 while( link != anchor ) |
|
812 { |
|
813 DThread* thread = condVarAdaption.GetThread( link ); |
|
814 |
|
815 // Found a match in the specified container. Write the object's handle (aka the object address) |
|
816 // back to the client address space |
|
817 if ( thread ) |
|
818 { |
|
819 AddTempHandle( thread ); |
|
820 } |
|
821 |
|
822 // Get next item |
|
823 link = link->iNext; |
|
824 } |
|
825 |
|
826 NKern::UnlockSystem(); |
|
827 |
|
828 // This variable holds the number of handles that we have already |
|
829 // written to the client-side. |
|
830 TInt currentWriteIndex = 0; |
|
831 const TInt handleCount = TempHandleCount(); |
|
832 TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs - writing %d handles to client...", handleCount ) ); |
|
833 for( ; currentWriteIndex<handleCount && r == KErrNone && currentWriteIndex < maxCount; ) |
|
834 { |
|
835 TAny* handle = TempHandleAt( currentWriteIndex ); |
|
836 r = Kern::ThreadRawWrite( &ClientThread(), params.iThrHandles + currentWriteIndex, &handle, sizeof(TAny*) ); |
|
837 if (r == KErrNone) |
|
838 { |
|
839 ++currentWriteIndex; |
|
840 } |
|
841 } |
|
842 |
|
843 if ( r == KErrBadDescriptor ) |
|
844 { |
|
845 MemSpyDriverUtils::PanicThread( ClientThread(), EPanicBadDescriptor ); |
|
846 } |
|
847 else |
|
848 { |
|
849 const TInt finalWrite = Kern::ThreadRawWrite( &ClientThread(), params.iThrCountPtr, ¤tWriteIndex, sizeof(TInt) ); |
|
850 if ( r == KErrNone ) |
|
851 { |
|
852 r = finalWrite; |
|
853 } |
|
854 } |
|
855 |
|
856 condVarHandle->Close(NULL); |
|
857 NKern::ThreadLeaveCS(); |
|
858 |
|
859 TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs() - END - r: %d", r)); |
|
860 return r; |
|
861 } |
|
862 |
|
863 |
|
864 TInt DMemSpyDriverLogChanContainers::GetCondVarSuspendedThreadInfo( TAny* aThreadHandle, TMemSpyDriverCondVarSuspendedThreadInfo* aParams ) |
|
865 { |
|
866 TMemSpyDriverCondVarSuspendedThreadInfo params; |
|
867 |
|
868 TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverCondVarSuspendedThreadInfo) ); |
|
869 if ( r != KErrNone ) |
|
870 { |
|
871 TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrInfo() - END - params read error: %d", r)); |
|
872 return r; |
|
873 } |
|
874 |
|
875 DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread(); |
|
876 |
|
877 NKern::ThreadEnterCS(); |
|
878 |
|
879 DObject* threadHandle = (DObject*) aThreadHandle; |
|
880 threadHandle = CheckedOpen(EMemSpyDriverContainerTypeThread, threadHandle); |
|
881 if ( threadHandle == NULL ) |
|
882 { |
|
883 Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrInfo() - END - thread not found"); |
|
884 NKern::ThreadLeaveCS(); |
|
885 return KErrNotFound; |
|
886 } |
|
887 |
|
888 DThread* thread = (DThread*) threadHandle; |
|
889 thread->FullName( params.iName ); |
|
890 params.iAddress = (TUint8*)thread; |
|
891 |
|
892 if ( r == KErrNone ) |
|
893 { |
|
894 r = Kern::ThreadRawWrite( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverCondVarSuspendedThreadInfo) ); |
|
895 } |
|
896 |
|
897 threadHandle->Close(NULL); |
|
898 NKern::ThreadLeaveCS(); |
|
899 |
|
900 TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrInfo() - END - r: %d", r)); |
|
901 return r; |
|
902 } |
|
903 |
|
904 |
|
905 |
|
906 |
|
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 TInt DMemSpyDriverLogChanContainers::SearchThreadsFor( DObject* aHandleToLookFor, RMemSpyMemStreamWriter& aStream ) |
|
940 { |
|
941 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor() - START" ) ); |
|
942 |
|
943 TInt matches = 0; |
|
944 DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread(); |
|
945 |
|
946 DObjectCon* container = Kern::Containers()[ EThread ]; |
|
947 NKern::ThreadEnterCS(); |
|
948 container->Wait(); |
|
949 |
|
950 const TInt containerEntryCount = container->Count(); |
|
951 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor - containerEntryCount: %d", containerEntryCount )); |
|
952 |
|
953 for( TInt i=0; i<containerEntryCount && !aStream.IsFull(); i++ ) |
|
954 { |
|
955 DThread* thread = (DThread*) (*container)[ i ]; |
|
956 MemSpyObjectIx* handles = threadAdaption.GetHandles( *thread ); |
|
957 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor - handles: 0x%08x", handles )); |
|
958 |
|
959 if ( handles != NULL ) |
|
960 { |
|
961 TBool found = handles->Find( aHandleToLookFor ); |
|
962 if (found) |
|
963 { |
|
964 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor - found handle match in [%O]", thread )); |
|
965 aStream.WriteUint32( (TUint32) thread ); |
|
966 ++matches; |
|
967 } |
|
968 } |
|
969 } |
|
970 |
|
971 // Finished with thread/process container. |
|
972 container->Signal(); |
|
973 NKern::ThreadLeaveCS(); |
|
974 |
|
975 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor() - END" ) ); |
|
976 return matches; |
|
977 } |
|
978 |
|
979 |
|
980 TInt DMemSpyDriverLogChanContainers::SearchProcessFor( DObject* aHandleToLookFor, RMemSpyMemStreamWriter& aStream ) |
|
981 { |
|
982 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor() - START" ) ); |
|
983 |
|
984 TInt matches = 0; |
|
985 DMemSpyDriverOSAdaptionDProcess& processAdaption = OSAdaption().DProcess(); |
|
986 |
|
987 DObjectCon* container = Kern::Containers()[ EProcess ]; |
|
988 NKern::ThreadEnterCS(); |
|
989 container->Wait(); |
|
990 |
|
991 const TInt containerEntryCount = container->Count(); |
|
992 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor - containerEntryCount: %d", containerEntryCount )); |
|
993 |
|
994 for( TInt i=0; i<containerEntryCount && !aStream.IsFull(); i++ ) |
|
995 { |
|
996 DProcess* process = (DProcess*) (*container)[ i ]; |
|
997 MemSpyObjectIx* handles = processAdaption.GetHandles( *process ); |
|
998 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor - handles: 0x%08x", handles )); |
|
999 |
|
1000 if ( handles != NULL ) |
|
1001 { |
|
1002 TBool found = handles->Find( aHandleToLookFor ); |
|
1003 if ( found ) |
|
1004 { |
|
1005 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor - found handle match in [%O]", process )); |
|
1006 aStream.WriteUint32( (TUint32) process ); |
|
1007 ++matches; |
|
1008 } |
|
1009 } |
|
1010 } |
|
1011 |
|
1012 // Finished with thread/process container. |
|
1013 container->Signal(); |
|
1014 NKern::ThreadLeaveCS(); |
|
1015 |
|
1016 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor() - END" ) ); |
|
1017 return matches; |
|
1018 } |
|
1019 |
|
1020 |
|
1021 TMemSpyDriverTimerState DMemSpyDriverLogChanContainers::MapToMemSpyTimerState( TTimer::TTimerState aState ) |
|
1022 { |
|
1023 TMemSpyDriverTimerState ret = EMemSpyDriverTimerStateUnknown; |
|
1024 // |
|
1025 switch( aState ) |
|
1026 { |
|
1027 case TTimer::EIdle: |
|
1028 ret = EMemSpyDriverTimerStateIdle; |
|
1029 break; |
|
1030 case TTimer::EWaiting: |
|
1031 ret = EMemSpyDriverTimerStateWaiting; |
|
1032 break; |
|
1033 case TTimer::EWaitHighRes: |
|
1034 ret = EMemSpyDriverTimerStateWaitHighRes; |
|
1035 break; |
|
1036 default: |
|
1037 break; |
|
1038 } |
|
1039 // |
|
1040 return ret; |
|
1041 } |
|
1042 |
|
1043 |
|
1044 TMemSpyDriverTimerType DMemSpyDriverLogChanContainers::MapToMemSpyTimerType( TTimer::TTimerType aType ) |
|
1045 { |
|
1046 TMemSpyDriverTimerType ret = EMemSpyDriverTimerTypeUnknown; |
|
1047 // |
|
1048 switch( aType ) |
|
1049 { |
|
1050 case TTimer::ERelative: |
|
1051 case TTimer::ELocked: |
|
1052 ret = EMemSpyDriverTimerTypeRelative; |
|
1053 break; |
|
1054 case TTimer::EAbsolute: |
|
1055 ret = EMemSpyDriverTimerTypeAbsolute; |
|
1056 break; |
|
1057 case TTimer::EHighRes: |
|
1058 ret = EMemSpyDriverTimerTypeHighRes; |
|
1059 break; |
|
1060 case TTimer::EInactivity: |
|
1061 ret = EMemSpyDriverTimerTypeInactivity; |
|
1062 break; |
|
1063 default: |
|
1064 break; |
|
1065 } |
|
1066 // |
|
1067 return ret; |
|
1068 } |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |