analyzetool/dynamicmemoryhook/src/analyzetoolmainallocator.cpp
branchRCL_3
changeset 49 7fdc9a71d314
parent 19 da2cedce4920
child 59 8ad140f3dd41
--- a/analyzetool/dynamicmemoryhook/src/analyzetoolmainallocator.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/src/analyzetoolmainallocator.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -22,7 +22,12 @@
 #include "analyzetoolmemoryallocator.h"
 #include "analyzetoolpanics.pan"
 #include "analyzetoolfastlog.h"
+#include "analyzetoolfilelog.h"
 #include <e32svr.h>
+#ifndef __WINSCW__ 
+#include <e32rom.h>
+#endif
+#include <sysutil.h>
 
 
 // CONSTANTS
@@ -30,15 +35,19 @@
 // The name of the memoryhook dll
 _LIT8( KMemoryHook, "AToolMemoryHook.dll" );
 
-// The name of the storage server dll
-_LIT8( KStorageServer, "AToolStorageServerClnt.dll" );
-
 // Length of the callstack address
 const TUint32 KAddressLength = 4;
 
 // Thread count
 const TInt KThreadCount = 1;
 
+// separator that replaces \n character in sw version
+_LIT( KSeparator, "@" );
+// new line character
+_LIT( KNewLine16, "\n" );
+_LIT( KSpace16, " " );
+
+
 // -----------------------------------------------------------------------------
 // RAnalyzeToolMainAllocator::RAnalyzeToolMainAllocator()
 // C++ default constructor can NOT contain any code, that
@@ -46,8 +55,9 @@
 // -----------------------------------------------------------------------------
 //
 RAnalyzeToolMainAllocator::RAnalyzeToolMainAllocator( TBool aNotFirst, 
-    const TFileName aFileName, TUint32 aLogOption, TUint32 aIsDebug,
-    TUint32 aAllocCallStackSize, TUint32 aFreeCallStackSize ) :
+    const TFileName& aFileName, const TPath& aFilePath, TUint32 aLogOption, TUint32 aIsDebug,
+    TUint32 aAllocCallStackSize, TUint32 aFreeCallStackSize,
+    const TDesC8& aAtoolVersion, const TDesC8& aApiVersion ) :
     RAnalyzeToolMemoryAllocator( aNotFirst ),
     iAnalyzeToolOpen( EFalse ),
     iDeviceDriverLoaded( EFalse ),
@@ -62,32 +72,7 @@
 
     // Basic error variable used in method.
     TInt error( KErrNone );
-    
-    // Connect to the storage server if logging mode not fast trace.
-    if ( iLogOption != EATLogToTraceFast )
-        {
-        error = iStorageServer.Connect();
-
-        LOGSTR2( "ATMH Opening RATStorageServer error %i", error );
-    
-        if ( KErrNone == error )
-            {
-            iStorageServerOpen = ETrue;
-            }
-        else
-            {
-            iStorageServerOpen = EFalse;
-            }
-    
-        if ( KErrNone == error )
-            {
-            // Make the storage server handle shared between threads
-            error = iStorageServer.ShareAuto();
-            }
-    
-        LOGSTR2( "ATMH Sharing RATStorageServer error %i", error );
-        }
-    
+        
     // Create mutex for schedule access to shared resources
     error = iMutex.CreateLocal();
 
@@ -135,16 +120,19 @@
         }
     
     // Retrieve the initial process information
-    LogProcessInformation( aFileName, aLogOption, aIsDebug );
+    LogProcessInformation( aFileName, aFilePath, aLogOption, aIsDebug, aAtoolVersion, aApiVersion );
+
+    // log version of ATApp, ATApi, S60 version and ROM checksum
+    LogDeviceInfo();
 
     // Create handler for receiving kernel events
     iEventHandler = new CLibraryEventHandler( iAnalyzeTool,
                                               iCodeblocks,
-                                              iStorageServer,
                                               iProcessId,
                                               iMutex, 
                                               *this,
-                                              aLogOption);
+                                              aLogOption,
+                                              iLogFile );
 
     __ASSERT_ALWAYS( iEventHandler != NULL, AssertPanic( ENoMemory ) );
     }
@@ -197,28 +185,33 @@
             LOGSTR2( "ATMH Unloading ldd error: %i", error );
             }
         }
-    
+    for( TInt i=0; i<iThreadArray.Count(); i++)
+    	{
+        // log thread removed
+		if ( iLogOption == EATLogToTraceFast )
+			{
+			ATFastLogThreadEnded( RProcess().Id().operator TUint(), RThread().Id().operator TUint() ); 
+			}
+		else if ( iLogOption == EATLogToFile )
+			{
+		    iLogFile.ATFileLogThreadEnded( RThread().Id().operator TUint() );		
+			}
+    	}
+
     // Close the thread array
     iThreadArray.Close();
 
-    if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
+    if ( iLogOption == EATLogToTraceFast )
         {
-        if ( iLogOption == EATLogToTraceFast )
-            {
-            LOGSTR1( "ATMH ATFastLogProcessEnded()" );
-            ATFastLogProcessEnded( iProcessId, handleLeakCount );
-            }
-        else
-            {
-            iStorageServerOpen = EFalse;
-            // Inform that process has ended and close the handle
-            LOGSTR1( "ATMH iStorageServer.LogProcessEnded()" );
-            iStorageServer.LogProcessEnded( iProcessId, handleLeakCount );
-            // Close the handle
-            iStorageServer.Close();
-            }
+        LOGSTR1( "ATMH ATFastLogProcessEnded()" );
+        ATFastLogProcessEnded( iProcessId, handleLeakCount );
         }
+    else if ( iLogOption == EATLogToFile )
+    	{
+        iLogFile.ATFileLogProcessEnded( handleLeakCount );
+    	}
     
+
     // Close the mutex
     iMutex.Close();
     }
@@ -287,6 +280,9 @@
 
     // Acquire the mutex
     iMutex.Wait();
+    
+    // get thread ID
+    TUint threadId = RThread().Id();
 
     // Alloc memory from the original allocator
     TAny* p = iAllocator->Alloc( aSize );
@@ -294,120 +290,86 @@
     LOGSTR3( "ATMH RAnalyzeToolMainAllocator::Alloc() - aSize: %i, address: %x", 
             aSize,  (TUint32) p );
 
