1 // Copyright (c) 2006-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". |
|
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 = 28; |
|
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 void 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 TestRegisterAccess(); |
|
90 void TestAttachExecutable(); |
|
91 void TestDebugFunctionality(); |
|
92 void TestStep(); |
|
93 void DoTestStep(TBool aThreadSpecific); |
|
94 void TestDriverSecurity(); |
|
95 void TestSecurity(); |
|
96 void TestEvents(); |
|
97 void TestEventsForExternalProcess(); |
|
98 void TestDemandPaging(); |
|
99 void TestTraceSecurity(); |
|
100 void TestDllUsage(); |
|
101 void TestKillProcess(); |
|
102 void TestProcessBreakPoints(); |
|
103 void TestMultipleTraceEvents(); |
|
104 void TestAddRemoveProcessEvents(); |
|
105 void TestProcessKillBreakpoint(); |
|
106 void DoTestProcessKillBreakpoint(); |
|
107 |
|
108 //crash flash test functions |
|
109 void TestCrashFlash(); |
|
110 |
|
111 TInt GetFlag(const TDes8 &aFlags, const TUint aOffset, Debug::TRegisterFlag &aFlagValue) const; |
|
112 |
|
113 void ReportPerformance(void); |
|
114 |
|
115 // helper functions |
|
116 void HelpTestSecurityAttachDetachExecutable(const TDesC& aProcessName, TBool aExpectSuccess); |
|
117 |
|
118 TInt HelpTestStepSetBreak(Debug::TBreakId& aBreakId, TThreadId aThreadId, const TUint32 aBreakAddress, Debug::TArchitectureMode aMode, TBool aThreadSpecific=ETrue, TProcessId aProcessId=0); |
|
119 TInt HelpTestStepClearBreak(const Debug::TBreakId aBreakId, const TThreadId aThreadId, TBool aThreadSpecific); |
|
120 TInt HelpTestStepWaitForBreak(const TDesC& aProcessName, Debug::TEventInfo& aEventInfo); |
|
121 TInt HelpTestStepReadPC(TThreadId aThreadId, TUint32& aPC); |
|
122 TInt HelpTestStep(TThreadId aThreadId, TUint32 aStartAddress, TUint32 aEndAddress, Debug::TArchitectureMode aMode, TUint aNumSteps, TBool aThreadSpecific=ETrue, TProcessId=0); |
|
123 |
|
124 TInt HelpTicksPerSecond(void); |
|
125 |
|
126 // helper functions |
|
127 void HelpStartTestTimer(void) { iStartTick = User::NTickCount(); iStopTick = 0; }; |
|
128 void HelpStopTestTimer(void) { iStopTick = User::NTickCount(); }; |
|
129 TInt HelpGetTestTicks(void) { return (iStopTick - iStartTick); }; |
|
130 TInt SwitchTestFunction(TTestFunction aTestFunction); |
|
131 TInt LaunchProcess(RProcess& aProcess, const TDesC& aFileName, TDebugFunctionType aFunctionType, TUint32 aDelay=0, TUint32 aExtraThreads=0); |
|
132 Debug::TTagHeader* GetTagHdr(const TDesC8& aDebugFunctionalityBlock, const Debug::TTagHeaderId aTagHdrId) const; |
|
133 Debug::TTag* GetTag(const Debug::TTagHeader* aTagHdr, const TInt aElement) const; |
|
134 Debug::TTag GetTag(const Debug::TTagHeaderId aTagHdrId, const TInt aElement); |
|
135 TBool ProcessExists(const TProcessId aProcessId); |
|
136 TBool ThreadExistsForProcess(const TThreadId aThreadId, const TProcessId aProcessId); |
|
137 TBool ListingSupported(const Debug::TListId aListId, const Debug::TListScope aListScope); |
|
138 void TestEventsWithExtraThreads(Debug::TKernelEventAction aActionMain, Debug::TKernelEventAction aActionExtra, TUint32 aExtraThreads); |
|
139 void FillArray(); |
|
140 void PrintUsage(); |
|
141 void PrintVersion(); |
|
142 |
|
143 enum TTestMode |
|
144 { |
|
145 //run all the tests |
|
146 EModeAll = 1<<0, |
|
147 //run the specified tests in reverse order |
|
148 EModeReverse = 1<<1, |
|
149 //print out help |
|
150 EModeHelp = 1<<2, |
|
151 //print out help |
|
152 EModeVersion = 1<<3 |
|
153 }; |
|
154 |
|
155 void RunTest(TInt aTestNumber); |
|
156 void ParseCommandLineL(TUint32& aMode, RArray<TInt>& aTests); |
|
157 |
|
158 TBool ProcessExists(const TDesC& aProcessName); |
|
159 |
|
160 private: |
|
161 |
|
162 TFunctionData iTestArray[KMaxTests]; |
|
163 #if defined(KERNEL_OOM_TESTING) |
|
164 RKernelLowMemorySecuritySvrSession iServSession; |
|
165 #elif defined (USER_OOM_TESTING) |
|
166 RUserLowMemorySecuritySvrSession iServSession; |
|
167 #else |
|
168 Debug::RSecuritySvrSession iServSession; |
|
169 #endif |
|
170 RThread iDebugThread; |
|
171 RProcess iDSSProcess; |
|
172 RSemaphore iAddressGlobSem; |
|
173 TThreadId iThreadID; |
|
174 TFileName iFileName; |
|
175 TUid iMySid; |
|
176 |
|
177 // Performance data |
|
178 TInt iMemoryReadKbytesPerSecond; |
|
179 TInt iMemoryWriteKbytesPerSecond; |
|
180 TInt iBreakpointsPerSecond; |
|
181 TInt iMaxBreakpoints; |
|
182 TInt iStepsPerSecond; |
|
183 |
|
184 // Timing information |
|
185 TInt iStartTick; |
|
186 TInt iStopTick; |
|
187 }; |
|
188 |
|
189 #endif // RMDEBUG_H |
|