adaptationlayer/modematadaptation/modematcontroller_exe/inc/modemattrace.h
changeset 0 63b37f68c1ce
equal deleted inserted replaced
-1:000000000000 0:63b37f68c1ce
       
     1 /*
       
     2 * Copyright (c) 2009 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 the License "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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef MODEMATTRACE_H
       
    21 #define MODEMATTRACE_H
       
    22 
       
    23 // INCLUDES
       
    24 // CONSTANTS
       
    25 
       
    26 // MACROS
       
    27 // INCLUDES
       
    28 #include <e32svr.h>    // For RDebug
       
    29 #include <e32std.h>
       
    30 
       
    31 _LIT( KATModemPanic, "ATModemSrvPanic" );
       
    32 
       
    33 #define KMaxLogLineLength 512
       
    34 #define _T(a) _L(a)
       
    35 
       
    36 
       
    37 #ifdef _DEBUG
       
    38 
       
    39 NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow
       
    40     {
       
    41 public:
       
    42     void Overflow(TDes16& /*aDes*/) {}
       
    43     };
       
    44 
       
    45 NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow
       
    46     {
       
    47 public:
       
    48     void Overflow(TDes8& /*aDes*/) {}
       
    49     };
       
    50 
       
    51 
       
    52 inline void Trace(TRefByValue<const TDesC16> aFmt, ...)
       
    53     {
       
    54     VA_LIST list;
       
    55     VA_START(list,aFmt);
       
    56     TBuf16<KMaxLogLineLength> theFinalString;
       
    57     TOverflowTruncate16 overflow;
       
    58     theFinalString.AppendFormatList(aFmt,list,&overflow);
       
    59     RDebug::Print(theFinalString);
       
    60     }
       
    61 
       
    62 inline void Trace(TRefByValue<const TDesC8> aFmt, ...)
       
    63     {
       
    64     VA_LIST list;
       
    65     VA_START(list, aFmt);
       
    66     TOverflowTruncate8 overflow;
       
    67     TBuf8<KMaxLogLineLength> buf8;
       
    68     buf8.AppendFormatList(aFmt, list, &overflow);
       
    69     TBuf16<KMaxLogLineLength> buf16(buf8.Length());
       
    70     buf16.Copy(buf8);
       
    71     TRefByValue<const TDesC> tmpFmt(_L("%S"));
       
    72     RDebug::Print(tmpFmt, &buf16);
       
    73     }
       
    74 
       
    75 inline void DumpMessage( const TDesC8& aPtr )
       
    76     {
       
    77     RDebug::Print(_L("Length %d "), aPtr.Length());
       
    78     const TUint8* data = aPtr.Ptr();
       
    79     for( TInt i = 0 ; i < aPtr.Length() ; i++ )
       
    80         {
       
    81         RDebug::Print(_L("[%d] 0x%x '%c'"),i,data[i],data[i]);
       
    82         }
       
    83     }
       
    84 
       
    85 #endif
       
    86 
       
    87 #define PANIC_TRACE( aMsg, aP1, aP2 )\
       
    88     {\
       
    89     RDebug::Printf( aMsg, aP1, aP2 );\
       
    90     } 
       
    91 
       
    92 static void Panic( const TDesC8& aFileName, const TInt aLineNum, TBool aPanic )
       
    93     {
       
    94     PANIC_TRACE( "Assertion failed in file=%S, line=%d", &aFileName, aLineNum );
       
    95     if( aPanic )
       
    96         {
       
    97         TBuf16<KMaxLogLineLength> buf16(aFileName.Length());
       
    98         buf16.Copy(aFileName);
       
    99         User::Panic( buf16, aLineNum );
       
   100         }
       
   101     }
       
   102 
       
   103 #ifdef _DEBUG
       
   104     #define BUILD_TRACE(a) BuildTraceFunc(a)
       
   105     #define C_TRACE(a) __TRACE_PRINTF(a) 
       
   106     #define DUMP_MESSAGE(a) DumpMessage(a)
       
   107 #ifdef __WINS__
       
   108     #define __TRACE_PRINTF(a) RDebug::Print a
       
   109 #else
       
   110     #define __TRACE_PRINTF(a) Trace a
       
   111 #endif
       
   112 #else
       
   113     #define C_TRACE( a )
       
   114     #define BUILD_TRACE( a ) 
       
   115     #define DUMP_MESSAGE(a) 
       
   116     #define __TRACE_PRINTF(a) 
       
   117     #define __ASSERT_FILE__(s) _LIT(KFileName,s)
       
   118 #endif // _DEBUG
       
   119 
       
   120 // Resets are made both in UDEB and UREL (traces only in udeb)
       
   121 #ifdef __WINS__
       
   122     #define ASSERT_PANIC_ALWAYS(a) 
       
   123     #define ASSERT_ALWAYS 
       
   124     #define TRACE_ASSERT_ALWAYS __TRACE_PRINTF( (_L("Assertion failed: file= __FILE__ , line=%d, compiled=__DATE__ __TIME__ "),__LINE__) )
       
   125     #define TRACE_ASSERT_ALWAYS_COND(a)if(!(a)){ __TRACE_PRINTF( (_L("Assertion failed: file= __FILE__ , line=%d, compiled=__DATE__ __TIME__ "),__LINE__) );}
       
   126 #else
       
   127     #define ASSERT_PANIC_ALWAYS(a) if(!(a)){Panic( _L8(__FILE__), __LINE__, ETrue );}
       
   128     #define ASSERT_ALWAYS Panic( _L8(__FILE__), __LINE__, ETrue )
       
   129     #define TRACE_ASSERT_ALWAYS Panic( _L8(__FILE__), __LINE__, EFalse );
       
   130     #define TRACE_ASSERT_ALWAYS_COND(a)if(!(a)) {Panic( _L8(__FILE__), __LINE__, EFalse );}
       
   131 #endif
       
   132 
       
   133 
       
   134 // Trace asserts activated also in UREL
       
   135 // define assertions
       
   136 #ifdef __WINS__
       
   137     #define TRACE_ASSERT(a) if (!(a)) {__TRACE_PRINTF((_L("Assertion failed: file= __FILE__ , line=%d, compiled=__DATE__ __TIME__ "),__LINE__));}
       
   138 #else
       
   139     #define TRACE_ASSERT(a) if (!(a)) {Panic( _L8(__FILE__), __LINE__, EFalse );}
       
   140 #endif  //__WINS__
       
   141 
       
   142 #endif
       
   143 
       
   144 
       
   145 // End of File
       
   146 
       
   147 
       
   148 
       
   149 
       
   150 
       
   151