-    // Don't collect or log data if storage server not open or logging mode fast.
-    if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
-        {
-        TInt error( KErrNone );
-        
-        // Check if eventhandler is started already
-        if ( !iEventHandler->IsStarted() )
-            {
-            // Install the eventhandler if needed
-            InstallEventHandler();
-            }
-        
-        // Reset the callstack
-        iCallStack.Reset();
+
+	TInt error( KErrNone );
+			
+	// Check if eventhandler is started already
+	if ( !iEventHandler->IsStarted() )
+		{
+		// Install the eventhandler if needed
+		InstallEventHandler();
+		}
+	
+	// Reset the callstack
+	iCallStack.Reset();
 
-        // If we don't want any call stack to be saved skip the next part
-        if( iAllocMaxCallStack > 0 )
-            {
-            // Find the current thread callstack start address
-            TUint32 stackstart( 0 );
-            TBool found( FindCurrentThreadStack( stackstart ) );
-            LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
-            
-            // Returns the value of the stack pointer at the 
-            // current point in your program.
-            TUint32 _sp;
-            __asm
-                {
-                mov [_sp], esp
-                }
-            
-            // Get process loaded code segments count
-            TInt blocksCount( iCodeblocks.Count() );
-            TUint arrayCounter = 0;
-            
-            // Iterate through callstack to find wanted callstack addresses
-            // - Start: current stack address
-            // - Stop: stack start address(Run-address of user stack)
-            // - Add: address length(The word size in the current system is 32 bits, which is 4 bytes)
-            for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
-                {
-                TUint32 addr = (TUint32) *( (TUint32*) i );
-                
-                // Checks is the given address in loaded code memory area.
-                if ( !IsAddressLoadedCode( addr ) )
-                    continue;
-                
-                // Iterate through array of code blocks to check if address is in code segment area 
-                for ( TInt j = 0; j < blocksCount; j++ )
-                    {
-                    // Checks if the given address is in this memory block area
-                    if ( iCodeblocks[j].CheckAddress( addr ) )
-                        {
-                        // To avoid recursive call to ReAlloc specifying granularity
-                        // Add address to the callstack
-                        iCallStack[arrayCounter] = ( addr );
-                        arrayCounter++;
-                        break;
-                        }
-                    }
-                
-                // Checks if the wanted callstack items are gathered
-                if ( arrayCounter == KATMaxCallstackLength ||
-                     arrayCounter == iAllocMaxCallStack )
-                    {
-                    LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
-                    break;
-                    }
-                } 
-            }
+	// If we don't want any call stack to be saved skip the next part
+	if( iAllocMaxCallStack > 0 )
+		{
+		// Find the current thread callstack start address
+		TUint32 stackstart( 0 );
+		TBool found( FindCurrentThreadStack( stackstart ) );
+		LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
+					
+		// Returns the value of the stack pointer at the 
+		// current point in your program.
+		TUint32 _sp;
+		__asm
+			{
+			mov [_sp], esp
+			}
+		
+		// Get process loaded code segments count
+		TInt blocksCount( iCodeblocks.Count() );
+		TUint arrayCounter = 0;
+		
+		// Iterate through callstack to find wanted callstack addresses
+		// - Start: current stack address
+		// - Stop: stack start address(Run-address of user stack)
+		// - Add: address length(The word size in the current system is 32 bits, which is 4 bytes)
+		for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+			{
+			TUint32 addr = (TUint32) *( (TUint32*) i );
+			
+			// Checks is the given address in loaded code memory area.
+			if ( !IsAddressLoadedCode( addr ) )
+				continue;
+			
+			// Iterate through array of code blocks to check if address is in code segment area 
+			for ( TInt j = 0; j < blocksCount; j++ )
+				{
+				// Checks if the given address is in this memory block area
+				if ( iCodeblocks[j].CheckAddress( addr ) )
+					{
+					// To avoid recursive call to ReAlloc specifying granularity
+					// Add address to the callstack
+					iCallStack[arrayCounter] = ( addr );
+					arrayCounter++;
+					break;
+					}
+				}
+			
+			// Checks if the wanted callstack items are gathered
+			if ( arrayCounter == KATMaxCallstackLength ||
+				 arrayCounter == iAllocMaxCallStack )
+				{
+				LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
+				break;
+				}
+			} 
+		}
 
-        // Log the memory allocation information
-        if ( iLogOption == EATLogToTraceFast )
-            {
-            // Using fast mode.
-            ATFastLogMemoryAllocated( iProcessId, (TUint32) p , iCallStack, aSize );
-            }
-        else
-            {
-            // Using storage server.
-            error = iStorageServer.LogMemoryAllocated( (TUint32) p,
-                                                       iCallStack,
-                                                       aSize );
-            if ( KErrNone != error )
-                {
-                switch ( error )
-                    {
-                    case KErrNoMemory:
-                        {
-                        LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc() - KErrNoMemory case"  );
-                        // Check if eventhandler is active
-                        if ( iEventHandler->IsActive() )
-                            {
-                            // Cancel iEventHandler because not needed anymore
-                            iEventHandler->Cancel();
-                            }
-                        if ( iStorageServerOpen )
-                            {
-                            // Close storage server
-                            iStorageServerOpen = EFalse;
-                            LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc() - close iStorageServer"  );
-                            iStorageServer.Close();
-                            }
-                        break;
-                        }
-                    default:
-                        {
-                        LOGSTR2( "ATMH LogMemoryAllocated error %i", error );
-                        break;
-                        }
-                    }
-                }
-            }
-        }
+	// Log the memory allocation information
+	if ( iLogOption == EATLogToTraceFast )
+		{
+		// Using fast mode.
+		ATFastLogMemoryAllocated( iProcessId, (TUint32) p , iCallStack, aSize, threadId );
+		} 
+	else if ( iLogOption == EATLogToFile )
+		{
+		iLogFile.ATFileLogMemoryAllocated( (TUint32) p , iCallStack, aSize, threadId );
+		}
+	
     // Release the mutex
     iMutex.Signal();
 
@@ -426,6 +388,9 @@
 
     // acquire the mutex
     iMutex.Wait();
