dosservices/tsrc/dsytesttool/AccessoryTestControl/inc/Siftrace.h
changeset 0 4e1aa6a622a0
child 41 c87e5f80c17d
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     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:  Declaration and implementation of SIF trace macros
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // Additional Lint configuration options are defined here.
       
    20 //lint -e1714 Member function not referenced.
       
    21 //   - CTFTestTimer, CTFActiveTest, copy constructors, assignment operators
       
    22 //lint -e1526 Member function not defined.
       
    23 //   - Copy constructors, assignment operators
       
    24 //lint -e714  Symbol not referenced
       
    25 //   - uid, LibEntryL
       
    26 //lint -e1711 Class has a virtual function but is not inherited
       
    27 //   - Inherited in the project that implements the test cases
       
    28 //lint -e755  Macro not referenced
       
    29 //   - Some trace macros
       
    30 //lint -e769  Enumeration constant not referenced
       
    31 //   - Panic codes are not referenced in WINS
       
    32 //lint -e1716 Virtual member function not referenced
       
    33 //   - Referenced b the project that implements the test cases
       
    34 //lint -esym(960, 69) Variable number of arguments
       
    35 //   - Log writer functions contain ellipsis
       
    36 //lint -esym(960, 54) Null statement by itself
       
    37 //   - When COMPONENT_TRACE is not enabled
       
    38 //lint -esym(960, 59) Left brace expected for if, else, for, do and while
       
    39 //   - TRACE_ASSERT macro
       
    40 //lint -e1924 C-style case
       
    41 //   - From _L macros
       
    42 //lint -e666 Expression with side effects
       
    43 //   - From TEST_CASE_TRACE
       
    44 
       
    45 #ifndef SIFTRACE_H
       
    46 #define SIFTRACE_H
       
    47 
       
    48 // INCLUDES
       
    49 #include <e32svr.h>
       
    50 
       
    51 // PC-LINT OPTIONS
       
    52 // Removes null statement not in line by itself warnings from 
       
    53 // COMPONENT_TRACE macros
       
    54 //lint -esym(960,54)
       
    55 
       
    56 // Removes "area too small" pointer cast warnings.
       
    57 //lint -e826
       
    58 
       
    59 // Member function not referenced (copy constructors / assignment operators)
       
    60 //lint -e1714
       
    61 
       
    62 // Member function not defined (copy constructors / assignment operators)
       
    63 //lint -e1526
       
    64 
       
    65 // Global macro not referenced
       
    66 //lint -e755
       
    67 
       
    68 // Symbol not referenced (uid)
       
    69 //lint -e714
       
    70 
       
    71 // Global enumeration constant not referenced
       
    72 //lint -e769
       
    73 
       
    74 // Virtual member not referenced
       
    75 //lint -e1716
       
    76 
       
    77 // Expression with side effects passed to macro
       
    78 //lint -e666
       
    79 
       
    80 // Enumeration not referenced
       
    81 //lint -e758
       
    82 
       
    83 // Declaration could be moved from header to module
       
    84 //lint -e759
       
    85 
       
    86 
       
    87 // CONSTANTS
       
    88 // MACROS
       
    89 #ifdef _DEBUG
       
    90 
       
    91     inline void TraceAssertFunc( const TDesC8& aFile, TInt aLine )
       
    92         {
       
    93         HBufC* buffer = HBufC::New( aFile.Length() + 1 );
       
    94         HBufC* date = HBufC::New( 32 );
       
    95         HBufC* time = HBufC::New( 32 );
       
    96         if ( buffer != NULL && date != NULL && time != NULL )
       
    97             {
       
    98             buffer->Des().Copy( aFile );
       
    99             date->Des().Copy( _L8( __DATE__ ) );
       
   100             time->Des().Copy( _L8( __TIME__ ) );
       
   101             RDebug::Print( _L( "Assertion failed: file=%s, line=%d, compiled=%s %s" ), buffer->Des().PtrZ(), aLine, date->Des().PtrZ(), time->Des().PtrZ() );
       
   102             }
       
   103         else
       
   104             {
       
   105             RDebug::Print( _L( "Assertion and memory allocation failed" ) );
       
   106             }
       
   107         delete buffer;
       
   108         delete date;
       
   109         delete time;
       
   110         }
       
   111 
       
   112     inline void ThisFileFunc( const TDesC8& aFile )
       
   113         {
       
   114         HBufC* buffer = HBufC::New( aFile.Length() + 1 );
       
   115         HBufC* date = HBufC::New( 32 );
       
   116         HBufC* time = HBufC::New( 32 );
       
   117         if ( buffer != NULL && date != NULL && time != NULL )
       
   118             {
       
   119             buffer->Des().Copy( aFile );
       
   120             date->Des().Copy( _L8( __DATE__ ) );
       
   121             time->Des().Copy( _L8( __TIME__ ) );
       
   122             RDebug::Print( _L( "File=%s, compiled=%s %s" ), buffer->Des().PtrZ(), date->Des().PtrZ(), time->Des().PtrZ() );
       
   123             }
       
   124         delete buffer;
       
   125         delete date;
       
   126         delete time;
       
   127         }
       
   128 
       
   129 
       
   130 //
       
   131 	// -----------------------------------------------------------------------------
       
   132 	// TracePanicFunc
       
   133 	// This method is needed to utilize debugging macros defined in dostrace.h.
       
   134 	// -----------------------------------------------------------------------------
       
   135 	//
       
   136 	inline void TracePanicFunc( const TDesC8& aFile, TInt aLine )
       
   137 	    {
       
   138 	    HBufC* buffer = HBufC::New( aFile.Length() + 1 );
       
   139 	    HBufC* date = HBufC::New( 32 );
       
   140 	    HBufC* time = HBufC::New( 32 );
       
   141 	    if ( buffer != NULL && date != NULL && time != NULL )
       
   142 	        {
       
   143 	        buffer->Des().Copy( aFile );
       
   144 	        date->Des().Copy( _L8( __DATE__ ) );
       
   145 	        time->Des().Copy( _L8( __TIME__ ) );
       
   146 	        RDebug::Print( _L( "Panic happened: file=%s, line=%d, compiled=%s %s" ), buffer->Des().PtrZ(), aLine, date->Des().PtrZ(), time->Des().PtrZ() );
       
   147 	        }
       
   148 	    else
       
   149 	        {
       
   150 	        RDebug::Print( _L( "Assertion and memory allocation failed" ) );
       
   151 	        }
       
   152 	    delete buffer;
       
   153 	    delete date;
       
   154 	    delete time;
       
   155 	    
       
   156 	    User::Panic( _L( "[AccFW:AccServer]" ), KErrGeneral );
       
   157 	    }
       
   158     
       
   159     #define PANIC_IF_FALSE( a ) if ( !( a ) ) TracePanicFunc( _L8( __FILE__ ), __LINE__ )
       
   160     #define PANIC_IF_TRUE( a ) if ( ( a ) ) TracePanicFunc( _L8( __FILE__ ), __LINE__ )
       
   161     #define PANIC_ALWAYS() TracePanicFunc( _L8( __FILE__ ), __LINE__ )
       
   162     
       
   163     #ifdef COMPONENT_TRACE_FLAG
       
   164 
       
   165         #define COMPONENT_TRACE_THIS_FILE ThisFileFunc( _L8( __FILE__ ) )
       
   166 
       
   167     #else //#ifdef COMPONENT_TRACE_FLAG
       
   168 
       
   169         #define COMPONENT_TRACE_THIS_FILE
       
   170 
       
   171     #endif //#ifdef COMPONENT_TRACE_FLAG
       
   172 
       
   173     #define TRACE_ASSERT( a ) if ( !( a ) ) TraceAssertFunc( _L8( __FILE__ ), __LINE__ )
       
   174     #define TRACE_ASSERT_RETURN( a ) if ( !( ( a ) == KErrNone ) ) TraceAssertFunc( _L8( __FILE__ ), __LINE__ )
       
   175     #define TRACE_ASSERT_ALWAYS TraceAssertFunc( _L8( __FILE__ ), __LINE__ )
       
   176 
       
   177     #ifdef COMPONENT_TRACE_FLAG
       
   178 
       
   179         #define COMPONENT_TRACE( a ) RDebug::Print a 
       
   180 
       
   181     #else // #ifdef COMPONENT_TRACE_FLAG
       
   182 
       
   183         #define COMPONENT_TRACE( a )
       
   184 
       
   185     #endif //#ifdef COMPONENT_TRACE_FLAG
       
   186 
       
   187 	#ifdef TEST_CASE_TRACE_FLAG
       
   188 
       
   189 		#define TEST_CASE_TRACE( a ) RDebug::Print a 
       
   190 	
       
   191 	#else
       
   192 	
       
   193 		#define TEST_CASE_TRACE( a )
       
   194 		
       
   195 	#endif //#ifdef TEST_CASE_TRACE_FLAG
       
   196 
       
   197     #ifdef API_TRACE_FLAG
       
   198 
       
   199         #define API_TRACE( a ) RDebug::Print a
       
   200 
       
   201     #else //#ifdef API_TRACE_FLAG
       
   202 
       
   203         #define API_TRACE( a )
       
   204 
       
   205     #endif //#ifdef API_TRACE_FLAG
       
   206 
       
   207 #else // #ifdef _DEBUG
       
   208 
       
   209     #define TRACE_ASSERT( a )
       
   210     #define TRACE_ASSERT_RETURN( a ) a
       
   211     #define TRACE_ASSERT_ALWAYS
       
   212 	#define TEST_CASE_TRACE( a )
       
   213     #define COMPONENT_TRACE( a )
       
   214     #define API_TRACE( a )
       
   215     #define COMPONENT_TRACE_THIS_FILE
       
   216 
       
   217 #endif //#ifdef _DEBUG
       
   218 
       
   219 
       
   220 
       
   221 // DATA TYPES
       
   222 // FUNCTION PROTOTYPES
       
   223 // FORWARD DECLARATIONS
       
   224 
       
   225 #endif //#ifndef ccftrace.h
       
   226 
       
   227 //  End of File