usbclasses/usbphoneasmodem/classimplementation/inc/debug.h
changeset 89 3592750162a5
parent 0 1e05558e2206
equal deleted inserted replaced
87:18fe5224f0dc 89:3592750162a5
    37 _LIT8(KPanicPrefix8, "PANIC code ");
    37 _LIT8(KPanicPrefix8, "PANIC code ");
    38 _LIT8(KLeavePrefix8, "LEAVE code ");
    38 _LIT8(KLeavePrefix8, "LEAVE code ");
    39 
    39 
    40 #ifdef _DEBUG
    40 #ifdef _DEBUG
    41 
    41 
    42 const TInt KMaxLogLineLength = 512;
    42 const TInt KMaxLogLineLength = 508;  // 512-4, 4 is taken by TBuf structure, 
       
    43 // otherwise exceeds maximum single use of 1024 bytes for stack in TBuf16 config
    43 
    44 
    44 // Trace options
    45 // Trace options
    45 #define KPRINTERROR		0x00000001 // Print error
    46 #define KPRINTERROR		0x00000001 // Print error
    46 #define KPRINTINFO	    0x00000002 // Print function trace
    47 #define KPRINTINFO	    0x00000002 // Print function trace
    47 #define KPRINTSTATE		0x00000004 // Print state machine infos
    48 #define KPRINTSTATE		0x00000004 // Print state machine infos
   111 	buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName);
   112 	buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName);
   112 	Trace(buf);
   113 	Trace(buf);
   113 	User::Panic(aPanicCategory, aPanicCode); 
   114 	User::Panic(aPanicCategory, aPanicCode); 
   114     }
   115     }
   115 
   116 
   116 inline void TraceLeave(char* aFile, TInt aLine, TInt aReason)
   117 inline void TraceLeaveL(char* aFile, TInt aLine, TInt aReason)
   117 	{
   118 	{
   118 	TPtrC8 fullFileName((const TUint8*)aFile);
   119 	TPtrC8 fullFileName((const TUint8*)aFile);
   119 	TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
   120 	TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1);
   120 	TBuf8<KMaxLogLineLength> buf;
   121 	TBuf8<KMaxLogLineLength> buf;
   121 	buf.Append(KLeavePrefix8);
   122 	buf.Append(KLeavePrefix8);
   136 
   137 
   137 #define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);}
   138 #define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);}
   138 
   139 
   139 #define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory)
   140 #define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory)
   140 
   141 
   141 #define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeave(__FILE__, __LINE__, REASON);}
   142 #define LEAVE_IF_ERROR(REASON) {if (REASON) TraceLeaveL(__FILE__, __LINE__, REASON);}
   142 
   143 
   143 #define LEAVE(REASON) TraceLeave(__FILE__, __LINE__, REASON)
   144 #define LEAVE(REASON) TraceLeaveL(__FILE__, __LINE__, REASON)
   144 
   145 
   145 #define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}}
   146 #define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryFormat8, &ptr8);}}
   146 
   147 
   147 #define TRACE_FUNC_ENTRY_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}}
   148 #define TRACE_FUNC_ENTRY_THIS {if(KTraceMask & KPRINTINFO) { TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); Trace(KFuncEntryThisFormat8, &ptr8, this);}}
   148 
   149