+    
+    // get thread ID
+    TUint threadId = RThread().Id();
 
     // Alloc memory from the original allocator
     TAny* p = iAllocator->Alloc( aSize );
@@ -433,113 +398,77 @@
     LOGSTR3( "ATMH RAnalyzeToolMainAllocator::Alloc() - aSize: %i, address: %x", 
             aSize,  (TUint32) p );
 
-    TInt error( KErrNone );
-    
-    if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
-        {
-        // Check if eventhandler is active already
-        // IsActive might return false value if a tested software has created many
-        // threads which install own CActiveScheduler.
-        if ( !iEventHandler->IsStarted() )
-            {
-            // Install the eventhandler if needed
-            InstallEventHandler();
-            }
-        
-        // Reset the callstack
-        iCallStack.Reset();
-        
-        // If we don't want any call stack to be saved skip the next part
-        if( iAllocMaxCallStack > 0 )
-            {
-            // Find the current thread callstack start address
-            TUint32 stackstart( 0 );
-            TBool found( FindCurrentThreadStack( stackstart ) );
-            LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
-            
-            // Get process loaded code segments count
-            TInt blocksCount( iCodeblocks.Count() );            
-            TUint arrayCounter = 0;
-            
-            // Iterate through callstack to find wanted callstack addresses
-            // - Start: current stack address(__current_sp(): Returns the value of the 
-            //      stack pointer at the current point in your program.)
-            // - Stop: stack start address(Run-address of user stack)
-            // - Add: address length(The word size in the current system is 32 bits, which is 4 bytes)
-            for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
-                {
-                TUint32 addr = (TUint32) *( (TUint32*) i );
-                
-                // Checks is the given address in loaded code memory area.
-                if ( !IsAddressLoadedCode( addr ) )
-                    continue;
-                
-                // Iterate through array of code blocks to check if address is in code segment area 
-                for ( TInt j = 0; j < blocksCount; j++ )
-                    {
-                    // Checks if the given address is in this memory block area
-                    if ( iCodeblocks[j].CheckAddress( addr ) )
-                        {
-                        // To avoid recursive call to ReAlloc specifying granularity
-                        // Add address to the callstack
-                        iCallStack[arrayCounter] = ( addr );
-                        arrayCounter++;
-                        break;
-                        }
-                    }
-                
-                // Checks if the wanted callstack items are gathered
-                if ( arrayCounter == KATMaxCallstackLength ||
-                     arrayCounter == iAllocMaxCallStack )
-                    {
-                    LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
-                    break;
-                    }
-                }
-            }
-        // Log the memory allocation information
-        if ( iLogOption == EATLogToTraceFast )
-            {
-            // Using fast mode.
-            ATFastLogMemoryAllocated( iProcessId, (TUint32) p, iCallStack, aSize );
-            }
-        else
-            {
-            // Using storage server.
-            error = iStorageServer.LogMemoryAllocated( (TUint32) p,
-                                                       iCallStack,
-                                                       aSize );
-            if ( KErrNone != error )
-                {
-                switch ( error )
-                    {
-                    case KErrNoMemory:
-                        {
-                        LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc() - KErrNoMemory case"  );
-                        // Check if eventhandler is active
-                        if ( iEventHandler->IsActive() )
-                            {
-                            // Cancel ieventhandler because not needed anymore
-                            iEventHandler->Cancel();
-                            }
-                        if ( iStorageServerOpen )
-                            {
-                            // Close storage server
-                            iStorageServerOpen = EFalse;
-                            LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc() - close iStorageServer"  );
-                            iStorageServer.Close();
-                            }
-                        break;
-                        }
-                    default:
-                        {
-                        LOGSTR2( "ATMH LogMemoryAllocated error %i", error );
-                        break;
-                        }
-                    }
-                }
-            }
-        }
+
+	// Check if eventhandler is active already
+	// IsActive might return false value if a tested software has created many
+	// threads which install own CActiveScheduler.
+	if ( !iEventHandler->IsStarted() )
+		{
+		// Install the eventhandler if needed
+		InstallEventHandler();
+		}
+	
+	// Reset the callstack
+	iCallStack.Reset();
+	
+	// If we don't want any call stack to be saved skip the next part
+	if( iAllocMaxCallStack > 0 )
+		{
+		// Find the current thread callstack start address
+		TUint32 stackstart( 0 );
+		TBool found( FindCurrentThreadStack( stackstart ) );
+		LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
+		
+		// Get process loaded code segments count
+		TInt blocksCount( iCodeblocks.Count() );            
+		TUint arrayCounter = 0;
+		
+		// Iterate through callstack to find wanted callstack addresses
+		// - Start: current stack address(__current_sp(): Returns the value of the 
+		//      stack pointer at the current point in your program.)
+		// - Stop: stack start address(Run-address of user stack)
+		// - Add: address length(The word size in the current system is 32 bits, which is 4 bytes)
+		for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+			{
+			TUint32 addr = (TUint32) *( (TUint32*) i );
+			
+			// Checks is the given address in loaded code memory area.
+			if ( !IsAddressLoadedCode( addr ) )
+				continue;
+			
+			// Iterate through array of code blocks to check if address is in code segment area 
+			for ( TInt j = 0; j < blocksCount; j++ )
+				{
+				// Checks if the given address is in this memory block area
+				if ( iCodeblocks[j].CheckAddress( addr ) )
+					{
+					// To avoid recursive call to ReAlloc specifying granularity
+					// Add address to the callstack
+					iCallStack[arrayCounter] = ( addr );
+					arrayCounter++;
+					break;
+					}
+				}
+			
+			// Checks if the wanted callstack items are gathered
+			if ( arrayCounter == KATMaxCallstackLength ||
+				 arrayCounter == iAllocMaxCallStack )
+				{
+				LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
+				break;
+				}
+			}
+		}
+	// Log the memory allocation information
+	if ( iLogOption == EATLogToTraceFast )
+		{
+		// Using fast mode.
+		ATFastLogMemoryAllocated( iProcessId, (TUint32) p, iCallStack, aSize, threadId );
+		}
+	else if ( iLogOption == EATLogToFile )
+		{
+		iLogFile.ATFileLogMemoryAllocated( (TUint32) p , iCallStack, aSize, threadId );
+		}
     
     // Release the mutex
     iMutex.Signal();
