sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Definitions for the run mode debug tests sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalTechnology sl@0: @released sl@0: */ sl@0: sl@0: #ifndef RMDEBUG_H sl@0: #define RMDEBUG_H sl@0: sl@0: #include "t_rmdebug_app.h" sl@0: #include "r_user_low_memory_security_svr_session.h" sl@0: #include "r_kernel_low_memory_security_svr_session.h" sl@0: sl@0: sl@0: class CRunModeAgent; sl@0: sl@0: // Create a pointer to function type sl@0: typedef void (CRunModeAgent::*testFunction)(); sl@0: sl@0: class TFunctionData sl@0: { sl@0: public: sl@0: testFunction iFunctionPtr; sl@0: TBuf<40> iFunctionName; sl@0: }; sl@0: sl@0: //number of test functions that we have sl@0: const TInt KMaxTests = 28; sl@0: sl@0: // sl@0: // class CRunModeAgent sl@0: // sl@0: // The basic run mode agent. sl@0: // sl@0: class CRunModeAgent : public CBase sl@0: { sl@0: public: sl@0: static CRunModeAgent* NewL(); sl@0: ~CRunModeAgent(); sl@0: void ClientAppL(); sl@0: sl@0: private: sl@0: CRunModeAgent(); sl@0: void ConstructL(); sl@0: void SetupAndAttachToDSS(); sl@0: sl@0: TInt TestStartup(); sl@0: TInt TestShutdown(); sl@0: sl@0: void TestGetExecutablesList(); sl@0: void TestGetProcessList(); sl@0: void TestGetThreadList(); sl@0: void TestGetCodeSegsList(); sl@0: void TestGetXipLibrariesList(); sl@0: void TestGetListInvalidData(); sl@0: sl@0: void DoTestGetThreadList(const TBool aShouldPass, const Debug::TListScope aListScope, const TUint64 aTargetId=0); sl@0: void DoTestGetCodeSegsList(const TBool aShouldPass, const Debug::TListScope aListScope, const TUint64 aTargetId=0); sl@0: sl@0: void DoGetList(const Debug::TListId aListId, const Debug::TListScope aListScope, RBuf8& aBuffer, TUint32& aSize, const TUint64 aTargetId=0); sl@0: sl@0: void TestMemoryAccess(); sl@0: void TestSuspendResume(); sl@0: void TestBreakPoints(); sl@0: void TestConsecutiveBreakPoints(); sl@0: void TestModifyBreak(); sl@0: void DoTestModifyBreak(TBool aThreadSpecific); sl@0: void TestBreakInfo(); sl@0: void DoTestBreakInfo(TBool aThreadSpecific); sl@0: void TestRunToBreak(); sl@0: void DoTestRunToBreak(TBool aThreadSpecific); sl@0: void TestRegisterAccess(); sl@0: void TestAttachExecutable(); sl@0: void TestDebugFunctionality(); sl@0: void TestStep(); sl@0: void DoTestStep(TBool aThreadSpecific); sl@0: void TestDriverSecurity(); sl@0: void TestSecurity(); sl@0: void TestEvents(); sl@0: void TestEventsForExternalProcess(); sl@0: void TestDemandPaging(); sl@0: void TestTraceSecurity(); sl@0: void TestDllUsage(); sl@0: void TestKillProcess(); sl@0: void TestProcessBreakPoints(); sl@0: void TestMultipleTraceEvents(); sl@0: void TestAddRemoveProcessEvents(); sl@0: void TestProcessKillBreakpoint(); sl@0: void DoTestProcessKillBreakpoint(); sl@0: sl@0: //crash flash test functions sl@0: void TestCrashFlash(); sl@0: sl@0: TInt GetFlag(const TDes8 &aFlags, const TUint aOffset, Debug::TRegisterFlag &aFlagValue) const; sl@0: sl@0: void ReportPerformance(void); sl@0: sl@0: // helper functions sl@0: void HelpTestSecurityAttachDetachExecutable(const TDesC& aProcessName, TBool aExpectSuccess); sl@0: sl@0: TInt HelpTestStepSetBreak(Debug::TBreakId& aBreakId, TThreadId aThreadId, const TUint32 aBreakAddress, Debug::TArchitectureMode aMode, TBool aThreadSpecific=ETrue, TProcessId aProcessId=0); sl@0: TInt HelpTestStepClearBreak(const Debug::TBreakId aBreakId, const TThreadId aThreadId, TBool aThreadSpecific); sl@0: TInt HelpTestStepWaitForBreak(const TDesC& aProcessName, Debug::TEventInfo& aEventInfo); sl@0: TInt HelpTestStepReadPC(TThreadId aThreadId, TUint32& aPC); sl@0: TInt HelpTestStep(TThreadId aThreadId, TUint32 aStartAddress, TUint32 aEndAddress, Debug::TArchitectureMode aMode, TUint aNumSteps, TBool aThreadSpecific=ETrue, TProcessId=0); sl@0: sl@0: TInt HelpTicksPerSecond(void); sl@0: sl@0: // helper functions sl@0: void HelpStartTestTimer(void) { iStartTick = User::NTickCount(); iStopTick = 0; }; sl@0: void HelpStopTestTimer(void) { iStopTick = User::NTickCount(); }; sl@0: TInt HelpGetTestTicks(void) { return (iStopTick - iStartTick); }; sl@0: TInt SwitchTestFunction(TTestFunction aTestFunction); sl@0: TInt LaunchProcess(RProcess& aProcess, const TDesC& aFileName, TDebugFunctionType aFunctionType, TUint32 aDelay=0, TUint32 aExtraThreads=0); sl@0: Debug::TTagHeader* GetTagHdr(const TDesC8& aDebugFunctionalityBlock, const Debug::TTagHeaderId aTagHdrId) const; sl@0: Debug::TTag* GetTag(const Debug::TTagHeader* aTagHdr, const TInt aElement) const; sl@0: Debug::TTag GetTag(const Debug::TTagHeaderId aTagHdrId, const TInt aElement); sl@0: TBool ProcessExists(const TProcessId aProcessId); sl@0: TBool ThreadExistsForProcess(const TThreadId aThreadId, const TProcessId aProcessId); sl@0: TBool ListingSupported(const Debug::TListId aListId, const Debug::TListScope aListScope); sl@0: void TestEventsWithExtraThreads(Debug::TKernelEventAction aActionMain, Debug::TKernelEventAction aActionExtra, TUint32 aExtraThreads); sl@0: void FillArray(); sl@0: void PrintUsage(); sl@0: void PrintVersion(); sl@0: sl@0: enum TTestMode sl@0: { sl@0: //run all the tests sl@0: EModeAll = 1<<0, sl@0: //run the specified tests in reverse order sl@0: EModeReverse = 1<<1, sl@0: //print out help sl@0: EModeHelp = 1<<2, sl@0: //print out help sl@0: EModeVersion = 1<<3 sl@0: }; sl@0: sl@0: void RunTest(TInt aTestNumber); sl@0: void ParseCommandLineL(TUint32& aMode, RArray& aTests); sl@0: sl@0: TBool ProcessExists(const TDesC& aProcessName); sl@0: sl@0: private: sl@0: sl@0: TFunctionData iTestArray[KMaxTests]; sl@0: #if defined(KERNEL_OOM_TESTING) sl@0: RKernelLowMemorySecuritySvrSession iServSession; sl@0: #elif defined (USER_OOM_TESTING) sl@0: RUserLowMemorySecuritySvrSession iServSession; sl@0: #else sl@0: Debug::RSecuritySvrSession iServSession; sl@0: #endif sl@0: RThread iDebugThread; sl@0: RProcess iDSSProcess; sl@0: RSemaphore iAddressGlobSem; sl@0: TThreadId iThreadID; sl@0: TFileName iFileName; sl@0: TUid iMySid; sl@0: sl@0: // Performance data sl@0: TInt iMemoryReadKbytesPerSecond; sl@0: TInt iMemoryWriteKbytesPerSecond; sl@0: TInt iBreakpointsPerSecond; sl@0: TInt iMaxBreakpoints; sl@0: TInt iStepsPerSecond; sl@0: sl@0: // Timing information sl@0: TInt iStartTick; sl@0: TInt iStopTick; sl@0: }; sl@0: sl@0: #endif // RMDEBUG_H