|
1 // Copyright (c) 2007-2010 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 "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 // |
|
15 // |
|
16 |
|
17 #include <memmodel/epoc/platform.h> |
|
18 #include <kernel.h> |
|
19 |
|
20 #include "TestDataWriter.h" |
|
21 |
|
22 |
|
23 #if defined _DEBUG |
|
24 |
|
25 void Panic(TInt aReason) |
|
26 { |
|
27 TDW_PRINTF("Panic with reason %d", aReason); |
|
28 Kern::PanicCurrentThread(_L("Trace core TestDataWriter PANIC"), aReason); |
|
29 } |
|
30 |
|
31 #endif |
|
32 |
|
33 DTestDataWriter::DTestDataWriter() |
|
34 : DTraceCoreWriter(EWriterTypeTest) |
|
35 , iNotifier(NULL) |
|
36 { |
|
37 } |
|
38 |
|
39 DTestDataWriter::~DTestDataWriter() |
|
40 { |
|
41 } |
|
42 |
|
43 TInt DTestDataWriter::Close() |
|
44 { |
|
45 return KErrNone; |
|
46 } |
|
47 |
|
48 TInt DTestDataWriter::Init() |
|
49 { |
|
50 return Register(); |
|
51 } |
|
52 |
|
53 TUint32 DTestDataWriter::WriteStart( TWriterEntryType aType ) |
|
54 { |
|
55 if(iNotifier) |
|
56 { |
|
57 iNotifier->WriteStart(); |
|
58 } |
|
59 |
|
60 iBuffer.Zero(); |
|
61 if ( aType == EWriterEntryTrace ) |
|
62 { |
|
63 iBuffer.SetLength( 1 ); |
|
64 iBuffer[0] = SYMBIAN_TRACE; |
|
65 } |
|
66 else if ( aType == EWriterEntryAscii ) |
|
67 { |
|
68 iBuffer.SetLength( 1 ); |
|
69 iBuffer[0] = PRINTF_TRACE; |
|
70 } |
|
71 |
|
72 return 0; |
|
73 } |
|
74 |
|
75 void DTestDataWriter::WriteEnd( TUint32 /*aEntryId*/ ) |
|
76 { |
|
77 if(iNotifier) |
|
78 { |
|
79 iNotifier->WriteComplete(TNotifyData((TUint32)iBuffer.Ptr(), iBuffer.Length())); |
|
80 } |
|
81 } |
|
82 |
|
83 void DTestDataWriter::WriteData( TUint32 /*aEntryId*/, TUint8 aData ) |
|
84 { |
|
85 TInt len = iBuffer.Length(); |
|
86 TInt sz = sizeof( TUint8 ); |
|
87 |
|
88 if(len + sz < iBuffer.MaxLength()) |
|
89 { |
|
90 iBuffer.Append((TUint8*) &aData, sz); |
|
91 } |
|
92 } |
|
93 |
|
94 void DTestDataWriter::WriteData( TUint32 /*aEntryId*/, TUint16 aData ) |
|
95 { |
|
96 TInt len = iBuffer.Length(); |
|
97 TInt sz = sizeof( TUint16 ); |
|
98 if(len + sz < iBuffer.MaxLength()) |
|
99 { |
|
100 iBuffer.Append((TUint8*) &aData, sz); |
|
101 } |
|
102 } |
|
103 |
|
104 void DTestDataWriter::WriteData( TUint32 /*aEntryId*/, TUint32 aData ) |
|
105 { |
|
106 |
|
107 TInt len = iBuffer.Length(); |
|
108 TInt sz = sizeof( TUint32 ); |
|
109 |
|
110 if(len + sz < iBuffer.MaxLength()) |
|
111 { |
|
112 iBuffer.Append((TUint8*) &aData, sz); |
|
113 } |
|
114 } |
|
115 |
|
116 |