@@ -561,87 +490,81 @@
     // Acquire the mutex
     iMutex.Wait();
     
-    if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
-        {
-        // Reset the callstack
-        iFreeCallStack.Reset();
-        
-        // Check if trace logging mode
-        // Also if we don't want any call stack to be stored skip the next part
-        if ( (iLogOption == EATUseDefault || iLogOption == EATLogToTrace || iLogOption == EATLogToTraceFast )
-                && iFreeMaxCallStack > 0 )
-            {
-            // Find the current thread callstack start address
-            TUint32 stackstart( 0 );
-            TBool found( FindCurrentThreadStack( stackstart ) );
-            LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
-            TUint32 _sp;
-            
-            // Returns the value of the stack pointer at the 
-            // current point in your program.
-            #ifdef __WINS__
-                __asm
-                    {
-                    mov [_sp], esp
-                    }
-            #else
-                _sp = __current_sp();
-            #endif
-            
-            // Get process loaded code segments count
-            TInt blocksCount( iCodeblocks.Count() );
-            TUint arrayCounter = 0;
-            
-            // Iterate through callstack to find wanted callstack addresses
-            // - Start: current stack address
-            // - Stop: stack start address(Run-address of user stack)
-            // - Add: address length(The word size in the current system is 32 bits, which is 4 bytes)            
-            for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
-                {
-                TUint32 addr = (TUint32) *( (TUint32*) i );
-                // Checks is the given address in loaded code memory area.
-                if ( ! IsAddressLoadedCode( addr ) )
-                    continue;
-                
-                // Iterate through array of code blocks to check if address is in code segment area 
-                for ( TInt j = 0; j < blocksCount; j++ )
-                    {
-                    // Checks if the given address is in this memory block area
-                    if ( iCodeblocks[j].CheckAddress( addr ) )
-                        {
-                        // To avoid recursive call to ReAlloc specifying granularity
-                        // Add address to the callstack
-                        iFreeCallStack[arrayCounter] = addr;
-                        arrayCounter++;
-                        break;
-                        }
-                    }
-                // Checks if the wanted callstack items are gathered
-                if ( arrayCounter == KATMaxFreeCallstackLength ||
-                     arrayCounter == iFreeMaxCallStack )
-                    {
-                    break;
-                    }
-                }
-            LOGSTR2( "ATMH > iFreeCallStack count ( %i )", arrayCounter );
-            }
-        // Log the memory free information.
-        if ( iLogOption == EATLogToTraceFast )
-            {
-            // Using fast mode.
-            ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack );
-            }
-        else
-            {
-            // Using storage server.
-            TInt err( iStorageServer.LogMemoryFreed( (TUint32) aPtr, iFreeCallStack ) );
-            if ( err != KErrNone )
-                {
-                LOGSTR2( "ATMH > LogMemoryFreed err( %i )", err );
-                }
-            }
-        }
-    
+    // get thread ID
+    TUint threadId = RThread().Id();
+
+	// Reset the callstack
+	iFreeCallStack.Reset();
+	
+	// Check if trace logging mode
+	// Also if we don't want any call stack to be stored skip the next part
+	if ( iFreeMaxCallStack > 0 )
+		{
+		// Find the current thread callstack start address
+		TUint32 stackstart( 0 );
+		TBool found( FindCurrentThreadStack( stackstart ) );
+		LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
+		TUint32 _sp;
+		
+		// Returns the value of the stack pointer at the 
+		// current point in your program.
+		#ifdef __WINS__
+			__asm
+				{
+				mov [_sp], esp
+				}
+		#else
+			_sp = __current_sp();
+		#endif
+		
+		// Get process loaded code segments count
+		TInt blocksCount( iCodeblocks.Count() );
+		TUint arrayCounter = 0;
+		
+		// Iterate through callstack to find wanted callstack addresses
+		// - Start: current stack address
+		// - Stop: stack start address(Run-address of user stack)
+		// - Add: address length(The word size in the current system is 32 bits, which is 4 bytes)            
+		for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+			{
+			TUint32 addr = (TUint32) *( (TUint32*) i );
+			// Checks is the given address in loaded code memory area.
+			if ( ! IsAddressLoadedCode( addr ) )
+				continue;
+			
+			// Iterate through array of code blocks to check if address is in code segment area 
+			for ( TInt j = 0; j < blocksCount; j++ )
+				{
+				// Checks if the given address is in this memory block area
+				if ( iCodeblocks[j].CheckAddress( addr ) )
+					{
+					// To avoid recursive call to ReAlloc specifying granularity
+					// Add address to the callstack
+					iFreeCallStack[arrayCounter] = addr;
+					arrayCounter++;
+					break;
+					}
+				}
+			// Checks if the wanted callstack items are gathered
+			if ( arrayCounter == KATMaxFreeCallstackLength ||
+				 arrayCounter == iFreeMaxCallStack )
+				{
+				break;
+				}
+			}
+		LOGSTR2( "ATMH > iFreeCallStack count ( %i )", arrayCounter );
+		}
+	// Log the memory free information.
+	if ( iLogOption == EATLogToTraceFast )
+		{
+		// Using fast mode.
+		ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack, threadId );
+		}
+    else if ( iLogOption == EATLogToFile )
+    	{
+        iLogFile.ATFileLogMemoryFreed( (TUint32) aPtr, iFreeCallStack, threadId );
+    	}
+     
     // Free the memory using original allocator
     iAllocator->Free( aPtr );
 
@@ -682,6 +605,15 @@
             LOGSTR2( "ATMH Thread stack size:    %x", params().iStackSize );
             iThreadArray.Append( TThreadStack( RThread().Id(),
                     params().iStackAddress + params().iStackSize ) );
+            if ( iLogOption == EATLogToTraceFast )
+            	{
+                // log thread added
+                ATFastLogThreadStarted( RProcess().Id().operator TUint() , RThread().Id().operator TUint() ); 
+            	}
+            else if ( iLogOption == EATLogToFile )
+            	{
+                iLogFile.ATFileLogThreadStarted( RThread().Id().operator TUint() );
+            	}
             }
         }
 
