|
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 __TRKDISPATCHLAYER_H__ |
|
20 #define __TRKDISPATCHLAYER_H__ |
|
21 |
|
22 #include <f32file.h> |
|
23 #include "TrkFramingLayer.h" |
|
24 #include "TrkKernelDriver.h" |
|
25 |
|
26 |
|
27 #ifndef __TEXT_SHELL__ |
|
28 #include <sysutil.h> |
|
29 #include <etel3rdparty.h> |
|
30 #endif |
|
31 |
|
32 #ifdef __OEM_TRK__ |
|
33 #include "TrkTcbCliSession.h" |
|
34 #endif |
|
35 |
|
36 |
|
37 |
|
38 // |
|
39 // Forward declarations |
|
40 // |
|
41 class CTrkDispatchLayer; |
|
42 class CTrkEngine; |
|
43 |
|
44 |
|
45 // |
|
46 // class CExitTrapper |
|
47 // |
|
48 // Watches to see when a process exists |
|
49 // |
|
50 class CExitTrapper : public CActive |
|
51 { |
|
52 public: |
|
53 |
|
54 CExitTrapper(CTrkDispatchLayer *aDispatch, TUint32 aProcessId); |
|
55 ~CExitTrapper(); |
|
56 |
|
57 void Watch(); |
|
58 |
|
59 protected: |
|
60 |
|
61 void RunL(); |
|
62 void DoCancel(); |
|
63 |
|
64 private: |
|
65 |
|
66 RProcess iProcess; |
|
67 TUint32 iProcessId; |
|
68 CTrkDispatchLayer *iDispatch; |
|
69 }; |
|
70 |
|
71 |
|
72 // |
|
73 // class CEventTrapper |
|
74 // |
|
75 // Listens for events like breakpoints, exceptions, panic, and library loads |
|
76 // |
|
77 class CEventTrapper : public CActive |
|
78 { |
|
79 public: |
|
80 |
|
81 CEventTrapper(CTrkDispatchLayer *aDispatch); |
|
82 ~CEventTrapper(); |
|
83 void Watch(); |
|
84 |
|
85 protected: |
|
86 |
|
87 void RunL(); |
|
88 void DoCancel(); |
|
89 |
|
90 private: |
|
91 |
|
92 SEventInfo iEventInfo; |
|
93 CTrkDispatchLayer *iDispatch; |
|
94 }; |
|
95 |
|
96 |
|
97 // |
|
98 // class CDebugProcess |
|
99 // |
|
100 // Represents a process being debugged by the user |
|
101 // |
|
102 class CDebugProcess : public CBase |
|
103 { |
|
104 public: |
|
105 |
|
106 static CDebugProcess* NewL(CTrkDispatchLayer *aDispatch, TUint32 aProcessId, TUint32 aMainThreadId); |
|
107 ~CDebugProcess(); |
|
108 |
|
109 void ConstructL(CTrkDispatchLayer *aDispatch, TUint32 aProcessId, TUint32 aMainThreadId); |
|
110 |
|
111 TUint32 ProcessId() { return iProcessId; } |
|
112 |
|
113 public: |
|
114 |
|
115 TBool iReadyForLibraryLoadNotification; |
|
116 |
|
117 private: |
|
118 |
|
119 TUint32 iProcessId; |
|
120 TUint32 iMainThreadId; |
|
121 CExitTrapper *iExitTrapper; |
|
122 }; |
|
123 |
|
124 #ifndef __TEXT_SHELL__ |
|
125 // |
|
126 //class CPhoneInfo |
|
127 // |
|
128 //This class is used to find the name of the Phone for eg: For Nokia 5800, the phone name is 5800 Music Express |
|
129 // |
|
130 class CPhoneInfo : public CActive |
|
131 { |
|
132 private: |
|
133 |
|
134 CTelephony::TPhoneIdV1 iPhoneIdV1; |
|
135 CTelephony::TPhoneIdV1Pckg iPhoneIdV1Pckg; |
|
136 CTelephony* iTelephony; |
|
137 CPhoneInfo(); |
|
138 void ConstructL(); |
|
139 |
|
140 public: |
|
141 static CPhoneInfo* NewL(); |
|
142 void GetPhoneName(CTrkDispatchLayer* aDispatchLayer); |
|
143 ~CPhoneInfo(); |
|
144 |
|
145 private: |
|
146 |
|
147 void RunL(); |
|
148 void DoCancel(); |
|
149 |
|
150 private: |
|
151 CTrkDispatchLayer* iDispatchLayer; |
|
152 |
|
153 }; |
|
154 |
|
155 #endif |
|
156 |
|
157 // |
|
158 // class TCreateProcessData |
|
159 // |
|
160 // Container class for information related to the creation of a new process |
|
161 // |
|
162 class TCreateProcessData |
|
163 { |
|
164 public: |
|
165 |
|
166 inline TCreateProcessData() |
|
167 : iProcessId(0), |
|
168 iMainThreadId(0), |
|
169 iEntryAddr(0xFFFFFFFF), |
|
170 iCodeAddr(0xFFFFFFFF), |
|
171 iDataAddr(0xFFFFFFFF), |
|
172 iBssAddr(0xFFFFFFFF) {}; |
|
173 |
|
174 public: |
|
175 |
|
176 TUint32 iProcessId; |
|
177 TUint32 iMainThreadId; |
|
178 TUint32 iEntryAddr; |
|
179 TUint32 iCodeAddr; |
|
180 TUint32 iDataAddr; |
|
181 TUint32 iBssAddr; |
|
182 }; |
|
183 |
|
184 // |
|
185 // class TProtocolVersion |
|
186 // |
|
187 // Container class for the protocol version |
|
188 // |
|
189 class TProtocolVersion |
|
190 { |
|
191 public: |
|
192 inline TProtocolVersion() { }; |
|
193 inline TProtocolVersion(TUint8 aMajor, TUint8 aMinor) |
|
194 : iMajor(aMajor), |
|
195 iMinor(aMinor) { }; |
|
196 public: |
|
197 TUint8 iMajor; |
|
198 TUint8 iMinor; |
|
199 }; |
|
200 |
|
201 // |
|
202 // class CTrkDispatchLayer |
|
203 // |
|
204 // Handles messages between the kernel side driver and the framing layer |
|
205 // |
|
206 class CTrkDispatchLayer : public CBase |
|
207 { |
|
208 public: |
|
209 |
|
210 static CTrkDispatchLayer* NewL(CTrkCommPort *aPort, CTrkEngine* aEngine); |
|
211 ~CTrkDispatchLayer(); |
|
212 |
|
213 void Listen(); |
|
214 void StopListening(); |
|
215 static void GetVersionInfo(TInt &aMajorVersion, TInt &aMinorVersion, TInt &aMajorAPIVersion, TInt &aMinorAPIVersion, TInt &aBuildNumber); |
|
216 void HandleMsg(const TDesC8& aMsg); |
|
217 |
|
218 TBool IsDebugging() { return iIsConnected; } |
|
219 |
|
220 void UpdatePhoneNameInfo(TDesC16& aPhoneModel); |
|
221 |
|
222 private: |
|
223 |
|
224 CTrkDispatchLayer(); |
|
225 void ConstructL(CTrkCommPort *aPort, CTrkEngine* aEngine); |
|
226 |
|
227 void FindPhoneSWVersion(); |
|
228 void FindPhoneNameL(); |
|
229 |
|
230 void DispatchMsgL(); |
|
231 void DoConnectL(); |
|
232 void DoDisconnectL(); |
|
233 void DoVersionsL(); |
|
234 void DoVersions2L(); |
|
235 void DoVersions3L(); |
|
236 void DoHostVersionsL(); |
|
237 void DoSupportMaskL(); |
|
238 void DoCPUTypeL(); |
|
239 void DoReadMemoryL(); |
|
240 void DoWriteMemoryL(); |
|
241 void DoReadRegistersL(); |
|
242 void DoWriteRegistersL(); |
|
243 void DoContinueL(); |
|
244 void DoStepL(); |
|
245 void DoStopL(); |
|
246 void DoSetBreakL(); |
|
247 void DoClearBreakL(); |
|
248 void DoModifyBreakThreadL(); |
|
249 void DoCreateItemL(); |
|
250 void DoDeleteItemL(); |
|
251 void DoReadInfoL(); |
|
252 void DoWriteInfoL(); |
|
253 |
|
254 void DoOpenFileL(); |
|
255 void OpenFileL(const TDesC& aFullPath, TUint aMode, TTime& aTime); |
|
256 void DoReadFileL(); |
|
257 TInt ReadFileL(TUint16 aLength, TPtr8& aData); |
|
258 |
|
259 void DoWriteFileL(); |
|
260 void WriteFileL(TDesC8& aData); |
|
261 |
|
262 void DoPositionFileL(); |
|
263 void PositionFileL(TSeek aSeek, TInt& aOffset); |
|
264 |
|
265 void DoCloseFileL(); |
|
266 void CloseFileL(const TTime& aModifiedTime); |
|
267 |
|
268 void DoInstallFileL(); |
|
269 void DoInstallFile2L(); |
|
270 |
|
271 void DoGetPhoneSWVersionL(); |
|
272 void DoGetPhoneNameL(); |
|
273 |
|
274 void DoCreateProcessL(TBool aRun=EFalse); |
|
275 void DoCreateExeL(const TDesC& aPath, const TDesC& aArgs, TCreateProcessData& aData, TBool aRun=EFalse); |
|
276 void DoKillProcessL(); |
|
277 |
|
278 void DoAttachProcessL(DSOSItemTypes aAttachType=kDSOSProcAttachItem); |
|
279 void DoDetachProcessL(); |
|
280 |
|
281 void DoReadProcessListL(TInt32 aIndex); |
|
282 void DoReadThreadListL(TInt32 aIndex); |
|
283 void DoReBuildProcessList(); |
|
284 void DoReBuildThreadList(TUint32 aProcessid); |
|
285 |
|
286 void DoNotifyStoppedL(TUint32 aProcessId, TUint32 aThreadId, TUint32 aCurrentPC, const TDesC8 &aDescription, TBool aAddException=false, const TUint16 aExceptionNumber=0); |
|
287 void DoNotifyProcessDiedL(TUint32 aProcessId, TInt aExitCode); |
|
288 void DoNotifyLibraryLoadedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId, TUint32 aCodeBaseAddress, TUint32 aDataBaseAddress); |
|
289 void DoNotifyLibraryUnloadedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId); |
|
290 void DoNotifyUserTraceL(TDesC8 &aTrace); |
|
291 void DoNotifyProcessAddedL(TDesC8 &aName, TUint32 aProcessId, TUint32 aThreadId, TUint32 aUid, TUint32 aCodeBaseAddress, TUint32 aDataBaseAddress); |
|
292 void DoReadLibraryInfoL(TDesC8& aFileName); |
|
293 void DoReadProcessInfoL(TUint32 aUid, TDesC8& aFileName); |
|
294 |
|
295 |
|
296 void GetDataFromBufferL(TAny *aData, TInt aLength); |
|
297 void AddToReplyBufferL(TUint8 aData, TBool aReset = false); |
|
298 void AddToReplyBufferL(TUint16 aData, TBool aReset = false); |
|
299 void AddToReplyBufferL(TUint32 aData, TBool aReset = false); |
|
300 void AddToReplyBufferL(const TDesC8 &aData, TBool aReset = false); |
|
301 |
|
302 |
|
303 void RespondOkL() { if (iReplyBuffer) iFramingLayer->RespondOkL(*iReplyBuffer); }; |
|
304 void InformEventL() { if (iReplyBuffer) iFramingLayer->InformEventL(*iReplyBuffer); }; |
|
305 |
|
306 |
|
307 TUint8 IsThreadSuspended(TUint32 aThreadId); |
|
308 TBool IsRestrictedFolder(const TDesC& aPath); |
|
309 TInt CloseCrashLogger(); |
|
310 TInt TerminateProcess(const TDesC& aProcessName); |
|
311 |
|
312 void CloseTcbServer(); |
|
313 private: |
|
314 |
|
315 CTrkEngine* iEngine; |
|
316 CTrkFramingLayer *iFramingLayer; |
|
317 #ifndef __TEXT_SHELL__ |
|
318 CPhoneInfo* iPhoneInfo; |
|
319 #endif |
|
320 |
|
321 HBufC8 *iInputBuffer; |
|
322 HBufC8 *iReplyBuffer; |
|
323 |
|
324 #ifndef __TEXT_SHELL__ |
|
325 TBuf8 <KSysUtilVersionTextLength> iPhoneVersion; |
|
326 TBuf8 <CTelephony::KPhoneModelIdSize> iPhoneModel; |
|
327 #endif |
|
328 |
|
329 enum TFileState |
|
330 { |
|
331 EFileOpened = 0, |
|
332 EFileReading = 1, |
|
333 EFileWriting = 2, |
|
334 EFileClosed = 3, |
|
335 EFileUnknown = -1 |
|
336 }; |
|
337 RFile iFile; |
|
338 RFs iFs; |
|
339 TFileState iFileState; |
|
340 |
|
341 RPointerArray<CDebugProcess> iDebugProcessList; |
|
342 |
|
343 RArray<TMetroTrkTaskInfo> iProcessList; |
|
344 RArray<TMetroTrkTaskInfo> iThreadList; |
|
345 |
|
346 RArray<TUint> iSuspendedThreadList; |
|
347 |
|
348 CEventTrapper *iEventTrapper; |
|
349 |
|
350 RMetroTrkDriver iKernelDriver; |
|
351 TBool iIsConnected; |
|
352 |
|
353 TBool iPhoneNameInfoAvailable; |
|
354 |
|
355 #ifdef __OEM_TRK__ |
|
356 RTrkTcbCliSession iTrkTcbSession; |
|
357 TBool iUseTcbServer; |
|
358 #endif |
|
359 TProtocolVersion iHostVersion; |
|
360 |
|
361 friend class CEventTrapper; |
|
362 friend class CExitTrapper; |
|
363 }; |
|
364 |
|
365 #endif // __TRKDISPATCHLAYER_H__ |