| author | William Roberts <williamr@symbian.org> | 
| Thu, 22 Jul 2010 16:32:06 +0100 | |
| branch | GCC_SURGE | 
| changeset 47 | 5b14749788d7 | 
| parent 25 | 84d9eb65b26f | 
| parent 44 | 36f374c67aa8 | 
| permissions | -rw-r--r-- | 
| 31 | 1 | /* | 
| 2 | * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). | |
| 3 | * All rights reserved. | |
| 4 | * This component and the accompanying materials are made available | |
| 5 | * under the terms of "Eclipse Public License v1.0" | |
| 6 | * which accompanies this distribution, and is available | |
| 7 | * at the URL "http://www.eclipse.org/legal/epl-v10.html". | |
| 8 | * | |
| 9 | * Initial Contributors: | |
| 10 | * Nokia Corporation - initial contribution. | |
| 11 | * | |
| 12 | * Contributors: | |
| 13 | * | |
| 14 | * Description: CS general debug class | |
| 15 | * | |
| 16 | */ | |
| 17 | ||
| 18 | ||
| 19 | // INCLUDE FILES | |
| 20 | ||
| 21 | // SYSTEM INCLUDES | |
| 22 | ||
| 23 | // USER INCLUDES | |
| 24 | #include "ccsdebug.h" | |
| 25 | ||
| 26 | // ============================== MEMBER FUNCTIONS ============================ | |
| 27 | ||
| 28 | // ---------------------------------------------------------------------------- | |
| 29 | // CCsDebugWrapper::__LatencyMarkStart | |
| 30 | // Marks the start time for latency measurement | |
| 31 | // ---------------------------------------------------------------------------- | |
| 32 | EXPORT_C void CCsDebugWrapper::__LatencyMarkStartL(TRefByValue<const TDesC> str) | |
| 33 | {
 | |
| 34 | CCsDebugArr* dbgArr = 0; | |
| 35 | ||
| 36 | // Check thread local storage: | |
| 37 | if ( !(Dll::Tls())) | |
| 38 | 	{	 
 | |
| 39 | dbgArr = CCsDebugArr::NewL(); | |
| 40 | User::LeaveIfError ( Dll::SetTls( dbgArr ) ); | |
| 41 | } | |
| 42 | else | |
| 43 | 	{
 | |
| 44 | dbgArr = static_cast<CCsDebugArr*>( Dll::Tls() ); | |
| 45 | } | |
| 46 | ||
| 47 | CCsDebug *dbg = CCsDebug::NewL(); | |
| 48 | dbg->Mark(str); | |
| 49 | ||
| 50 | dbgArr->Push(*dbg); | |
| 51 | } | |
| 52 | ||
| 53 | // ---------------------------------------------------------------------------- | |
| 54 | // CCsDebugWrapper::__LatencyMarkEnd | |
| 55 | // Marks the end time for latency measurement | |
| 56 | // Displays the difference from Latency Mark start | |
| 57 | // ---------------------------------------------------------------------------- | |
| 58 | EXPORT_C void CCsDebugWrapper::__LatencyMarkEnd(TRefByValue<const TDesC> str) | |
| 59 | {
 | |
| 60 | CCsDebugArr* dbgArr = 0; | |
| 61 | ||
| 62 | // Check thread local storage: | |
| 63 | if ( !(Dll::Tls()) ) | |
| 64 | 	{	 
 | |
| 65 | return; | |
| 66 | } | |
| 67 | else | |
| 68 | 	{
 | |
| 69 | dbgArr = static_cast<CCsDebugArr*>( Dll::Tls() ); | |
| 70 | } | |
| 71 | ||
| 44 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 72 | if ( dbgArr && !(dbgArr->IsEmpty()) ) | 
| 31 | 73 |     {
 | 
| 74 | CCsDebug* dbg = dbgArr->Pop(); | |
| 75 | dbg->UnMark(str); | |
| 76 | delete dbg; | |
| 77 | } | |
| 78 | ||
| 44 
36f374c67aa8
Revision: 201025
 Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> parents: 
31diff
changeset | 79 | if ( dbgArr && dbgArr->IsEmpty() ) | 
| 31 | 80 |     {
 | 
| 81 | delete dbgArr; | |
| 82 | Dll::SetTls( NULL ); | |
| 83 | } | |
| 84 | } | |
| 85 | ||
| 86 | // ---------------------------------------------------------------------------- | |
| 87 | // CCsDebug::NewL | |
| 88 | // Two Phase Construction | |
| 89 | // ---------------------------------------------------------------------------- | |
| 90 | EXPORT_C CCsDebug* CCsDebug::NewL() | |
| 91 | {
 | |
| 92 | CCsDebug* self = new (ELeave) CCsDebug(); | |
| 93 | CleanupStack::PushL(self); | |
| 94 | self->ConstructL(); | |
| 95 | CleanupStack::Pop(self); | |
| 96 | return self; | |
| 97 | } | |
| 98 | ||
| 99 | // ---------------------------------------------------------------------------- | |
| 100 | // CCsDebug::ConstructL | |
| 101 | // Two Phase Construction | |
| 102 | // ---------------------------------------------------------------------------- | |
| 103 | void CCsDebug::ConstructL() | |
| 104 | {
 | |
| 105 | } | |
| 106 | ||
| 107 | // ---------------------------------------------------------------------------- | |
| 108 | // CCsDebug::Mark | |
| 109 | // Marks the start time for latency measurement | |
| 110 | // ---------------------------------------------------------------------------- | |
| 111 | void CCsDebug::Mark(TRefByValue<const TDesC> str,...) | |
| 112 | {
 | |
| 113 | VA_LIST list; | |
| 114 | VA_START(list, str); | |
| 115 | ||
| 116 | // Print to log file | |
| 117 | TBuf<MAX_BUFF_LENGTH> buf; | |
| 118 | buf.FormatList(str, list); | |
| 119 |     PRINT_LATENCY1 ( _L("#### [%S] Latency Measurement Start ####"), &buf );
 | |
| 120 | ||
| 121 | startTime.HomeTime(); | |
| 122 | } | |
| 123 | ||
| 124 | // ---------------------------------------------------------------------------- | |
| 125 | // CCsDebug::UnMark | |
| 126 | // Marks the end time for latency measurement | |
| 127 | // Displays the difference from Latency Mark start | |
| 128 | // ---------------------------------------------------------------------------- | |
| 129 | void CCsDebug::UnMark(TRefByValue<const TDesC> str,...) | |
| 130 | {
 | |
| 131 | endTime.HomeTime(); | |
| 132 | VA_LIST list; | |
| 133 | VA_START(list, str); | |
| 134 | ||
| 135 | // Print to log file | |
| 136 | TBuf<MAX_BUFF_LENGTH> buf; | |
| 137 | buf.FormatList(str, list); | |
| 138 | ||
| 139 | TTimeIntervalMicroSeconds diff = endTime.MicroSecondsFrom(startTime); | |
| 140 | TInt mytime = (diff.Int64()) / TIME_FACTOR; | |
| 141 | ||
| 142 | 	PRINT_LATENCY2 ( _L("#### [%S] Latency Measurement End, Time taken = %d (ms) ####"), &buf, mytime );
 | |
| 143 | } | |
| 144 | ||
| 145 | ||
| 146 | // ---------------------------------------------------------------------------- | |
| 147 | // CCsDebugArr::NewL | |
| 148 | // Two Phase Construction | |
| 149 | // ---------------------------------------------------------------------------- | |
| 150 | EXPORT_C CCsDebugArr* CCsDebugArr::NewL() | |
| 151 | {
 | |
| 152 | CCsDebugArr* self = new (ELeave) CCsDebugArr(); | |
| 153 | return self; | |
| 154 | } | |
| 155 | ||
| 156 | // ---------------------------------------------------------------------------- | |
| 157 | // CCsDebugArr::Push | |
| 158 | // Push an element into the array | |
| 159 | // ---------------------------------------------------------------------------- | |
| 160 | EXPORT_C void CCsDebugArr::Push(CCsDebug& dbg) | |
| 161 | {
 | |
| 162 | debugArray.Append(&dbg); | |
| 163 | } | |
| 164 | ||
| 165 | // ---------------------------------------------------------------------------- | |
| 166 | // CCsDebugArr::Pop | |
| 167 | // Pop an element from the array | |
| 168 | // ---------------------------------------------------------------------------- | |
| 169 | EXPORT_C CCsDebug* CCsDebugArr::Pop() | |
| 170 | {
 | |
| 171 | TInt index = debugArray.Count() - 1; | |
| 172 | CCsDebug* dbg = debugArray[index]; | |
| 173 | debugArray.Remove(index); | |
| 174 | return (dbg); | |
| 175 | } | |
| 176 | ||
| 177 | // ---------------------------------------------------------------------------- | |
| 178 | // CCsDebugArr::IsEmpty | |
| 179 | // Check if array is empty | |
| 180 | // ---------------------------------------------------------------------------- | |
| 181 | EXPORT_C TBool CCsDebugArr::IsEmpty() | |
| 182 | {
 | |
| 183 | if ( debugArray.Count() == 0 ) | |
| 184 | return ETrue; | |
| 185 | else | |
| 186 | return EFalse; | |
| 187 | } | |
| 188 | ||
| 189 | // ---------------------------------------------------------------------------- | |
| 190 | // CCsDebugArr::~CCsDebugArr | |
| 191 | // Destructor | |
| 192 | // ---------------------------------------------------------------------------- | |
| 193 | CCsDebugArr::~CCsDebugArr() | |
| 194 | {
 | |
| 195 | debugArray.ResetAndDestroy(); | |
| 196 | } | |
| 197 | ||
| 198 | // End of file |