@@ -718,6 +650,15 @@
             {
             // Remove the thread
             iThreadArray.Remove( i );
+            if ( iLogOption == EATLogToTraceFast )
+            	{
+                // log thread removed
+                ATFastLogThreadEnded( RProcess().Id().operator TUint(), RThread().Id().operator TUint() ); 
+            	}
+            else if ( iLogOption == EATLogToFile )
+            	{
+                iLogFile.ATFileLogThreadEnded( RThread().Id().operator TUint() );
+            	}
             LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Close() - thread removed" );
             break;
             }
@@ -740,6 +681,9 @@
 
     // Acquire the mutex
     iMutex.Wait();
+    
+    // get thread ID
+    TUint threadId = RThread().Id();
 
     // Realloc the memory using original allocator
     TAny* ptr = iAllocator->ReAlloc( aPtr, aSize, aMode );
@@ -752,142 +696,78 @@
         LOGSTR3( "ATMH RAnalyzeToolMainAllocator::ReAlloc() - aSize: %i, aMode: %i", 
                 aSize, aMode );
       
-        // Don't collect or log data if storage server not open or logging mode is not fast.
-        if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
-            {
-            TInt error( KErrNone );
-            TUint arrayCounter = 0;
-            
-            // Reset the callstack
-            iReCallStack.Reset();
-            
-            // If we don't want any call stack to be saved skip the next part
-            if( iAllocMaxCallStack > 0 )
-                {
-                // Find the current thread callstack start address
-                TUint32 stackstart( 0 );
-                TBool found( FindCurrentThreadStack( stackstart ) );
-                LOGSTR3( "ATMH > stackstart: %x , find = %i", stackstart, found );
-    
-                // Returns the value of the stack pointer at the 
-                // current point in your program.
-                TUint32 _sp( 0 );
-                __asm
-                    {
-                    mov [_sp], esp
-                    }
-                
-                // Get process loaded code segments count
-                TInt blocksCount( iCodeblocks.Count() );
-                
-                // Iterate through callstack to find wanted callstack addresses
-                // - Start: current stack address
-                // - Stop: stack start address(Run-address of user stack)
-                // - Add: address length(The word size in the current system is 32 bits, which is 4 bytes)                
-                for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
-                    {
-                    TUint32 addr = (TUint32) *( (TUint32*) i );
-                    // Checks is the given address in loaded code memory area.
-                    if ( ! IsAddressLoadedCode( addr ) )
-                        continue;
-                    
-                    // Iterate through array of code blocks to check if address is in code segment area 
-                    for ( TInt j = 0; j < blocksCount; j++ )
-                        {
-                        // Checks if the given address is in this memory block area
-                        if ( iCodeblocks[j].CheckAddress( addr ) )
-                            {
-                            // To avoid recursive call to ReAlloc specifying granularity
-                            // Add address to the callstack
-                            iReCallStack[arrayCounter] = addr;
-                            arrayCounter++;
-                            break;
-                            }
-                        }
-                    // Checks if the wanted callstack items are gathered
-                    if ( arrayCounter == KATMaxCallstackLength || 
-                         arrayCounter == iAllocMaxCallStack )
-                        {
-                        LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
-                        break;
-                        }
-                    }
-                }
-            
-            // No need to report free if the aPtr was NULL
-            if ( aPtr != NULL )
-                {
-                // Reset the free callstack
-                iFreeCallStack.Reset();
-                
-                // Check that logging mode is trace/trace fast so we use free call stack 
-                // and call stack size bigger than zero
-                if ( ( iLogOption == EATUseDefault || iLogOption == EATLogToTrace || iLogOption == EATLogToTraceFast ) && iFreeMaxCallStack > 0 )
-                    {
-                    for ( TInt i = 0; i < arrayCounter; i++ )
-                        {
-                        if ( i == KATMaxFreeCallstackLength || i == iFreeMaxCallStack )
-                            {
-                            break;
-                            }
-                        iFreeCallStack[i] = iReCallStack[i];
-                        }
-                    }
-                // Try to remove old address from the storage server's
-                // leak array. If found. it's removed from the array because system frees
-                // old address directly in the RHeap in ReAlloc case.
-                if ( iLogOption == EATLogToTraceFast )
-                    {
-                    ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack );
-                    }
-                else
-                    {
-                    iStorageServer.LogMemoryFreed( (TUint32) aPtr, iFreeCallStack );
-                    }
-                }
-            // Log the memory allocation information
-            if ( iLogOption == EATLogToTraceFast )
-                {
-                // Using fast logging mode.
-                ATFastLogMemoryAllocated( iProcessId, (TUint32) ptr, iReCallStack, aSize );
-                }
-            else
-                {
-                // Using storage server.
-                error = iStorageServer.LogMemoryAllocated( (TUint32) ptr,
-                                                           iReCallStack,
-                                                           aSize );
-                if ( KErrNone != error )
-                    {
-                    switch ( error )
-                        {
-                        case KErrNoMemory:
-                            {
-                            LOGSTR1( "ATMH RAnalyzeToolMainAllocator::ReAlloc() - KErrNoMemory case"  );
-                            // Check if eventhandler is active
-                            if ( iEventHandler->IsActive() )
-                                {
-                                // Cancel iEventHandler because not needed anymore
-                                iEventHandler->Cancel();
-                                }
-                            if ( iStorageServerOpen )
-                                {
-                                // Close storage server
-                                iStorageServerOpen = EFalse;
-                                LOGSTR1( "ATMH RAnalyzeToolMainAllocator::ReAlloc() - close iStorageServer"  );
-                                iStorageServer.Close();
-                                }
-                            break;
-                            }
-                        default:
-                            {
-                            LOGSTR2( "ATMH LogMemoryAllocated error %i", error );
-                            break;
-                            }
-                        }
-                    }
-                }
-            }
+
+	TInt error( KErrNone );
+	TUint arrayCounter = 0;
+	
+	// Reset the callstack
+	iReCallStack.Reset();
+	
+	// If we don't want any call stack to be saved skip the next part
+	if( iAllocMaxCallStack > 0 )
+		{
+		// Find the current thread callstack start address
+		TUint32 stackstart( 0 );
+		TBool found( FindCurrentThreadStack( stackstart ) );
+		LOGSTR3( "ATMH > stackstart: %x , find = %i", stackstart, found );
+
+		// Returns the value of the stack pointer at the 
+		// current point in your program.
+		TUint32 _sp( 0 );
+		__asm
+			{
+			mov [_sp], esp
+			}
+		
+		// Get process loaded code segments count
+		TInt blocksCount( iCodeblocks.Count() );
+		
+		// Iterate through callstack to find wanted callstack addresses
+		// - Start: current stack address
+		// - Stop: stack start address(Run-address of user stack)
+		// - Add: address length(The word size in the current system is 32 bits, which is 4 bytes)                
+		for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+			{
+			TUint32 addr = (TUint32) *( (TUint32*) i );
+			// Checks is the given address in loaded code memory area.
+			if ( ! IsAddressLoadedCode( addr ) )
+				continue;
+			
+			// Iterate through array of code blocks to check if address is in code segment area 
+			for ( TInt j = 0; j < blocksCount; j++ )
+				{
+				// Checks if the given address is in this memory block area
+				if ( iCodeblocks[j].CheckAddress( addr ) )
+					{
+					// To avoid recursive call to ReAlloc specifying granularity
+					// Add address to the callstack
+					iReCallStack[arrayCounter] = addr;
+					arrayCounter++;
+					break;
+					}
+				}
+			// Checks if the wanted callstack items are gathered
+			if ( arrayCounter == KATMaxCallstackLength || 
+				 arrayCounter == iAllocMaxCallStack )
+				{
+				LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
+				break;
+				}
+			}
+		}
+	
+	
+	// Log the memory reallocation information
+	if ( iLogOption == EATLogToTraceFast )
+		{
+		// Using fast logging mode.
+		ATFastLogMemoryReallocated( iProcessId, (TUint32) aPtr, (TUint32) ptr, iReCallStack, aSize, threadId );
+		}
+	else if ( iLogOption == EATLogToFile )
+		{
+		iLogFile.ATFileLogMemoryReallocated( (TUint32) aPtr, (TUint32) ptr, iReCallStack, aSize, threadId );
+		}
+       
         }
     
     // Release the mutex
