|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32test/debug/d_debugapi.h |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __D_DEBUGAPI_H__ |
|
19 #define __D_DEBUGAPI_H__ |
|
20 |
|
21 #ifdef __KERNEL_MODE__ |
|
22 #include <kernel/kdebug.h> |
|
23 #else |
|
24 #include <e32std.h> |
|
25 #endif |
|
26 |
|
27 _LIT(KTestLddName, "TestDebugAPI"); |
|
28 |
|
29 class RDebugAPIChecker: public RBusLogicalChannel |
|
30 { |
|
31 public: |
|
32 enum |
|
33 { |
|
34 ETProcess, |
|
35 ETChunk, |
|
36 ETThread, |
|
37 ETIPAccess |
|
38 }; |
|
39 /**Used to pass arguments to ldd when checking inter-process data access*/ |
|
40 struct IPAccessArgs |
|
41 { |
|
42 TUint iProcessID; |
|
43 TUint iAddress; |
|
44 TUint iValue; |
|
45 }; |
|
46 |
|
47 public: |
|
48 static inline TVersion Version() { return TVersion(1, 0, 1); } |
|
49 #ifndef __KERNEL_MODE__ |
|
50 public: |
|
51 inline TInt Open(); |
|
52 inline TInt Process(); |
|
53 inline TInt Chunk(); |
|
54 inline TInt Thread(); |
|
55 inline TInt IPAccess(RDebugAPIChecker::IPAccessArgs* aArgs); |
|
56 #endif |
|
57 }; |
|
58 |
|
59 |
|
60 #ifndef __KERNEL_MODE__ |
|
61 |
|
62 inline TInt RDebugAPIChecker::Open() |
|
63 { |
|
64 return DoCreate(KTestLddName, Version(), NULL, NULL, NULL, EOwnerThread); |
|
65 } |
|
66 inline TInt RDebugAPIChecker::Process() |
|
67 { |
|
68 return DoControl(ETProcess); |
|
69 } |
|
70 inline TInt RDebugAPIChecker::Chunk() |
|
71 { |
|
72 return DoControl(ETChunk); |
|
73 } |
|
74 inline TInt RDebugAPIChecker::Thread() |
|
75 { |
|
76 return DoControl(ETThread); |
|
77 } |
|
78 inline TInt RDebugAPIChecker::IPAccess(RDebugAPIChecker::IPAccessArgs* aArgs) |
|
79 { |
|
80 return DoControl(ETIPAccess, aArgs); |
|
81 } |
|
82 |
|
83 #endif //#ifndef __KERNEL_MODE__ |
|
84 |
|
85 #ifdef __KERNEL_MODE__ |
|
86 |
|
87 /** |
|
88 Holds the offsets common to all memory models. |
|
89 @see TOffsetTableEntry. |
|
90 */ |
|
91 struct TDebugOffsetTable |
|
92 { |
|
93 // debugger info |
|
94 TInt iDebugger_ObjectOffsetTable; |
|
95 TInt iDebugger_ObjectOffsetTableCount; |
|
96 TInt iDebugger_ThreadContextTable; |
|
97 TInt iDebugger_Version; |
|
98 TInt iDebugger_OSVersion; |
|
99 TInt iDebugger_Reserved; |
|
100 TInt iDebugger_Containers; |
|
101 TInt iDebugger_Scheduler; |
|
102 TInt iDebugger_CurrentThread; |
|
103 TInt iDebugger_CodeSegGlobalList; |
|
104 TInt iDebugger_CodeSegLock; |
|
105 TInt iDebugger_Change; |
|
106 // DMutex info |
|
107 TInt iMutex_HoldCount; |
|
108 // more debugger info |
|
109 TInt iDebugger_ShadowPages; |
|
110 TInt iDebugger_ShadowPageCount; |
|
111 TInt iDebugger_EventMask; |
|
112 // DObjectCon info |
|
113 TInt iObjectCon_Mutex; |
|
114 TInt iObjectCon_Objects; |
|
115 TInt iObjectCon_Count; |
|
116 // more debugger info |
|
117 TInt iDebugger_EventHandlerBreakpoint; |
|
118 TInt iDebuggerOffset_Reserved6; |
|
119 TInt iDebuggerOffset_Reserved7; |
|
120 TInt iDebuggerOffset_Reserved8; |
|
121 // thread info |
|
122 TInt iThread_Name; |
|
123 TInt iThread_Id; |
|
124 TInt iThread_OwningProcess; |
|
125 TInt iThread_NThread; |
|
126 TInt iThread_SupervisorStack; |
|
127 TInt iThread_SupervisorStackSize; |
|
128 TInt iThread_UserStackRunAddress; |
|
129 TInt iThread_UserStackSize; |
|
130 TInt iThread_UserContextType; |
|
131 TInt iThread_SavedSupervisorSP; |
|
132 TInt iThread_Priority; |
|
133 TInt iThread_ThreadType; |
|
134 TInt iDebuggerOffset_Reserved12; |
|
135 // process info |
|
136 TInt iProcess_Name; |
|
137 TInt iProcess_Id; |
|
138 TInt iProcess_Attributes; |
|
139 TInt iProcess_CodeSeg; |
|
140 TInt iProcess_DataBssRunAddress; |
|
141 TInt iProcess_DataBssStackChunk; |
|
142 TInt iProcess_ChunkCount; //ARMv5 specific |
|
143 TInt iProcess_Chunks; //ARMv5 specific |
|
144 TInt iDebuggerOffset_Reserved13; |
|
145 TInt iDebuggerOffset_Reserved14; |
|
146 TInt iDebuggerOffset_Reserved15; |
|
147 TInt iDebuggerOffset_Reserved16; |
|
148 // chunkinfo info |
|
149 TInt iChunkInfo_DataSectionBase; //ARMv5 specific |
|
150 TInt iChunkInfo_Chunk; //ARMv5 specific |
|
151 TInt iDebuggerOffset_Reserved36; |
|
152 TInt iDebuggerOffset_Reserved37; |
|
153 // chunk info |
|
154 TInt iChunk_OwningProcess; //ARMv5 specific |
|
155 TInt iChunk_Size; |
|
156 TInt iChunk_Attributes; |
|
157 TInt iChunk_ChunkType; |
|
158 TInt iChunk_ChunkState; //ARMv5 specific |
|
159 TInt iChunk_HomeBase; //ARMv5 specific |
|
160 TInt iDebuggerOffset_Reserved17; |
|
161 TInt iDebuggerOffset_Reserved18; |
|
162 TInt iDebuggerOffset_Reserved19; |
|
163 TInt iDebuggerOffset_Reserved20; |
|
164 // library info |
|
165 TInt iLibrary_MapCount; |
|
166 TInt iLibrary_State; |
|
167 TInt iLibrary_CodeSeg; |
|
168 TInt iDebuggerOffset_Reserved21; |
|
169 TInt iDebuggerOffset_Reserved22; |
|
170 TInt iDebuggerOffset_Reserved23; |
|
171 TInt iDebuggerOffset_Reserved24; |
|
172 // code seg info |
|
173 TInt iCodeSeg_Next; |
|
174 TInt iCodeSeg_Prev; |
|
175 TInt iCodeSeg_Deps; |
|
176 TInt iCodeSeg_DepsCount; |
|
177 TInt iCodeSeg_FileName; |
|
178 TInt iCodeSeg_XIP; |
|
179 TInt iCodeSeg_Info; |
|
180 TInt iDebuggerOffset_Reserved25; |
|
181 TInt iDebuggerOffset_Reserved26; |
|
182 TInt iDebuggerOffset_Reserved27; |
|
183 TInt iDebuggerOffset_Reserved28; |
|
184 // scheduler info |
|
185 TInt iScheduler_KernCSLocked; |
|
186 TInt iScheduler_LockWaiting; |
|
187 TInt iScheduler_CurrentThread; |
|
188 TInt iScheduler_AddressSpace; |
|
189 TInt iDebuggerOffset_Reserved29; |
|
190 TInt iDebuggerOffset_Reserved30; |
|
191 TInt iDebuggerOffset_Reserved31; |
|
192 TInt iDebuggerOffset_Reserved32; |
|
193 // code segment information non-XIP |
|
194 TInt iCodeSegInfoRAM_CodeSize; |
|
195 TInt iCodeSegInfoRAM_TextSize; |
|
196 TInt iCodeSegInfoRAM_DataSize; |
|
197 TInt iCodeSegInfoRAM_BssSize; |
|
198 TInt iCodeSegInfoRAM_CodeRunAddress; |
|
199 TInt iCodeSegInfoRAM_CodeLoadAddress; |
|
200 TInt iCodeSegInfoRAM_DataRunAddr; |
|
201 TInt iCodeSegInfoRAM_DataLoadAddr; |
|
202 TInt iCodeSegInfoRAM_ConstOffset; |
|
203 TInt iCodeSegInfoRAM_ExportDir; |
|
204 TInt iCodeSegInfoRAM_ExportDirCount; |
|
205 TInt iDebuggerOffset_Reserved38; |
|
206 TInt iDebuggerOffset_Reserved39; |
|
207 TInt iDebuggerOffset_Reserved40; |
|
208 TInt iDebuggerOffset_Reserved41; |
|
209 // code segment information XIP |
|
210 TInt iCodeSegInfoXIP_CodeAddress; |
|
211 TInt iCodeSegInfoXIP_DataAddress; |
|
212 TInt iCodeSegInfoXIP_DataRunAddress; |
|
213 TInt iCodeSegInfoXIP_CodeSize; |
|
214 TInt iCodeSegInfoXIP_TextSize; |
|
215 TInt iCodeSegInfoXIP_DataSize; |
|
216 TInt iCodeSegInfoXIP_BssSize; |
|
217 TInt iCodeSegInfoXIP_ExportDir; |
|
218 TInt iCodeSegInfoXIP_ExportDirCount; |
|
219 TInt iDebuggerOffset_Reserved42; |
|
220 TInt iDebuggerOffset_Reserved43; |
|
221 TInt iDebuggerOffset_Reserved44; |
|
222 TInt iDebuggerOffset_Reserved45; |
|
223 }; |
|
224 |
|
225 /** |
|
226 Holds the offsets specific to moving memory models. |
|
227 @see TOffsetMovingTableEntry |
|
228 */ |
|
229 struct TMovingDebugOffsetTable |
|
230 { |
|
231 TInt iProcess_ChunkCount; |
|
232 TInt iProcess_Chunks; |
|
233 |
|
234 TInt iChunkInfo_DataSectionBase; |
|
235 TInt iChunkInfo_Chunk; |
|
236 |
|
237 TInt iChunk_OwningProcess; |
|
238 TInt iChunk_ChunkState; |
|
239 TInt iChunk_HomeBase; |
|
240 |
|
241 TInt iReserved1; |
|
242 TInt iReserved2; |
|
243 TInt iReserved3; |
|
244 TInt iReserved4; |
|
245 }; |
|
246 |
|
247 /** |
|
248 Holds the offsets specific to multiple memory models. |
|
249 @see TOffsetMultipleTableEntry |
|
250 */ |
|
251 struct TMultipleDebugOffsetTable |
|
252 { |
|
253 TInt iProcess_OsAsid; |
|
254 TInt iProcess_LocalPageDir; |
|
255 TInt iProcess_ChunkCount; |
|
256 TInt iProcess_Chunks; |
|
257 TInt iChunkInfo_Chunk; |
|
258 TInt iChunk_OwningProcess; |
|
259 TInt iReserved1; |
|
260 TInt iReserved2; |
|
261 TInt iReserved3; |
|
262 TInt iReserved4; |
|
263 }; |
|
264 |
|
265 class DDebugAPIChecker : public DLogicalChannelBase |
|
266 { |
|
267 public: |
|
268 virtual ~DDebugAPIChecker(); |
|
269 protected: |
|
270 // from DLogicalChannelBase |
|
271 virtual TInt DoCreate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer); |
|
272 virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2); |
|
273 private: |
|
274 inline TInt8 Read8(void* aBase, TInt aOffset) {return *((TInt8*)aBase + aOffset);} |
|
275 inline TInt Read(void* aBase, TInt aOffset) {return (TInt) (*((TInt*)((TInt8*)aBase + aOffset)));} |
|
276 |
|
277 TInt Process(); |
|
278 TInt Chunk(); |
|
279 TInt Thread(); |
|
280 TInt IPAccess(TAny* a1); |
|
281 TUint8* ExtractName(TInt aSymbianName, TUint8* aCharName); |
|
282 TInt GetOffsets(); |
|
283 |
|
284 TInt ReadFromOtherProcessArmv6(); |
|
285 |
|
286 private: |
|
287 DDebuggerInfo* iDebugInfo; |
|
288 TDebugOffsetTable* iOffsetTable;/**Contains the offsets common to all memory models*/ |
|
289 TMemoryModelType iMMUType; /**Identifies the memory model*/ |
|
290 void* iVariantOffsetTable; /**Contains memory-model-spacific offsets*/ |
|
291 TInt* iScheduler; /**Will hold the address of the scheduler*/ |
|
292 |
|
293 TInt iCurrentProcess_OsAsid; //Used to call ReadFromOtherProcessArmv6 |
|
294 TInt iCurrentProcess_LocalPageDir; //Used to call ReadFromOtherProcessArmv6 |
|
295 TInt iOtherProcess_OsAsid; //Used to call ReadFromOtherProcessArmv6 |
|
296 TInt iOtherProcess_LocalPageDir; //Used to call ReadFromOtherProcessArmv6 |
|
297 TInt iAddress; //Used to call ReadFromOtherProcessArmv6 |
|
298 }; |
|
299 |
|
300 #endif //#ifdef __KERNEL_MODE__ |
|
301 |
|
302 #endif // __D_DEBUGAPI_H__ |