debugsrv/runmodedebug/rmdebug_test/rm_debug/basic_tests/t_rmdebug2.h
changeset 56 aa2539c91954
parent 54 a151135b0cf9
child 60 e54443a6878c
child 62 1c2bb2fc7c87
equal deleted inserted replaced
54:a151135b0cf9 56:aa2539c91954
     1 // Copyright (c) 2006-2010 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 // Definitions for the run mode debug tests
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology
       
    21  @released
       
    22 */
       
    23 
       
    24 #ifndef RMDEBUG_H
       
    25 #define RMDEBUG_H
       
    26 
       
    27 #include "t_rmdebug_app.h"
       
    28 #include "r_user_low_memory_security_svr_session.h"
       
    29 #include "r_kernel_low_memory_security_svr_session.h"
       
    30 
       
    31 
       
    32 class CRunModeAgent;
       
    33 
       
    34 // Create a pointer to function type
       
    35 typedef void (CRunModeAgent::*testFunction)();
       
    36 
       
    37 class TFunctionData
       
    38 	{
       
    39 public:
       
    40 	testFunction iFunctionPtr;
       
    41 	TBuf<40> iFunctionName;
       
    42 	};
       
    43 
       
    44 //number of test functions that we have
       
    45 const TInt KMaxTests = 31; 
       
    46 
       
    47 //
       
    48 // class CRunModeAgent
       
    49 //
       
    50 // The basic run mode agent.
       
    51 //
       
    52 class CRunModeAgent : public CBase
       
    53 	{
       
    54 public:
       
    55 	static CRunModeAgent* NewL();
       
    56 	~CRunModeAgent();
       
    57 	void ClientAppL();
       
    58 
       
    59 private:
       
    60 	CRunModeAgent();
       
    61 	void ConstructL();
       
    62 	void SetupAndAttachToDSS();
       
    63 
       
    64 	TInt TestStartup();
       
    65 	TInt TestShutdown();
       
    66 
       
    67 	void TestGetExecutablesList();
       
    68 	void TestGetProcessList();
       
    69 	void TestGetThreadList();
       
    70 	void TestGetCodeSegsList();
       
    71 	void TestGetXipLibrariesList();
       
    72 	void TestGetListInvalidData();
       
    73 
       
    74 	TBool DoTestGetThreadList(const TBool aShouldPass, const Debug::TListScope aListScope, const TUint64 aTargetId=0);
       
    75 	void DoTestGetCodeSegsList(const TBool aShouldPass, const Debug::TListScope aListScope, const TUint64 aTargetId=0);
       
    76 
       
    77 	void DoGetList(const Debug::TListId aListId, const Debug::TListScope aListScope, RBuf8& aBuffer, TUint32& aSize, const TUint64 aTargetId=0);
       
    78 
       
    79 	void TestMemoryAccess();
       
    80 	void TestSuspendResume();
       
    81 	void TestBreakPoints();
       
    82 	void TestConsecutiveBreakPoints();
       
    83 	void TestModifyBreak();
       
    84 	void DoTestModifyBreak(TBool aThreadSpecific);
       
    85 	void TestBreakInfo();
       
    86 	void DoTestBreakInfo(TBool aThreadSpecific);
       
    87 	void TestRunToBreak();
       
    88 	void DoTestRunToBreak(TBool aThreadSpecific);
       
    89 	void TestBreakPointsInLoop();
       
    90 	void DoTestBreakPointsInLoop(TBool aThreadSpecific);
       
    91 	void TestRegisterAccess();
       
    92 	void TestAttachExecutable();
       
    93 	void TestDebugFunctionality();
       
    94 	void TestStep();
       
    95 	void DoTestStep(TBool aThreadSpecific);
       
    96 	void TestDriverSecurity();
       
    97 	void TestSecurity();
       
    98 	void TestEvents();
       
    99 	void TestEventsForExternalProcess();
       
   100 	void TestDemandPaging();
       
   101 	void TestTraceSecurity();
       
   102 	void TestDllUsage();
       
   103 	void TestKillProcess();
       
   104 	void TestProcessBreakPoints();
       
   105 	void TestMultipleTraceEvents();
       
   106 	void TestAddRemoveProcessEvents();
       
   107 	void TestProcessKillBreakpoint();
       
   108 	void DoTestProcessKillBreakpoint();
       
   109 	void TestAttachToAll();
       
   110 	void ResetAttachToAll(RThread& aTestThread, TRequestStatus* aFirstSessionStat=NULL, Debug::RSecuritySvrSession* aSecondSession=NULL);
       
   111 	void LaunchDebugProcessAndSetBreakpoint(RProcess& aResultProcess, TThreadId& aResultThread);
       
   112 	void TestResumeBreakpointsRepeatedly();
       
   113 
       
   114 	//crash flash test functions
       
   115 	void TestCrashFlash();
       
   116 		
       
   117 	TInt GetFlag(const TDes8 &aFlags, const TUint aOffset, Debug::TRegisterFlag &aFlagValue) const;
       
   118 
       
   119 	void ReportPerformance(void);
       
   120 
       
   121 	// helper functions
       
   122 	void HelpTestSecurityAttachDetachExecutable(const TDesC& aProcessName, TBool aExpectSuccess);
       
   123 
       
   124 	TInt HelpTestStepSetBreak(Debug::TBreakId& aBreakId, TThreadId aThreadId, const TUint32 aBreakAddress, Debug::TArchitectureMode aMode, TBool aThreadSpecific=ETrue, TProcessId aProcessId=0);
       
   125 	TInt HelpTestStepClearBreak(const Debug::TBreakId aBreakId, const TThreadId aThreadId, TBool aThreadSpecific);
       
   126 	TInt HelpTestStepWaitForBreak(const TDesC& aProcessName, Debug::TEventInfo& aEventInfo);
       
   127 	TInt HelpTestStepReadPC(TThreadId aThreadId, TUint32& aPC);
       
   128 	TInt HelpTestStep(TThreadId aThreadId, TUint32 aStartAddress, TUint32 aEndAddress, Debug::TArchitectureMode aMode, TUint aNumSteps, TBool aThreadSpecific=ETrue, TProcessId=0);
       
   129 
       
   130 	TInt HelpTicksPerSecond(void);
       
   131 
       
   132 	// helper functions
       
   133 	void HelpStartTestTimer(void) { iStartTick = User::NTickCount(); iStopTick = 0; };
       
   134 	void HelpStopTestTimer(void) { iStopTick = User::NTickCount(); };
       
   135 	TInt HelpGetTestTicks(void) { return (iStopTick - iStartTick); };
       
   136 	TInt SwitchTestFunction(TTestFunction aTestFunction, const TBool aResume = ETrue);
       
   137 	TInt LaunchProcess(RProcess& aProcess, const TDesC& aFileName, TDebugFunctionType aFunctionType, TUint32 aDelay=0, TUint32 aExtraThreads=0);
       
   138 	Debug::TTagHeader* GetTagHdr(const TDesC8& aDebugFunctionalityBlock, const Debug::TTagHeaderId aTagHdrId) const;
       
   139 	Debug::TTag* GetTag(const Debug::TTagHeader* aTagHdr, const TInt aElement) const;
       
   140 	Debug::TTag GetTag(const Debug::TTagHeaderId aTagHdrId, const TInt aElement);
       
   141 	TBool ProcessExists(const TProcessId aProcessId);
       
   142 	TBool ThreadExistsForProcess(const TThreadId aThreadId, const TProcessId aProcessId);
       
   143 	TBool ListingSupported(const Debug::TListId aListId, const Debug::TListScope aListScope);
       
   144 	void TestEventsWithExtraThreads(Debug::TKernelEventAction aActionMain, Debug::TKernelEventAction aActionExtra, TUint32 aExtraThreads);
       
   145 	void FillArray();
       
   146 	void PrintUsage();
       
   147 	void PrintVersion();
       
   148 
       
   149 	enum TTestMode 
       
   150 		{
       
   151 		//run all the tests
       
   152 		EModeAll = 1<<0,
       
   153 		//run the specified tests in reverse order
       
   154 		EModeReverse = 1<<1,
       
   155 		//print out help
       
   156 		EModeHelp = 1<<2,
       
   157 		//print out help
       
   158 		EModeVersion = 1<<3
       
   159 		};
       
   160 
       
   161 	void RunTest(TInt aTestNumber);
       
   162 	void ParseCommandLineL(TUint32& aMode, RArray<TInt>& aTests);
       
   163 
       
   164 	TBool ProcessExists(const TDesC& aProcessName);
       
   165 	static void TimedWait(TRequestStatus& aStatus, TInt aTimeoutInMs, TInt aLineNumber);
       
   166 
       
   167 
       
   168 private:
       
   169 
       
   170 	TFunctionData iTestArray[KMaxTests];
       
   171 #if defined(KERNEL_OOM_TESTING)
       
   172 	RKernelLowMemorySecuritySvrSession iServSession;
       
   173 #elif defined (USER_OOM_TESTING)
       
   174 	RUserLowMemorySecuritySvrSession iServSession;
       
   175 #else
       
   176 	Debug::RSecuritySvrSession iServSession;
       
   177 #endif
       
   178 	RThread	iDebugThread;
       
   179 	
       
   180 	//Set by test thread, used to check its run state
       
   181 	RProperty iRunCountSubscribe;
       
   182 	
       
   183 	// Used for timeouts when checking the run state
       
   184 	RTimer iTimer;
       
   185 	
       
   186 	RProcess iDSSProcess;
       
   187 	TThreadId iThreadID;
       
   188 	TFileName iFileName;
       
   189 
       
   190 	// Performance data
       
   191 	TInt iMemoryReadKbytesPerSecond;	
       
   192 	TInt iMemoryWriteKbytesPerSecond;	
       
   193 	TInt iBreakpointsPerSecond;
       
   194 	TInt iMaxBreakpoints;
       
   195 	TInt iStepsPerSecond;
       
   196 
       
   197 	// Timing information
       
   198 	TInt iStartTick;
       
   199 	TInt iStopTick;
       
   200 	};
       
   201 
       
   202 #endif // RMDEBUG_H