@@ -911,10 +791,12 @@
     // Acquire the mutex
     iMutex.Wait();
 
+    // get thread ID
+    TUint threadId = RThread().Id();
+    
     // Realloc the memory using original allocator
     TAny* ptr = iAllocator->ReAlloc( aPtr, aSize, aMode );
     
-    TInt error( KErrNone );
     TUint arrayCounter = 0;
     
     // NULL addresses are not in a process under test
@@ -925,136 +807,65 @@
         LOGSTR3( "ATMH RAnalyzeToolMainAllocator::ReAlloc() - aSize: %i, aMode: %i", 
                 aSize, aMode );
  
-        // Don't collect or log data if storage server not open or logging mode is not fast.
-        if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
-            {
-            // Reset the callstack
-            iReCallStack.Reset();
-            
-            // If we don't want any call stack to be saved skip the next part
-            if( iAllocMaxCallStack > 0 )
-                {
-                // Find the current thread callstack start address
-                TUint32 stackstart( 0 );
-                TBool found( FindCurrentThreadStack( stackstart ) );
-                LOGSTR3( "ATMH > stackstart: %x , find = %i", stackstart, found );
-                
-                // Get process loaded code segments count
-                TInt blocksCount( iCodeblocks.Count() );
-                
-                // Iterate through callstack to find wanted callstack addresses
-                // - Start: current stack address(__current_sp(): Returns the value of the 
-                //      stack pointer at the current point in your program.)
-                // - Stop: stack start address(Run-address of user stack)
-                // - Add: address length(The word size in the current system is 32 bits, which is 4 bytes)
-                for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
-                    {
-                    TUint32 addr = (TUint32) *( (TUint32*) i );
-                    
-                    // Checks is the given address in loaded code memory area.
-                    if ( !IsAddressLoadedCode( addr ) )
-                        continue;
-                                
-                    // Iterate through array of code blocks to check if address is in code segment area 
-                    for ( TInt j = 0; j < blocksCount; j++ )
-                        {
-                        // Checks if the given address is in this memory block area
-                        if ( iCodeblocks[j].CheckAddress( addr ) )
-                            {
-                            // To avoid recursive call to ReAlloc specifying granularity
-                            // Add address to the callstack
-                            iReCallStack[arrayCounter] = ( addr );
-                            arrayCounter++;
-                            break;
-                            }
-                        }
-                    // Checks if the wanted callstack items are gathered
-                    if ( arrayCounter == KATMaxCallstackLength || 
-                         arrayCounter == iAllocMaxCallStack )
-                        {
-                        LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
-                        break;
-                        }
-                    }
-                }
-            
-            // No need to report free if the aPtr was NULL
-            if ( aPtr != NULL )
-                {
-                // Reset the free callstack
-                iFreeCallStack.Reset();
-                
-                // Check that logging mode is trace/trace fast so we use free call stack 
-                // and call stack size bigger than zero
-                if ( (iLogOption == EATUseDefault || iLogOption == EATLogToTrace || iLogOption == EATLogToTraceFast )
-                        && iFreeMaxCallStack > 0 )
-                    {
-                    for ( TInt i = 0; i < arrayCounter; i++ )
-                        {
-                        if ( i == KATMaxFreeCallstackLength || i == iFreeMaxCallStack )
-                            {
-                            break;
-                            }
-                        iFreeCallStack[i] = ( iReCallStack[i] );
-                        }
-                    }
-                
-                // Try to remove old address from the storage server's
-                // leak array. If found. it's removed from the array because system frees
-                // old address directly in the RHeap in ReAlloc case.
-                if ( iLogOption == EATLogToTraceFast )
-                    {
-                    ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack );
-                    }
-                else
-                    {
-                    iStorageServer.LogMemoryFreed( (TUint32) aPtr, iFreeCallStack );
-                    }
-                }
-            
-            // Log the memory allocation information
-            if ( iLogOption == EATLogToTraceFast )
-                {
-                // Using fast logging mode.
-                ATFastLogMemoryAllocated( iProcessId, (TUint32) ptr, iReCallStack, aSize );
-                }
-            else
-                {
-                // Using storage server.
-                error = iStorageServer.LogMemoryAllocated( (TUint32) ptr,
-                                                        iReCallStack,
-                                                        aSize );
-                if ( KErrNone != error )
-                    {
-                    switch ( error )
-                        {
-                        case KErrNoMemory:
-                            {
-                            LOGSTR1( "ATMH RAnalyzeToolMainAllocator::ReAlloc() - KErrNoMemory case"  );
-                            // Check if eventhandler is active
-                            if ( iEventHandler->IsActive() )
-                                {
-                                // Cancel iEventHandler because not needed anymore
-                                iEventHandler->Cancel();
-                                }
-                            if ( iStorageServerOpen )
-                                {
-                                // Close storage server
-                                iStorageServerOpen = EFalse;
-                                LOGSTR1( "ATMH RAnalyzeToolMainAllocator::ReAlloc() - close iStorageServer"  );
-                                iStorageServer.Close();
-                                }
-                            break;
-                            }
-                        default:
-                            {
-                            LOGSTR2( "ATMH LogMemoryAllocated error %i", error );
-                            break;
-                            }
-                        }
-                    }
-                }
-            }
+		// Reset the callstack
+		iReCallStack.Reset();
+		
+		// If we don't want any call stack to be saved skip the next part
+		if( iAllocMaxCallStack > 0 )
+			{
+			// Find the current thread callstack start address
+			TUint32 stackstart( 0 );
+			TBool found( FindCurrentThreadStack( stackstart ) );
+			LOGSTR3( "ATMH > stackstart: %x , find = %i", stackstart, found );
+			
+			// Get process loaded code segments count
+			TInt blocksCount( iCodeblocks.Count() );
+			
+			// Iterate through callstack to find wanted callstack addresses
+			// - Start: current stack address(__current_sp(): Returns the value of the 
+			//      stack pointer at the current point in your program.)
+			// - Stop: stack start address(Run-address of user stack)
+			// - Add: address length(The word size in the current system is 32 bits, which is 4 bytes)
+			for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+				{
+				TUint32 addr = (TUint32) *( (TUint32*) i );
+				
+				// Checks is the given address in loaded code memory area.
+				if ( !IsAddressLoadedCode( addr ) )
+					continue;
+							
+				// Iterate through array of code blocks to check if address is in code segment area 
+				for ( TInt j = 0; j < blocksCount; j++ )
+					{
+					// Checks if the given address is in this memory block area
+					if ( iCodeblocks[j].CheckAddress( addr ) )
+						{
+						// To avoid recursive call to ReAlloc specifying granularity
+						// Add address to the callstack
+						iReCallStack[arrayCounter] = ( addr );
+						arrayCounter++;
+						break;
+						}
+					}
+				// Checks if the wanted callstack items are gathered
+				if ( arrayCounter == KATMaxCallstackLength || 
+					 arrayCounter == iAllocMaxCallStack )
+					{
+					LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
+					break;
+					}
+				}
+			}
+		
+		if ( iLogOption == EATLogToTraceFast )
+			{
+			// Using fast logging mode.
+			ATFastLogMemoryReallocated( iProcessId, (TUint32) aPtr, (TUint32) ptr, iReCallStack, aSize, threadId );
+			}
+		else if ( iLogOption == EATLogToFile )
+			{
+			iLogFile.ATFileLogMemoryReallocated( (TUint32) aPtr, (TUint32) ptr, iReCallStack, aSize, threadId );
+			} 
         }
 
     // Release the mutex
