51
|
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 |
|
62
|
745 |
TMemSpyDriverPAndSInfo params;
|
51
|
746 |
if ( isReady )
|
|
747 |
{
|
62
|
748 |
//TMemSpyDriverPAndSInfo params;
|
51
|
749 |
//
|
|
750 |
params.iType = pra.GetType( *object );
|
|
751 |
params.iCategory = pra.GetCategory( *object );
|
|
752 |
params.iKey = pra.GetKey( *object );
|
|
753 |
params.iRefCount = pra.GetRefCount( *object );
|
|
754 |
params.iTid = pra.GetThreadId( *object );
|
|
755 |
params.iCreatorSID = pra.GetCreatorSID( *object );
|
|
756 |
//
|
|
757 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetPAndSInfo - writing back to client thread..."));
|
62
|
758 |
//r = Kern::ThreadRawWrite( &ClientThread(), aInfo, ¶ms, sizeof( TMemSpyDriverPAndSInfo ) );
|
|
759 |
r = KErrNone; //--
|
51
|
760 |
}
|
|
761 |
else
|
|
762 |
{
|
|
763 |
r = KErrNotReady;
|
|
764 |
}
|
|
765 |
|
|
766 |
NKern::UnlockSystem();
|
62
|
767 |
//--
|
|
768 |
if( r == KErrNone )
|
|
769 |
{
|
|
770 |
r = Kern::ThreadRawWrite( &ClientThread(), aInfo, ¶ms, sizeof( TMemSpyDriverPAndSInfo ) );
|
|
771 |
}
|
|
772 |
|
|
773 |
//--
|
51
|
774 |
object->Close(NULL);
|
|
775 |
}
|
|
776 |
|
|
777 |
NKern::ThreadLeaveCS();
|
|
778 |
|
|
779 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetPAndSInfo() - END - r: %d", r));
|
|
780 |
return r;
|
|
781 |
}
|
|
782 |
|
|
783 |
|
|
784 |
TInt DMemSpyDriverLogChanContainers::GetCondVarSuspendedThreads( TMemSpyDriverInternalCondVarSuspendedThreadParams* aParams )
|
|
785 |
{
|
|
786 |
|
|
787 |
TMemSpyDriverInternalCondVarSuspendedThreadParams params;
|
|
788 |
TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverInternalCondVarSuspendedThreadParams) );
|
|
789 |
if ( r != KErrNone )
|
|
790 |
{
|
|
791 |
TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs() - END - params read error: %d", r));
|
|
792 |
return r;
|
|
793 |
}
|
|
794 |
|
|
795 |
DMemSpyDriverOSAdaptionDCondVar& condVarAdaption = OSAdaption().DCondVar();
|
|
796 |
|
|
797 |
const TInt maxCount = params.iMaxCount;
|
|
798 |
NKern::ThreadEnterCS();
|
|
799 |
|
|
800 |
DObject* condVarHandle = (DObject*) params.iCondVarHandle;
|
|
801 |
condVarHandle = CheckedOpen(EMemSpyDriverContainerTypeCondVar, condVarHandle);
|
|
802 |
if ( condVarHandle == NULL )
|
|
803 |
{
|
|
804 |
Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs() - END - condVar not found");
|
|
805 |
NKern::ThreadLeaveCS();
|
|
806 |
return KErrNotFound;
|
|
807 |
}
|
|
808 |
|
|
809 |
ResetTempHandles();
|
|
810 |
|
|
811 |
DCondVar* condVar = (DCondVar*) condVarHandle;
|
|
812 |
|
|
813 |
NKern::LockSystem(); // Keep this, needed for iterating suspended queue -TomS
|
|
814 |
|
|
815 |
// Iterate through suspended threads, writing back thread pointer (handle)
|
|
816 |
// to client
|
|
817 |
SDblQue& suspQueue = condVarAdaption.GetSuspendedQ( *condVar );
|
|
818 |
SDblQueLink* anchor = &suspQueue.iA;
|
|
819 |
SDblQueLink* link = suspQueue.First();
|
|
820 |
while( link != anchor )
|
|
821 |
{
|
|
822 |
DThread* thread = condVarAdaption.GetThread( link );
|
|
823 |
|
|
824 |
// Found a match in the specified container. Write the object's handle (aka the object address)
|
|
825 |
// back to the client address space
|
|
826 |
if ( thread )
|
|
827 |
{
|
|
828 |
AddTempHandle( thread );
|
|
829 |
}
|
|
830 |
|
|
831 |
// Get next item
|
|
832 |
link = link->iNext;
|
|
833 |
}
|
|
834 |
|
|
835 |
NKern::UnlockSystem();
|
|
836 |
|
|
837 |
// This variable holds the number of handles that we have already
|
|
838 |
// written to the client-side.
|
|
839 |
TInt currentWriteIndex = 0;
|
|
840 |
const TInt handleCount = TempHandleCount();
|
|
841 |
TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs - writing %d handles to client...", handleCount ) );
|
|
842 |
for( ; currentWriteIndex<handleCount && r == KErrNone && currentWriteIndex < maxCount; )
|
|
843 |
{
|
|
844 |
TAny* handle = TempHandleAt( currentWriteIndex );
|
|
845 |
r = Kern::ThreadRawWrite( &ClientThread(), params.iThrHandles + currentWriteIndex, &handle, sizeof(TAny*) );
|
|
846 |
if (r == KErrNone)
|
|
847 |
{
|
|
848 |
++currentWriteIndex;
|
|
849 |
}
|
|
850 |
}
|
|
851 |
|
|
852 |
if ( r == KErrBadDescriptor )
|
|
853 |
{
|
|
854 |
MemSpyDriverUtils::PanicThread( ClientThread(), EPanicBadDescriptor );
|
|
855 |
}
|
|
856 |
else
|
|
857 |
{
|
|
858 |
const TInt finalWrite = Kern::ThreadRawWrite( &ClientThread(), params.iThrCountPtr, ¤tWriteIndex, sizeof(TInt) );
|
|
859 |
if ( r == KErrNone )
|
|
860 |
{
|
|
861 |
r = finalWrite;
|
|
862 |
}
|
|
863 |
}
|
|
864 |
|
|
865 |
condVarHandle->Close(NULL);
|
|
866 |
NKern::ThreadLeaveCS();
|
|
867 |
|
|
868 |
TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs() - END - r: %d", r));
|
|
869 |
return r;
|
|
870 |
}
|
|
871 |
|
|
872 |
|
|
873 |
TInt DMemSpyDriverLogChanContainers::GetCondVarSuspendedThreadInfo( TAny* aThreadHandle, TMemSpyDriverCondVarSuspendedThreadInfo* aParams )
|
|
874 |
{
|
|
875 |
TMemSpyDriverCondVarSuspendedThreadInfo params;
|
|
876 |
|
|
877 |
TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverCondVarSuspendedThreadInfo) );
|
|
878 |
if ( r != KErrNone )
|
|
879 |
{
|
|
880 |
TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrInfo() - END - params read error: %d", r));
|
|
881 |
return r;
|
62
|
882 |
}
|
51
|
883 |
|
|
884 |
NKern::ThreadEnterCS();
|
|
885 |
|
|
886 |
DObject* threadHandle = (DObject*) aThreadHandle;
|
|
887 |
threadHandle = CheckedOpen(EMemSpyDriverContainerTypeThread, threadHandle);
|
|
888 |
if ( threadHandle == NULL )
|
|
889 |
{
|
|
890 |
Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrInfo() - END - thread not found");
|
|
891 |
NKern::ThreadLeaveCS();
|
|
892 |
return KErrNotFound;
|
|
893 |
}
|
|
894 |
|
|
895 |
DThread* thread = (DThread*) threadHandle;
|
|
896 |
thread->FullName( params.iName );
|
|
897 |
params.iAddress = (TUint8*)thread;
|
|
898 |
|
|
899 |
if ( r == KErrNone )
|
|
900 |
{
|
|
901 |
r = Kern::ThreadRawWrite( &ClientThread(), aParams, ¶ms, sizeof(TMemSpyDriverCondVarSuspendedThreadInfo) );
|
|
902 |
}
|
|
903 |
|
|
904 |
threadHandle->Close(NULL);
|
|
905 |
NKern::ThreadLeaveCS();
|
|
906 |
|
|
907 |
TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrInfo() - END - r: %d", r));
|
|
908 |
return r;
|
|
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 |
|
|
940 |
|
|
941 |
|
|
942 |
|
|
943 |
|
|
944 |
|
|
945 |
|
|
946 |
TInt DMemSpyDriverLogChanContainers::SearchThreadsFor( DObject* aHandleToLookFor, RMemSpyMemStreamWriter& aStream )
|
|
947 |
{
|
|
948 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor() - START" ) );
|
|
949 |
|
|
950 |
TInt matches = 0;
|
|
951 |
DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread();
|
|
952 |
|
|
953 |
DObjectCon* container = Kern::Containers()[ EThread ];
|
|
954 |
NKern::ThreadEnterCS();
|
|
955 |
container->Wait();
|
|
956 |
|
|
957 |
const TInt containerEntryCount = container->Count();
|
|
958 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor - containerEntryCount: %d", containerEntryCount ));
|
|
959 |
|
|
960 |
for( TInt i=0; i<containerEntryCount && !aStream.IsFull(); i++ )
|
|
961 |
{
|
|
962 |
DThread* thread = (DThread*) (*container)[ i ];
|
|
963 |
MemSpyObjectIx* handles = threadAdaption.GetHandles( *thread );
|
|
964 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor - handles: 0x%08x", handles ));
|
|
965 |
|
|
966 |
if ( handles != NULL )
|
|
967 |
{
|
|
968 |
TBool found = handles->Find( aHandleToLookFor );
|
|
969 |
if (found)
|
|
970 |
{
|
|
971 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor - found handle match in [%O]", thread ));
|
|
972 |
aStream.WriteUint32( (TUint32) thread );
|
|
973 |
++matches;
|
|
974 |
}
|
|
975 |
}
|
|
976 |
}
|
|
977 |
|
|
978 |
// Finished with thread/process container.
|
|
979 |
container->Signal();
|
|
980 |
NKern::ThreadLeaveCS();
|
|
981 |
|
|
982 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor() - END" ) );
|
|
983 |
return matches;
|
|
984 |
}
|
|
985 |
|
|
986 |
|
|
987 |
TInt DMemSpyDriverLogChanContainers::SearchProcessFor( DObject* aHandleToLookFor, RMemSpyMemStreamWriter& aStream )
|
|
988 |
{
|
|
989 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor() - START" ) );
|
|
990 |
|
|
991 |
TInt matches = 0;
|
|
992 |
DMemSpyDriverOSAdaptionDProcess& processAdaption = OSAdaption().DProcess();
|
|
993 |
|
|
994 |
DObjectCon* container = Kern::Containers()[ EProcess ];
|
|
995 |
NKern::ThreadEnterCS();
|
|
996 |
container->Wait();
|
|
997 |
|
|
998 |
const TInt containerEntryCount = container->Count();
|
|
999 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor - containerEntryCount: %d", containerEntryCount ));
|
|
1000 |
|
|
1001 |
for( TInt i=0; i<containerEntryCount && !aStream.IsFull(); i++ )
|
|
1002 |
{
|
|
1003 |
DProcess* process = (DProcess*) (*container)[ i ];
|
|
1004 |
MemSpyObjectIx* handles = processAdaption.GetHandles( *process );
|
|
1005 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor - handles: 0x%08x", handles ));
|
|
1006 |
|
|
1007 |
if ( handles != NULL )
|
|
1008 |
{
|
|
1009 |
TBool found = handles->Find( aHandleToLookFor );
|
|
1010 |
if ( found )
|
|
1011 |
{
|
|
1012 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor - found handle match in [%O]", process ));
|
|
1013 |
aStream.WriteUint32( (TUint32) process );
|
|
1014 |
++matches;
|
|
1015 |
}
|
|
1016 |
}
|
|
1017 |
}
|
|
1018 |
|
|
1019 |
// Finished with thread/process container.
|
|
1020 |
container->Signal();
|
|
1021 |
NKern::ThreadLeaveCS();
|
|
1022 |
|
|
1023 |
TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor() - END" ) );
|
|
1024 |
return matches;
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
|
|
1028 |
TMemSpyDriverTimerState DMemSpyDriverLogChanContainers::MapToMemSpyTimerState( TTimer::TTimerState aState )
|
|
1029 |
{
|
|
1030 |
TMemSpyDriverTimerState ret = EMemSpyDriverTimerStateUnknown;
|
|
1031 |
//
|
|
1032 |
switch( aState )
|
|
1033 |
{
|
|
1034 |
case TTimer::EIdle:
|
|
1035 |
ret = EMemSpyDriverTimerStateIdle;
|
|
1036 |
break;
|
|
1037 |
case TTimer::EWaiting:
|
|
1038 |
ret = EMemSpyDriverTimerStateWaiting;
|
|
1039 |
break;
|
|
1040 |
case TTimer::EWaitHighRes:
|
|
1041 |
ret = EMemSpyDriverTimerStateWaitHighRes;
|
|
1042 |
break;
|
|
1043 |
default:
|
|
1044 |
break;
|
|
1045 |
}
|
|
1046 |
//
|
|
1047 |
return ret;
|
|
1048 |
}
|
|
1049 |
|
|
1050 |
|
|
1051 |
TMemSpyDriverTimerType DMemSpyDriverLogChanContainers::MapToMemSpyTimerType( TTimer::TTimerType aType )
|
|
1052 |
{
|
|
1053 |
TMemSpyDriverTimerType ret = EMemSpyDriverTimerTypeUnknown;
|
|
1054 |
//
|
|
1055 |
switch( aType )
|
|
1056 |
{
|
|
1057 |
case TTimer::ERelative:
|
|
1058 |
case TTimer::ELocked:
|
|
1059 |
ret = EMemSpyDriverTimerTypeRelative;
|
|
1060 |
break;
|
|
1061 |
case TTimer::EAbsolute:
|
|
1062 |
ret = EMemSpyDriverTimerTypeAbsolute;
|
|
1063 |
break;
|
|
1064 |
case TTimer::EHighRes:
|
|
1065 |
ret = EMemSpyDriverTimerTypeHighRes;
|
|
1066 |
break;
|
|
1067 |
case TTimer::EInactivity:
|
|
1068 |
ret = EMemSpyDriverTimerTypeInactivity;
|
|
1069 |
break;
|
|
1070 |
default:
|
|
1071 |
break;
|
|
1072 |
}
|
|
1073 |
//
|
|
1074 |
return ret;
|
|
1075 |
}
|
|
1076 |
|
|
1077 |
|
|
1078 |
|
|
1079 |
|
|
1080 |
|
|
1081 |
|
|
1082 |
|
|
1083 |
|