0
|
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 |
// Implements a debug thread for testing.
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32base.h>
|
|
19 |
#include <e32base_private.h>
|
|
20 |
#include <e32cons.h>
|
|
21 |
#include "d_rmdebugthread.h"
|
|
22 |
|
|
23 |
EXPORT_C TBuf8<SYMBIAN_RMDBG_MEMORYSIZE> gMemoryAccessBytes;
|
|
24 |
extern void RMDebug_BranchTst1();
|
|
25 |
|
|
26 |
EXPORT_C TInt TestData;
|
|
27 |
|
|
28 |
CDebugServThread::CDebugServThread()
|
|
29 |
//
|
|
30 |
// Empty constructor
|
|
31 |
//
|
|
32 |
{
|
|
33 |
}
|
|
34 |
|
|
35 |
GLDEF_C TInt CDebugServThread::ThreadFunction(TAny*)
|
|
36 |
//
|
|
37 |
// Generic thread function for testing
|
|
38 |
//
|
|
39 |
{
|
|
40 |
CTrapCleanup* cleanup=CTrapCleanup::New();
|
|
41 |
if (cleanup == NULL)
|
|
42 |
{
|
|
43 |
User::Leave(KErrNoMemory);
|
|
44 |
}
|
|
45 |
|
|
46 |
RThread::Rendezvous(KErrNone);
|
|
47 |
|
|
48 |
TestData = 1;
|
|
49 |
|
|
50 |
while(1)
|
|
51 |
{
|
|
52 |
RMDebug_BranchTst1();
|
|
53 |
|
|
54 |
TestData++;
|
|
55 |
|
|
56 |
// Wait half a second (suspends this thread)
|
|
57 |
User::After(500000);
|
|
58 |
|
|
59 |
if (TestData == 0xFFFFFFFF)
|
|
60 |
{
|
|
61 |
break;
|
|
62 |
}
|
|
63 |
}
|
|
64 |
|
|
65 |
delete cleanup;
|
|
66 |
|
|
67 |
return (KErrNone);
|
|
68 |
}
|
|
69 |
|
|
70 |
EXPORT_C TInt StartDebugThread(RThread& aDebugThread)
|
|
71 |
//
|
|
72 |
// Starts the test thread
|
|
73 |
//
|
|
74 |
{
|
|
75 |
TInt res=KErrNone;
|
|
76 |
|
|
77 |
// Create the thread
|
|
78 |
res = aDebugThread.Create( KDebugThreadName,
|
|
79 |
CDebugServThread::ThreadFunction,
|
|
80 |
KDefaultStackSize,
|
|
81 |
KDebugThreadDefaultHeapSize,
|
|
82 |
KDebugThreadDefaultHeapSize,
|
|
83 |
NULL
|
|
84 |
);
|
|
85 |
|
|
86 |
// Check that the creation worked
|
|
87 |
if (res == KErrNone)
|
|
88 |
{
|
|
89 |
TRequestStatus rendezvousStatus;
|
|
90 |
|
|
91 |
aDebugThread.SetPriority(EPriorityNormal);
|
|
92 |
// Make a request for a rendezvous
|
|
93 |
aDebugThread.Rendezvous(rendezvousStatus);
|
|
94 |
// Set the thread as ready for execution
|
|
95 |
aDebugThread.Resume();
|
|
96 |
// Wait for the resumption
|
|
97 |
User::WaitForRequest(rendezvousStatus);
|
|
98 |
}
|
|
99 |
else
|
|
100 |
{
|
|
101 |
// Close the handle.
|
|
102 |
aDebugThread.Close();
|
|
103 |
}
|
|
104 |
|
|
105 |
return res;
|
|
106 |
}
|