os/kernelhwsrv/kernel/eka/debug/utrace/inc/traceutils.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2007-2009 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 the License "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 // Trace API
    15 // @internalTechnology
    16 // @prototype
    17 //
    18 
    19 #ifndef TRACEUTILS_H_
    20 #define TRACEUTILS_H_
    21 #include <e32btrace.h>
    22 
    23 namespace UTF
    24 {
    25 
    26 /**
    27 Maximum length of a formatted string
    28 */
    29 const static TInt KMaxPrintfSize = 256;
    30 
    31 /**
    32 Dummy class to toss away overflow
    33 @internalComponent
    34 */
    35 #ifndef __KERNEL_MODE__
    36 class TTruncateOverflow16 : public TDes16Overflow
    37 	{
    38 	public:
    39 	virtual void Overflow(TDes&) {};
    40 	};
    41 
    42 /**
    43 Dummy class to toss away overflow
    44 @internalComponent
    45 */
    46 class TTruncateOverflow8 : public TDes8Overflow
    47 	{
    48 	public:
    49 	virtual void Overflow(TDes8&) {};
    50 	};
    51 #endif  //__KERNEL_MODE__
    52 
    53 
    54 /**@internalComponent*/
    55 #define UTRACE_HEADER(aSize,aClassification,aContext,aPc)																\
    56 	((((aSize) + (aContext?4:0) + (aPc?4:0)) << BTrace::ESizeIndex*8)										\
    57 	+(((aContext?BTrace::EContextIdPresent:0) | (aPc?BTrace::EPcPresent:0)) << BTrace::EFlagsIndex*8)			\
    58 	+((aClassification) << BTrace::ECategoryIndex*8)																				\
    59 	+((0) << BTrace::ESubCategoryIndex*8))
    60 
    61 
    62 /**@internalComponent*/
    63 #define UTRACE_SECONDARY_0(aClassification,aModuleUid,aThreadIdPresent,aPcPresent,aPc,aFormatId)	\
    64 	BTrace::OutFilteredPcFormatBig(UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,0,0)
    65 
    66 /** @internalComponent */
    67 #define UTRACE_SECONDARY_1(aClassification,aModuleUid,aThreadIdPresent,aPcPresent,aPc,aFormatId, aData1) \
    68 	BTrace::OutFilteredPcFormatBig(UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,&aData1,4)
    69 
    70 /**
    71  * @internalComponent
    72  * @prototype
    73  */
    74 #define UTRACE_SECONDARY_ANY(aClassification, aModuleUid, aThreadIdPresent, aPcPresent, aPc, aFormatId, aData, aDataSize) \
    75 	BTrace::OutFilteredPcFormatBig(UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,aData,(TInt)(aDataSize))
    76 
    77 
    78 #ifdef __MARM_ARMV5__
    79 	//armv5
    80 #define GET_PC(pc) \
    81 	TUint32 pc = 0; \
    82 	asm("mov pc, __return_address()")
    83 #elif __MARM_ARM4__
    84 	//arm4 not implemented yet!
    85 #define GET_PC(pc) \
    86 	TUint32 pc = 0;
    87 #elif __WINS__
    88 	//wins
    89 #define GET_PC(pc) \
    90 	TUint32 pc = 0; \
    91 	_asm push edx \
    92 	_asm mov edx, [ebp+4] \
    93 	_asm mov [pc], edx \
    94 	_asm pop edx
    95 	//This is instead of doing "asm(mov pc, ebp+4)" as that gives warnings about registers being spilled.
    96 #elif __X86__ 
    97 	//x86 not implemented yet!
    98 #define GET_PC(pc) \
    99 	TUint32 pc = 0;
   100 /*	asm("push edx"); \
   101 	asm("mov %0, [edx+4]": "=r" (pc)); \
   102 	asm("pop edx") */
   103 #else
   104 //other platforms
   105 #define GET_PC(pc) \
   106 	TUint32 pc = 0;
   107 #endif
   108 
   109 }//namespace UTF
   110 #endif /*TRACEUTILS_H_*/