Update contrib.
1 // Copyright (c) 2002-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32utils\d_exc\minkda.h
15 // API exposed by example of kernel-side debug agent.
22 _LIT(KKdaLddName, "MINKDA");
24 inline TVersion KKdaLddVersion() { return TVersion(1, 0, 1); }
31 Size must be multiple of 4 bytes.
37 enum { KRegCount = 16 };
38 TUint32 iRn[KRegCount];
44 ARM-specific exception-related data.
45 Size must be multiple of 4 bytes.
59 /** Point to instruction which caused exception */
62 Address which caused exception (System Control Coprocessor Fault
65 TUint32 iFaultAddress;
66 /** System Control Coprocessor Fault Status Register */
68 /** R13 supervisor mode banked register */
70 /** R14 supervisor mode banked register */
72 /** SPSR supervisor mode banked register */
90 Exception or panic information block.
91 Size must be multiple of 4 bytes.
97 enum TType { EException, EPanic };
100 /** ID of thread which crashed */
102 /** CPU-specific information (exception only) */
108 Thread information block.
109 Size must be multiple of 4 bytes.
116 /** ID of owning process */
118 /** user stack base address */
120 /** user stack size */
122 TExitCategoryName iExitCategory;
130 Code Segment Information Block
131 Size must be multiple of 4 bytes.
134 class TDbgCodeSegInfo
144 API exposed by minimal kernel debug agent.
146 This API is provided as an example only. There are no guarantees of
147 binary/source compatibility.
150 class RMinKda : public RBusLogicalChannel
163 // Size of following structs must be multiple of 4 bytes.
164 struct TCodeSnapshotParams
170 struct TCodeInfoParams
178 struct TReadMemParams
184 struct TDbgInfoParams
186 TBuf8<KMaxFullName> iFullName;
190 TBuf8<KMaxExitCategoryName> iExitCategory;
195 #ifndef __KERNEL_MODE__
197 inline void Trap(TRequestStatus& aStatus, TDbgCrashInfo& aInfo);
198 inline void CancelTrap();
199 inline void KillCrashedThread();
200 inline TInt GetThreadInfo(TUint aTid, TDbgThreadInfo& aInfo);
201 inline TInt ReadMem(TUint aTid, TLinAddr aSrc, TDes8& aDest);
202 inline TInt GetCodeSegs(TUint aPid, TAny** aHandleArray, TInt& aHandleCount);
203 inline TInt GetCodeSegInfo(TAny* aHandle, TUint aPid, TDbgCodeSegInfo& aInfo);
208 #ifndef __KERNEL_MODE__
210 inline TInt RMinKda::Open()
212 return DoCreate(KKdaLddName, KKdaLddVersion(), KNullUnit, NULL, NULL, EOwnerThread);
216 Ask to be notified of the next panic or exception occurence.
218 The crashed thread will remain suspended until KillCrashedThread() is
219 called allowing more information to be gathered (e.g. stack content).
221 If more threads panic or take an exception, they will be suspended
222 too until the first one is killed.
224 @param aStatus Request to complete when panic/exception occurs
225 @param aInfo Filled when request completes
228 inline void RMinKda::Trap(TRequestStatus& aStatus, TDbgCrashInfo& aInfo)
230 DoControl(ETrap, &aStatus, &aInfo);
233 /** Cancel previous call to Trap() */
235 inline void RMinKda::CancelTrap()
237 DoControl(ECancelTrap, NULL, NULL);
241 Kill the thread which crashed causing the Trap() request to complete.
244 inline void RMinKda::KillCrashedThread()
246 DoControl(EKillCrashedThread, NULL, NULL);
251 Return information about thread identified by its ID.
254 inline TInt RMinKda::GetThreadInfo(TUint aTid, TDbgThreadInfo& aInfo)
256 TDbgInfoParams params;
257 TInt r=DoControl(EGetThreadInfo, (TAny*)aTid, ¶ms);
260 aInfo.iFullName.Copy(params.iFullName);
261 aInfo.iPid = params.iPid;
262 aInfo.iStackBase = params.iStackBase;
263 aInfo.iStackSize = params.iStackSize;
264 aInfo.iExitCategory.Copy(params.iExitCategory);
265 aInfo.iExitReason = params.iExitReason;
266 aInfo.iCpu = params.iCpu;
272 Read memory from designated thread address space.
274 @param aTid Thread id
275 @param aSrc Source address
276 @param aDest Destination descriptor. Number of bytes to read is
279 @return standard error code
282 inline TInt RMinKda::ReadMem(TUint aTid, TLinAddr aSrc, TDes8& aDest)
284 TReadMemParams params;
287 params.iDes = &aDest;
288 return DoControl(EReadMem, ¶ms, NULL);
291 inline TInt RMinKda::GetCodeSegs(TUint aPid, TAny** aHandleArray, TInt& aHandleCount)
293 TCodeSnapshotParams params;
295 params.iHandles = aHandleArray;
296 params.iCountPtr = &aHandleCount;
297 return DoControl(EGetCodeSegs, ¶ms, NULL);
300 inline TInt RMinKda::GetCodeSegInfo(TAny* aHandle, TUint aPid, TDbgCodeSegInfo& aInfo)
302 TBuf8<KMaxPath> path;
303 TCodeInfoParams params;
305 params.iHandle = aHandle;
306 params.iPathPtr = &path;
307 TInt r = DoControl(EGetCodeSegInfo, ¶ms, NULL);
310 aInfo.iCodeBase = params.iCodeBase;
311 aInfo.iCodeSize = params.iCodeSize;
312 aInfo.iPath.Copy(path);