os/kernelhwsrv/kerneltest/e32test/debug/d_debugapi.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/debug/d_debugapi.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,302 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32test/debug/d_debugapi.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#ifndef __D_DEBUGAPI_H__
    1.22 +#define __D_DEBUGAPI_H__
    1.23 +
    1.24 +#ifdef __KERNEL_MODE__
    1.25 +	#include <kernel/kdebug.h>
    1.26 +#else
    1.27 +	#include <e32std.h>
    1.28 +#endif
    1.29 +
    1.30 +_LIT(KTestLddName, "TestDebugAPI");
    1.31 +
    1.32 +class RDebugAPIChecker: public RBusLogicalChannel
    1.33 +	{
    1.34 +public:
    1.35 +	enum 
    1.36 +		{
    1.37 +		ETProcess,
    1.38 +		ETChunk,
    1.39 +		ETThread,
    1.40 +		ETIPAccess
    1.41 +		};
    1.42 +	/**Used to pass arguments to ldd when checking inter-process data access*/
    1.43 +	struct IPAccessArgs
    1.44 +		{
    1.45 +		TUint  iProcessID;
    1.46 +		TUint iAddress;
    1.47 +		TUint  iValue;
    1.48 +		};
    1.49 +
    1.50 +public:
    1.51 +	static inline TVersion Version() { return TVersion(1, 0, 1); }
    1.52 +#ifndef __KERNEL_MODE__
    1.53 +public:
    1.54 +	inline TInt Open();
    1.55 +	inline TInt Process();
    1.56 +	inline TInt Chunk();
    1.57 +	inline TInt Thread();
    1.58 +	inline TInt IPAccess(RDebugAPIChecker::IPAccessArgs* aArgs);
    1.59 +#endif
    1.60 +	};
    1.61 +
    1.62 +
    1.63 +#ifndef __KERNEL_MODE__
    1.64 +
    1.65 +inline TInt RDebugAPIChecker::Open()
    1.66 +	{
    1.67 +	return DoCreate(KTestLddName, Version(), NULL, NULL, NULL, EOwnerThread);
    1.68 +	}
    1.69 +inline TInt RDebugAPIChecker::Process()
    1.70 +	{
    1.71 +	return DoControl(ETProcess);
    1.72 +	}
    1.73 +inline TInt RDebugAPIChecker::Chunk()
    1.74 +	{
    1.75 +	return DoControl(ETChunk);
    1.76 +	}
    1.77 +inline TInt RDebugAPIChecker::Thread()
    1.78 +	{
    1.79 +	return DoControl(ETThread);
    1.80 +	}
    1.81 +inline TInt RDebugAPIChecker::IPAccess(RDebugAPIChecker::IPAccessArgs* aArgs)
    1.82 +	{
    1.83 +	return DoControl(ETIPAccess, aArgs);
    1.84 +	}
    1.85 +
    1.86 +#endif //#ifndef __KERNEL_MODE__
    1.87 +
    1.88 +#ifdef __KERNEL_MODE__
    1.89 +
    1.90 +/**
    1.91 +Holds the offsets common to all memory models. 
    1.92 +@see TOffsetTableEntry.
    1.93 +*/
    1.94 +struct TDebugOffsetTable
    1.95 +	{
    1.96 +	// debugger info
    1.97 +	TInt iDebugger_ObjectOffsetTable;
    1.98 +	TInt iDebugger_ObjectOffsetTableCount;
    1.99 +	TInt iDebugger_ThreadContextTable;
   1.100 +	TInt iDebugger_Version;
   1.101 +	TInt iDebugger_OSVersion;
   1.102 +	TInt iDebugger_Reserved;
   1.103 +	TInt iDebugger_Containers;
   1.104 +	TInt iDebugger_Scheduler;
   1.105 +	TInt iDebugger_CurrentThread;
   1.106 +	TInt iDebugger_CodeSegGlobalList;
   1.107 +	TInt iDebugger_CodeSegLock;
   1.108 +	TInt iDebugger_Change;
   1.109 +	// DMutex info
   1.110 +	TInt iMutex_HoldCount;
   1.111 +	// more debugger info
   1.112 +	TInt iDebugger_ShadowPages;
   1.113 +	TInt iDebugger_ShadowPageCount;
   1.114 +	TInt iDebugger_EventMask;
   1.115 +	// DObjectCon info
   1.116 +	TInt iObjectCon_Mutex;
   1.117 +	TInt iObjectCon_Objects;
   1.118 +	TInt iObjectCon_Count;
   1.119 +	// more debugger info
   1.120 +	TInt iDebugger_EventHandlerBreakpoint;
   1.121 +	TInt iDebuggerOffset_Reserved6;
   1.122 +	TInt iDebuggerOffset_Reserved7;
   1.123 +	TInt iDebuggerOffset_Reserved8;
   1.124 +	// thread info
   1.125 +	TInt iThread_Name;
   1.126 +	TInt iThread_Id;
   1.127 +	TInt iThread_OwningProcess;
   1.128 +	TInt iThread_NThread;
   1.129 +	TInt iThread_SupervisorStack;
   1.130 +	TInt iThread_SupervisorStackSize;
   1.131 +	TInt iThread_UserStackRunAddress;
   1.132 +	TInt iThread_UserStackSize;
   1.133 +	TInt iThread_UserContextType;
   1.134 +	TInt iThread_SavedSupervisorSP;
   1.135 +	TInt iThread_Priority;
   1.136 +	TInt iThread_ThreadType;
   1.137 +	TInt iDebuggerOffset_Reserved12;
   1.138 +	// process info
   1.139 +	TInt iProcess_Name;
   1.140 +	TInt iProcess_Id;
   1.141 +	TInt iProcess_Attributes;
   1.142 +	TInt iProcess_CodeSeg;
   1.143 +	TInt iProcess_DataBssRunAddress;
   1.144 +	TInt iProcess_DataBssStackChunk;
   1.145 +	TInt iProcess_ChunkCount;			//ARMv5 specific
   1.146 +	TInt iProcess_Chunks;				//ARMv5 specific
   1.147 +	TInt iDebuggerOffset_Reserved13;
   1.148 +	TInt iDebuggerOffset_Reserved14;
   1.149 +	TInt iDebuggerOffset_Reserved15;
   1.150 +	TInt iDebuggerOffset_Reserved16;
   1.151 +	// chunkinfo info
   1.152 +	TInt iChunkInfo_DataSectionBase;	//ARMv5 specific
   1.153 +	TInt iChunkInfo_Chunk;				//ARMv5 specific
   1.154 +	TInt iDebuggerOffset_Reserved36;
   1.155 +	TInt iDebuggerOffset_Reserved37;
   1.156 +	// chunk info
   1.157 +	TInt iChunk_OwningProcess;			//ARMv5 specific
   1.158 +	TInt iChunk_Size;
   1.159 +	TInt iChunk_Attributes;
   1.160 +	TInt iChunk_ChunkType;
   1.161 +	TInt iChunk_ChunkState;				//ARMv5 specific
   1.162 +	TInt iChunk_HomeBase;				//ARMv5 specific
   1.163 +	TInt iDebuggerOffset_Reserved17;
   1.164 +	TInt iDebuggerOffset_Reserved18;
   1.165 +	TInt iDebuggerOffset_Reserved19;
   1.166 +	TInt iDebuggerOffset_Reserved20;
   1.167 +	// library info
   1.168 +	TInt iLibrary_MapCount;
   1.169 +	TInt iLibrary_State;
   1.170 +	TInt iLibrary_CodeSeg;
   1.171 +	TInt iDebuggerOffset_Reserved21;
   1.172 +	TInt iDebuggerOffset_Reserved22;
   1.173 +	TInt iDebuggerOffset_Reserved23;
   1.174 +	TInt iDebuggerOffset_Reserved24;
   1.175 +	// code seg info
   1.176 +	TInt iCodeSeg_Next;
   1.177 +	TInt iCodeSeg_Prev;
   1.178 +	TInt iCodeSeg_Deps;
   1.179 +	TInt iCodeSeg_DepsCount;
   1.180 +	TInt iCodeSeg_FileName;
   1.181 +	TInt iCodeSeg_XIP;
   1.182 +	TInt iCodeSeg_Info;
   1.183 +	TInt iDebuggerOffset_Reserved25;
   1.184 +	TInt iDebuggerOffset_Reserved26;
   1.185 +	TInt iDebuggerOffset_Reserved27;
   1.186 +	TInt iDebuggerOffset_Reserved28;
   1.187 +	// scheduler info
   1.188 +	TInt iScheduler_KernCSLocked;
   1.189 +	TInt iScheduler_LockWaiting;
   1.190 +	TInt iScheduler_CurrentThread;
   1.191 +	TInt iScheduler_AddressSpace;
   1.192 +	TInt iDebuggerOffset_Reserved29;
   1.193 +	TInt iDebuggerOffset_Reserved30;
   1.194 +	TInt iDebuggerOffset_Reserved31;
   1.195 +	TInt iDebuggerOffset_Reserved32;
   1.196 +	// code segment information non-XIP
   1.197 +	TInt iCodeSegInfoRAM_CodeSize;
   1.198 +	TInt iCodeSegInfoRAM_TextSize;
   1.199 +	TInt iCodeSegInfoRAM_DataSize;
   1.200 +	TInt iCodeSegInfoRAM_BssSize;
   1.201 +	TInt iCodeSegInfoRAM_CodeRunAddress;
   1.202 +	TInt iCodeSegInfoRAM_CodeLoadAddress;
   1.203 +	TInt iCodeSegInfoRAM_DataRunAddr;
   1.204 +	TInt iCodeSegInfoRAM_DataLoadAddr;
   1.205 +	TInt iCodeSegInfoRAM_ConstOffset;
   1.206 +	TInt iCodeSegInfoRAM_ExportDir;
   1.207 +	TInt iCodeSegInfoRAM_ExportDirCount;
   1.208 +	TInt iDebuggerOffset_Reserved38;
   1.209 +	TInt iDebuggerOffset_Reserved39;
   1.210 +	TInt iDebuggerOffset_Reserved40;
   1.211 +	TInt iDebuggerOffset_Reserved41;
   1.212 +	// code segment information XIP
   1.213 +	TInt iCodeSegInfoXIP_CodeAddress;
   1.214 +	TInt iCodeSegInfoXIP_DataAddress;
   1.215 +	TInt iCodeSegInfoXIP_DataRunAddress;
   1.216 +	TInt iCodeSegInfoXIP_CodeSize;
   1.217 +	TInt iCodeSegInfoXIP_TextSize;
   1.218 +	TInt iCodeSegInfoXIP_DataSize;
   1.219 +	TInt iCodeSegInfoXIP_BssSize;
   1.220 +	TInt iCodeSegInfoXIP_ExportDir;
   1.221 +	TInt iCodeSegInfoXIP_ExportDirCount;
   1.222 +	TInt iDebuggerOffset_Reserved42;
   1.223 +	TInt iDebuggerOffset_Reserved43;
   1.224 +	TInt iDebuggerOffset_Reserved44;
   1.225 +	TInt iDebuggerOffset_Reserved45;
   1.226 +	};
   1.227 +
   1.228 +/**
   1.229 +Holds the offsets specific to moving memory models.
   1.230 +@see TOffsetMovingTableEntry
   1.231 +*/
   1.232 +struct TMovingDebugOffsetTable
   1.233 +	{
   1.234 +	TInt iProcess_ChunkCount;
   1.235 +	TInt iProcess_Chunks;
   1.236 +
   1.237 +	TInt iChunkInfo_DataSectionBase;
   1.238 +	TInt iChunkInfo_Chunk;
   1.239 +
   1.240 +	TInt iChunk_OwningProcess;
   1.241 +	TInt iChunk_ChunkState;
   1.242 +	TInt iChunk_HomeBase;
   1.243 +
   1.244 +	TInt iReserved1;
   1.245 +	TInt iReserved2;
   1.246 +	TInt iReserved3;
   1.247 +	TInt iReserved4;
   1.248 +	};
   1.249 +
   1.250 +/**
   1.251 +Holds the offsets specific to multiple memory models.
   1.252 +@see TOffsetMultipleTableEntry
   1.253 +*/
   1.254 +struct TMultipleDebugOffsetTable 
   1.255 +	{
   1.256 +	TInt iProcess_OsAsid;
   1.257 +	TInt iProcess_LocalPageDir;
   1.258 +	TInt iProcess_ChunkCount;
   1.259 +	TInt iProcess_Chunks;
   1.260 +	TInt iChunkInfo_Chunk;
   1.261 +	TInt iChunk_OwningProcess;
   1.262 +	TInt iReserved1;
   1.263 +	TInt iReserved2;
   1.264 +	TInt iReserved3;
   1.265 +	TInt iReserved4;
   1.266 +	};
   1.267 +
   1.268 +class DDebugAPIChecker : public DLogicalChannelBase
   1.269 +	{
   1.270 +public:
   1.271 +	virtual ~DDebugAPIChecker();
   1.272 +protected:
   1.273 +	// from DLogicalChannelBase
   1.274 +	virtual TInt DoCreate(TInt aUnit, const TDesC8* aInfo, const TVersion& aVer);
   1.275 +	virtual TInt Request(TInt aFunction, TAny* a1, TAny* a2);
   1.276 +private:
   1.277 +	inline TInt8 Read8(void* aBase, TInt aOffset)	{return *((TInt8*)aBase + aOffset);}
   1.278 +	inline TInt  Read(void* aBase, TInt aOffset)	{return (TInt) (*((TInt*)((TInt8*)aBase + aOffset)));}
   1.279 +	
   1.280 +	TInt Process();
   1.281 +	TInt Chunk();
   1.282 +	TInt Thread();
   1.283 +	TInt IPAccess(TAny* a1);
   1.284 +	TUint8* ExtractName(TInt aSymbianName, TUint8* aCharName);
   1.285 +	TInt GetOffsets();
   1.286 +
   1.287 +	TInt ReadFromOtherProcessArmv6();
   1.288 +
   1.289 +private:
   1.290 +	DDebuggerInfo* iDebugInfo;
   1.291 +	TDebugOffsetTable* iOffsetTable;/**Contains the offsets common to all memory models*/ 
   1.292 +	TMemoryModelType iMMUType;		/**Identifies the memory model*/
   1.293 +	void* iVariantOffsetTable;		/**Contains memory-model-spacific offsets*/
   1.294 +	TInt* iScheduler;				/**Will hold the address of the scheduler*/
   1.295 +
   1.296 +	TInt iCurrentProcess_OsAsid;		//Used to call ReadFromOtherProcessArmv6
   1.297 +	TInt iCurrentProcess_LocalPageDir;	//Used to call ReadFromOtherProcessArmv6
   1.298 +	TInt iOtherProcess_OsAsid;			//Used to call ReadFromOtherProcessArmv6
   1.299 +	TInt iOtherProcess_LocalPageDir;	//Used to call ReadFromOtherProcessArmv6
   1.300 +	TInt iAddress;						//Used to call ReadFromOtherProcessArmv6
   1.301 +	};
   1.302 +
   1.303 +#endif //#ifdef __KERNEL_MODE__
   1.304 +
   1.305 +#endif // __D_DEBUGAPI_H__