diff -r ccab7f1f8266 -r a71a3e32a2ae analyzetool/dynamicmemoryhook/src/analyzetoolfastlog.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/analyzetool/dynamicmemoryhook/src/analyzetoolfastlog.cpp Thu May 13 23:59:27 2010 +0300 @@ -0,0 +1,298 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include // RDebug +#include +#include "analyzetoolfastlog.h" +#include "atlog.h" + +// Local time function. +TInt64 CurrentTime() + { + LOGSTR1( "ATFL CurrentTime()" ); + TTime time; + time.UniversalTime(); + return time.Int64() - KMicroSecondsAt1970; + } + +TInt ATFastLogProcessStarted( const TDesC8& aProcessName, + TUint aProcessId, + TUint32 aIsDebug ) + { + LOGSTR1( "ATFL ATFastLogProcessStarted()" ); + // Convert process name to 16-bit descriptor. + TBuf processName; + processName.Copy( aProcessName ); + // Buffer to trace. + TBuf buffer; + // Format process name and id. + buffer.Format( KProcessStart16, &processName, aProcessId ); + // Timestamp. + buffer.AppendNum( CurrentTime(), EHex ) ; + // Append udeb/urel information to the process start. + buffer.Append( KSpaceTrace ); + buffer.AppendNum( aIsDebug, EHex ); + // Append version number. + buffer.Append( KSpaceTrace ); + buffer.AppendNum( KATTraceVersion, EHex ); + // Log to trace. + RDebug::Print( KTraceMessage, aProcessId ,&buffer ); + return KErrNone; + } + +TInt ATFastLogProcessEnded( TUint aProcessId, + TUint aHandleLeakCount ) + { + LOGSTR1( "ATFL ATFastLogProcessEnded()" ); + // Handle leaks. + if ( aHandleLeakCount > 0 ) + { + // Buffer to trace. + TBuf buffer2; + buffer2.Format( KHandleLeak16, &KUnknownModule16, aHandleLeakCount ); + // Trace it. + RDebug::Print( KTraceMessage, aProcessId, &buffer2 ); + } + // Process end trace. + TBuf buffer; + buffer.Format( KProcessEnd16, aProcessId ); + buffer.AppendNum( CurrentTime(), EHex); + buffer.Append( KNewLineTrace ); + RDebug::Print( KTraceMessage, aProcessId, &buffer ); + return KErrNone; + } + +TInt ATFastLogDllLoaded( TUint aProcessId, + const TDesC8& aDllName, + TUint32 aStartAddress, + TUint32 aEndAddress ) + { + LOGSTR1( "ATFL ATFastLogDllLoaded()" ); + // Timestamp. + TInt64 time = CurrentTime(); + // Convert dll name to 16-bit descriptor. + TBuf dll; + dll.Copy( aDllName ); + // Buffer to trace. + TBuf buffer; + buffer.Format( KDllLoad16, &dll, time, aStartAddress, aEndAddress ); + RDebug::Print( KTraceMessage, aProcessId, &buffer ); + return KErrNone; + } + +TInt ATFastLogDllUnloaded( TUint aProcessId, const TDesC8& aDllName, TUint32 aStartAddress, + TUint32 aEndAddress ) + { + LOGSTR1( "ATFL ATFastLogDllUnloaded()" ); + // Timestamp. + TInt64 time = CurrentTime(); + // Convert dll name to 16-bit descriptor. + TBuf dll; + dll.Copy( aDllName ); + // Buffer to trace. + TBuf buffer; + buffer.Format( KDllUnload16, &dll, time, aStartAddress, aEndAddress ); + RDebug::Print( KTraceMessage, aProcessId, &buffer ); + return KErrNone; + } + +TInt ATFastLogMemoryAllocated( TUint aProcessId, TUint32 aMemAddress, + TFixedArray& aCallstack, + TInt aSize ) + { + LOGSTR1( "ATFL ATFastLogMemoryAllocated()" ); + // ALLOCH