1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/rm_debug/d_rmdebugthread2.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,205 @@
1.4 +// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Implements a debug thread for testing.
1.18 +//
1.19 +//
1.20 +
1.21 +#include <e32base.h>
1.22 +#include <e32base_private.h>
1.23 +#include <e32cons.h>
1.24 +#include <e32debug.h>
1.25 +#include "d_rmdebugthread2.h"
1.26 +
1.27 +#include "d_rmdebug_step_test.h"
1.28 +#include "d_demand_paging.h"
1.29 +
1.30 +EXPORT_C TBuf8<SYMBIAN_RMDBG_MEMORYSIZE> gMemoryAccessBytes;
1.31 +IMPORT_C extern void RMDebug_BranchTst1();
1.32 +IMPORT_C extern TInt RMDebugDemandPagingTest();
1.33 +
1.34 +EXPORT_C TInt TestData;
1.35 +EXPORT_C TTestFunction FunctionChooser;
1.36 +
1.37 +const TInt NUMBER_TRACE_CALLS = 200;
1.38 +
1.39 +EXPORT_C TInt TestFunction()
1.40 + {
1.41 + //set TestData to an arbitrary value which we check for in t_rmdebug
1.42 + TestData = 0xffeeddcc;
1.43 +
1.44 + User::After(3000000); // pause three seconds.
1.45 +
1.46 + return 0;
1.47 + }
1.48 +
1.49 +/**
1.50 + Wrapper around RMDebugDemandPagingTest, need to pause for a short time to
1.51 + allow time in t_rmdebug.cpp to issue a User::WaitForRequest to catch the break point
1.52 + */
1.53 +EXPORT_C void TestPagedCode()
1.54 + {
1.55 + User::After(100000);
1.56 +
1.57 + // call the function in paged code
1.58 + RMDebugDemandPagingTest();
1.59 + }
1.60 +
1.61 +EXPORT_C void TestMultipleTraceCalls()
1.62 + {
1.63 + //arbitrary function to set a BP on
1.64 + RMDebug_BranchTst1();
1.65 +
1.66 + for(TInt cnt = NUMBER_TRACE_CALLS; cnt>0; cnt--)
1.67 + {
1.68 + RDebug::Printf("Trace event");
1.69 + }
1.70 +
1.71 + //another arbitrary function to set a BP on
1.72 + RMDebug_StepTest_Non_PC_Modifying();
1.73 + }
1.74 +
1.75 +CDebugServThread::CDebugServThread()
1.76 +//
1.77 +// Empty constructor
1.78 +//
1.79 + {
1.80 + }
1.81 +
1.82 +GLDEF_C TInt CDebugServThread::ThreadFunction(TAny*)
1.83 +//
1.84 +// Generic thread function for testing
1.85 +//
1.86 + {
1.87 + // set FunctionChooser to run the default function
1.88 + FunctionChooser = EDefaultFunction;
1.89 +
1.90 + CTrapCleanup* cleanup=CTrapCleanup::New();
1.91 + if (cleanup == NULL)
1.92 + {
1.93 + User::Leave(KErrNoMemory);
1.94 + }
1.95 +
1.96 + RThread::Rendezvous(KErrNone);
1.97 +
1.98 + TestData = 1;
1.99 +
1.100 + while(TestData != 0xFFFFFFFF)
1.101 + {
1.102 + switch(FunctionChooser)
1.103 + {
1.104 + case EDemandPagingFunction:
1.105 + TestPagedCode();
1.106 + break;
1.107 + case EDefaultFunction:
1.108 + // the default function is the stepping test functions
1.109 + case EStepFunction:
1.110 + {
1.111 + RMDebug_BranchTst1();
1.112 +
1.113 + // Single stepping test support code
1.114 +
1.115 + // ARM tests
1.116 + RMDebug_StepTest_Non_PC_Modifying();
1.117 +
1.118 + RMDebug_StepTest_Branch();
1.119 +
1.120 + RMDebug_StepTest_Branch_And_Link();
1.121 +
1.122 + RMDebug_StepTest_MOV_PC();
1.123 +
1.124 + RMDebug_StepTest_LDR_PC();
1.125 +
1.126 +// thumb/interworking tests not supported on armv4
1.127 +#ifdef __MARM_ARMV5__
1.128 +
1.129 + // Thumb tests
1.130 + RMDebug_StepTest_Thumb_Non_PC_Modifying();
1.131 +
1.132 + RMDebug_StepTest_Thumb_Branch();
1.133 +
1.134 + RMDebug_StepTest_Thumb_Branch_And_Link();
1.135 +
1.136 + RMDebug_StepTest_Thumb_Back_Branch_And_Link();
1.137 +
1.138 + // ARM <-> Thumb interworking tests
1.139 + RMDebug_StepTest_Interwork();
1.140 +
1.141 + RMDebug_StepTest_Thumb_AddPC();
1.142 +
1.143 +#endif // __MARM_ARMV5__
1.144 +
1.145 + // Single-stepping performance
1.146 + RMDebug_StepTest_Count();
1.147 +
1.148 + // multiple step test
1.149 + RMDebug_StepTest_ARM_Step_Multiple();
1.150 +
1.151 + TestData++;
1.152 +
1.153 + // Wait 50mSecs. // (suspends this thread)
1.154 + User::After(50000);
1.155 +
1.156 + break;
1.157 + }
1.158 + case EMultipleTraceCalls:
1.159 + TestMultipleTraceCalls();
1.160 + break;
1.161 + default:
1.162 + //do nothing
1.163 + break;
1.164 + }
1.165 + }
1.166 +
1.167 + delete cleanup;
1.168 +
1.169 + return (KErrNone);
1.170 + }
1.171 +
1.172 +EXPORT_C TInt StartDebugThread(RThread& aDebugThread, const TDesC& aDebugThreadName)
1.173 +//
1.174 +// Starts a test thread
1.175 +//
1.176 +{
1.177 + TInt res=KErrNone;
1.178 +
1.179 + // Create the thread
1.180 + res = aDebugThread.Create( aDebugThreadName,
1.181 + CDebugServThread::ThreadFunction,
1.182 + KDefaultStackSize,
1.183 + KDebugThreadDefaultHeapSize,
1.184 + KDebugThreadDefaultHeapSize,
1.185 + NULL
1.186 + );
1.187 +
1.188 + // Check that the creation worked
1.189 + if (res == KErrNone)
1.190 + {
1.191 + TRequestStatus rendezvousStatus;
1.192 +
1.193 + aDebugThread.SetPriority(EPriorityNormal);
1.194 + // Make a request for a rendezvous
1.195 + aDebugThread.Rendezvous(rendezvousStatus);
1.196 + // Set the thread as ready for execution
1.197 + aDebugThread.Resume();
1.198 + // Wait for the resumption
1.199 + User::WaitForRequest(rendezvousStatus);
1.200 + }
1.201 + else
1.202 + {
1.203 + // Close the handle.
1.204 + aDebugThread.Close();
1.205 + }
1.206 +
1.207 + return res;
1.208 + }