@@ -1249,6 +1060,15 @@
             {
             // Remove the thread
             iThreadArray.Remove( i );
+            if ( iLogOption == EATLogToTraceFast )
+            	{
+                // log thread removed
+                ATFastLogThreadEnded( RProcess().Id().operator TUint(), aThreadId ); 
+            	}
+            else if ( iLogOption == EATLogToFile )
+				{
+                iLogFile.ATFileLogThreadEnded( aThreadId );
+				}
             LOGSTR1( "ATMH > thread removed" );
             break;
             }
@@ -1285,8 +1105,8 @@
 // Retrieve and log the process initial information
 // -----------------------------------------------------------------------------
 //
-void RAnalyzeToolMainAllocator::LogProcessInformation( const TFileName aFileName,
-    TUint32 aLogOption, TUint32 aIsDebug )
+void RAnalyzeToolMainAllocator::LogProcessInformation( const TFileName& aFileName, const TPath& aFilePath,
+    TUint32 aLogOption, TUint32 aIsDebug, const TDesC8& aAtoolVersion, const TDesC8& aApiVersion )
     {
     LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation()" );
     
@@ -1309,31 +1129,38 @@
         // Append thread to array of the users of this allocator
         error = iThreadArray.Append(
         TThreadStack( RThread().Id(), params().iStackAddress + params().iStackSize) );
+        
 
         __ASSERT_ALWAYS( KErrNone == error, AssertPanic( ECantAppendToTheArray ) );
-
-        // Log process information
-        if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
+        
+        // Using fast logging mode.
+        if ( iLogOption == EATLogToTraceFast )
+            {          
+            LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation() - ATFastLogProcessStarted() #1" );
+            // Log process information
+            ATFastLogProcessStarted( params().iProcessName, iProcessId, aIsDebug, aAtoolVersion, aApiVersion );    
+            // log thread added
+            ATFastLogThreadStarted( iProcessId, RThread().Id().operator TUint() );
+            }
+        else if ( iLogOption == EATLogToFile )
             {
-            if ( iLogOption == EATLogToTraceFast )
-                {
-                // Using fast logging mode.
-                LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation() - ATFastLogProcessStarted() #1" );
-                ATFastLogProcessStarted( params().iProcessName, iProcessId, aIsDebug );                
-                }
-            else
+            // Open a file server session and a file.
+            error = iLogFile.OpenFsAndFile( aFileName, aFilePath, params().iProcessName );
+
+            // Return without logging, if an error occured
+            if ( error != KErrNone )
                 {
-                // Using storage server.
-                LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation() - iStorageServerOpen #1" );
-                error = iStorageServer.LogProcessStarted(
-                        aFileName,
-                        params().iProcessName,
-                        iProcessId, 
-                        aLogOption, 
-                        aIsDebug );
+                // TODO
                 }
+            
+            //if everything is ok, add file version in the begining of file
+            iLogFile.ATFileLogVersion();
+            //log process start
+            iLogFile.ATFileLogProcessStarted( params().iProcessName, iProcessId, aIsDebug, aAtoolVersion, aApiVersion ); 
+            // log thread added
+            iLogFile.ATFileLogThreadStarted( RThread().Id().operator TUint() );
             }
-
+                      
         LOGSTR2( "ATMH LogProcessStarted error %i", error );
 
         // Iterate through process codesegments
@@ -1349,31 +1176,27 @@
             if ( KErrNone == error )
                 {
                 // Don't log AnalyzeTool libraries
-                if ( 0 != codeinfo().iFullName.CompareC( KMemoryHook ) &&
-                     0 != codeinfo().iFullName.CompareC( KStorageServer ) )
+                if ( 0 != codeinfo().iFullName.CompareC( KMemoryHook ) )
                     {
                     // Log the loaded codesegment(s)
-                    if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
+
+                    if ( iLogOption == EATLogToTraceFast )
                         {
-                        if ( iLogOption == EATLogToTraceFast )
-                            {
-                            // Using fast logging mode.
-                            LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation() - ATFastLogDllLoaded() #2" );
-                            ATFastLogDllLoaded( iProcessId,
-                                    codeinfo().iFullName,
-                                    codeinfo().iRunAddress,
-                                    codeinfo().iRunAddress + codeinfo().iSize );
-                            }
-                        else
-                            {
-                            // Using storage server.
-                            LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation() - iStorageServerOpen #2" );
-                            error = iStorageServer.LogDllLoaded(
-                                    codeinfo().iFullName,
-                                    codeinfo().iRunAddress,
-                                    codeinfo().iRunAddress + codeinfo().iSize );
-                            }
+                        // Using fast logging mode.
+                        LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation() - ATFastLogDllLoaded() #2" );
+                        ATFastLogDllLoaded( iProcessId,
+                                codeinfo().iFullName,
+                                codeinfo().iRunAddress,
+                                codeinfo().iRunAddress + codeinfo().iSize );
                         }
+                    else if ( iLogOption == EATLogToFile )
+						{
+                        iLogFile.ATFileLogDllLoaded( 
+								codeinfo().iFullName,
+                                codeinfo().iRunAddress,
+                                codeinfo().iRunAddress + codeinfo().iSize );
+						}
+                    
 
                     LOGSTR2( "ATMH LogDllLoaded error %i", error );
 
@@ -1403,29 +1226,24 @@
             if ( KErrNone == error )
                 {
                 // Log the loaded dynamic codesegment(s)
-                if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
+
+                if ( iLogOption == EATLogToTraceFast )
                     {
-                    if ( iLogOption == EATLogToTraceFast )
-                        {
-                        // Using fast logging mode.
-                        LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation() - - ATFastLogDllLoaded()#3" );
-                        ATFastLogDllLoaded( iProcessId,
-                                info().iLibraryName,
-                                info().iRunAddress,
-                                info().iRunAddress + info().iSize );
-                        }
-                    else
-                        {
-                        // Using storage server.
-                        LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation() - iStorageServerOpen #3" );
-                        error = iStorageServer.LogDllLoaded(
-                                info().iLibraryName,
-                                info().iRunAddress,
-                                info().iRunAddress + info().iSize );
-                        }
+                    // Using fast logging mode.
+                    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation() - - ATFastLogDllLoaded()#3" );
+                    ATFastLogDllLoaded( iProcessId,
+                            info().iLibraryName,
+                            info().iRunAddress,
+                            info().iRunAddress + info().iSize );
                     }
-
-
+                else if ( iLogOption == EATLogToFile )
+                	{
+                	iLogFile.ATFileLogDllLoaded( 
+                			info().iLibraryName,
+                			info().iRunAddress,
+                			info().iRunAddress + info().iSize );
+                	}
+     
                 LOGSTR2( "ATMH LogDllLoaded error %i", error );
 
                 if ( KErrNone == error )
@@ -1441,6 +1259,7 @@
         }
     }
 
+
 // -----------------------------------------------------------------------------
 // RAnalyzeToolMainAllocator::FindCurrentThreadStack()
 // Find the current thread which is using the heap
@@ -1504,6 +1323,59 @@
         {
         iEventHandler->Start();
         }
+      }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::LogDeviceInfo()
+// Logs iversion of ATApp, ATApi, S60 version and ROM checksum 
+// at the startup of hooked application
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolMainAllocator::LogDeviceInfo()
+    {
+    //get s60 version
+    TBuf<KSysUtilVersionTextLength> bufS60;
+    if (SysUtil::GetSWVersion(bufS60) == KErrNone)
+        {
+        TInt index(0);
+        //replace newlines in string with '@'
+        //while ((index = bufS60.Find(KNewLine)) != KSysUtilVersionTextLength && index != KErrNotFound)
+        while ( (index = bufS60.Find(KNewLine16)) != KErrNotFound)
+            {
+            bufS60.Replace(index, 1, KSeparator);
+            }
+        while ( (index = bufS60.Find(KSpace16)) != KErrNotFound)
+			{
+			bufS60.Replace(index, 1, KSeparator);
+			}
+        }
+
+    TBuf<KHexa32Length> bufChecksum;
+    
+#ifndef __WINSCW__
+    TRomHeader* romHeader = (TRomHeader*) UserSvr::RomHeaderAddress();
+    if (romHeader)
+        {
+        bufChecksum.Format(_L("%08x"), romHeader->iCheckSum);
+        }
+#endif
+    
+    TBuf8<KSysUtilVersionTextLength> s60Version;
+    s60Version.Copy(bufS60);
+    
+    TBuf8<KHexa32Length> romChecksum;
+    romChecksum.Copy(bufChecksum);
+    
+    //only fastlog implementation
+    if (iLogOption == EATLogToTraceFast)
+    	{  
+        ATFastLogDeviceInfo(s60Version, romChecksum);
+        }
+    else if ( iLogOption == EATLogToFile )
+    	{
+        iLogFile.ATFileLogDeviceInfo( s60Version, romChecksum );
+    	}
+    
     }
 
 // End of File