Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Implements a debug thread for testing.
19 #include <e32base_private.h>
22 #include "d_rmdebugthread2.h"
24 #include "d_rmdebug_step_test.h"
25 #include "d_demand_paging.h"
27 EXPORT_C TBuf8<SYMBIAN_RMDBG_MEMORYSIZE> gMemoryAccessBytes;
28 IMPORT_C extern void RMDebug_BranchTst1();
29 IMPORT_C extern TInt RMDebugDemandPagingTest();
31 EXPORT_C TInt TestData;
32 EXPORT_C TTestFunction FunctionChooser;
34 const TInt NUMBER_TRACE_CALLS = 200;
36 EXPORT_C TInt TestFunction()
38 //set TestData to an arbitrary value which we check for in t_rmdebug
39 TestData = 0xffeeddcc;
41 User::After(3000000); // pause three seconds.
47 Wrapper around RMDebugDemandPagingTest, need to pause for a short time to
48 allow time in t_rmdebug.cpp to issue a User::WaitForRequest to catch the break point
50 EXPORT_C void TestPagedCode()
54 // call the function in paged code
55 RMDebugDemandPagingTest();
58 EXPORT_C void TestMultipleTraceCalls()
60 //arbitrary function to set a BP on
63 for(TInt cnt = NUMBER_TRACE_CALLS; cnt>0; cnt--)
65 RDebug::Printf("Trace event");
68 //another arbitrary function to set a BP on
69 RMDebug_StepTest_Non_PC_Modifying();
72 CDebugServThread::CDebugServThread()
79 GLDEF_C TInt CDebugServThread::ThreadFunction(TAny*)
81 // Generic thread function for testing
84 // set FunctionChooser to run the default function
85 FunctionChooser = EDefaultFunction;
87 CTrapCleanup* cleanup=CTrapCleanup::New();
90 User::Leave(KErrNoMemory);
93 RThread::Rendezvous(KErrNone);
97 while(TestData != 0xFFFFFFFF)
99 switch(FunctionChooser)
101 case EDemandPagingFunction:
104 case EDefaultFunction:
105 // the default function is the stepping test functions
108 RMDebug_BranchTst1();
110 // Single stepping test support code
113 RMDebug_StepTest_Non_PC_Modifying();
115 RMDebug_StepTest_Branch();
117 RMDebug_StepTest_Branch_And_Link();
119 RMDebug_StepTest_MOV_PC();
121 RMDebug_StepTest_LDR_PC();
123 // thumb/interworking tests not supported on armv4
124 #ifdef __MARM_ARMV5__
127 RMDebug_StepTest_Thumb_Non_PC_Modifying();
129 RMDebug_StepTest_Thumb_Branch();
131 RMDebug_StepTest_Thumb_Branch_And_Link();
133 RMDebug_StepTest_Thumb_Back_Branch_And_Link();
135 // ARM <-> Thumb interworking tests
136 RMDebug_StepTest_Interwork();
138 RMDebug_StepTest_Thumb_AddPC();
140 #endif // __MARM_ARMV5__
142 // Single-stepping performance
143 RMDebug_StepTest_Count();
145 // multiple step test
146 RMDebug_StepTest_ARM_Step_Multiple();
150 // Wait 50mSecs. // (suspends this thread)
155 case EMultipleTraceCalls:
156 TestMultipleTraceCalls();
169 EXPORT_C TInt StartDebugThread(RThread& aDebugThread, const TDesC& aDebugThreadName)
171 // Starts a test thread
177 res = aDebugThread.Create( aDebugThreadName,
178 CDebugServThread::ThreadFunction,
180 KDebugThreadDefaultHeapSize,
181 KDebugThreadDefaultHeapSize,
185 // Check that the creation worked
188 TRequestStatus rendezvousStatus;
190 aDebugThread.SetPriority(EPriorityNormal);
191 // Make a request for a rendezvous
192 aDebugThread.Rendezvous(rendezvousStatus);
193 // Set the thread as ready for execution
194 aDebugThread.Resume();
195 // Wait for the resumption
196 User::WaitForRequest(rendezvousStatus);
201 aDebugThread.Close();