|
1 /* |
|
2 * Copyright (c) 2004 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 |
|
19 #ifndef __TRKKERNELDRIVER_H__ |
|
20 #define __TRKKERNELDRIVER_H__ |
|
21 |
|
22 // |
|
23 // class TCapsMetroTrkDriver |
|
24 // |
|
25 class TCapsMetroTrkDriver |
|
26 { |
|
27 public: |
|
28 TVersion iVersion; |
|
29 }; |
|
30 |
|
31 |
|
32 // |
|
33 // class SEventInfo |
|
34 // |
|
35 class SEventInfo |
|
36 { |
|
37 public: |
|
38 |
|
39 enum TEventType |
|
40 { |
|
41 EUnknown = -1, |
|
42 EThreadBreakPoint, |
|
43 EThreadException, |
|
44 EThreadPanic, |
|
45 EProcessPanic, |
|
46 ELibraryLoaded, |
|
47 ELibraryUnloaded, |
|
48 EUserTrace, |
|
49 EProcessAdded |
|
50 }; |
|
51 |
|
52 inline SEventInfo() { Reset(); }; |
|
53 |
|
54 inline void Reset() { iProcessId = 0; |
|
55 iThreadId = 0; |
|
56 iCurrentPC = 0; |
|
57 iExceptionNumber = 0; |
|
58 iFileName.FillZ(); |
|
59 iPanicCategory.FillZ(); |
|
60 iCodeAddress = 0; |
|
61 iDataAddress = 0; |
|
62 iEventType = EUnknown; |
|
63 iTraceData.FillZ(); |
|
64 iTraceDataLen = 0; |
|
65 iPanicReason = 0; |
|
66 iUid = 0; |
|
67 }; |
|
68 public: |
|
69 |
|
70 TUint32 iProcessId; |
|
71 TUint32 iThreadId; |
|
72 TUint32 iCurrentPC; |
|
73 TInt iExceptionNumber; // from TExcType |
|
74 TBuf8<KMaxName> iFileName; |
|
75 TBuf8<KMaxName> iPanicCategory; |
|
76 TUint32 iCodeAddress; |
|
77 TUint32 iDataAddress; |
|
78 TEventType iEventType; |
|
79 TBuf8<260> iTraceData; |
|
80 TInt iTraceDataLen; |
|
81 // START_PANIC |
|
82 TInt iPanicReason; |
|
83 // END_PANIC |
|
84 TUint32 iUid; |
|
85 }; |
|
86 |
|
87 |
|
88 // |
|
89 // class TMetroTrkBreakInfo |
|
90 // |
|
91 class TMetroTrkBreakInfo |
|
92 { |
|
93 public: |
|
94 |
|
95 inline TMetroTrkBreakInfo(const TUint32 aAddress, const TBool aThumbMode, TInt32 *aId, const TUint32 aProcessId) |
|
96 : iAddress(aAddress), |
|
97 iThumbMode(aThumbMode), |
|
98 iId(aId), |
|
99 iProcessId(aProcessId) {}; |
|
100 |
|
101 public: |
|
102 |
|
103 TUint32 iAddress; |
|
104 TBool iThumbMode; |
|
105 TInt32* iId; |
|
106 TUint32 iProcessId; |
|
107 }; |
|
108 |
|
109 |
|
110 // |
|
111 // class TMetroTrkMemoryInfo |
|
112 // |
|
113 class TMetroTrkMemoryInfo |
|
114 { |
|
115 public: |
|
116 |
|
117 inline TMetroTrkMemoryInfo(const TUint32 aAddress, const TInt32 aLength, TDesC8 *aData) |
|
118 : iAddress(aAddress), |
|
119 iLength(aLength), |
|
120 iData(aData) {}; |
|
121 |
|
122 public: |
|
123 |
|
124 TUint32 iAddress; |
|
125 TInt16 iLength; |
|
126 TDesC8* iData; |
|
127 }; |
|
128 |
|
129 |
|
130 // |
|
131 // class TMetroTrkRegisterInfo |
|
132 // |
|
133 class TMetroTrkRegisterInfo |
|
134 { |
|
135 public: |
|
136 |
|
137 inline TMetroTrkRegisterInfo(const TInt16 aFirstRegister, const TInt16 aLastRegister, TDesC8 *aValues) |
|
138 : iFirstRegister(aFirstRegister), |
|
139 iLastRegister(aLastRegister), |
|
140 iValues(aValues) {}; |
|
141 |
|
142 public: |
|
143 |
|
144 TInt16 iFirstRegister; |
|
145 TInt16 iLastRegister; |
|
146 TDesC8* iValues; |
|
147 }; |
|
148 |
|
149 |
|
150 // |
|
151 // class TMetroTrkTaskInfo |
|
152 // |
|
153 class TMetroTrkTaskInfo |
|
154 { |
|
155 public: |
|
156 |
|
157 inline TMetroTrkTaskInfo(TUint32 aOtherId) |
|
158 : iId(0), |
|
159 iOtherId(aOtherId), |
|
160 iPriority(0) { iName.FillZ(); }; |
|
161 |
|
162 public: |
|
163 |
|
164 TUint32 iId; |
|
165 TUint32 iOtherId; |
|
166 TUint32 iPriority; |
|
167 TBuf8<KMaxName> iName; |
|
168 }; |
|
169 |
|
170 |
|
171 // |
|
172 // class TMetroTrkStepInfo |
|
173 // |
|
174 class TMetroTrkStepInfo |
|
175 { |
|
176 public: |
|
177 |
|
178 inline TMetroTrkStepInfo(const TUint32 aStartAddress, const TUint32 aStopAddress, const TBool aStepInto) |
|
179 : iStartAddress(aStartAddress), |
|
180 iStopAddress(aStopAddress), |
|
181 iStepInto(aStepInto) {}; |
|
182 |
|
183 public: |
|
184 |
|
185 TUint32 iStartAddress; |
|
186 TUint32 iStopAddress; |
|
187 TBool iStepInto; |
|
188 }; |
|
189 |
|
190 |
|
191 // |
|
192 // class TMetroTrkDriverInfo |
|
193 // |
|
194 class TMetroTrkDriverInfo |
|
195 { |
|
196 public: |
|
197 |
|
198 TUint32 iPanic1Address; |
|
199 TUint32 iPanic2Address; |
|
200 TUint32 iException1Address; |
|
201 TUint32 iException2Address; |
|
202 TUint32 iLibraryLoadedAddress; |
|
203 TUint32 iUserLibraryEnd; |
|
204 }; |
|
205 |
|
206 |
|
207 // |
|
208 // class TMetroTrkProcessInfo |
|
209 // |
|
210 class TMetroTrkProcessInfo |
|
211 { |
|
212 public: |
|
213 |
|
214 inline TMetroTrkProcessInfo(TUint32 *aCodeAddress, TUint32 *aDataAddress) |
|
215 : iCodeAddress(aCodeAddress), |
|
216 iDataAddress(aDataAddress) {}; |
|
217 |
|
218 public: |
|
219 |
|
220 TUint32* iCodeAddress; |
|
221 TUint32* iDataAddress; |
|
222 }; |
|
223 |
|
224 class TMetroTrkLibInfo |
|
225 { |
|
226 public: |
|
227 |
|
228 inline TMetroTrkLibInfo(TUint32 aLength, TDesC8* aFileName) |
|
229 : iCodeAddress(0xFFFFFFFF), |
|
230 iDataAddress(0xFFFFFFFF), |
|
231 iAttachProcessId(0), |
|
232 iAttachThreadId(0), |
|
233 iFileNameLength(aLength), |
|
234 iFileName(aFileName) |
|
235 {}; |
|
236 |
|
237 public: |
|
238 //TBuf8<KMaxFileName> iFileName; |
|
239 TUint32 iCodeAddress; |
|
240 TUint32 iDataAddress; |
|
241 TUint32 iAttachProcessId; |
|
242 TUint32 iAttachThreadId; |
|
243 TUint32 iFileNameLength; |
|
244 TDesC8* iFileName; |
|
245 }; |
|
246 |
|
247 class TMetroTrkExeInfo |
|
248 { |
|
249 public: |
|
250 |
|
251 inline TMetroTrkExeInfo(TUint32 aUid, TUint32 aLength, TDesC8* aFileName) |
|
252 : iProcessID(0), |
|
253 iThreadID(0), |
|
254 iUid(aUid), |
|
255 iCodeAddress(0xFFFFFFFF), |
|
256 iDataAddress(0xFFFFFFFF), |
|
257 iFileNameLength(aLength), |
|
258 iFileName(aFileName) |
|
259 {}; |
|
260 |
|
261 public: |
|
262 TUint32 iProcessID; |
|
263 TUint32 iThreadID; |
|
264 TUint32 iUid; |
|
265 TUint32 iCodeAddress; |
|
266 TUint32 iDataAddress; |
|
267 TUint32 iFileNameLength; |
|
268 TDesC8* iFileName; |
|
269 }; |
|
270 |
|
271 class TMetroTrkProcUidInfo |
|
272 { |
|
273 public: |
|
274 inline TMetroTrkProcUidInfo(TUint32 aProcID) |
|
275 : iProcessID(aProcID), |
|
276 iUid1(0), |
|
277 iUid2(0), |
|
278 iUid3(0), |
|
279 iSecurID(0), |
|
280 iVendorID(0) |
|
281 {}; |
|
282 |
|
283 public: |
|
284 TUint32 iProcessID; |
|
285 TUint32 iUid1; |
|
286 TUint32 iUid2; |
|
287 TUint32 iUid3; |
|
288 TUint32 iSecurID; |
|
289 TUint32 iVendorID; |
|
290 }; |
|
291 |
|
292 class TTrkLibName |
|
293 { |
|
294 public: |
|
295 inline TTrkLibName() { iName.FillZ(); iEmptySlot = ETrue;}; |
|
296 inline TTrkLibName(TDesC8 aName) { iName.Copy(aName); iEmptySlot = EFalse; }; |
|
297 |
|
298 TBuf8<KMaxLibraryName> iName; |
|
299 TBool iEmptySlot; |
|
300 }; |
|
301 |
|
302 // |
|
303 // class RMetroTrkDriver |
|
304 // |
|
305 class RMetroTrkDriver : public RBusLogicalChannel |
|
306 { |
|
307 public: |
|
308 |
|
309 enum TControl |
|
310 { |
|
311 EControlSetBreak = 0, |
|
312 EControlClearBreak, |
|
313 EControlChangeBreakThread, |
|
314 EControlSuspendThread, |
|
315 EControlResumeThread, |
|
316 EControlStepRange, |
|
317 EControlReadMemory, |
|
318 EControlWriteMemory, |
|
319 EControlReadRegisters, |
|
320 EControlWriteRegisters, |
|
321 EControlGetProcessInfo, |
|
322 EControlGetThreadInfo, |
|
323 EControlGetProcessAddresses, |
|
324 EControlGetStaticLibraryInfo, |
|
325 EControlEnableLibLoadedEvent, |
|
326 EControlDisableLibLoadedEvent, |
|
327 EControlGetLibraryInfo, |
|
328 EControlGetExeInfo, |
|
329 EControlGetProcUidInfo, |
|
330 EControlDetachProcess |
|
331 }; |
|
332 |
|
333 enum TRequest |
|
334 { |
|
335 ERequestGetEvent=0x0, ERequestGetEventCancel=0x1 |
|
336 }; |
|
337 |
|
338 public: |
|
339 |
|
340 inline TInt Open(const TMetroTrkDriverInfo aDriverInfo); |
|
341 inline TInt SetBreak(const TUint32 aProcessId, const TUint32 aThreadId, const TUint32 aAddr, const TBool aThumbMode, TInt32 &aId); |
|
342 inline TInt ClearBreak(const TInt32 aId); |
|
343 inline TInt ChangeBreakThread(const TUint32 aThreadId, const TInt32 aId); |
|
344 inline TInt SuspendThread(const TUint32 aThreadId); |
|
345 inline TInt ResumeThread(const TUint32 aThreadId); |
|
346 inline TInt StepRange(const TUint32 aThreadId, const TUint32 aStartAddress, const TUint32 aStopAddress, TBool aStepInto); |
|
347 inline TInt ReadMemory(const TUint32 aThreadId, const TUint32 aAddress, const TInt16 aLength, TDes8 &aData); |
|
348 inline TInt WriteMemory(const TUint32 aThreadId, const TUint32 aAddress, const TInt16 aLength, TDesC8 &aData); |
|
349 inline TInt ReadRegisters(const TUint32 aThreadId, const TInt32 aFirstRegister, const TInt32 aLastRegister, TDes8 &aValues); |
|
350 inline TInt WriteRegisters(const TUint32 aThreadId, const TInt32 aFirstRegister, const TInt32 aLastRegister, TDesC8 &aValues); |
|
351 inline void GetEvent(TRequestStatus &aStatus, SEventInfo &aEventInfo); |
|
352 inline void CancelGetEvent(); |
|
353 inline TInt GetProcessInfo(const TInt aIndex, TMetroTrkTaskInfo &aInfo); |
|
354 inline TInt GetThreadInfo(const TInt aIndex, TMetroTrkTaskInfo &aInfo); |
|
355 inline TInt GetProcessAddresses(const TUint32 aThreadId, TUint32 &aCodeAddress, TUint32 &aDataAddress); |
|
356 inline TInt GetStaticLibraryInfo(const TInt aIndex, SEventInfo &aInfo); |
|
357 inline TInt EnableLibLoadedEvent(); |
|
358 inline TInt DisableLibLoadedEvent(); |
|
359 inline TInt GetLibraryInfo(TMetroTrkLibInfo &aInfo); |
|
360 inline TInt GetExeInfo(TMetroTrkExeInfo &aInfo); |
|
361 inline TInt GetProcUidInfo(TMetroTrkProcUidInfo &aInfo); |
|
362 inline TInt DetachProcess(const TUint32 &aProcessId); |
|
363 |
|
364 }; |
|
365 |
|
366 |
|
367 _LIT(KMetroTrkDriverName,"Trk Driver"); |
|
368 |
|
369 // Version information |
|
370 const TInt KMajorVersionNumber=2; |
|
371 const TInt KMinorVersionNumber=0; |
|
372 const TInt KBuildVersionNumber=3; |
|
373 |
|
374 |
|
375 inline TInt RMetroTrkDriver::Open(const TMetroTrkDriverInfo aDriverInfo) |
|
376 { |
|
377 TBuf8<32> buf; |
|
378 buf.Append((TUint8*)&aDriverInfo.iPanic1Address, 4); |
|
379 buf.Append((TUint8*)&aDriverInfo.iPanic2Address, 4); |
|
380 buf.Append((TUint8*)&aDriverInfo.iException1Address, 4); |
|
381 buf.Append((TUint8*)&aDriverInfo.iException2Address, 4); |
|
382 buf.Append((TUint8*)&aDriverInfo.iLibraryLoadedAddress, 4); |
|
383 buf.Append((TUint8*)&aDriverInfo.iUserLibraryEnd, 4); |
|
384 |
|
385 #ifdef EKA2 |
|
386 return DoCreate(KMetroTrkDriverName, TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber), KNullUnit, NULL, &buf); |
|
387 #else |
|
388 return DoCreate(KMetroTrkDriverName, TVersion(KMajorVersionNumber, KMinorVersionNumber, KBuildVersionNumber), NULL, KNullUnit, NULL, &buf); |
|
389 #endif |
|
390 } |
|
391 |
|
392 inline TInt RMetroTrkDriver::SetBreak(const TUint32 aProcessId, const TUint32 aThreadId, const TUint32 aAddr, const TBool aThumbMode, TInt32 &aId) |
|
393 { |
|
394 TMetroTrkBreakInfo info(aAddr, aThumbMode, &aId, aProcessId); |
|
395 return DoSvControl(EControlSetBreak, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info); |
|
396 } |
|
397 |
|
398 inline TInt RMetroTrkDriver::ClearBreak(const TInt32 aId) |
|
399 { |
|
400 return DoSvControl(EControlClearBreak, reinterpret_cast<TAny*>(aId)); |
|
401 } |
|
402 |
|
403 inline TInt RMetroTrkDriver::ChangeBreakThread(const TUint32 aThreadId, const TInt32 aId) |
|
404 { |
|
405 return DoControl(EControlChangeBreakThread, reinterpret_cast<TAny*>(aThreadId), reinterpret_cast<TAny*>(aId)); |
|
406 } |
|
407 |
|
408 inline TInt RMetroTrkDriver::SuspendThread(const TUint32 aThreadId) |
|
409 { |
|
410 return DoControl(EControlSuspendThread, reinterpret_cast<TAny*>(aThreadId)); |
|
411 } |
|
412 |
|
413 inline TInt RMetroTrkDriver::ResumeThread(const TUint32 aThreadId) |
|
414 { |
|
415 return DoSvControl(EControlResumeThread, reinterpret_cast<TAny*>(aThreadId)); |
|
416 } |
|
417 |
|
418 inline TInt RMetroTrkDriver::StepRange(const TUint32 aThreadId, const TUint32 aStartAddress, const TUint32 aStopAddress, TBool aStepInto) |
|
419 { |
|
420 TMetroTrkStepInfo info(aStartAddress, aStopAddress, aStepInto); |
|
421 return DoSvControl(EControlStepRange, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info); |
|
422 } |
|
423 |
|
424 inline TInt RMetroTrkDriver::ReadMemory(const TUint32 aThreadId, const TUint32 aAddress, const TInt16 aLength, TDes8 &aData) |
|
425 { |
|
426 TMetroTrkMemoryInfo info(aAddress, aLength, &aData); |
|
427 return DoControl(EControlReadMemory, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info); |
|
428 } |
|
429 |
|
430 inline TInt RMetroTrkDriver::WriteMemory(const TUint32 aThreadId, const TUint32 aAddress, const TInt16 aLength, TDesC8 &aData) |
|
431 { |
|
432 TMetroTrkMemoryInfo info(aAddress, aLength, &aData); |
|
433 return DoControl(EControlWriteMemory, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info); |
|
434 } |
|
435 |
|
436 inline TInt RMetroTrkDriver::ReadRegisters(const TUint32 aThreadId, const TInt32 aFirstRegister, const TInt32 aLastRegister, TDes8 &aValues) |
|
437 { |
|
438 TMetroTrkRegisterInfo info(aFirstRegister, aLastRegister, &aValues); |
|
439 return DoControl(EControlReadRegisters, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info); |
|
440 } |
|
441 |
|
442 inline TInt RMetroTrkDriver::WriteRegisters(const TUint32 aThreadId, const TInt32 aFirstRegister, const TInt32 aLastRegister, TDesC8 &aValues) |
|
443 { |
|
444 TMetroTrkRegisterInfo info(aFirstRegister, aLastRegister, &aValues); |
|
445 return DoControl(EControlWriteRegisters, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info); |
|
446 } |
|
447 |
|
448 inline void RMetroTrkDriver::GetEvent(TRequestStatus &aStatus, SEventInfo &aEventInfo) |
|
449 { |
|
450 DoRequest(ERequestGetEvent, aStatus, (TAny*)&aEventInfo); |
|
451 } |
|
452 |
|
453 inline void RMetroTrkDriver::CancelGetEvent() |
|
454 { |
|
455 DoCancel(ERequestGetEventCancel); |
|
456 } |
|
457 |
|
458 inline TInt RMetroTrkDriver::GetProcessInfo(const TInt aIndex, TMetroTrkTaskInfo &aInfo) |
|
459 { |
|
460 return DoControl(EControlGetProcessInfo, reinterpret_cast<TAny*>(aIndex), (TAny*)&aInfo); |
|
461 } |
|
462 |
|
463 inline TInt RMetroTrkDriver::GetThreadInfo(const TInt aIndex, TMetroTrkTaskInfo &aInfo) |
|
464 { |
|
465 return DoControl(EControlGetThreadInfo, reinterpret_cast<TAny*>(aIndex), (TAny*)&aInfo); |
|
466 } |
|
467 |
|
468 inline TInt RMetroTrkDriver::GetProcessAddresses(const TUint32 aThreadId, TUint32 &aCodeAddress, TUint32 &aDataAddress) |
|
469 { |
|
470 TMetroTrkProcessInfo info(&aCodeAddress, &aDataAddress); |
|
471 return DoControl(EControlGetProcessAddresses, reinterpret_cast<TAny*>(aThreadId), (TAny*)&info); |
|
472 } |
|
473 |
|
474 inline TInt RMetroTrkDriver::GetStaticLibraryInfo(const TInt aIndex, SEventInfo &aInfo) |
|
475 { |
|
476 return DoControl(EControlGetStaticLibraryInfo, reinterpret_cast<TAny*>(aIndex), (TAny*)&aInfo); |
|
477 } |
|
478 |
|
479 inline TInt RMetroTrkDriver::EnableLibLoadedEvent() |
|
480 { |
|
481 return DoControl(EControlEnableLibLoadedEvent); |
|
482 } |
|
483 |
|
484 inline TInt RMetroTrkDriver::DisableLibLoadedEvent() |
|
485 { |
|
486 return DoControl(EControlDisableLibLoadedEvent); |
|
487 } |
|
488 |
|
489 inline TInt RMetroTrkDriver::GetLibraryInfo(TMetroTrkLibInfo &aInfo) |
|
490 { |
|
491 return DoControl(EControlGetLibraryInfo, (TAny*)&aInfo); |
|
492 } |
|
493 |
|
494 inline TInt RMetroTrkDriver::GetExeInfo(TMetroTrkExeInfo &aInfo) |
|
495 { |
|
496 return DoControl(EControlGetExeInfo, (TAny*)&aInfo); |
|
497 } |
|
498 |
|
499 inline TInt RMetroTrkDriver::GetProcUidInfo(TMetroTrkProcUidInfo &aInfo) |
|
500 { |
|
501 return DoControl(EControlGetProcUidInfo, (TAny*)&aInfo); |
|
502 } |
|
503 |
|
504 inline TInt RMetroTrkDriver::DetachProcess(const TUint32 &aProcessId) |
|
505 { |
|
506 return DoControl(EControlDetachProcess, (TAny*)&aProcessId); |
|
507 } |
|
508 #endif // __TRKKERNELDRIVER_H__ |