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