sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Implements a debug thread for testing. sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include "d_rmdebugthread.h" sl@0: sl@0: EXPORT_C TBuf8 gMemoryAccessBytes; sl@0: extern void RMDebug_BranchTst1(); sl@0: sl@0: EXPORT_C TInt TestData; sl@0: sl@0: CDebugServThread::CDebugServThread() sl@0: // sl@0: // Empty constructor sl@0: // sl@0: { sl@0: } sl@0: sl@0: GLDEF_C TInt CDebugServThread::ThreadFunction(TAny*) sl@0: // sl@0: // Generic thread function for testing sl@0: // sl@0: { sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); sl@0: if (cleanup == NULL) sl@0: { sl@0: User::Leave(KErrNoMemory); sl@0: } sl@0: sl@0: RThread::Rendezvous(KErrNone); sl@0: sl@0: TestData = 1; sl@0: sl@0: while(1) sl@0: { sl@0: RMDebug_BranchTst1(); sl@0: sl@0: TestData++; sl@0: sl@0: // Wait half a second (suspends this thread) sl@0: User::After(500000); sl@0: sl@0: if (TestData == 0xFFFFFFFF) sl@0: { sl@0: break; sl@0: } sl@0: } sl@0: sl@0: delete cleanup; sl@0: sl@0: return (KErrNone); sl@0: } sl@0: sl@0: EXPORT_C TInt StartDebugThread(RThread& aDebugThread) sl@0: // sl@0: // Starts the test thread sl@0: // sl@0: { sl@0: TInt res=KErrNone; sl@0: sl@0: // Create the thread sl@0: res = aDebugThread.Create( KDebugThreadName, sl@0: CDebugServThread::ThreadFunction, sl@0: KDefaultStackSize, sl@0: KDebugThreadDefaultHeapSize, sl@0: KDebugThreadDefaultHeapSize, sl@0: NULL sl@0: ); sl@0: sl@0: // Check that the creation worked sl@0: if (res == KErrNone) sl@0: { sl@0: TRequestStatus rendezvousStatus; sl@0: sl@0: aDebugThread.SetPriority(EPriorityNormal); sl@0: // Make a request for a rendezvous sl@0: aDebugThread.Rendezvous(rendezvousStatus); sl@0: // Set the thread as ready for execution sl@0: aDebugThread.Resume(); sl@0: // Wait for the resumption sl@0: User::WaitForRequest(rendezvousStatus); sl@0: } sl@0: else sl@0: { sl@0: // Close the handle. sl@0: aDebugThread.Close(); sl@0: } sl@0: sl@0: return res; sl@0: }