author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 2 |
// All rights reserved. |
sl@0 | 3 |
// This component and the accompanying materials are made available |
sl@0 | 4 |
// under the terms of the License "Eclipse Public License v1.0" |
sl@0 | 5 |
// which accompanies this distribution, and is available |
sl@0 | 6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 7 |
// |
sl@0 | 8 |
// Initial Contributors: |
sl@0 | 9 |
// Nokia Corporation - initial contribution. |
sl@0 | 10 |
// |
sl@0 | 11 |
// Contributors: |
sl@0 | 12 |
// |
sl@0 | 13 |
// Description: |
sl@0 | 14 |
// Implements a debug thread for testing. |
sl@0 | 15 |
// |
sl@0 | 16 |
// |
sl@0 | 17 |
|
sl@0 | 18 |
#include <e32base.h> |
sl@0 | 19 |
#include <e32base_private.h> |
sl@0 | 20 |
#include <e32cons.h> |
sl@0 | 21 |
#include "d_rmdebugthread.h" |
sl@0 | 22 |
|
sl@0 | 23 |
EXPORT_C TBuf8<SYMBIAN_RMDBG_MEMORYSIZE> gMemoryAccessBytes; |
sl@0 | 24 |
extern void RMDebug_BranchTst1(); |
sl@0 | 25 |
|
sl@0 | 26 |
EXPORT_C TInt TestData; |
sl@0 | 27 |
|
sl@0 | 28 |
CDebugServThread::CDebugServThread() |
sl@0 | 29 |
// |
sl@0 | 30 |
// Empty constructor |
sl@0 | 31 |
// |
sl@0 | 32 |
{ |
sl@0 | 33 |
} |
sl@0 | 34 |
|
sl@0 | 35 |
GLDEF_C TInt CDebugServThread::ThreadFunction(TAny*) |
sl@0 | 36 |
// |
sl@0 | 37 |
// Generic thread function for testing |
sl@0 | 38 |
// |
sl@0 | 39 |
{ |
sl@0 | 40 |
CTrapCleanup* cleanup=CTrapCleanup::New(); |
sl@0 | 41 |
if (cleanup == NULL) |
sl@0 | 42 |
{ |
sl@0 | 43 |
User::Leave(KErrNoMemory); |
sl@0 | 44 |
} |
sl@0 | 45 |
|
sl@0 | 46 |
RThread::Rendezvous(KErrNone); |
sl@0 | 47 |
|
sl@0 | 48 |
TestData = 1; |
sl@0 | 49 |
|
sl@0 | 50 |
while(1) |
sl@0 | 51 |
{ |
sl@0 | 52 |
RMDebug_BranchTst1(); |
sl@0 | 53 |
|
sl@0 | 54 |
TestData++; |
sl@0 | 55 |
|
sl@0 | 56 |
// Wait half a second (suspends this thread) |
sl@0 | 57 |
User::After(500000); |
sl@0 | 58 |
|
sl@0 | 59 |
if (TestData == 0xFFFFFFFF) |
sl@0 | 60 |
{ |
sl@0 | 61 |
break; |
sl@0 | 62 |
} |
sl@0 | 63 |
} |
sl@0 | 64 |
|
sl@0 | 65 |
delete cleanup; |
sl@0 | 66 |
|
sl@0 | 67 |
return (KErrNone); |
sl@0 | 68 |
} |
sl@0 | 69 |
|
sl@0 | 70 |
EXPORT_C TInt StartDebugThread(RThread& aDebugThread) |
sl@0 | 71 |
// |
sl@0 | 72 |
// Starts the test thread |
sl@0 | 73 |
// |
sl@0 | 74 |
{ |
sl@0 | 75 |
TInt res=KErrNone; |
sl@0 | 76 |
|
sl@0 | 77 |
// Create the thread |
sl@0 | 78 |
res = aDebugThread.Create( KDebugThreadName, |
sl@0 | 79 |
CDebugServThread::ThreadFunction, |
sl@0 | 80 |
KDefaultStackSize, |
sl@0 | 81 |
KDebugThreadDefaultHeapSize, |
sl@0 | 82 |
KDebugThreadDefaultHeapSize, |
sl@0 | 83 |
NULL |
sl@0 | 84 |
); |
sl@0 | 85 |
|
sl@0 | 86 |
// Check that the creation worked |
sl@0 | 87 |
if (res == KErrNone) |
sl@0 | 88 |
{ |
sl@0 | 89 |
TRequestStatus rendezvousStatus; |
sl@0 | 90 |
|
sl@0 | 91 |
aDebugThread.SetPriority(EPriorityNormal); |
sl@0 | 92 |
// Make a request for a rendezvous |
sl@0 | 93 |
aDebugThread.Rendezvous(rendezvousStatus); |
sl@0 | 94 |
// Set the thread as ready for execution |
sl@0 | 95 |
aDebugThread.Resume(); |
sl@0 | 96 |
// Wait for the resumption |
sl@0 | 97 |
User::WaitForRequest(rendezvousStatus); |
sl@0 | 98 |
} |
sl@0 | 99 |
else |
sl@0 | 100 |
{ |
sl@0 | 101 |
// Close the handle. |
sl@0 | 102 |
aDebugThread.Close(); |
sl@0 | 103 |
} |
sl@0 | 104 |
|
sl@0 | 105 |
return res; |
sl@0 | 106 |
} |