|
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 #ifndef MEMSPYDRIVERCLIENT_H |
|
19 #define MEMSPYDRIVERCLIENT_H |
|
20 |
|
21 // System includes |
|
22 #include <e32base.h> |
|
23 #include <e32std.h> |
|
24 #include <e32const.h> |
|
25 |
|
26 // User includes |
|
27 #include <memspy/driver/memspydriverstreamreader.h> |
|
28 #include <memspy/driver/memspydriverobjectsshared.h> |
|
29 #include <memspy/driver/memspydriverenumerationsshared.h> |
|
30 |
|
31 |
|
32 class RMemSpyDriverClient : public RBusLogicalChannel |
|
33 { |
|
34 public: // GENERAL API |
|
35 |
|
36 /** |
|
37 * |
|
38 */ |
|
39 IMPORT_C TInt Open(); |
|
40 |
|
41 /** |
|
42 * |
|
43 */ |
|
44 IMPORT_C void Close(); |
|
45 |
|
46 /** |
|
47 * |
|
48 */ |
|
49 IMPORT_C void GetVersion( TVersion& aVersion ); |
|
50 |
|
51 |
|
52 public: // RAW MEMORY |
|
53 |
|
54 /** |
|
55 * |
|
56 */ |
|
57 IMPORT_C TInt ReadMemory( TUint aTid, TLinAddr aSrc, TDes8& aDest ); |
|
58 |
|
59 |
|
60 public: // CODE SEGS |
|
61 |
|
62 /** |
|
63 * |
|
64 */ |
|
65 IMPORT_C TInt GetCodeSegs( TAny** aHandleArray, TInt& aHandleCount, TBool aOnlyRamLoaded = EFalse ); |
|
66 |
|
67 /** |
|
68 * |
|
69 */ |
|
70 IMPORT_C TInt GetCodeSegs( TUint aPid, TAny** aHandleArray, TInt& aHandleCount ); |
|
71 |
|
72 /** |
|
73 * |
|
74 */ |
|
75 IMPORT_C TInt GetCodeSegInfo( TAny* aHandle, TUint aPid, TMemSpyDriverCodeSegInfo& aInfo ); |
|
76 |
|
77 |
|
78 public: // CHUNKS |
|
79 |
|
80 /** |
|
81 * |
|
82 */ |
|
83 IMPORT_C TInt GetChunkHandles( TAny** aHandleArray, TInt& aHandleCount ); |
|
84 |
|
85 /** |
|
86 * |
|
87 */ |
|
88 IMPORT_C TInt GetChunkInfo( TAny* aHandle, TMemSpyDriverChunkInfo& aInfo ); |
|
89 |
|
90 /** |
|
91 * |
|
92 */ |
|
93 IMPORT_C TInt GetChunkInfo( TAny* aHandle, TMemSpyDriverChunkInfoWithoutName& aInfo ); |
|
94 |
|
95 /** |
|
96 * |
|
97 */ |
|
98 IMPORT_C TInt GetChunkHandlesForProcess( TUint aPid, TAny** aHandleArray, TInt& aHandleCount ); |
|
99 |
|
100 /** |
|
101 * |
|
102 */ |
|
103 IMPORT_C TInt GetChunkHandlesForThread( TUint aTid, TAny** aHandleArray, TInt& aHandleCount ); |
|
104 |
|
105 |
|
106 public: // THREAD & PROCESS |
|
107 |
|
108 /** |
|
109 * |
|
110 */ |
|
111 IMPORT_C TInt GetThreadInfo( TUint aTid, TMemSpyDriverThreadInfo& aInfo ); |
|
112 |
|
113 /** |
|
114 * |
|
115 */ |
|
116 IMPORT_C TInt GetProcessInfo( TUint aPid, TMemSpyDriverProcessInfo& aInfo ); |
|
117 |
|
118 /** |
|
119 * |
|
120 */ |
|
121 IMPORT_C TInt ProcessThreadsSuspend( TUint aPid ); |
|
122 |
|
123 /** |
|
124 * |
|
125 */ |
|
126 IMPORT_C TInt ProcessThreadsResume( TUint aPid ); |
|
127 |
|
128 /** |
|
129 * |
|
130 */ |
|
131 IMPORT_C TInt ThreadEnd( TUint aTid, TExitType aType ); |
|
132 |
|
133 /** |
|
134 * |
|
135 */ |
|
136 IMPORT_C TInt OpenThread( TUint aId, RThread& aThread ); |
|
137 |
|
138 /** |
|
139 * |
|
140 */ |
|
141 IMPORT_C TInt OpenProcess( TUint aId, RProcess& aProcess ); |
|
142 |
|
143 /** |
|
144 * |
|
145 */ |
|
146 IMPORT_C void GetThreadsL( const TProcessId& aId, RArray<TThreadId>& aThreads ); |
|
147 |
|
148 /** |
|
149 * |
|
150 */ |
|
151 IMPORT_C TInt SetPriority( TUint aId, TThreadPriority aPriority ); |
|
152 |
|
153 public: // HEAP INFO |
|
154 |
|
155 /** |
|
156 * |
|
157 */ |
|
158 IMPORT_C TInt GetHeapInfoUser( TMemSpyHeapInfo& aInfo, TUint aTid ); |
|
159 IMPORT_C TInt GetHeapInfoUser( TMemSpyHeapInfo& aInfo, TUint aTid, RArray<TMemSpyDriverFreeCell>& aFreeCells ); |
|
160 IMPORT_C TInt GetHeapInfoUser(TMemSpyHeapInfo& aInfo, TUint aTid, RArray<TMemSpyDriverCell>& aCells, TBool aCollectAllocatedCellsAsWellAsFree); |
|
161 |
|
162 /** |
|
163 * |
|
164 */ |
|
165 IMPORT_C TInt GetHeapInfoKernel( TMemSpyHeapInfo& aInfo ); |
|
166 IMPORT_C TInt GetHeapInfoKernel( TMemSpyHeapInfo& aInfo, RArray<TMemSpyDriverFreeCell>& aFreeCells ); |
|
167 |
|
168 public: // HEAP DATA |
|
169 |
|
170 /** |
|
171 * Get free cell data. If aFreeCellChecksum is 0, then no checksum comparison is performed. |
|
172 */ |
|
173 IMPORT_C TInt GetHeapData( TUint aTid, TUint32 aFreeCellChecksum, TDes8& aDest, TUint& aReadAddress, TUint& aAmountRemaining ); |
|
174 |
|
175 /** |
|
176 * |
|
177 */ |
|
178 IMPORT_C TInt GetHeapDataNext( TUint aTid, TDes8& aDest, TUint& aReadAddress, TUint& aAmountRemaining ); |
|
179 |
|
180 /** |
|
181 * |
|
182 */ |
|
183 IMPORT_C HBufC8* GetHeapDataKernelLC( TMemSpyHeapInfo& aInfo, RArray<TMemSpyDriverFreeCell>& aFreeCells ); |
|
184 |
|
185 |
|
186 public: // HEAP WALK |
|
187 |
|
188 /** |
|
189 * |
|
190 */ |
|
191 IMPORT_C TInt WalkHeapInit( TUint aTid ); |
|
192 |
|
193 /** |
|
194 * |
|
195 */ |
|
196 IMPORT_C TInt WalkHeapNextCell( TUint aTid, TMemSpyDriverCellType& aCellType, TAny*& aCellAddress, TInt& aLength, TInt& aNestingLevel, TInt& aAllocNumber, TInt& aCellheaderSize, TAny*& aCellPayloadAddress ); |
|
197 |
|
198 /** |
|
199 * |
|
200 */ |
|
201 IMPORT_C TInt WalkHeapReadCellData( TAny* aCellAddress, TDes8& aDest, TInt aReadLen ); |
|
202 |
|
203 /** |
|
204 * |
|
205 */ |
|
206 IMPORT_C TInt WalkHeapGetCellInfo( TAny*& aCellAddress, TMemSpyDriverCellType& aCellType, TInt& aLength, TInt& aNestingLevel, TInt& aAllocNumber, TInt& aCellheaderSize, TAny*& aCellPayloadAddress ); |
|
207 |
|
208 /** |
|
209 * |
|
210 */ |
|
211 IMPORT_C void WalkHeapClose(); |
|
212 |
|
213 |
|
214 public: // STACK RELATED |
|
215 |
|
216 /** |
|
217 * |
|
218 */ |
|
219 IMPORT_C TInt GetStackInfo( TUint aTid, TMemSpyDriverStackInfo& aInfo ); |
|
220 |
|
221 /** |
|
222 * |
|
223 */ |
|
224 IMPORT_C TInt GetStackData( TUint aTid, TDes8& aDest, TUint& aAmountRemaining, TMemSpyDriverDomainType aDomain = EMemSpyDriverDomainUser, TBool aEntireStack = ETrue ); |
|
225 |
|
226 /** |
|
227 * |
|
228 */ |
|
229 IMPORT_C TInt GetStackDataNext( TUint aTid, TDes8& aDest, TUint& aAmountRemaining, TMemSpyDriverDomainType aDomain = EMemSpyDriverDomainUser, TBool aEntireStack = ETrue ); |
|
230 |
|
231 |
|
232 public: // EVENT MONITOR |
|
233 |
|
234 /** |
|
235 * @returns TInt handle |
|
236 */ |
|
237 IMPORT_C TInt EventMonitorOpen( TUint& aHandle ); |
|
238 |
|
239 /** |
|
240 * |
|
241 */ |
|
242 IMPORT_C TInt EventMonitorClose( TUint aHandle ); |
|
243 |
|
244 /** |
|
245 * |
|
246 */ |
|
247 IMPORT_C void EventMonitorNotify( TUint aHandle, TRequestStatus& aStatus, TUint& aContext ); |
|
248 |
|
249 /** |
|
250 * |
|
251 */ |
|
252 IMPORT_C void EventMonitorNotifyCancel( TUint aHandle ); |
|
253 |
|
254 |
|
255 public: // PROCESS INSPECTION |
|
256 |
|
257 /** |
|
258 * |
|
259 */ |
|
260 IMPORT_C TInt ProcessInspectionOpen( TUint aPid ); |
|
261 |
|
262 /** |
|
263 * |
|
264 */ |
|
265 IMPORT_C TInt ProcessInspectionClose( TUint aPid ); |
|
266 |
|
267 /** |
|
268 * |
|
269 */ |
|
270 IMPORT_C void ProcessInspectionRequestChanges( TUint aPid, TRequestStatus& aStatus, TMemSpyDriverProcessInspectionInfo& aInfo ); |
|
271 |
|
272 /** |
|
273 * |
|
274 */ |
|
275 IMPORT_C void ProcessInspectionRequestChangesCancel( TUint aPid ); |
|
276 |
|
277 /** |
|
278 * |
|
279 */ |
|
280 IMPORT_C void ProcessInspectionAutoStartItemsReset(); |
|
281 |
|
282 /** |
|
283 * |
|
284 */ |
|
285 IMPORT_C TInt ProcessInspectionAutoStartItemsAdd( TUint aSID ); |
|
286 |
|
287 |
|
288 public: // Handles related |
|
289 |
|
290 /** |
|
291 * Get all of the handles in a specific container |
|
292 */ |
|
293 IMPORT_C TInt GetContainerHandles( TMemSpyDriverContainerType aContainer, TAny** aHandleArray, TInt& aHandleCount ); |
|
294 |
|
295 /** |
|
296 * Get all handles of a specific type, for a specific thread. |
|
297 */ |
|
298 IMPORT_C TInt GetThreadHandlesByType( TInt aTid, TMemSpyDriverContainerType aType, TAny** aHandleArray, TInt& aHandleCount ); |
|
299 |
|
300 /** |
|
301 * Get all handles of a specific type, for a specific process. |
|
302 */ |
|
303 IMPORT_C TInt GetProcessHandlesByType( TInt aPid, TMemSpyDriverContainerType aType, TAny** aHandleArray, TInt& aHandleCount ); |
|
304 |
|
305 /** |
|
306 * Get handle info for a specific handle owner by a specific thread. If the handle is not thread-specific, then |
|
307 * use KMemSpyDriverEnumerateContainerHandles as the aTid parameter. |
|
308 */ |
|
309 IMPORT_C TInt GetGenericHandleInfo( TInt aTid, TMemSpyDriverContainerType aType, TAny* aHandle, TMemSpyDriverHandleInfoGeneric& aParams ); |
|
310 |
|
311 /** |
|
312 * Fetches the in-memory size of a specific kernel object (where possible). The size is an approximation since |
|
313 * it doesn't take into account the size of ASSP-specific classes. |
|
314 */ |
|
315 IMPORT_C TInt GetApproximateKernelObjectSize( TMemSpyDriverContainerType aType ); |
|
316 |
|
317 /** |
|
318 * Use this method to identify the handles of threads & processes that happen to reference |
|
319 * the specified thread or process. |
|
320 * |
|
321 * In brief, every kernel-side thread and process object contains a handle container. This container |
|
322 * is the DObject-handles which the thread or process has open. |
|
323 * |
|
324 * This method can be used to search all of the other handle containers within other threads & processes |
|
325 * to see if any of those handle containers happen to reference the specified thread or process (as defined by |
|
326 * aTid or aPid). |
|
327 */ |
|
328 IMPORT_C TInt GetReferencesToMyThread( TUint aTid ); |
|
329 IMPORT_C TInt GetReferencesToMyProcess( TUint aPid ); |
|
330 |
|
331 /** |
|
332 * Get info about a P&S kernel object |
|
333 */ |
|
334 IMPORT_C TInt GetPAndSInfo( TAny* aHandle, TMemSpyDriverPAndSInfo& aInfo ); |
|
335 |
|
336 /** |
|
337 * Get handles to suspended threads from a CondVar |
|
338 */ |
|
339 IMPORT_C TInt GetCondVarSuspendedThreads( TAny* aCondVarHandle, TAny** aThreadHandleArray, TInt& aThreadCount ); |
|
340 |
|
341 /** |
|
342 * Get info about CondVar suspended thread |
|
343 */ |
|
344 IMPORT_C TInt GetCondVarSuspendedThreadInfo( TAny* aHandle, TMemSpyDriverCondVarSuspendedThreadInfo& aInfo ); |
|
345 |
|
346 public: // CLIENT <-> SERVER |
|
347 |
|
348 /** |
|
349 * Gets handles of all sessions that are connected to a particular server |
|
350 */ |
|
351 IMPORT_C TInt GetServerSessionHandles( TAny* aServerHandle, TAny** aSessionHandleArray, TInt& aSessionHandleCount ); |
|
352 |
|
353 /** |
|
354 * Gets session information for a given session handle. |
|
355 */ |
|
356 IMPORT_C TInt GetServerSessionInfo( TAny* aSessionHandle, TMemSpyDriverServerSessionInfo& aParams ); |
|
357 |
|
358 |
|
359 public: // STREAM INTERFACE |
|
360 |
|
361 /** |
|
362 * Opens a MemSpy data stream for reading |
|
363 */ |
|
364 IMPORT_C RMemSpyMemStreamReader StreamOpenL(); |
|
365 |
|
366 public: // MISC |
|
367 |
|
368 /** |
|
369 * |
|
370 */ |
|
371 IMPORT_C TMemSpyMemoryModelType MemoryModelType(); |
|
372 |
|
373 /** |
|
374 * |
|
375 */ |
|
376 IMPORT_C TBool IsDebugKernel(); |
|
377 |
|
378 /** |
|
379 * Round value to a multiple of the current page size |
|
380 * |
|
381 */ |
|
382 IMPORT_C TUint32 RoundToPageSize( TUint32 aValue ); |
|
383 |
|
384 /** |
|
385 * |
|
386 */ |
|
387 IMPORT_C TInt Impersonate( TUint32 aValue ); |
|
388 |
|
389 private: // Internal methods |
|
390 static TUint RHeapVTable(); |
|
391 static TBool DebugEUser(); |
|
392 void ResetStreamBuffer(); |
|
393 void ReadHeapInfoFreeCellsFromXferBufferL( RArray<TMemSpyDriverFreeCell>& aFreeCells ); |
|
394 |
|
395 private: // Data members |
|
396 RBuf8 iBuffer; |
|
397 }; |
|
398 |
|
399 |
|
400 |
|
401 #endif |