sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Trace API sl@0: // @internalTechnology sl@0: // @prototype sl@0: // sl@0: sl@0: #ifndef TRACEUTILS_H_ sl@0: #define TRACEUTILS_H_ sl@0: #include sl@0: sl@0: namespace UTF sl@0: { sl@0: sl@0: /** sl@0: Maximum length of a formatted string sl@0: */ sl@0: const static TInt KMaxPrintfSize = 256; sl@0: sl@0: /** sl@0: Dummy class to toss away overflow sl@0: @internalComponent sl@0: */ sl@0: #ifndef __KERNEL_MODE__ sl@0: class TTruncateOverflow16 : public TDes16Overflow sl@0: { sl@0: public: sl@0: virtual void Overflow(TDes&) {}; sl@0: }; sl@0: sl@0: /** sl@0: Dummy class to toss away overflow sl@0: @internalComponent sl@0: */ sl@0: class TTruncateOverflow8 : public TDes8Overflow sl@0: { sl@0: public: sl@0: virtual void Overflow(TDes8&) {}; sl@0: }; sl@0: #endif //__KERNEL_MODE__ sl@0: sl@0: sl@0: /**@internalComponent*/ sl@0: #define UTRACE_HEADER(aSize,aClassification,aContext,aPc) \ sl@0: ((((aSize) + (aContext?4:0) + (aPc?4:0)) << BTrace::ESizeIndex*8) \ sl@0: +(((aContext?BTrace::EContextIdPresent:0) | (aPc?BTrace::EPcPresent:0)) << BTrace::EFlagsIndex*8) \ sl@0: +((aClassification) << BTrace::ECategoryIndex*8) \ sl@0: +((0) << BTrace::ESubCategoryIndex*8)) sl@0: sl@0: sl@0: /**@internalComponent*/ sl@0: #define UTRACE_SECONDARY_0(aClassification,aModuleUid,aThreadIdPresent,aPcPresent,aPc,aFormatId) \ sl@0: BTrace::OutFilteredPcFormatBig(UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,0,0) sl@0: sl@0: /** @internalComponent */ sl@0: #define UTRACE_SECONDARY_1(aClassification,aModuleUid,aThreadIdPresent,aPcPresent,aPc,aFormatId, aData1) \ sl@0: BTrace::OutFilteredPcFormatBig(UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,&aData1,4) sl@0: sl@0: /** sl@0: * @internalComponent sl@0: * @prototype sl@0: */ sl@0: #define UTRACE_SECONDARY_ANY(aClassification, aModuleUid, aThreadIdPresent, aPcPresent, aPc, aFormatId, aData, aDataSize) \ sl@0: BTrace::OutFilteredPcFormatBig(UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,aData,(TInt)(aDataSize)) sl@0: sl@0: sl@0: #ifdef __MARM_ARMV5__ sl@0: //armv5 sl@0: #define GET_PC(pc) \ sl@0: TUint32 pc = 0; \ sl@0: asm("mov pc, __return_address()") sl@0: #elif __MARM_ARM4__ sl@0: //arm4 not implemented yet! sl@0: #define GET_PC(pc) \ sl@0: TUint32 pc = 0; sl@0: #elif __WINS__ sl@0: //wins sl@0: #define GET_PC(pc) \ sl@0: TUint32 pc = 0; \ sl@0: _asm push edx \ sl@0: _asm mov edx, [ebp+4] \ sl@0: _asm mov [pc], edx \ sl@0: _asm pop edx sl@0: //This is instead of doing "asm(mov pc, ebp+4)" as that gives warnings about registers being spilled. sl@0: #elif __X86__ sl@0: //x86 not implemented yet! sl@0: #define GET_PC(pc) \ sl@0: TUint32 pc = 0; sl@0: /* asm("push edx"); \ sl@0: asm("mov %0, [edx+4]": "=r" (pc)); \ sl@0: asm("pop edx") */ sl@0: #else sl@0: //other platforms sl@0: #define GET_PC(pc) \ sl@0: TUint32 pc = 0; sl@0: #endif sl@0: sl@0: }//namespace UTF sl@0: #endif /*TRACEUTILS_H_*/