Revision: 201035 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 15 Sep 2010 13:53:27 +0300
branchRCL_3
changeset 49 7fdc9a71d314
parent 46 e26895079d7c
child 59 8ad140f3dd41
Revision: 201035 Kit: 201036
analyzetool/analyzetool_plat/analyzetool_api/analyzetool_api.metaxml
analyzetool/analyzetool_plat/analyzetool_api/group/bld.inf
analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/analyzetool.h
analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/analyzetool.inl
analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/analyzetoolcleaner.h
analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/analyzetooltraceconstants.h
analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/atcommon.h
analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/customuser.h
analyzetool/analyzetool_plat/group/bld.inf
analyzetool/analyzetoolcleaner/group/analyzetoolcleaner.mmp
analyzetool/analyzetoolcleaner/group/bld.inf
analyzetool/analyzetoolcleaner/inc/analyzetoolcleaner.h
analyzetool/commandlineengine/group/atool.vcproj
analyzetool/commandlineengine/inc/ATCommonDefines.h
analyzetool/commandlineengine/inc/CATBase.h
analyzetool/commandlineengine/inc/CATModule2.h
analyzetool/commandlineengine/inc/CATParseBinaryFile.h
analyzetool/commandlineengine/inc/CATParseTraceFile.h
analyzetool/commandlineengine/inc/CATProcessData.h
analyzetool/commandlineengine/inc/CATProject.h
analyzetool/commandlineengine/inc/catalloc.h
analyzetool/commandlineengine/inc/catallocs.h
analyzetool/commandlineengine/install/atool.exe
analyzetool/commandlineengine/src/CATBase.cpp
analyzetool/commandlineengine/src/CATDatParser.cpp
analyzetool/commandlineengine/src/CATModule2.cpp
analyzetool/commandlineengine/src/CATParseBinaryFile.cpp
analyzetool/commandlineengine/src/CATParseTraceFile.cpp
analyzetool/commandlineengine/src/CATProject.cpp
analyzetool/commandlineengine/src/arguments.cpp
analyzetool/commandlineengine/src/atool.cpp
analyzetool/commandlineengine/src/catallocs.cpp
analyzetool/commandlineengine/src/helps.cpp
analyzetool/dynamicmemoryhook/bwins/atoolmemoryhooku.def
analyzetool/dynamicmemoryhook/eabi/atoolmemoryhooku.def
analyzetool/dynamicmemoryhook/group/atoolmemoryhook.mmp
analyzetool/dynamicmemoryhook/inc/analyzetoolallocator.h
analyzetool/dynamicmemoryhook/inc/analyzetooleventhandler.h
analyzetool/dynamicmemoryhook/inc/analyzetoolfastlog.h
analyzetool/dynamicmemoryhook/inc/analyzetoolfilelog.h
analyzetool/dynamicmemoryhook/inc/analyzetoolmainallocator.h
analyzetool/dynamicmemoryhook/inc/analyzetoolmainallocator.inl
analyzetool/dynamicmemoryhook/inc/analyzetoolpanics.pan
analyzetool/dynamicmemoryhook/inc/atdriveinfo.h
analyzetool/dynamicmemoryhook/inc/customuser.h
analyzetool/dynamicmemoryhook/src/analyzetoolallocator.cpp
analyzetool/dynamicmemoryhook/src/analyzetooleventhandler.cpp
analyzetool/dynamicmemoryhook/src/analyzetoolfastlog.cpp
analyzetool/dynamicmemoryhook/src/analyzetoolfilelog.cpp
analyzetool/dynamicmemoryhook/src/analyzetoolmainallocator.cpp
analyzetool/dynamicmemoryhook/src/analyzetoolmemoryallocator.cpp
analyzetool/dynamicmemoryhook/src/atdriveinfo.cpp
analyzetool/dynamicmemoryhook/src/customuser.cpp
analyzetool/group/ReleaseNotes_AnalyzeTool.txt
analyzetool/group/bld.inf
analyzetool/kerneleventhandler/group/bld.inf
analyzetool/kerneleventhandler/inc/analyzetool.h
analyzetool/kerneleventhandler/inc/analyzetool.inl
analyzetool/kerneleventhandler/inc/analyzetooltraceconstants.h
analyzetool/kerneleventhandler/inc/atcommon.h
analyzetool/rom/analyzetool_rom.iby
analyzetool/sis/AnalyzeTool.pkg
analyzetool/sis/AnalyzeTool_udeb.pkg
analyzetool/sis/analyzeTool_stub.pkg
analyzetool/staticlib/group/bld.inf
analyzetool/staticlib/src/atoolstaticlib.cpp
analyzetool/storageserver/client/bwins/atoolstorageserverclntu.def
analyzetool/storageserver/client/eabi/atoolstorageserverclntu.def
analyzetool/storageserver/client/group/atoolstorageserverclnt.mmp
analyzetool/storageserver/client/inc/atstorageserverclnt.h
analyzetool/storageserver/client/src/atstorageserverclnt.cpp
analyzetool/storageserver/group/bld.inf
analyzetool/storageserver/inc/atstorageservercommon.h
analyzetool/storageserver/server/group/atoolstorageserver.mmp
analyzetool/storageserver/server/inc/atdllinfo.h
analyzetool/storageserver/server/inc/atdriveinfo.h
analyzetool/storageserver/server/inc/atdynprocessinfo.h
analyzetool/storageserver/server/inc/atmemoryentry.h
analyzetool/storageserver/server/inc/atstorageserver.h
analyzetool/storageserver/server/inc/atstorageserversession.h
analyzetool/storageserver/server/src/atdllinfo.cpp
analyzetool/storageserver/server/src/atdriveinfo.cpp
analyzetool/storageserver/server/src/atdynprocessinfo.cpp
analyzetool/storageserver/server/src/atmemoryentry.cpp
analyzetool/storageserver/server/src/atstorageserver.cpp
analyzetool/storageserver/server/src/atstorageserversession.cpp
analyzetool/storageserver/sis/atstorageserver.pkg
analyzetool/storageserver/sis/atstorageserver_udeb.pkg
memspy/CommandLine/Include/MemSpyCommandLine.h
memspy/CommandLine/Include/MemSpyCommands.h
memspy/CommandLine/Source/MemSpyCommandLine.cpp
memspy/CommandLine/Source/MemSpyCommandLineMain.cpp
memspy/CommandLine/group/MemSpyCommandLine.mmp
memspy/Console/Include/ConsoleMenu.h
memspy/Console/Source/ConsoleDWOperation.cpp
memspy/Console/Source/ConsoleMain.cpp
memspy/Console/Source/ConsoleMenu.cpp
memspy/Console/group/MemSpyConsole.mmp
memspy/Console/group/bld.inf
memspy/Driver/BWINS/memspydriverclientu.def
memspy/Driver/Kernel/Include/MemSpyDriverHeap.h
memspy/Driver/Kernel/Include/MemSpyDriverHeapStatistics.h
memspy/Driver/Kernel/Include/MemSpyDriverHeapWalker.h
memspy/Driver/Kernel/Include/MemSpyDriverInspectedProcess.h
memspy/Driver/Kernel/Include/MemSpyDriverLog.h
memspy/Driver/Kernel/Include/MemSpyDriverOSAdaption.h
memspy/Driver/Kernel/Include/MemSpyDriverObjectIx.h
memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanContainerBase.h
memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanHeapBase.h
memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanHeapInfo.h
memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanHeapWalk.h
memspy/Driver/Kernel/Source/MemSpyDriverEventMonitor.cpp
memspy/Driver/Kernel/Source/MemSpyDriverHeap.cpp
memspy/Driver/Kernel/Source/MemSpyDriverHeapWalker.cpp
memspy/Driver/Kernel/Source/MemSpyDriverInspectedProcess.cpp
memspy/Driver/Kernel/Source/MemSpyDriverLogicalChannel.cpp
memspy/Driver/Kernel/Source/MemSpyDriverOSAdaption.cpp
memspy/Driver/Kernel/Source/MemSpyDriverObjectIx.cpp
memspy/Driver/Kernel/Source/MemSpyDriverStreamWriter.cpp
memspy/Driver/Kernel/Source/MemSpyDriverSuspensionManager.cpp
memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanBase.cpp
memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanChunks.cpp
memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanClientServer.cpp
memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanContainerBase.cpp
memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanContainers.cpp
memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapBase.cpp
memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapData.cpp
memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapInfo.cpp
memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapWalk.cpp
memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanMisc.cpp
memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanStack.cpp
memspy/Driver/Shared/MemSpyDriverObjectsInternal.h
memspy/Driver/Shared/MemSpyDriverOpCodes.h
memspy/Driver/Shared/heaputils.cpp
memspy/Driver/Shared/heaputils.h
memspy/Driver/User/Include/RBuildQueryableHeap.h
memspy/Driver/User/Source/MemSpyDriverClient.cpp
memspy/Driver/User/Source/RBuildQueryableHeap.cpp
memspy/Driver/eabi/memspydriverclientu.def
memspy/Driver/group/MemSpyDriver.mmp
memspy/Driver/group/MemSpyDriverClient.mmp
memspy/Engine/BWINS/MemSpyEngineu.def
memspy/Engine/Include/ClientServer/MemSpyEngineServer.h
memspy/Engine/Include/Sink/MemSpyEngineOutputSinkFile.h
memspy/Engine/Source/ClientServer/MemSpyEngineServer.cpp
memspy/Engine/Source/DeviceWideOps/MemSpyDeviceWideOperations.cpp
memspy/Engine/Source/Helpers/MemSpyEngineHelperActiveObject.cpp
memspy/Engine/Source/Helpers/MemSpyEngineHelperFbServ.cpp
memspy/Engine/Source/Helpers/MemSpyEngineHelperHeap.cpp
memspy/Engine/Source/Helpers/MemSpyEngineHelperKernelContainers.cpp
memspy/Engine/Source/Helpers/MemSpyEngineHelperStack.cpp
memspy/Engine/Source/MemSpyEngine.cpp
memspy/Engine/Source/MemSpyEngineImp.cpp
memspy/Engine/Source/MemSpyEngineUtils.cpp
memspy/Engine/Source/Sink/MemSpyEngineOutputList.cpp
memspy/Engine/Source/Sink/MemSpyEngineOutputSink.cpp
memspy/Engine/Source/Sink/MemSpyEngineOutputSinkFile.cpp
memspy/Engine/Source/SysMemTracker/MemSpyEngineHelperSysMemTracker.cpp
memspy/Engine/Source/SysMemTracker/MemSpyEngineHelperSysMemTrackerEntryHeap.cpp
memspy/Engine/Source/SysMemTracker/MemSpyEngineHelperSysMemTrackerEntryManager.cpp
memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectContainer.cpp
memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectProcess.cpp
memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectThread.cpp
memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectThreadInfoObjects.cpp
memspy/Engine/eabi/MemSpyEngineu.def
memspy/Engine/group/MemSpyEngine.mmp
memspy/MemSpyClient/bwins/MemSpyClientu.def
memspy/MemSpyClient/eabi/MemSpyClientu.def
memspy/MemSpyClient/group/MemSpyClient.mmp
memspy/MemSpyClient/group/bld.inf
memspy/MemSpyClient/inc/memspyapiecom.h
memspy/MemSpyClient/inc/memspyapiheap.h
memspy/MemSpyClient/inc/memspyapikernelobject.h
memspy/MemSpyClient/inc/memspyapikernelobjectitem.h
memspy/MemSpyClient/inc/memspyapimemorytrackingcycle.h
memspy/MemSpyClient/inc/memspyapiprocess.h
memspy/MemSpyClient/inc/memspyapiserver.h
memspy/MemSpyClient/inc/memspyapithread.h
memspy/MemSpyClient/inc/memspyapithreadinfoitem.h
memspy/MemSpyClient/inc/memspyecomdata.h
memspy/MemSpyClient/inc/memspyheapdata.h
memspy/MemSpyClient/inc/memspykernelobjectdata.h
memspy/MemSpyClient/inc/memspymemorytrackingcycledata.h
memspy/MemSpyClient/inc/memspyprocessdata.h
memspy/MemSpyClient/inc/memspyserverdata.h
memspy/MemSpyClient/inc/memspysession.h
memspy/MemSpyClient/inc/memspythreaddata.h
memspy/MemSpyClient/inc/memspythreadinfoitemdata.h
memspy/MemSpyClient/src/memspyapiecom.cpp
memspy/MemSpyClient/src/memspyapiheap.cpp
memspy/MemSpyClient/src/memspyapikernelobject.cpp
memspy/MemSpyClient/src/memspyapikernelobjectitem.cpp
memspy/MemSpyClient/src/memspyapimemorytrackingcycle.cpp
memspy/MemSpyClient/src/memspyapiprocess.cpp
memspy/MemSpyClient/src/memspyapiserver.cpp
memspy/MemSpyClient/src/memspyapithread.cpp
memspy/MemSpyClient/src/memspyapithreadinfoitem.cpp
memspy/MemSpyClient/src/memspysession.cpp
memspy/MemSpyServer/Source/MemSpyServerMain.cpp
memspy/MemSpyServer/data/MemSpyEComInterfaceIds.xml
memspy/MemSpyServer/group/MemSpyServer.mmp
memspy/MemSpyServer/group/bld.inf
memspy/group/ReleaseNotes_MemSpy.txt
memspy/group/bld.inf
memspy/memspy_plat/memspy_api/include/MemSpyEngineClientInterface.h
memspy/memspy_plat/memspy_api/include/memspy/driver/shared/MemSpyDriverEnumerationsShared.h
memspy/memspy_plat/memspy_api/include/memspy/driver/shared/MemSpyDriverObjectsShared.h
memspy/memspy_plat/memspy_api/include/memspy/driver/shared/MemSpyDriverObjectsSharedRHeap.h
memspy/memspy_plat/memspy_api/include/memspy/driver/user/MemSpyDriverClient.h
memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperECom.h
memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperFbServ.h
memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperHeap.h
memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperKernelContainers.h
memspy/memspy_plat/memspy_api/include/memspy/engine/MemSpyEngine.h
memspy/memspy_plat/memspy_api/include/memspy/engine/MemSpyEngineImp.h
memspy/memspy_plat/memspy_api/include/memspy/engine/Sink/MemSpyEngineOutputSink.h
memspy/memspy_plat/memspy_api/include/memspy/engine/SysMemTracker/MemSpyEngineHelperSysMemTracker.h
memspy/memspy_plat/memspy_api/include/memspy/engine/SysMemTracker/MemSpyEngineHelperSysMemTrackerConfig.h
memspy/memspy_plat/memspy_api/include/memspy/engine/ThreadAndProcess/MemSpyEngineObjectProcess.h
memspy/memspy_plat/memspy_api/include/memspy/engine/ThreadAndProcess/MemSpyEngineObjectThread.h
memspy/memspy_plat/memspy_api/include/memspy/engine/ThreadAndProcess/MemSpyEngineObjectThreadInfoObjects.h
memspy/rom/memspy.iby
piprofiler/engine/inc/SamplerController.h
piprofiler/engine/src/ProfilerEshell.cpp
piprofiler/engine/src/SamplerController.cpp
piprofiler/group/ReleaseNotes_PIProfiler.txt
piprofiler/piprofiler_plat/inc/SamplerPluginInterface.h
piprofiler/plugins/BUPplugin/inc/BupPlugin.h
piprofiler/plugins/BUPplugin/src/BupPlugin.cpp
piprofiler/plugins/GeneralsPlugin/inc/GeneralsPlugin.h
piprofiler/plugins/GeneralsPlugin/src/GeneralsPlugin.cpp
piprofiler/plugins/GeneralsPlugin/src/MemSamplerImpl.cpp
piprofiler/plugins/PWRplugin/inc/PwrPlugin.h
piprofiler/plugins/PWRplugin/src/PwrPlugin.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/analyzetool_plat/analyzetool_api/analyzetool_api.metaxml	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<api id="e7d1f55108565c675ad3ff377518344a" dataversion="2.0">
+  <name>AnalyzeTool API</name>
+  <description>Defines the API, which is used by application compiled with AnlayzeTool.</description>
+  <type>c++</type>
+  <collection>AnalyzeTool</collection>
+  <libs>
+    <lib name="atoolstaticlib.lib"/>
+    <lib name="atoolcleaner.lib"/>
+    <lib name="atoolmemoryhook.lib"/>
+  </libs>
+  <release category="platform" sinceversion=""/>
+  <attributes>
+    <htmldocprovided>no</htmldocprovided>
+    <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/analyzetool_plat/analyzetool_api/group/bld.inf	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,28 @@
+/*
+* 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 <platform_paths.hrh>
+
+PRJ_EXPORTS
+// Analyzetool API
+../inc/analyzetool/analyzetool.h				            OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/analyzetool.h)
+../inc/analyzetool/analyzetool.inl				            OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/analyzetool.inl)
+../inc/analyzetool/analyzetoolcleaner.h				        OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/analyzetoolcleaner.h)
+../inc/analyzetool/analyzetooltraceconstants.h				OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/analyzetooltraceconstants.h)
+../inc/analyzetool/atcommon.h				                OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/atcommon.h)
+../inc/analyzetool/customuser.h				                OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/customuser.h)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/analyzetool.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,325 @@
+/*
+* 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:  Declaration of the class RAnalyzeTool.
+*
+*/
+
+
+#ifndef __ANALYZETOOL_H__
+#define __ANALYZETOOL_H__
+
+// INCLUDES
+#include <e32cmn.h>
+
+//Version information for command line engine.
+//Tells the version of AT core componenets.
+//ANALYZETOOL_CORE_VERSION_FOR_CLE 1.10.0
+
+// CONSTANTS
+inline TVersion KAnalyzeToolLddVersion() { return TVersion(1, 0, 1); }
+
+/* The name of the analyze tool device driver*/
+_LIT( KAnalyzeToolLddName, "AToolKernelEventHandler" );
+
+/* The priority of AnalyzeTool Dfc */
+const TInt KAnalyzeToolThreadPriority = 27;
+
+/* The name of the AnalyzeTool DFC */
+_LIT8( KAnalyzeToolThreadName, "AnalyzeToolThreadDfc" );
+
+/* The panic literal */
+_LIT( KClientPanic, "AnalyzeTool" );
+
+//const TInt KATMaxCallstackLength = 20;
+
+/* The device handler panic codes */
+enum TPanic
+	{
+	EPanicRequestPending,
+	EPanicNoRequestPending,
+	EPanicUnsupportedRequest
+	};
+
+// Size of following must be multiple of 4 bytes.
+
+class TMainThreadParams
+	{
+	public:
+		RAllocator* iAllocator;
+		TBool       iAlone;
+		TUint       iProcessId;
+	};
+typedef TPckgBuf<TMainThreadParams> TMainThreadParamsBuf;
+
+class TLibraryInfo
+	{
+	public:
+		TBuf8<KMaxLibraryName> iLibraryName;
+		TLinAddr  iRunAddress;
+		TUint32   iSize;
+		TInt      iIndex;
+		TUint     iProcessId;
+	};
+
+typedef TPckgBuf<TLibraryInfo> TLibraryInfoBuf;
+
+class TCodesegInfo
+	{
+	public:
+		TBuf8<KMaxLibraryName> iFullName;
+		TLinAddr iRunAddress;
+		TUint32  iSize;
+		TInt  iIndex;
+		TUint iProcessId;
+		TInt  iCodesegIndex; 
+		TLinAddr iFileEntryPoint;
+		TInt     iFuntionCount;
+		TLibraryFunction iFirstFunction;
+		TModuleMemoryInfo iMemoryInfo;
+	};
+
+typedef TPckgBuf<TCodesegInfo> TCodesegInfoBuf;
+
+class TThreadParams
+	{		
+	public:
+	    TLinAddr iStackAddress;
+	    TInt iStackSize;
+	    TUint iThreadId;
+	};
+
+typedef TPckgBuf<TThreadParams> TThreadParamsBuf;
+
+class TProcessIdentityParams
+	{		
+	public:
+		TBuf8<KMaxProcessName> iProcessName;
+		TInt iDynamicCount;
+		TInt iCodesegCount;
+		TUint iProcessId;
+		TUint iThreadId;
+	    TLinAddr iStackAddress;
+	    TInt iStackSize;
+	};
+
+typedef TPckgBuf<TProcessIdentityParams> TProcessIdentityParamsBuf;
+
+class TLibraryEventInfo
+	{
+	public:
+		enum TLibraryEvent
+			{ 
+			ELibraryAdded = 0, 
+			ELibraryRemoved,
+			EKillThread 
+			};
+					
+	public:
+		TUint iProcessId;
+		TBuf8<KMaxLibraryName> iLibraryName;
+		TLinAddr iRunAddress;
+		TUint32 iSize;
+		TLibraryEvent iEventType;
+		TUint iThreadId;
+	};
+
+typedef TPckgBuf<TLibraryEventInfo> TLibraryEventInfoBuf;
+
+class TProcessHandleInfo
+	{
+	public:
+		TInt     iProcessHandleCount;
+		TInt     iThreadHandleCount;
+		TInt     iIndex;
+		TInt     iThreadCount;
+		TLinAddr iUserStackRunAddress;
+		TInt     iUserStackSize;
+		TUint    iProcessId;
+	};
+
+typedef TPckgBuf<TProcessHandleInfo> TProcessHandleInfoBuf;
+
+/**
+*  A class for particular process's current handle count
+*/
+class TATProcessHandles
+    {
+    public:
+    
+        /** The ID of the process. */
+        TUint iProcessId;
+        
+        /** The number of current handles in the library. */
+        TInt iCurrentHandleCount;
+    };
+
+typedef TPckgBuf<TATProcessHandles> TATProcessHandlesBuf;
+
+class TClientCount
+    {
+    public:
+    
+        /** The count of clients */
+        TInt iClientCount;     
+    };
+
+typedef TPckgBuf<TClientCount> TClientCountBuf;
+
+class TATMemoryModel
+    {
+    public :
+        /* Memory model*/
+        TUint32 iMemoryModel;
+    };
+typedef TPckgBuf<TATMemoryModel> TATMemoryModelBuf;
+
+// CLASS DECLARATION
+
+/**
+*  The user-side handle to a logical channel which provides functions to 
+*  open a channel and to make requests to a analyze tool device driver. 
+*/
+
+class RAnalyzeTool : public RBusLogicalChannel
+	{
+	
+	public:
+		
+	/** Enumeration of supported functions */
+	enum TBasicAnalyzerControl
+		{
+		EGetProcessInfo = 0, /* The process information */
+		EGetCodesegInfo,	 /* The codesegment information */
+		EGetLibraryInfo,     /* The library information */
+		EGetDynamicInfo,	 /* The count of dynamic code in the process */
+		ELibraryEvent,       /* Subscribe events from library events */
+		ECancelLibraryEvent, /* Cancel subscribetion of library events */
+		ECurrentClientCount,  /* The count of clients in device driver */
+		EMainThreadAlloctor,
+		EThreadStack,
+		EGetProcessHandle,	/* Gets process global handles info*/
+		EGetCurrentHandles, /* Get a process's current handle count */
+		EGetMemoryModel
+		};
+			
+#ifndef __KERNEL_MODE__
+
+        /**
+        * Opens a handle to a logical channel.
+        * @return TInt Returns KErrNone, if successful or otherwise 
+        		  one of the other system-wide error codes
+        */
+		inline TInt Open();
+
+        /**
+        * Acquires process information.
+        * @param aProcessIdentityParams The process information which 
+        								is filled by the device driver
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		inline TInt GetProcessInfo( 
+				TProcessIdentityParamsBuf& aProcessIdentityParams );
+
+        /**
+        * Acquires codeseg information.
+        * @param aCodesegInfo The codeseg information which 
+        					  is filled by the device driver
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		inline TInt GetCodesegInfo( TCodesegInfoBuf& aCodesegInfo );
+		
+        /**
+        * Acquires library information.
+        * @param aLibraryInfo The library information which 
+        					  is filled by the device driver
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		inline TInt GetLibraryInfo( TLibraryInfoBuf& aLibraryInfo );
+				
+        /**
+        * Subscribes library event.
+        * @param aStatus The request status object for this request. 
+        * @param aLibraryInfo The library information which 
+        					  is filled by the device driver
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		inline void LibraryEvent( TRequestStatus& aStatus, 
+		                          TLibraryEventInfo& aLibraryInfo );
+		
+        /**
+        * Cancels subscribetion of the library event.
+        */
+		inline void CancelLibraryEvent();
+
+        /**
+        * Acquires device driver current client count.
+        * @param aClientCount A reference to TInt which is 
+        				      updated by the device driver.
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		inline TInt ClientCount( TClientCountBuf& aClientCount );
+		
+        /**
+        * Acquires process main thread RAllocator
+        * @param aMainThreadParams The main thread information which 
+        					        is filled by the device driver
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */	
+		inline TInt MainThreadAlloctor( TMainThreadParamsBuf& aMainThreadParams );
+		
+		/**
+		* Acquires main thread stack address.
+		* @param aThreadStack Pointer to the TThreadParams object.
+		* @return TInt Returns KErrNone, if successful
+					   otherwise one of the other system-wide error codes
+		*/
+		inline TInt ThreadStack( TThreadParamsBuf& aThreadStack );
+
+        /**
+        * Acquires information about process global handles.
+        * @param aProcessHandleInfo Pointer to the TProcessHandleInfo object.
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		inline TInt GetProcessHandleInfo( TProcessHandleInfoBuf& aProcessHandleInfo );
+
+        /**
+        * Acquires a process's current handle count.
+        * @param aProcessHandles Pointer to the TATProcessHandles object.
+        * @return TInt Returns KErrNone, if successful
+                       otherwise one of the other system-wide error codes
+        */
+        inline TInt GetCurrentHandleCount( TATProcessHandlesBuf& aProcessHandles );
+
+        /**
+         * Acquires memory model system uses.
+         * @param aMemoryModel pointer to the TATMemoryModelBuf object.
+         */
+        inline TInt GetMemoryModel( TATMemoryModelBuf& aMemoryModel );
+        
+#endif // #ifndef __KERNEL_MODE__
+	};
+
+// INLINES
+#include <analyzetool/analyzetool.inl>
+
+#endif // #ifndef __ANALYZETOOL_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/analyzetool.inl	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,159 @@
+/*
+* 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:  Definitions for inline methods of the class RAnalyzeTool.
+*
+*/
+
+
+#ifndef __ANALYZETOOL_INL
+#define __ANALYZETOOL_INL
+
+#ifndef __KERNEL_MODE__
+
+// ----------------------------------------------------------------------------
+// RAnalyzeTool::Open()
+// Opens a handle to a analyze tool device driver
+// ----------------------------------------------------------------------------
+//
+inline TInt RAnalyzeTool::Open()
+	{
+	return DoCreate( KAnalyzeToolLddName, 
+					 KAnalyzeToolLddVersion(), 
+					 KNullUnit, 
+					 NULL, 
+					 NULL, 
+					 EOwnerProcess );
+	}
+
+// ----------------------------------------------------------------------------
+// RAnalyzeTool::GetProcessInfo()
+// Acquires process information.
+// ----------------------------------------------------------------------------
+//
+inline TInt RAnalyzeTool::GetProcessInfo( 
+		TProcessIdentityParamsBuf& aProcessIdentityParams )
+	{
+	return DoControl( EGetProcessInfo, &aProcessIdentityParams, NULL );
+	}
+
+// ----------------------------------------------------------------------------
+// RAnalyzeTool::GetCodesegInfo()
+// Acquires codeseg information.
+// ----------------------------------------------------------------------------
+//
+inline TInt RAnalyzeTool::GetCodesegInfo( TCodesegInfoBuf& aCodesegInfo )
+	{
+	return DoControl( EGetCodesegInfo, &aCodesegInfo, NULL );
+	}
+
+// ----------------------------------------------------------------------------
+// RAnalyzeTool::GetLibraryInfo()
+// Symbian 2nd phase constructor can leave.
+// ----------------------------------------------------------------------------
+//
+inline TInt RAnalyzeTool::GetLibraryInfo( TLibraryInfoBuf& aLibraryinfo )
+	{
+	return DoControl( EGetLibraryInfo, &aLibraryinfo, NULL );
+	}
+
+// ----------------------------------------------------------------------------
+// RAnalyzeTool::LibraryEvent()
+// Subscribes library event.
+// ----------------------------------------------------------------------------
+//
+inline void RAnalyzeTool::LibraryEvent( TRequestStatus& aStatus,
+	TLibraryEventInfo& aLibInfo )
+	{
+	return DoRequest( ELibraryEvent, aStatus, (TAny*)&aLibInfo );
+	}
+
+// ----------------------------------------------------------------------------
+// RAnalyzeTool::CancelLibraryEvent()
+// Cancels subscribetion of the library event.
+// ----------------------------------------------------------------------------
+//
+inline void RAnalyzeTool::CancelLibraryEvent()
+	{
+	DoControl( ECancelLibraryEvent, NULL, NULL);
+	}
+
+// ----------------------------------------------------------------------------
+// RAnalyzeTool::ClientCount()
+// Acquires the count of device driver current users
+// ----------------------------------------------------------------------------
+//
+inline TInt RAnalyzeTool::ClientCount( TClientCountBuf& aClientCount )
+	{
+	return DoControl( ECurrentClientCount, &aClientCount, NULL );
+	}
+
+// ----------------------------------------------------------------------------
+// RAnalyzeTool::MainThreadAlloctor()
+// Acquires information about process main thread
+// ----------------------------------------------------------------------------
+//
+inline TInt RAnalyzeTool::MainThreadAlloctor( 
+	        TMainThreadParamsBuf& aMainThreadParams )
+    {
+    return DoControl( EMainThreadAlloctor, &aMainThreadParams, NULL );
+    }
+
+// ----------------------------------------------------------------------------
+// RAnalyzeTool::ThreadStack()
+// Acquires main thread stack address.
+// ----------------------------------------------------------------------------
+//
+inline TInt RAnalyzeTool::ThreadStack( TThreadParamsBuf& aThreadStack )
+    {
+    return DoControl( EThreadStack, &aThreadStack, NULL );
+    }
+
+// ----------------------------------------------------------------------------
+// RAnalyzeTool::GetProcessHandleInfo()
+// Acquires information about process handles
+// ----------------------------------------------------------------------------
+//
+inline TInt RAnalyzeTool::GetProcessHandleInfo( 
+		    TProcessHandleInfoBuf& aProcessHandleInfo )
+    {
+    return DoControl( EGetProcessHandle, &aProcessHandleInfo, NULL );
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::GetCurrentHandleCount()
+// Acquires a process's current handle count
+// -----------------------------------------------------------------------------
+//
+inline TInt RAnalyzeTool::GetCurrentHandleCount( 
+		    TATProcessHandlesBuf& aProcessHandles )
+    {
+    return DoControl( EGetCurrentHandles, &aProcessHandles, NULL );
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::GetMemoryModel()
+// Acquires memory model system uses.
+// -----------------------------------------------------------------------------
+//
+inline TInt RAnalyzeTool::GetMemoryModel( 
+            TATMemoryModelBuf& aMemoryModel )
+    {
+    return DoControl( EGetMemoryModel, &aMemoryModel, NULL );
+    }
+
+#endif // #ifndef __KERNEL_MODE__
+
+#endif // __ANALYZETOOL_INL
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/analyzetoolcleaner.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,63 @@
+/*
+* 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:  Definitions for the class TAnalyzeToolCleanerBase.
+*
+*/
+
+#ifndef __ANALYZETOOLCLEANER_H__
+#define __ANALYZETOOLCLEANER_H__
+
+// INCLUDES
+#include <e32std.h>
+
+// CONSTANTS
+#define ATCLEANERTABLESIZE 10
+#define ATCLEANERTABLE TFixedArray<TUint32, ATCLEANERTABLESIZE>
+_LIT( KATCleanerDllName, "atoolcleaner.dll" );
+
+// CLASS DECLARATION
+
+/**
+*  Cleaner base class
+*/
+class TAnalyzeToolCleanerBase
+    {
+public:
+    /**
+    * Cleanup function which uninstall allocator
+    */
+    virtual void Cleanup() = 0;
+    };
+
+// CLASS DECLARATION
+
+/**
+*  Cleaner class
+*/
+class THookCleaner
+    {
+public:
+    /**
+    * C++ default constructor.
+    */
+    THookCleaner();
+    
+    /**
+    * Destructor.
+    */
+    ~THookCleaner();
+    
+    ATCLEANERTABLE iTable;
+    };
+#endif // __ANALYZETOOLCLEANER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/analyzetooltraceconstants.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,209 @@
+/*
+* 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:  Common declarations/definitions for Analyze Tool.
+*
+*/
+
+#ifndef __ANALYZETOOLTRACECONSTANTS_H__
+#define __ANALYZETOOLTRACECONSTANTS_H__
+
+#include <analyzetool/atcommon.h>
+
+// Trace version information.
+const TUint KATTraceVersion = 0x3;
+
+// The default logging mode 
+const TATLogOption KDefaultLoggingMode = EATLogToTraceFast;
+
+// When needed, update the data file's version number directly inside
+// the _LIT8 macro. Note, if you change this string, also remember to update
+// the constant "KVersionStringLength" below.
+
+_LIT8( KDataFileVersion, "ATOOL_BINARY_FILE_VERSION 1\n" );
+_LIT( KOpenSquareBracket, "[" );
+_LIT( KCloseSquareBracket, "]" );
+_LIT( KUnderLine, "_" );
+_LIT( KLeftBracket, "(" );
+_LIT( KRightBracket, ")" );
+
+_LIT8( KSpace, " " );
+_LIT8( KUdeb, "UDEB" );
+_LIT8( KUrel, "UREL" );
+    
+// Constants for logging through debug channel
+
+// remember to change length of KTagLength when length of constants changes
+
+_LIT8( KATIdentifier, "<AT> " );
+_LIT8( KProcessStart, "PCS " );
+_LIT8( KProcessEnd, "PCE " );
+_LIT8( KVersionsInfo, "DEVINFO ");
+_LIT8( KThreadStart, "TDS " );
+_LIT8( KThreadEnd, "TDE " );
+_LIT8( KDllLoad, "DLL " );
+_LIT8( KDllUnload, "DLU " );
+_LIT8( KTestStart, "TSS " );
+_LIT8( KTestEnd, "TSE " );
+_LIT8( KHandleLeak, "HDL " );
+_LIT8( KLoggingCancelled, "LGC " );
+_LIT8( KErrorOccured, "ERR " );
+_LIT8( KMemoryAllocHeader, "ALH " );
+_LIT8( KMemoryAllocFragment, "ALF " );
+_LIT8( KMemoryFreedHeader, "FRH " );
+_LIT8( KMemoryFreedFragment, "FRF " );
+_LIT8( KMemoryReallocHeader, "RAH " );
+_LIT8( KMemoryReallocFragment, "RAF " );
+
+//to be implemented on carbide side (was logged from storage server/ carbide extension)
+//_LIT( KSubtestStart, "TEST_START " );
+//_LIT( KSubtestEnd, "TEST_END " );
+
+// File name format
+_LIT( KFormat, "%S%S%02d%S%S");// pad char="0", field width=2
+
+// A string for setting time January 1st, 1970 AD nominal Gregorian
+_LIT( KJanuaryFirst1970, "19700000:000000.000000" );
+
+
+// todo
+// Module name when it cannot be defined
+// was used in "handle leak" message - always unknown
+//_LIT8( KUnknownModule, "Unknown" );
+
+// Constant time variable used to calculate timestamps for pc side.
+const TInt64  KMicroSecondsAt1970 = 62168256000000000;
+
+// The length of the string KDataFileVersion
+const TInt KVersionStringLength = 27;
+
+// The maximum length of one word (32 bits) represented in the hexadecimal text format
+// without "0x" prefix
+const TInt KHexa32Length = 8;
+
+// The maximum length of one word (32 bits) represented in the decimal text format
+const TInt KDec32Length = 10;
+
+// The maximum length of a TInt64 represented in the hexadecimal text format without
+// "0x" prefix
+const TInt KHexa64Length = 16;
+
+// The length of one space character in text
+const TInt KSpaceLength = 1;
+
+// The length of the AT message identifier with one space character ("<AT> ")
+const TInt KATIdentifierLength = 5;
+
+// The length of the tag with one space character (e.g. "FRH ")
+const TInt KTagLength = 4;
+
+// The length of atool version string (x.x.x)
+const TInt KAtoolVersionLength = 6;
+
+// The length of api version string (x.x.x)
+const TInt KApiVersionLength = 5;
+
+// The length of sw version version string
+const TInt KSwVersionLength = 64;
+
+// The length of the combination atId+processId+msgTag (<AT> NNN PCS )
+const TInt KTraceHeaderLength = KATIdentifierLength + KHexa32Length + KSpaceLength + KTagLength;
+
+// Max length of alloc, free, realloc last item (callstack adress)
+const TInt KLastItemLength = KHexa32Length + KSpaceLength;
+
+// The maximum length of the process start (PCS) buffer
+// <<AT>> <Process ID> PCS <Process name> <Time stamp> <Udeb> <Version>
+const TInt KProcessStartBufLength = KTraceHeaderLength + 
+									KMaxProcessName + KSpaceLength + 
+									KHexa32Length + KSpaceLength + 
+									KHexa64Length + KSpaceLength +
+									KHexa32Length;
+
+// The maximum length of the versions info (VER) buffer
+// <<AT>> <Process ID> VER <AT version> <API version> <S60 version> <ROM ID>
+const TInt KVersionsInfoBufLength = KTraceHeaderLength + 
+		                            KAtoolVersionLength + KSpaceLength +
+		                            KApiVersionLength + KSpaceLength +
+									KSwVersionLength + KSpaceLength + 
+									KHexa32Length;
+
+// The maximum length of the process end PCE buffer
+// <<AT>> <Process ID> PCE
+const TInt KProcessEndBufLength = KTraceHeaderLength;
+
+// The maximum length of the load dll (DLL) buffer
+// <<AT>> <Process ID> DLL <DLL name> <Memory start address> <Memory end address>
+const TInt KDllLoadBufLength = KTraceHeaderLength +
+		                       KMaxLibraryName + KSpaceLength +
+		                       KHexa32Length + KSpaceLength + 
+		                       KHexa32Length;
+
+// The maximum length of the unload dll (DLU) buffer
+// <<AT>> <Process ID> DLU <DLL name> <Memory start address> <Memory end address>
+const TInt KDllUnloadBufLength = KTraceHeaderLength + 
+		                         KMaxLibraryName + KSpaceLength +
+		                         KHexa32Length + KSpaceLength + 
+		                         KHexa32Length;
+        
+// The maximum length of the error (ERR) buffer
+// <<AT>> <Process ID> ERR <Thread ID> <Error code> <Error message> 
+const TInt KErrOccuredBufLength = KTraceHeaderLength +
+		                          KHexa64Length + KSpaceLength +
+		                          KHexa32Length + KSpaceLength +
+		                          200; //err message length
+                                        
+// The maximum length of the alloc "ALH /ALF" buffer. 
+const TInt KMemAllocBufLength = 255;
+
+// The maximum length of the free "FRH/FRF" buffer.
+const TInt KMemFreedBufLength = 255;
+
+// The maximum length of the realloc "REH/REF" buffer.
+const TInt KMemReallocBufLength = 255;
+
+// The maximum length of the handle leak "HDL" buffer
+// <<AT>> <Process ID> HDL <Handle count>
+const TInt KHandleLeakBufLength = KTraceHeaderLength +
+                                  KHexa32Length;
+                                        
+// The maximum length of the test satart "TSS" buffer
+// <<AT>> <Process ID> TSS <Sub test name> <Handle count>
+const TInt KTestStartBufLength = KTraceHeaderLength +
+                                 KATMaxSubtestIdLength + KSpaceLength +
+                                 KHexa64Length;
+
+// The maximum length of the test end (TSE) buffer
+// <<AT>> <Process ID> TSE <Sub test name> <Handle count>
+const TInt KTestEndBufLength = KTraceHeaderLength + 
+		                       KATMaxSubtestIdLength + KSpaceLength + 
+		                       KHexa64Length;
+
+// The maximum length of the thread start (TDS) buffer.
+// <<AT>> <Process ID> TDS <Thread ID>
+const TInt KThreadStartBufLength = KTraceHeaderLength +
+                                   KHexa64Length; 
+
+
+// The maximum length of the thread end (TDE) buffer.
+// <<AT>> <Process ID> TDE <Thread ID>
+const TInt KThreadEndBufLength = KTraceHeaderLength +
+                                 KHexa64Length; 
+
+// The maximun length of the file name extension buffer.
+const TInt KExtensionLength = 50;
+
+// The maximun length of the process UID3 buffer.
+const TInt KProcessUidLength = 20;
+
+#endif // __ANALYZETOOLTRACECONSTANTS_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/atcommon.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,108 @@
+/*
+* 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:  Common declarations/definitions for Analyze Tool.
+*
+*/
+
+
+#ifndef ATCOMMON_H_
+#define ATCOMMON_H_
+
+// CONSTANTS
+const TInt KATMaxCallstackLength = 256;
+const TInt KATMaxFreeCallstackLength = 256;
+const TInt KATMaxSubtestIdLength = 256;
+
+// The following constants only limit the configuration UI.
+// The bigger the number is, the more space will be allocated run-time
+// by the client. So, change with care.
+const TInt KATMaxProcesses = 20;
+const TInt KATMaxDlls = 30;
+
+// Constants defining call stack address range in multiple memory model.
+const TInt32 KATMultipleMemoryModelLowLimit = 0x70000000;
+const TInt32 KATMultipleMemoryModelHighLimit = 0x90000000;
+
+
+// CLASS DECLARATIONS
+
+/**
+*  A class for storing process information
+*/
+class TATProcessInfo
+    {
+    public:
+    
+        /** The ID of the process. */
+        TUint iProcessId;
+        
+        /** The name of the process. */
+        TBuf8<KMaxProcessName> iProcessName;
+        
+        /** The starting time of the process. */
+        TInt64 iStartTime;
+    };
+
+
+// ENUMERATIONS
+
+/**
+*  Enumeration for different logging modes of Analyze Tool 
+*/
+enum TATLogOption
+    {
+    /** Using the default. */
+    EATUseDefault = 0,
+    
+    /** Logging to a file in S60. */
+    EATLogToFile,
+    
+    /** Logging to debug channel. */
+    EATLogToTrace,
+    
+    /** Logging to debug channel bypassing storage server. */
+    EATLogToTraceFast,
+    
+    /** Logging switched off. */
+    EATLoggingOff
+    };
+
+/**
+*  Class which supports interfacing with AnalyzeTool exported
+*  functions. Mainly meant for STIF integration.
+*/
+class AnalyzeToolInterface
+    {
+    public:
+
+        /**
+        * This function starts subtest with a given name.
+        * @param aSubtestId The name identifying this particular sub test. The length
+        *   of this descriptor must not be greater than KATMaxSubtestIdLength, or
+        *   otherwise the method raises a STSEClient: 2 panic.
+        */
+        IMPORT_C static void StartSubTest( const TDesC8& aSubtestId );
+
+        /**
+        * This function stops a subtest with a given name.
+        * @param aSubtestId The name identifying this particular sub test. The length
+        *   of this descriptor must not be greater than KATMaxSubtestIdLength, or
+        *   otherwise the method raises a STSEClient: 2 panic. 
+        */   
+        IMPORT_C static void StopSubTest( const TDesC8& aSubtestId );
+
+    };
+    
+
+#endif /*ATCOMMON_H_*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/analyzetool_plat/analyzetool_api/inc/analyzetool/customuser.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,218 @@
+/*
+* 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:  Declaration of the class CustomUser containing overloaded User static functions.
+*
+*/
+
+
+#ifndef CUSTOMUSER_H
+#define CUSTOMUSER_H
+
+// INCLUDES
+#include <u32std.h>
+#include <e32svr.h>
+
+// CONSTANTS
+const TInt KATVersionLength = 20;
+const TInt KATDefaultLogOption = 0;
+const TInt KATDefaultDebug = 1;
+const TInt KATDefaultAllocCallStackSize = 40;
+const TInt KATDefaultFreeCallStackSize = 0;
+    
+// TYPEDEFS
+typedef TBuf<KATVersionLength> TATVersion;
+
+// Argument list for SetupThreadHeap function parameters. (currently not used)
+// When needed, update the argument type directly inside _LIT macro.
+_LIT( KATArgumentList, "%i%i" ); //etc. 
+
+// CLASS DECLARATION
+
+/**
+*  Class which overloads the User functions and provides access to 
+*  the overloaded functions  
+*/
+class CustomUser
+    {
+    public: // Enumerations
+        enum TATOptions
+            {
+            /** Acquiring the log filename */
+            ELogFileName = 1,   
+            /** Acquiring the version number */
+            EVersion,
+            /** Acquiring logging option */
+            ELogOption,
+            /** Acquiring UDEB/UREL information */  
+            EDebug,
+            /** Acquiring max allocation call stack size */
+            EAllocCallStackSize,
+            /** Acquiring max free call stack size */
+            EFreeCallStackSize,
+            /** Acquiring the path of logfile */
+            ELogFilePath
+            };
+        
+    public:
+
+        /**
+        * Overloaded version of User::Exit()
+        * Terminates the current thread, specifying a reason. All child 
+        * threads are terminated and all resources are cleaned up.If the 
+        * current thread is the main thread in a process, the process is
+        * also terminated.
+        * @param aReason The reason code.
+        */
+        IMPORT_C static void Exit( TInt aReason );
+
+        /**
+        * Overloaded version of User::Panic()
+        * Panics the current thread, specifying a category name and panic
+        * number. Keep the length of the category name small;
+        * a length of 16 is ideal.
+        * @param aCategory A reference to the descriptor containing the text 
+        * that defines the category for this panic.
+        * @param aReason The panic number. 
+        */   
+        IMPORT_C static void Panic( const TDesC& aCategory, TInt aReason );
+
+        /**
+        * Overloaded version of UserHeap::SetupThreadHeap()
+        * Setups the threads heap.
+        * @param aNotFirst Is this first thread using specified heap
+        * @param aInfo Specifies the thread heap properties
+        * @param aFileName The name of the log file
+        * @param aLogOption The logging option
+        * @param aIsDebug Determines whether a binary is UDEB or UREL
+        * @param aVersion Atool version number
+        * @param aAllocCallStackSize Max number of stored callstack items when memory allocated
+        * @param aFreeCallStackSize Max number of stored callstack items when memory freed
+        * @param aFmt A descriptor containing the format string
+        * @return TInt KErrNone, if the insertion is successful, otherwise 
+        * one of the system wide error codes.
+        */   
+        IMPORT_C static TInt SetupThreadHeap( 
+                             TBool aNotFirst, 
+                             SStdEpocThreadCreateInfo& aInfo,
+                             const TFileName& aFileName,
+                             const TPath& aFilePath,
+                             TUint32 aLogOption, TUint32 aIsDebug,
+                             const TATVersion& aVersion,
+                             TUint32 aAllocCallStackSize,
+                             TUint32 aFreeCallStackSize,
+                             TRefByValue<const TDesC> aFmt, ... );
+                             
+        /**
+        * Overloaded version of UserHeap::SetCritical()
+        * Sets up or changes the effect that termination of the current 
+        * thread has, either on its owning process, or on the whole system.
+        * The precise effect of thread termination is defined by the following
+        *  specific values of the TCritical enum:
+        * ENotCritical
+        * EProcessCritical
+        * EProcessPermanent
+        * ESystemCritical
+        * ESystemPermanent
+        * Notes: The enum value EAllThreadsCritical cannot be set using this
+        * function. It is associated with a process, not a thread, and, if 
+        * appropriate, should be set using User::SetProcessCritical().
+        * The states associated with ENotCritical, EProcessCritical, 
+        * EProcessPermanent, ESystemCritical and ESystemPermanent are all 
+        * mutually exclusive, i.e. the thread can only be in one of these 
+        * states at any one time.
+        * @param aCritical The state to be set.
+        * @return TInt KErrNone, if successful; KErrArgument, if 
+        * EAllThreadsCritical is passed - this is a state associated with a 
+        * process, and you use User::SetProcessCritical() to set it.
+        */ 
+        IMPORT_C static TInt SetCritical( User::TCritical aCritical );
+        
+        /**
+        * Overloaded version of UserHeap::SetCritical()
+        * Sets up or changes the effect that termination of subsequently 
+        * created threads will have, either on the owning process, 
+        * or on the whole system. It is important to note that we are not
+        * referring to threads that have already been created, but threads
+        * that will be created subsequent to a call to this function.
+        * The precise effect of thread termination is defined by the following
+        * specific values of the TCritical enum:
+        * ENotCritical
+        * EAllThreadsCritical
+        * ESystemCritical
+        * ESystemPermanent
+        * Notes:
+        * The enum values EProcessCritical and EProcessPermanent cannot be set
+        * using this function. They are states associated with a thread, not a
+        * process, and, if appropriate, should be set using 
+        * User::SetCritical(). The states associated with ENotCritical, 
+        * EAllThreadsCritical, ESystemCritical and ESystemPermanent are all 
+        * mutually exclusive, i.e. the process can only be in one of these 
+        * states at any one time.
+        * @param aCritical The state to be set.
+        * @return TInt KErrNone, if successful; KErrArgument, if either 
+        * EProcessCritical or EProcessPermanent is passed - these are states
+        * associated with a thread, and you use User::SetCritical() 
+        * to set them.
+        */ 
+        IMPORT_C static TInt SetProcessCritical( User::TCritical aCritical );
+                
+    private: // Private functions
+        
+        /**
+        * Factory function for creating RAllocator instances.
+        * @param aNotFirst Is this first thread using specified heap
+        * @param aLogOption The logging option
+        * @param aFileName The name of the logging file
+        * @param aIsDebug Determines whether a binary is UDEB or UREL
+        * @param aAllocCallStackSize Max number of stored callstack items when memory allocated
+        * @param aFreecallStackSize Max number of stored callstack items when memory freed
+        * @param aAtoolVersion Version of atool
+        * @param aApiVersion  Version of atool's api
+        * @return RAllocator& A reference to created allocator
+        */  
+        static RAllocator& InstallAllocator( TBool aNotFirst,
+                                             const TFileName& aFileName,
+                                             const TPath& aFilePath,
+                                             TUint32 aLogOption, TUint32 aIsDebug,
+                                             TUint32 aAllocCallStackSize,
+                                             TUint32 aFreeCallStackSize, 
+                                             const TDesC8& aAtoolVersion,
+                                             const TDesC8& aApiVersion );
+        
+		/**
+		* Check atool version
+		* @param aVersion - Atool version number.
+		* @param aToolVersion The atool version number
+		* @return KErrNone if correct version found, otherwise one of the system wide 
+		* error codes.
+		*/
+        static TInt CheckVersion( const TATVersion& aVersion, TDes& aToolVersion, TDes& aApiVersion ); 
+        
+
+        /**
+		* Function for showing incorrect version information (file or debug channel).
+		* @param aLogOption The logging option
+		* @param aFileName The name of the log file
+		* @param aToolVersion The atool version number
+		*/
+        static void ReportIncorrectVersion( const TUint32 aLogOption, 
+											const TFileName& aFileName,
+											const TPath& aFilePath,
+											const TDes& aToolVersion );
+        
+    };
+
+#endif // CUSTOMUSER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/analyzetool_plat/group/bld.inf	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,19 @@
+/*
+* 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: 
+*
+*/
+
+// Analyze Tool API
+#include "../analyzetool_api/group/bld.inf"
--- a/analyzetool/analyzetoolcleaner/group/analyzetoolcleaner.mmp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/analyzetoolcleaner/group/analyzetoolcleaner.mmp	Wed Sep 15 13:53:27 2010 +0300
@@ -30,6 +30,7 @@
 
 USERINCLUDE   ../inc
 USERINCLUDE   ../../inc
+USERINCLUDE   ../../analyzetool_plat/analyzetool_api/inc/analyzetool
 
 OS_LAYER_SYSTEMINCLUDE
 
--- a/analyzetool/analyzetoolcleaner/group/bld.inf	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/analyzetoolcleaner/group/bld.inf	Wed Sep 15 13:53:27 2010 +0300
@@ -1,8 +1,22 @@
+/*
+* 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:  
+*
+*/
+
 PRJ_PLATFORMS
 ARMV5 WINSCW
 
-PRJ_EXPORTS
-../inc/analyzetoolcleaner.h  OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/analyzetoolcleaner.h)
-
 PRJ_MMPFILES
 analyzetoolcleaner.mmp
--- a/analyzetool/analyzetoolcleaner/inc/analyzetoolcleaner.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
-* 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:  Definitions for the class TAnalyzeToolCleanerBase.
-*
-*/
-
-#ifndef __ANALYZETOOLCLEANER_H__
-#define __ANALYZETOOLCLEANER_H__
-
-// INCLUDES
-#include <e32std.h>
-
-// CONSTANTS
-#define ATCLEANERTABLESIZE 10
-#define ATCLEANERTABLE TFixedArray<TUint32, ATCLEANERTABLESIZE>
-_LIT( KATCleanerDllName, "atoolcleaner.dll" );
-
-// CLASS DECLARATION
-
-/**
-*  Cleaner base class
-*/
-class TAnalyzeToolCleanerBase
-    {
-public:
-    /**
-    * Cleanup function which uninstall allocator
-    */
-    virtual void Cleanup() = 0;
-    };
-
-// CLASS DECLARATION
-
-/**
-*  Cleaner class
-*/
-class THookCleaner
-    {
-public:
-    /**
-    * C++ default constructor.
-    */
-    THookCleaner();
-    
-    /**
-    * Destructor.
-    */
-    ~THookCleaner();
-    
-    ATCLEANERTABLE iTable;
-    };
-#endif // __ANALYZETOOLCLEANER_H__
--- a/analyzetool/commandlineengine/group/atool.vcproj	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/group/atool.vcproj	Wed Sep 15 13:53:27 2010 +0300
@@ -241,6 +241,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\src\CATParseBinaryFile.cpp"
+				>
+			</File>
+			<File
 				RelativePath="..\src\CATParseTraceFile.cpp"
 				>
 			</File>
@@ -335,6 +339,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\src\CATParseBinaryFile.h"
+				>
+			</File>
+			<File
 				RelativePath="..\inc\CATParseTraceFile.h"
 				>
 			</File>
@@ -343,6 +351,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\inc\CATProcessData.h"
+				>
+			</File>
+			<File
 				RelativePath="..\inc\CATProject.h"
 				>
 			</File>
--- a/analyzetool/commandlineengine/inc/ATCommonDefines.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/inc/ATCommonDefines.h	Wed Sep 15 13:53:27 2010 +0300
@@ -23,6 +23,51 @@
 
 using namespace std;
 
+#define MAIN_ID "<AT>"
+#define ALLOC_ID "ALLOC" // < V.1.6 allocation. // todo remove
+#define ALLOCH_ID "ALH" // Header of multi message allocation.
+#define ALLOCF_ID "ALF" // Fragment of multi message allocation.
+#define REALLOCH_ID "RAH" // Header of multi message reallocation.
+#define REALLOCF_ID "RAF" // Fragment of multi message reallocation.
+#define FREE_ID "FREE"
+#define FREEH_ID "FRH" // Header of multi message free.
+#define FREEF_ID "FRF" // Fragment of multi message free.
+#define HANDLE_LEAK_ID "HANDLE_LEAK"
+
+const string ERROR_OCCURED = "ERR"; // Error messages.
+const string INCORRECT_ATOOL_VERSION = "INCORRECT_ATOOL_VERSION";
+
+// if changed, change also in analyzetoolfilelog.h
+enum EMessageType{
+    EFileVersion = 0,
+	EProcessStart,
+    EProcessEnd,
+    EThreadStart,
+	EThreadEnd,
+	EDllLoad,
+	EDllUnload,
+	EAllocH,
+	EAllocF,
+	EFreeH,
+	EFreeF,
+	EReallocH,
+	EReallocF,
+	ETestStart,
+	ETestEnd,
+	EHandleLeak,
+	EDeviceInfo,
+	EError  
+    };
+
+/**
+* Invalid characters in trace file line content.
+* These will be filtered out before actuall parsing of line.
+10 = LF
+13 = CR
+124 = |
+*/
+const char cINVALID_TRACE_FILE_CHARS[] = { 10, 13, 124 };
+
 /**
 * Atool return code.
 */
@@ -81,9 +126,12 @@
 // makefile dir is used in atool.cpp to check will we use sbs2 (in analyze and clear)
 #define RAPTOR_MAKEFILE_DIR "atool_temp\\build"
 
+//part of user defined filename to be replaced by process name
+const string AT_PROCESSNAME_TAG = "%processname%";
+
 // Atool version number and date
-#define ATOOL_VERSION "1.9.1" // NOTE! This version number is written also to temporary cpp file.
-#define ATOOL_DATE "29th April 2010"
+#define ATOOL_VERSION "1.10.0" // NOTE! This version number is written also to temporary cpp file.
+#define ATOOL_DATE "2nd July 2010"
 
 // Default/min/max call stack sizes
 const int AT_ALLOC_CALL_STACK_SIZE_DEFAULT = 40;
@@ -96,10 +144,10 @@
 
 // Constant compatibility string in temporary cpp.
 // Api version ; current version.
-#define ATOOL_COMPATIBILITY_STRING "1.7.5;1.9.1"
+#define ATOOL_COMPATIBILITY_STRING "1.7.6;1.10.0"
 
 // Datafile version
-#define AT_DATA_FILE_VERSION "DATA_FILE_VERSION 11"
+#define AT_DATA_FILE_VERSION "DATA_FILE_VERSION 12"
 
 // Latest dbghelp.dll version
 const int DBGHELP_VERSION_MAJ = 6;
@@ -115,7 +163,8 @@
 const string AT_BUILD_SUMMARY_TARGET = "\tTarget: ";
 const string AT_BUILD_SUMMARY_FAILED = "Build failed: ";
 const string AT_BUILD_SUMMARY_ERRORS = "\tErrors: ";
-const string AT_BUILD_SUMMARY_DATA_FILE_NAME = "\tInternal data gathering filename: ";
+const string AT_BUILD_SUMMARY_DATA_FILE_NAME = "\tLog file name: ";
+const string AT_BUILD_SUMMARY_DATA_FILE_PATH = "\tLog file path: ";
 const string AT_BUILD_SUMMARY_NORMAL_BUILD_COMPLETE = "Normal build complete: ";
 const string AT_BUILD_SUMMARY_STATIC_LIBRARY = "\tModule is static library.";
 const string AT_BUILD_SUMMARY_UNSUPPORTED_TARGET_TYPE = "\tModule has unsupported target type.";
@@ -127,9 +176,9 @@
 const string AT_BUILD_SUMMARY_LOGGING_MODE = "Data gathering mode: ";
 const string AT_BUILD_SUMMARY_ALLOC_CALL_STACK_SIZE = "Allocation call stack size: ";
 const string AT_BUILD_SUMMARY_FREE_CALL_STACK_SIZE = "Free call stack size: ";
-const string AT_BUILD_SUMMARY_FILE = "monitored internal";
+const string AT_BUILD_SUMMARY_FILE = "log to file";
 const string AT_BUILD_SUMMARY_TRACE = "monitored external";
-const string AT_BUILD_SUMMARY_TRACE_FAST = "external";
+const string AT_BUILD_SUMMARY_TRACE_FAST = "output to trace";
 
 const string AT_UNSUPPORTED_TARGET_TYPE = "\tModule has unsupported target type.";
 const string AT_UNSUPPORTED_COMPILE_DEFINITION = "\tModule defined unsupported compile definition.";
@@ -304,17 +353,21 @@
 
 // Trace file constants definitions
 #define LABEL_DATA_FILE_VERSION "DATA_FILE_VERSION"
-#define LABEL_PROCESS_START     "PROCESS_START"
-#define LABEL_DLL_LOAD          "DLL_LOAD"
-#define LABEL_DLL_UNLOAD		"DLL_UNLOAD"
+#define LABEL_PROCESS_START     "PCS"
+#define LABEL_DLL_LOAD          "DLL"
+#define LABEL_DLL_UNLOAD		"DLU"
 #define LABEL_MEM_LEAK          "MEM_LEAK"
-#define LABEL_PROCESS_END       "PROCESS_END"
-#define LABEL_ERROR_OCCURED     "ERROR_OCCURED"
-#define LABEL_HANDLE_LEAK       "HANDLE_LEAK"
-#define LABEL_TEST_START        "TEST_START"
-#define LABEL_TEST_END          "TEST_END"
+#define LABEL_PROCESS_END       "PCE"
+#define LABEL_ERROR_OCCURED     "ERR"
+#define LABEL_HANDLE_LEAK       "HDL"
+#define LABEL_TEST_START        "TSS"
+#define LABEL_TEST_END          "TSE"
+#define LABEL_THREAD_START		"TDS"
+#define LABEL_THREAD_END		"TDE"
+#define LABEL_DEVICE_INFO		"DEVINFO"
 #define LABEL_LOGGING_CANCELLED "LOGGING_CANCELLED"
 
+
 // AddressToLine related constants
 
 #define LABEL_ABNORMAL "ABNORMAL"
@@ -471,8 +524,10 @@
 {
 	bool bNoBuild; /** Only intrument project? (no build) */ 
 	bool bDataFileName; /** Is internal data gathering filename defined */
+	bool bDataFilePath; /** Is internal data gathering file path defined */
 	bool bAbldTest; /** Is build only for test modules (abld test build.. */
 	string sDataFileName; /** Internal data gathering filename */
+	string sDataFilePath; /** Path to internal data gathering file */
 	int iBuildSystem; /** 1 = sbs, 2 = raptor */
 	int iLoggingMode; /** Just for old parameter parsing. 1=trace, 2=file, 0=? */
 	int iAllocCallStackSize; /** Call stack size when memory allocated */
@@ -491,7 +546,9 @@
 		bNoBuild = false;
 		bAbldTest = false;
 		bDataFileName = false;
+		bDataFilePath = false;
 		sDataFileName = "";
+		sDataFilePath = "";
 		iBuildSystem = 0;
 		iLoggingMode = 0;
 		iAllocCallStackSize = AT_ALLOC_CALL_STACK_SIZE_DEFAULT;
--- a/analyzetool/commandlineengine/inc/CATBase.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/inc/CATBase.h	Wed Sep 15 13:53:27 2010 +0300
@@ -170,6 +170,13 @@
 	static string RemovePathAndExt( string sFileName, bool bReverseFindExt = false );
 
 	/**
+	* Returns time  stamp in microseconds parsed from start of trace message
+	* @param sLineStart
+	* @return int
+	*/
+	unsigned __int64 ParseTimeStamp( string sLineStart );
+
+	/**
 	* Check if given file exists.
 	* @param pFilename Pointer to file name.
 	* @return False If file does not exists.
@@ -283,6 +290,16 @@
 	static string GetStringUntilNextSpace( string& sInput, bool bEraseFromInput = true );
 
 	/**
+	* Function returns string from begin of given string until next atool's main id <AT>,
+	* characters until next space are removed from sInput string.
+	*
+	* @param sInput Line which contains main id.
+	* @param bEraseFromInput If true characters before main id will be removed.
+	* @return string String until main id.
+	*/
+	static string GetStringUntilMainId( string& sInput, bool bEraseFromInput = true );
+
+	/**
 	* Convert unix path to windows
 	* @param sPath
 	*/
@@ -293,6 +310,7 @@
 	* @param sId unique id to add in file name
 	* @param sPath where to create
 	* @param sS60FileName of the logging file
+	* @param sS60FilePath of the logging file
 	* @param iLogOption logging mode
 	* @param iIsDebug build type
 	* @param iAllocCallStackSize
@@ -302,6 +320,7 @@
 	static bool CreateTemporaryCpp( const string& sId
 								 ,const string& sPath
 								 ,const string& sS60FileName
+								 ,const string& sS60FilePath
 								 ,int iLogOption
 								 ,int iIsDebug
 								 ,int iAllocCallStackSize
@@ -345,6 +364,13 @@
 	static bool IsDataFile( string sFile );
 
 	/**
+	* checks given file is it binary log file
+	* @param sFile
+	* @return true if it is binary logfile
+	*/
+	static bool IsBinaryLogFile( string sFile );
+
+	/**
 	* Parses a path string containing ".." to a valid
 	* path without relations. If given string does
 	* not contain relations it will not be changed
--- a/analyzetool/commandlineengine/inc/CATModule2.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/inc/CATModule2.h	Wed Sep 15 13:53:27 2010 +0300
@@ -74,6 +74,7 @@
 	/**
 	* Create AT temporary cpp file for module.
 	* @param sS60FileName.
+	* @param sS60FileName.
 	* @param eLoggingMode.
 	* @param eBuildType.
 	* @param iAllocCallStackSize.
@@ -81,12 +82,19 @@
 	* @return true if successful.
 	*/
 	bool CreateTempCpp(const string& sS60FileName
+		, const string& sS60FilePath
 		, int eLoggingMode
 		, int eBuildType
 		, int iAllocCallStackSize
 		, int iFreeCallStackSize );
 
 	/**
+	* returns default data file name without extension in format processName.targetType
+	* @return string with default file name
+	*/
+	string GetDefaultFileName();
+
+	/**
 	* Add AT changes to modules mmp file.
 	* @return true if successful.
 	*/
@@ -287,6 +295,12 @@
 	string GetS60FileName() const;
 
 	/**
+	* Set S60 logging file name.
+	* @param aFileName s60 logging file name.
+	*/
+	void SetS60FileName( const string& aFileName );
+
+	/**
 	* Set target binary name.
 	* @param sTarget binary file name.
 	*/
@@ -514,6 +528,10 @@
 	vector<MAP_FUNC_INFO> m_vMapFileFuncList;
 	// File logging mode filename.
 	string m_sS60FileName;
+	// true if file name not empty and %processname% string replaced
+	bool m_bS60FileNameResolved;
+	// File logging mode file path.
+	string m_sS60FilePath;
 	// Is all data loaded for address to code line functions.
 	bool m_bAddressToLineInitialized;
 	// Read listing files (armv5 platform).
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/commandlineengine/inc/CATParseBinaryFile.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,113 @@
+/*
+* 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:  Definitions for class CATParseTrace, CProcessData and
+*               CSubTestData.
+*
+*/
+
+
+#ifndef __CATPARSEBINARYFILE_H__
+#define __CATPARSEBINARYFILE_H__
+
+#include "../inc/ATCommonDefines.h"
+#include "../inc/CATDataSaver.h"
+#include "../inc/CATBase.h"
+#include "../inc/catallocs.h"
+
+/**
+* Parses raw trace data to AnalyzeTool specific data file.
+*/
+class CATParseBinaryFile : public CATBase
+{
+public:
+	/**
+	* Constructor
+	*/
+	CATParseBinaryFile();
+
+	/**
+	* Main function to start parse.
+	*
+	* @param pFileName A trace file name
+	* @param pOutputFileName Pointer to output file name
+	*/
+	bool StartParse( const char* pFileName, const char* pOutputFileName );
+
+	/**
+	* Get data saver
+	* @return CATDataSaver*
+	*/
+	CATDataSaver* GetDataSaver(void);
+	
+	/**
+	* Gets 64bit number from input string
+	* @param cVal Input data
+	* @return Acquired number
+	*/
+	unsigned __int64 StringToNum64( unsigned char* cVal );
+
+	/**
+	* Gets 32bit number from input string
+	* @param cVal Input data
+	* @return Acquired number
+	*/
+	unsigned long StringToNum32( unsigned char* cVal );
+
+	/**
+	* Get next string from file
+	* @param pData Acquired data
+	* @param pIn Input file stream
+	* @param pStreamPos Actuall position in file
+	* @param pStreamEnd End of file
+	* @return false if no error
+	*/
+	bool GetString( unsigned char* pData, ifstream &pIn, size_t &streamPos,  size_t streamEnd );
+
+	/**
+	* Get next 8bit number from file
+	* @param pData Acquired data
+	* @param pIn Input file stream
+	* @param pStreamPos Actuall position in file
+	* @param pStreamEnd End of file
+	* @return false if no error
+	*/
+	bool GetNum8( unsigned char* pData, ifstream &pIn, size_t &pStreamPos, size_t pStreamEnd );
+
+	/**
+	* Get next 32bit number from file
+	* @param pData Acquired data
+	* @param pIn Input file stream
+	* @param pStreamPos Actuall position in file
+	* @param pStreamEnd End of file
+	* @return false if no error
+	*/
+	bool GetNum32( unsigned char* pData, ifstream &pIn, size_t &pStreamPos, size_t pStreamEnd );
+
+	/**
+	* Get next 64bit number from file
+	* @param pData Acquired data
+	* @param pIn Input file stream
+	* @param pStreamPos Actuall position in file
+	* @param pStreamEnd End of file
+	* @return false if no error
+	*/
+	bool GetNum64( unsigned char* pData, ifstream &pIn, size_t &pStreamPos, size_t pStreamEnd );
+
+#ifndef MODULE_TEST
+private:
+#endif
+	CATDataSaver m_DataSaver; /** Data saver */
+};
+
+#endif
\ No newline at end of file
--- a/analyzetool/commandlineengine/inc/CATParseTraceFile.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/inc/CATParseTraceFile.h	Wed Sep 15 13:53:27 2010 +0300
@@ -42,13 +42,21 @@
 	* @param pFileName A trace file name
 	* @param pOutputFileName Pointer to output file name
 	*/
-	bool StartParse( const char* pFileName, const char* pOutputFileName );
+	bool StartParse( const char* pFileName, const char* pOutputFileName, const char* pCleanedTraceFile = NULL );
 
 	/**
 	* Get data saver
 	* @return CATDataSaver*
 	*/
-	CATDataSaver* GetDataSaver(void);	
+	CATDataSaver* GetDataSaver(void);
+	
+	/**
+	* Get time from timestamp in microseconds as string
+	* @param iTimeStamp Timestamp for current message
+	* @param iTimeSpan Timespan for current process
+	* @return string Acquired time in microseconds(as string)
+	*/
+	static string GetTimeFromTimeStamp( unsigned __int64 iTimeStamp, unsigned __int64 iTimeSpan );
 
 #ifndef MODULE_TEST
 private:
@@ -56,36 +64,4 @@
 	CATDataSaver m_DataSaver; /** Data saver */
 };
 
-/**
-* Represents data of a single subtest.
-*/
-class CSubTestData : public CATAllocs
-{
-public:
-	// Members
-
-	bool bRunning; /** Is sub test running */
-	vector<string> vData; /** data */
-	string sSubTestName; /** test name */
-	string sStartTime; /** start time */
-	string sEndTime; /** end time */
-	string sSubTestStartHandleCount; /** handle count at start */
-	string sSubTestEndHandleCount; /** handle count at end */
-};
-
-/**
-* Represents data of a single run.
-*/
-class CProcessData : public CATAllocs
-{
-public:
-	// Members
-
-	bool bProcessOnGoing; /** is process on going */
-	int iProcessID; /** process id (pid)*/
-	vector<string> vData; /** data */
-	vector<string> vHandleLeaks; /** handle leak(s) */
-	vector<CSubTestData> vSubTests; /** process sub test(s) */
-};
-
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/commandlineengine/inc/CATProcessData.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,58 @@
+/*
+* 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:  Definitions for class CATParseTrace, CProcessData and
+*               CSubTestData.
+*
+*/
+
+#ifndef __CATPROCESSDATA_H__
+#define __CATPROCESSDATA_H__
+
+/**
+* Represents data of a single subtest.
+*/
+class CSubTestData : public CATAllocs
+{
+public:
+	// Members
+
+	bool bRunning; /** Is sub test running */
+	vector<string> vData; /** data */
+	string sSubTestName; /** test name */
+	string sStartTime; /** start time */
+	string sEndTime; /** end time */
+	string sSubTestStartHandleCount; /** handle count at start */
+	string sSubTestEndHandleCount; /** handle count at end */
+};
+
+/**
+* Represents data of a single run.
+*/
+class CProcessData : public CATAllocs
+{
+public:
+	// Members
+
+	bool bProcessOnGoing; /** is process on going */
+	int iProcessID; /** process id (pid)*/
+	vector<string> vData; /** data */
+	vector<string> vHandleLeaks; /** handle leak(s) */
+	vector<CSubTestData> vSubTests; /** process sub test(s) */
+
+	// time at the start of the process - time stamp at the start of process
+	// in microseconds
+	unsigned __int64 iTimeSpan;
+};
+
+#endif
\ No newline at end of file
--- a/analyzetool/commandlineengine/inc/CATProject.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/inc/CATProject.h	Wed Sep 15 13:53:27 2010 +0300
@@ -21,6 +21,7 @@
 
 #include "ATCommonDefines.h"
 #include "CATBase.h"
+#include "../inc/CATParseBinaryFile.h"
 
 class CATModule2;
 class CATDatParser;
@@ -127,6 +128,8 @@
 	*/
 	~CATProject();
 
+	CATParseBinaryFile Parser;
+
 	/**
 	* Set arguments.
 	* @param arguments.
@@ -191,6 +194,12 @@
 	void SetS60FileName( const string& sFileName);
 
 	/**
+	* Set S60 logging file path.
+	* @param sFilePath filename.
+	*/
+	void SetS60FilePath( const string& sFilePath );
+
+	/**
 	* Set target module.
 	* @param sTargetModule target module name.
 	*/
@@ -608,6 +617,8 @@
 	string m_sMakeFile;
 	// User given S60 log file name.
 	string m_sS60FileName;
+	// User given S60 log file path.
+	string m_sS60FilePath;
 	// Target module.
 	string m_sTargetModule;
 	// Target modules (used in carbide instrumenting).
@@ -620,6 +631,8 @@
 	vector<string> m_vRomSymbolFiles;
 	// Temporary data file name if user gave trace file.
 	string m_sDataFileTemp;
+	// Temporary data file name if user gave binary log file.
+	string m_sBinaryLogFileTemp;
 	// User given output file to store analyse results.
 	string m_sDataFileOutput;
 	// Analyser object.
--- a/analyzetool/commandlineengine/inc/catalloc.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/inc/catalloc.h	Wed Sep 15 13:53:27 2010 +0300
@@ -50,6 +50,8 @@
 
 	string m_sSize; /** Allocation size */
 
+	string m_iThreadId; /** Thread id*/
+
 	unsigned long m_iCSCount; /** Call stack address count */
 
 	map<unsigned long,string> m_vCallStack; /** Call stack where packet number is key */
--- a/analyzetool/commandlineengine/inc/catallocs.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/inc/catallocs.h	Wed Sep 15 13:53:27 2010 +0300
@@ -40,13 +40,25 @@
 	* Alloc header message (multimessage call stack).
 	* @param sAllocHString allocation string
 	*/
-	void AllocH( const string& sAllocHString );
+	void AllocH( const string& sAllocHString, const string& aTimeString );
 
 	/*
 	* Alloc fragment message (fragment of call stack in multimessage alloc).
 	* @param sAllocFString allocation string
 	*/
-	void AllocF( const string& sAllocFString );
+	void AllocF( const string& sAllocFString, const string& aTimeString );
+
+    /*
+	* Realloc header message (multimessage call stack).
+	* @param sReallocHString allocation string
+	*/
+	void ReallocH( const string& sReallocHString, const string& aTimeString );
+
+	/*
+	* Relloc fragment message (fragment of call stack in multimessage alloc).
+	* @param sReallocFString allocation string
+	*/
+	void ReallocF( const string& sReallocFString, const string& aTimeString );
 
 	/**
 	* Free message.
@@ -59,14 +71,14 @@
 	* (not implemented yeat.)
 	* @param sFreeHString string
 	*/
-	void FreeH( const string& sFreeHString );
+	void FreeH( const string& sFreeHString, const string& aTimeString );
 
 	/**
 	* Free fragment message.
 	* (not implemented yeat.)
 	* @param sFreeFString string
 	*/
-	void FreeF( const string& sFreeFString );
+	void FreeF( const string& sFreeFString, const string& aTimeString );
 
 	/**
 	* Get "leak" list ordered by allocation time.
Binary file analyzetool/commandlineengine/install/atool.exe has changed
--- a/analyzetool/commandlineengine/src/CATBase.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/CATBase.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -144,7 +144,7 @@
 {
 	LOG_LOW_FUNC_ENTRY("CATBase::GetPathOrFileName");
 	string sRet;
-	size_t iPos = sInput.size();
+	size_t iPos = sInput.size()-1;
 
 	sInput = ChangeSlashToBackSlash( sInput );
 
@@ -228,6 +228,30 @@
 }
 
 // -----------------------------------------------------------------------------
+// CATBase::GetStringUntilMainId
+// Function returns string from begin of given string until next atool's main id <AT>,
+// characters until next main id are removed from sInput string.
+// -----------------------------------------------------------------------------
+string CATBase::GetStringUntilMainId( string& sInput, bool bEraseFromInput )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::GetStringUntilMainId");
+	string sTemp( sInput );
+	size_t iSize = sTemp.find(MAIN_ID);
+	if( iSize != string::npos )
+	{
+		sTemp.resize( iSize );
+		if( bEraseFromInput )
+			sInput.erase( 0, (iSize) );
+	}
+	else
+	{
+		if ( bEraseFromInput )
+			sInput.clear();
+	}
+	return sTemp;
+}
+
+// -----------------------------------------------------------------------------
 // CATBase::ChangeSlashToBackSlash
 // Function changes all BackSlash characters to Slash character from
 // given string.
@@ -245,6 +269,73 @@
 	return sInput;
 }
 
+
+// -----------------------------------------------------------------------------
+// CATBase::ParseTimeStamp
+// Function returns time parsed from start of trace message
+// -----------------------------------------------------------------------------
+unsigned __int64 CATBase::ParseTimeStamp( string sLineStart )
+{
+	unsigned __int64 iTime(0);
+
+	int iHours(0), iMinutes(0), iSeconds(0), iMiliseconds(0), iMicroseconds(0);
+	int iErr(0), iRet(0);
+
+	TrimString( sLineStart );
+	string sTimeString = GetStringUntilNextSpace( sLineStart );
+
+	// Get time
+	int iPos = sTimeString.find( ":" );
+	if( iPos != string::npos ) // ':' found, this is timestamp from fastTrace/traceViewer 
+	{
+		// possible formats 
+		// hh:mm:ss - seconds (ft)
+        // hh:mm:ss:mmm - miliseconds (ft/tw)
+		// hh:mm:ss:mmmmmm - microseconds (ft/tw)
+		// hh:mm:ss:nnnnnnnnn - nanoseconds (ft) - ignore last 3digits
+
+		iRet = sscanf_s( sTimeString.c_str(), "%d:%d:%d.%3d%3d", &iHours, &iMinutes, &iSeconds, &iMiliseconds, &iMicroseconds );
+		if( iRet == 5 || iRet == 4 )
+		{
+			// get microseconds
+			iTime = ( ( ( iHours*60 + iMinutes )*60 + iSeconds )*1000 + iMiliseconds )*1000 + iMicroseconds;
+		}
+		else
+		{
+			iErr = true;
+		}
+	}
+	else if( sTimeString.find( "." ) != string::npos ) // epoc timestamp in format ssss.mmm
+	{
+		iRet = sscanf_s( sTimeString.c_str(), "%d.%d", &iSeconds, &iMiliseconds );
+		if( iRet == 2 )
+		{
+			// get microseconds
+			iTime = ( ( ( iHours*60 + iMinutes )*60 + iSeconds )*1000 + iMiliseconds )*1000 + iMicroseconds;
+		}
+		else
+		{
+			iErr = true;
+		}
+	}
+	else // timestamp in microseconds from binary log file or from ft
+	{
+		iRet = sscanf_s( sTimeString.c_str(), "%016I64x", &iTime);
+		if( iRet == 1 )
+		{
+		}
+		else
+		{
+			iErr = true;
+		}
+	}
+
+	if( iErr )
+		cout << "Error, can not read timestamp.\n";
+
+	return iTime;
+}
+
 // -----------------------------------------------------------------------------
 // CATBase::FileExists
 // Check if given file exists.
@@ -876,6 +967,7 @@
 bool CATBase::CreateTemporaryCpp( const string& sId,
 								 const string& sPath
 								 ,const string& sS60FileName
+								 ,const string& sS60FilePath
 								 ,int iLogOption
 								 ,int iIsDebug
 								 ,int iAllocCallStackSize
@@ -911,6 +1003,8 @@
 	out << "\nconst TInt ATTempFreeCallStackSize(" << iFreeCallStackSize << ");";
 	// Log file name
 	out << "\n_LIT( ATTempLogFileName, \"" << sS60FileName << "\" );";
+	// Log file path
+	out << "\n_LIT( ATTempLogFilePath, \"" << sS60FilePath << "\" );";
 	// Version number
 	out << "\n_LIT( ATTempVersion, \"" << ATOOL_COMPATIBILITY_STRING << "\" );";
 	// Variable functions use enumeration values that are defined in memoryhook (customuser.h)
@@ -924,7 +1018,8 @@
             ELogOption = 3,
             EDebug = 4,
             EAllocCallStackSize = 5,
-            EFreeCallStackSize = 6
+            EFreeCallStackSize = 6,
+			ELogFilePath = 7
             };
 */
 	out << "\nTInt GetInt( const TUint8 aType )";
@@ -944,6 +1039,7 @@
 	out << "\n{";
 	out << "\ncase 1: return ATTempLogFileName();";
 	out << "\ncase 2: return ATTempVersion();";
+	out << "\ncase 7: return ATTempLogFilePath();";
 	out << "\ndefault: return KNullDesC();";
 	out << "\n}";
 	out << "\n}";
@@ -955,15 +1051,24 @@
 	out << sS60FileName;
 	out << "\" );\n";
 
+	out << "\n_LIT( KFilePath, \"";
+	out << sS60FilePath;
+	out << "\" );\n";
+
 	// Hardcoded version number for support.
 	out << "\n/* The AnalyzeTool version number used. */";
-	out << "\n_LIT( KAtoolVersion, \"1.7.5;1.9.1\" );\n";
+	out << "\n_LIT( KAtoolVersion, \"1.7.6;1.10.0\" );\n";
 
 	out << "\nconst TFileName LogFileName()";
 	out << "\n    {";
 	out << "\n    return TFileName( KFileName() );";
 	out << "\n    }";
 
+	out << "\nconst TPath LogFilePath()";
+	out << "\n    {";
+	out << "\n    return TPath( KFilePath() );";
+	out << "\n    }";
+
 	out << "\nTUint32 AllocCallStackSize()";
 	out << "\n    {";
 	out << "\n    return TUint32( ";
@@ -1034,6 +1139,36 @@
 		return false;
 }
 
+// -----------------------------------------------------------------------------
+// CATBase::IsBinaryLogFile
+// -----------------------------------------------------------------------------
+bool CATBase::IsBinaryLogFile( string sFile )
+{
+	LOG_FUNC_ENTRY("CATBase::IsDataFile");
+	// Check that sFile not empty
+	if ( sFile.empty() || sFile.length() < 1 )
+		return false;
+
+	// Temporary line char array.
+	char cLineFromFile[MAX_LINE_LENGTH];
+	//Open file
+	ifstream in( sFile.c_str() );
+
+	//File open ok?
+	if( !in.good() )
+		return false;
+
+	//Read all lines
+	in.getline( cLineFromFile, MAX_LINE_LENGTH );
+
+	string sLineFromFile( cLineFromFile );
+	in.close();
+
+	if( sLineFromFile.find( "ATOOL_BINARY_FILE_VERSION" ) != string::npos )
+		return true;
+	else
+		return false;
+}
 
 // -----------------------------------------------------------------------------
 // CATBase::ParseStringToVector
--- a/analyzetool/commandlineengine/src/CATDatParser.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/CATDatParser.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -364,7 +364,7 @@
 	string sPid = GetStringUntilNextSpace( sLine );
 	m_iCurrentProcessId = _httoi( sPid.c_str() );
 
-	// Header for process tart
+	// Header for process start
 	m_DataSaver.AddString( "\n--------------------------------\n" );
 	m_DataSaver.AddString( "Test Run start (" );
 	m_DataSaver.AddString( m_sCurrentProcessName.c_str() );
@@ -515,10 +515,13 @@
 			for( size_t i = 0 ; i < m_vHandleLeaks.size() ; i++ )
 			{
 				string sTempHandleLeak( m_vHandleLeaks[i] );
-				// Name.
-				string sHandleLeakModule( GetStringUntilNextSpace( sTempHandleLeak ) );
 				// Count.
 				string sNrOfLeaks( GetStringUntilNextSpace(sTempHandleLeak) );
+
+				// Name.
+				//string sHandleLeakModule( GetStringUntilNextSpace( sTempHandleLeak ) );
+				string sHandleLeakModule( "Unknown" );
+
 				unsigned long iNrOfLeaks = _httoi( sNrOfLeaks.c_str() );
 				iTotalNrOfLeaks += iNrOfLeaks;
 				if( iNrOfLeaks )
@@ -598,15 +601,6 @@
 	if ( _stricmp( "winscw", m_sProjectPlatform.c_str() ) == 0 )
 		CreateWinscwModule( structDllInfo.sModuleName );
 
-	if ( m_iDataVersion >= AT_DLL_TIMESTAMP_DATA_VERSION )
-	{
-		// Pickup module loading time.
-		string sLoadTime = GetStringUntilNextSpace( sLine );
-		unsigned long long ull;
-		if ( hexToDec( sLoadTime, ull ) )
-			structDllInfo.iLoadTime = ull;
-	}
-
 	// Get dll start memory string address from line
 	// Convert string address to real memory address
 	structDllInfo.iStartAddress = 
@@ -618,6 +612,15 @@
 		_httoi( 
 		GetStringUntilNextSpace( sLine ).c_str() );
 
+	if ( m_iDataVersion >= AT_DLL_TIMESTAMP_DATA_VERSION )
+	{
+		// Pickup module loading time.
+		string sLoadTime = GetStringUntilNextSpace( sLine );
+		unsigned long long ull;
+		if ( hexToDec( sLoadTime, ull ) )
+			structDllInfo.iLoadTime = ull;
+	}
+
 	// Is module already loaded, if not add it to list.
 	bool bFound = false;
 	for( vector<DLL_LOAD_INFO>::iterator it = m_vDllLoadModList.begin();
@@ -669,6 +672,10 @@
 	string sModuleName = GetStringUntilNextSpace( sLine );
 	ChangeToLower( sModuleName );
 
+	// skip adresses - not currently used
+	GetStringUntilNextSpace( sLine );
+	GetStringUntilNextSpace( sLine );
+
 	// Unload time
 	unsigned long long ull;
 	string sUnload = GetStringUntilNextSpace( sLine );
--- a/analyzetool/commandlineengine/src/CATModule2.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/CATModule2.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -27,6 +27,7 @@
 {
 	LOG_FUNC_ENTRY("CATModule2::CATModule2");
 	m_bAddressToLineInitialized = false;
+	m_bS60FileNameResolved = false;
 	m_pAddressToLine = 0;
 	m_sErrors = "";
 	m_sMakeFile = "";
@@ -333,25 +334,37 @@
 	}
 }
 bool CATModule2::CreateTempCpp(const string& sS60FileName
+							        , const string& sS60FilePath
 									, int eLoggingMode
 									, int eBuildType
 									, int iAllocCallStackSize
 									, int iFreeCallStackSize )
 {
 	LOG_FUNC_ENTRY("CATModule2::CreateTemporaryCpp");
-	// S60 filename
-	m_sS60FileName = sS60FileName;
+
 	// Make s60 filename target.type.dat if its empty and logging mode is file
-	if ( eLoggingMode == CATProject::FILE
-		&& m_sS60FileName.empty() )
+	if ( eLoggingMode == CATProject::FILE )
 	{
-		m_sS60FileName = m_sTarget;
-		m_sS60FileName.append(".");
-		m_sS60FileName.append( m_sTargetType );
-		m_sS60FileName.append(".dat");
+		// S60 filename
+		SetS60FileName( sS60FileName );
+		
+		// S60 filepath
+		// use double slashes in temp cpp file
+		m_sS60FilePath = sS60FilePath;
+		int iIgnore(0);
+		size_t iPos = m_sS60FilePath.find("\\", iIgnore );
+		while( iPos != string::npos )
+		{
+			m_sS60FilePath.replace( iPos, 1, "\\\\" );
+			// dont replace previously replaced slashes
+			iIgnore = iPos + 2;
+			iPos = m_sS60FilePath.find("\\", iIgnore );
+		}
+
+
 	}
 	return CreateTemporaryCpp( GetUniqueId(), m_sTempPath,
-		m_sS60FileName, eLoggingMode, eBuildType, iAllocCallStackSize, iFreeCallStackSize );
+		m_sS60FileName, m_sS60FilePath, eLoggingMode, eBuildType, iAllocCallStackSize, iFreeCallStackSize );
 }
 
 bool CATModule2::ModifyMmp()
@@ -1286,15 +1299,46 @@
 string CATModule2::GetS60FileName() const
 {
 	LOG_LOW_FUNC_ENTRY("CATModule2::GetS60FileName");
+	return m_sS60FileName;
+}
+
+void CATModule2::SetS60FileName( const string& aFileName  )
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::SetS60FileName");
+
+	m_sS60FileName = aFileName;
+
+	//check new m_sS60FileName and change it if needed
+	string sProcessName = "";
+	sProcessName.append( m_sTarget );
+	sProcessName.append(".");
+	sProcessName.append( m_sTargetType );
+		
 	if ( m_sS60FileName.empty() )
 	{
-		string sGeneratedDatName = m_sTarget;
-		sGeneratedDatName.append(".");
-		sGeneratedDatName.append( m_sTargetType );
-		sGeneratedDatName.append(".dat");
-		return sGeneratedDatName;
+		m_sS60FileName = sProcessName;
+		m_sS60FileName.append(".dat");
 	}
-	return m_sS60FileName;
+	else
+	{
+		// if data file name contains %processname% string, replace it with process name
+		string sProcessnameTemp = "[";
+		sProcessnameTemp.append( sProcessName );
+		sProcessnameTemp.append( "]" );
+		size_t iSpot;
+
+		//create temp name in lowercase
+		string sS60FileNameLower = m_sS60FileName;
+		ChangeToLower( sS60FileNameLower );
+
+		// find %processname% string in lowercase name, replace it with process name in in m_sS60FileName
+		// replace it also in temp string (matching indexes)
+		while( ( iSpot = sS60FileNameLower.find( AT_PROCESSNAME_TAG ) ) != string::npos )
+		{
+			m_sS60FileName.replace( iSpot, AT_PROCESSNAME_TAG.length(), sProcessnameTemp );
+			sS60FileNameLower.replace( iSpot, AT_PROCESSNAME_TAG.length(), sProcessnameTemp );
+		}
+    }
 }
 
 string CATModule2::GetLstNameOfSource(string sSource) const
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/commandlineengine/src/CATParseBinaryFile.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,734 @@
+/*
+* 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:  Definitions for the class CATParseTraceFile.
+*
+*/
+
+
+#include "../inc/ATCommonDefines.h"
+#include "../inc/CATParseBinaryFile.h"
+#include "../inc/catdatasaver.h"
+#include "../inc/CATDatParser.h"
+#include "../inc/CATProcessData.h"
+
+#include <time.h>
+
+
+
+// -----------------------------------------------------------------------------
+// CATParseBinaryFile::CATParseTraceFile
+// Constructor.
+// -----------------------------------------------------------------------------
+CATParseBinaryFile::CATParseBinaryFile()
+{
+	LOG_FUNC_ENTRY("CATParseTraceFile::CATParseTraceFile");
+	m_DataSaver.SetPrintFlag( false );
+}
+
+// -----------------------------------------------------------------------------
+// CATParseBinaryFile::StartParse
+// Main function to start trace parsing.
+// -----------------------------------------------------------------------------
+bool CATParseBinaryFile::StartParse( const char* pFileName, const char* pOutputFileName )
+{
+	LOG_FUNC_ENTRY("CATParseTraceFile::StartParse");
+
+	// Return value, will be changed to true if process start found.
+	bool bRet = false;
+
+	// Check pointers
+	if ( pFileName == NULL  )
+		return bRet;
+
+
+	if ( ! FileExists( pFileName ) )
+	{
+		cout << AT_MSG << "Error, input file \""
+			<< pFileName
+			<< "\" does not exist." << endl;
+		return bRet;
+	}
+
+	// Open input and output file
+	ifstream in( pFileName, ios::binary );
+	ofstream sDataToParse( pOutputFileName );
+
+	// Check file opened ok
+	if ( !in.good() )
+		return false;
+
+	// Get stream size
+	size_t streamPos = in.tellg();
+	in.seekg( 0, ios::end);
+	size_t streamEnd = in.tellg();
+	in.seekg( 0, ios::beg );
+
+	//Origianl characters (not filtered).
+
+	unsigned char cDataFromFile[MAX_LINE_LENGTH];
+
+	bool bProcessEndReached = false;
+	bool bError = false;
+
+	char messageType = 0;
+	unsigned __int64 messageTime = 0;
+
+	unsigned long iProcessId(0);
+	int iAddressCount(0);
+	string sTemp;
+
+	//first parse version info
+	GetString( cDataFromFile, in, streamPos, streamEnd );
+	//todo check if version is correct	
+
+	while( !bError && !bProcessEndReached )
+	{
+		// get time
+		if( !GetNum64( cDataFromFile, in, streamPos, streamEnd ) )
+		{
+			bError = true;
+			break;
+		}
+		messageTime = StringToNum64( cDataFromFile );
+
+		// get message type
+		if( !GetNum8( cDataFromFile, in, streamPos, streamEnd ) )
+		{
+			bError = true;
+			break;
+		}
+		messageType = (int)cDataFromFile[0];
+
+		switch (messageType)
+		{
+			case EProcessStart:
+				{
+				//temp string to store data until we get to processID
+				sTemp.clear();
+
+                //PCS MemoryLeaker.exe[edf5a8b2]0001 17b 48939b0f5c04f 1 3 1.10.0 1.7.5
+				sTemp.append( LABEL_PROCESS_START );
+				sTemp.append( " " );
+
+				// get process name
+				if( !GetString( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+
+				sTemp.append( (char *)cDataFromFile );
+				sTemp.append( " " );
+
+				//get process id
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+			    {
+					bError = true;
+					break;
+				}
+				iProcessId = StringToNum32(cDataFromFile);
+
+				// write stored data
+				sDataToParse << std::hex << messageTime;
+				sDataToParse << " ";
+				sDataToParse << MAIN_ID;
+				sDataToParse << " ";
+				sDataToParse << std::hex << iProcessId;
+				sDataToParse << " ";
+				sDataToParse << sTemp;
+				sDataToParse <<  std::hex << iProcessId;
+				sDataToParse << " ";
+
+				//write time
+				sDataToParse <<  std::hex << messageTime;
+				sDataToParse << " ";
+
+				//get udeb/urel
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::dec << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				//add trace version - TODO check
+				sDataToParse <<  std::dec << 3;
+				sDataToParse << " ";
+
+				// get atool version
+				if( !GetString( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse << (char *)cDataFromFile;
+				sDataToParse << " ";
+
+				// get api version
+				if( !GetString( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse << (char *)cDataFromFile;
+				sDataToParse << "\n";
+
+				//process start found
+				bRet = true;
+
+				}
+				break;
+
+			case EProcessEnd:
+				{
+				sDataToParse << messageTime;
+				sDataToParse << " ";
+				sDataToParse << MAIN_ID;
+				sDataToParse << " ";
+				sDataToParse << iProcessId;
+				sDataToParse << " ";
+				//PCE
+				sDataToParse << LABEL_PROCESS_END ;
+				sDataToParse << "\n";
+				bProcessEndReached = true;
+				}
+				break;
+
+			case EDllLoad:
+				{
+				sDataToParse << std::hex << messageTime;
+				sDataToParse << " ";
+				sDataToParse << MAIN_ID;
+				sDataToParse << " ";
+				sDataToParse << iProcessId;
+				sDataToParse << " ";
+				//DLL AToolMemoryLeakerDll3.dll 3ff80000 3ff92000
+				sDataToParse << LABEL_DLL_LOAD ;
+				sDataToParse << " ";
+
+				// get dll name
+				if( !GetString( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse << (char *)cDataFromFile;
+				sDataToParse << " ";
+
+				// get start address
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				// get end address
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << "\n";
+				}
+				break;
+			
+			case EDllUnload:
+				{
+				sDataToParse << messageTime;
+				sDataToParse << " ";
+				sDataToParse << MAIN_ID;
+				sDataToParse << " ";
+				sDataToParse << iProcessId;
+				sDataToParse << " ";
+				//DLU AToolMemoryLeakerDll3.dll 3ff80000 3ff92000
+				sDataToParse << LABEL_DLL_UNLOAD ;
+				sDataToParse << " ";
+
+				// get dll name
+				if( !GetString( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse << (char *)cDataFromFile;
+				sDataToParse << " ";
+
+				// get start address
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				// get end address
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << "\n";
+				}
+				break;
+
+			case EAllocH:
+				{
+				sDataToParse << messageTime;
+				sDataToParse << " ";
+				sDataToParse << MAIN_ID;
+				sDataToParse << " ";
+				sDataToParse << iProcessId;
+				sDataToParse << " ";
+				//ALH 5a7a6734 5c 17c 11 6003ded4 60010df2 40001bff 40001c39 ...
+				// no fragments in log file
+				sDataToParse << ALLOCH_ID ;
+				sDataToParse << " ";
+
+				// get mam address
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				// get size of allocation
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				// get thread id
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				// get address count
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				int iAddressCount = StringToNum32(cDataFromFile);
+				sDataToParse <<  std::hex << iAddressCount;
+
+				// get callstack
+				for(int i=0; i<iAddressCount; i++)
+				{
+					sDataToParse << " ";
+					if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+					{
+						bError = true;
+						break;
+					}
+				    sDataToParse <<  std::hex << StringToNum32(cDataFromFile); 
+				}
+				sDataToParse << "\n";
+				}
+				break;
+
+			case EFreeH:
+				{
+				sDataToParse << std::hex <<messageTime;
+				sDataToParse << " ";
+				sDataToParse << MAIN_ID;
+				sDataToParse << " ";
+				sDataToParse << iProcessId;
+				sDataToParse << " ";
+				//FRH 5a7a679c 17c 0 (6003ded4 60010df2 40001bff 40001c39 ...)
+				// no fragments in log file
+				sDataToParse << FREEH_ID ;
+				sDataToParse << " ";
+
+				// get mem address
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				// get thread id
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				// get address count
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				iAddressCount = StringToNum32(cDataFromFile);
+				sDataToParse <<  std::hex << iAddressCount;
+
+				// get callstack
+				for(int i=0; i<iAddressCount; i++)
+				{
+					sDataToParse << " ";
+					if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+					{
+						bError = true;
+						break;
+					}
+				    sDataToParse <<  std::hex << StringToNum32(cDataFromFile); 
+				}
+				sDataToParse << "\n";
+
+				break;
+
+			case EReallocH:
+				sDataToParse << std::hex << messageTime;
+				sDataToParse << " ";
+				sDataToParse << MAIN_ID;
+				sDataToParse << " ";
+				sDataToParse << iProcessId;
+				sDataToParse << " ";
+				// RAH 0 5a7a6f30 30 17c 17 6003e02b 60010ef8 600083e5 ...
+				// no fragments in log file
+				sDataToParse << REALLOCH_ID ;
+				sDataToParse << " ";
+
+				// get freed mem address
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				// get allocated mem address
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				// get size of allocation
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				// get thread id
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << " ";
+
+				// get address count
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				iAddressCount = StringToNum32(cDataFromFile);
+				sDataToParse <<  std::hex << iAddressCount;
+
+				// get callstack
+				for(int i=0; i<iAddressCount; i++)
+				{
+					sDataToParse << " ";
+					if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+					{
+						bError = true;
+						break;
+					}
+				    sDataToParse <<  std::hex << StringToNum32(cDataFromFile); 
+				}
+				sDataToParse << "\n";
+				}
+				break;
+
+			case EHandleLeak:
+				{
+				sDataToParse << std::hex << messageTime;
+				sDataToParse << " ";
+				sDataToParse << MAIN_ID;
+				sDataToParse << " ";
+				sDataToParse << iProcessId;
+				sDataToParse << " ";
+				//HDL handleLeakCount
+				sDataToParse << LABEL_HANDLE_LEAK ;
+				sDataToParse << " ";
+
+				//get handle leak count
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << "\n";
+				}
+				break;
+
+			case EThreadStart:
+				{
+				sDataToParse << std::hex << messageTime;
+				sDataToParse << " ";
+				sDataToParse << MAIN_ID;
+				sDataToParse << " ";
+				sDataToParse << iProcessId;
+				sDataToParse << " ";
+				// TDS 17c
+				sDataToParse << LABEL_THREAD_START;
+				sDataToParse << " ";
+
+				// get thread ID
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << "\n";
+				}
+				break;
+
+			case EThreadEnd:
+				{
+				sDataToParse << std::hex << messageTime;
+				sDataToParse << " ";
+				sDataToParse << MAIN_ID;
+				sDataToParse << " ";
+				sDataToParse << iProcessId;
+				sDataToParse << " ";
+				// TDE 17c
+				sDataToParse << LABEL_THREAD_END;
+				sDataToParse << " ";
+
+				// get thread ID
+				if( !GetNum32( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				sDataToParse <<  std::hex << StringToNum32(cDataFromFile);
+				sDataToParse << "\n";
+				}
+				break;
+
+			case EDeviceInfo:
+				{
+				// DEVINFO swVersion  romChecksum //both are descriptors
+				sDataToParse << std::hex << messageTime;
+				sDataToParse << " ";
+				sDataToParse << MAIN_ID;
+				sDataToParse << " ";
+
+				sDataToParse << LABEL_DEVICE_INFO;
+				sDataToParse << " ";
+
+				// get swVersion
+				if( !GetString( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}			
+				sDataToParse << (char *)cDataFromFile;
+				sDataToParse << " ";
+
+				// todo check
+				// get romChecksum
+				if( !GetString( cDataFromFile, in, streamPos, streamEnd ) )
+				{
+					bError = true;
+					break;
+				}
+				
+				sDataToParse << (char *)cDataFromFile;
+				sDataToParse << "\n";
+				}
+				break;
+
+			case EError:
+				//currently not used
+				break;
+			case ETestStart:
+			case ETestEnd:
+				// currently can not occure in bin log file, this is added from carbide in traces
+				break;
+			default:
+				bError = true;
+				break;				
+		}
+	}
+
+	// Close file.
+	in.close();
+
+	sDataToParse.close();
+	return !bError;
+}
+
+// -----------------------------------------------------------------------------
+// CATParseBinaryFile::GetDataSaver
+// Gets data saver object.
+// -----------------------------------------------------------------------------
+CATDataSaver* CATParseBinaryFile::GetDataSaver(void)	
+{
+	LOG_LOW_FUNC_ENTRY("CATParseTraceFile::GetDataSaver");
+	return &m_DataSaver;
+}
+
+// -----------------------------------------------------------------------------
+// CATParseBinaryFile::StringToNum64
+// Gets 64bit number from input string
+// -----------------------------------------------------------------------------
+unsigned __int64 CATParseBinaryFile::StringToNum64( unsigned char* cVal )
+{
+	unsigned __int64 iRetVal(0);
+
+	for(int i=7; i>=0; i--)
+		iRetVal = ( iRetVal << 8 ) + cVal[i];
+
+	return iRetVal;
+}
+
+// -----------------------------------------------------------------------------
+// CATParseBinaryFile::StringToNum32
+// Gets 32bit number from input string
+// -----------------------------------------------------------------------------
+unsigned long CATParseBinaryFile::StringToNum32( unsigned char* cVal )
+{
+	unsigned long iRetVal(0);
+
+	for(int i=4; i>=0; i--)
+		iRetVal = ( iRetVal << 8 ) + cVal[i];
+
+	return iRetVal;
+}
+
+// -----------------------------------------------------------------------------
+// CATParseBinaryFile::GetString
+// Get next string from file
+// -----------------------------------------------------------------------------
+bool CATParseBinaryFile::GetString( unsigned char* pData, ifstream &pIn, size_t &pStreamPos, size_t pStreamEnd )
+{
+	int	numOfRead = 1;
+	if(pStreamPos + numOfRead <= pStreamEnd)
+	{
+		pIn.read((char*)pData, numOfRead);
+		pStreamPos = pIn.tellg();
+	}
+	else
+	{
+		return false;
+	}
+
+	numOfRead = (int)pData[0] >> 2;
+	if(pStreamPos + numOfRead <= pStreamEnd)
+	{
+		pIn.read((char*)pData, numOfRead);
+		pStreamPos = pIn.tellg();
+		pData[numOfRead] = 0;
+	}
+	else
+	{
+		return false;
+	}
+
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATParseBinaryFile::GetNum8
+// Get next 8bit number from file
+// -----------------------------------------------------------------------------
+bool CATParseBinaryFile::GetNum8( unsigned char* pData, ifstream &pIn, size_t &pStreamPos, size_t pStreamEnd )
+{
+	int	numOfRead = 1;
+	if(pStreamPos + numOfRead <= pStreamEnd)
+	{
+		pIn.read((char*)pData, numOfRead);
+		pStreamPos = pIn.tellg();
+	}
+	else
+	{
+		return false;
+	}
+
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATParseBinaryFile::GetNum32
+// Get next 32bit number from file
+// -----------------------------------------------------------------------------
+bool CATParseBinaryFile::GetNum32( unsigned char* pData, ifstream &pIn, size_t &pStreamPos, size_t pStreamEnd )
+{
+	int	numOfRead = 4;
+	if(pStreamPos + numOfRead <= pStreamEnd)
+	{
+		pIn.read((char*)pData, numOfRead);
+		pStreamPos = pIn.tellg();
+	}
+	else
+	{
+		return false;
+	}
+
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATParseBinaryFile::GetNum64
+// Get next 64bit number from file
+// -----------------------------------------------------------------------------
+bool CATParseBinaryFile::GetNum64( unsigned char* pData, ifstream &pIn, size_t &pStreamPos, size_t pStreamEnd )
+{
+	int	numOfRead = 8;
+	if(pStreamPos + numOfRead <= pStreamEnd)
+	{
+		pIn.read((char*)pData, numOfRead);
+		pStreamPos = pIn.tellg();
+	}
+	else
+	{
+		return false;
+	}
+
+	return true;
+}
+
+//EOF
--- a/analyzetool/commandlineengine/src/CATParseTraceFile.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/CATParseTraceFile.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -20,28 +20,11 @@
 #include "../inc/CATParseTraceFile.h"
 #include "../inc/catdatasaver.h"
 #include "../inc/CATDatParser.h"
+#include "../inc/CATProcessData.h"
 
 #include <time.h>
 
-#define MAIN_ID "PCSS"
-#define ALLOC_ID "ALLOC" // < V.1.6 allocation.
-#define ALLOCH_ID "ALLOCH" // Header of multi message allocation.
-#define ALLOCF_ID "ALLOCF" // Fragment of multi message allocation.
-#define FREE_ID "FREE"
-#define FREEH_ID "FREEH" // Header of multi message free.
-#define FREEF_ID "FREEF" // Fragment of multi message free.
-#define HANDLE_LEAK_ID "HANDLE_LEAK"
 
-const string ERROR_OCCURED = "ERROR_OCCURED"; // Error messages.
-const string INCORRECT_ATOOL_VERSION = "INCORRECT_ATOOL_VERSION";
-/**
-* Invalid characters in trace file line content.
-* These will be filtered out before actuall parsing of line.
-10 = LF
-13 = CR
-124 = |
-*/
-const char cINVALID_TRACE_FILE_CHARS[] = { 10, 13, 124 };
 
 // -----------------------------------------------------------------------------
 // CATParseTraceFile::CATParseTraceFile
@@ -57,12 +40,13 @@
 // CATParseTraceFile::StartParse
 // Main function to start trace parsing.
 // -----------------------------------------------------------------------------
-bool CATParseTraceFile::StartParse( const char* pFileName, const char* pOutputFileName )
+bool CATParseTraceFile::StartParse( const char* pFileName, const char* pOutputFileName, const char* pCleanedTraceFile )
 {
 	LOG_FUNC_ENTRY("CATParseTraceFile::StartParse");
 
 	// Return value, will be changed to true if process start found.
 	bool bRet = false;
+	bool bCreateCleanedTraces = false;
 
 	// Check pointers
 	if ( pFileName == NULL  )
@@ -79,6 +63,24 @@
 		return bRet;
 	}
 
+	ofstream cleanedTraces;
+
+	// check is creation of file needed
+	if( pCleanedTraceFile != NULL )
+	{
+		// if yes open file for cleaned traces
+	    // (<AT> messages with cleaned timestamps)
+		bCreateCleanedTraces = true;
+
+		cleanedTraces.open(pCleanedTraceFile);
+
+		if( !cleanedTraces.good() )
+		{
+			printf( "Can not open file: %s\n", pCleanedTraceFile );
+			return bRet;
+		}
+	}
+
 	// Open data file
 	ifstream in( pFileName );
 
@@ -140,10 +142,17 @@
 		if( strstr( cLineFromFile, MAIN_ID ) != NULL )
 		{
 			string sRestOfLine( cLineFromFile );
-			string sTemp;
+			string sTemp("");
+			unsigned __int64 iTimeStamp(0);
+			string sTime("");
+			string sLineStart("");
 
-			// Delete all characters before main ID
-			sRestOfLine.erase( 0, sRestOfLine.find( MAIN_ID ) );
+			// Get part of line before main id. This should contain time info
+			sLineStart = GetStringUntilMainId( sRestOfLine );
+			// Get message's time stamp in microseconds
+			iTimeStamp = ParseTimeStamp( sLineStart );
+			// store whole line from MAIN_ID - to be logged to cleaned traces file
+		    string sLineToCleanedFile( sRestOfLine );
 
 			// Get main ID
 			sTemp = GetStringUntilNextSpace( sRestOfLine );
@@ -156,7 +165,7 @@
 
 			// Get next argument
 			sTemp = GetStringUntilNextSpace( sRestOfLine );
-			// This might be process id or error message
+			// This might be process id, device info message or error message
 			if ( sTemp.compare( ERROR_OCCURED ) == 0 )
 			{
 				// Api mismatch between s60 side and atool.exe
@@ -179,7 +188,31 @@
 					cout << sRestOfLine << endl;
 				continue;
 			}
+
+			if ( sTemp.compare( LABEL_DEVICE_INFO ) == 0 ) 
+			{
+
+				if( vProcessList[iProcessIDinList].bProcessOnGoing == false )
+				continue;
+
+				// get time string from timestamp
+			    sTime = GetTimeFromTimeStamp( iTimeStamp, vProcessList[iProcessIDinList].iTimeSpan );
+
+				// device info line, log it to cleaned file for carbide
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << LABEL_DEVICE_INFO << " "; //add Message type
+				cleanedTraces << sRestOfLine << "\n"; //add the rest of the line
+				}
+				continue;
+			}
+
 			unsigned long iProcessID = _httoi( sTemp.c_str() );
+			// todo to be removed when reallocations are implemented
+			string sProcessID = sTemp;
 
 			iProcessIDinList = -1;
 			// Find process from list
@@ -221,6 +254,26 @@
 				bRet = true; // Set return value true we found start.
 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
 				vProcessList[iProcessIDinList].bProcessOnGoing = true;
+
+				// remove <processName> <processID> part
+				GetStringUntilNextSpace( sRestOfLine );
+				GetStringUntilNextSpace( sRestOfLine );
+				// get time
+				sTemp = GetStringUntilNextSpace( sRestOfLine );
+				unsigned __int64 iTemp(0);
+				sscanf_s( sTemp.c_str(), "%016I64x", &iTemp);
+				//calculate span between PCS time and PCS timestamp
+				vProcessList[iProcessIDinList].iTimeSpan = iTemp - iTimeStamp;
+
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTemp << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
 				continue;
 			}
 
@@ -228,6 +281,13 @@
 			if( vProcessList[iProcessIDinList].bProcessOnGoing == false )
 				continue;
 
+			// get time string from timestamp
+			sTime = GetTimeFromTimeStamp( iTimeStamp, vProcessList[iProcessIDinList].iTimeSpan );
+
+			// TODO version with reallocation
+			//cleanedTraces << sTime << " "; //add time
+			//cleanedTraces << sLineToCleanedFile << "\n"; //add the rest of the line
+
 			// "Old style" allocation (< v.1.6)
 			if( ! _stricmp( pCommand, ALLOC_ID ) )
 			{
@@ -248,8 +308,17 @@
 			}
 			else if ( ! _stricmp( pCommand, ALLOCH_ID ) )
 			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
 				// Add alloc
-				vProcessList[iProcessIDinList].AllocH( sRestOfLine );
+				vProcessList[iProcessIDinList].AllocH( sRestOfLine, sTime );
 
 				// Subtests running?
 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
@@ -258,7 +327,7 @@
 					if( viSubTestIter->bRunning )
 					{
 						// Save alloc also to sub test
-						viSubTestIter->AllocH( sRestOfLine );
+						viSubTestIter->AllocH( sRestOfLine, sTime );
 					}
 					viSubTestIter++;
 				}
@@ -266,8 +335,17 @@
 			// Allocation fragment (call stack).
 			else if ( ! _stricmp( pCommand, ALLOCF_ID ) )
 			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
 				// Add alloc fragment
-				vProcessList[iProcessIDinList].AllocF( sRestOfLine );
+				vProcessList[iProcessIDinList].AllocF( sRestOfLine, sTime );
 				
 				// Subtests running?
 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
@@ -276,7 +354,164 @@
 					if( viSubTestIter->bRunning )
 					{
 						// Save alloc fragment also to sub test
-						viSubTestIter->AllocF( sRestOfLine );
+						viSubTestIter->AllocF( sRestOfLine, sTime );
+					}
+					viSubTestIter++;
+				}
+			}
+			else if ( ! _stricmp( pCommand, REALLOCH_ID ) )
+			{
+				// Add free
+
+				// get 'free' line from realloc line
+				string sFreeRestOfLine = sRestOfLine;
+				string sFreeLine = "";
+				sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address
+				sFreeLine.append( " " );
+				// next two strings are for 'alloc' (address and size) - lets remove them
+				GetStringUntilNextSpace( sFreeRestOfLine, true );
+				GetStringUntilNextSpace( sFreeRestOfLine, true );
+				// add rest of line to 'free' line
+				sFreeLine.append( sFreeRestOfLine );
+				//add 'free' line
+				vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime );
+
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				// construct 'free' header trace
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << FREEH_ID << " "; //add FRH
+				cleanedTraces << sFreeLine << "\n"; //add the rest of the line
+				}
+
+				// Add alloc
+
+				//get 'alloc' line from realloc line
+				// only first string is unnecessary, lets remove it
+				GetStringUntilNextSpace( sRestOfLine );
+     			// add 'alloc' line
+				vProcessList[iProcessIDinList].AllocH( sRestOfLine, sTime );
+
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				// construct 'alloc' header trace
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << ALLOCH_ID << " "; //add FRH
+				cleanedTraces << sRestOfLine << "\n"; //add the rest of the line
+				}
+
+				// Subtests running?
+				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
+				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
+				{
+					if( viSubTestIter->bRunning )
+					{
+						// Save realloc also to sub test
+						// Add free
+
+						// get 'free' line from realloc line
+						string sFreeRestOfLine = sRestOfLine;
+						string sFreeLine = "";
+						sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address
+						sFreeLine.append( " " );
+						// next two strings are for 'alloc' (address and size) - lets remove them
+						GetStringUntilNextSpace( sFreeRestOfLine, true );
+						GetStringUntilNextSpace( sFreeRestOfLine, true );
+						// add rest of line to 'free' line
+						sFreeLine.append( sFreeRestOfLine );
+						//add 'free' line
+						vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime );
+
+						// Add alloc
+
+						//get 'alloc' line from realloc line
+						// only first string is unnecessary, lets remove it
+						GetStringUntilNextSpace( sRestOfLine );
+     					// add 'alloc' line
+						vProcessList[iProcessIDinList].AllocH( sRestOfLine, sTime );
+					}
+					viSubTestIter++;
+				}
+			}
+			// rellocation fragment (call stack).
+			else if ( ! _stricmp( pCommand, REALLOCF_ID ) )
+			{
+				// Add free fragment 
+
+				// get 'free' line from realloc line
+				string sFreeRestOfLine = sRestOfLine;
+				string sFreeLine = "";
+				sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address
+				sFreeLine.append( " " );
+				// next string is for 'alloc' (address) - lets remove it
+				GetStringUntilNextSpace( sFreeRestOfLine, true );
+				// add rest of line to 'free' line
+				sFreeLine.append( sFreeRestOfLine );
+				//add 'free' line
+				vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime );
+
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				// construct 'free' fragment trace
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << FREEF_ID << " "; //add FRF
+				cleanedTraces << sFreeLine << "\n"; //add the rest of the line
+				}
+
+				// Add alloc fragment
+
+				// first string is for 'free' (address), lets remove it first
+				GetStringUntilNextSpace( sRestOfLine, true );
+				//add 'alloc' line
+				vProcessList[iProcessIDinList].AllocF( sRestOfLine, sTime );
+
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				// construct 'alloc' fragment trace
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << ALLOCF_ID << " "; //add FRF
+				cleanedTraces << sRestOfLine << "\n"; //add the rest of the line
+				}
+				
+				// Subtests running?
+				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
+				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
+				{
+					if( viSubTestIter->bRunning )
+					{
+						// Save alloc fragment also to sub test
+						// Add free fragment 
+
+						// get 'free' line from realloc line
+						string sFreeRestOfLine = sRestOfLine;
+						string sFreeLine = "";
+						sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address
+						sFreeLine.append( " " );
+						// next string is for 'alloc' (address) - lets remove it
+						GetStringUntilNextSpace( sFreeRestOfLine, true );
+						// add rest of line to 'free' line
+						sFreeLine.append( sFreeRestOfLine );
+						//add 'free' line
+						vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime );
+
+						// Add alloc fragment
+
+						// first string is for 'free' (address), lets remove it first
+						GetStringUntilNextSpace( sRestOfLine, true );
+						//add 'alloc' line
+						vProcessList[iProcessIDinList].AllocF( sRestOfLine, sTime );
 					}
 					viSubTestIter++;
 				}
@@ -302,8 +537,17 @@
 			// Header free.
 			else if( ! _stricmp( pCommand, FREEH_ID ) )
 			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
 				// Send free
-				vProcessList[iProcessIDinList].FreeH( sRestOfLine );
+				vProcessList[iProcessIDinList].FreeH( sRestOfLine, sTime );
 
 				// Subtests running?
 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
@@ -312,7 +556,7 @@
 					if( viSubTestIter->bRunning )
 					{
 						// Send free to subtest
-						viSubTestIter->FreeH( sRestOfLine );
+						viSubTestIter->FreeH( sRestOfLine, sTime );
 					}
 					viSubTestIter++;
 				}
@@ -320,11 +564,34 @@
 			}
 			else if( ! _stricmp( pCommand, FREEF_ID ) )
 			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
 				// Not used currently.
 			}
 			// Command process end
 			else if( ! _stricmp( pCommand, LABEL_PROCESS_END ) )
 			{
+				// append processID and time
+				sWholeTempLine.append(" ");
+				sWholeTempLine.append( sProcessID );
+				sWholeTempLine.append(" ");
+				sWholeTempLine.append( sTime );
+
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
 				// Set process has ended.
 				vProcessList[iProcessIDinList].bProcessOnGoing = false;
 
@@ -405,6 +672,15 @@
 			}
 			else if( ! _stricmp( pCommand, LABEL_HANDLE_LEAK ) )
 			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
 				// Make whole line
 				sTemp.append( " " );
 				sTemp.append( sRestOfLine );
@@ -412,6 +688,19 @@
 			}
 			else if( ! _stricmp( pCommand, LABEL_DLL_LOAD ) )
 			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
+				// append time to the end of the line
+				sWholeTempLine.append( " " );
+				sWholeTempLine.append( sTime );
+
 				// Add module load to process data.
 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
 				// Add module load to subtest data if test running.
@@ -425,6 +714,19 @@
 			}
 			else if( ! _stricmp( pCommand, LABEL_DLL_UNLOAD ) )
 			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
+				// append time to the end of the line
+				sWholeTempLine.append( " " );
+				sWholeTempLine.append( sTime );
+
 				// Add module load to process data.
 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
 				// Add module unload to subtest data if test running.
@@ -439,10 +741,28 @@
 				     sTemp.find( LABEL_PROCESS_END ) != string::npos || sTemp.find( LABEL_ERROR_OCCURED ) != string::npos ||
 					 sTemp.find( LABEL_HANDLE_LEAK ) != string::npos )
 			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
 			}
 			else if( ! _stricmp( pCommand, LABEL_TEST_START ) )
 			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
 				bRet = true; // Set return value true we found start.
 				// Get sub test time
 				string sSubTestTime = GetStringUntilNextSpace( sRestOfLine );
@@ -461,6 +781,15 @@
 			}
 			else if( ! _stricmp( pCommand, LABEL_TEST_END ) )
 			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
 				// Get sub test time
 				string sSubTestEnd = GetStringUntilNextSpace( sRestOfLine );
 				// Get sub test name
@@ -481,9 +810,53 @@
 					viSubTestIter++;
 				}
 			}
+			else if( ! _stricmp( pCommand, LABEL_THREAD_START ) )
+			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
+				//currently not used
+			}
+			else if( ! _stricmp( pCommand, LABEL_THREAD_END ) )
+			{
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+
+				//currently not used
+			}
+			else
+			{
+				// unknown tag, log it to cleaned file for carbide
+				if( bCreateCleanedTraces )
+				{
+				// add message to cleaned traces file
+				cleanedTraces << sTime << " "; //add time
+				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
+				cleanedTraces << sProcessID << " "; //add process ID
+				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
+				}
+			}
 		}
 	}
 
+	if( bCreateCleanedTraces )
+	{
+	// close stream
+	cleanedTraces.close();
+	}
+
 	// Print all saved data from processes
 	for( unsigned int i = 0 ; i < vProcessList.size() ; i++ )
 	{
@@ -582,4 +955,19 @@
 	LOG_LOW_FUNC_ENTRY("CATParseTraceFile::GetDataSaver");
 	return &m_DataSaver;
 }
+
+
+// -----------------------------------------------------------------------------
+// CATBase::GetTimeFromTimeStamp
+// Gets time from timestamp in microseconds as string
+// -----------------------------------------------------------------------------
+string CATParseTraceFile::GetTimeFromTimeStamp( unsigned __int64 iTimeStamp, unsigned __int64 iTimeSpan )
+{
+	unsigned __int64 iTime = iTimeStamp + iTimeSpan;
+	stringstream ss;
+	ss <<  std::hex << iTime;
+
+    return ss.str();
+}
+
 //EOF
--- a/analyzetool/commandlineengine/src/CATProject.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/CATProject.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -19,6 +19,7 @@
 #include "../inc/CATProject.h"
 #include "../inc/CATModule2.h"
 #include "../inc/CATParseTraceFile.h"
+#include "../inc/CATParseBinaryFile.h"
 #include "../inc/CATDatParser.h"
 
 //dbghelp.dll version function.
@@ -51,10 +52,12 @@
 	m_sDataFile = "";
 	m_sDataFileOutput = "";
 	m_sDataFileTemp = "";
+	m_sBinaryLogFileTemp = "";
 	m_sEpocRoot = "\\";
 	m_sMakeFile = "";
 	m_sPlatform = "";
 	m_sS60FileName = "";
+	m_sS60FilePath = "";
 	m_sTargetModule = "";
 	m_sVariant = "";
 
@@ -84,6 +87,14 @@
 		if ( FileExists( m_sDataFileTemp.c_str() ) )
 			FileDelete( m_sDataFileTemp, false );
 	}
+
+	// Temporary trace file
+	if ( !m_sBinaryLogFileTemp.empty() )
+	{
+		if ( FileExists( m_sBinaryLogFileTemp.c_str() ) )
+			FileDelete( m_sBinaryLogFileTemp, false );
+	}
+	
 }
 
 bool CATProject::SetArguments( ARGUMENTS& arguments )
@@ -180,10 +191,14 @@
 		bRet = false;
 	}
 
-	//Internal data file.
+	//Internal data file name.
 	if ( arguments.HOOK.bDataFileName )
 		SetS60FileName( arguments.HOOK.sDataFileName );
 
+	//Internal data file path.
+	if ( arguments.HOOK.bDataFilePath )
+		SetS60FilePath( arguments.HOOK.sDataFilePath );
+
 	//Build command.
 	if ( arguments.HOOK.sBuildCmd.empty() && ( 
 		GetMode() == CATProject::COMPILE ||
@@ -503,15 +518,45 @@
 {
 	LOG_FUNC_ENTRY("CATProject::RunAnalyze");
 
-	// Parse data file if it is trace.
+	// Parse data file if it is not data file.
 	if ( !IsDataFile( m_sDataFile ) )
 	{
 		m_sDataFileTemp.clear();
 		m_sDataFileTemp.append( m_sDataFile );
 		m_sDataFileTemp.append( ".atool" );
-		cout << AT_MSG << "Parsing trace file..." << endl;
+
+		// make filename for file with cleaned timestamps
+		// <m_sDataFile>.cleaned in the same place as output file
+		string sTraceFileCleaned( GetPathOrFileName( false, m_sDataFileOutput ) );
+		sTraceFileCleaned.append( GetPathOrFileName( true, m_sDataFile ) );
+		sTraceFileCleaned.append( ".cleaned" );
+
+		//check if it is binary log file
+		if( IsBinaryLogFile( m_sDataFile ) )
+		{
+			// convert binary log file to ASCII trace format
+			m_sBinaryLogFileTemp.clear();
+		    m_sBinaryLogFileTemp.append( m_sDataFile );
+		    m_sBinaryLogFileTemp.append( ".totraces" );
+
+			cout << AT_MSG << "Parsing binary data file..." << endl;
+
+			CATParseBinaryFile Parser;
+			stringstream dataToParse;
+			if ( ! Parser.StartParse( m_sDataFile.c_str(), m_sBinaryLogFileTemp.c_str() ) )
+			{
+				return AT_RETURN_CODE::EMPTY_DATA_FILE;
+			}
+			m_sDataFile = m_sBinaryLogFileTemp;
+			
+		}
+		else
+		{
+			cout << AT_MSG << "Parsing trace file..." << endl;
+		}
+
 		CATParseTraceFile Parser;
-		if ( ! Parser.StartParse( m_sDataFile.c_str(), m_sDataFileTemp.c_str() ) )
+		if ( ! Parser.StartParse( m_sDataFile.c_str(), m_sDataFileTemp.c_str(), sTraceFileCleaned.c_str() ) )
 		{
 			return AT_RETURN_CODE::EMPTY_DATA_FILE;
 		}
@@ -787,14 +832,17 @@
 			if ( m_eLoggingMode == CATProject::FILE 
 				&& m_vModules.at(i)->GetTargetType().compare("exe") == 0 )
 			{
-				if ( m_sS60FileName.empty() )
-					cout << AT_BUILD_SUMMARY_DATA_FILE_NAME
+				cout << AT_BUILD_SUMMARY_DATA_FILE_NAME
 						<< m_vModules.at(i)->GetS60FileName()
 						<< endl;
-				else
-					cout << AT_BUILD_SUMMARY_DATA_FILE_NAME
-					<< m_sS60FileName
+
+				// if filePath not empty, use it for log file
+				if ( !m_sS60FilePath.empty() )
+				{
+					cout << AT_BUILD_SUMMARY_DATA_FILE_PATH
+					<< m_sS60FilePath
 					<< endl;
+				}
 			}
 		}
 		else
@@ -1553,7 +1601,7 @@
 	for( size_t i = 0 ; i < m_vModules.size(); i++)
 	{
 		if( ! m_vModules.at(i)->CreateTempCpp(
-			m_sS60FileName, m_eLoggingMode, m_eBuildType, m_iAllocCallStackSize, m_iFreeCallStackSize ) )
+			m_sS60FileName, m_sS60FilePath, m_eLoggingMode, m_eBuildType, m_iAllocCallStackSize, m_iFreeCallStackSize ) )
 			bRet = false;
 	}
 	return bRet;
@@ -1955,6 +2003,7 @@
 		out << m_vTargetModules.at(i) << AT_PROJECT_ATTRIBUTES_SEPARATOR;
 	out << endl;
 	out << m_sBuildCommand << endl;
+	out << m_sS60FilePath << endl;
 	out.close();
 	return true;
 }
@@ -2010,6 +2059,7 @@
 		iSpot = sLine.find( AT_PROJECT_ATTRIBUTES_SEPARATOR );
 	}
 	in.getline( cLine, MAX_LINE_LENGTH ); m_sBuildCommand = cLine;
+	in.getline( cLine, MAX_LINE_LENGTH ); m_sS60FilePath = string( cLine );
 	in.close();
 	return true;
 }
@@ -2368,6 +2418,11 @@
 	LOG_FUNC_ENTRY("CATProject::SetS60FileName");
 	m_sS60FileName = sFileName;
 }
+void CATProject::SetS60FilePath( const string& sFilePath)
+{
+	LOG_FUNC_ENTRY("CATProject::SetS60FilePath");
+	m_sS60FilePath = sFilePath;
+}
 void CATProject::SetRomSymbolFiles(const vector<string>& vRomSymbolFiles)
 {
 	LOG_FUNC_ENTRY("CATProject::SetRomSymbolFiles");
--- a/analyzetool/commandlineengine/src/arguments.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/arguments.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -22,11 +22,13 @@
 bool parseAnalyzeArguments( vector<string>& vArgs, ARGUMENTS& args );
 bool parseParseArguments( vector<string>& vArgs, ARGUMENTS& args );
 bool checkDataFileName( string& sFileName );
+bool checkDataFilePath( string& sFilePath );
 bool parseSbsConfiguration( string& sConfiguration, ARGUMENTS& args );
 
 // Constants for old "hooking" parameter parsing.
 #define INVALID_PARAMETER "AnalyzeTool : Error, invalid parameter: "
-const char DATAFILENAME_INVALID_CHARS[] = " &^+-@$%*()|\\/[]{}<>?;:,\"'";
+const char DATAFILENAME_INVALID_CHARS[] = " &^+-@$*()|\\/[]{}<>?;:,\"'";
+const char DATAFILEPATH_INVALID_CHARS[] = " &^+-@$%*()|/[]{}<>?;,\"'";
 
 /**
 * Check datafile name for invalid characters.
@@ -44,6 +46,40 @@
 }
 
 /**
+* Check datafile path for invalid characters and correct format.
+* @return true if file path ok.
+*/
+bool checkDataFilePath( string& sFilePath )
+{
+	for ( size_t i = 0; i < sFilePath.length(); i++ )
+	{
+		char c = sFilePath.at( i );
+		if( strchr( DATAFILEPATH_INVALID_CHARS, c ) != 0 )
+			return false;
+		// first char must be drive letter a-z
+		if( i == 0 && ( c = tolower( c ) < 'a' || c > 'z' ) )
+			return false;
+		// if last char is not '\', add it
+		if( i == sFilePath.length()-1 &&  c != '\\' )
+			sFilePath.append( "\\" );
+	}
+
+	// ':\' after drive letter
+	if( sFilePath.find( ":\\" ) != 1 )
+		return false;
+
+	// there can be only one ':' on pos 1
+	if( sFilePath.find( ":", 2 ) != string::npos )
+		return false;
+
+	//check double slashes
+	if( sFilePath.find( "\\\\" ) != string::npos )
+		return false;
+
+	return true;
+}
+
+/**
 * Parse base arguments from given vector of strings.
 * Removes debug / help arguments from vector.
 */
@@ -178,16 +214,19 @@
 			args.eMainSwitch = SWITCH_HELP;
 		else if ( ! _stricmp( (*it).c_str(), "-me" ) )
 		{
-			args.eMainSwitch = SWITCH_HOOK;
-			args.eHookSwitch = HOOK_EXTERNAL;
+			cout << AT_MSG << "This feature is no longer supported. You can use -tr parameter for output to trace. \n" << endl;
 		}
-		else if ( ! _stricmp( (*it).c_str(), "-e" ) )
+		else if ( ! _stricmp( (*it).c_str(), "-e" ) ||  ! _stricmp( (*it).c_str(), "-tr" ) )
 		{
 			args.eMainSwitch = SWITCH_HOOK;
 			args.eHookSwitch = HOOK_EXTERNAL_FAST;
 		}
 		else if ( ! _stricmp( (*it).c_str(), "-mi" ) )
 		{
+			cout << AT_MSG << "This feature is no longer supported. You can use -lf parameter for logging to file. \n" << endl;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-lf" ) )
+		{
 			args.eMainSwitch = SWITCH_HOOK;
 			args.eHookSwitch = HOOK_INTERNAL;
 		}
@@ -355,7 +394,8 @@
 				}
 				else if ( ! _stricmp( it->c_str(), "sbs" ) 
 					|| ! _stricmp( it->c_str(), "abld" )
-					|| ! _stricmp( it->c_str(), "-f" ) )
+					|| ! _stricmp( it->c_str(), "-f" )
+					|| ! _stricmp( it->c_str(), "-fp" ) )
 				{
 					bRet = false;
 					cout << AT_MSG << "Error, missing call stack size parameter." << endl;
@@ -407,13 +447,13 @@
 				if ( it == vArgs.end() )
 				{
 					bRet = false;
-					cout << AT_MSG << "Error, missing internal data gathering file name." << endl;
+					cout << AT_MSG << "Error, missing log file name." << endl;
 					break;
 				}
 				else if ( ! _stricmp( it->c_str(), "sbs" ) || ! _stricmp( it->c_str(), "abld" ) )
 				{
 					bRet = false;
-					cout << AT_MSG << "Error, missing internal data gathering file name." << endl;
+					cout << AT_MSG << "Error, missing log file name." << endl;
 					break;
 				}
 				else
@@ -427,7 +467,41 @@
 					else
 					{
 						bRet = false;
-						cout << AT_MSG << "Error, specified internal data gathering file name contains invalid character(s)." << endl;
+						cout << AT_MSG << "Error, specified log file name contains invalid character(s)." << endl;
+						break;
+					}
+				}
+			}
+			// Data file path.
+			else if ( _stricmp( it->c_str(), "-fp" ) == 0 )
+			{
+				it++;
+				if ( it == vArgs.end() )
+				{
+					bRet = false;
+					cout << AT_MSG << "Error, missing path for log file." << endl;
+					break;
+				}
+				else if ( ! _stricmp( it->c_str(), "sbs" ) || ! _stricmp( it->c_str(), "abld" ) )
+				{
+					bRet = false;
+					cout << AT_MSG << "Error, missing path for log file." << endl;
+					break;
+				}
+				else
+				{
+					string sFormattedPath = string(*it);
+					if ( checkDataFilePath( sFormattedPath ) )
+					{
+						// Pickup filename.
+						args.HOOK.bDataFilePath = true;
+						args.HOOK.sDataFilePath = sFormattedPath;
+					}
+					else
+					{
+						bRet = false;
+						cout << AT_MSG << "Error, specified log file path contains invalid character(s) "
+							<< "or is in wrong format. Please, check help for correct format," << endl;
 						break;
 					}
 				}
--- a/analyzetool/commandlineengine/src/atool.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/atool.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -207,6 +207,12 @@
 				cout << AT_MSG << "Error, " << args.PARSE.sDataFile << " is already parsed." << endl;
 				return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
 			}
+			else if( CATBase::IsBinaryLogFile( args.PARSE.sDataFile ) )
+			{
+				cout << AT_MSG << "Error, " << args.PARSE.sDataFile << " is binary log file." << endl;
+				return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
+			}
+
 			if ( args.PARSE.bOutputFile )
 			{
 				//Save data with name in arguments[3]
--- a/analyzetool/commandlineengine/src/catallocs.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/catallocs.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -36,14 +36,65 @@
 	}
 }
 
-void CATAllocs::AllocH( const string& sAllocHString )
+void CATAllocs::AllocH( const string& sAllocHString, const string& aTimeString )
 {
 	LOG_LOW_FUNC_ENTRY("CATAllocs::AllocH");
 	string sAllocH( sAllocHString );
 	// Parse alloc & create new allocation.
 	CATAlloc alloc;
+	alloc.m_sTime = aTimeString;
 	string sAddress = GetStringUntilNextSpace( sAllocH, true );
-	alloc.m_sTime = GetStringUntilNextSpace( sAllocH, true );
+	alloc.m_sSize = GetStringUntilNextSpace( sAllocH, true );
+	alloc.m_iThreadId = GetStringUntilNextSpace ( sAllocH, true );
+	alloc.m_iCSCount = _httoi( string( GetStringUntilNextSpace( sAllocH, true ) ).c_str() );
+	// Insert call stack fragment as "first" 1 because we are header.
+	if ( alloc.m_iCSCount > 0 )
+		alloc.m_vCallStack.insert( pair<unsigned long,string>( 0, sAllocH ) );
+	// Add allocation
+	pair< map<string,CATAlloc>::iterator, bool> ret;
+	ret = m_vAllocs.insert( pair<string, CATAlloc>( sAddress, alloc ) );
+	if( ret.second == false )
+	{
+		// Allocation to this memory address was already added.
+		LOG_STRING( "CATAllocs: Allocating same address again, address: " << sAddress );
+	}
+}
+
+void CATAllocs::AllocF( const string& sAllocFString, const string& aTimeString )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::AllocF");
+	string sAllocF( sAllocFString );
+	string sAddress = GetStringUntilNextSpace( sAllocF, true );
+	string sTime = aTimeString;
+	unsigned long iNumber = _httoi( string( GetStringUntilNextSpace( sAllocF, true ) ).c_str() );
+	string sCallSstack = sAllocF;
+	// Find correct allocation into which add call stack fragment.
+	map<string, CATAlloc>::iterator it;
+	it = m_vAllocs.find( sAddress );
+	// TODO: If cannot find, create new in cache.
+	if ( it == m_vAllocs.end() )
+	{
+		LOG_STRING( "CATAllocs: Allocate fragment without header: " << sAddress );
+		return;
+	}
+	pair< map<unsigned long,string>::iterator, bool> ret;
+	// Add call stack to it.
+	ret = it->second.m_vCallStack.insert( pair<unsigned long,string>( iNumber, sCallSstack ) );
+	if( ret.second == false )
+	{
+		LOG_STRING( "CATAllocs: Same allocation fragment again: " << sAddress );
+	}
+}
+
+// ReallocH.
+void CATAllocs::ReallocH( const string& sReallocHString, const string& aTimeString )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::ReallocH");
+	string sAllocH( sReallocHString );
+	// Parse alloc & create new allocation.
+	CATAlloc alloc;
+	string sAddress = GetStringUntilNextSpace( sAllocH, true );
+	alloc.m_sTime = aTimeString;
 	alloc.m_sSize = GetStringUntilNextSpace( sAllocH, true );
 	alloc.m_iCSCount = _httoi( string( GetStringUntilNextSpace( sAllocH, true ) ).c_str() );
 	// Insert call stack fragment as "first" 1 because we are header.
@@ -59,12 +110,13 @@
 	}
 }
 
-void CATAllocs::AllocF( const string& sAllocFString )
+// ReallocF.
+void CATAllocs::ReallocF( const string& sReallocFString, const string& aTimeString )
 {
-	LOG_LOW_FUNC_ENTRY("CATAllocs::AllocF");
-	string sAllocF( sAllocFString );
+	LOG_LOW_FUNC_ENTRY("CATAllocs::ReallocF");
+	string sAllocF( sReallocFString );
 	string sAddress = GetStringUntilNextSpace( sAllocF, true );
-	string sTime = GetStringUntilNextSpace( sAllocF, true );
+	string sTime = aTimeString;
 	unsigned long iNumber = _httoi( string( GetStringUntilNextSpace( sAllocF, true ) ).c_str() );
 	string sCallSstack = sAllocF;
 	// Find correct allocation into which add call stack fragment.
@@ -104,7 +156,7 @@
 }
 
 // FreeH.
-void CATAllocs::FreeH( const string& sFreeH )
+void CATAllocs::FreeH( const string& sFreeH, const string& aTimeString )
 {
 	LOG_LOW_FUNC_ENTRY("CATAllocs::FreeH");
 	// Current implementation does not use call stack of
@@ -112,6 +164,7 @@
 	string sFree( sFreeH );
 	string sKey = GetStringUntilNextSpace( sFree );
 	// Time stamp. (not used currently)
+	// Thread ID. (not used currently)
 	// Call stack count. (not used currently)
 	// Call stack data. (not used currently)
 
@@ -128,7 +181,7 @@
 }
 
 // FreeF.
-void CATAllocs::FreeF( const string& /* sFreeF */ )
+void CATAllocs::FreeF( const string& /* sFreeF */, const string& /* aTimeString */ )
 {
 	LOG_LOW_FUNC_ENTRY("CATAllocs::FreeF");
 	// Fragments are currently ignored.
--- a/analyzetool/commandlineengine/src/helps.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/helps.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -32,9 +32,8 @@
 	cout<< "\n";
 	cout<< "Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).\nAll rights reserved.\n\n";
 	cout<< "Usage:\n";
-	cout<< "atool -e [optional parameters] abld [abld parameters]\n";
-	cout<< "      -me [optional parameters] abld [abld parameters]\n";
-	cout<< "      -mi [optional parameters] [-f data-file] sbs [sbs parameters]\n";
+	cout<< "atool -tr [optional parameters] abld [abld parameters]\n";
+	cout<< "      -lf [optional parameters] abld [abld parameters]\n";
 	cout<< "      -a data-file [output-file] [-s symbol-file] [-l#]\n";
 	cout<< "      -p data-file output-file\n";
 	cout<< "      -c\n";
@@ -42,11 +41,8 @@
 	cout<< "      -help\n";
 	cout<< "\n";
 	cout<< "Mandatory parameter to choose:\n";
-	cout<< " -e              Build project for analysis using external data gathering.\n";
-	cout<< " -me             Build project for analysis using monitored external\n";
-	cout<< "                 data gathering.\n";
-	cout<< " -mi             Build project for analysis using monitored internal\n";
-	cout<< "                 data gathering.\n";
+	cout<< " -tr             Build project for analysis using output to trace.\n";
+	cout<< " -lf             Build project for analysis using logging to file.\n";
 	cout<< " abld...         Use SBS v.1 build system with defined build command,\n";
 	cout<< "                 which includes supported platform and build type.\n";
 	cout<< " sbs...          Use SBS v.2 (Raptor) build system with defined sbs build\n";
@@ -63,8 +59,10 @@
 	cout<< "                 is allocated. Size can be between 0-256.\n";
 	cout<< " -fcs size       Specifies the call stack size gathered when memory is freed.\n";
 	cout<< "                 Size can be between 0-256.\n";
-	cout<< " -f data file    Specifies the filename for monitored internal data gathering\n";
+	cout<< " -f data file    Specifies the filename for logging to file.\n";
 	cout<< "                 (50 chars max). Cannot contain path.\n";
+	cout<< " -fp file path   Specifies the path of log file.\n";
+	cout<< "                 (in format <driveLetter>:\\<dir1>\\<dir2>\\...\\<dirN>\\)\n";
 	cout<< " output-file     Specifies the results data file name.\n";
 	cout<< " -l              Logging level of analyze report(0,1,2,3), default 3.\n";
 	cout<< " -s symbol-file  Specifies rom/rofs symbol file(s) to be used in analyze.\n";
@@ -125,37 +123,37 @@
 	cout<< "Building syntax examples:" << endl;
 	cout<< "Cmd   Description" << endl;
 	
-	cout<< "atool -e abld build armv5 udeb" << endl;
-	cout<< "      Hooks every component from bld.inf. Using external data gathering," << endl;
+	cout<< "atool -tr abld build armv5 udeb" << endl;
+	cout<< "      Hooks every component from bld.inf. Using output to trace," << endl;
 	cout<< "      udeb build type and armv5 platform." << endl;
 
-	cout<< "atool -mi -acs 5 sbs -c winscw_udeb" << endl;
+	cout<< "atool -lf -acs 5 sbs -c winscw_udeb" << endl;
 	cout<< "      Hooks every component from bld.inf. Using Symbian Build System v.2" << endl;
-	cout<< "      Using monitored internal data gathering, call stack size of 5" << endl;
+	cout<< "      Using loging to data file, call stack size of 5" << endl;
 	cout<< "      in allocations, udeb build type and winscw platform." << endl;
 	
-	cout<< "atool -me abld build armv5 udeb foobar" << endl;
-	cout<< "      Hooks only foobar.mmp component from bld.inf. Using monitored" << endl;
-	cout<< "      external data gathering, udeb build type and armv5 platform." << endl;
+	cout<< "atool -tr abld build armv5 udeb foobar" << endl;
+	cout<< "      Hooks only foobar.mmp component from bld.inf. Using " << endl;
+	cout<< "      output to trace, udeb build type and armv5 platform." << endl;
 	
-	cout<< "atool -e -acs 0 -fcs 0 abld build armv5.default udeb" << endl;
+	cout<< "atool -lf -acs 0 -fcs 0 abld build armv5.default udeb" << endl;
 	cout<< "      Hooks every component from bld.inf. Using default binary variant," << endl;
-	cout<< "      external data gathering, 0 sized callstacks in allocation(s)/free(s)," << endl;
+	cout<< "      output to trace, 0 sized callstacks in allocation(s)/free(s)," << endl;
 	cout<< "      udeb build type and armv5 platform." << endl;
 	
-	cout<< "atool -e sbs -b bld.inf -c armv5_udeb" << endl;
+	cout<< "atool -tr sbs -b bld.inf -c armv5_udeb" << endl;
 	cout<< "      Hooks every component from bld.inf. Using Symbian Build System v.2" << endl;
-	cout<< "      , external data gathering, udeb build type and armv5 platform." << endl;
+	cout<< "      , output to trace, udeb build type and armv5 platform." << endl;
 	
-	cout<< "atool -me sbs -s system.xml --config=winscw_udeb" << endl;
+	cout<< "atool -tr sbs -s system.xml --config=winscw_udeb" << endl;
 	cout<< "      Hooks every layer defined in system.xml system model. Using Symbian Build" << endl;
-	cout<< "      System v.2, external data gathering, udeb build type and winscw platform." << endl;
+	cout<< "      System v.2, output to trace, udeb build type and winscw platform." << endl;
 
 	cout<< endl;
 	cout<< "Instrumenting syntax examples:" << endl;
 	cout<< "Cmd   Description" << endl;
-	cout<< "atool -e -nobuild abld build winscw udeb" << endl;
-	cout<< "      Instruments every component from bld.inf. Using external data gathering,"<<endl;
+	cout<< "atool -tr -nobuild abld build winscw udeb" << endl;
+	cout<< "      Instruments every component from bld.inf. Using output to trace,"<<endl;
 	cout<< "      udeb build target and winscw platform." << endl;
     cout<< "   After project is instrumented, it needs to compiled using same platform and" << endl;
 	cout<< "   build type as given to instrumenting. Use -c parameter to remove changes." << endl;
--- a/analyzetool/dynamicmemoryhook/bwins/atoolmemoryhooku.def	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/bwins/atoolmemoryhooku.def	Wed Sep 15 13:53:27 2010 +0300
@@ -1,10 +1,10 @@
 EXPORTS
 	?Alloc@RAnalyzeToolAllocator@@UAEPAXH@Z @ 1 NONAME ; void * RAnalyzeToolAllocator::Alloc(int)
-	?Alloc@RAnalyzeToolMainAllocator@@UAEPAXH@Z @ 2 NONAME ; void * RAnalyzeToolMainAllocator::Alloc(int)
-	?Exit@CustomUser@@SAXH@Z @ 3 NONAME ; void CustomUser::Exit(int)
-	?InstallAllocator@CustomUser@@CAAAVRAllocator@@HABV?$TBuf@$0BAA@@@KKKK@Z @ 4 NONAME ; class RAllocator & CustomUser::InstallAllocator(int, class TBuf<256> const &, unsigned long, unsigned long, unsigned long, unsigned long)
-	?Panic@CustomUser@@SAXABVTDesC16@@H@Z @ 5 NONAME ; void CustomUser::Panic(class TDesC16 const &, int)
-	?SetCritical@CustomUser@@SAHW4TCritical@User@@@Z @ 6 NONAME ; int CustomUser::SetCritical(enum User::TCritical)
-	?SetProcessCritical@CustomUser@@SAHW4TCritical@User@@@Z @ 7 NONAME ; int CustomUser::SetProcessCritical(enum User::TCritical)
-	?SetupThreadHeap@CustomUser@@SAHHAAUSStdEpocThreadCreateInfo@@ABV?$TBuf@$0BAA@@@KKABV?$TBuf@$0BE@@@KKV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 8 NONAME ; int CustomUser::SetupThreadHeap(int, struct SStdEpocThreadCreateInfo &, class TBuf<256> const &, unsigned long, unsigned long, class TBuf<20> const &, unsigned long, unsigned long, class TRefByValue<class TDesC16 const >, ...)
+	?SetupThreadHeap@CustomUser@@SAHHAAUSStdEpocThreadCreateInfo@@ABV?$TBuf@$0BAA@@@1KKABV?$TBuf@$0BE@@@KKV?$TRefByValue@$$CBVTDesC16@@@@ZZ @ 2 NONAME ; int CustomUser::SetupThreadHeap(int, struct SStdEpocThreadCreateInfo &, class TBuf<256> const &, class TBuf<256> const &, unsigned long, unsigned long, class TBuf<20> const &, unsigned long, unsigned long, class TRefByValue<class TDesC16 const >, ...)
+	?SetCritical@CustomUser@@SAHW4TCritical@User@@@Z @ 3 NONAME ; int CustomUser::SetCritical(enum User::TCritical)
+	?Exit@CustomUser@@SAXH@Z @ 4 NONAME ; void CustomUser::Exit(int)
+	?SetProcessCritical@CustomUser@@SAHW4TCritical@User@@@Z @ 5 NONAME ; int CustomUser::SetProcessCritical(enum User::TCritical)
+	?InstallAllocator@CustomUser@@CAAAVRAllocator@@HABV?$TBuf@$0BAA@@@0KKKKABVTDesC8@@1@Z @ 6 NONAME ; class RAllocator & CustomUser::InstallAllocator(int, class TBuf<256> const &, class TBuf<256> const &, unsigned long, unsigned long, unsigned long, unsigned long, class TDesC8 const &, class TDesC8 const &)
+	?Panic@CustomUser@@SAXABVTDesC16@@H@Z @ 7 NONAME ; void CustomUser::Panic(class TDesC16 const &, int)
+	?Alloc@RAnalyzeToolMainAllocator@@UAEPAXH@Z @ 8 NONAME ; void * RAnalyzeToolMainAllocator::Alloc(int)
 
--- a/analyzetool/dynamicmemoryhook/eabi/atoolmemoryhooku.def	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/eabi/atoolmemoryhooku.def	Wed Sep 15 13:53:27 2010 +0300
@@ -1,16 +1,18 @@
 EXPORTS
 	_ZN10CustomUser11SetCriticalEN4User9TCriticalE @ 1 NONAME
-	_ZN10CustomUser15SetupThreadHeapEiR24SStdEpocThreadCreateInfoRK4TBufILi256EEmmRKS2_ILi20EEmm11TRefByValueIK7TDesC16Ez @ 2 NONAME
-	_ZN10CustomUser16InstallAllocatorEiRK4TBufILi256EEmmmm @ 3 NONAME
+	_ZN10CustomUser15SetupThreadHeapEiR24SStdEpocThreadCreateInfoRK4TBufILi256EES5_mmRKS2_ILi20EEmm11TRefByValueIK7TDesC16Ez @ 2 NONAME
+	_ZN10CustomUser16InstallAllocatorEiRK4TBufILi256EES3_mmmmRK6TDesC8S6_ @ 3 NONAME
 	_ZN10CustomUser18SetProcessCriticalEN4User9TCriticalE @ 4 NONAME
 	_ZN10CustomUser4ExitEi @ 5 NONAME
 	_ZN10CustomUser5PanicERK7TDesC16i @ 6 NONAME
-	_ZTI20CLibraryEventHandler @ 7 NONAME ; #<TI>#
-	_ZTI21RAnalyzeToolAllocator @ 8 NONAME ; #<TI>#
-	_ZTI25RAnalyzeToolMainAllocator @ 9 NONAME ; #<TI>#
-	_ZTI27RAnalyzeToolMemoryAllocator @ 10 NONAME ; #<TI>#
-	_ZTV20CLibraryEventHandler @ 11 NONAME ; #<VT>#
-	_ZTV21RAnalyzeToolAllocator @ 12 NONAME ; #<VT>#
-	_ZTV25RAnalyzeToolMainAllocator @ 13 NONAME ; #<VT>#
-	_ZTV27RAnalyzeToolMemoryAllocator @ 14 NONAME ; #<VT>#
+	_ZTI10RATFileLog @ 7 NONAME
+	_ZTI20CLibraryEventHandler @ 8 NONAME
+	_ZTI21RAnalyzeToolAllocator @ 9 NONAME
+	_ZTI25RAnalyzeToolMainAllocator @ 10 NONAME
+	_ZTI27RAnalyzeToolMemoryAllocator @ 11 NONAME
+	_ZTV10RATFileLog @ 12 NONAME
+	_ZTV20CLibraryEventHandler @ 13 NONAME
+	_ZTV21RAnalyzeToolAllocator @ 14 NONAME
+	_ZTV25RAnalyzeToolMainAllocator @ 15 NONAME
+	_ZTV27RAnalyzeToolMemoryAllocator @ 16 NONAME
 
--- a/analyzetool/dynamicmemoryhook/group/atoolmemoryhook.mmp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/group/atoolmemoryhook.mmp	Wed Sep 15 13:53:27 2010 +0300
@@ -39,14 +39,12 @@
 SOURCE        analyzetoolmainallocator.cpp
 SOURCE        analyzetoolallocator.cpp
 SOURCE        analyzetoolfastlog.cpp
-
-SOURCEPATH    ../../storageserver/server/src
 SOURCE        atdriveinfo.cpp
+SOURCE        analyzetoolfilelog.cpp
 
 USERINCLUDE   ../inc
 USERINCLUDE   ../../inc
-USERINCLUDE   ../../storageserver/inc
-USERINCLUDE   ../../storageserver/server/inc
+USERINCLUDE   ../../analyzetool_plat/analyzetool_api/inc/analyzetool
 
 #ifdef WINSCW
 APP_LAYER_SYSTEMINCLUDE
@@ -56,10 +54,14 @@
 
 LIBRARY       efsrv.lib 
 LIBRARY       euser.lib
-LIBRARY       atoolstorageserverclnt.lib
 LIBRARY       flogger.lib
 LIBRARY       charconv.lib 
-LIBRARY       platformenv.lib 
+LIBRARY       platformenv.lib
+LIBRARY       sysutil.lib 
+LIBRARY       estor.lib 
+#ifdef WINSCW
+LIBRARY        cone.lib
+#endif
 
 #if ( SYMBIAN_VERSION_SUPPORT >= SYMBIAN_3 )
 MACRO	USE_CLEANER_DLL
--- a/analyzetool/dynamicmemoryhook/inc/analyzetoolallocator.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/inc/analyzetoolallocator.h	Wed Sep 15 13:53:27 2010 +0300
@@ -24,9 +24,9 @@
 #include "codeblock.h"
 #include "threadstack.h"
 #include "analyzetoolmemoryallocator.h"
-#include <analyzetool/atstorageserverclnt.h>
 #include <analyzetool/analyzetool.h>
 #include <analyzetool/atcommon.h>
+#include "analyzetoolfilelog.h"
 
 // CLASS DECLARATION
 
@@ -42,29 +42,24 @@
         /**
         * C++ default constructor.
         * @param aNotFirst Is this first thread using this heap
-        * @param aStorageServer A reference to the 
-        *                       <code>RATStorageServer</code> which is 
-        *                       used to store kernel events
         * @param aCodeblocks A reference to array of code segments
         * @param aMutex A reference to mutex for schedule access to the 
         *                   shared resources
         * @param aProcessId A reference to the observed process id
         * @param aAnalyzeTool Reference to device driver
-        * @param aStorageServerOpen Variable to check if Storage server is connected
-        * @param aLogOption The logging option for storage server
+        * @param aLogOption The logging option
         * @param aAllocCallStackSize Max number of stored callstack items when memory allocated
         * @param aFreeCallStackSize Max number of stored callstack items when memory freed
         */
         RAnalyzeToolAllocator( TBool aNotFirst,
-                               RATStorageServer& aStorageServer, 
                                RArray<TCodeblock>& aCodeblocks, 
                                RMutex& aMutex, 
                                TUint aProcessId,
                                RAnalyzeTool& aAnalyzeTool,
-                               TBool aStorageServerOpen,
                                TUint32 aLogOption,
                                TUint32 aAllocCallStackSize,
-                               TUint32 aFreeCallStackSize );
+                               TUint32 aFreeCallStackSize,
+                               RATFileLog& iLogFile );
         /**
         * Destructor.
         */                     
@@ -202,9 +197,6 @@
 
     private: 
     
-        /* Handle to the storage server*/
-        RATStorageServer& iStorageServer;
-
         /* A reference to codeblocks of the observed process */            
         RArray<TCodeblock>& iCodeblocks;
 
@@ -228,9 +220,6 @@
 
         RAnalyzeTool& iAnalyzeTool;
 
-        /* A flag for indicating that the RATStorageServer is open */
-        TBool iStorageServerOpen;
-
         /* Log option */
         TUint32 iLogOption;
         
@@ -240,6 +229,9 @@
         /* Max items on stored call stack when memory freed */
         TUint32 iFreeMaxCallStack;
         
+        /* Binary log file */
+        RATFileLog& iLogFile;
+        
     };
 
 #endif // ANALYZETOOLALLOCATOR_H
--- a/analyzetool/dynamicmemoryhook/inc/analyzetooleventhandler.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/inc/analyzetooleventhandler.h	Wed Sep 15 13:53:27 2010 +0300
@@ -21,9 +21,10 @@
 
 // INCLUDES
 #include <e32cmn.h>
+#include <e32base.h>
 #include "codeblock.h"
-#include <analyzetool/atstorageserverclnt.h>
 #include <analyzetool/analyzetool.h>
+#include "analyzetoolfilelog.h"
 
 // FORWARD DECLARATIONS
 class MAnalyzeToolEventhandlerNotifier;
@@ -43,9 +44,6 @@
         * @param aAnalyzeTool A reference to the <code>RAnalyzeTool</code> 
                  which is used to observe kernel events 
         * @param aCodeblocks A reference to array of code segments
-        * @param aStorageServer A reference to the 
-        *                       <code>RATStorageServer</code> which is 
-        *                       used to store kernel events
         * @param aProcessId A reference to the observed process id
         * @param aMutex A reference to mutex to schedule access to the 
         *                   shared resources
@@ -54,12 +52,12 @@
         * @param aLogOption Current used log option on allocator.
         */
         CLibraryEventHandler( RAnalyzeTool& aAnalyzeTool, 
-                RArray<TCodeblock>& aCodeblocks, 
-                RATStorageServer& aStorageServer, 
+                RArray<TCodeblock>& aCodeblocks,
                 TUint aProcessId,
                 RMutex& aMutex,
                 MAnalyzeToolEventhandlerNotifier& aNotifier,
-                TUint32 aLogOption );
+                TUint32 aLogOption,
+                RATFileLog& iLogFile );
 
         /**
         * Destructor.
@@ -95,9 +93,6 @@
         /* A reference to codeblocks of the observed process */
         RArray<TCodeblock>& iCodeblocks;
 
-        /* Handle to the storage server*/
-        RATStorageServer& iStorageServer;
-
         /* The observered process id */ 
         TUint iProcessId;
 
@@ -115,6 +110,10 @@
 
         /* Current used log option */
         TUint32 iLogOption;
+        
+        // TODO comment
+		/* */
+		RATFileLog& iLogFile;
     };
 
 #endif // ANALYZETOOLEVENTHANDLER_H
--- a/analyzetool/dynamicmemoryhook/inc/analyzetoolfastlog.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/inc/analyzetoolfastlog.h	Wed Sep 15 13:53:27 2010 +0300
@@ -36,7 +36,9 @@
 */
 GLREF_C TInt ATFastLogProcessStarted( const TDesC8& aProcessName,
                                  TUint aProcessId,
-                                 TUint32 aIsDebug );
+                                 TUint32 aIsDebug,
+                                 const TDesC8& aAtoolVersion,
+                                 const TDesC8& aApiVersion );
 
 /**
  * TBD 
@@ -78,19 +80,60 @@
  * @param aMemAddress The memory location where memory has been allocated.
  * @param aCallstack An array including the current call stack.
  * @param aSize The size of the newly allocated memory chunk.
+ * @param aThreadId ID of the thread
  * @return KErrNone.
 */
 GLREF_C TInt ATFastLogMemoryAllocated( TUint aProcessId, TUint32 aMemAddress,
                                   TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
-                                  TInt aSize );
+                                  TInt aSize,  TUint aThreadId  );
         
 /**
  * TBD
  * @param aProcessId The ID number of the process ended.
  * @param aMemAddress The memory location where memory has been deallocated.
  * @param aFreeCallstack An array including the current call stack.
+ * @param aThreadId ID of the thread
  * @return KErrNone.
 */
 GLREF_C TInt ATFastLogMemoryFreed( TUint aProcessId, TUint32 aMemAddress, 
-                              TFixedArray<TUint32, KATMaxFreeCallstackLength>& aFreeCallstack );
+                              TFixedArray<TUint32, KATMaxFreeCallstackLength>& aFreeCallstack,
+                              TUint aThreadId );
+
+/**
+ * TBD
+ * @param aProcessId The ID number of the process ended.
+ * @param aMemAddressFree The memory location where memory has been deallocated.
+ * @param aMemAddressAlloc The memory location where memory has been allocated.
+ * @param aFreeCallstack An array including the current call stack.
+ * @param aThreadId ID of the thread
+ * @return KErrNone.
+*/
+GLREF_C TInt ATFastLogMemoryReallocated( TUint aProcessId, TUint32 aMemAddressFree,  TUint32 aMemAddressAlloc,
+                                  TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
+                                  TInt aSize,  TUint aThreadId  );
+
+/**
+ * TBD
+ * @param aProcessId The ID number of the process ended.
+ * @param aThreadID An ID of the new thread started
+ * @return KErrNone.
+*/
+GLREF_C TInt ATFastLogThreadStarted( TUint aProcessId, TUint aThreadId );
+
+/**
+ * TBD
+ * @param aProcessId The ID number of the process ended.
+ * @param aThreadID An ID of the thread ended
+ * @return KErrNone.
+*/
+GLREF_C TInt ATFastLogThreadEnded( TUint aProcessId, TUint64 aThreadId );
+
+/**
+ * TBD
+ * @param aS60Version S60 version
+ * @aChecksum ROM checksum
+ * @return KErrNone.
+*/
+TInt ATFastLogDeviceInfo( const TDesC8& aS60Version, const TDesC8& aChecksum);
+
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/dynamicmemoryhook/inc/analyzetoolfilelog.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,223 @@
+/*
+* Copyright (c) 2010 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:  Declaration of the class TATDriveInfo.
+*
+*/
+
+#ifndef ANALYZETOOLFILELOG_H_
+#define ANALYZETOOLFILELOG_H_
+
+#include <e32base.h>
+#include <s32file.h> //RFileWriteStream 
+#include <f32file.h> //RFs
+#include <analyzetool/atcommon.h>
+
+class RATFileLog : public CBase
+	{
+    enum EMessageType{
+        EFileVersion = 0,
+        		EProcessStart,
+                EProcessEnd,
+                EThreadStart,
+                EThreadEnd,
+                EDllLoad,
+                EDllUnload,
+                EAllocH,
+                EAllocF,
+                EFreeH,
+                EFreeF,
+                EReallocH,
+                EReallocF,
+                ETestStart,
+                ETestEnd,
+                EHandleLeak,
+                EDeviceInfo,
+                EError  
+	    };
+    
+public:
+    
+    RATFileLog();
+	virtual ~RATFileLog();
+
+/**
+ * TBD
+ * @return KErrNone.
+*/
+	
+TInt ATFileLogVersion();
+
+/**
+ * TBD
+ * @param aProcessName The name of the new process started. The length of this
+ *   descriptor must not be greater than KMaxProcessName.
+ * @param aIsDebug Determines whether a binary is UDEB or UREL
+ * @return KErrNone.
+*/
+
+TInt ATFileLogProcessStarted( const TDesC8& aProcessName,
+                                      TUint aProcessId,
+                                      TUint32 aIsDebug,
+                                      const TDesC8& aAtoolVersion,
+                                      const TDesC8& aApiVersion );
+
+/**
+ * TBD 
+ * @param aProcessId The ID number of the process ended.
+ * @param aHandleLeakCount Number of handles open.
+ * @return KErrNone, if successful; otherwise one of the other
+ *   system-wide error codes.
+ */
+TInt ATFileLogProcessEnded( TUint aHandleLeakCount );
+
+/**
+ * TBD
+ * @param aDllName The name of the new DLL loaded. The length of this descriptor
+ *   must not be greater than KMaxLibraryName.
+ * @param aStartAddress The start address of the DLL loaded.
+ * @param aEndAddress The end address of the DLL loaded.
+ * @return KErrNone.
+*/
+TInt ATFileLogDllLoaded( const TDesC8& aDllName, TUint32 aStartAddress,
+                                TUint32 aEndAddress );
+
+/**
+ * TBD
+ * @param aDllName The name of the DLL to be unloaded. The length of this
+ *   descriptor must not be greater than KMaxLibraryName.
+ * @param aStartAddress The start address of the DLL to be unloaded.
+ * @param aEndAddress The end address of the DLL to be unloaded.
+ * @return KErrNone.
+*/
+TInt ATFileLogDllUnloaded( const TDesC8& aDllName, TUint32 aStartAddress,
+                                       TUint32 aEndAddress );
+
+/**
+ * TBD
+ * @param aMemAddress The memory location where memory has been allocated.
+ * @param aCallstack An array including the current call stack.
+ * @param aSize The size of the newly allocated memory chunk.
+ * @param aThreadId ID of the thread
+ * @return KErrNone.
+*/
+TInt ATFileLogMemoryAllocated( TUint32 aMemAddress,
+                                  TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
+                                  TInt aSize,  TUint aThreadId  );
+        
+/**
+ * TBD
+ * @param aMemAddress The memory location where memory has been deallocated.
+ * @param aFreeCallstack An array including the current call stack.
+ * @param aThreadId ID of the thread
+ * @return KErrNone.
+*/
+TInt ATFileLogMemoryFreed( TUint32 aMemAddress, 
+		                      TFixedArray<TUint32, KATMaxFreeCallstackLength>& aFreeCallstack,
+                              TUint aThreadId );
+
+/**
+ * TBD
+ * @param aMemAddressFree The memory location where memory has been deallocated.
+ * @param aMemAddressAlloc The memory location where memory has been allocated.
+ * @param aFreeCallstack An array including the current call stack.
+ * @param aThreadId ID of the thread
+ * @return KErrNone.
+*/
+TInt ATFileLogMemoryReallocated( TUint32 aMemAddressFree,  TUint32 aMemAddressAlloc,
+                                  TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
+                                  TInt aSize,  TUint aThreadId  );
+
+/**
+ * TBD
+ * @param aThreadID An ID of the new thread started
+ * @return KErrNone.
+*/
+TInt ATFileLogThreadStarted( TUint aThreadId );
+
+/**
+ * TBD
+ * @param aThreadID An ID of the thread ended
+ * @return KErrNone.
+*/
+TInt ATFileLogThreadEnded( TUint64 aThreadId );
+
+/**
+ * TBD
+ * @param aS60Version S60 version
+ * @aChecksum ROM checksum
+ * @return KErrNone.
+*/
+TInt ATFileLogDeviceInfo( const TDesC8& aS60Version, const TDesC8& aChecksum);
+
+/**
+* Opens a file server session and a file with the name specified.
+* @param aFileName The name of the file into which to log.
+* @param aProcessName Current process name.
+* @return KErrNone, if successful; otherwise one of the other system wide
+*   error codes.
+*/
+TInt OpenFsAndFile( const TDesC& aFileName, const TDesC& aFilePath, const TDesC8& aProcessName );
+
+/**
+* Method is used to parse file name extension.
+* @param aFileName The name of the file into which to log.
+* @param aExtension Parsed file extension. 
+*/
+void ParseExtension( TDes& aFileName, TDes& aExtension );
+
+/**
+* Called internally when need generate new file name.
+* @param aFileName The name of the file into which to log.
+* @param aProcessName Current process name.
+*/
+void GenerateNewFileName( TDes& aFileName, const TDesC8& aProcessName );
+
+/**
+* Method is used to check that file exists and is valid.
+* @param aFileName The name of the file into which to log.
+*/
+void CheckIfFileAlreadyExist( const TDes& aFileName );
+
+/**
+* Closes the handles to the file server session and to the file (if currently open).
+*/
+void CloseFsAndFile();
+
+// Local time function.
+TInt64 CurrentTime();
+
+
+
+/**
+* A variable telling the number of microseconds from January 1st, 0 AD
+* nominal Gregorian to January 1st, 1970 AD nominal Gregorian. 
+*/
+TInt64 iMicroSecondsAt1970;
+
+/** A handle to a file server */
+RFs iFileServer;
+
+/** A handle to a file write stream */
+RFileWriteStream iFile;
+
+/** The logging file of this process */
+TBuf8<KMaxFileName> iLogFile;
+
+/** A member variable for storing results of server function calls. */ 
+TInt iError;
+
+
+};
+
+#endif /* ANALYZETOOLFILELOG_H_ */
--- a/analyzetool/dynamicmemoryhook/inc/analyzetoolmainallocator.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/inc/analyzetoolmainallocator.h	Wed Sep 15 13:53:27 2010 +0300
@@ -22,11 +22,11 @@
 // INCLUDES
 #include <u32std.h>
 #include "codeblock.h"
-#include <analyzetool/atstorageserverclnt.h>
 #include <analyzetool/analyzetool.h>
 #include <analyzetool/atcommon.h>
 #include "analyzetoolmemoryallocator.h"
 #include "analyzetooleventhandlernotifier.h"
+#include "analyzetoolfilelog.h"
 
 // FORWARD DECLARATIONS
 class CLibraryEventHandler;
@@ -47,16 +47,21 @@
         * C++ default constructor.
         * @param aNotFirst Is this first thread using this heap
         * @param aFileName The name of the log file
-        * @param aLogOption The logging option for storage server
+        * @param aLogOption The logging option
         * @param aIsDebug Determines whether a binary is UDEB or UREL
         * @param aAllocCallStackSize Max number of stored callstack items when memory allocated
         * @param aFreeCallStackSize Max number of stored callstack items when memory freed
+        * @param aAtoolVersion Version of atool
+        * @param aApiVersion Version of api
         */
         RAnalyzeToolMainAllocator( TBool aNotFirst,
-                const TFileName aFileName,
+                const TFileName& aFileName,
+                const TPath& aFilePath,
                 TUint32 aLogOption, TUint32 aIsDebug,
                 TUint32 aAllocCallStackSize,
-                TUint32 aFreeCallStackSize );
+                TUint32 aFreeCallStackSize,
+                const TDesC8& aAtoolVersion,
+                const TDesC8& aApiVersion );
 
         /**
         * Destructor.
@@ -191,13 +196,7 @@
         void ShareHeap();
 
     public: // inlines
-    
-        /**
-        * Acquires the open RATStorageServer handle
-        * @return RATStorageServer& The open RATStorageServer handle
-        */
-        inline RATStorageServer& StorageServer();
-        
+            
         /**
         * Acquires the codeblocks of the process
         * @return RArray<TCodeblock>& The process codeblocks
@@ -221,12 +220,6 @@
 		* @return RAnalyzeTool A reference to logical channel
 		*/
         inline RAnalyzeTool& AnalyzeTool();
- 
-         /**
-        * Acquires information if storage server is open
-        * @return TBool iStorageServerOpen
-        */
-        inline TBool StorageServerOpen();
                 
         /**
         * Acquires the log option type 
@@ -245,17 +238,23 @@
          * @return TUint32 iFreeMaxCallStack
          */
         inline TUint32 FreeMaxCallStack();
+        
+        /**
+         * Acquires handle to lig file
+         * @return RATFileLog iLogFile
+         */
+        inline RATFileLog& LogFile();
 
     private: // private functions
 
         /**
         * Log the process initial information
         * @param aFileName The name of the log file
-        * @param aLogOption The logging option for storage serve
+        * @param aLogOption The logging option
         * @param aIsDebug Determines whether a binary is UDEB or UREL
         */
-        void LogProcessInformation( const TFileName aFileName, TUint32 aLogOption,
-                                                                TUint32 aIsDebug );
+        void LogProcessInformation( const TFileName& aFileName,  const TPath& aFilePath,  TUint32 aLogOption,
+        		TUint32 aIsDebug, const TDesC8& aAtoolVersion, const TDesC8& aApiVersion );
 
         /**
         * Find the current thread which is using the heap
@@ -268,11 +267,14 @@
         * Installs the eventhandler, if possible
         */
         void InstallEventHandler();
+        
+        /**
+        * Logs version of ATApp, ATApi, S60 version and ROM checksum 
+        * at the startup of hooked application
+        */
+        void LogDeviceInfo();
 
     private: // member variables
-            
-        /* Handle to the RATStorageServer */
-        RATStorageServer iStorageServer;
 
         /* Handle to the RAnalyzeTool */		
         RAnalyzeTool iAnalyzeTool;           
@@ -303,9 +305,6 @@
                 
         /* Array of threads using this heap */
         RArray<TThreadStack> iThreadArray;
-
-        /* A flag for indicating that the RATStorageServer is open */
-        TBool iStorageServerOpen;
         
         /* Log option */
         TUint32 iLogOption;
@@ -319,6 +318,10 @@
         /* Max items on stored call stack when memory freed */
         TUint32 iFreeMaxCallStack;
         
+        /* Binary log file */
+        RATFileLog iLogFile;
+       
+        
     };
 
 // INLINES
--- a/analyzetool/dynamicmemoryhook/inc/analyzetoolmainallocator.inl	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/inc/analyzetoolmainallocator.inl	Wed Sep 15 13:53:27 2010 +0300
@@ -17,16 +17,6 @@
 
 
 #include "analyzetoolmemoryallocator.h"
-
-// -----------------------------------------------------------------------------
-// RAnalyzeToolMainAllocator::StorageServer()
-// Acquires reference to open RATStorageServer
-// -----------------------------------------------------------------------------
-//
-inline RATStorageServer& RAnalyzeToolMainAllocator::StorageServer()
-    {
-    return iStorageServer;
-    }
   
 // -----------------------------------------------------------------------------
 // RAnalyzeToolMainAllocator::Codeblocks()
@@ -69,16 +59,6 @@
     }
 
 // -----------------------------------------------------------------------------
-// RAnalyzeToolMainAllocator::StorageServerOpen()
-// Acquires the iStorageServerOpen variable
-// -----------------------------------------------------------------------------
-//
-inline TBool RAnalyzeToolMainAllocator::StorageServerOpen()
-    {
-    return iStorageServerOpen;
-    }
-
-// -----------------------------------------------------------------------------
 // RAnalyzeToolMainAllocator::LogOption()
 // Acquires the iLogOption variable
 // -----------------------------------------------------------------------------
@@ -106,4 +86,14 @@
     {
     return iFreeMaxCallStack;
     }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::LogFile()
+// Acquires the iLogFile variable
+// -----------------------------------------------------------------------------
+//
+inline RATFileLog& RAnalyzeToolMainAllocator::LogFile()
+	{
+	return iLogFile;
+	}
 // End of File
--- a/analyzetool/dynamicmemoryhook/inc/analyzetoolpanics.pan	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/inc/analyzetoolpanics.pan	Wed Sep 15 13:53:27 2010 +0300
@@ -30,8 +30,6 @@
     ECantLoadDevice,
     ECantAppendToTheArray,
     ECantFindRightThread,
-    ECantConnectStorageServer,
-    ECantShareStorageServer,
     ECantCreateMutex,
     ECantLoadDeviceDriver,
     ECantConnectDeviceDriver
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/dynamicmemoryhook/inc/atdriveinfo.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* 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:  Declaration of the class TATDriveInfo.
+*
+*/
+
+
+
+#ifndef ATDRIVEINFO_H
+#define ATDRIVEINFO_H
+
+#include <f32file.h>
+
+// The path of the storage file
+#ifdef __WINS__
+_LIT( KATDataFilePath, ":\\logs\\analyzetool\\" );
+#else
+_LIT( KATDataFilePath, ":\\analyzetool\\" );
+_LIT( KATDataFilePath2, ":\\data\\analyzetool\\" );
+#endif
+
+/**
+*  Check what drives exists and creates file full path.
+*/
+class TATDriveInfo
+    {    
+    public: // Constructors
+        
+        /**
+        * C++ default constructor.
+        */
+        TATDriveInfo();
+
+    public: // New functions
+
+        /**
+        * Create the file full path.
+        * @param aPath Full path.
+        * @param aFileName Filename.
+        * @param aFs A handle to a file server.
+        * @return KErrNone or KErrAlreadyExists, if successful; 
+        *   Otherwise one of the other system wide error codes.
+        */
+        static TInt CreatePath( TDes& aPath, const TDesC& aFileName, const TDesC& aFilePath, RFs& aFs );   
+    
+    private: // New functions
+    
+        /**
+        * Get the available drive character.
+        * @param aDrive The drive letter.
+        * @param aDriveNumber The drive number.
+        * @param aFs A handle to a file server.
+        * @param aDriveType Drive type.
+        * @return KErrNone, if successful; otherwise KErrNotFound
+        */
+        static TInt GetDrive( TChar& aDrive, TInt& aDriveNumber, 
+                RFs& aFs, const TUint aDriveType );  
+        
+    };
+
+#endif // ATDRIVEINFO_H
+
+// End of File
+
--- a/analyzetool/dynamicmemoryhook/inc/customuser.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,207 +0,0 @@
-/*
-* 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:  Declaration of the class CustomUser containing overloaded User static functions.
-*
-*/
-
-
-#ifndef CUSTOMUSER_H
-#define CUSTOMUSER_H
-
-// INCLUDES
-#include <u32std.h>
-#include <e32svr.h>
-// CONSTANTS
-const TInt KATVersionLength = 20;
-const TInt KATDefaultLogOption = 0;
-const TInt KATDefaultDebug = 1;
-const TInt KATDefaultAllocCallStackSize = 40;
-const TInt KATDefaultFreeCallStackSize = 0;
-    
-// TYPEDEFS
-typedef TBuf<KATVersionLength> TATVersion;
-
-// Argument list for SetupThreadHeap function parameters. (currently not used)
-// When needed, update the argument type directly inside _LIT macro.
-_LIT( KATArgumentList, "%i%i" ); //etc. 
-
-// CLASS DECLARATION
-
-/**
-*  Class which overloads the User functions and provides access to 
-*  the overloaded functions  
-*/
-class CustomUser
-    {
-    public: // Enumerations
-        enum TATOptions
-            {
-            /** Acquiring the log filename */
-            ELogFileName = 1,   
-            /** Acquiring the version number */
-            EVersion,
-            /** Acquiring logging option */
-            ELogOption,
-            /** Acquiring UDEB/UREL information */  
-            EDebug,
-            /** Acquiring max allocation call stack size */
-            EAllocCallStackSize,
-            /** Acquiring max free call stack size */
-            EFreeCallStackSize
-            };
-        
-    public:
-
-        /**
-        * Overloaded version of User::Exit()
-        * Terminates the current thread, specifying a reason. All child 
-        * threads are terminated and all resources are cleaned up.If the 
-        * current thread is the main thread in a process, the process is
-        * also terminated.
-        * @param aReason The reason code.
-        */
-        IMPORT_C static void Exit( TInt aReason );
-
-        /**
-        * Overloaded version of User::Panic()
-        * Panics the current thread, specifying a category name and panic
-        * number. Keep the length of the category name small;
-        * a length of 16 is ideal.
-        * @param aCategory A reference to the descriptor containing the text 
-        * that defines the category for this panic.
-        * @param aReason The panic number. 
-        */   
-        IMPORT_C static void Panic( const TDesC& aCategory, TInt aReason );
-
-        /**
-        * Overloaded version of UserHeap::SetupThreadHeap()
-        * Setups the threads heap.
-        * @param aNotFirst Is this first thread using specified heap
-        * @param aInfo Specifies the thread heap properties
-        * @param aFileName The name of the log file
-        * @param aLogOption The logging option for storage server
-        * @param aIsDebug Determines whether a binary is UDEB or UREL
-        * @param aVersion Atool version number
-        * @param aAllocCallStackSize Max number of stored callstack items when memory allocated
-        * @param aFreeCallStackSize Max number of stored callstack items when memory freed
-        * @param aFmt A descriptor containing the format string
-        * @return TInt KErrNone, if the insertion is successful, otherwise 
-        * one of the system wide error codes.
-        */   
-        IMPORT_C static TInt SetupThreadHeap( 
-                             TBool aNotFirst, 
-                             SStdEpocThreadCreateInfo& aInfo,
-                             const TFileName& aFileName,
-                             TUint32 aLogOption, TUint32 aIsDebug,
-                             const TATVersion& aVersion,
-                             TUint32 aAllocCallStackSize,
-                             TUint32 aFreeCallStackSize,
-                             TRefByValue<const TDesC> aFmt, ... );
-                             
-        /**
-        * Overloaded version of UserHeap::SetCritical()
-        * Sets up or changes the effect that termination of the current 
-        * thread has, either on its owning process, or on the whole system.
-        * The precise effect of thread termination is defined by the following
-        *  specific values of the TCritical enum:
-        * ENotCritical
-        * EProcessCritical
-        * EProcessPermanent
-        * ESystemCritical
-        * ESystemPermanent
-        * Notes: The enum value EAllThreadsCritical cannot be set using this
-        * function. It is associated with a process, not a thread, and, if 
-        * appropriate, should be set using User::SetProcessCritical().
-        * The states associated with ENotCritical, EProcessCritical, 
-        * EProcessPermanent, ESystemCritical and ESystemPermanent are all 
-        * mutually exclusive, i.e. the thread can only be in one of these 
-        * states at any one time.
-        * @param aCritical The state to be set.
-        * @return TInt KErrNone, if successful; KErrArgument, if 
-        * EAllThreadsCritical is passed - this is a state associated with a 
-        * process, and you use User::SetProcessCritical() to set it.
-        */ 
-        IMPORT_C static TInt SetCritical( User::TCritical aCritical );
-        
-        /**
-        * Overloaded version of UserHeap::SetCritical()
-        * Sets up or changes the effect that termination of subsequently 
-        * created threads will have, either on the owning process, 
-        * or on the whole system. It is important to note that we are not
-        * referring to threads that have already been created, but threads
-        * that will be created subsequent to a call to this function.
-        * The precise effect of thread termination is defined by the following
-        * specific values of the TCritical enum:
-        * ENotCritical
-        * EAllThreadsCritical
-        * ESystemCritical
-        * ESystemPermanent
-        * Notes:
-        * The enum values EProcessCritical and EProcessPermanent cannot be set
-        * using this function. They are states associated with a thread, not a
-        * process, and, if appropriate, should be set using 
-        * User::SetCritical(). The states associated with ENotCritical, 
-        * EAllThreadsCritical, ESystemCritical and ESystemPermanent are all 
-        * mutually exclusive, i.e. the process can only be in one of these 
-        * states at any one time.
-        * @param aCritical The state to be set.
-        * @return TInt KErrNone, if successful; KErrArgument, if either 
-        * EProcessCritical or EProcessPermanent is passed - these are states
-        * associated with a thread, and you use User::SetCritical() 
-        * to set them.
-        */ 
-        IMPORT_C static TInt SetProcessCritical( User::TCritical aCritical );
-                
-    private: // Private functions
-        
-        /**
-        * Factory function for creating RAllocator instances.
-        * @param aNotFirst Is this first thread using specified heap
-        * @param aLogOption The logging option for storage server
-        * @param aFileName The name of the logging file
-        * @param aIsDebug Determines whether a binary is UDEB or UREL
-        * @param aAllocCallStackSize Max number of stored callstack items when memory allocated
-        * @param aFreecallStackSize Max number of stored callstack items when memory freed
-        * @return RAllocator& A reference to created allocator
-        */  
-        static RAllocator& InstallAllocator( TBool aNotFirst,
-                                             const TFileName& aFileName,
-                                             TUint32 aLogOption, TUint32 aIsDebug,
-                                             TUint32 aAllocCallStackSize,
-                                             TUint32 aFreeCallStackSize );
-        
-		/**
-		* Check atool version
-		* @param aVersion - Atool version number.
-		* @param aToolVersion The atool version number
-		* @return KErrNone if correct version found, otherwise one of the system wide 
-		* error codes.
-		*/
-        static TInt CheckVersion( const TATVersion& aVersion, TDes& aToolVersion ); 
-        
-		/**
-		* Function for showing incorrect version information (file or debug channel).
-		* @param aLogOption The logging option
-		* @param aFileName The name of the log file
-		* @param aToolVersion The atool version number
-		*/
-        static void ReportIncorrectVersion( const TUint32 aLogOption, 
-											const TFileName& aFileName,
-											const TDes& aToolVersion );
-        
-    };
-
-#endif // CUSTOMUSER_H
-
-// End of File
--- a/analyzetool/dynamicmemoryhook/src/analyzetoolallocator.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/src/analyzetoolallocator.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -37,27 +37,25 @@
 // might leave.
 // -----------------------------------------------------------------------------
 //
-RAnalyzeToolAllocator::RAnalyzeToolAllocator( TBool aNotFirst, 
-                                              RATStorageServer& aStorageServer, 
+RAnalyzeToolAllocator::RAnalyzeToolAllocator( TBool aNotFirst,
                                               RArray<TCodeblock>& aCodeblocks, 
                                               RMutex& aMutex,
                                               TUint aProcessId,
                                               RAnalyzeTool& aAnalyzeTool,
-                                              TBool aStorageServerOpen,
                                               TUint32 aLogOption,
                                               TUint32 aAllocCallStackSize,
-                                              TUint32 aFreeCallStackSize ) :
+                                              TUint32 aFreeCallStackSize,
+                                              RATFileLog& aLogFile ) :
     RAnalyzeToolMemoryAllocator( aNotFirst ),
-    iStorageServer( aStorageServer ), 
     iCodeblocks( aCodeblocks ), 
     iMutex( aMutex ),
     iProcessId( aProcessId ),
     iThreadArray( KATMaxCallstackLength ),
     iAnalyzeTool( aAnalyzeTool ),
-    iStorageServerOpen( aStorageServerOpen ),
     iLogOption( aLogOption ),
     iAllocMaxCallStack( aAllocCallStackSize ),
-    iFreeMaxCallStack( aFreeCallStackSize )
+    iFreeMaxCallStack( aFreeCallStackSize ),
+    iLogFile ( aLogFile )
     {
     LOGSTR1( "ATMH RAnalyzeToolAllocator::RAnalyzeToolAllocator()" );
     
@@ -71,6 +69,16 @@
         LOGSTR2( "ATMH Thread stack size:    %x", params().iStackSize );
         error = iThreadArray.Append( TThreadStack( RThread().Id(), 
                              params().iStackAddress + params().iStackSize ) );
+
+        if ( iLogOption == EATLogToTraceFast )
+        	{
+            // log thread added
+            ATFastLogThreadStarted( aProcessId, RThread().Id().operator TUint() ); 
+        	}
+        else if ( iLogOption == EATLogToFile )
+        	{
+            iLogFile.ATFileLogThreadStarted( RThread().Id().operator TUint() );
+        	}
         }
     
     __ASSERT_ALWAYS( KErrNone == error, AssertPanic( ECantAppendToTheArray ) ); 
@@ -85,6 +93,20 @@
     {
     LOGSTR1( "ATMH RAnalyzeToolAllocator::~RAnalyzeToolAllocator()" );
     
+    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();
     }
@@ -134,88 +156,67 @@
     // Acquire the mutex
     iMutex.Wait();
     
+    // get thread ID
+    TUint threadId = RThread().Id();
     // Alloc memory from the original allocator
     TAny* p = iAllocator->Alloc( aSize );
     
     LOGSTR3( "ATMH RAnalyzeToolAllocator::Alloc() - aSize: %i, address: %x", 
              aSize,  (TUint32) p );
     
-    // Don't collect call stack and log data
-    // if storage server not open or logging mode not fast.
-    if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
-        {
-        // Reset the callstack
-        iCallStack.Reset();
-    
-        // Find the current thread callstack start address
-        TUint32 stackstart( 0 );
-        TBool found( FindCurrentThreadStack( stackstart ) );
-        LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
-        
-        TUint32 _sp;
-        __asm
-            {
-            mov [_sp], esp
-            }
-        
-        // Get codeblocks count
-        TInt blocksCount( iCodeblocks.Count() );
-        TInt error( KErrNone );
-        TUint arrayCounter = 0;
-        
-        for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
-            {
-            TUint32 addr = (TUint32) *( (TUint32*) i );
-            if ( ! IsAddressLoadedCode( addr ) )
-                continue;
-            for ( TInt j = 0; j < blocksCount; j++ )
-                {
-                if ( iCodeblocks[j].CheckAddress( addr ) )
-                    {
-                    // To avoid recursive call to ReAlloc specifying granularity
-                    // Add address to the callstack
-                    iCallStack[arrayCounter] = ( addr );
-                    arrayCounter++;
-                    break;
-                    }
-                }
-            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 )
-                {
-                LOGSTR2( "ATMH LogMemoryAllocated error %i", error );
-                switch ( error )
-                    {
-                    case KErrNoMemory:
-                    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc() - KErrNoMemory case"  );
-                    if ( iStorageServerOpen )
-                        {
-                        iStorageServerOpen = EFalse;
-                        LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc() - close iStorageServer"  );
-                        iStorageServer.Close();
-                        }
-                    break;
-                    }
-                }
-            }
-        }
+	// Reset the callstack
+	iCallStack.Reset();
+
+	// Find the current thread callstack start address
+	TUint32 stackstart( 0 );
+	TBool found( FindCurrentThreadStack( stackstart ) );
+	LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
+	
+	TUint32 _sp;
+	__asm
+		{
+		mov [_sp], esp
+		}
+	
+	// Get codeblocks count
+	TInt blocksCount( iCodeblocks.Count() );
+	TInt error( KErrNone );
+	TUint arrayCounter = 0;
+	
+	for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+		{
+		TUint32 addr = (TUint32) *( (TUint32*) i );
+		if ( ! IsAddressLoadedCode( addr ) )
+			continue;
+		for ( TInt j = 0; j < blocksCount; j++ )
+			{
+			if ( iCodeblocks[j].CheckAddress( addr ) )
+				{
+				// To avoid recursive call to ReAlloc specifying granularity
+				// Add address to the callstack
+				iCallStack[arrayCounter] = ( addr );
+				arrayCounter++;
+				break;
+				}
+			}
+		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();
     
@@ -235,79 +236,59 @@
     // Acquire the mutex
     iMutex.Wait();
     
+    // get thread ID
+    TUint threadId = RThread().Id();
+        
     // Alloc memory from the original allocator
     TAny* p = iAllocator->Alloc( aSize );
-    
-    // Don't collect call stack and log data
-    // if storage server not open or logging mode not fast.
-    if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
-        {
-        // Reset the callstack
-        iCallStack.Reset(); 
         
-        // Find the current thread callstack start address
-        TUint32 stackstart( 0 );
-        TBool found( FindCurrentThreadStack( stackstart ) );
-        LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
-        
-        // Get codeblocks count
-        TInt blocksCount( iCodeblocks.Count() );
-        TInt error( KErrNone );
-        TUint arrayCounter = 0;
-        
-        for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
-            {
-            TUint32 addr = (TUint32) *( (TUint32*) i );
-            if ( ! IsAddressLoadedCode( addr ) )
-                continue;
-            for ( TInt j = 0; j < blocksCount; j++ )
-                {
-                if ( iCodeblocks[j].CheckAddress( addr ) )
-                    {
-                    // To avoid recursive call to ReAlloc specifying granularity
-                    // Add address to the callstack
-                    iCallStack[arrayCounter] = ( addr );
-                    arrayCounter++;
-                    break;
-                    }
-                }
-            if ( arrayCounter == KATMaxCallstackLength ||
-                 arrayCounter == iAllocMaxCallStack )
-                {
-                LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
-                break;
-                }
-            }
-        // Log the memory allocation information
-        if ( iLogOption == EATLogToTraceFast )
-            {
-            // Fast mode.
-            ATFastLogMemoryAllocated( iProcessId, (TUint32) p, iCallStack, aSize );
-            }
-        else
-            {
-            // Using storage server.
-            error = iStorageServer.LogMemoryAllocated( (TUint32) p, 
-                                                        iCallStack, 
-                                                        aSize );
-            if ( KErrNone != error )
-                {
-                LOGSTR2( "ATMH LogMemoryAllocated error %i", error );
-                switch ( error )
-                    {
-                    case KErrNoMemory:
-                    LOGSTR1( "ATMH RAnalyzeToolAllocator::Alloc() - KErrNoMemory case"  );
-                    if ( iStorageServerOpen )
-                        {
-                        iStorageServerOpen = EFalse;
-                        LOGSTR1( "ATMH RAnalyzeToolAllocator::Alloc() - close iStorageServer"  );
-                        iStorageServer.Close();
-                        }
-                    break;
-                    }
-                }
-            }
-        }
+
+	// Reset the callstack
+	iCallStack.Reset(); 
+	
+	// Find the current thread callstack start address
+	TUint32 stackstart( 0 );
+	TBool found( FindCurrentThreadStack( stackstart ) );
+	LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
+	
+	// Get codeblocks count
+	TInt blocksCount( iCodeblocks.Count() );
+	TUint arrayCounter = 0;
+	
+	for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+		{
+		TUint32 addr = (TUint32) *( (TUint32*) i );
+		if ( ! IsAddressLoadedCode( addr ) )
+			continue;
+		for ( TInt j = 0; j < blocksCount; j++ )
+			{
+			if ( iCodeblocks[j].CheckAddress( addr ) )
+				{
+				// To avoid recursive call to ReAlloc specifying granularity
+				// Add address to the callstack
+				iCallStack[arrayCounter] = ( addr );
+				arrayCounter++;
+				break;
+				}
+			}
+		if ( arrayCounter == KATMaxCallstackLength ||
+			 arrayCounter == iAllocMaxCallStack )
+			{
+			LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
+			break;
+			}
+		}
+	// Log the memory allocation information
+	if ( iLogOption == EATLogToTraceFast )
+		{
+		// 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(); 
@@ -329,76 +310,68 @@
     // Acquire the mutex
     iMutex.Wait();
     
-    // Don't collect or log data if storage server not open or logging mode not fast.
-    if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
-        {
-        // Reset the callstack
-        iFreeCallStack.Reset();
-        
-        // Check if trace logging mode because free call stack is not used in other log options.
-        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;
-            
-            #ifdef __WINS__
-                __asm
-                    {
-                    mov [_sp], esp
-                    }
-            #else
-                _sp = __current_sp();
-            #endif
-            
-            // Get codeblocks count
-            TInt blocksCount( iCodeblocks.Count() );
-            TUint arrayCounter = 0;
-        
-            for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
-                {
-                TUint32 addr = (TUint32) *( (TUint32*) i );
-                if ( ! IsAddressLoadedCode( addr ) )
-                    continue;
-                for ( TInt j = 0; j < blocksCount; j++ )
-                    {
-                    if ( iCodeblocks[j].CheckAddress( addr ) )
-                        {
-                        // To avoid recursive call to ReAlloc specifying granularity
-                        // Add address to the callstack
-                        iFreeCallStack[arrayCounter] = addr;
-                        arrayCounter++;
-                        break;
-                        }
-                    }
-                if ( arrayCounter == KATMaxFreeCallstackLength ||
-                     arrayCounter == iFreeMaxCallStack )
-                    {
-                    break;
-                    }
-                }
-            LOGSTR2( "ATMH > iFreeCallStack count ( %i )", arrayCounter );
-            }
-        
-        // Log freed memory.
-        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();
+	
+	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;
+		
+		#ifdef __WINS__
+			__asm
+				{
+				mov [_sp], esp
+				}
+		#else
+			_sp = __current_sp();
+		#endif
+		
+		// Get codeblocks count
+		TInt blocksCount( iCodeblocks.Count() );
+		TUint arrayCounter = 0;
+	
+		for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+			{
+			TUint32 addr = (TUint32) *( (TUint32*) i );
+			if ( ! IsAddressLoadedCode( addr ) )
+				continue;
+			for ( TInt j = 0; j < blocksCount; j++ )
+				{
+				if ( iCodeblocks[j].CheckAddress( addr ) )
+					{
+					// To avoid recursive call to ReAlloc specifying granularity
+					// Add address to the callstack
+					iFreeCallStack[arrayCounter] = addr;
+					arrayCounter++;
+					break;
+					}
+				}
+			if ( arrayCounter == KATMaxFreeCallstackLength ||
+				 arrayCounter == iFreeMaxCallStack )
+				{
+				break;
+				}
+			}
+		LOGSTR2( "ATMH > iFreeCallStack count ( %i )", arrayCounter );
+		}
+	
+	// Log freed memory.
+	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 ); 
@@ -440,6 +413,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() );
+				}
             }
         }
     
@@ -476,6 +458,16 @@
             {
             // 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() );
+				}
+            
             break;
             }
         }
@@ -497,6 +489,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 );
@@ -509,117 +504,61 @@
         LOGSTR3( "ATMH RAnalyzeToolAllocator::ReAlloc() - aSize: %i, aMode: %i", 
                 aSize, aMode );
 
-        // Don't collect or log data if storage server not open or logging mode fast.
-        if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
-            {
-            // Reset the callstack
-            iReCallStack.Reset(); 
+
+		// Reset the callstack
+		iReCallStack.Reset(); 
 
-            // Find the current thread callstack start address
-            TUint32 stackstart( 0 ); 
-            TBool found( FindCurrentThreadStack( stackstart ) );
-            LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
-            
-            // Get current sp
-            TUint32 _sp( 0 );
-            __asm
-                {
-                mov [_sp], esp
-                }
-            
-            // Get codeblocks count
-            TInt blocksCount( iCodeblocks.Count() );
-            TInt error( KErrNone );
-            TUint arrayCounter = 0;
-            
-            for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
-                {
-                TUint32 addr = (TUint32) *( (TUint32*) i );
-                if ( ! IsAddressLoadedCode( addr ) )
-                    continue;
-                for ( TInt j = 0; j < blocksCount; j++ )
-                    {
-                    if ( iCodeblocks[j].CheckAddress( addr ) )
-                        {
-                        // To avoid recursive call to ReAlloc specifying granularity
-                        // Add address to the callstack
-                        iReCallStack[arrayCounter] = addr;
-                        arrayCounter++;
-                        break;
-                        }
-                    }
-                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();
-                
-                // if trace logging mode(s) we also log call stack in free.
-                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 mode.
-                ATFastLogMemoryAllocated( iProcessId, (TUint32) ptr, iFreeCallStack, aSize);
-                }
-            else
-                {
-                // Using storage server.
-                error = iStorageServer.LogMemoryAllocated( (TUint32) ptr, 
-                                                            iReCallStack, 
-                                                            aSize );
-                if ( KErrNone != error )
-                    {
-                    LOGSTR2( "ATMH LogMemoryAllocated ReAlloc error %i", error );
-                    switch ( error )
-                        {
-                        case KErrNoMemory:
-                        LOGSTR1( "ATMH RAnalyzeToolAllocator::ReAlloc() - KErrNoMemory case"  );
-                        if ( iStorageServerOpen )
-                            {
-                            iStorageServerOpen = EFalse;
-                            LOGSTR1( "ATMH RAnalyzeToolAllocator::ReAlloc() - close iStorageServer"  );
-                            iStorageServer.Close();
-                            }
-                        break;
-                        }
-                    }
-                }
-            }
-        }
+		// Find the current thread callstack start address
+		TUint32 stackstart( 0 ); 
+		TBool found( FindCurrentThreadStack( stackstart ) );
+		LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
+		
+		// Get current sp
+		TUint32 _sp( 0 );
+		__asm
+			{
+			mov [_sp], esp
+			}
+		
+		// Get codeblocks count
+		TInt blocksCount( iCodeblocks.Count() );
+		TInt error( KErrNone );
+		TUint arrayCounter = 0;
+		
+		for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+			{
+			TUint32 addr = (TUint32) *( (TUint32*) i );
+			if ( ! IsAddressLoadedCode( addr ) )
+				continue;
+			for ( TInt j = 0; j < blocksCount; j++ )
+				{
+				if ( iCodeblocks[j].CheckAddress( addr ) )
+					{
+					// To avoid recursive call to ReAlloc specifying granularity
+					// Add address to the callstack
+					iReCallStack[arrayCounter] = addr;
+					arrayCounter++;
+					break;
+					}
+				}
+			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
     iMutex.Signal();
@@ -641,6 +580,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 );
@@ -653,110 +595,55 @@
         LOGSTR3( "ATMH RAnalyzeToolAllocator::ReAlloc() - aSize: %i, aMode: %i", 
                 aSize, aMode );
 
-        // Don't collect or log data if storage server not open or logging mode fast.
-        if ( iStorageServerOpen || iLogOption == EATLogToTraceFast )
-            {
-            // Reset the callstack
-            iReCallStack.Reset(); 
+		// Reset the callstack
+		iReCallStack.Reset(); 
+
+		// Find the current thread callstack start address
+		TUint32 stackstart( 0 ); 
+		TBool found( FindCurrentThreadStack( stackstart ) );
+		LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
+		
+		// Get codeblocks count
+		TInt blocksCount( iCodeblocks.Count() );
 
-            // Find the current thread callstack start address
-            TUint32 stackstart( 0 ); 
-            TBool found( FindCurrentThreadStack( stackstart ) );
-            LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found );
-            
-            // Get codeblocks count
-            TInt blocksCount( iCodeblocks.Count() );
-            TInt error( KErrNone );
-            TUint arrayCounter = 0;
-            
-            for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
-                {
-                TUint32 addr = (TUint32) *( (TUint32*) i );
-                if ( ! IsAddressLoadedCode( addr ) )
-                    continue;
-                for ( TInt j = 0; j < blocksCount; j++ )
-                    {
-                    if ( iCodeblocks[j].CheckAddress( addr ) )
-                        {
-                        // To avoid recursive call to ReAlloc specifying granularity
-                        // Add address to the callstack
-                        iReCallStack[arrayCounter] = ( addr );
-                        arrayCounter++;
-                        break;
-                        }
-                    }
-                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();
-                
-                // if trace logging mode(s) we also log call stack with free.
-                if ( ( iLogOption == EATUseDefault || iLogOption == EATLogToTrace || iLogOption == EATLogToTraceFast )
-                        && iFreeMaxCallStack > 0 )
-                    {
-                    for ( TInt i = 0; i < arrayCounter; i++ )
-                        {
-                        if ( i == iFreeCallStack.Count() )
-                            {
-                            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 mode.
-                ATFastLogMemoryAllocated( iProcessId, (TUint32) ptr, iReCallStack, aSize );
-                }
-            else
-                {
-                // Using storage server.
-                error = iStorageServer.LogMemoryAllocated( (TUint32) ptr, 
-                                                            iReCallStack, 
-                                                            aSize );
-                if ( KErrNone != error )
-                    {
-                    LOGSTR2( "ATMH LogMemoryAllocated ReAlloc error %i", error );
-                    switch ( error )
-                        {
-                        case KErrNoMemory:
-                        LOGSTR1( "ATMH RAnalyzeToolAllocator::ReAlloc() - KErrNoMemory case"  );
-                        if ( iStorageServerOpen )
-                            {
-                            iStorageServerOpen = EFalse;
-                            LOGSTR1( "ATMH RAnalyzeToolAllocator::ReAlloc() - close iStorageServer"  );
-                            iStorageServer.Close();
-                            }
-                        break;
-                        }
-                    }
-                }
-            }
-        }
+		TUint arrayCounter = 0;
+		
+		for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+			{
+			TUint32 addr = (TUint32) *( (TUint32*) i );
+			if ( ! IsAddressLoadedCode( addr ) )
+				continue;
+			for ( TInt j = 0; j < blocksCount; j++ )
+				{
+				if ( iCodeblocks[j].CheckAddress( addr ) )
+					{
+					// To avoid recursive call to ReAlloc specifying granularity
+					// Add address to the callstack
+					iReCallStack[arrayCounter] = ( addr );
+					arrayCounter++;
+					break;
+					}
+				}
+			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
     iMutex.Signal();
--- a/analyzetool/dynamicmemoryhook/src/analyzetooleventhandler.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/src/analyzetooleventhandler.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -68,15 +68,13 @@
                         iLibraryInfo.iRunAddress,
                         iLibraryInfo.iRunAddress + iLibraryInfo.iSize );
                 }
-            else
-                {
-                LOGSTR1( "ATMH CLibraryEventHandler::RunL() - iStorageServer.LogDllLoaded() " );
-                error = iStorageServer.LogDllLoaded( 
-                        iLibraryInfo.iLibraryName, 
-                        iLibraryInfo.iRunAddress,
-                        iLibraryInfo.iRunAddress + iLibraryInfo.iSize );
-                LOGSTR2( "ATMH StorageServer error: %i",  error );
-                }
+            else if( iLogOption == EATLogToFile )
+            	{
+				iLogFile.ATFileLogDllLoaded( iLibraryInfo.iLibraryName, 
+						iLibraryInfo.iRunAddress,
+						iLibraryInfo.iRunAddress + iLibraryInfo.iSize );
+            	}
+            
             if ( KErrNone == error )
                 {
                 iCodeblocks.Append( TCodeblock( iLibraryInfo.iRunAddress, 
@@ -106,23 +104,12 @@
                             iLibraryInfo.iRunAddress, 
                             iLibraryInfo.iRunAddress + iLibraryInfo.iSize );
                     }
-                else
-                    {
-                    LOGSTR1( "ATMH CLibraryEventHandler::RunL() - iStorageServer.LogDllUnloaded() " );
-                    #ifdef LOGGING_ENABLED
-                    TInt error = iStorageServer.LogDllUnloaded( 
-                            libraryName/*iLibraryInfo.iLibraryName*/, 
-                            iLibraryInfo.iRunAddress, 
-                            iLibraryInfo.iRunAddress + iLibraryInfo.iSize );
-    
-                    LOGSTR2( "ATMH StorageServer error: %i",  error );
-                    #else
-                    iStorageServer.LogDllUnloaded( 
-                                                libraryName/*iLibraryInfo.iLibraryName*/, 
-                                                iLibraryInfo.iRunAddress, 
-                                                iLibraryInfo.iRunAddress + iLibraryInfo.iSize );
-                    #endif
-                    }
+                else if( iLogOption == EATLogToFile )
+					{
+					iLogFile.ATFileLogDllUnloaded( iLibraryInfo.iLibraryName, 
+							iLibraryInfo.iRunAddress,
+							iLibraryInfo.iRunAddress + iLibraryInfo.iSize );
+					}
                 iCodeblocks.Remove( i );
                 break;
                 }
@@ -198,19 +185,20 @@
 // -----------------------------------------------------------------------------
 //
 CLibraryEventHandler::CLibraryEventHandler( RAnalyzeTool& aAnalyzeTool, 
-	RArray<TCodeblock>& aCodeblocks, RATStorageServer& aStorageServer, 
+	RArray<TCodeblock>& aCodeblocks,
 	TUint aProcessId, RMutex& aMutex, 
 	MAnalyzeToolEventhandlerNotifier& aNotifier,
-	TUint32 aLogOption ) 
+	TUint32 aLogOption,
+	RATFileLog& aFileLog ) 
  :	CActive( EPriorityNormal ),
     iAnalyzeTool( aAnalyzeTool ),
     iCodeblocks( aCodeblocks ),
-    iStorageServer( aStorageServer ),
     iProcessId( aProcessId ),
     iMutex( aMutex ),
     iStarted( EFalse ),
     iNotifier( aNotifier ),
-    iLogOption( aLogOption )
+    iLogOption( aLogOption ),
+    iLogFile( aFileLog )
     {
     LOGSTR1( "ATMH CLibraryEventHandler::CLibraryEventHandler()" );
     }
--- a/analyzetool/dynamicmemoryhook/src/analyzetoolfastlog.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/src/analyzetoolfastlog.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -15,7 +15,6 @@
 *
 */
 
-
 #include <e32debug.h> // RDebug
 #include <analyzetool/analyzetooltraceconstants.h>
 #include "analyzetoolfastlog.h"
@@ -32,26 +31,51 @@
 
 TInt ATFastLogProcessStarted( const TDesC8& aProcessName,
                                  TUint aProcessId,
-                                 TUint32 aIsDebug )
+                                 TUint32 aIsDebug,
+                                 const TDesC8& aAtoolVersion,
+                                 const TDesC8& aApiVersion )
     {
     LOGSTR1( "ATFL ATFastLogProcessStarted()" );
-    // Convert process name to 16-bit descriptor.
-    TBuf<KMaxProcessName> processName;
-    processName.Copy( aProcessName );
-    // Buffer to trace.
-    TBuf<KProcessStartBufLength> buffer;
-    // Format process name and id.
-    buffer.Format( KProcessStart16, &processName, aProcessId );
-    // Timestamp.
+    
+    // PCS <Process name> <Process ID> <Time stamp> <Udeb> <Version>
+
+    //Buffer to trace
+    TBuf8<KProcessStartBufLength> buffer;
+    
+    // AT indentifier
+    buffer.Append( KATIdentifier );
+    // process id
+    buffer.AppendNum( aProcessId, EHex );
+    buffer.Append( KSpace );
+    
+    // PCS
+    buffer.Append( KProcessStart );
+    // process name
+    buffer.Append( aProcessName );
+    buffer.Append( KSpace );
+    // process id
+    buffer.AppendNum( aProcessId, EHex );
+    buffer.Append( KSpace );
+    // time stamp
     buffer.AppendNum( CurrentTime(), EHex ) ;
-    // Append udeb/urel information to the process start.
-    buffer.Append( KSpaceTrace );  
+    buffer.Append( KSpace );
+    // urel/udeb
     buffer.AppendNum( aIsDebug, EHex );
-    // Append version number.
-    buffer.Append( KSpaceTrace );  
+    buffer.Append( KSpace );
+    // version
     buffer.AppendNum( KATTraceVersion, EHex );
-    // Log to trace.
-    RDebug::Print( KTraceMessage, aProcessId ,&buffer );
+    buffer.Append( KSpace );    
+    // atool version
+    buffer.Append( aAtoolVersion );
+    buffer.Append( KSpace );
+    // ATAPI version
+    buffer.Append( aApiVersion );
+
+
+
+
+    RDebug::RawPrint( buffer );
+       
     return KErrNone;
     }
 
@@ -59,21 +83,44 @@
                             TUint aHandleLeakCount )
     {
     LOGSTR1( "ATFL ATFastLogProcessEnded()" );
-    // Handle leaks.
+    
+    // PCE
+    
     if ( aHandleLeakCount > 0 )
-        {
+    	{
+        // HDL <Handle count>
+    
         // Buffer to trace.
-        TBuf<KHandleLeakBufLength> buffer2;
-        buffer2.Format( KHandleLeak16, &KUnknownModule16, aHandleLeakCount );
-        // Trace it.
-        RDebug::Print( KTraceMessage, aProcessId, &buffer2 );
-        }
-    // Process end trace.
-    TBuf<KProcessEndBufLength> buffer;
-    buffer.Format( KProcessEnd16, aProcessId );
-    buffer.AppendNum( CurrentTime(), EHex);
-    buffer.Append( KNewLineTrace );
-    RDebug::Print( KTraceMessage, aProcessId, &buffer );
+        TBuf8<KHandleLeakBufLength> buffer2;
+        
+        // AT indentifier
+        buffer2.Append( KATIdentifier );
+        // process id
+        buffer2.AppendNum( aProcessId, EHex );
+        buffer2.Append( KSpace );
+        
+        // HDL
+        buffer2.Append( KHandleLeak );
+        // leak count
+        buffer2.AppendNum( aHandleLeakCount );
+
+        RDebug::RawPrint( buffer2 );
+    	}
+    
+    // Buffer to trace.
+    TBuf8<KProcessEndBufLength> buffer;
+    
+    // AT indentifier
+    buffer.Append( KATIdentifier );
+    // process id
+    buffer.AppendNum( aProcessId, EHex );
+    buffer.Append( KSpace );
+    
+    // PCE
+    buffer.Append( KProcessEnd );
+    RDebug::RawPrint( buffer );
+    
+        
     return KErrNone;
     }
 
@@ -83,15 +130,31 @@
                                         TUint32 aEndAddress )
     {
     LOGSTR1( "ATFL ATFastLogDllLoaded()" );
-    // Timestamp.
-    TInt64 time = CurrentTime();
-    // Convert dll name to 16-bit descriptor.
-    TBuf<KMaxLibraryName> dll;
-    dll.Copy( aDllName );
+    
+    // DLL <DLL name> <Memory start address> <Memory end address>
+    
     // Buffer to trace.
-    TBuf<KDllLoadBufLength> buffer;
-    buffer.Format( KDllLoad16, &dll, time, aStartAddress, aEndAddress );
-    RDebug::Print( KTraceMessage, aProcessId, &buffer );
+    TBuf8<KDllLoadBufLength> buffer;
+    
+    // AT indentifier
+    buffer.Append( KATIdentifier );
+    // process id
+    buffer.AppendNum( aProcessId, EHex  );
+    buffer.Append( KSpace );
+    
+    // DLL
+    buffer.Append( KDllLoad );
+    // dll name
+    buffer.Append( aDllName );
+    buffer.Append( KSpace );
+    // start adress
+    buffer.AppendNum( aStartAddress, EHex );
+    buffer.Append( KSpace );   
+    //end adress
+    buffer.AppendNum( aEndAddress, EHex );
+    
+    RDebug::RawPrint( buffer );
+    
     return KErrNone;
     }
 
@@ -99,67 +162,77 @@
                                        TUint32 aEndAddress )
     {
     LOGSTR1( "ATFL ATFastLogDllUnloaded()" );
-    // Timestamp.
-    TInt64 time = CurrentTime();
-    // Convert dll name to 16-bit descriptor.
-    TBuf<KMaxLibraryName> dll;
-    dll.Copy( aDllName );
+    
+    // DLU <DLL name> <Memory start address> <Memory end address>
+    
     // Buffer to trace.
-    TBuf<KDllLoadBufLength> buffer;
-    buffer.Format( KDllUnload16, &dll, time, aStartAddress, aEndAddress );
-    RDebug::Print( KTraceMessage, aProcessId, &buffer );   
+    TBuf8<KDllUnloadBufLength> buffer;
+    
+    // AT indentifier
+    buffer.Append( KATIdentifier );
+    // process id
+    buffer.AppendNum( aProcessId, EHex  );
+    buffer.Append( KSpace );
+    
+    // DLU
+    buffer.Append( KDllUnload );
+    // dll name
+    buffer.Append( aDllName );
+    buffer.Append( KSpace );
+    // start adress
+    buffer.AppendNum( aStartAddress, EHex );
+    buffer.Append( KSpace );   
+    //end adress
+    buffer.AppendNum( aEndAddress, EHex );
+    
+    RDebug::RawPrint( buffer );
+
     return KErrNone;
     }
 
 TInt ATFastLogMemoryAllocated( TUint aProcessId, TUint32 aMemAddress,
                                   TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
-                                  TInt aSize )
+                                  TInt aSize, TUint aThreadId )
     {
     LOGSTR1( "ATFL ATFastLogMemoryAllocated()" );
-    // ALLOCH <Memory address> <Time stamp> <Allocation size> <Call stack address count> 
-    // <Call stack address> <Call stack address> ...
-    
-    // Timestamp.
-    TInt64 time = CurrentTime();
     
-    // Trace buffer and pointer to it.
-    TBufC<KMemAllocBufLength> buffer;
-    TPtr ptr( buffer.Des() );
-    // Append the tag implying a memory allocation line in the data file
-    ptr.Append( KMemoryAllocHeader );
+    // ALH <Memory address> <Allocation size> <Thread ID> 
+    // <Call stack address count> <Call stack address> <Call stack address> ...
+        
+    // Buffer to trace.
+    TBuf8<KMemAllocBufLength> buffer;
     
-    // Append the start address of this allocation in the 32-bit (max 8 characters)
-    // hexadecimal text format.
-    ptr.AppendNum( aMemAddress, EHex );
-    
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format
-    ptr.Append( KSpaceTrace );
-    ptr.AppendNum( time, EHex );
+    // AT indentifier
+    buffer.Append( KATIdentifier );
+    // process id
+    buffer.AppendNum( aProcessId, EHex  );
+    buffer.Append( KSpace );
     
-    // Append the size of the allocation in the 32-bit (max 8 characters) hexadecimal
-    // text format.
-    ptr.Append( KSpaceTrace );
-    ptr.AppendNum( aSize, EHex );
-    
+    // ALH
+    buffer.Append( KMemoryAllocHeader );
+    // memory adress
+    buffer.AppendNum( aMemAddress, EHex );
+    buffer.Append( KSpace );
+    // allocation size
+    buffer.AppendNum( aSize, EHex );
+    buffer.Append( KSpace ); 
+    // thread ID
+    buffer.AppendNum( aThreadId, EHex );
+    buffer.Append( KSpace );
+
     // Search call stack for address count.
-    TInt addrCount(0);
-    for ( TInt j = 0; j < aCallstack.Count() ; j++ )
-        {
-        if ( aCallstack.At(j) == 0 )
-            break;
-        addrCount++;
-        }
-    // Current position in call stack.
-    TInt addrPos( 0 );
+	TInt addrCount(0);
+	for ( TInt j = 0; j < aCallstack.Count() ; j++ )
+		{
+		if ( aCallstack.At(j) == 0 )
+			break;
+		addrCount++;
+		}
+	// Current position in call stack.
+	TInt addrPos( 0 );
     
-    // Append address count.
-    ptr.Append( KSpaceTrace );
-    ptr.AppendNum( addrCount, EHex );
-            
-    // Calculate last item length
-    TInt lastItemLength( KTraceMessage().Length() + KHexa32Length + 
-            KSpaceLength + KNewlineLength );
+    // address count
+    buffer.AppendNum( addrCount, EHex );
     
     TUint packetNumber( 1 );
     
@@ -167,132 +240,310 @@
     // this memory allocation 
     for ( TInt j = 0; j < addrCount; j++ )
         {
-        // ALLOCF <Memory address> <Time stamp> <Packet number> 
-        // <Call stack address> <Call stack address> ...
-        if ( ptr.Length() <= 0 )
-            {               
+        // ALF <Memory address> <Packet number> <Call stack address> <Call stack address> ...
+        if ( buffer.Length() <= 0 )
+            {
+            // AT indentifier
+            buffer.Append( KATIdentifier );
+            // process id
+            buffer.AppendNum( aProcessId, EHex  );
+            buffer.Append( KSpace ); 
+            
             // Create alloc fragment message header
-            ptr.Append( KMemoryAllocFragment );
-            ptr.AppendNum( aMemAddress, EHex );
-            ptr.Append( KSpaceTrace );
-            ptr.AppendNum( time, EHex );
-            ptr.Append( KSpaceTrace );        
-            ptr.AppendNum( packetNumber, EHex );
+            buffer.Append( KMemoryAllocFragment );
+            buffer.AppendNum( aMemAddress, EHex );
+            buffer.Append( KSpace );     
+            buffer.AppendNum( packetNumber, EHex );
             // Increase packet number
             packetNumber++;
             }
       
         // Append call stack address.
-        ptr.AppendFormat( KHexaNumberTrace, aCallstack.At( addrPos ) );
+        buffer.Append( KSpace );
+        buffer.AppendNum( aCallstack.At( addrPos ), EHex );
         
         // Move the call stack position.
         addrPos++;
         
         // Check if buffer max length exceed
-        if ( lastItemLength + ptr.Length() >= KMemAllocBufLength )
+        if ( KLastItemLength + buffer.Length() >= KMemAllocBufLength )
             {
-            ptr.Append( KNewLineTrace );
             // Log through debug channel 
-            RDebug::Print( KTraceMessage, aProcessId, &buffer );
+            RDebug::RawPrint( buffer );
             // Empty trace buffer
-            ptr.Delete( 0, ptr.MaxLength() );
+            buffer.Delete( 0, buffer.MaxLength() );
             }
         }
     // Send last message if exists.
-    if ( ptr.Length() > 0 )
+    if ( buffer.Length() > 0 )
         {
-        ptr.Append( KNewLineTrace );
-        RDebug::Print( KTraceMessage, aProcessId, &buffer);
+        RDebug::RawPrint( buffer );
         }
+ 
     return KErrNone;
     }
 
 
 TInt ATFastLogMemoryFreed( TUint aProcessId, TUint32 aMemAddress, 
-                              TFixedArray<TUint32, KATMaxFreeCallstackLength>& aFreeCallstack )
+                              TFixedArray<TUint32, KATMaxFreeCallstackLength>& aFreeCallstack,
+                              TUint aThreadId )
     {
     LOGSTR1( "ATFL ATFastLogMemoryFreed()" );
-    // FREEH <Memory address> <Time tamp> <Call stack address count> <Call stack address>
-    // <Call stack address> ...
-    
-    // Timestamp.
-    TInt64 time = CurrentTime();
-    
-    // Trace buffer and pointer to it.
-    TBufC<KMemFreedBufLength> buffer;
-    TPtr ptr( buffer.Des() );
- 
-    // Append the tag implying a memory allocation line in the data file
-    ptr.Append( KMemoryFreedHeader );
-    
-    // Append the start address of this allocation in the 32-bit (max 8 characters)
-    // hexadecimal text format.
-    ptr.AppendNum( aMemAddress, EHex );
+
+	// FRH <Memory address> <Thread ID> <Call stack address count> 
+	// <Call stack address> <Call stack address> ...
+	
+	// Buffer to trace.
+	TBuf8<KMemFreedBufLength> buffer;
+
+	// AT indentifier
+	buffer.Append( KATIdentifier );
+	// process id
+	buffer.AppendNum( aProcessId, EHex  );
+	buffer.Append( KSpace );
+	
+	// FRH
+	buffer.Append( KMemoryFreedHeader );
+	
+	// Append the start address of this allocation in the 32-bit (max 8 characters)
+	// hexadecimal text format.
+	buffer.AppendNum( aMemAddress, EHex );
+	buffer.Append( KSpace );
+	
+	// thread ID
+	buffer.AppendNum( aThreadId, EHex );
+	buffer.Append( KSpace );
+	
+	// Search call stack for address count.
+	TInt addrCount(0);
+	for ( TInt j = 0; j < aFreeCallstack.Count() ; j++ )
+		{
+		if ( aFreeCallstack.At(j) == 0 )
+			break;
+		addrCount++;
+		}
+	// Current position in call stack.
+	TInt addrPos( 0 );
+	
+	// address count.
+	buffer.AppendNum( addrCount, EHex );
+	
+	TUint packetNumber( 1 );
+	
+	// Go through all call stack's memory addresses associated with
+	// this memory allocation 
+	for ( TInt j = 0; j < addrCount; j++ )
+		{
+		// FRF <Memory address> <Packet number> 
+		// <Call stack address> <Call stack address> ...
+		if ( buffer.Length() <= 0 )
+			{               
+			// Create alloc fragment message header
+			buffer.Append( KMemoryFreedFragment );
+			buffer.AppendNum( aMemAddress, EHex );
+			buffer.Append( KSpace );
+			buffer.AppendNum( packetNumber, EHex );
+			// Increase packet number
+			packetNumber++;
+			}
+	  
+		// Append call stack address.
+		buffer.Append( KSpace );
+		buffer.AppendNum( aFreeCallstack.At( addrPos ), EHex );
+		
+		// Move the call stack position.
+		addrPos++;
+		
+		// Check if buffer max length exceed
+		if ( KLastItemLength + buffer.Length() >= KMemFreedBufLength )
+			{
+			// Log through debug channel 
+			RDebug::RawPrint( buffer );
+			// Empty trace buffer
+			buffer.Delete( 0, buffer.MaxLength() );
+			}
+		}
+	// Send last message if exists.
+	if ( buffer.Length() > 0 )
+		{
+		RDebug::RawPrint( buffer );
+		}
+		
+    return KErrNone;   
+    }
+
+TInt ATFastLogMemoryReallocated( TUint aProcessId, TUint32 aMemAddressFree,  TUint32 aMemAddressAlloc,
+                                  TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
+                                  TInt aSize, TUint aThreadId )
+    {
+    LOGSTR1( "ATFL ATFastLogMemoryReallocated()" );    
     
-    // Append timestamp;
-    ptr.Append( KSpaceTrace );
-    ptr.AppendNum( time, EHex);
+    // RAH <Freed memory address> <Allocated memory address> <Allocation size> <Thread ID>
+    // <Call stack address count> <Call stack address> <Call stack address> ...
+        
+    // Buffer to trace.
+    TBuf8<KMemReallocBufLength> buffer;
+    
+    // AT indentifier
+    buffer.Append( KATIdentifier );
+    // process id
+    buffer.AppendNum( aProcessId, EHex  );
+    buffer.Append( KSpace );
     
+    // RAH
+    buffer.Append( KMemoryReallocHeader );
+    // memory adress freed
+    buffer.AppendNum( aMemAddressFree, EHex );
+    buffer.Append( KSpace );
+    // memory adress allocated
+    buffer.AppendNum( aMemAddressAlloc, EHex );
+    buffer.Append( KSpace );
+    // allocation size
+    buffer.AppendNum( aSize, EHex );
+    buffer.Append( KSpace ); 
+    // thread ID
+    buffer.AppendNum( aThreadId, EHex );
+    buffer.Append( KSpace );
+
     // Search call stack for address count.
-    TInt addrCount(0);
-    for ( TInt j = 0; j < aFreeCallstack.Count() ; j++ )
-        {
-        if ( aFreeCallstack.At(j) == 0 )
-            break;
-        addrCount++;
-        }
-    // Current position in call stack.
-    TInt addrPos( 0 );
+	TInt addrCount(0);
+	for ( TInt j = 0; j < aCallstack.Count() ; j++ )
+		{
+		if ( aCallstack.At(j) == 0 )
+			break;
+		addrCount++;
+		}
+	// Current position in call stack.
+	TInt addrPos( 0 );
     
-    // Append address count.
-    ptr.Append( KSpaceTrace );
-    ptr.AppendNum( addrCount, EHex );
-            
-    // Calculate last item length
-    TInt lastItemLength( KTraceMessage().Length() + KHexa32Length + 
-            KSpaceLength + KNewlineLength );
-    
+    // address count
+    buffer.AppendNum( addrCount, EHex );
+        
     TUint packetNumber( 1 );
     
     // Go through all call stack's memory addresses associated with
     // this memory allocation 
     for ( TInt j = 0; j < addrCount; j++ )
         {
-        // ALLOCF <Memory address> <Time stamp> <Packet number> 
+        // RAF <Freed memory address> <Allocated memory address> <Packet number>
         // <Call stack address> <Call stack address> ...
-        if ( ptr.Length() <= 0 )
-            {               
+        if ( buffer.Length() <= 0 )
+            {
+            // AT indentifier
+            buffer.Append( KATIdentifier );
+            // process id
+            buffer.AppendNum( aProcessId, EHex  );
+            buffer.Append( KSpace ); 
+            
             // Create alloc fragment message header
-            ptr.Append( KMemoryFreedFragment );
-            ptr.AppendNum( aMemAddress, EHex );
-            ptr.Append( KSpaceTrace );
-            ptr.AppendNum( packetNumber, EHex );
+            buffer.Append( KMemoryReallocFragment );
+            // memory adress freed
+            buffer.AppendNum( aMemAddressFree, EHex );
+            buffer.Append( KSpace );
+            // memory adress allocated
+            buffer.AppendNum( aMemAddressAlloc, EHex );
+            buffer.Append( KSpace );
+            // packet number
+            buffer.AppendNum( packetNumber, EHex );
             // Increase packet number
             packetNumber++;
             }
       
         // Append call stack address.
-        ptr.AppendFormat( KHexaNumberTrace, aFreeCallstack.At( addrPos ) );
+        buffer.Append( KSpace );
+        buffer.AppendNum( aCallstack.At( addrPos ), EHex );
         
         // Move the call stack position.
         addrPos++;
         
         // Check if buffer max length exceed
-        if ( lastItemLength + ptr.Length() >= KMemFreedBufLength )
+        if ( KLastItemLength + buffer.Length() >= KMemAllocBufLength )
             {
-            ptr.Append( KNewLineTrace );
             // Log through debug channel 
-            RDebug::Print( KTraceMessage, aProcessId, &buffer );
+            RDebug::RawPrint( buffer );
             // Empty trace buffer
-            ptr.Delete( 0, ptr.MaxLength() );
+            buffer.Delete( 0, buffer.MaxLength() );
             }
         }
     // Send last message if exists.
-    if ( ptr.Length() > 0 )
+    if ( buffer.Length() > 0 )
         {
-        ptr.Append( KNewLineTrace );
-        RDebug::Print( KTraceMessage, aProcessId, &buffer);
+        RDebug::RawPrint( buffer);
         }
-    return KErrNone;   
+      
+    return KErrNone;
+    }
+
+TInt ATFastLogThreadStarted( TUint aProcessId, TUint aThreadId )
+    {
+    LOGSTR1( "ATFL ATFastLogThreadStarted()" );
+    
+    // TDS <Thread ID>
+
+    //Buffer to trace
+    TBuf8<KThreadStartBufLength> buffer;
+    
+    // AT indentifier
+    buffer.Append( KATIdentifier );
+    // process id
+    buffer.AppendNum( aProcessId, EHex  );
+    buffer.Append( KSpace );
+    
+    // TDS
+    buffer.Append( KThreadStart );
+    // thread ID
+    buffer.AppendNum( aThreadId, EHex );
+
+    RDebug::RawPrint( buffer );
+       
+    return KErrNone;
     }
 
+TInt ATFastLogThreadEnded( TUint aProcessId, TUint64 aThreadId )
+    {
+    LOGSTR1( "ATFL ATFastLogThreadEnded()" );
+    
+    // TDE <Thread ID>
+
+    //Buffer to trace
+    TBuf8<KThreadEndBufLength> buffer;
+    
+    // AT indentifier
+    buffer.Append( KATIdentifier );
+    // process id
+    buffer.AppendNum( aProcessId, EHex  );
+    buffer.Append( KSpace );
+    
+    // TDE
+    buffer.Append( KThreadEnd );
+    // thread ID
+    buffer.AppendNum( aThreadId, EHex );
+
+    RDebug::RawPrint( buffer );
+       
+    return KErrNone;
+    }
+
+TInt ATFastLogDeviceInfo( const TDesC8& aS60Version, const TDesC8& aChecksum)
+    {
+    LOGSTR1( "ATFL ATFastLogVersionsInfo()" );
+    
+    //Buffer to trace
+    TBuf8<KVersionsInfoBufLength> buffer;
+    
+    // AT indentifier
+    buffer.Append( KATIdentifier );
+    
+    // VER
+    buffer.Append( KVersionsInfo );
+    
+    // sw version
+    buffer.Append(aS60Version);
+    buffer.Append(KSpace);
+    // rom checksum
+    buffer.Append(aChecksum);
+
+    RDebug::RawPrint( buffer );
+    
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/dynamicmemoryhook/src/analyzetoolfilelog.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,603 @@
+/*
+* Copyright (c) 2010 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:  Declaration of the class TATDriveInfo.
+*
+*/
+
+#include "analyzetoolfilelog.h"
+#include "atdriveinfo.h"
+#include "atlog.h"
+#include <analyzetool/customuser.h>
+#include <analyzetool/analyzetooltraceconstants.h>
+#include <f32file.h> //RFs
+#include <utf.h>
+
+// New file name start and end index.
+const TInt KNameIndexStart = 1;
+const TInt KNameIndexEnd = 100;
+
+RATFileLog::RATFileLog()
+	{
+
+    // Initialize iMicroSecondsAt1970
+    TTime time( KJanuaryFirst1970 );
+    iMicroSecondsAt1970 = time.Int64();
+    iError = KErrNone;
+	}
+
+RATFileLog::~RATFileLog()
+	{
+	// Auto-generated destructor stub
+	}
+
+
+// Local time function.
+TInt64 RATFileLog::CurrentTime()
+    {
+    LOGSTR1( "ATFL void CATStorageServerSession::GetTime()" );
+    
+    // Get the current universal time
+    TTime time;
+    time.UniversalTime();
+        
+    // Change the time format that tells the number of microseconds from January First,
+    // 0 AD nominal Gregorian, into a format that tells the number of microseconds from
+    // January First, 1970 AD nominal Gregorian. This is a more generic format and
+    // can be directly exploited by the PC code parsing the data file that this
+    // server generates.        
+    return ( time.Int64() - iMicroSecondsAt1970 );        
+    }
+
+TInt RATFileLog::ATFileLogVersion()
+{
+    LOGSTR1( "ATFL CATFileLog::ATFileLogVersion()" );
+    
+    iFile << KDataFileVersion;
+
+    iFile.CommitL();   
+    return KErrNone;
+}
+
+TInt RATFileLog::ATFileLogProcessStarted( const TDesC8& aProcessName,
+                                          TUint aProcessId,
+                                          TUint32 aIsDebug,
+                                          const TDesC8& aAtoolVersion,
+                                          const TDesC8& aApiVersion )
+{
+    LOGSTR1( "ATFL CATFileLog::ATFileLogProcessStarted()" );
+ 
+    // log the current time
+    iFile << this->CurrentTime();
+    
+    // <Time stamp> PCS <Process name> <Process ID> <Udeb> <Version>
+    iFile << (TUint8)EProcessStart;
+    iFile << aProcessName;
+    iFile << (TUint32)aProcessId;
+    iFile << aIsDebug;
+    iFile << aAtoolVersion;
+    iFile << aApiVersion;
+    
+    // ensure that any buffered data is written to the stream
+    iFile.CommitL();
+    
+    return KErrNone;
+}
+
+// -----------------------------------------------------------------------------
+// RATFileLog::ATFileLogProcessEnded
+// 
+// -----------------------------------------------------------------------------
+// 
+TInt RATFileLog::ATFileLogProcessEnded( TUint aHandleLeakCount )
+{
+	LOGSTR1( "ATFL CATFileLog::ATFileLogProcessEnded()" );
+	   
+	if ( aHandleLeakCount > 0 )
+	{
+		// HDL <Handle count>
+		iFile << this->CurrentTime();
+        iFile << (TUint8)EHandleLeak;
+        iFile << (TUint32)aHandleLeakCount;	
+	}
+
+	// log the current time
+    iFile << this->CurrentTime();
+	
+	// PCE
+	iFile << (TUint8)EProcessEnd;
+	
+    // ensure that any buffered data is written to the stream
+    iFile.CommitL();
+	
+	return KErrNone;	
+}
+
+
+// -----------------------------------------------------------------------------
+// RATFileLog::ATFileLogDllLoaded
+// 
+// -----------------------------------------------------------------------------
+// 
+TInt RATFileLog::ATFileLogDllLoaded( const TDesC8& aDllName, TUint32 aStartAddress,
+                                TUint32 aEndAddress )
+{
+	LOGSTR1( "ATFL CATFileLog::ATFileLogDllLoaded()" );
+	    
+	// log the current time
+	iFile << this->CurrentTime();
+	
+	// DLL <DLL name> <Memory start address> <Memory end address>
+
+	// DLL
+	iFile << (TUint8)EDllLoad;
+	// dll name
+	iFile << aDllName;
+	// start adress
+	iFile << aStartAddress;
+	//end adress
+	iFile << aEndAddress;
+	
+	// ensure that any buffered data is written to the stream
+	iFile.CommitL();
+	
+	return KErrNone;
+}
+
+
+
+// -----------------------------------------------------------------------------
+// RATFileLog::ATFileLogDllUnloaded
+// 
+// -----------------------------------------------------------------------------
+// 
+TInt RATFileLog::ATFileLogDllUnloaded( const TDesC8& aDllName, TUint32 aStartAddress,
+                                       TUint32 aEndAddress )
+{
+    LOGSTR1( "ATFL CATFileLog::ATFileLogDllUnloaded()" );
+
+    // log the current time
+    iFile << this->CurrentTime();
+    
+    // DLU <DLL name> <Memory start address> <Memory end address>
+    
+    // DLU
+    iFile << (TUint8)EDllUnload;
+    // dll name
+    iFile << aDllName;
+    // start adress
+    iFile << aStartAddress;
+    //end adress
+    iFile << aEndAddress;
+    
+    // ensure that any buffered data is written to the stream
+    iFile.CommitL();
+	
+	return KErrNone;
+		
+}
+
+
+// -----------------------------------------------------------------------------
+// RATFileLog::ATFileLogMemoryAllocated
+// 
+// -----------------------------------------------------------------------------
+// 
+TInt RATFileLog::ATFileLogMemoryAllocated( TUint32 aMemAddress,
+                                  TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
+                                  TInt aSize,  TUint aThreadId  )
+{
+	LOGSTR1( "ATFL CATFileLog::ATFileLogMemoryAllocated()" );
+	
+	// ALH <Memory address> <Allocation size> <Thread ID> 
+	// <Call stack address count> <Call stack address> <Call stack address> ...
+	
+	// log the current time
+	iFile << this->CurrentTime();
+
+	// ALH
+	iFile << (TUint8)EAllocH;
+	// memory adress
+	iFile << aMemAddress;
+	// allocation size
+	iFile << (TUint32)aSize;
+	// thread ID
+	iFile << (TUint32)aThreadId;
+
+	// Search call stack for address count.
+	TInt addrCount(0);
+	for ( TInt j = 0; j < aCallstack.Count() ; j++ )
+		{
+		if ( aCallstack.At(j) == 0 )
+			break;
+		addrCount++;
+		}
+	
+	// address count
+    iFile << (TUint32)addrCount;
+		
+	// Go through all call stack's memory addresses associated with
+	// this memory allocation 
+	for ( TInt addrPos = 0; addrPos < addrCount; addrPos++ )
+		{
+	    iFile <<  aCallstack.At( addrPos );
+		}
+
+	// ensure that any buffered data is written to the stream
+	iFile.CommitL();
+
+	return KErrNone;	
+}
+
+
+// -----------------------------------------------------------------------------
+// RATFileLog::ATFileLogMemoryFreed
+// 
+// -----------------------------------------------------------------------------
+// 
+TInt RATFileLog::ATFileLogMemoryFreed( TUint32 aMemAddress, 
+		                                  TFixedArray<TUint32, KATMaxFreeCallstackLength>& aFreeCallstack, 
+		                                  TUint aThreadId )
+{
+    LOGSTR1( "ATFL CATFileLog::ATFileLogMemoryFreed()" );
+	
+	// FRH <Memory address> <Thread ID> <Call stack address count> 
+	// <Call stack address> <Call stack address> ...
+
+	// log the current time
+	iFile << this->CurrentTime();
+
+	// FRH
+	iFile << (TUint8)EFreeH;
+	
+	// Append the start address of this allocation in the 32-bit (max 8 characters)
+	// hexadecimal text format.
+	iFile << aMemAddress;
+
+	// thread ID
+	iFile << (TUint32)aThreadId;
+	
+	// Search call stack for address count.
+	TInt addrCount(0);
+	for ( TInt j = 0; j < aFreeCallstack.Count() ; j++ )
+		{
+		if ( aFreeCallstack.At(j) == 0 )
+			break;
+		addrCount++;
+		}
+	
+	// address count.
+	iFile << (TUint32)addrCount;
+
+	// Go through all call stack's memory addresses associated with
+	// this memory allocation 
+	for ( TInt addrPos = 0; addrPos < addrCount; addrPos++ )
+		{
+		iFile << aFreeCallstack.At( addrPos );
+		}
+
+	// ensure that any buffered data is written to the stream
+	iFile.CommitL();
+
+	return KErrNone;		
+}
+
+
+// -----------------------------------------------------------------------------
+// RATFileLog::ATFileLogMemoryReallocated
+// 
+// -----------------------------------------------------------------------------
+// 
+TInt RATFileLog::ATFileLogMemoryReallocated( TUint32 aMemAddressFree,  TUint32 aMemAddressAlloc,
+                                  TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
+                                  TInt aSize,  TUint aThreadId  )
+{
+	LOGSTR1( "ATFL CATFileLog::ATFileLogMemoryReallocated()" );    
+	    
+	// RAH <Freed memory address> <Allocated memory address> <Allocation size> <Thread ID>
+	// <Call stack address count> <Call stack address> <Call stack address> ...
+	        
+    // log the current time
+    iFile << this->CurrentTime();
+	
+	// RAH
+    iFile <<  (TUint8)EReallocH;
+	// memory adress freed
+    iFile << aMemAddressFree;
+	// memory adress allocated
+    iFile << aMemAddressAlloc;
+	// allocation size
+    iFile << (TUint32)aSize;
+	// thread ID
+    iFile << (TUint32)aThreadId;
+
+	// Search call stack for address count.
+	TInt addrCount(0);
+	for ( TInt j = 0; j < aCallstack.Count() ; j++ )
+		{
+		if ( aCallstack.At(j) == 0 )
+			break;
+		addrCount++;
+		}
+	
+	// address count
+	iFile << (TUint32)addrCount;
+		
+	// Go through all call stack's memory addresses associated with
+	// this memory allocation 
+	for ( TInt addrPos = 0; addrPos < addrCount; addrPos++ )
+		{	  
+		// Append call stack address.
+		iFile << aCallstack.At( addrPos );
+		}
+
+	// ensure that any buffered data is written to the stream
+	iFile.CommitL();
+
+	return KErrNone;	
+}
+
+
+// -----------------------------------------------------------------------------
+// RATFileLog::ATFileLogThreadStarted
+// 
+// -----------------------------------------------------------------------------
+// 
+TInt RATFileLog::ATFileLogThreadStarted( TUint aThreadId )
+{
+	LOGSTR1( "ATFL CATFileLog::ATFileLogThreadStarted()" );
+
+	// log the current time
+	iFile << this->CurrentTime();
+	
+	// TDS <Thread ID>
+
+	// TDS
+	iFile << (TUint8)EThreadStart;
+	// thread ID
+	iFile << (TUint32)aThreadId;
+    
+    // ensure that any buffered data is written to the stream
+    iFile.CommitL();
+
+	return KErrNone;
+}
+
+
+// -----------------------------------------------------------------------------
+// RATFileLog::ATFileLogThreadEnded
+// 
+// -----------------------------------------------------------------------------
+// 
+TInt RATFileLog::ATFileLogThreadEnded( TUint64 aThreadId )
+{
+	  LOGSTR1( "ATFL CATFileLog::ATFileLogThreadEnded()" );
+
+		// log the current time
+		iFile << this->CurrentTime();
+		
+		// TDE <Thread ID>
+
+		// TDE
+		iFile << (TUint8)EThreadEnd;
+		// thread ID
+		iFile << (TUint32)aThreadId;
+	    
+	    // ensure that any buffered data is written to the stream
+	    iFile.CommitL();
+
+		return KErrNone;
+}
+
+
+// -----------------------------------------------------------------------------
+// RATFileLog::ATFileLogDeviceInfo
+// 
+// -----------------------------------------------------------------------------
+// 
+TInt RATFileLog::ATFileLogDeviceInfo( const TDesC8& aS60Version, const TDesC8& aChecksum)
+
+{
+    LOGSTR1( "ATFL CATFileLog::ATFileLogVersionsInfo()" );
+
+    // log the current time
+    iFile << this->CurrentTime();
+
+    // VER
+    iFile << (TUint8)EDeviceInfo;
+    // sw version
+    iFile << aS60Version;
+    // rom checksum
+    iFile << aChecksum;
+
+    // ensure that any buffered data is written to the stream
+    iFile.CommitL();
+
+	return KErrNone;	
+}
+
+
+
+// -----------------------------------------------------------------------------
+// RATFileLog::OpenFsAndFile
+// Internally used for opening a handle to the file server and a file
+// -----------------------------------------------------------------------------
+// 
+TInt RATFileLog::OpenFsAndFile( const TDesC& aFileName, const TDesC& aFilePath, 
+    const TDesC8& aProcessName )
+    {
+    LOGSTR1( "ATFL TInt CATFileLog::OpenFsAndFile()" );
+    
+    // Connect file server, return if error occured
+    iError = iFileServer.Connect();
+    if ( iError )
+        {
+        iFileServer.Close();
+        return iError;
+        }
+    
+    iError = iFileServer.ShareAuto();
+    if( iError )
+    	{
+		iFileServer.Close();
+		return iError;
+    	}
+
+    // Open a file
+    TBuf<KMaxFileName> fileNameBuf;  
+    
+    iError = TATDriveInfo::CreatePath( fileNameBuf, aFileName, aFilePath, iFileServer );
+                        
+    // Return, if an error occured, and it
+    // is not KErrAlreadyExists
+    if ( iError && iError != KErrAlreadyExists )
+        {
+        iFileServer.Close();
+        return iError;
+        }
+
+    // if file already exist, generat new filename with index
+    GenerateNewFileName( fileNameBuf, aProcessName );
+    
+    // Save the file name for this session
+    CnvUtfConverter::ConvertFromUnicodeToUtf8( iLogFile, fileNameBuf );
+    
+    LOGSTR2( "ATFL > iError(%i)", iError );
+        
+    // If the file does not exist, create it. Write also the version number of
+    // the file at the beginning of the new file
+    if ( iError == KErrNotFound )
+        {
+        iError = iFile.Create( iFileServer, fileNameBuf, EFileWrite | EFileShareAny );
+        if ( !iError )
+            {
+        	// todo
+            }
+        }
+       
+    if ( iError )
+        {
+        iFile.Close();
+        iFileServer.Close();
+        return iError;
+        }
+
+    return iError;
+    }
+
+// -----------------------------------------------------------------------------
+// RATFileLog::GenerateNewFileName
+// Called internally when need generate new file name.
+// -----------------------------------------------------------------------------
+//                     
+void RATFileLog::GenerateNewFileName( TDes& aFileName,
+    const TDesC8& aProcessName )
+    {    
+    LOGSTR1( "ATFL void CATFileLog::GenerateNewFileName()" );
+        
+    // Extension
+    TBuf<KExtensionLength> extension;
+        
+	// Check if file already exist
+	CheckIfFileAlreadyExist( aFileName );
+	if ( iError == KErrNotFound )
+		{
+	    // If not we can use filename without indexing
+		return;
+		}
+	
+	// File with aFileName already exist, let's add index
+	
+	// Parse file extension if exists.
+	ParseExtension( aFileName, extension );
+	
+	// Temp file name
+	TBuf<KMaxFileName> tempName;
+	
+	for ( TInt i = KNameIndexStart; i < KNameIndexEnd; i++ )
+		{
+		tempName.Delete( 0, tempName.MaxLength() );
+		tempName.Format( KFormat, &aFileName, &KLeftBracket, i, &KRightBracket, &extension );
+		LOGSTR2( "ATFL > tempName(%S)", &tempName );
+		// Try to open file
+		CheckIfFileAlreadyExist( tempName );
+		// File does not exist, this index can be used
+		if ( iError == KErrNotFound )
+			{
+			aFileName.Copy( tempName );
+			break;
+			}
+		}
+    }
+
+// -----------------------------------------------------------------------------
+// RATFileLog::ParseExtension
+// Method is used to parse file name extension.
+// -----------------------------------------------------------------------------
+//                     
+void RATFileLog::ParseExtension( 
+    TDes& aFileName, TDes& aExtension )
+    {    
+    LOGSTR2( "ATFL void CATFileLog::ParseExtension(%S)", 
+            &aFileName );
+
+    // Parse current file name
+    TParse parse;
+    // Set up the TParse object 
+    parse.Set( aFileName, NULL, NULL );
+
+    // Tests whether an extension is present.
+    if ( parse.ExtPresent() )
+        {
+        // Gets the extension
+        aExtension.Copy( parse.Ext() );
+        // Remove extension from file name
+        TInt pos( aFileName.Find( aExtension ) );
+        aFileName.Delete( pos, aFileName.Length() );
+        LOGSTR3( "ATFL > aFileName(%S), aExtension(%S)", 
+                &aFileName, &aExtension );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// RATFileLog::CheckIfFileAlreadyExist
+// Method is used to check that file exists and is valid.
+// -----------------------------------------------------------------------------
+//                     
+void RATFileLog::CheckIfFileAlreadyExist( 
+    const TDes& aFileName )
+    {    
+    LOGSTR2( "ATFL void CATFileLog::CheckIfFileAlreadyExist(%S)", 
+            &aFileName );
+    
+    iError = iFile.Open( iFileServer, aFileName, EFileWrite );
+    LOGSTR2( "ATFL > iError(%i)", iError );
+    }
+
+
+// -----------------------------------------------------------------------------
+// RATFileLog::CloseFsAndFile
+// Internally used for closing a handle to the file server and a file
+// -----------------------------------------------------------------------------
+// 
+void RATFileLog::CloseFsAndFile()
+    {
+    LOGSTR1( "ATFL void CATFileLog::CloseFsAndFile()" );
+    
+    // Close the file    
+    iFile.Close();
+                 
+    // Close the server session and return the error code   
+    iFileServer.Close();
+    }
+
--- 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
--- a/analyzetool/dynamicmemoryhook/src/analyzetoolmemoryallocator.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/src/analyzetoolmemoryallocator.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -27,8 +27,7 @@
 //
 RAnalyzeToolMemoryAllocator::RAnalyzeToolMemoryAllocator( TBool aNotFirst ) :
     RAllocator(),
-    iNotFirst( aNotFirst )/*,
-    iStorageServerOpen( EFalse )*/
+    iNotFirst( aNotFirst )
     {
     LOGSTR1( "ATMH RAnalyzeToolMemoryAllocator::RAnalyzeToolMemoryAllocator()" );
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analyzetool/dynamicmemoryhook/src/atdriveinfo.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,216 @@
+/*
+* 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:  Definitions for the class TATDriveInfo.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <driveinfo.h>
+#include "atdriveinfo.h"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// TATDriveInfo::TATDriveInfo
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+TATDriveInfo::TATDriveInfo()
+    {
+    LOGSTR1( "TATD TATDriveInfo::TATDriveInfo()" );
+    }
+
+// -----------------------------------------------------------------------------
+// TATDriveInfo::CreatePath()
+// -----------------------------------------------------------------------------
+//    
+TInt TATDriveInfo::CreatePath( TDes& aPath, 
+    const TDesC& aFileName, const TDesC& aFilePath, RFs& aFs )
+    {
+    LOGSTR1( "TATD TInt TATDriveInfo::CreatePath()" );
+    TInt err( KErrNotFound );
+    
+    // first try to create user defined directory
+    if( aFilePath.Length()>0 )
+    	{
+		err = aFs.MkDir( aFilePath );
+		LOGSTR2( "STSE > defined path aFs.MkDir err = %i", err );
+		
+		if ( !err || err == KErrAlreadyExists )
+			{
+			//directory was succesfully created or exists
+			aPath.Copy( aFilePath );
+			if ( aFileName.Length() != 0 && 
+				 ( ( aPath.MaxLength() - aPath.Length() ) > aFileName.Length() ) )
+				{
+				aPath.Append( aFileName );
+				}
+			return err;
+			}
+		else if( err == KErrBadName )
+			{
+			// TODO bad path, log error
+			// log default name in the end of function
+			}
+    	}
+	
+
+
+	//error when trying to create user defined directory, lets use default paths
+    
+    // Drive letter    
+    TChar driveLetter;
+    // Drive number
+    TInt dNumber( EDriveZ );     
+    TBool found( EFalse );
+    // Drive type
+    TUint driveType( KDriveAttRemovable );    
+    
+    
+    while ( !found )
+        {
+        // Get drive letter
+        if ( GetDrive( driveLetter, dNumber, aFs, driveType ) == KErrNotFound )
+        	{
+        	if ( driveType == KDriveAttInternal )
+        		{
+                return KErrNotFound;
+        		}       	
+            driveType = KDriveAttInternal;
+        	dNumber = EDriveZ;
+        	}       
+        else
+        	{
+			// Create path
+			aPath.Delete( 0, aPath.MaxLength() );
+			aPath.Append( driveLetter );
+		  
+		            
+		#ifdef __WINS__
+            // For emulator the data file is stored to different location
+            aPath.Append( KATDataFilePath );       
+		#else
+		    TDriveInfo driveInfo;
+		    aFs.Drive( driveInfo, dNumber );      
+            // The drive is removable( memory card ) so we can log inside of root folder
+            if ( driveInfo.iDriveAtt & KDriveAttRemovable )
+                {
+                aPath.Append( KATDataFilePath );       
+                }
+            // The drive is internal user can only access data folder so log into that
+            else
+                {
+                aPath.Append( KATDataFilePath2 );       
+                }
+		#endif
+						
+			// Make a directory for logging data file
+			err = aFs.MkDir( aPath );
+			LOGSTR2( "STSE > aFs.MkDir err = %i", err );
+			
+			if ( !err || err == KErrAlreadyExists )
+				{                
+                if ( aFileName.Length() != 0 && 
+                     ( ( aPath.MaxLength() - aPath.Length() ) > aFileName.Length() ) )
+                    {
+                    aPath.Append( aFileName );
+                    }
+				found = ETrue;
+				}
+        	}
+        }        
+    return err;        
+    }
+
+// -----------------------------------------------------------------------------
+// TATDriveInfo::GetDrive()
+// -----------------------------------------------------------------------------
+//    
+TInt TATDriveInfo::GetDrive( TChar& aDrive, TInt& aDriveNumber, RFs& aFs, 
+	const TUint aDriveType )
+    {
+    LOGSTR1( "TATD TInt TATDriveInfo::GetDrive()" );
+       
+    // Contains drive information.
+    TDriveInfo driveInfo; 
+    
+    for ( TInt i = aDriveNumber; i >= (TInt)EDriveA; i-- )
+        {
+        // Gets information about a drive and the medium mounted on it.
+        // If error occured then skip to next drive.
+        if ( aFs.Drive( driveInfo, i ) != KErrNone )
+            continue;
+                
+        // Test whether drive is available. If not, skip to next drive.
+        if ( driveInfo.iDriveAtt & KDriveAbsent || i == (TInt)EDriveD ||
+             driveInfo.iDriveAtt & KDriveAttRom || 
+             driveInfo.iMediaAtt & KMediaAttWriteProtected ||
+             driveInfo.iDriveAtt & KDriveFileSysROFS )
+            continue;
+        
+        // Maps a drive number to the corresponding character.
+        if ( aFs.DriveToChar( i, aDrive ) != KErrNone )
+            continue;                
+        
+        if ( driveInfo.iDriveAtt & aDriveType &&
+             driveInfo.iType != EMediaNotPresent &&
+             driveInfo.iType != EMediaCdRom )
+            {
+            TUint status( 0 );
+            
+            switch ( aDriveType )
+                {
+                case KDriveAttRemovable:
+                    {
+                    // Get the drive status of the default removable mass storage.                    
+                    if ( DriveInfo::GetDriveStatus( aFs, i, status ) == KErrNone )
+                        {
+                        // To indicate that the drive is physically removable.
+                        if ( status & DriveInfo::EDriveRemovable &&
+                             !( status & DriveInfo::EDriveCorrupt ) )
+                            {
+                            aDriveNumber = --i;
+                            return KErrNone;
+                            }
+                        }
+                    }
+                    break;
+                case KDriveAttInternal:
+                    {
+                    // Get the drive status of the default removable mass storage.
+                    if ( DriveInfo::GetDriveStatus( aFs, i, status ) == KErrNone )
+                        {
+                        // To indicate that the drive is internal and 
+                        // cannot be physically removed.
+                        if ( status & DriveInfo::EDriveInternal &&
+                             !( status & DriveInfo::EDriveExternallyMountable ) )
+                            {
+                            aDriveNumber = --i;
+                            return KErrNone;
+                            }
+                        }
+                    }
+                    break;
+                    
+                default:
+                    break;
+                }
+            }
+        }
+    return KErrNotFound;
+    }
+ 
+// End of File
--- a/analyzetool/dynamicmemoryhook/src/customuser.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/src/customuser.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -23,9 +23,9 @@
 #include "atlog.h"
 #include "analyzetoolmemoryallocator.h"
 #include "analyzetoolpanics.pan"
-#include "atstorageservercommon.h"
 #include "atdriveinfo.h"
 #include <analyzetool/analyzetooltraceconstants.h>
+#include "analyzetoolfastlog.h"
 
 #ifdef USE_CLEANER_DLL
 // Global variable to detect dll attach & detach in process.
@@ -121,7 +121,7 @@
 // CONSTANTS
 // When needed, update the version number directly inside _LIT macro.
 // Constant for the atool API(staticlib) version.
-_LIT( KAtoolApiVersion, "1.7.5" );
+_LIT( KAtoolApiVersion, "1.7.6" );
 
 // Version number buffer length
 const TInt KAtoolVersionNumberLength = 10;
@@ -133,8 +133,8 @@
 _LIT( KVersionSeparator, ";" );
 
 // Incorrect version error strings 
-_LIT( KIncorrectText, "ERROR_OCCURED INCORRECT_ATOOL_VERSION [API v.%S][ATOOL v.%S]" );
-_LIT( KIncorrectTextTrace, "PCSS " );
+_LIT( KIncorrectText, "ERR INCORRECT_ATOOL_VERSION [API v.%S][ATOOL v.%S]" );
+_LIT( KIncorrectTextTrace, "<AT> " );
 
 // -----------------------------------------------------------------------------
 // CustomUser::Panic()
@@ -240,7 +240,7 @@
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt CustomUser::SetupThreadHeap( TBool aNotFirst, 
-    SStdEpocThreadCreateInfo& aInfo, const TFileName& aFileName,
+    SStdEpocThreadCreateInfo& aInfo, const TFileName& aFileName, const TPath& aFilePath,
     TUint32 aLogOption, TUint32 aIsDebug, const TATVersion& aVersion,
     TUint32 aAllocCallStackSize, TUint32 aFreeCallStackSize,
     TRefByValue<const TDesC> aFmt, ... )
@@ -250,13 +250,18 @@
     
     // Add handling of the argument list here.
         
-    TInt ret( KErrNone );    
+    TInt ret( KErrNone ); 
+    
     // Check version number
     TBuf<KAtoolVersionNumberLength> atoolVer;
-    if ( CheckVersion( aVersion, atoolVer ) != KErrNone )
+    TBuf<KApiVersionLength> apiVer;
+    TInt err( KErrNone );
+    err = CheckVersion( aVersion, atoolVer, apiVer );
+    
+    if ( err )
     	{
     	LOGSTR1( "ATMH > Wrong API version > Inform user and Exit." );
-    	ReportIncorrectVersion( aLogOption, aFileName, atoolVer );
+    	ReportIncorrectVersion( aLogOption, aFileName, aFilePath, atoolVer );
     	return KAtoolVersionError;
     	}
     
@@ -277,8 +282,12 @@
     #endif
 #endif
         // Install the RAllocator
-        aInfo.iAllocator = &InstallAllocator( aNotFirst, aFileName, aLogOption, aIsDebug,
-                aAllocCallStackSize, aFreeCallStackSize );
+        TBuf8<KAtoolVersionLength> atoolVer8;
+        atoolVer8.Copy(atoolVer);
+        TBuf8<KApiVersionLength> apiVer8;
+        apiVer8.Copy(apiVer);
+        aInfo.iAllocator = &InstallAllocator( aNotFirst, aFileName, aFilePath, aLogOption, aIsDebug,
+                aAllocCallStackSize, aFreeCallStackSize, atoolVer8, apiVer8 );
         }
     else
         {
@@ -291,6 +300,8 @@
         // Switch thread heap 
         User::SwitchAllocator( allocator );
         }
+    
+
     return ret;
     }
 
@@ -301,8 +312,8 @@
 //
 //lint -e{429} suppress "Custodial pointer 'allocator' has not been freed or returned"
 EXPORT_C RAllocator& CustomUser::InstallAllocator( 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 )
     {
     LOGSTR1( "ATMH CustomUser::InstallAllocator()" );
     
@@ -331,8 +342,9 @@
             LOGSTR1( "ATMH CustomUser::InstallAllocator() - first thread of the program" );
             // Only one thread in the program. Must be main thread
             RAnalyzeToolMainAllocator* allocator = 
-				new RAnalyzeToolMainAllocator( aNotFirst, aFileName, aLogOption,
-				                               aIsDebug, aAllocCallStackSize, aFreeCallStackSize );
+				new RAnalyzeToolMainAllocator( aNotFirst, aFileName, aFilePath, aLogOption,
+				                               aIsDebug, aAllocCallStackSize, aFreeCallStackSize, 
+				                               aAtoolVersion, aApiVersion );
             
             __ASSERT_ALWAYS( allocator != NULL, AssertPanic( ENoMemory ) );
             
@@ -349,15 +361,14 @@
             // Create new RAllocator with handles from the main thread
             RAnalyzeToolAllocator* allocator = new RAnalyzeToolAllocator( 
                     aNotFirst,
-                    ((RAnalyzeToolMainAllocator*)params().iAllocator)->StorageServer(), 
                     ((RAnalyzeToolMainAllocator*)params().iAllocator)->Codeblocks(), 
                     ((RAnalyzeToolMainAllocator*)params().iAllocator)->Mutex(), 
                     ((RAnalyzeToolMainAllocator*)params().iAllocator)->ProcessId(), 
                     ((RAnalyzeToolMainAllocator*)params().iAllocator)->AnalyzeTool(),
-                    ((RAnalyzeToolMainAllocator*)params().iAllocator)->StorageServerOpen(),
                     ((RAnalyzeToolMainAllocator*)params().iAllocator)->LogOption(),
                     ((RAnalyzeToolMainAllocator*)params().iAllocator)->AllocMaxCallStack(),
-                    ((RAnalyzeToolMainAllocator*)params().iAllocator)->FreeMaxCallStack() );
+                    ((RAnalyzeToolMainAllocator*)params().iAllocator)->FreeMaxCallStack(),
+                    ((RAnalyzeToolMainAllocator*)params().iAllocator)->LogFile() );
 
             __ASSERT_ALWAYS( allocator != NULL, AssertPanic( ENoMemory ) );
             
@@ -373,8 +384,8 @@
         {
         LOGSTR1( "ATMH CustomUser::InstallAllocator() - analyzetool.Open() returned error, creating DD" );
         RAnalyzeToolMainAllocator* allocator = 
-			new RAnalyzeToolMainAllocator( aNotFirst, aFileName, aLogOption, aIsDebug,
-			        aAllocCallStackSize, aFreeCallStackSize );
+			new RAnalyzeToolMainAllocator( aNotFirst, aFileName, aFilePath, aLogOption, aIsDebug,
+			        aAllocCallStackSize, aFreeCallStackSize, aAtoolVersion, aApiVersion );
         
         __ASSERT_ALWAYS( allocator != NULL, AssertPanic( ENoMemory ) );
         
@@ -391,7 +402,7 @@
 // Check atool version
 // -----------------------------------------------------------------------------
 //
-TInt CustomUser::CheckVersion( const TATVersion& aVersion, TDes& aToolVersion )
+TInt CustomUser::CheckVersion( const TATVersion& aVersion, TDes& aToolVersion, TDes& aApiVersion )
     { 
     LOGSTR2( "ATMH CustomUser::CheckVersion(), aVersion( %S )", &aVersion );
     
@@ -402,9 +413,9 @@
     // Find separator place
     TInt findplace( version.Find( KVersionSeparator() ) );
     // Parse API version first [x.x.x;x.x.x]
-    if ( findplace >= 0 && findplace <= apiVer.MaxLength() )
+    if ( findplace >= 0 && findplace <= aApiVersion.MaxLength() )
 		{
-		apiVer.Copy( version.Mid( 0, findplace ) ); 
+        aApiVersion.Copy( version.Mid( 0, findplace ) ); 
 		version.Delete( 0, findplace + KVersionSeparator().Length() );
 		}
  
@@ -412,18 +423,18 @@
     	{
     	aToolVersion.Copy( version );
     	if ( aToolVersion.Compare( KAtoolApiVersion ) == KErrNone &&
-    		 apiVer.Length() == 0 )
+    	     aApiVersion.Length() == 0 )
     		{
     		// Support 1.5.0 version (Version info: [1.5.0])
-    		apiVer.Copy( version );
+    	    aApiVersion.Copy( version );
     		}
     	}
     
     LOGSTR3( "ATMH > API version( %S ), ATOOL version( %S )", 
-    		&apiVer, &aToolVersion );
+    		&aApiVersion, &aToolVersion );
         
     // Check version numbers 
-    if ( apiVer.Compare( KAtoolApiVersion ) == KErrNone )
+    if ( aApiVersion.Compare( KAtoolApiVersion ) == KErrNone )
     	{
     	return KErrNone;
     	}
@@ -436,11 +447,11 @@
 // -----------------------------------------------------------------------------
 //
 void CustomUser::ReportIncorrectVersion( const TUint32 aLogOption,
-	const TFileName& aFileName, const TDes& aToolVersion )
+	const TFileName& aFileName, const TPath& aFilePath, const TDes& aToolVersion )
 	{
 	LOGSTR2( "ATMH CustomUser::ReportIncorrectVersion(), aFileName( %S )", 
 			&aFileName );
-	
+
 	switch ( aLogOption )
 		{
 		case EATLogToFile:
@@ -459,7 +470,7 @@
 			
 			if ( !err )
 				{				
-                err = TATDriveInfo::CreatePath( logFileBuf, aFileName, fs );
+                err = TATDriveInfo::CreatePath( logFileBuf, aFileName, aFilePath, fs );
 			    
 				// Replace file if exists
 				if ( err && err != KErrAlreadyExists )
@@ -493,9 +504,9 @@
 			break;
 			
 		case EATUseDefault:
-		case EATLogToTrace:
+		case EATLogToTraceFast:
 			{
-			LOGSTR1( "ATMH > ReportIncorrectVersion > EATLogToTrace" );
+			LOGSTR1( "ATMH > ReportIncorrectVersion > EATLogToTraceFast" );
 			// Error msg buffer
 			TBuf<KMaxFileName> msg;	
 			msg.Copy( KIncorrectTextTrace );
--- a/analyzetool/group/ReleaseNotes_AnalyzeTool.txt	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/group/ReleaseNotes_AnalyzeTool.txt	Wed Sep 15 13:53:27 2010 +0300
@@ -1,7 +1,7 @@
 ===============================================================================
 
-RELEASE NOTES - ANALYZETOOL v1.9.1
-RELEASED 29th April 2010
+RELEASE NOTES - ANALYZETOOL v1.10.0
+RELEASED 2nd July 2010
 
 SUPPORTS SYMBIAN^1+
 
@@ -20,14 +20,14 @@
 
 ===============================================================================
 
-What's New in v1.9.1
+
+What's New in v1.10.0
 ====================
-- Change: Removed Avkon and Console UI's to simplify the maintenance of the
-  tool
-- Change: Middleware layer dependencies removed so AnalyzeTool can be now used
-  also in OS layer builds
-- Fix: Move all binaries to ROM instead of ROFS to avoid ROM build
-  dependencies issues in hooked components
+  
+- Change: Storage server was removed
+- Change: New trace format
+- Change: Logging to binary file added
+- Change: Capture of reallocations implemented
 
 ===============================================================================
 
@@ -85,18 +85,12 @@
 =============
 - Kernel analysis are not supported.
 
-- When using monitored internal data gathering mode (-mi) and hooked
-  application contains huge amounts of allocations AnalyzeTool? storageserver
-  might run out of memory to store the data. This message "Symbian error code
-  -4" is seen when analyzing the data file with atool.exe. Solution is to use
-  external / monitored external data gathering mode. 
-
 - Switch allocator. AnalyzeTool change the application memory allocator to
   AnalyzeTool own memory allocator and using the User::SwitchAllocator function
   can lead to situation where the tested application does not work properly.
   
 - AnalyzeTool hooked QT applications becomes too slow to run. Use small size
-  call stack(s) and new logging mode (external -e). 
+  call stack(s) and new logging mode (external -tr). 
 
 - Stif test case with AnalyzeTool can inform wrong memory leak alert.
 
@@ -116,6 +110,17 @@
 Version History:
 ================
 
+Version 1.9.1 - 29th April 2010
+==============================
+- Change: Removed Avkon and Console UI's to simplify the maintenance of the
+  tool
+- Change: Middleware layer dependencies removed so AnalyzeTool can be now used
+  also in OS layer builds
+- Fix: Move all binaries to ROM instead of ROFS to avoid ROM build
+  dependencies issues in hooked components
+
+===============================================================================
+
 Version 1.9.0 - 8th April 2010
 ==============================
 - Feature: Remove false positive memory leaks with better handling of global
--- a/analyzetool/group/bld.inf	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/group/bld.inf	Wed Sep 15 13:53:27 2010 +0300
@@ -17,10 +17,9 @@
 
 #include <platform_paths.hrh>
 
-
+#include "../analyzetool_plat/group/bld.inf"
 #include "../commandlineengine/group/bld.inf"
 #include "../staticlib/group/bld.inf"
-#include "../storageserver/group/bld.inf"
 #include "../kerneleventhandler/group/bld.inf"
 #include "../analyzetoolcleaner/group/bld.inf"
 #include "../dynamicmemoryhook/group/bld.inf"
--- a/analyzetool/kerneleventhandler/group/bld.inf	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/kerneleventhandler/group/bld.inf	Wed Sep 15 13:53:27 2010 +0300
@@ -20,12 +20,6 @@
 PRJ_PLATFORMS
 ARMV5 WINSCW
 
-PRJ_EXPORTS
-../inc/analyzetool.h OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/analyzetool.h)
-../inc/atcommon.h OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/atcommon.h)
-../inc/analyzetool.inl OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/analyzetool.inl)
-../inc/analyzetooltraceconstants.h OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/analyzetooltraceconstants.h)
-
 PRJ_MMPFILES
 atoolkerneleventhandler.mmp
 
--- a/analyzetool/kerneleventhandler/inc/analyzetool.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,325 +0,0 @@
-/*
-* 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:  Declaration of the class RAnalyzeTool.
-*
-*/
-
-
-#ifndef __ANALYZETOOL_H__
-#define __ANALYZETOOL_H__
-
-// INCLUDES
-#include <e32cmn.h>
-
-//Version information for command line engine.
-//Tells the version of AT core componenets.
-//ANALYZETOOL_CORE_VERSION_FOR_CLE 1.9.1
-
-// CONSTANTS
-inline TVersion KAnalyzeToolLddVersion() { return TVersion(1, 0, 1); }
-
-/* The name of the analyze tool device driver*/
-_LIT( KAnalyzeToolLddName, "AToolKernelEventHandler" );
-
-/* The priority of AnalyzeTool Dfc */
-const TInt KAnalyzeToolThreadPriority = 27;
-
-/* The name of the AnalyzeTool DFC */
-_LIT8( KAnalyzeToolThreadName, "AnalyzeToolThreadDfc" );
-
-/* The panic literal */
-_LIT( KClientPanic, "AnalyzeTool" );
-
-//const TInt KATMaxCallstackLength = 20;
-
-/* The device handler panic codes */
-enum TPanic
-	{
-	EPanicRequestPending,
-	EPanicNoRequestPending,
-	EPanicUnsupportedRequest
-	};
-
-// Size of following must be multiple of 4 bytes.
-
-class TMainThreadParams
-	{
-	public:
-		RAllocator* iAllocator;
-		TBool       iAlone;
-		TUint       iProcessId;
-	};
-typedef TPckgBuf<TMainThreadParams> TMainThreadParamsBuf;
-
-class TLibraryInfo
-	{
-	public:
-		TBuf8<KMaxLibraryName> iLibraryName;
-		TLinAddr  iRunAddress;
-		TUint32   iSize;
-		TInt      iIndex;
-		TUint     iProcessId;
-	};
-
-typedef TPckgBuf<TLibraryInfo> TLibraryInfoBuf;
-
-class TCodesegInfo
-	{
-	public:
-		TBuf8<KMaxLibraryName> iFullName;
-		TLinAddr iRunAddress;
-		TUint32  iSize;
-		TInt  iIndex;
-		TUint iProcessId;
-		TInt  iCodesegIndex; 
-		TLinAddr iFileEntryPoint;
-		TInt     iFuntionCount;
-		TLibraryFunction iFirstFunction;
-		TModuleMemoryInfo iMemoryInfo;
-	};
-
-typedef TPckgBuf<TCodesegInfo> TCodesegInfoBuf;
-
-class TThreadParams
-	{		
-	public:
-	    TLinAddr iStackAddress;
-	    TInt iStackSize;
-	    TUint iThreadId;
-	};
-
-typedef TPckgBuf<TThreadParams> TThreadParamsBuf;
-
-class TProcessIdentityParams
-	{		
-	public:
-		TBuf8<KMaxProcessName> iProcessName;
-		TInt iDynamicCount;
-		TInt iCodesegCount;
-		TUint iProcessId;
-		TUint iThreadId;
-	    TLinAddr iStackAddress;
-	    TInt iStackSize;
-	};
-
-typedef TPckgBuf<TProcessIdentityParams> TProcessIdentityParamsBuf;
-
-class TLibraryEventInfo
-	{
-	public:
-		enum TLibraryEvent
-			{ 
-			ELibraryAdded = 0, 
-			ELibraryRemoved,
-			EKillThread 
-			};
-					
-	public:
-		TUint iProcessId;
-		TBuf8<KMaxLibraryName> iLibraryName;
-		TLinAddr iRunAddress;
-		TUint32 iSize;
-		TLibraryEvent iEventType;
-		TUint iThreadId;
-	};
-
-typedef TPckgBuf<TLibraryEventInfo> TLibraryEventInfoBuf;
-
-class TProcessHandleInfo
-	{
-	public:
-		TInt     iProcessHandleCount;
-		TInt     iThreadHandleCount;
-		TInt     iIndex;
-		TInt     iThreadCount;
-		TLinAddr iUserStackRunAddress;
-		TInt     iUserStackSize;
-		TUint    iProcessId;
-	};
-
-typedef TPckgBuf<TProcessHandleInfo> TProcessHandleInfoBuf;
-
-/**
-*  A class for particular process's current handle count
-*/
-class TATProcessHandles
-    {
-    public:
-    
-        /** The ID of the process. */
-        TUint iProcessId;
-        
-        /** The number of current handles in the library. */
-        TInt iCurrentHandleCount;
-    };
-
-typedef TPckgBuf<TATProcessHandles> TATProcessHandlesBuf;
-
-class TClientCount
-    {
-    public:
-    
-        /** The count of clients */
-        TInt iClientCount;     
-    };
-
-typedef TPckgBuf<TClientCount> TClientCountBuf;
-
-class TATMemoryModel
-    {
-    public :
-        /* Memory model*/
-        TUint32 iMemoryModel;
-    };
-typedef TPckgBuf<TATMemoryModel> TATMemoryModelBuf;
-
-// CLASS DECLARATION
-
-/**
-*  The user-side handle to a logical channel which provides functions to 
-*  open a channel and to make requests to a analyze tool device driver. 
-*/
-
-class RAnalyzeTool : public RBusLogicalChannel
-	{
-	
-	public:
-		
-	/** Enumeration of supported functions */
-	enum TBasicAnalyzerControl
-		{
-		EGetProcessInfo = 0, /* The process information */
-		EGetCodesegInfo,	 /* The codesegment information */
-		EGetLibraryInfo,     /* The library information */
-		EGetDynamicInfo,	 /* The count of dynamic code in the process */
-		ELibraryEvent,       /* Subscribe events from library events */
-		ECancelLibraryEvent, /* Cancel subscribetion of library events */
-		ECurrentClientCount,  /* The count of clients in device driver */
-		EMainThreadAlloctor,
-		EThreadStack,
-		EGetProcessHandle,	/* Gets process global handles info*/
-		EGetCurrentHandles, /* Get a process's current handle count */
-		EGetMemoryModel
-		};
-			
-#ifndef __KERNEL_MODE__
-
-        /**
-        * Opens a handle to a logical channel.
-        * @return TInt Returns KErrNone, if successful or otherwise 
-        		  one of the other system-wide error codes
-        */
-		inline TInt Open();
-
-        /**
-        * Acquires process information.
-        * @param aProcessIdentityParams The process information which 
-        								is filled by the device driver
-        * @return TInt Returns KErrNone, if successful
-        			   otherwise one of the other system-wide error codes
-        */
-		inline TInt GetProcessInfo( 
-				TProcessIdentityParamsBuf& aProcessIdentityParams );
-
-        /**
-        * Acquires codeseg information.
-        * @param aCodesegInfo The codeseg information which 
-        					  is filled by the device driver
-        * @return TInt Returns KErrNone, if successful
-        			   otherwise one of the other system-wide error codes
-        */
-		inline TInt GetCodesegInfo( TCodesegInfoBuf& aCodesegInfo );
-		
-        /**
-        * Acquires library information.
-        * @param aLibraryInfo The library information which 
-        					  is filled by the device driver
-        * @return TInt Returns KErrNone, if successful
-        			   otherwise one of the other system-wide error codes
-        */
-		inline TInt GetLibraryInfo( TLibraryInfoBuf& aLibraryInfo );
-				
-        /**
-        * Subscribes library event.
-        * @param aStatus The request status object for this request. 
-        * @param aLibraryInfo The library information which 
-        					  is filled by the device driver
-        * @return TInt Returns KErrNone, if successful
-        			   otherwise one of the other system-wide error codes
-        */
-		inline void LibraryEvent( TRequestStatus& aStatus, 
-		                          TLibraryEventInfo& aLibraryInfo );
-		
-        /**
-        * Cancels subscribetion of the library event.
-        */
-		inline void CancelLibraryEvent();
-
-        /**
-        * Acquires device driver current client count.
-        * @param aClientCount A reference to TInt which is 
-        				      updated by the device driver.
-        * @return TInt Returns KErrNone, if successful
-        			   otherwise one of the other system-wide error codes
-        */
-		inline TInt ClientCount( TClientCountBuf& aClientCount );
-		
-        /**
-        * Acquires process main thread RAllocator
-        * @param aMainThreadParams The main thread information which 
-        					        is filled by the device driver
-        * @return TInt Returns KErrNone, if successful
-        			   otherwise one of the other system-wide error codes
-        */	
-		inline TInt MainThreadAlloctor( TMainThreadParamsBuf& aMainThreadParams );
-		
-		/**
-		* Acquires main thread stack address.
-		* @param aThreadStack Pointer to the TThreadParams object.
-		* @return TInt Returns KErrNone, if successful
-					   otherwise one of the other system-wide error codes
-		*/
-		inline TInt ThreadStack( TThreadParamsBuf& aThreadStack );
-
-        /**
-        * Acquires information about process global handles.
-        * @param aProcessHandleInfo Pointer to the TProcessHandleInfo object.
-        * @return TInt Returns KErrNone, if successful
-        			   otherwise one of the other system-wide error codes
-        */
-		inline TInt GetProcessHandleInfo( TProcessHandleInfoBuf& aProcessHandleInfo );
-
-        /**
-        * Acquires a process's current handle count.
-        * @param aProcessHandles Pointer to the TATProcessHandles object.
-        * @return TInt Returns KErrNone, if successful
-                       otherwise one of the other system-wide error codes
-        */
-        inline TInt GetCurrentHandleCount( TATProcessHandlesBuf& aProcessHandles );
-
-        /**
-         * Acquires memory model system uses.
-         * @param aMemoryModel pointer to the TATMemoryModelBuf object.
-         */
-        inline TInt GetMemoryModel( TATMemoryModelBuf& aMemoryModel );
-        
-#endif // #ifndef __KERNEL_MODE__
-	};
-
-// INLINES
-#include <analyzetool/analyzetool.inl>
-
-#endif // #ifndef __ANALYZETOOL_H__
-
-// End of File
--- a/analyzetool/kerneleventhandler/inc/analyzetool.inl	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/*
-* 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:  Definitions for inline methods of the class RAnalyzeTool.
-*
-*/
-
-
-#ifndef __ANALYZETOOL_INL
-#define __ANALYZETOOL_INL
-
-#ifndef __KERNEL_MODE__
-
-// ----------------------------------------------------------------------------
-// RAnalyzeTool::Open()
-// Opens a handle to a analyze tool device driver
-// ----------------------------------------------------------------------------
-//
-inline TInt RAnalyzeTool::Open()
-	{
-	return DoCreate( KAnalyzeToolLddName, 
-					 KAnalyzeToolLddVersion(), 
-					 KNullUnit, 
-					 NULL, 
-					 NULL, 
-					 EOwnerProcess );
-	}
-
-// ----------------------------------------------------------------------------
-// RAnalyzeTool::GetProcessInfo()
-// Acquires process information.
-// ----------------------------------------------------------------------------
-//
-inline TInt RAnalyzeTool::GetProcessInfo( 
-		TProcessIdentityParamsBuf& aProcessIdentityParams )
-	{
-	return DoControl( EGetProcessInfo, &aProcessIdentityParams, NULL );
-	}
-
-// ----------------------------------------------------------------------------
-// RAnalyzeTool::GetCodesegInfo()
-// Acquires codeseg information.
-// ----------------------------------------------------------------------------
-//
-inline TInt RAnalyzeTool::GetCodesegInfo( TCodesegInfoBuf& aCodesegInfo )
-	{
-	return DoControl( EGetCodesegInfo, &aCodesegInfo, NULL );
-	}
-
-// ----------------------------------------------------------------------------
-// RAnalyzeTool::GetLibraryInfo()
-// Symbian 2nd phase constructor can leave.
-// ----------------------------------------------------------------------------
-//
-inline TInt RAnalyzeTool::GetLibraryInfo( TLibraryInfoBuf& aLibraryinfo )
-	{
-	return DoControl( EGetLibraryInfo, &aLibraryinfo, NULL );
-	}
-
-// ----------------------------------------------------------------------------
-// RAnalyzeTool::LibraryEvent()
-// Subscribes library event.
-// ----------------------------------------------------------------------------
-//
-inline void RAnalyzeTool::LibraryEvent( TRequestStatus& aStatus,
-	TLibraryEventInfo& aLibInfo )
-	{
-	return DoRequest( ELibraryEvent, aStatus, (TAny*)&aLibInfo );
-	}
-
-// ----------------------------------------------------------------------------
-// RAnalyzeTool::CancelLibraryEvent()
-// Cancels subscribetion of the library event.
-// ----------------------------------------------------------------------------
-//
-inline void RAnalyzeTool::CancelLibraryEvent()
-	{
-	DoControl( ECancelLibraryEvent, NULL, NULL);
-	}
-
-// ----------------------------------------------------------------------------
-// RAnalyzeTool::ClientCount()
-// Acquires the count of device driver current users
-// ----------------------------------------------------------------------------
-//
-inline TInt RAnalyzeTool::ClientCount( TClientCountBuf& aClientCount )
-	{
-	return DoControl( ECurrentClientCount, &aClientCount, NULL );
-	}
-
-// ----------------------------------------------------------------------------
-// RAnalyzeTool::MainThreadAlloctor()
-// Acquires information about process main thread
-// ----------------------------------------------------------------------------
-//
-inline TInt RAnalyzeTool::MainThreadAlloctor( 
-	        TMainThreadParamsBuf& aMainThreadParams )
-    {
-    return DoControl( EMainThreadAlloctor, &aMainThreadParams, NULL );
-    }
-
-// ----------------------------------------------------------------------------
-// RAnalyzeTool::ThreadStack()
-// Acquires main thread stack address.
-// ----------------------------------------------------------------------------
-//
-inline TInt RAnalyzeTool::ThreadStack( TThreadParamsBuf& aThreadStack )
-    {
-    return DoControl( EThreadStack, &aThreadStack, NULL );
-    }
-
-// ----------------------------------------------------------------------------
-// RAnalyzeTool::GetProcessHandleInfo()
-// Acquires information about process handles
-// ----------------------------------------------------------------------------
-//
-inline TInt RAnalyzeTool::GetProcessHandleInfo( 
-		    TProcessHandleInfoBuf& aProcessHandleInfo )
-    {
-    return DoControl( EGetProcessHandle, &aProcessHandleInfo, NULL );
-    }
-
-// -----------------------------------------------------------------------------
-// DAnalyzeToolChannel::GetCurrentHandleCount()
-// Acquires a process's current handle count
-// -----------------------------------------------------------------------------
-//
-inline TInt RAnalyzeTool::GetCurrentHandleCount( 
-		    TATProcessHandlesBuf& aProcessHandles )
-    {
-    return DoControl( EGetCurrentHandles, &aProcessHandles, NULL );
-    }
-
-// -----------------------------------------------------------------------------
-// DAnalyzeToolChannel::GetMemoryModel()
-// Acquires memory model system uses.
-// -----------------------------------------------------------------------------
-//
-inline TInt RAnalyzeTool::GetMemoryModel( 
-            TATMemoryModelBuf& aMemoryModel )
-    {
-    return DoControl( EGetMemoryModel, &aMemoryModel, NULL );
-    }
-
-#endif // #ifndef __KERNEL_MODE__
-
-#endif // __ANALYZETOOL_INL
-
-// End of file
--- a/analyzetool/kerneleventhandler/inc/analyzetooltraceconstants.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,171 +0,0 @@
-/*
-* 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:  Common declarations/definitions for Analyze Tool.
-*
-*/
-
-
-
-#ifndef __ANALYZETOOLTRACECONSTANTS_H__
-#define __ANALYZETOOLTRACECONSTANTS_H__
-
-#include <analyzetool/atcommon.h>
-
-// Trace version information.
-const TUint KATTraceVersion = 0x2;
-
-// The default logging mode 
-const TATLogOption KDefaultLoggingMode = EATLogToTrace;
-
-// When needed, update the storage data file's version number directly inside
-// the _LIT8 macro. Note, if you change this string, also remember to update
-// the constant "KVersionStringLength" below.
-
-_LIT8( KDataFileVersion, "DATA_FILE_VERSION 11\r\n" );
-_LIT8( KProcessStart, "PROCESS_START %S %x " );
-_LIT16( KProcessStart16, "PROCESS_START %S %x " );
-_LIT8( KDllLoad, "DLL_LOAD %S %Lx %x %x\r\n" );
-_LIT16( KDllLoad16, "DLL_LOAD %S %Lx %x %x\r\n" );
-_LIT8( KDllUnload, "DLL_UNLOAD %S %Lx %x %x\r\n" );
-_LIT16( KDllUnload16, "DLL_UNLOAD %S %Lx %x %x\r\n" );
-_LIT8( KProcessEnd, "PROCESS_END %x " );
-_LIT16( KProcessEnd16, "PROCESS_END %x " );
-_LIT8( KProcessEndAbnormal, "PROCESS_END %x ABNORMAL " );
-_LIT8( KMemoryLeak, "MEM_LEAK " ); // Remember to update value of KMemoryLeak when changing this.
-_LIT8( KHandleLeak, "HANDLE_LEAK %S %x\r\n" );
-_LIT16( KHandleLeak16, "HANDLE_LEAK %S %x\r\n" );
-_LIT8( KErrorOccured, "ERROR_OCCURED %d " );
-_LIT8( KLoggingCancelled, "LOGGING_CANCELLED %x\r\n" );
-_LIT8( KNewLine, "\r\n" );
-_LIT8( KHexaNumber, " %x" );
-_LIT8( KSpace, " " );
-_LIT8( KUdeb, "UDEB" );
-_LIT8( KUrel, "UREL" );
-    
-// Constants for logging through debug channel
-_LIT( KTraceMessage, "PCSS %x %S" );
-_LIT( KMemoryAllocHeader, "ALLOCH " );
-_LIT( KMemoryAllocFragment, "ALLOCF " );
-_LIT( KMemoryFreedHeader, "FREEH " );
-_LIT( KMemoryFreedFragment, "FREEF " );
-_LIT( KSpaceTrace, " " );
-_LIT( KNewLineTrace, "\r\n" );
-_LIT( KHexaNumberTrace, " %x" );
-_LIT( KProcessEndTrace, "PROCESS_END %x " );
-_LIT( KProcessEndAbnormalTrace, "PROCESS_END %x ABNORMAL " );
-_LIT( KErrorOccuredTrace, "ERROR_OCCURED %d " );
-_LIT( KSubtestStart, "TEST_START " );
-_LIT( KSubtestEnd, "TEST_END " );
-_LIT8( KEmpty, "" );
-_LIT( KOpenSquareBracket, "[" );
-_LIT( KCloseSquareBracket, "]" );
-_LIT( KUnderLine, "_" );
-// File name format
-_LIT( KFormat, "%S%S%02d%S");// pad char="0", field width=2
-
-// A string for setting time January 1st, 1970 AD nominal Gregorian
-_LIT( KJanuaryFirst1970, "19700000:000000.000000" );
-
-// Module name when it cannot be defined
-_LIT8( KUnknownModule, "Unknown" );
-_LIT16( KUnknownModule16, "Unknown" );
-
-// Constant time variable used to calculate timestamps for pc side.
-const TInt64  KMicroSecondsAt1970 = 62168256000000000;
-
-// The length of the string KDataFileVersion
-const TInt KVersionStringLength = 22;
-
-// The length of the string KMemoryLeak
-const TInt KMemleakLength = 9;
-
-// The maximum length of one word (32 bits) represented in the hexadecimal text format
-// without "0x" prefix
-const TInt KHexa32Length = 8;
-
-// The maximum length of one word (32 bits) represented in the decimal text format
-const TInt KDec32Length = 10;
-
-// The maximum length of a TInt64 represented in the hexadecimal text format without
-// "0x" prefix
-const TInt KHexa64Length = 16;
-
-// The length of one space character in text
-const TInt KSpaceLength = 1;
-
-// The length of the combination of carriage return and new line characters.
-const TInt KNewlineLength = 2;
-
-// The maximum length of the "PROCESS_START..." buffer. The first number is length of
-// the line tag and one space character (see the descriptor constants above).
-const TInt KProcessStartBufLength = 16 + KMaxProcessName + KSpaceLength + KHexa32Length +
-                                        KSpaceLength + KHexa64Length + KHexa32Length + KNewlineLength;
-
-// The maximum length of the "DLL_LOAD..." buffer. The first number is length of
-// the line tag and one space character (see the descriptor constants above).
-const TInt KDllLoadBufLength = 9 + KMaxLibraryName + KSpaceLength + KHexa64Length + KSpaceLength +
-                    KHexa32Length + KSpaceLength + KHexa32Length + KNewlineLength;
-
-// The maximum length of the "DLL_UNLOAD..." buffer. The first number is length of
-// the line tag and one space character (see the descriptor constants above).
-const TInt KDllUnloadBufLength = 11 + KMaxLibraryName + KHexa64Length + KSpaceLength + KSpaceLength + 
-                    KHexa32Length + KSpaceLength + KHexa32Length + KNewlineLength;
-
-// The maximum length of the "PROCESS_END..." buffer. The first number is length of
-// the line tag and one space character (see the descriptor constants above).
-const TInt KProcessEndBufLength = 12 + KHexa32Length + KSpaceLength +
-                                        KHexa64Length + KNewlineLength;
-                                        
-// The maximum length of the "ERROR_OCCURED..." buffer. The first number is length of
-// the line tag and one space character (see the descriptor constants above).
-const TInt KErrOccuredBufLength = 14 + KDec32Length + KSpaceLength +
-                                        KHexa64Length + KNewlineLength;
-                                        
-// The maximum length of the "ALLOCH / ALLOCF..." buffer. 
-const TInt KMemAllocBufLength = 255;
-
-// The maximum length of the "FREE..." buffer.
-const TInt KMemFreedBufLength = 255;
-
-// The maximum length of the "HANDLE_LEAK..." buffer. The first number is length of
-// the line tag and one space character (see the descriptor constants above).
-const TInt KHandleLeakBufLength = 12 + KMaxLibraryName + KSpaceLength +
-                                        KHexa32Length + KNewlineLength;
-                                        
-// The maximum length of the "TEST_START..." buffer. The first number is length of
-// the line tag and one space character (see the descriptor constants above).
-const TInt KTestStartBufLength = 11 + KHexa64Length + KSpaceLength +
-                                        KATMaxSubtestIdLength + KSpaceLength + KHexa64Length + KNewlineLength;
-
-// The maximum length of the "TEST_END..." buffer. The first number is length of
-// the line tag and one space character (see the descriptor constants above).
-const TInt KTestEndBufLength = 9 + KHexa64Length + KSpaceLength +
-                                        KATMaxSubtestIdLength + KSpaceLength + KHexa64Length + KNewlineLength;
-
-// The maximun length of the "LOGGING_CANCELLED..." buffer. The first number is the
-// length of the line tag and one space character (see the descriptor constants above).
-const TInt KCancelBufLength = 18 + KHexa64Length + KNewlineLength;
-
-// The maximun length of the "PROCESS_END %x ABNORMAL..." buffer. The first number is length of
-// the line tag and one space character (see the descriptor constants above).
-const TInt KEndAbnormalBufLength = 22 + KHexa32Length + KHexa64Length + 
-                                        KSpaceLength + KNewlineLength;
-
-// The maximun length of the file name extension buffer.
-const TInt KExtensionLength = 50;
-
-// The maximun length of the process UID3 buffer.
-const TInt KProcessUidLength = 20;
-
-#endif // __ANALYZETOOLTRACECONSTANTS_H__
--- a/analyzetool/kerneleventhandler/inc/atcommon.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
-* 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:  Common declarations/definitions for Analyze Tool.
-*
-*/
-
-
-#ifndef ATCOMMON_H_
-#define ATCOMMON_H_
-
-// CONSTANTS
-const TInt KATMaxCallstackLength = 256;
-const TInt KATMaxFreeCallstackLength = 256;
-const TInt KATMaxSubtestIdLength = 256;
-
-// The following constants only limit the configuration UI.
-// The bigger the number is, the more space will be allocated run-time
-// by the client. So, change with care.
-const TInt KATMaxProcesses = 20;
-const TInt KATMaxDlls = 30;
-
-// Constants defining call stack address range in multiple memory model.
-const TInt32 KATMultipleMemoryModelLowLimit = 0x70000000;
-const TInt32 KATMultipleMemoryModelHighLimit = 0x90000000;
-
-
-// CLASS DECLARATIONS
-
-/**
-*  A class for storing process information
-*/
-class TATProcessInfo
-    {
-    public:
-    
-        /** The ID of the process. */
-        TUint iProcessId;
-        
-        /** The name of the process. */
-        TBuf8<KMaxProcessName> iProcessName;
-        
-        /** The starting time of the process. */
-        TInt64 iStartTime;
-    };
-
-
-// ENUMERATIONS
-
-/**
-*  Enumeration for different logging modes of Analyze Tool 
-*/
-enum TATLogOption
-    {
-    /** Using the default. */
-    EATUseDefault = 0,
-    
-    /** Logging to a file in S60. */
-    EATLogToFile,
-    
-    /** Logging to debug channel. */
-    EATLogToTrace,
-    
-    /** Logging to debug channel bypassing storage server. */
-    EATLogToTraceFast,
-    
-    /** Logging switched off. */
-    EATLoggingOff
-    };
-
-/**
-*  Class which supports interfacing with AnalyzeTool exported
-*  functions. Mainly meant for STIF integration.
-*/
-class AnalyzeToolInterface
-    {
-    public:
-
-        /**
-        * This function starts subtest with a given name.
-        * @param aSubtestId The name identifying this particular sub test. The length
-        *   of this descriptor must not be greater than KATMaxSubtestIdLength, or
-        *   otherwise the method raises a STSEClient: 2 panic.
-        */
-        IMPORT_C static void StartSubTest( const TDesC8& aSubtestId );
-
-        /**
-        * This function stops a subtest with a given name.
-        * @param aSubtestId The name identifying this particular sub test. The length
-        *   of this descriptor must not be greater than KATMaxSubtestIdLength, or
-        *   otherwise the method raises a STSEClient: 2 panic. 
-        */   
-        IMPORT_C static void StopSubTest( const TDesC8& aSubtestId );
-
-    };
-    
-
-#endif /*ATCOMMON_H_*/
--- a/analyzetool/rom/analyzetool_rom.iby	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/rom/analyzetool_rom.iby	Wed Sep 15 13:53:27 2010 +0300
@@ -29,9 +29,5 @@
 // Cleaner
 file=ABI_DIR\BUILD_DIR\atoolcleaner.dll           	            SHARED_LIB_DIR\atoolcleaner.dll
 
-// Storage server
-file=ABI_DIR\BUILD_DIR\atoolstorageserver.exe                   PROGRAMS_DIR\atoolstorageserver.exe
-file=ABI_DIR\BUILD_DIR\atoolstorageserverclnt.dll               SHARED_LIB_DIR\atoolstorageserverclnt.dll
-
 
 #endif // __ANALYZETOOL_ROM_IBY__
--- a/analyzetool/sis/AnalyzeTool.pkg	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/sis/AnalyzeTool.pkg	Wed Sep 15 13:53:27 2010 +0300
@@ -18,7 +18,7 @@
 &EN
 
 ; standard SIS file header
-#{"AnalyzeTool"},(0x20012432),1,9,1,TYPE=SA, RU
+#{"AnalyzeTool"},(0x20012432),1,10,0,TYPE=SA, RU
 
 ;Localised Vendor name
 %{"Nokia Corporation"}
@@ -34,8 +34,6 @@
 
 "\epoc32\release\armv5\urel\atoolkerneleventhandler.ldd"            -"!:\sys\bin\atoolkerneleventhandler.ldd"
 "\epoc32\release\armv5\urel\atoolmemoryhook.dll"                    -"!:\sys\bin\atoolmemoryhook.dll"
-"\epoc32\release\armv5\urel\atoolstorageserver.exe"                 -"!:\sys\bin\atoolstorageserver.exe"
-"\epoc32\release\armv5\urel\atoolstorageserverclnt.dll"             -"!:\sys\bin\atoolstorageserverclnt.dll"
 "\epoc32\release\armv5\urel\atoolcleaner.dll"                 		-"!:\sys\bin\atoolcleaner.dll"
 
 ; Install console application
--- a/analyzetool/sis/AnalyzeTool_udeb.pkg	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/sis/AnalyzeTool_udeb.pkg	Wed Sep 15 13:53:27 2010 +0300
@@ -18,7 +18,7 @@
 &EN
 
 ; standard SIS file header
-#{"AnalyzeTool"},(0x20012432),1,9,1,TYPE=SA, RU
+#{"AnalyzeTool"},(0x20012432),1,10,0,TYPE=SA, RU
 
 ;Localised Vendor name
 %{"Nokia Corporation"}
@@ -34,8 +34,6 @@
 
 "\epoc32\release\armv5\udeb\atoolkerneleventhandler.ldd"            -"!:\sys\bin\atoolkerneleventhandler.ldd"
 "\epoc32\release\armv5\udeb\atoolmemoryhook.dll"                    -"!:\sys\bin\atoolmemoryhook.dll"
-"\epoc32\release\armv5\udeb\atoolstorageserver.exe"                 -"!:\sys\bin\atoolstorageserver.exe"
-"\epoc32\release\armv5\udeb\atoolstorageserverclnt.dll"             -"!:\sys\bin\atoolstorageserverclnt.dll"
 "\epoc32\release\armv5\urel\atoolcleaner.dll"                 		-"!:\sys\bin\atoolcleaner.dll"
 
 ; Install console application
--- a/analyzetool/sis/analyzeTool_stub.pkg	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/sis/analyzeTool_stub.pkg	Wed Sep 15 13:53:27 2010 +0300
@@ -18,7 +18,7 @@
 &EN
 
 ;Header
-#{"AnalyzeTool"}, (0x20012432), 1,9,1
+#{"AnalyzeTool"}, (0x20012432), 1,10,0
 
 ; Non-localised vendor name
 :"Nokia Corporation"
@@ -29,8 +29,6 @@
 ; AnalyzeTool binaries
 ""-"z:\sys\bin\atoolkerneleventhandler.ldd"
 ""-"z:\sys\bin\atoolmemoryhook.dll"
-""-"z:\sys\bin\atoolstorageserver.exe"
-""-"z:\sys\bin\atoolstorageserverclnt.dll"
 ""-"z:\sys\bin\atoolcleaner.dll"
 
 ""-"z:\sys\bin\atool.exe"
\ No newline at end of file
--- a/analyzetool/staticlib/group/bld.inf	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/staticlib/group/bld.inf	Wed Sep 15 13:53:27 2010 +0300
@@ -20,8 +20,5 @@
 PRJ_PLATFORMS
 ARMV5 WINSCW
 
-PRJ_EXPORTS
-../../dynamicmemoryhook/inc/customuser.h OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/customuser.h)
-
 PRJ_MMPFILES
 atoolstaticlib.mmp
--- a/analyzetool/staticlib/src/atoolstaticlib.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/staticlib/src/atoolstaticlib.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -113,6 +113,7 @@
         
     return CustomUser::SetupThreadHeap( aNotFirst, aInfo, 
             GetString( (TUint8) CustomUser::ELogFileName ),
+            GetString( (TUint8) CustomUser::ELogFilePath ),
             (TUint32) logOption, (TUint32) debug,
             GetString( (TUint8) CustomUser::EVersion ),
             (TUint32) allocCallStack, (TUint32) freeCallStack,
--- a/analyzetool/storageserver/client/bwins/atoolstorageserverclntu.def	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-EXPORTS
-	??0RATStorageServer@@QAE@XZ @ 1 NONAME ; RATStorageServer::RATStorageServer(void)
-	?CancelLogging@RATStorageServer@@QAEHI@Z @ 2 NONAME ; int RATStorageServer::CancelLogging(unsigned int)
-	?CheckMemoryAddress@RATStorageServer@@QBEHK@Z @ 3 NONAME ; int RATStorageServer::CheckMemoryAddress(unsigned long) const
-	?Close@RATStorageServer@@QAEXXZ @ 4 NONAME ; void RATStorageServer::Close(void)
-	?Connect@RATStorageServer@@QAEHXZ @ 5 NONAME ; int RATStorageServer::Connect(void)
-	?GetCurrentAllocsL@RATStorageServer@@QAEHIAAK0@Z @ 6 NONAME ; int RATStorageServer::GetCurrentAllocsL(unsigned int, unsigned long &, unsigned long &)
-	?GetLoadedDllsL@RATStorageServer@@QAEHIAAV?$RArray@V?$TBuf8@$0DM@@@@@@Z @ 7 NONAME ; int RATStorageServer::GetLoadedDllsL(unsigned int, class RArray<class TBuf8<60> > &)
-	?GetLoggingFileL@RATStorageServer@@QAEHIAAVTDes8@@@Z @ 8 NONAME ; int RATStorageServer::GetLoggingFileL(unsigned int, class TDes8 &)
-	?GetLoggingModeL@RATStorageServer@@QAEHIAAW4TATLogOption@@@Z @ 9 NONAME ; int RATStorageServer::GetLoggingModeL(unsigned int, enum TATLogOption &)
-	?GetMaxAllocsL@RATStorageServer@@QAEHIAAK0@Z @ 10 NONAME ; int RATStorageServer::GetMaxAllocsL(unsigned int, unsigned long &, unsigned long &)
-	?GetProcessesL@RATStorageServer@@QAEHAAV?$RArray@VTATProcessInfo@@@@@Z @ 11 NONAME ; int RATStorageServer::GetProcessesL(class RArray<class TATProcessInfo> &)
-	?GetUdebL@RATStorageServer@@QAEHIAAK@Z @ 12 NONAME ; int RATStorageServer::GetUdebL(unsigned int, unsigned long &)
-	?IsMemoryAdded@RATStorageServer@@QAEHK@Z @ 13 NONAME ; int RATStorageServer::IsMemoryAdded(unsigned long)
-	?LogDllLoaded@RATStorageServer@@QAEHABVTDesC8@@KK@Z @ 14 NONAME ; int RATStorageServer::LogDllLoaded(class TDesC8 const &, unsigned long, unsigned long)
-	?LogDllUnloaded@RATStorageServer@@QAEHABVTDesC8@@KK@Z @ 15 NONAME ; int RATStorageServer::LogDllUnloaded(class TDesC8 const &, unsigned long, unsigned long)
-	?LogMemoryAllocated@RATStorageServer@@QAEHKAAV?$TFixedArray@K$0BAA@@@H@Z @ 16 NONAME ; int RATStorageServer::LogMemoryAllocated(unsigned long, class TFixedArray<unsigned long, 256> &, int)
-	?LogMemoryFreed@RATStorageServer@@QAEHKAAV?$TFixedArray@K$0BAA@@@@Z @ 17 NONAME ; int RATStorageServer::LogMemoryFreed(unsigned long, class TFixedArray<unsigned long, 256> &)
-	?LogProcessEnded@RATStorageServer@@QAEHII@Z @ 18 NONAME ; int RATStorageServer::LogProcessEnded(unsigned int, unsigned int)
-	?LogProcessStarted@RATStorageServer@@QAEHABVTDesC16@@ABVTDesC8@@IKK@Z @ 19 NONAME ; int RATStorageServer::LogProcessStarted(class TDesC16 const &, class TDesC8 const &, unsigned int, unsigned long, unsigned long)
-	?StartSubTest@RATStorageServer@@QAEHABVTDesC8@@@Z @ 20 NONAME ; int RATStorageServer::StartSubTest(class TDesC8 const &)
-	?StartSubTest@RATStorageServer@@QAEHIABVTDesC8@@H@Z @ 21 NONAME ; int RATStorageServer::StartSubTest(unsigned int, class TDesC8 const &, int)
-	?StopSubTest@RATStorageServer@@QAEHABVTDesC8@@@Z @ 22 NONAME ; int RATStorageServer::StopSubTest(class TDesC8 const &)
-	?StopSubTest@RATStorageServer@@QAEHIABVTDesC8@@H@Z @ 23 NONAME ; int RATStorageServer::StopSubTest(unsigned int, class TDesC8 const &, int)
-	?Version@RATStorageServer@@QBE?AVTVersion@@XZ @ 24 NONAME ; class TVersion RATStorageServer::Version(void) const
-
--- a/analyzetool/storageserver/client/eabi/atoolstorageserverclntu.def	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-EXPORTS
-	_ZN16RATStorageServer11StopSubTestERK6TDesC8 @ 1 NONAME
-	_ZN16RATStorageServer11StopSubTestEjRK6TDesC8i @ 2 NONAME
-	_ZN16RATStorageServer12LogDllLoadedERK6TDesC8mm @ 3 NONAME
-	_ZN16RATStorageServer12StartSubTestERK6TDesC8 @ 4 NONAME
-	_ZN16RATStorageServer12StartSubTestEjRK6TDesC8i @ 5 NONAME
-	_ZN16RATStorageServer13CancelLoggingEj @ 6 NONAME
-	_ZN16RATStorageServer13GetMaxAllocsLEjRmS0_ @ 7 NONAME
-	_ZN16RATStorageServer13GetProcessesLER6RArrayI14TATProcessInfoE @ 8 NONAME
-	_ZN16RATStorageServer13IsMemoryAddedEm @ 9 NONAME
-	_ZN16RATStorageServer14GetLoadedDllsLEjR6RArrayI5TBuf8ILi60EEE @ 10 NONAME
-	_ZN16RATStorageServer14LogDllUnloadedERK6TDesC8mm @ 11 NONAME
-	_ZN16RATStorageServer14LogMemoryFreedEmR11TFixedArrayImLi256EE @ 12 NONAME
-	_ZN16RATStorageServer15GetLoggingFileLEjR5TDes8 @ 13 NONAME
-	_ZN16RATStorageServer15GetLoggingModeLEjR12TATLogOption @ 14 NONAME
-	_ZN16RATStorageServer15LogProcessEndedEjj @ 15 NONAME
-	_ZN16RATStorageServer17GetCurrentAllocsLEjRmS0_ @ 16 NONAME
-	_ZN16RATStorageServer17LogProcessStartedERK7TDesC16RK6TDesC8jmm @ 17 NONAME
-	_ZN16RATStorageServer18LogMemoryAllocatedEmR11TFixedArrayImLi256EEi @ 18 NONAME
-	_ZN16RATStorageServer5CloseEv @ 19 NONAME
-	_ZN16RATStorageServer7ConnectEv @ 20 NONAME
-	_ZN16RATStorageServer8GetUdebLEjRm @ 21 NONAME
-	_ZN16RATStorageServerC1Ev @ 22 NONAME
-	_ZN16RATStorageServerC2Ev @ 23 NONAME
-	_ZNK16RATStorageServer18CheckMemoryAddressEm @ 24 NONAME
-	_ZNK16RATStorageServer7VersionEv @ 25 NONAME
-
--- a/analyzetool/storageserver/client/group/atoolstorageserverclnt.mmp	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
-* 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:  The .mmp file for the client side of AToolStorageServer
-*
-*/
-
-#include <platform_paths.hrh>
-
-TARGET            atoolstorageserverclnt.dll
-TARGETTYPE        dll
-UID               0x1000008d 0x20012431
-CAPABILITY        ALL -TCB
-
-SMPSAFE
-
-SOURCEPATH        ../src
-
-SOURCE            atstorageserverclnt.cpp
-
-USERINCLUDE       ../inc
-USERINCLUDE       ../../inc
-USERINCLUDE       ../../server/inc
-USERINCLUDE       ../../../inc
-
-OS_LAYER_SYSTEMINCLUDE
-
-LIBRARY           euser.lib
-LIBRARY           flogger.lib
-
-// End of File
--- a/analyzetool/storageserver/client/inc/atstorageserverclnt.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,371 +0,0 @@
-/*
-* 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:  Declaration of the client side handle class RATStorageServer
-*
-*/
-
-
-
-#ifndef ATSTORAGESERVERCLNT_H
-#define ATSTORAGESERVERCLNT_H
-
-
-// INCLUDES
-#include    <e32base.h>
-#include    <analyzetool/atcommon.h>
-
-
-// CONSTANTS
-// Constants for the lowest version of the server with which the
-// client is compatible
-const TUint KLowestVersionNumberMaj = 0;
-const TUint KLowestVersionNumberMin = 1;
-const TUint KLowestVersionNumberBld = 1;
-
-
-// FORWARD DECLARATIONS
-class TATProcessInfo;
-
-
-// CLASS DECLARATION
-
-/**
-*  The main class of the Storage Server client. Objects of this class work as handles
-*  to the Storage Server's server side. Use Connect() to connect a client to the server,
-*  and Close() to end an opened session.
-*/
-class RATStorageServer: public RSessionBase
-    {
-    public:  // Constructor and destructor
-       
-        /**
-        * C++ default constructor.
-        */
-        IMPORT_C RATStorageServer();
-   
-    public: // New functions
-        
-        /**
-        * Creates a new process for the server, if that doesn't already exist, and
-        * connects a client to the server by creating a new session with it, and
-        * initializes the client for use. To end the server session, use Close().
-        * @return KErrNone, if successful; otherwise one of the other
-        *   system-wide error codes.
-        */
-        IMPORT_C TInt Connect();
-    
-        /**
-        * Closes a handle to a server session. This has also the effect of destroying
-        * the associated server side session object. Also, the server itself and the
-        * process where it is running are destroyed, if there are no other open sessions
-        * left.
-        */
-        IMPORT_C void Close();
-    
-        /**
-        * This method is called to initialize the server for logging and it is to be
-        * called as the first method after connecting to the server. The method informs
-        * the server that a new process has been started. The method cannot be called
-        * again without a call to the LogProcessEnded() first. Otherwise a STSEClient: 3
-        * panic is raised. A KERN-EXEC: 0 panic is raised if the client is not connected
-        * to the server.
-        * @param aFileName The name of the logging file used when the system is logging
-        *   to a file (the logging mode is EATLogToFile). The length of aFileName must not be
-        *   greater than KMaxFileName, otherwise the method raises a STSEClient: 2 panic.
-        * @param aProcessName The name of the new process started. The length of this
-        *   descriptor must not be greater than KMaxProcessName, otherwise the method
-        *   raises a STSEClient: 2 panic.
-        * @param aProcessId The ID of the process started.
-        * @param aLogOption An option telling the logging mode.
-        * @param aIsDebug Determines whether a binary is UDEB or UREL
-        * @return KErrNone, if successful; otherwise one of the other
-        *   system-wide error codes.
-        */
-        IMPORT_C TInt LogProcessStarted( const TDesC& aFileName,
-                                         const TDesC8& aProcessName,
-                                         TUint aProcessId,
-                                         TUint32 aLogOption, TUint32 aIsDebug );
-        
-        /**
-        * Asks the server to log that a new DLL has been loaded. Note, the method
-        * LogProcessStarted() has to be previously called. Otherwise a STSEClient: 3
-        * panic is raised. A KERN-EXEC: 0 panic is raised if the client is not connected
-        * to the server.
-        * @param aDllName The name of the new DLL loaded. The length of this descriptor
-        *   must not be greater than KMaxLibraryName, otherwise the method raises a
-        *   STSEClient: 2 panic.
-        * @param aStartAddress The start address of the DLL loaded.
-        * @param aEndAddress The end address of the DLL loaded.
-        * @return KErrNone, if successful; otherwise one of the other
-        *   system-wide error codes.
-        */
-        IMPORT_C TInt LogDllLoaded( const TDesC8& aDllName, TUint32 aStartAddress,
-                                              TUint32 aEndAddress );
-        
-        /**
-        * Asks the server to log that a new DLL has been unloaded. Note, the method
-        * LogProcessStarted() has to be previously called. Otherwise a STSEClient: 3
-        * panic is raised. A KERN-EXEC: 0 panic is raised if the client is not connected
-        * to the server. If the method is called with illegal parameter values, a
-        * STSEClient: 2 panic is raised.
-        * @param aDllName The name of the DLL to be unloaded. The length of this
-        *   descriptor must not be greater than KMaxLibraryName, otherwise the method
-        *   raises a STSEClient: 2 panic.
-        * @param aStartAddress The start address of the DLL to be unloaded.
-        * @param aEndAddress The end address of the DLL to be unloaded.
-        * @return KErrNone, if successful; otherwise one of the other
-        *   system-wide error codes.
-        */
-        IMPORT_C TInt LogDllUnloaded( const TDesC8& aDllName, TUint32 aStartAddress,
-                                               TUint32 aEndAddress );
-        
-        /**
-        * Informs the server that a memory allocation has occured at the specified
-        * address. Sends also the current call stack to the server. Note, the method
-        * LogProcessStarted() has to be previously called. Otherwise a STSEClient: 3 
-        * panic is raised. A KERN-EXEC: 0 panic is raised if the client is not connected
-        * to the server.
-        * @param aMemAddress The memory location where memory has been allocated.
-        * @param aCallstack An array including the current call stack.
-        * @param aSize The size of the newly allocated memory chunk.
-        * @return KErrNone, if successful; otherwise one of the other
-        *   system-wide error codes.
-        */
-        IMPORT_C TInt LogMemoryAllocated( TUint32 aMemAddress,
-                                          TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
-                                          TInt aSize );
-                
-        /**
-        * Informs the server that memory was released at the specified address. Note,
-        * the method LogProcessStarted() has to be previously called. Otherwise a 
-        * STSEClient: 3 panic is raised. A KERN-EXEC: 0 panic is raised if the client is
-        * not connected to the server.
-        * @param aMemAddress The memory location where memory has been deallocated.
-        * @param aFreeCallstack An array including the current call stack.
-        * @return KErrNone, if successful; otherwise one of the other
-        *   system-wide error codes.
-        */
-        IMPORT_C TInt LogMemoryFreed( TUint32 aMemAddress, 
-                                      TFixedArray<TUint32, KATMaxFreeCallstackLength>& aFreeCallstack );
-        
-        /**
-        * Tells the server that the process under test has been ended. Prints information
-        * related to process ending, such as possibly occured memory leaks (when file
-        * logging mode used), and possibly occured handle leaks. Note, the method 
-        * LogProcessStarted() has to be previously called. Otherwise a STSEClient:
-        * 3 panic is raised. A call to this method also closes the file opened for
-        * the current process. So, no further logging is possible without a new call
-        * to the method LogProcessStarted(). A KERN-EXEC: 0 panic is raised if the client
-        * is not connected to the server.
-        * @param aProcessId The ID number of the process ended.
-        * @param aHandleLeaks Amount of handle leaks.
-        * @return KErrNone, if successful; otherwise one of the other
-        *   system-wide error codes.
-        */
-        IMPORT_C TInt LogProcessEnded( TUint aProcessId, 
-                                       TUint aHandleLeaks );
-           
-        /**
-        * Gives the lowest version number of the server needed for this client.
-        * @return The lowest version of the server needed for this client.
-        */
-        IMPORT_C TVersion Version() const;  
-
-        /**
-        * Checks if the current process has allocated, but not freed, the given memory
-        * address. Note, the method LogProcessStarted() has to be previously called.
-        * Otherwise a STSEClient: 3 panic is raised. A KERN-EXEC: 0 panic is raised if
-        * the client is not connected to the server.
-        * @param aMemAddress The memory location to check.
-        * @return When the system is logging into a file: the index of a found 
-        *   memory address or KErrNotFound, if a matching memory address cannot
-        *   be found. When the system is not logging into a file: always KErrNone.
-        */
-        IMPORT_C TInt CheckMemoryAddress( TUint32 aMemAddress ) const;
-        
-        /**
-        * Gets all the processes with currently open logging sessions.
-        * @param aProcesses A reference to a process array to be filled by the server.
-        * @return KErrNone, if successful; otherwise one of the other
-        *   system wide error codes.
-        */
-        IMPORT_C TInt GetProcessesL( RArray<TATProcessInfo>& aProcesses );
-        
-        /**
-        * Gets all the DLLs loaded by the given process.
-        * @param aProcessId The ID of the process whose DLLs will be fetched.
-        * @param aDlls An array that after this function call includes names of
-        *   the given process's dlls
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was
-        *   not found; otherwise one of the other system wide error codes.
-        */
-        IMPORT_C TInt GetLoadedDllsL( TUint aProcessId,
-                                      RArray< TBuf8<KMaxLibraryName> >& aDlls );
-                
-        /**
-        * Gets the logging mode of the given process.
-        * @param aProcessId The ID of the process whose logging mode is being asked.
-        * @param aLoggingMode An enumeration telling the logging mode after a call
-        *   to this function.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was
-        *   not found; otherwise one of the other system wide error codes.
-        */
-        IMPORT_C TInt GetLoggingModeL( TUint aProcessId, TATLogOption& aLoggingMode );
-        
-        /**
-        * Starts a sub test for the given process.
-        * @param aProcessId The ID of the process for which to start a sub test.
-        * @param aSubtestId The name identifying this particular sub test. The length
-        *   of this descriptor must not be greater than KATMaxSubtestIdLength, or
-        *   otherwise the method raises a STSEClient: 2 panic.
-        * @param aHandleCount The current handle count of a particular process.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was not
-        *   found; KErrNotSupported, if the requested process does not have a logging
-        *   session ongoing or its logging mode is not EATLogToTrace; Otherwise one of the
-        *   other system wide error codes.
-        */
-        IMPORT_C TInt StartSubTest( TUint aProcessId, const TDesC8& aSubtestId, TInt aHandleCount = 0 );
-
-        /**
-        * Stops a sub test for the given process.
-        * @param aProcessId The ID of the process for which to stop a sub test.
-        * @param aSubtestId The name identifying this particular sub test. The length
-        *   of this descriptor must not be greater than KATMaxSubtestIdLength, or
-        *   otherwise the method raises a STSEClient: 2 panic.
-        * @param aHandleCount The current handle count of a particular process.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was not
-        *   found; KErrNotSupported, if the requested process does not have a logging
-        *   session ongoing or its logging mode is not EATLogToTrace; Otherwise one of the
-        *   other system wide error codes.
-        */
-        IMPORT_C TInt StopSubTest( TUint aProcessId, const TDesC8& aSubtestId, TInt aHandleCount = 0 );
-        
-        /**
-        * Gets the number and total size of the memory chunks currently allocated by the
-        * requested process. 
-        * @param aProcessId The ID of the process whose information is requested.
-        * @param aNumber On return contains the number of memory chunks currenlty
-        *   allocated by the requested process.
-        * @param aSize On return contains the amount of memory currently allocated
-        *   by the requested process.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was not
-        *   found; Otherwise one of the other system wide error codes.
-        */
-        IMPORT_C TInt GetCurrentAllocsL( TUint aProcessId, TUint32& aNumber, TUint32& aSize );
-        
-        /**
-        * Gets the maximum number and total size of the memory chunks allocated by the
-        * requested process. 
-        * @param aProcessId The ID of the process whose information is requested.
-        * @param aNumber On return contains the maximum number of memory chunks
-        *   allocated by the requested process during the test run.
-        * @param aSize On return contains the maximum amount of memory allocated
-        *   by the requested process during the test run.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was not
-        *   found; Otherwise one of the other system wide error codes.
-        */
-        IMPORT_C TInt GetMaxAllocsL( TUint aProcessId, TUint32& aNumber, TUint32& aSize );
-        
-        /**
-        * Starts a sub test for the calling process.
-        * @param aSubtestId The name identifying this particular sub test. The length
-        *   of this descriptor must not be greater than KATMaxSubtestIdLength, or
-        *   otherwise the method raises a STSEClient: 2 panic.
-        * @return KErrNone, if successful; KErrNotSupported, if the calling process
-        *   does not have a logging session ongoing or its logging mode is not
-        *   EATLogToTrace; Otherwise one of the other system wide error codes.
-        */
-        IMPORT_C TInt StartSubTest( const TDesC8& aSubtestId );
-
-        /**
-        * Stops a sub test for the calling process
-        * @param aSubtestId The name identifying this particular sub test. The length
-        *   of this descriptor must not be greater than KATMaxSubtestIdLength, or
-        *   otherwise the method raises a STSEClient: 2 panic.
-        * @return KErrNone, if successful; KErrNotSupported, if the calling process
-        *   does not have a logging session ongoing or its logging mode is not
-        *   EATLogToTrace; Otherwise one of the other system wide error codes.
-        */
-        IMPORT_C TInt StopSubTest( const TDesC8& aSubtestId );
-        
-        /**
-        * Cancels logging for the requested process. After logging of a given process
-        * has been cancelled, the session associated with that process will not be
-        * usable anymore. If a process wants to start logging again, it needs to close
-        * the handle and open it again in order to create a new session. Until then, most
-        * of the client's methods will return KErrCancel.
-        * @param aProcessId The process ID of the process whose logging is requested to
-        *   be cancelled.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was
-        *   not found; otherwise one of the other system wide error codes.
-        */
-        IMPORT_C TInt CancelLogging( TUint aProcessId );
-
-        /**
-        * Gets the number and total size of the memory chunks currently allocated by the
-        * requested process. 
-        * @param aProcessId The ID of the process whose information is requested.
-        * @param aIsUdeb On return contains an value greater than KErrNone if
-        *   mode is UDEB. Else the mode is UREL
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was not
-        *   found; Otherwise one of the other system wide error codes.
-        */
-        IMPORT_C TInt GetUdebL( TUint aProcessId, TUint32& aIsUdeb );
-
-        /**
-        * Gets the number and total size of the memory chunks currently allocated by the
-        * requested process. 
-        * @param aProcessId The ID of the process whose information is requested.
-        * @param aFileName On return contains logging filename for the process.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was not
-        *   found; Otherwise one of the other system wide error codes.
-        */
-        IMPORT_C TInt GetLoggingFileL( TUint aProcessId, TDes8& aFileName );
-     
-        /**
-		* Check a memory allocation (memory address) from an internal array.
-		* @param aMemAddress The memory address to be check
-		* @return KErrNone, if memory address found in array; 
-		* 	KErrNotFound, if the requested memory address was not found.
-		*/
-        IMPORT_C TInt IsMemoryAdded( TUint32 aMemAddress );
-               
-    protected: // New functions
-    
-        /**
-        * Creates a new process for the server, if it does not already exist.
-        * @return KErrNone, if successful; otherwise one of the other
-        * system-wide error codes. 
-        */
-        TInt CreateProcess();
-        
-    private: // Internal functions
-    
-        /**
-        * Creates two buffers: one for storing call stack memory addresses and one for
-        * handle leaks. Internally used by this class. May leave, if there is 
-        * insufficient memory.
-        */
-        void ConstructBuffersL();
-        
-    private: // Data
-    
-        /** A pointer to a buffer of call stack's memory addresses */
-        CBufFlat* iStackBuf;
-    };
-
-#endif      // ATSTORAGESERVERCLNT_H   
-
-            
-// End of File
--- a/analyzetool/storageserver/client/src/atstorageserverclnt.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,930 +0,0 @@
-/*
-* 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:  Definitions for the client side handle class RATStorageServer
-*
-*/
-
-
-
-// INCLUDE FILES
-#include    "atstorageserverclnt.h"
-#include    "atstorageserver.h"
-#include    "atlog.h"
-#include    "atstorageservercommon.h"
-
-
-// CONSTANTS
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::RATStorageServer
-// C++ default constructor.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C RATStorageServer::RATStorageServer() :
-    RSessionBase(), iStackBuf( NULL )
-    {
-    LOGSTR1( "STSE RATStorageServer::RATStorageServer()" );
-    }
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::Connect
-// A function for connecting to the server
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RATStorageServer::Connect()
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::Connect()" );
- 
-    TInt errorCode( KErrNone );
-    errorCode = CreateProcess();
-    
-    // If process's creation failed, return the error code
-    if ( errorCode != KErrNone )
-        {
-        return errorCode;
-        }
-        
-    // Otherwise create a new session    
-    errorCode = CreateSession( KStorageServerName, Version() );
-    
-    // If creation of a new session failed, return the error code
-    if ( errorCode != KErrNone )
-        {
-        return errorCode;
-        }
-    
-    // Construct a buffer for call stack's memory addresses. If the function leaves,
-    // the leave code is put in "errorCode". 
-    TRAP( errorCode, ConstructBuffersL() ); 
-    
-    return errorCode;
-    }
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::Close
-// Destroys all memory reserved by this class, and calls RSessionBase::Close()
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void RATStorageServer::Close()
-    {
-    LOGSTR1( "STSE void RATStorageServer::Close()" );
-    
-    // Delete iStackBuf
-    delete iStackBuf;
-    iStackBuf = NULL;
-    
-    // Call the base class' Close()
-    RSessionBase::Close(); 
-    }
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::LogProcessStarted
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RATStorageServer::LogProcessStarted( const TDesC& aFileName,
-                                                   const TDesC8& aProcessName,
-                                                   TUint aProcessId,
-                                                   TUint32 aLogOption, TUint32 aIsDebug )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::LogProcessStarted()" );
-    
-    // Panic always if aFileName or aProcessName are longer than allowed.
-    __ASSERT_ALWAYS( aFileName.Length() <= KMaxFileName &&
-                     aProcessName.Length() <= KMaxProcessName,
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    // Panic (in debug builds) if aProcessId is KNullProcessId
-    __ASSERT_DEBUG( aProcessId != KNullProcessId,
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-
-    // This information is optional -> ignoring error
-    // Must be before EProcessStarted in order to append udeb/urel
-    // information to LogProcessStarted
-    TIpcArgs ipcArgs2( aIsDebug );
-    SendReceive( CATStorageServer::EProcessUdeb, ipcArgs2 );
-    
-    TIpcArgs ipcArgs( &aFileName, &aProcessName, aProcessId, aLogOption );
-    TInt error( 0 );
-    
-    error = SendReceive( CATStorageServer::EProcessStarted, ipcArgs );
-
-    // Return, if error is not KErrNone.
-    if ( error != KErrNone )
-        {
-        return error;
-        }
-    
-    return KErrNone;
-    }
-       
-// -----------------------------------------------------------------------------
-// RATStorageServer::LogDllLoaded
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RATStorageServer::LogDllLoaded( const TDesC8& aDllName,
-                                              TUint32 aStartAddress,
-                                              TUint32 aEndAddress )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::LogDllLoaded()" );
-    
-    // Panic always if aDllName is longer than allowed.
-    __ASSERT_ALWAYS( aDllName.Length() <= KMaxLibraryName,
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    // Panic (in debug builds) if aStartAddress is greater than aEndAddress
-    __ASSERT_DEBUG( aStartAddress <= aEndAddress,
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    TIpcArgs ipcArgs( &aDllName, aStartAddress, aEndAddress );
-    
-    return SendReceive( CATStorageServer::EDllLoaded, ipcArgs );
-    }
-    
-// -----------------------------------------------------------------------------
-// RATStorageServer::LogDllUnloaded
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RATStorageServer::LogDllUnloaded( const TDesC8& aDllName,
-                                                TUint32 aStartAddress,
-                                                TUint32 aEndAddress )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::LogDllUnloaded()" );
-    
-    // Panic always if aDllName is longer than allowed.
-    __ASSERT_ALWAYS( aDllName.Length() <= KMaxLibraryName,
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    // Panic (in debug builds) if aStartAddress is greater than aEndAddress
-    __ASSERT_DEBUG( aStartAddress <= aEndAddress,
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-      
-    TIpcArgs ipcArgs( &aDllName, aStartAddress, aEndAddress );
-    
-    return SendReceive( CATStorageServer::EDllUnloaded, ipcArgs );
-    }    
-        
-// -----------------------------------------------------------------------------
-// RATStorageServer::LogMemoryAllocated
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RATStorageServer::LogMemoryAllocated( TUint32 aMemAddress,
-                                                    TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
-                                                    TInt aSize )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::LogMemoryAllocated()" );
-    
-    TInt count=0;
-    // The number of memory addresses in aCallstack
-    for ( TInt i = 0; i < KATMaxCallstackLength; i++ )
-        {
-        if( aCallstack[i] == 0 )
-            {
-            break;
-            }
-        count++;
-        }
-    
-    LOGSTR2( "STSE The number of memory addresses in the current call stack: %d", count );
-    
-    // The maximum number of call stack's memory addresses this server can handle
-    // is KMaxCallstackLength
-    if ( count > KATMaxCallstackLength )
-        {
-        count = KATMaxCallstackLength;
-        }
-        
-    // Panic (in debug builds) if the parameters are faulty
-    __ASSERT_DEBUG( aMemAddress != 0 && count >= 0 && aSize >= 0,
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-          
-    // Buffer position
-    TInt pos = 0;  
-    TUint32 callStackAddr;
-                 
-    // Write the number of memory addresses of aCallstack (one word) into
-    // the beginning of the call stack buffer
-    iStackBuf->Write( pos, &count, KWordSize );
-    
-    // Increase the position by one word
-    pos += KWordSize; 
-      
-    // Write all the memory addresses of aCallStack into the buffer 
-    for ( TInt i = 0; i < count; i++ )
-        {
-        callStackAddr = aCallstack[i];
-        
-        // Write the current memory address (the length of an address is one word)
-        iStackBuf->Write( pos, &callStackAddr, KWordSize ); 
-        
-        // Move the pos variable one word (4 bytes) onwards.
-        pos += KWordSize;        
-        }  
-    
-    TPtr8 bufPtr( iStackBuf->Ptr(0) );       
-     
-    TIpcArgs ipcArgs( aMemAddress, &bufPtr, aSize );
-     
-    return SendReceive( CATStorageServer::EMemoryAllocated, ipcArgs );  
-    }
-        
-// -----------------------------------------------------------------------------
-// RATStorageServer::LogMemoryFreed
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RATStorageServer::LogMemoryFreed( TUint32 aMemAddress,
-        TFixedArray<TUint32, KATMaxFreeCallstackLength>& aFreeCallstack )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::LogMemoryFreed()" );
-    
-    TInt count=0;
-    // The number of memory addresses in aFreeCallstack
-    for ( TInt i = 0; i < KATMaxCallstackLength; i++ )
-        {
-        if( aFreeCallstack[i] == 0 )
-            {
-            break;
-            }
-        count++;
-        }
-    LOGSTR3( "STSE > aFreeCallstack.Count() ( %i ), address( %x )", 
-    		count, aMemAddress );
-    
-    // The maximum number of call stack's memory addresses this server can handle
-	// is KMaxCallstackLength
-	if ( count > KATMaxFreeCallstackLength )
-		{
-		count = KATMaxFreeCallstackLength;
-		}
-		  
-	// Buffer position
-	TInt pos = 0;	
-	TUint32 callStackAddr;
-				 
-	// Write the number of memory addresses of aFreeCallstack (one word) into
-	// the beginning of the call stack buffer
-	iStackBuf->Write( pos, &count, KWordSize );
-	
-	// Increase the position by one word
-	pos += KWordSize; 
-	  
-	// Write all the memory addresses of aFreeCallstack into the buffer 
-	for ( TInt i = 0; i < count; i++ )
-		{
-		callStackAddr = aFreeCallstack[i];
-		
-		// Write the current memory address (the length of an address is one word)
-		iStackBuf->Write( pos, &callStackAddr, KWordSize ); 
-		
-		// Move the pos variable one word (4 bytes) onwards.
-		pos += KWordSize;        
-		}  
-	
-	TPtr8 bufPtr( iStackBuf->Ptr( 0 ) );	 
-	TIpcArgs ipcArgs( aMemAddress, &bufPtr );
-    	
-    return SendReceive( CATStorageServer::EMemoryFreed, ipcArgs );
-    }        
-        
-// -----------------------------------------------------------------------------
-// RATStorageServer::LogProcessEnded
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RATStorageServer::LogProcessEnded( TUint aProcessId,
-                                                 TUint aHandleLeaks )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::LogProcessEnded()" );
-    
-    // Panic (in debug builds) if the parameters are faulty
-    __ASSERT_DEBUG( aProcessId != KNullProcessId,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    TIpcArgs ipcArgs( aProcessId, aHandleLeaks );
-    
-    return SendReceive( CATStorageServer::EProcessEnded, ipcArgs );
-    }
-
-//-----------------------------------------------------------------------------
-// RATStorageServer::Version()
-// Returns the version number.
-//-----------------------------------------------------------------------------
-//
-EXPORT_C TVersion RATStorageServer::Version() const
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::Version()" );
-    
-    return TVersion(KLowestVersionNumberMaj, KLowestVersionNumberMin,
-                                                KLowestVersionNumberBld);
-    }
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::CheckMemoryAddress
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RATStorageServer::CheckMemoryAddress( TUint32 aMemAddress ) const
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::CheckMemoryAddress()" );
-    
-    // Panic (in debug builds) if the parameters are faulty
-    __ASSERT_DEBUG( aMemAddress != 0, 
-            StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    TIpcArgs ipcArgs( aMemAddress );
-    
-    return SendReceive( CATStorageServer::EMemoryCheck, ipcArgs ); 
-    }
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::GetProcessesL
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::GetProcessesL( RArray<TATProcessInfo>& aProcesses )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::GetProcessesL()" );
-    
-    TInt error( KErrNone );
-    TInt sizeOfProcessInfo = sizeof( TATProcessInfo );
-    
-    // Reset the sent array
-    aProcesses.Reset();
-    
-    // Calculate the length of the buffer to be constructed for processes.
-    // One word will be reserved for the length of the array.
-    TInt bufferLength = KWordSize + KATMaxProcesses * sizeOfProcessInfo; 
-    
-    CBufFlat* processBuf;
-    // Construct processBuf and expand it before the beginning (index 0)
-    processBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( processBuf );
-    processBuf->ExpandL( 0, bufferLength );
-    
-    TPtr8 bufPtr( processBuf->Ptr(0) );
-    
-    // Send the buffer to the server, which will fill it.
-    TIpcArgs ipcArgs( &bufPtr );  
-    error = SendReceive( CATStorageServer::EGetProcesses, ipcArgs ); 
-    // Return with the error code if the operation failed
-    if ( error != KErrNone )
-        {
-        CleanupStack::PopAndDestroy( processBuf );
-        return error;
-        }
-    
-    // A variable for the number of TATProcessInfo objects
-    TInt count( 0 );
-     // A variable for the position
-    TInt pos( 0 );
-    
-    // Read the value for count 
-    processBuf->Read( pos, &count, KWordSize );
-    
-    // Return if we got an illegal value for count     
-    if ( count < 0 || count > KATMaxProcesses )
-        {
-        CleanupStack::PopAndDestroy( processBuf );
-        return KErrGeneral;
-        }    
-
-    // Move the position one word onwards.    
-    pos += KWordSize;
-
-    TATProcessInfo processInfo;
-
-    // Go through all TATProcessInfo objects sent to the server 
-    for ( TInt j = 0; j < count; j++ )
-        {
-        // Read one of the TATProcessInfo objects stored in the buffer.
-        processBuf->Read( pos, &processInfo, sizeOfProcessInfo );
-       
-        // Append this processInfo to the array
-        error = aProcesses.Append( processInfo );
-
-        if ( error != KErrNone )
-            {
-            CleanupStack::PopAndDestroy( processBuf );
-            return error;
-            }
-
-        // Move the pos variable one word onwards.
-        pos += sizeOfProcessInfo;
-        }  
-    
-    CleanupStack::PopAndDestroy( processBuf );
-    return error;
-    }
-        
-// -----------------------------------------------------------------------------
-// RATStorageServer::GetLoadedDllsL
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::GetLoadedDllsL( TUint aProcessId, 
-                                                RArray< TBuf8<KMaxLibraryName> >& aDlls )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::GetLoadedDllsL()" );
-    
-    // Panic (in debug builds) if aProcessId is faulty
-    __ASSERT_DEBUG( aProcessId != KNullProcessId,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    TInt error( KErrNone );
-    
-    // Size of a DLL descriptor
-    TInt sizeOfDllDesc = sizeof( TBuf8<KMaxLibraryName> );
-    
-    // Reset the sent array
-    aDlls.Reset();
-    
-    // Calculate the length of the buffer to be constructed for DLL names.
-    // One word will be reserved for the length of the array.
-    TInt bufferLength = KWordSize + KATMaxDlls * sizeOfDllDesc; 
-    
-    CBufFlat* dllBuf;
-    // Construct dllBuf and expand it before the beginning (index 0)
-    dllBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( dllBuf );
-    dllBuf->ExpandL( 0, bufferLength );
-    
-    TPtr8 bufPtr( dllBuf->Ptr(0) );
-    
-    // Call the server with the given arguments
-    TIpcArgs ipcArgs( aProcessId, &bufPtr );  
-    error = SendReceive( CATStorageServer::EGetDlls, ipcArgs );
-    
-    // Return, if error is not KErrNone.
-    if ( error != KErrNone )
-        {
-        CleanupStack::PopAndDestroy( dllBuf );      
-        return error;
-        }
-    
-    // A variable for the number of objects in the buffer
-    TInt count( 0 );
-    
-     // A variable for the position
-    TInt pos( 0 );
-    
-    // Read the value for count 
-    dllBuf->Read( pos, &count, KWordSize );
-    
-    // Return if we got an illegal value for count
-    if ( count < 0 || count > KATMaxDlls )
-        {
-        CleanupStack::PopAndDestroy( dllBuf );
-        return KErrGeneral;
-        }
-
-    // Move the position one word onwards.    
-    pos += KWordSize;
-
-    TBuf8<KMaxLibraryName> dllName;
-
-    // Go through all DLL names objects sent to the server 
-    for ( TInt j = 0; j < count; j++ )
-        {
-        // Read one of the DLL names stored in the buffer.
-        dllBuf->Read( pos, &dllName, sizeOfDllDesc );
-       
-        // Append this DLL name to the array
-        error = aDlls.Append( dllName );
-
-        if ( error != KErrNone )
-            {
-            return error;
-            }
-
-        // Move the pos variable one word onwards.
-        pos += sizeOfDllDesc;
-        }  
-    
-    CleanupStack::PopAndDestroy( dllBuf );
-    return error;
-    }    
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::GetLoggingModeL
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::GetLoggingModeL( TUint aProcessId,
-                                                TATLogOption& aLoggingMode )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::GetLoggingModeL()" );
-    
-    // Panic (in debug builds) if aProcessId is illegal
-    __ASSERT_DEBUG( aProcessId != KNullProcessId,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    TInt error(0);
-    
-    // The length of the buffer to be constructed for logging mode
-    TInt bufferLength = KWordSize; 
-    
-    CBufFlat* loggingModeBuf;
-    // Construct allocInfoBuf and expand it before the beginning (index 0)
-    loggingModeBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( loggingModeBuf );
-    loggingModeBuf->ExpandL( 0, bufferLength );
-    
-    TPtr8 bufPtr( loggingModeBuf->Ptr(0) );
-    
-    // Call the server
-    TIpcArgs ipcArgs( aProcessId, &bufPtr );  
-    error = SendReceive( CATStorageServer::EGetLoggingMode, ipcArgs );
-    
-    // Return if an error occured.
-    if ( error )
-        {
-        CleanupStack::PopAndDestroy( loggingModeBuf );
-        return error;
-        }
-      
-    // A variable for the position
-    TInt pos( 0 );
-    
-    // Read the value for aNumber
-    loggingModeBuf->Read( pos, &aLoggingMode, KWordSize );
-    
-    CleanupStack::PopAndDestroy( loggingModeBuf );
-    
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::StartSubTest
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::StartSubTest( TUint aProcessId, 
-                                              const TDesC8& aSubtestId, TInt aHandleCount )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::StartSubTest()" );
-    
-    // Panic if the parameters are faulty
-    __ASSERT_ALWAYS( aSubtestId.Length() <= KATMaxSubtestIdLength,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-        
-    // Panic (in debug builds) if the parameters are faulty
-    __ASSERT_DEBUG( aProcessId != KNullProcessId,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-        
-    TIpcArgs ipcArgs( aProcessId, &aSubtestId, aHandleCount );
-    
-    return SendReceive( CATStorageServer::ESubtestStart, ipcArgs );
-    }
-    
-// -----------------------------------------------------------------------------
-// RATStorageServer::StopSubTest
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::StopSubTest( TUint aProcessId, 
-                                             const TDesC8& aSubtestId, TInt aHandleCount )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::StopSubTest()" );
-    
-    // Panic if the parameters are faulty
-    __ASSERT_ALWAYS( aSubtestId.Length() <= KATMaxSubtestIdLength,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-        
-    // Panic (in debug builds) if the parameters are faulty
-    __ASSERT_DEBUG( aProcessId != KNullProcessId,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-        
-    TIpcArgs ipcArgs( aProcessId, &aSubtestId, aHandleCount );
-    
-    return SendReceive( CATStorageServer::ESubtestStop, ipcArgs );
-    }
-    
-// -----------------------------------------------------------------------------
-// RATStorageServer::GetCurrentAllocsL
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::GetCurrentAllocsL( TUint aProcessId, 
-                                                  TUint32& aNumber,
-                                                  TUint32& aSize   )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::GetCurrentAllocsL()" );
-    
-    // Panic (in debug builds) if aProcessId is illegal
-    __ASSERT_DEBUG( aProcessId != KNullProcessId,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    TInt error(0);
-    
-    // The length of the buffer to be constructed for allocation number and size
-    TInt bufferLength = KWordSize + KWordSize; 
-    
-    CBufFlat* allocInfoBuf;
-    // Construct allocInfoBuf and expand it before the beginning (index 0)
-    allocInfoBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( allocInfoBuf );
-    allocInfoBuf->ExpandL( 0, bufferLength );
-    
-    TPtr8 bufPtr( allocInfoBuf->Ptr(0) );
-    
-    // Call the server
-    TIpcArgs ipcArgs( aProcessId, &bufPtr );  
-    error = SendReceive( CATStorageServer::EGetCurrentAllocs, ipcArgs );
-    
-    // Return if error is not KErrNone.
-    if ( error != KErrNone )
-        {
-        CleanupStack::PopAndDestroy( allocInfoBuf );
-        return error;
-        }
-      
-    // A variable for the position
-    TInt pos( 0 );
-    
-    // Read the value for aNumber
-    allocInfoBuf->Read( pos, &aNumber, KWordSize );
-    
-    pos += KWordSize;
-    
-    // Read the value for aSize
-    allocInfoBuf->Read( pos, &aSize, KWordSize );
-    
-    CleanupStack::PopAndDestroy( allocInfoBuf );
-    
-    return KErrNone;
-    }
-                                                  
-// -----------------------------------------------------------------------------
-// RATStorageServer::GetMaxAllocsL
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::GetMaxAllocsL( TUint aProcessId, 
-                                              TUint32& aNumber,
-                                              TUint32& aSize   )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::GetMaxAllocsL()" );
-    
-    // Panic (in debug builds) if aProcessId is illegal
-    __ASSERT_DEBUG( aProcessId != KNullProcessId,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-        
-    TInt error(0);
-     
-    // The length of the buffer to be constructed for allocation number and size
-    TInt bufferLength = KWordSize + KWordSize; 
-
-    CBufFlat* allocInfoBuf;
-    // Construct allocInfoBuf and expand it before the beginning (index 0)
-    allocInfoBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( allocInfoBuf );
-    allocInfoBuf->ExpandL( 0, bufferLength );
-
-    TPtr8 bufPtr( allocInfoBuf->Ptr(0) );
-
-    // Call the server
-    TIpcArgs ipcArgs( aProcessId, &bufPtr );
-    error = SendReceive( CATStorageServer::EGetMaxAllocs, ipcArgs );
-
-    // Return, if error is not KErrNone.
-    if ( error != KErrNone )
-        {
-        CleanupStack::PopAndDestroy( allocInfoBuf );
-        return error;
-        }
-
-    // A variable for the position
-    TInt pos( 0 );
-
-    // Read the value for aNumber
-    allocInfoBuf->Read( pos, &aNumber, KWordSize );
-
-    pos += KWordSize;
-
-    // Read the value for aSize
-    allocInfoBuf->Read( pos, &aSize, KWordSize );
-
-    CleanupStack::PopAndDestroy( allocInfoBuf );
-
-    return KErrNone;
-    }
-    
-// -----------------------------------------------------------------------------
-// RATStorageServer::StartSubTest
-// An overloaded version without a PID parameter
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::StartSubTest( const TDesC8& aSubtestId )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::StartSubTest()" );
-    
-    // Panic if the parameters are faulty
-    __ASSERT_ALWAYS( aSubtestId.Length() <= KATMaxSubtestIdLength,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-        
-    TIpcArgs ipcArgs( &aSubtestId );
-    
-    return SendReceive( CATStorageServer::ESubtestStart2, ipcArgs );
-    }
-    
-// -----------------------------------------------------------------------------
-// RATStorageServer::StopSubTest
-// An overloaded version without a PID parameter
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::StopSubTest( const TDesC8& aSubtestId )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::StopSubTest()" );
-    
-    // Panic if the parameters are faulty
-    __ASSERT_ALWAYS( aSubtestId.Length() <= KATMaxSubtestIdLength,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-        
-    TIpcArgs ipcArgs( &aSubtestId );
-    
-    return SendReceive( CATStorageServer::ESubtestStop2, ipcArgs );
-    }
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::CancelLogging
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::CancelLogging( TUint aProcessId )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::CancelLogging()" );
-    
-    // Panic (in debug builds) if aProcessId is illegal
-    __ASSERT_DEBUG( aProcessId != KNullProcessId,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    TIpcArgs ipcArgs( aProcessId );
-    
-    return SendReceive( CATStorageServer::ECancelLogging, ipcArgs );
-    }
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::CreateProcess
-// Checks if the server already exists. If it doesn't, creates a new process
-// for it.
-// -----------------------------------------------------------------------------
-//
-TInt RATStorageServer::CreateProcess()
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::CreateProcess()" );
-    
-    TInt errorCode( KErrNone );
- 
-    // Check if the server already exists
-    TFindServer findServer( KStorageServerName );
-    TFullName fullName;
-
-    errorCode = findServer.Next( fullName );
-    
-    // Return KErrNone if the server is already running
-    if ( errorCode == KErrNone )
-        {
-        return KErrNone;
-        }
-    
-    // Otherwise initiate starting the server by creating first a new process for it.
-    // The second argument of the Create() method call is an empty descriptor, because
-    // we don't need to pass any data to the thread function of the new process's main
-    // thread.
-    RProcess process;
-    errorCode = process.Create( KStorageServerFile, KNullDesC );
-    
-    // Return the error code if the creation of the process failed
-    if ( errorCode != KErrNone )
-        {
-        return errorCode;
-        }
-    
-    TRequestStatus status;
-    process.Rendezvous( status );
-    
-    // If the status is not KRequestPending, abort the project creation
-    // and return KErrGeneral
-    if ( status != KRequestPending )
-        {
-        process.RendezvousCancel( status );
-        process.Kill( KErrGeneral );
-        process.Close();
-        return KErrGeneral;
-        }
-    
-    // Otherwise make the first thread of the new process eligible for execution
-    process.Resume();
-    
-    // Wait for a signal from the server       
-    User::WaitForRequest( status );
-    
-    // Close the process handle    
-    process.Close();
-    
-    // Return the error code
-    return status.Int();
-    }
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::ConstructBuffersL
-// Allocates buffers from heap. Called when connecting to the server
-// -----------------------------------------------------------------------------
-//
-void RATStorageServer::ConstructBuffersL()
-    {
-    LOGSTR1( "STSE void RATStorageServer::ConstructBuffersL()" );
-    
-    // Calculate the length of the buffer to be constructed for call stack.
-    // One word will be reserved for the length of the array
-    TInt bufferLength = ( (1 + KATMaxCallstackLength) * KWordSize  );
-    
-    // Construct iStackBuf and expand it before the beginning (index 0)
-    iStackBuf = CBufFlat::NewL( bufferLength );
-    iStackBuf->ExpandL( 0, bufferLength );
-    }
-    
-// -----------------------------------------------------------------------------
-// RATStorageServer::GetLoggingFileL
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::GetLoggingFileL( TUint aProcessId,
-                                                    TDes8& aFileName )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::GetLoggingFileL()" );
-    
-    // Panic (in debug builds) if aProcessId is illegal
-    __ASSERT_DEBUG( aProcessId != KNullProcessId,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    TInt error(0);
-
-    TBuf8<KMaxFileName> fileBuf;
-    // Call the server
-    TIpcArgs ipcArgs( aProcessId, &fileBuf );  
-    error = SendReceive( CATStorageServer::EGetLoggingFile, ipcArgs );
-    
-    // Return, if an error occured.
-    if ( error )
-        {
-        return error;
-        }
-      
-    aFileName.Copy( fileBuf );
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::GetUdebL
-// -----------------------------------------------------------------------------
-//    
-EXPORT_C TInt RATStorageServer::GetUdebL( TUint aProcessId, TUint32& aIsUdeb )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::GetUdebL()" );
-    
-    // Panic (in debug builds) if aProcessId is illegal
-    __ASSERT_DEBUG( aProcessId != KNullProcessId,        
-        StorageServerPanic( KCategoryClient, EAToolBadArgument ) );
-    
-    TInt error(0);
-    TBuf8<KMaxVersionName> isUdeb;
-    _LIT8( KUdeb, "UDEB" );
-    // Call the server
-    TIpcArgs ipcArgs( aProcessId, &isUdeb );  
-    error = SendReceive( CATStorageServer::EGetUdeb, ipcArgs );
-    
-    // Return, if an error occured.
-    if ( error != KErrNone )
-        {
-        return error;
-        }
-    
-    if ( isUdeb.Compare( KUdeb() ) == 0 )
-        {
-        LOGSTR1( "STSE TInt RATStorageServer::GetUdebL() - Is UDEB" );    
-        aIsUdeb = 1;    
-        }
-    else
-        {
-        LOGSTR1( "STSE TInt RATStorageServer::GetUdebL() - Is UREL" );
-        aIsUdeb = 0;    
-        }
-
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// RATStorageServer::IsMemoryAdded
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RATStorageServer::IsMemoryAdded( TUint32 aMemAddress )
-    {
-    LOGSTR1( "STSE TInt RATStorageServer::IsMemoryAdded()" );
-        
-    TIpcArgs ipcArgs( aMemAddress );    
-    return SendReceive( CATStorageServer::EIsMemoryAdded, ipcArgs );
-    }
-
-//  End of File
--- a/analyzetool/storageserver/group/bld.inf	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
-* 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 <platform_paths.hrh>
-
-PRJ_PLATFORMS
-ARMV5 WINSCW
-
-PRJ_EXPORTS
-../client/inc/atstorageserverclnt.h         OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/atstorageserverclnt.h)
-
-PRJ_MMPFILES
-../server/group/atoolstorageserver.mmp
-../client/group/atoolstorageserverclnt.mmp
-
-PRJ_TESTMMPFILES
-../internal/tsrc/group/storageservertest.mmp
--- a/analyzetool/storageserver/inc/atstorageservercommon.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
-* 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:  Includes common constants and enums for the AnalyzeTool 
-*                StorageServer client and server.
-*
-*/
-
-
-
-#ifndef ATSTORAGESERVERCOMMON_H
-#define ATSTORAGESERVERCOMMON_H
-
-
-//  INCLUDES
-
-#include <e32base.h>
-
-
-// CONSTANTS
-
-// Server's file name
-_LIT(KStorageServerFile, "AToolStorageServer.exe");
-
-// server name
-_LIT(KStorageServerName,"AToolStorageServer");
-
-
-// The path of the storage file
-#ifdef __WINS__
-_LIT( KATDataFilePath, ":\\logs\\analyzetool\\" );
-#else
-_LIT( KATDataFilePath, ":\\analyzetool\\" );
-_LIT( KATDataFilePath2, ":\\data\\analyzetool\\" );
-#endif
-
-// The word size in the current system is 32 bits, which is 4 bytes.
-const TInt KWordSize = 4;
-
-// Leak array granularity value
-const TInt KLeakArrayGranularity = 100;
-
-// DATA TYPES
-
-/** Storage Server panic codes */
-enum TStorageServerPanics
-    {
-    EAToolBadRequest = 1, // An undefined operation request from the client
-    EAToolBadArgument,    // Illegal arguments / function parameters   
-    EAToolNotAllowed,     // An operation is not allowed in the current program state
-    EAToolInternalError,   // An internal error has occured
-    EAToolIllegalLogOption // An undefined log option has been requested 
-    };
-
-
-/** Panic categories */
-_LIT(KCategoryServer,"STSEServer");
-_LIT(KCategoryClient,"STSEClient");
-
-inline void StorageServerPanic( const TDesC &aCategory, TStorageServerPanics aReason )
-    {
-    User::Panic(aCategory, aReason);
-    }
-  
-#endif      // ATSTORAGESERVERCOMMON_H   
-
-// End of File
--- a/analyzetool/storageserver/server/group/atoolstorageserver.mmp	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
-* 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:  The .mmp file for the server side of AToolStorageServer
-*
-*/
-
-#include <platform_paths.hrh>
-
-TARGET        atoolstorageserver.exe
-TARGETTYPE    exe
-UID           0x0 0x20012430   
-CAPABILITY    NONE
-
-SMPSAFE
-
-EPOCHEAPSIZE 0x10000 0x800000
-
-SOURCEPATH    ../src
-
-SOURCE        atstorageserver.cpp
-SOURCE        atstorageserversession.cpp
-SOURCE        atmemoryentry.cpp
-SOURCE        atdynprocessinfo.cpp
-SOURCE        atdriveinfo.cpp
-SOURCE        atdllinfo.cpp
-
-USERINCLUDE   ../inc
-USERINCLUDE   ../../inc
-USERINCLUDE   ../../../inc
-
-OS_LAYER_SYSTEMINCLUDE
-
-LIBRARY     euser.lib
-LIBRARY     efsrv.lib
-LIBRARY     flogger.lib
-LIBRARY     charconv.lib
-LIBRARY     platformenv.lib 
-
-// End of File
--- a/analyzetool/storageserver/server/inc/atdllinfo.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
-* 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:  Declaration of the class TATDllInfo.
-*
-*/
-
-
-#ifndef ATDLLINFO_H
-#define ATDLLINFO_H
-
-// INCLUDES
-#include <u32std.h>
-
-/**
-*  Stores information of process loaded library
-*/
-class TATDllInfo
-    {
-    
-    public: // Constructors
-        
-        /**
-        * C++ default constructor.
-        * @param aStartAddress Start address of the library 
-        * @param aEndAddress The end address of the library 
-        * @param aLoadTime The current time in a 64-bit form.
-        * @param aDllName The name of the library
-        */
-        TATDllInfo( const TUint32 aStartAddress, const TUint32 aEndAddress, 
-        		const TInt64& aLoadTime, const TDesC8& aDllName );
-
-    public: // New functions
-
-        /**
-        * Returs library start address
-        * @return TUint32 start address of the library
-        */
-        TUint32 StartAddress();
-        
-        /**
-		* Returns library end address
-		* @return TUint32 end address of the library
-		*/
-		TUint32 EndAddress();
-                
-        /**
-        * Gets specific library name
-        * return TDes8 Name of the library
-        */
-        TDes8& Name();
-        
-        /**
-		* Returns library load time
-		* @return TInt64 library load time
-		*/
-        TInt64 LibraryLoadTime();
-        		
-        /**
-		* Checks if two objects of this class match based on the objects's
-        * saved library name.
-		* @param aFirst Library object
-		* @param aSecond Library object
-		* return TBool ETrue, if the two objects match. EFalse otherwise.
-		*/
-        static TBool Match( const TATDllInfo& aFirst, const TATDllInfo& aSecond );
-                
-    public: // Member variables
-
-        /* Start address of the loaded dll */
-    	const TUint32 iStartAddress;
-
-        /* End address of the loaded dll */
-        const TUint32 iEndAddress;
-
-        /* Loaded dll name */
-        TBuf8<KMaxLibraryName> iName;
-        
-        /** For storing the time when DLL has loaded. */
-        const TInt64 iLoadTime;
-    };
-
-#endif // ATDLLINFO_H
-
-// End of File
-
--- a/analyzetool/storageserver/server/inc/atdriveinfo.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
-* 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:  Declaration of the class TATDriveInfo.
-*
-*/
-
-
-
-#ifndef ATDRIVEINFO_H
-#define ATDRIVEINFO_H
-
-#include <f32file.h>
-
-/**
-*  Check what drives exists and creates file full path.
-*/
-class TATDriveInfo
-    {    
-    public: // Constructors
-        
-        /**
-        * C++ default constructor.
-        */
-        TATDriveInfo();
-
-    public: // New functions
-
-        /**
-        * Create the file full path.
-        * @param aPath Full path.
-        * @param aFileName Filename.
-        * @param aFs A handle to a file server.
-        * @return KErrNone or KErrAlreadyExists, if successful; 
-        *   Otherwise one of the other system wide error codes.
-        */
-        static TInt CreatePath( TDes& aPath, const TDesC& aFileName, RFs& aFs );   
-    
-    private: // New functions
-    
-        /**
-        * Get the available drive character.
-        * @param aDrive The drive letter.
-        * @param aDriveNumber The drive number.
-        * @param aFs A handle to a file server.
-        * @param aDriveType Drive type.
-        * @return KErrNone, if successful; otherwise KErrNotFound
-        */
-        static TInt GetDrive( TChar& aDrive, TInt& aDriveNumber, 
-                RFs& aFs, const TUint aDriveType );  
-        
-    };
-
-#endif // ATDRIVEINFO_H
-
-// End of File
-
--- a/analyzetool/storageserver/server/inc/atdynprocessinfo.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
-* 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:  Declaration of the class CATDynProcessInfo
-*
-*/
-
-
-#ifndef ATDYNPROCESSINFO_H
-#define ATDYNPROCESSINFO_H
-
-
-//  INCLUDES
-#include    <e32base.h>
-#include    <analyzetool/atcommon.h>
-#include	"atdllinfo.h"
-
-// FORWARD DECLARATIONS
-class CATStorageServerSession;
-
-// CLASS DECLARATION
-
-/**
-*  A class that can store different process related information. The information
-*  is associated to a particular process wiht a member telling a process ID.
-*  All the other information but the process ID and the pointer to this process's
-*  associated session object can be subject to change dynamically, run-time.
-*/
-class CATDynProcessInfo : public CBase
-    {
-    public: // Constructor
-
-        /**
-        * Constructor. 
-        */ 
-        CATDynProcessInfo();
-    
-        /**
-        * Constructor. 
-        * @param aProcessId A process ID.
-        * @param aSessionObject A pointer to this process's associated session object.
-        * @param aDlls The loaded DLLs of the associated process.
-        */
-        CATDynProcessInfo( TUint aProcessId,
-                           CATStorageServerSession* aSessionObject,
-                           const RArray<TATDllInfo>& aDlls );
-        
-        /**
-        * Constructor.
-        * @param aProcessId A process ID.
-        * @param aSessionObject A pointer to this process's associated session object.
-        */
-        CATDynProcessInfo( TUint aProcessId,
-                           CATStorageServerSession* aSessionObject );
-                           
-        /**
-        * Constructor.
-        * @param aProcessId A process ID.
-        */
-        CATDynProcessInfo( TUint aProcessId );
-
-        /**
-        * Destructor
-        */
-        virtual ~CATDynProcessInfo();
-        
-    public:
-        
-        /**
-        * Compares two objects of this class based on the process ID.
-        * @param aFirst The first object of this class to be compared.
-        * @param aSecond The second object of this class to be compared.
-        * @return  Zero, if the two objects are equal. A negative value,
-        *   if the first object is less than the second. A positive value,
-        *   if the first object is greater than the second.
-        */
-        static TInt Compare( const CATDynProcessInfo& aFirst,
-                             const CATDynProcessInfo& aSecond );
-        
-    public:
-
-        /** The ID of the process. */
-        const TUint iProcessId;
-        
-        /** A pointer to the session object associated with this process. */
-        CATStorageServerSession* const iSessionObject;
-        
-        /** The DLLs loaded by the associated process */
-        RArray<TATDllInfo> iDlls;
-    };
-  
-#endif      // ATDYNPROCESSINFO_H
--- a/analyzetool/storageserver/server/inc/atmemoryentry.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
-* 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:  Declaration of the class CATMemoryEntry
-*
-*/
-
-
-#ifndef ATMEMORYENTRY_H
-#define ATMEMORYENTRY_H
-
-
-//  INCLUDES
-#include <e32base.h>
-
-
-// CLASS DECLARATION
-
-/**
-*  A class for storing memory entries when the server is informed that memory has been
-*  allocated. The class stores the memory address of a new allocation and a pointer to
-*  a buffer including the current call stack. It also stores a time stamp, and the size
-*  of the allocation. 
-*     The class has member methods for evaluating two different objects of this class
-*  with each other. In the construction the class takes a pointer to the call stack
-*  buffer, but it does not create the buffer itself. However, it is responsible for
-*  deleting the buffer in the destruction.
-*/
-class CATMemoryEntry : public CBase
-    {
-    public: // Constructor
-
-        /**
-        * Constructor.
-        * @param aMemAddress An address to allocated memory.
-        * @param aCallstackBuf A pointer to a buffer containing call stack's memory
-        *   addresses.
-        * @param aAllocTime The current time in a 64-bit form.
-        * @param aAllocSize The size of an allocated memory chunk.
-        */ 
-        CATMemoryEntry( TUint32 aMemAddress, const CBufFlat* aCallstackBuf,
-                        const TInt64& aAllocTime, TInt aAllocSize );
-
-        /**
-        * Destructor
-        */
-        virtual ~CATMemoryEntry();
-
-    public:
-        /**
-        * Compares two objects of this class based on the allocation time.
-        * @param aFirst The first object of this class to be compared.
-        * @param aSecond The second object of this class to be compared.
-        * @return  Zero, if the two objects are equal. A negative value,
-        *   if the first object is less than the second. A positive value,
-        *   if the first object is greater than the second.
-        */
-        static TInt Compare( const CATMemoryEntry& aFirst,
-                             const CATMemoryEntry& aSecond );
-
-        /**
-        * Checks if two objects of this class match based on the objects's
-        * saved memory allocation addresses.
-        * @param aFirst The first object of this class to be evaluated.
-        * @param aSecond The second object of this class to be evaluated.
-        * @return ETrue, if the two objects match. EFalse otherwise.
-        */
-        static TBool Match( const CATMemoryEntry& aFirst,
-                            const CATMemoryEntry& aSecond );
-
-    public:
-
-        /** For storing an address of a memory allocation. */
-        const TUint32 iMemAddress;
-
-        /** A pointer to an array for storing the current call stack. */
-        const CBufFlat* const iCallstackBuf;
-        
-        /** For storing the time when an allocation has occured. */
-        const TInt64 iAllocTime;
-        
-        /** For storing the size of an allocation. */
-        const TInt iAllocSize;
-        
-    };
-  
-  
-#endif      // ATMEMORYENTRY_H
--- a/analyzetool/storageserver/server/inc/atstorageserver.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,218 +0,0 @@
-/*
-* 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:  Declaration of the server side main class CATStorageServer
-*
-*/
-
-
-#ifndef ATSTORAGESERVER_H
-#define ATSTORAGESERVER_H
-
-
-//  INCLUDES
-#include    <e32base.h>
-#include    <analyzetool/atcommon.h>
-#include 	"atdllinfo.h"
-
-// CONSTANTS
-// Constants for the server's version
-const TUint KVersionNumberMaj = 0;
-const TUint KVersionNumberMin = 1;
-const TUint KVersionNumberBld = 1;
-
-// DATA TYPES
-
-// FORWARD DECLARATIONS
-class TATProcessInfo;
-class CATDynProcessInfo;
-class CATStorageServerSession;
-
-// CLASS DECLARATION
-
-/**
-*  The main class of the Storage Server.
-*  When a client connects to the server, a new session object
-*  is created by an object of this class. If the server does not exist when
-*  connecting, a new process and an object of this class are created first.
-*/
-class CATStorageServer : public CPolicyServer
-    {
-    
-    public: // Enumerations
-    
-        // opcodes used in message passing between client and server
-        enum TStorageServerReq
-            {
-            EProcessStarted,
-            EDllLoaded,
-            EDllUnloaded,
-            EMemoryAllocated,
-            EMemoryFreed,
-            EProcessEnded,
-            EMemoryCheck,
-            EGetProcesses,
-            EGetDlls,
-            ESetLoggingMode,
-            EGetLoggingMode,
-            ESubtestStart,
-            ESubtestStop,
-            ESubtestStart2,
-            ESubtestStop2,
-            EGetCurrentAllocs,
-            EGetMaxAllocs,
-            ECancelLogging,
-            EGetUdeb,
-            EGetLoggingFile,
-            EProcessUdeb,
-            EIsMemoryAdded,
-            EOutOfBounds
-            };
-    
-    
-    public: // Constructors and destructor
-        
-        /**
-        * Two-phased constructor that can leave.
-        * @return A new instance of this class
-        */
-        static CATStorageServer* NewL();
-        
-        /**
-        * Two-phased constructor that can leave and leaves a pointer
-        * on the cleanup stack.
-        * @return A new instance of this class
-        */
-        static CATStorageServer* NewLC();
-        
-        /**
-        * Destructor
-        */
-        virtual ~CATStorageServer();
-
-    public: // New functions
-        
-  
-        /**
-        * Creates a new server object and starts the server.
-        */
-        static void RunServerL();
-        
-        /**
-        * Increments the count of active sessions for this server.
-        */
-        void IncSessionCount();
-
-        /**
-        * Decrements the count of active sessions for this server.
-        */
-        void DecSessionCount();
-        
-        /**
-        * Adds a new process into the server's arrays.
-        * @param aProcessName The name of the process to be added.
-        * @param aProcessId The ID of the process to be added.
-        * @param aSessionObject A pointer to the current process's associated session
-        *   object.
-        * @param aStartTime The starting time of the process to be added. It represents
-        *   time as a number of microseconds since midnight, January 1st, 0 AD nominal 
-        *   Gregorian. This is the representation used by, e.g., the TTime class.
-        * @return KErrNone, if the operation is successful; KErrAlreadyExists, if
-        *   an attempt is being made to insert a duplicate process; otherwise one of
-        *   the other system wide error codes.
-        */
-        TInt AddProcessL( const TDesC8& aProcessName, 
-                         TUint aProcessId,
-                         CATStorageServerSession* aSessionObject,
-                         const TInt64& aStartTime );
-        
-        /**
-        * Removes a process from the server's arrays.
-        * @param aProcessId The ID of the process to be removed.
-        * @return KErrNone, if successful; KErrNotFound, if a process with
-        *   the specified process ID could not be found in the array.
-        */
-        TInt RemoveProcessL( TUint aProcessId );
-        
-        /**
-        * Adds a DLL for a given process to the dynamic process info array of this class.
-        * @param aProcessId The ID of the process that has loaded the DLL to be added.
-        * @param aDllInfo Information of the DLL.
-        * @return KErrNone, if successful; KErrNotFound, if a process with the given
-        *   process ID could not be found; KErrAlreadyExists, if a DLL with the given
-        *   name was already stored; otherwise one of the other system wide error codes.
-        */
-        TInt AddDllL( TUint aProcessId, const TATDllInfo aDllInfo );
-        
-        /**
-        * Removes a DLL associated with the given process from the dynamic process
-        * info array of this class.
-        * @param aProcessId The ID of the process that has loaded the DLL to be removed.
-        * @param aDllName The name of the DLL to be removed.
-        * @return KErrNone, if successful; KErrNotFound, if a process with
-        *   the specified process ID could not be found, or if a DLL with the specified
-        *   name could not be found.
-        */
-        TInt RemoveDllL( TUint aProcessId, const TDesC8& aDllName );
-            
-        /**
-        * Gives a reference to the process info array of this class.
-        * @return A reference to iProcesses array
-        */
-        const RArray<TATProcessInfo>& ProcessInfoArray();
-        
-        /**
-        * Gives a reference to the dynamic process info array of this class.
-        * @return A reference to iProcessesDyn array
-        */
-        const RPointerArray<CATDynProcessInfo>& DynProcessInfoArray();
-                
-    public: // Functions from base classes
-        
-        /**
-        * From CPolicyServer.
-        * Creates a new server-side session object.
-        * @param aVersion The version of this server
-        * @param aMessage A message from the client
-        * @return A pointer to a new session object.
-        */
-        CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const;
-        
-    private:
-
-        /**
-        * C++ default constructor.
-        * @param aPriority A priority for this active object
-        */
-        CATStorageServer( TInt aPriority );
-
-        /**
-        *  Symbian 2nd phase constructor.
-        */
-        void ConstructL();
-   
-    private: // Data
-        
-        /** The number of active sessions */
-        TInt iSessionCount;
-        
-        /** An array for storing TATProcessInfo objects */
-        RArray<TATProcessInfo> iProcesses;
-        
-        /** An array for storing CATDynProcessInfo pointers */
-        RPointerArray<CATDynProcessInfo> iProcessesDyn;
-    };
-
-#endif      // ATSTORAGESERVER_H
-            
-// End of File
\ No newline at end of file
--- a/analyzetool/storageserver/server/inc/atstorageserversession.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,588 +0,0 @@
-/*
-* 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:  Declaration of the server side session class CATStorageServerSession
-*
-*/
-
-
-#ifndef ATSTORAGESERVERSESSION_H
-#define ATSTORAGESERVERSESSION_H
-
-
-//  INCLUDES
-#include    <e32base.h>
-#include    <f32file.h>
-#include    <analyzetool/atcommon.h>
-
-// FORWARD DECLARATIONS
-class CATStorageServer;
-class CATMemoryEntry;
-
-// CLASS DECLARATIONS
-
-/**
-*  A class for storing memory addresses and sizes of allocations.
-*  Needed for giving allocation information for the configuration UI.
-*/
-class TAllocInfo
-    {
-    public:
-    
-    // Constructor
-    TAllocInfo( TUint32 aMemAddress, TInt aAllocSize );
-    
-    /** Address of a memory allocation. */
-    const TUint32 iMemAddress;
-    
-    /** Size of the associated allocation. */
-    const TInt iAllocSize;
-    };
-
-
-/**
-*  The session class for Storage Server.
-*  When the Storage Server client connects to the server, a new object of this
-*  class is constructed. So, for every client there is an associated object
-*  of this class. CATStorageServer forwards all client messages to their associated
-*  session objects.
-*/
-class CATStorageServerSession : public CSession2
-    {
-    public: // Enumerations
-        
-    public:  // Constructors and destructor
-        
-        /**
-        * Two-phased constructor that can leave.
-        * @return A new instance of this class
-        */
-        static CATStorageServerSession* NewL( CATStorageServer& aStorageServer );
-        
-        /**
-        * Two-phased constructor that can leave and leaves a pointer
-        * on the cleanup stack.
-        * @return A new instance of this class
-        */
-        static CATStorageServerSession* NewLC( CATStorageServer& aStorageServer );
-        
-        /**
-        * Destructor
-        */
-        virtual ~CATStorageServerSession();
-        
-    public: // Functions from base classes 
-        
-        /**
-        * Receives messages sent by a client.
-        * @param aMessage A message from a client
-        */
-        virtual void ServiceL( const RMessage2& aMessage );
-        
-    protected: // new functions
-        
-        /**
-        * Initializes this session for logging. This includes opening a logging file
-        * with a requested name. The method is to be called as the first method after
-        * connecting to the server. The method logs information on process starting into
-        * the just opened logging file.
-        * If a logging session is already ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is already
-        * ongoing. Otherwise one of the other system wide error codes.
-        */
-        TInt LogProcessStartedL( const RMessage2& aMessage );
-        
-        /**
-        * Initializes this session for logging. The method is to be called as the first
-        * method after connecting to the server. The method logs information on process
-        * starting into debug channel.
-        * If a logging session is already ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is already
-        * ongoing. Otherwise one of the other system wide error codes.
-        */
-        TInt LogProcessStartTraceL( const RMessage2& aMessage );
-         
-        /**
-        * Logs information on a DLL load into the opened file.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is not
-        *   currently ongoing; Otherwise one of the other system wide error codes.
-        */
-        TInt LogDllLoadedL( const RMessage2& aMessage );
-        
-        /**
-        * Logs information on a DLL load into debug channel.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is not
-        *   currently ongoing; Otherwise one of the other system wide error codes.
-        */
-        TInt LogDllLoadTraceL( const RMessage2& aMessage );
-        
-        /**
-        * Logs information on a DLL unload into the opened file.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is not
-        *   currently ongoing; Otherwise one of the other system wide error codes.
-        */
-        TInt LogDllUnloadedL( const RMessage2& aMessage );
-        
-        /**
-        * Logs information on a DLL unload into debug channel.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is not
-        *   currently ongoing; Otherwise one of the other system wide error codes.
-        */
-        TInt LogDllUnloadTraceL( const RMessage2& aMessage );
-        
-        /**
-        * Stores a memory allocation (memory address, current call stack, allocation
-        * time and allocation size) in an internal array.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is not
-        *   currently ongoing; KErrAlreadyExists, if an attempt is being made to allocate
-        *   again an already allocated memory area; Otherwise one of the other system
-        *   wide error codes.
-        */
-        TInt LogMemoryAllocatedL( const RMessage2& aMessage );
-        
-        /**
-        * Logs information on a memory allocation into debug channel.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is not
-        *   currently ongoing; KErrAlreadyExists, if an attempt is being made to allocate
-        *   again an already allocated memory area; Otherwise one of the other system
-        *   wide error codes.
-        */
-        TInt LogMemoryAllocTraceL( const RMessage2& aMessage );
-                
-        /**
-        * Check a memory allocation (memory address) from an internal array.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @param aRemoveAlloc Boolean to enable removing the found address from allocations.
-        * @return KErrNone, if memory address found in array; 
-        *   KErrNotFound, if the requested memory address was not found.
-        */
-        TInt IsMemoryAdded( const RMessage2& aMessage, const TBool aRemoveAlloc = EFalse );
-        
-        /**
-        * Removes a memory allocation (memory address, current call stack, allocation
-        * time and allocation size) from an internal array.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is not
-        *   currently ongoing; KErrNotFound, if the requested memory address was not
-        *   found; Otherwise one of the other system wide error codes.
-        */
-        TInt LogMemoryFreedL( const RMessage2& aMessage );
-        
-        /**
-        * Logs information on freeing of a memory allocatin into debug channel.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is not
-        *   currently ongoing; KErrNotFound, if the requested memory address was not
-        *   found; Otherwise one of the other system wide error codes.
-        */
-        TInt LogMemoryFreedTraceL( const RMessage2& aMessage );
-        
-        /**
-        * Logs all non-released memory allocations into the opened file as memory leaks.
-        * Then the method logs a number of possibly occured handle leaks into the file.
-        * Next, the method logs information on process ending into the logging file.
-        * Finally, this method closes the logging file opened for the connected process,
-        * and ends the current logging session. However, this method does not end the 
-        * actual client-server session.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is not
-        *   currently ongoing; KErrNotSupported if this method is called with a wrong
-        *   process id from the client. Otherwise one of the other system wide error
-        *   codes.
-        */
-        TInt LogProcessEndedL( const RMessage2& aMessage );
-        
-        /**
-        * Logs a number of possibly occured handle leaks into debug channel. Then, the method
-        * logs information on process ending into debug channel. The method also
-        * ends the current logging session. However, this method does not end the actual
-        * client-server session.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrCancel, if a logging session is not
-        *   currently ongoing; KErrNotSupported if this method is called with a wrong
-        *   process id from the client. Otherwise one of the other system wide error
-        *   codes.
-        */
-        TInt LogProcessEndTraceL( const RMessage2& aMessage );
-        
-        /**
-        * Checks if a given memory address can be found.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return When the system is logging into a file: the index of a found 
-        *   memory address, or KErrNotFound, if a matching memory address cannot
-        *   be found. KErrNone, when the system is not logging into a file.
-        *   KErrCancel, if a logging session is not currently ongoing.
-        */
-        TInt CheckMemoryAddressL( const RMessage2& aMessage );
-        
-        /**
-        * Checks if a given memory address can be found.
-        * If a logging session is not ongoing, the method makes the client raise an
-        * STSEClient: 3 panic, and returns KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return When the system is logging into a file: the index of a found 
-        *   memory address, or KErrNotFound, if a matching memory address cannot
-        *   be found. KErrNone, when the system is not logging into a file.
-        *   KErrCancel, if a logging session is not currently ongoing.
-        */
-        TInt CheckMemoryAddressTrace( const RMessage2& aMessage );
-        
-        /**
-        * Gets all the processes currently logging with AnalyzeTool
-        * @param aMessage A message that includes parameters sent by the client.
-        *   On return a buffer including all the currently logging processes is written
-        *   into this message.
-        * @return KErrNone, if successful; otherwise one of the other system wide error
-        *   codes.
-        */
-        TInt GetProcessesL( const RMessage2& aMessage );
-        
-        /**
-        * Gets all the DLLs loaded by the process determined by the parameters.
-        * @param aMessage A message that includes parameters sent by the client.
-        *   A buffer including all the DLLs loaded by the requested process is
-        *   written into this message.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was
-        *   not found; otherwise one of the other system wide error codes.
-        */
-        TInt GetDllsL( const RMessage2& aMessage );
-        
-        /**
-        * Gets the logging mode of the process determined by the parameters.
-        * @param aMessage A message that includes parameters sent by the client.
-        *   On return, the logging mode is written into this message.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was
-        *   not found; otherwise one of the other system wide error codes.
-        */
-        TInt GetLoggingModeL( const RMessage2& aMessage );
-        
-        /**
-        * Starts a sub test for the given process.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process is not
-        *   found; KErrNotSupported, if the requested process does not have a logging
-        *   session ongoing or its logging mode is not EATLogToTrace; Otherwise one of the
-        *   other system wide error codes.
-        */
-        TInt StartSubtestL( const RMessage2& aMessage );
-        
-        /**
-        * Stops a sub test for the given process.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process is not
-        *   found; KErrNotSupported, if the requested process does not have a logging
-        *   session ongoing or its logging mode is not EATLogToTrace; Otherwise one of the
-        *   other system wide error codes.
-        */
-        TInt StopSubtestL( const RMessage2& aMessage );
-        
-        /**
-        * Starts a sub test for the calling process. Does not need a PID from the client.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrNotSupported, if the calling process
-        *   does not have a logging session ongoing or its logging mode is not
-        *   EATLogToTrace; Otherwise one of the other system wide error codes.
-        */
-        TInt StartSubtest2L( const RMessage2& aMessage );
-        
-        /**
-        * Stops a sub test for the calling process. Does not need a PID from the client.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrNotSupported, if the calling process
-        *   does not have a logging session ongoing or its logging mode is not
-        *   EATLogToTrace; Otherwise one of the other system wide error codes.
-        */
-        TInt StopSubtest2( const RMessage2& aMessage );
-        
-        /**
-        * Gets the number and total size of the current memory chunks allocated by the
-        * requested process.
-        * @param aMessage A message that includes parameters sent by the client. The
-        *   requested information is written into this message.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was
-        *   not found; otherwise one of the other system wide error codes.
-        */
-        TInt GetCurrentAllocsL( const RMessage2& aMessage );
-        
-        /**
-        * Gets the maximum number of memory chunks and the maximum amount of memory 
-        * allocated by the requested process during the test run.
-        * @param aMessage A message that includes parameters sent by the client. The
-        *   requested information is written into this message.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was
-        *   not found; otherwise one of the other system wide error codes.
-        */
-        TInt GetMaxAllocsL( const RMessage2& aMessage );
-        
-        /**
-        * Cancels logging for the requested process. After logging of a given process
-        * has been cancelled, the session associated with that process will not be
-        * usable anymore. If a process wants to start logging again, it needs to close
-        * the handle and open it again in order to create a new session. Until then, any
-        * of the server's methods that can be called by the client will return
-        * KErrCancel.
-        * @param aMessage A message that includes parameters sent by the client.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was
-        *   not found; otherwise one of the other system wide error codes.
-        */
-        TInt CancelLoggingL( const RMessage2& aMessage );
-        
-        /**
-        * Gets the logging file of the process determined by the parameters.
-        * @param aMessage A message that includes parameters sent by the client.
-        *   On return, the logging file is written into this message.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was
-        *   not found; otherwise one of the other system wide error codes.
-        */
-        TInt GetLoggingFileL( const RMessage2& aMessage );
-        
-        /**
-        * Gets the mode of the process determined by the parameters.
-        * @param aMessage A message that includes parameters sent by the client.
-        *   On return, the logging file is written into this message.
-        * @return KErrNone, if successful; KErrNotFound, if the requested process was
-        *   not found; otherwise one of the other system wide error codes.
-        */
-        TInt GetUdebL( const RMessage2& aMessage );
-        
-        /**
-        * Sets the mode of the process determined by the parameters.
-        * @param aMessage A message that includes parameters sent by the client.
-        */
-        void SetUdeb( const RMessage2& aMessage );
-        
-    private:  // New functions for internal use  
-    
-        /**
-        * Releases the resources reserved by this object, and before closing the logging
-        * file and file server session, the method logs information on the occured error
-        * into the logging file.
-        * @param aError The error code to be logged.
-        */
-        void HandleError( TInt aError );
-        
-        /**
-        * Releases the resources reserved by this object, and logs information on the
-        * occured error into debug channel.
-        * @param aError The error code to be logged.
-        */
-        void HandleErrorTrace( TInt aError );
-        
-        /**
-        * Opens a file server session and a file with the name specified.
-        * @param aFileName The name of the file into which to log.
-        * @param aProcessName Current process name.
-        * @return KErrNone, if successful; otherwise one of the other system wide
-        *   error codes.
-        */
-        TInt OpenFsAndFile( const TDesC& aFileName, const TDesC8& aProcessName );
-        
-        /**
-        * Method is used to parse file name extension.
-        * @param aFileName The name of the file into which to log.
-        * @param aExtension Parsed file extension. 
-        */
-        void ParseExtension( TDes& aFileName, TDes& aExtension );
-        
-        /**
-        * Called internally when need generate new file name.
-        * @param aFileName The name of the file into which to log.
-        * @param aProcessName Current process name.
-        */
-        void GenerateNewFileName( TDes& aFileName, const TDesC8& aProcessName );
-        
-        /**
-        * Method is used to check that file exists and is valid.
-        * @param aFileName The name of the file into which to log.
-        */
-        void CheckIfFileAlreadyExist( const TDes& aFileName );
-        
-        /**
-        * Method is used to check file version.
-        * @param aFileName The name of the file into which to log.
-        */
-        void CheckFileVersion( const TDes& aFileName );
-        
-        /**
-        * Closes the handles to the file server session and to the file (if currently open).
-        */
-        void CloseFsAndFile();
-        
-        /**
-        * Writes the memory leaks stored in the iLeakArray member array into the
-        * logging file opened for the current logging session. If the method is
-        * called in a wrong program state (logging session is not ongoing, or the
-        * logging mode is not EATLogToFile), STSEClient: 4, and STSEServer: 4
-        * panics are raised.
-        * @param aMessage The current message from the client.
-        * @return KErrNone, if successful; otherwise one of the other system wide
-        *   error codes.
-        */
-        TInt PrintLeaksL( const RMessage2& aMessage );
-        
-        /**
-        * Sets the server's mode of operation. The operation mode is determined with
-        * an enumeration value, which is received from the client. If the method is
-        * called in a wrong program state (logging session is ongoing), STSEClient: 4,
-        * and STSEServer: 4 panics are raised.
-        * @param aMessage The current message from the client.
-        */
-        void SetLogOption( const RMessage2& aMessage );
-        
-        /**
-        * Logs the given descriptor through debug channel.
-        * @param aLogString The descriptor to be logged.
-        * @return KErrNone, if successful; KErrNotSupported, if a logging session is not
-        *   ongoing, or the logging mode is not EATLogToTrace;
-        */
-        TInt LogThroughTrace( const TDesC& aLogString ) const;
-        
-        /**
-        * Gives a reference to the allocation info array of this class.
-        * @return A reference to iAllocInfoArray array
-        */
-        RArray<TAllocInfo>& AllocInfoArray();
-               
-        /**
-        * Creates a panic in the associated client's code.
-        * @param aPanic The panic code
-        * @param aMessage The message associated with this panic.
-        */
-        void PanicClient( TInt aPanic, const RMessage2& aMessage );
-        
-        /**
-        * Logs the abnormal end to the debug channel (If logging mode is EATLogToTrace) 
-        * and to the file(If logging mode is EATLogToFile).
-        */
-        void LogAbnormalEnd();
-        
-        /**
-        * Get the current universal time.
-        * @return Time
-        */
-        TInt64 GetTime();
-        
-    private: // Constructors 
-        
-        /**
-        * C++ default constructor.
-        */
-        CATStorageServerSession( CATStorageServer& aStorageServer );
-        
-        /**
-        *  Symbian 2nd phase constructor.
-        */
-        void ConstructL();   
-        
-    private: // Data
-        
-        /** A reference to the CATStorageServer object that has created this session */    
-        CATStorageServer& iStorageServer;
-               
-        /** A handle to a file server */
-        RFs iFileServer;
-        
-        /** A handle to a file */
-        RFile iFile;
-        
-        /** A member variable for storing results of server function calls. */ 
-        TInt iError;
-        
-        /** An object for getting time stamps */ 
-        TTime iTime;
-        
-        /** 
-        * An array for storing CATMemoryEntry pointers. Used when logging
-        * to an S60 file.
-        */
-        RPointerArray<CATMemoryEntry> iLeakArray;
-        
-        /** 
-        * An array for storing TAllocInfo objects. Used for keeping records on memory
-        * allocations and their sizes.
-        */
-        RArray<TAllocInfo> iAllocInfoArray;
-        
-        /** The ID of the process associated with this session. */
-        TUint iProcessId;
-        
-        /**
-        * A boolean telling whether this session has been initialized for logging
-        * ( whether the client's LogProcessStarted() method has been called ) or not.
-        */
-        TBool iLoggingOngoing;
-        
-        /**
-        * A variable telling the number of microseconds from January 1st, 0 AD
-        * nominal Gregorian to January 1st, 1970 AD nominal Gregorian. 
-        */
-        TInt64 iMicroSecondsAt1970;
-        
-        /**
-        * An enumeration that tells the current operation mode of the Storage Server.
-        */
-        TATLogOption iLogOption;
-        
-        /** The total size of all the current allocations of this process */
-        TUint32 iCurAllocSize;
-        
-        /** The maximum number of allocations of this process */
-        TUint32 iMaxAllocs;
-        
-        /** The maximum total size of allocations of this process */
-        TUint32 iMaxAllocSize;
-        
-        /** The logging file of this process */
-        TBuf8<KMaxFileName> iLogFile;
-
-        /** The mode of the session. Default is 1 = UDEB */
-        TUint32 iIsUdeb;
-    };
-
-#endif      // ATSTORAGESERVERSESSION_H
-
-// End of File
--- a/analyzetool/storageserver/server/src/atdllinfo.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-/*
-* 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:  Definitions for the class TATDllInfo.
-*
-*/
-
-// INCLUDE FILES
-#include "atdllinfo.h"
-#include "atlog.h"
-
-// -----------------------------------------------------------------------------
-// TATDllInfo::TATDllInfo
-// C++ default constructor.
-// -----------------------------------------------------------------------------
-//
-TATDllInfo::TATDllInfo( const TUint32 aStartAddress, const TUint32 aEndAddress,
-	const TInt64& aLoadTime, const TDesC8& aDllName  )
- :  iStartAddress( aStartAddress ), iEndAddress( aEndAddress ), 
-	iLoadTime( aLoadTime )
-    {
-    LOGSTR3( "STSE TATDllInfo::TATDllInfo() %x - %x", iStartAddress, iEndAddress );
-    
-    iName.Copy( aDllName );
-    }
-
-// -----------------------------------------------------------------------------
-// TATDllInfo::StartAddress
-// Returns library start address
-// -----------------------------------------------------------------------------
-//
-TUint32 TATDllInfo::StartAddress()
-    {
-    LOGSTR2( "STSE TATDllInfo::StartAddress( %x )", iStartAddress );
-    
-    return iStartAddress;
-    }
-
-// -----------------------------------------------------------------------------
-// TATDllInfo::EndAddress
-// Returns library end address
-// -----------------------------------------------------------------------------
-//
-TUint32 TATDllInfo::EndAddress()
-    {
-    LOGSTR2( "STSE TATDllInfo::EndAddress( %x )", iEndAddress );
-    
-    return iEndAddress;
-    }
-
-// -----------------------------------------------------------------------------
-// TATDllInfo::Name
-// Gets specific library name
-// -----------------------------------------------------------------------------
-//
-TDes8& TATDllInfo::Name()
-    {
-    LOGSTR1( "STSE TATDllInfo::Name()" );
-    
-    return iName;
-    }
-
-// -----------------------------------------------------------------------------
-// TATDllInfo::LibraryLoadTime
-// Returns library load time
-// -----------------------------------------------------------------------------
-//
-TInt64 TATDllInfo::LibraryLoadTime()
-    {
-    LOGSTR1( "STSE TATDllInfo::LibraryLoadTime()" );
-    
-    return iLoadTime;
-    }
-        
-// -----------------------------------------------------------------------------
-// TATDllInfo::Match
-// Checks if two objects of this class match based on the objects's
-// saved library name.
-// -----------------------------------------------------------------------------
-//
-TBool TATDllInfo::Match( const TATDllInfo& aFirst, const TATDllInfo& aSecond )
-    {
-    LOGSTR1( "STSE TATDllInfo::Match()" );
-    
-    if ( aFirst.iName.Compare( aSecond.iName ) == 0 )
-        {
-        return ETrue;
-        }
-    return EFalse;
-    }
-
-// End of File
--- a/analyzetool/storageserver/server/src/atdriveinfo.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-/*
-* 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:  Definitions for the class TATDriveInfo.
-*
-*/
-
-
-
-// INCLUDE FILES
-#include <f32file.h>
-#include <driveinfo.h>
-#include "atdriveinfo.h"
-#include "atstorageservercommon.h"
-#include "atlog.h"
-
-// -----------------------------------------------------------------------------
-// TATDriveInfo::TATDriveInfo
-// C++ default constructor.
-// -----------------------------------------------------------------------------
-//
-TATDriveInfo::TATDriveInfo()
-    {
-    LOGSTR1( "TATD TATDriveInfo::TATDriveInfo()" );
-    }
-
-// -----------------------------------------------------------------------------
-// TATDriveInfo::CreatePath()
-// -----------------------------------------------------------------------------
-//    
-TInt TATDriveInfo::CreatePath( TDes& aPath, 
-    const TDesC& aFileName, RFs& aFs )
-    {
-    LOGSTR1( "TATD TInt TATDriveInfo::CreatePath()" );
-    
-    // Drive letter    
-    TChar driveLetter;
-    // Drive number
-    TInt dNumber( EDriveZ );     
-    TBool found( EFalse );
-    // Drive type
-    TUint driveType( KDriveAttRemovable );    
-    TInt err( KErrNotFound );
-    
-    while ( !found )
-        {
-        // Get drive letter
-        if ( GetDrive( driveLetter, dNumber, aFs, driveType ) == KErrNotFound )
-        	{
-        	if ( driveType == KDriveAttInternal )
-        		{
-                return KErrNotFound;
-        		}       	
-            driveType = KDriveAttInternal;
-        	dNumber = EDriveZ;
-        	}       
-        else
-        	{
-			// Create path
-			aPath.Delete( 0, aPath.MaxLength() );
-			aPath.Append( driveLetter );
-		  
-		            
-		#ifdef __WINS__
-            // For emulator the data file is stored to different location
-            aPath.Append( KATDataFilePath );       
-		#else
-		    TDriveInfo driveInfo;
-		    aFs.Drive( driveInfo, dNumber );      
-            // The drive is removable( memory card ) so we can log inside of root folder
-            if ( driveInfo.iDriveAtt & KDriveAttRemovable )
-                {
-                aPath.Append( KATDataFilePath );       
-                }
-            // The drive is internal user can only access data folder so log into that
-            else
-                {
-                aPath.Append( KATDataFilePath2 );       
-                }
-		#endif
-						
-			// Make a directory for AToolStorageServer's logging data file
-			err = aFs.MkDir( aPath );
-			LOGSTR2( "STSE > aFs.MkDir err = %i", err );
-			
-			if ( !err || err == KErrAlreadyExists )
-				{                
-                if ( aFileName.Length() != 0 && 
-                     ( ( aPath.MaxLength() - aPath.Length() ) > aFileName.Length() ) )
-                    {
-                    aPath.Append( aFileName );
-                    }
-				found = ETrue;
-				}
-        	}
-        }        
-    return err;        
-    }
-
-// -----------------------------------------------------------------------------
-// TATDriveInfo::GetDrive()
-// -----------------------------------------------------------------------------
-//    
-TInt TATDriveInfo::GetDrive( TChar& aDrive, TInt& aDriveNumber, RFs& aFs, 
-	const TUint aDriveType )
-    {
-    LOGSTR1( "TATD TInt TATDriveInfo::GetDrive()" );
-       
-    // Contains drive information.
-    TDriveInfo driveInfo; 
-    
-    for ( TInt i = aDriveNumber; i >= (TInt)EDriveA; i-- )
-        {
-        // Gets information about a drive and the medium mounted on it.
-        // If error occured then skip to next drive.
-        if ( aFs.Drive( driveInfo, i ) != KErrNone )
-            continue;
-                
-        // Test whether drive is available. If not, skip to next drive.
-        if ( driveInfo.iDriveAtt & KDriveAbsent || i == (TInt)EDriveD ||
-             driveInfo.iDriveAtt & KDriveAttRom || 
-             driveInfo.iMediaAtt & KMediaAttWriteProtected ||
-             driveInfo.iDriveAtt & KDriveFileSysROFS )
-            continue;
-        
-        // Maps a drive number to the corresponding character.
-        if ( aFs.DriveToChar( i, aDrive ) != KErrNone )
-            continue;                
-        
-        if ( driveInfo.iDriveAtt & aDriveType &&
-             driveInfo.iType != EMediaNotPresent &&
-             driveInfo.iType != EMediaCdRom )
-            {
-            TUint status( 0 );
-            
-            switch ( aDriveType )
-                {
-                case KDriveAttRemovable:
-                    {
-                    // Get the drive status of the default removable mass storage.                    
-                    if ( DriveInfo::GetDriveStatus( aFs, i, status ) == KErrNone )
-                        {
-                        // To indicate that the drive is physically removable.
-                        if ( status & DriveInfo::EDriveRemovable &&
-                             !( status & DriveInfo::EDriveCorrupt ) )
-                            {
-                            aDriveNumber = --i;
-                            return KErrNone;
-                            }
-                        }
-                    }
-                    break;
-                case KDriveAttInternal:
-                    {
-                    // Get the drive status of the default removable mass storage.
-                    if ( DriveInfo::GetDriveStatus( aFs, i, status ) == KErrNone )
-                        {
-                        // To indicate that the drive is internal and 
-                        // cannot be physically removed.
-                        if ( status & DriveInfo::EDriveInternal &&
-                             !( status & DriveInfo::EDriveExternallyMountable ) )
-                            {
-                            aDriveNumber = --i;
-                            return KErrNone;
-                            }
-                        }
-                    }
-                    break;
-                    
-                default:
-                    break;
-                }
-            }
-        }
-    return KErrNotFound;
-    }
- 
-// End of File
--- a/analyzetool/storageserver/server/src/atdynprocessinfo.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
-* 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:  Definitions for the class CATDynProcessInfo
-*
-*/
-
-
-// INCLUDE FILES
-#include    "atdynprocessinfo.h"
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-
-// -----------------------------------------------------------------------------
-// CATDynProcessInfo::CATDynProcessInfo
-// -----------------------------------------------------------------------------
-//  
-CATDynProcessInfo::CATDynProcessInfo() :
-    iProcessId( KNullProcessId ),
-    iSessionObject( NULL )
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// CATDynProcessInfo::CATDynProcessInfo
-// -----------------------------------------------------------------------------
-//  
-CATDynProcessInfo::CATDynProcessInfo( TUint aProcessId,
-                                      CATStorageServerSession* aSessionObject,
-                                      const RArray<TATDllInfo>& aDlls ) :
-    iProcessId( aProcessId ),
-    iSessionObject( aSessionObject ),
-    iDlls( aDlls )
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// CATDynProcessInfo::CATDynProcessInfo
-// -----------------------------------------------------------------------------
-//  
-CATDynProcessInfo::CATDynProcessInfo( TUint aProcessId,
-                                      CATStorageServerSession* aSessionObject ) :
-    iProcessId( aProcessId ), iSessionObject( aSessionObject )
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// CATDynProcessInfo::CATDynProcessInfo
-// -----------------------------------------------------------------------------
-//  
-CATDynProcessInfo::CATDynProcessInfo( TUint aProcessId ) :
-    iProcessId( aProcessId ), iSessionObject( NULL )
-    {
-    }
-
-// Destructor
-CATDynProcessInfo::~CATDynProcessInfo()
-    {
-    iDlls.Close();
-    }
-
-// -----------------------------------------------------------------------------
-// CATDynProcessInfo::Compare
-// -----------------------------------------------------------------------------
-//  
-TInt CATDynProcessInfo::Compare( const CATDynProcessInfo& aFirst, 
-	const CATDynProcessInfo& aSecond )
-    {
-    if ( aFirst.iProcessId < aSecond.iProcessId )
-        {
-        return -1;
-        }
-    
-    if ( aFirst.iProcessId > aSecond.iProcessId )
-        {
-        return 1;
-        }
-   
-    // else
-    return 0;
-    }
-
-// End of File
--- a/analyzetool/storageserver/server/src/atmemoryentry.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
-* 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:  Definitions for the class CATMemoryEntry
-*
-*/
-
-
-
-// INCLUDE FILES
-#include    "atmemoryentry.h"
-
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-
-// -----------------------------------------------------------------------------
-// CATMemoryEntry::CATMemoryEntry
-// C++ default constructor.
-// -----------------------------------------------------------------------------
-//  
-CATMemoryEntry::CATMemoryEntry( TUint32 aMemAddress,
-                                const CBufFlat* aCallstackBuf,
-                                const TInt64& aAllocTime,
-                                TInt aAllocSize ) :
-    iMemAddress( aMemAddress ),
-    iCallstackBuf( aCallstackBuf ),
-    iAllocTime( aAllocTime ),
-    iAllocSize( aAllocSize )
-    {
-    }
-
-// Destructor
-CATMemoryEntry::~CATMemoryEntry()
-    {
-    delete const_cast<CBufFlat*>( iCallstackBuf );
-    }
-
-// -----------------------------------------------------------------------------
-// CATMemoryEntry::Compare
-// -----------------------------------------------------------------------------
-//  
-TInt CATMemoryEntry::Compare( const CATMemoryEntry& aFirst, const CATMemoryEntry& aSecond )
-    {
-    if ( aFirst.iAllocTime < aSecond.iAllocTime )
-        {
-        return -1;
-        }
-    
-    if ( aFirst.iAllocTime > aSecond.iAllocTime )
-        {
-        return 1;
-        }
-   
-    // else
-    return 0;
-    }
-
-// -----------------------------------------------------------------------------
-// CATMemoryEntry::Match
-// -----------------------------------------------------------------------------
-//
-TBool CATMemoryEntry::Match( const CATMemoryEntry& aFirst, const CATMemoryEntry& aSecond )
-    {
-    if ( aFirst.iMemAddress == aSecond.iMemAddress )
-        {
-        return ETrue;
-        }
-    
-    // else
-    return EFalse;
-    }
-
-
--- a/analyzetool/storageserver/server/src/atstorageserver.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,452 +0,0 @@
-/*
-* 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:  Definitions for the class CATStorageServer. Includes also the
-*                entry point of the atoolstorageserver.exe executable.
-*
-*/
-
-
-
-
-// INCLUDE FILES
-
-#include    "atstorageserver.h"
-#include    "atstorageserversession.h"
-#include    "atstorageservercommon.h"
-#include    "atlog.h"
-#include    "atdynprocessinfo.h"
-
-
-// CONSTANTS
-
-
-// The amount of different ranges of requests specified for this policy server.
-// In a policy server, different actions can be determined for different ranges
-// of requests.
-const TUint8 KAmountOfRanges = 2;
-
-
-const TInt ranges[KAmountOfRanges] =
-    {
-    CATStorageServer::EProcessStarted,
-    CATStorageServer::EOutOfBounds
-    };
-
-
-const TUint8 actionForRange[ KAmountOfRanges ] = 
-    { 0, CPolicyServer::ENotSupported };
-
-
-const CPolicyServer::TPolicyElement elements[] =
-    {
-    
-    { _INIT_SECURITY_POLICY_C1( ECapability_None ),
-          CPolicyServer::EFailClient }
-    
-    };
-
-
-const CPolicyServer::TPolicy policy =
-    {
-    CPolicyServer::EAlwaysPass, // On connect
-    KAmountOfRanges, // Range count
-    ranges,
-    actionForRange,
-    elements,
-    };
-
-
-
-// ENTRY POINT
-
-TInt E32Main()
-    { 
-    LOGSTR1( "STSE TInt E32Main() in ATStorageServer.cpp" );
-    
-    __UHEAP_MARK;
-    
-    // Create a cleanup stack 
-    CTrapCleanup* cleanup = CTrapCleanup::New();
-    
-    TInt errorCode( KErrNoMemory );
-    
-    // If there was enough memory to create a cleanup stack, 
-    // create and start the server.
-    if( cleanup )
-        {
-        // If RunServerL() doesn't leave, errorCode will be set to KErrNone
-        TRAP( errorCode, CATStorageServer::RunServerL() );
-        delete cleanup;
-        }
-
-    // Signal the client that server creation failed, if a leave occured during
-    // the call to 'RunServerL()' function
-    if( errorCode != KErrNone )
-        {
-        RProcess::Rendezvous( errorCode );
-        }
-    
-    __UHEAP_MARKEND;
-       
-    return errorCode;
-    
-    }
-
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CATStorageServer::CATStorageServer
-// C++ default constructor can NOT contain any code that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CATStorageServer::CATStorageServer( TInt aPriority ) :
-    CPolicyServer( aPriority, policy, ESharableSessions ),
-    iSessionCount( 0 )
-    {
-    LOGSTR1( "STSE CATStorageServer::CATStorageServer()" );
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServer::ConstructL
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CATStorageServer::ConstructL()
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServer::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CATStorageServer* CATStorageServer::NewL()
-    {
-    CATStorageServer* self = NewLC();
-    CleanupStack::Pop( self );
-    
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServer::NewLC
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CATStorageServer* CATStorageServer::NewLC()
-    {  
-    CATStorageServer* self = new ( ELeave ) CATStorageServer( EPriorityStandard );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    self->StartL( KStorageServerName );
-    return self;
-    }
-
-// Destructor
-CATStorageServer::~CATStorageServer()
-    {
-    LOGSTR1( "STSE CATStorageServer::~CATStorageServer()" );
-    
-    iProcesses.Close();
-    iProcessesDyn.ResetAndDestroy();
-    iProcessesDyn.Close();
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServer::NewSessionL
-// Create a new server session.
-// -----------------------------------------------------------------------------
-// 
-CSession2* CATStorageServer::NewSessionL(
-    const TVersion &aVersion,
-    const RMessage2& /*aMessage*/ ) const
-    {
-    LOGSTR1( "STSE CSession2* CATStorageServer::NewSessionL()" );
-    
-    // The server's version
-    TVersion version( KVersionNumberMaj, KVersionNumberMin,
-        KVersionNumberBld );
-
-    // Check this is a high enough version of the server
-    if ( !User::QueryVersionSupported(version, aVersion) )
-        {
-        User::Leave( KErrNotSupported );
-        }
-    
-    // Construct and return a new session object
-    return CATStorageServerSession::NewL( const_cast<CATStorageServer&>(*this) );
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServer::RunServerL
-// Create active scheduler and a server object
-// -----------------------------------------------------------------------------
-//    
-void CATStorageServer::RunServerL()
-    {
-    LOGSTR1( "STSE void CATStorageServer::RunServerL()" );
-    
-    // Create and install an active scheduler
-    CActiveScheduler* activeSched = new (ELeave) CActiveScheduler;
-    CleanupStack::PushL( activeSched );
-    CActiveScheduler::Install( activeSched );
-
-    // Create server
-    CATStorageServer::NewLC();
-     
-    // The initialization performed alright, signal the client
-    RProcess::Rendezvous( KErrNone );
-
-    // Start the active scheduler
-    CActiveScheduler::Start();
-
-    // Remove the server and active scheduler from the cleanup stack
-    CleanupStack::PopAndDestroy( 2, activeSched );
-    }
-  
-// -----------------------------------------------------------------------------
-// CATStorageServer::IncSessionCount
-// Increments the count of active sessions for this server.
-// -----------------------------------------------------------------------------
-// 
-void CATStorageServer::IncSessionCount()
-    {
-    LOGSTR1( "STSE void CATStorageServer::IncSessionCount()" );
-    
-    iSessionCount++;
-    }
-    
-// -----------------------------------------------------------------------------
-// CATStorageServer::DecSessionCount
-// Decrements the count of active sessions for this server.
-// -----------------------------------------------------------------------------
-// 
-void CATStorageServer::DecSessionCount()
-    {
-    LOGSTR1( "STSE void CATStorageServer::DecSessionCount()" );
-       
-    iSessionCount--;
-    
-    // Cancels all outstanding messages and stops the active scheduler,
-    // if there are no other sessions open at the moment
-    if ( iSessionCount <= 0 )
-        {
-        this->Cancel();
-        CActiveScheduler::Stop();
-        }
-    }
-  
-// -----------------------------------------------------------------------------
-// CATStorageServer::AddProcessL
-// -----------------------------------------------------------------------------
-// 
-TInt CATStorageServer::AddProcessL( const TDesC8& aProcessName,
-                                   TUint aProcessId,
-                                   CATStorageServerSession* aSessionObject,
-                                   const TInt64& aStartTime )
-    {
-    LOGSTR1( "STSE TInt CATStorageServer::AddProcessL()" );
-
-    TInt error( KErrNone );
-    TATProcessInfo processInfo;
-    
-    processInfo.iProcessId = aProcessId;
-    processInfo.iProcessName.Copy( aProcessName );
-    processInfo.iStartTime = aStartTime;
-    
-    // Insert the static process info into the iProcesses array
-    error = iProcesses.InsertInUnsignedKeyOrder( processInfo );
-    
-    // Return if an error occured
-    if ( error != KErrNone)
-        {
-        return error;
-        }
-    
-    // Construct a CATDynProcessInfo object with the given process ID and logging mode
-    CATDynProcessInfo* dynProcessInfo = 
-                            new (ELeave) CATDynProcessInfo( aProcessId,
-                                                            aSessionObject );
-    
-    // Insert the dynamic process info into the iProcessesDyn array
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    error = iProcessesDyn.InsertInOrder( dynProcessInfo, order );
-    
-    return error;
-    }
-    
-// -----------------------------------------------------------------------------
-// CATStorageServer::RemoveProcessL
-// -----------------------------------------------------------------------------
-// 
-TInt CATStorageServer::RemoveProcessL( TUint aProcessId )
-    {
-    LOGSTR1( "STSE TInt CATStorageServer::RemoveProcessL()" );
-    
-    TATProcessInfo processInfo;
-    processInfo.iProcessId = aProcessId;
-    
-    TInt index = iProcesses.FindInUnsignedKeyOrder( processInfo );
-
-    // Return, if a process with the requested process ID was not found
-    if ( index == KErrNotFound )
-        {
-        return index; 
-        }
-     
-    // Remove the TATProcessInfo object at "index" from the array
-    iProcesses.Remove( index );
-     
-    // Now, start removing the associated dynamic process info object
-
-    // Construct a CATDynProcessInfo object with the given process ID
-    CATDynProcessInfo* dynProcessInfo = 
-                            new (ELeave) CATDynProcessInfo( aProcessId );
-    
-    // Find the index of a CATDynProcessInfo object with the given ID in the array
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    index = iProcessesDyn.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-     
-    // Return, if a process with the requested process ID was not found
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-     
-    // Otherwise, delete the object and remove the pointer at "index"
-    delete iProcessesDyn[index];
-    iProcessesDyn.Remove( index ); 
-     
-    return KErrNone;   
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServer::AddDllL
-// -----------------------------------------------------------------------------
-// 
-TInt CATStorageServer::AddDllL( TUint aProcessId, 
-    const TATDllInfo aDllInfo )
-    {
-    LOGSTR1( "STSE TInt CATStorageServer::AddDllL()" );
- 
-    // Construct a CATDynProcessInfo object with the given process ID
-    CATDynProcessInfo* dynProcessInfo = 
-		new (ELeave) CATDynProcessInfo( aProcessId );
-  
-    // Find out if a process with this ID can be found in the dynamic process array
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    TInt index = iProcessesDyn.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-     
-    // Return, if a process with the requested process ID was not found 
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-        
-    // If we are here, the wanted process was found at index => append a DLL for it
-    dynProcessInfo = iProcessesDyn[index];
-    
-    // Get the DLL array from this dynamic process info object
-    RArray<TATDllInfo>& dllArray = dynProcessInfo->iDlls;    
-    
-    // Let's see if the DLL to be added already exists
-    TIdentityRelation<TATDllInfo> matcher( TATDllInfo::Match );
-    index = dllArray.Find( aDllInfo, matcher );
-    
-    // If so, return KErrAlreadyExists
-    if ( index != KErrNotFound )
-        {
-        return KErrAlreadyExists;
-        }
-
-    // Otherwise append this DLL to the array and return 
-    return dynProcessInfo->iDlls.Append( aDllInfo );
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServer::RemoveDllL
-// -----------------------------------------------------------------------------
-// 
-TInt CATStorageServer::RemoveDllL( TUint aProcessId,
-                                  const TDesC8& aDllName )
-    {
-    LOGSTR1( "STSE TInt CATStorageServer::RemoveDllL()" );
-
-    // Construct a CATDynProcessInfo object with the given process ID
-    CATDynProcessInfo* dynProcessInfo = 
-		new (ELeave) CATDynProcessInfo( aProcessId );
-  
-    // Find out if a process with this ID can be found in the dynamic process array
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    TInt index = iProcessesDyn.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-     
-    // Return, if a process with the requested process ID was not found 
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-        
-    // If we are here, the wanted process was found at index
-    dynProcessInfo = iProcessesDyn[index];
-
-    // Get the DLL array from this dynamic process info object
-    RArray<TATDllInfo>& dllArray = dynProcessInfo->iDlls;
-    
-    // Try to find wanted DLL
-    TIdentityRelation<TATDllInfo> matcher( TATDllInfo::Match );    
-    index = dllArray.Find( TATDllInfo( 0, 0, 0, aDllName  ), matcher );
-    
-    // Return, if a process with the requested process ID was not found 
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-        
-    // Otherwise remove the found DLL at "index"
-    dllArray.Remove( index );    
-        
-    return KErrNone;  
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServer::ProcessInfoArray
-// -----------------------------------------------------------------------------
-// 
-const RArray<TATProcessInfo>& CATStorageServer::ProcessInfoArray()
-    {
-    LOGSTR1( "STSE RArray<TATProcessInfo>& CATStorageServer::ProcessInfoArray()" );
-     
-    return iProcesses;   
-    }
-    
-// -----------------------------------------------------------------------------
-// CATStorageServer::DynProcessInfoArray
-// -----------------------------------------------------------------------------
-// 
-const RPointerArray<CATDynProcessInfo>& CATStorageServer::DynProcessInfoArray()
-    {
-    LOGSTR1( "STSE RPointerArray<CATDynProcessInfo>& CATStorageServer::DynProcessInfoArray()" );
-     
-    return iProcessesDyn;   
-    }    
-    
-//  End of File
--- a/analyzetool/storageserver/server/src/atstorageserversession.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3397 +0,0 @@
-/*
-* 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:  Definitions and constants for the class CATStorageServerSession
-*
-*/
-
-
-
-// INCLUDE FILES
-#include    <utf.h>
-#include    <analyzetool/analyzetooltraceconstants.h>
-#include    "atstorageserversession.h"
-#include    "atstorageserver.h"
-#include    "atstorageservercommon.h"
-#include    "atmemoryentry.h"
-#include    "atlog.h"
-#include    "atdynprocessinfo.h"
-#include    "atdriveinfo.h"
-
-// CONSTANTS
-
-// New file name start and end index.
-const TInt KNameIndexStart = 1;
-const TInt KNameIndexEnd = 100;
-
-// ==================== MEMBER FUNCTIONS for TAllocInfo ========================
-
-// -----------------------------------------------------------------------------
-// TAllocInfo::TAllocInfo
-// Implementation for the constructor of the class TAllocInfo
-// -----------------------------------------------------------------------------
-//
-TAllocInfo::TAllocInfo( TUint32 aMemAddress, TInt aAllocSize ) :
-    iMemAddress( aMemAddress ),
-    iAllocSize( aAllocSize )
-    {
-    }
-
-
-// ============== MEMBER FUNCTIONS for CATStorageServerSession =================
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::CATStorageServerSession
-// C++ default constructor. It Does not contain any code that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CATStorageServerSession::CATStorageServerSession( CATStorageServer& aStorageServer ) :
-    iStorageServer( aStorageServer ),
-    iError( 0 ),
-    iLeakArray( KLeakArrayGranularity ),
-    iProcessId( KNullProcessId ),
-    iLoggingOngoing( EFalse ),
-    iLogOption( KDefaultLoggingMode ),
-    iCurAllocSize( 0 ),
-    iMaxAllocs( 0 ),
-    iMaxAllocSize( 0 ),
-    iLogFile( KEmpty() ),
-    iIsUdeb( 1 )
-    {
-    LOGSTR1( "STSE CATStorageServerSession::CATStorageServerSession()" );
-    
-    // Initialize iMicroSecondsAt1970
-    TTime time( KJanuaryFirst1970 );
-    iMicroSecondsAt1970 = time.Int64();
-    
-    // Increment the server's session count by one (1)
-    iStorageServer.IncSessionCount();
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::ConstructL
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CATStorageServerSession::ConstructL()
-    {
-    // Intentionally left empty
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CATStorageServerSession* CATStorageServerSession::NewL( CATStorageServer& aStorageServer )
-    { 
-    CATStorageServerSession* self = NewLC( aStorageServer );
-    CleanupStack::Pop( self );
-    
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::NewLC
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CATStorageServerSession* CATStorageServerSession::NewLC( CATStorageServer& aStorageServer )
-    { 
-    CATStorageServerSession* self = new ( ELeave ) CATStorageServerSession( aStorageServer );
-    
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::~CATStorageServerSession
-// Destructor
-// -----------------------------------------------------------------------------
-CATStorageServerSession::~CATStorageServerSession()
-    {
-    LOGSTR1( "STSE CATStorageServerSession::~CATStorageServerSession()" );
-      
-    // Empty the array and delete the referenced objects
-    iLeakArray.ResetAndDestroy();
-  
-    // Close the leak array
-    iLeakArray.Close();
-    
-    // Close the allocation info array
-    iAllocInfoArray.Close();
-    
-    // Check if process closed abnormal
-    if ( iProcessId != KNullProcessId && 
-         iLoggingOngoing && iLogOption != EATLoggingOff && 
-         iError != KErrNoMemory )
-        {
-        LogAbnormalEnd();
-        }
-    
-    // Close the file and the handle to the file server
-    CloseFsAndFile();
-    
-    // Remove the process with the current PID from the server's array of processes
-    TRAP_IGNORE( iStorageServer.RemoveProcessL( iProcessId ) );
-    
-    // Decrement the server's session count by one (1)
-    iStorageServer.DecSessionCount();
-    }
-    
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::ServiceL
-// This function is called by the client/server framework
-// -----------------------------------------------------------------------------
-//
-void CATStorageServerSession::ServiceL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE void CATStorageServerSession::ServiceL()" );
-    
-    // If logging has been cancelled for this session, return immediately
-    if( iLogOption == EATLoggingOff )
-        {
-        aMessage.Complete( KErrCancel );
-        return;
-        }
-    
-    switch ( aMessage.Function() )
-        {
-        case CATStorageServer::EProcessStarted:
-            {
-            // If logging is not ongoing, set the log option
-            if( !iLoggingOngoing )
-                {
-                // Set the operation mode
-                SetLogOption( aMessage );
-                }
-
-            switch ( iLogOption )
-                {
-                case EATLogToTrace:
-                    {
-                    iError = LogProcessStartTraceL( aMessage );
-                    }
-                break;
-                
-                case EATLogToFile:
-                    {
-                    iError = LogProcessStartedL( aMessage );
-                    }
-                break;
-                
-                default:
-                    {
-                    // Panic the client and set iError KErrCancel, because being
-                    // here implies that an illegal log option has been given.
-                    PanicClient( EAToolIllegalLogOption, aMessage );
-                    iError = KErrCancel;
-                    }
-                break;
-                }
-            } 
-        break;
-        
-        
-        case CATStorageServer::EDllLoaded:
-            {
-            switch ( iLogOption )
-                {
-                case EATLogToTrace:
-                    {
-                    iError = LogDllLoadTraceL( aMessage );
-                    }
-                break;
-                
-                case EATLogToFile:
-                    {
-                    iError = LogDllLoadedL( aMessage );
-                    }
-                break;
-                
-                default:
-                    {
-                    // Panic the client and set iError KErrCancel, because being
-                    // here implies that an illegal log option has been given.
-                    PanicClient( EAToolIllegalLogOption, aMessage );
-                    iError = KErrCancel;
-                    }
-                break;
-                }
-            }
-        break;
-        
-        
-        case CATStorageServer::EDllUnloaded:
-            {
-            switch ( iLogOption )
-                {
-                case EATLogToTrace:
-                    {
-                    iError = LogDllUnloadTraceL( aMessage );
-                    }
-                break;
-                
-                case EATLogToFile:
-                    {
-                    iError = LogDllUnloadedL( aMessage );
-                    }
-                break;
-                
-                default:
-                    {
-                    // Panic the client and set iError KErrCancel, because being
-                    // here implies that an illegal log option has been given.
-                    PanicClient( EAToolIllegalLogOption, aMessage );
-                    iError = KErrCancel;
-                    }
-                break;
-                }
-            }
-        break;
-        
-        
-        case CATStorageServer::EMemoryAllocated:
-            {
-            switch ( iLogOption )
-                {
-                case EATLogToTrace:
-                    {
-                    iError = LogMemoryAllocTraceL( aMessage );
-                    }
-                break;
-                
-                case EATLogToFile:
-                    {
-                    iError = LogMemoryAllocatedL( aMessage );
-                    }
-                break;
-                
-                default:
-                    {
-                    // Panic the client and set iError KErrCancel, because being
-                    // here implies that an illegal log option has been given.
-                    PanicClient( EAToolIllegalLogOption, aMessage );
-                    iError = KErrCancel;
-                    }
-                break;
-                }
-            }
-        break;
-        
-        
-        case CATStorageServer::EMemoryFreed:
-            {
-            switch ( iLogOption )
-                {
-                case EATLogToTrace:
-                    {
-                    iError = LogMemoryFreedTraceL( aMessage );
-                    }
-                break;
-                
-                case EATLogToFile:
-                    {
-                    iError = LogMemoryFreedL( aMessage );
-                    }
-                break;
-                
-                default:
-                    {
-                    // Panic the client and set iError KErrCancel, because being
-                    // here implies that an illegal log option has been given.
-                    PanicClient( EAToolIllegalLogOption, aMessage );
-                    iError = KErrCancel;
-                    }
-                break;
-                }
-            }
-        break;
-        
-        
-        case CATStorageServer::EProcessEnded:
-            {
-            switch ( iLogOption )
-                {
-                case EATLogToTrace:
-                    {
-                    iError = LogProcessEndTraceL( aMessage );
-                    }
-                break;
-                
-                case EATLogToFile:
-                    {
-                    iError = LogProcessEndedL( aMessage );
-                    }
-                break;
-                
-                default:
-                    {
-                    // Panic the client and set iError KErrCancel, because being
-                    // here implies that an illegal log option has been given.
-                    PanicClient( EAToolIllegalLogOption, aMessage );
-                    iError = KErrCancel;
-                    }
-                break;
-                }
-            }
-        break;
-        
-        
-        case CATStorageServer::EMemoryCheck:
-            {
-            switch ( iLogOption )
-                {
-                case EATLogToTrace:
-                    {
-                    iError = CheckMemoryAddressTrace( aMessage );
-                    }
-                break;
-                
-                case EATLogToFile:
-                    {
-                    iError = CheckMemoryAddressL( aMessage );
-                    }
-                break;
-                
-                default:
-                    {
-                    // Panic the client and set iError KErrCancel, because being
-                    // here implies that an illegal log option has been given.
-                    PanicClient( EAToolIllegalLogOption, aMessage );
-                    iError = KErrCancel;
-                    }
-                break;
-                }
-            }
-        break;
-        
-        
-        case CATStorageServer::EGetProcesses:
-            {
-            iError = GetProcessesL( aMessage );
-            }
-        break;
-        
-        
-        case CATStorageServer::EGetDlls:
-            {
-            iError = GetDllsL( aMessage );
-            }
-        break;
-        
-        case CATStorageServer::EGetLoggingMode:
-            {
-            iError = GetLoggingModeL( aMessage );
-            }
-        break;
-        
-        case CATStorageServer::ESubtestStart:
-            {
-            iError = StartSubtestL( aMessage );
-            }
-        break;
-        
-        case CATStorageServer::ESubtestStop:
-            {
-            iError = StopSubtestL( aMessage );
-            }
-        break;
-        
-        case CATStorageServer::ESubtestStart2:
-            {
-            iError = StartSubtest2L( aMessage );
-            }
-        break;
-               
-        case CATStorageServer::ESubtestStop2:
-            {
-            iError = StopSubtest2( aMessage );
-            }
-        break;
-        
-        case CATStorageServer::EGetCurrentAllocs:
-            {
-            iError = GetCurrentAllocsL( aMessage );
-            }
-        break;
-        
-        case CATStorageServer::EGetMaxAllocs:
-            {
-            iError = GetMaxAllocsL( aMessage );
-            }
-        break;
-        
-        case CATStorageServer::ECancelLogging:
-            {
-            iError = CancelLoggingL( aMessage );
-            }
-        break;
-
-        case CATStorageServer::EGetUdeb:
-            {
-            iError = GetUdebL( aMessage );
-            }
-        break;
-        
-        case CATStorageServer::EGetLoggingFile:
-            {
-            iError = GetLoggingFileL( aMessage );
-            }
-        break;
-
-        case CATStorageServer::EProcessUdeb:
-            {
-            SetUdeb( aMessage );
-            }
-        break;
-        
-        case CATStorageServer::EIsMemoryAdded:
-            {
-            iError = IsMemoryAdded( aMessage );
-            LOGSTR2( "STSE > IsMemoryAdded err = %i", iError );
-            }
-        break;       
-        
-        default:
-            {
-            // Panic both the client and server, because being here implies
-            // that there is an internal error in the client/server.
-            PanicClient( EAToolBadRequest, aMessage );
-            StorageServerPanic( KCategoryServer, EAToolBadRequest );
-            }
-        break;
-            
-        }
-    
-    // Complete the message, if it has not been already cancelled.
-    if ( iError != KErrCancel )
-        {
-        // Log the error code. Only KErrNoMemory errors are logged.
-        if ( iLogOption == EATLogToFile && iError == KErrNoMemory  )
-            {
-            HandleError( iError );
-            }
-        else if ( iLogOption == EATLogToTrace && iError == KErrNoMemory )
-            {
-            HandleErrorTrace( iError );
-            }
-               
-        // Complete serving the message 
-        aMessage.Complete( iError );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogProcessStartedL()
-// Opens a logging file with the requested name and then writes information
-// on process start into the file.
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::LogProcessStartedL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogProcessStartedL()" );
-    
-    // Panic the client and return, if this method has already been called for this
-    // session object (and a logging file has been opened)
-    if ( iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    iError = KErrNone;
-    
-    LOGMEM;
-    
-    // READ THE FIRST ARGUMENT (descriptor)  
-    
-    // Length of the first argument (index 0)
-    TInt length = aMessage.GetDesLength( 0 );
-    
-    LOGSTR2( "STSE length of the fileName: %i", length );
-    
-    // Return if errors
-    if ( length == KErrArgument || length == KErrBadDescriptor )
-        {
-        return length;
-        }
-    
-    // Construct a buffer for file name, and leave the pointer on Cleanup Stack
-    HBufC* fileName = HBufC::NewLC( length );
-    TPtr fileNamePtr( fileName->Des() );
-     
-    // Read the client side's descriptor at index 0
-    iError = aMessage.Read( 0, fileNamePtr );
-    
-    if ( iError != KErrNone )
-        {
-        CleanupStack::PopAndDestroy( fileName );
-        return iError;
-        }
-    
-    // READ THE SECOND ARGUMENT (descriptor)  
-    
-    // Length of the second argument (index 1)   
-    length = aMessage.GetDesLength( 1 );
-    
-    LOGSTR2( "STSE length of the processName: %i", length );
-    
-    // Return if errors
-    if ( length == KErrArgument || length == KErrBadDescriptor )
-        {
-        CleanupStack::PopAndDestroy( fileName );
-        return length;
-        }
-    
-    HBufC8* processName = HBufC8::NewL( length );
-    TPtr8 bufPtr( processName->Des() );
-
-    // Read the client side's descriptor at index 1 
-    iError = aMessage.Read( 1, bufPtr );
-  
-    if ( iError != KErrNone )
-        {
-        delete processName;
-        CleanupStack::PopAndDestroy( fileName );
-        return iError;
-        }
-    
-    // READ THE THIRD ARGUMENT (integer, a process ID)    
-    TInt processId = aMessage.Int2();
-    
-    // Open a file server session and a file. The file
-    // will be opened with the name received from the client
-    iError = OpenFsAndFile( *fileName, *processName );
-    CleanupStack::PopAndDestroy( fileName );
-    // Return without logging, if an error occured
-    if ( iError != KErrNone )
-        {
-        // Delete the local objects
-        delete processName;
-        return iError;
-        }
-    
-    // Get the home time for the configuration UI
-    iTime.HomeTime();
-    
-    // Add the process into the server's array of processes
-    iError = iStorageServer.AddProcessL( *processName,
-                                        processId,
-                                        this,
-                                        iTime.Int64() );
-
-    // Return without logging, if an error occured
-    if ( iError )
-        {
-        // Remove, if something was added regardless of the error
-        // However, we must not remove an existing process
-        if ( iError != KErrAlreadyExists )
-            {
-            iStorageServer.RemoveProcessL( processId );
-            }
-        return iError;
-        }
-      
-    // Make a buffer that will be logged into the opened logging file
-    TBuf8<KProcessStartBufLength> loggingBuf;
-    loggingBuf.Format( KProcessStart, processName, processId );
-    
-    delete processName;
-    
-    // Get the current universal time       
-    TInt64 timeFrom1970( GetTime() );
-    
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format
-    loggingBuf.AppendNum( timeFrom1970, EHex );
-    
-    // Append udeb/urel information to the process start
-    loggingBuf.Append( KSpace );  
-    loggingBuf.AppendNum( iIsUdeb, EHex );
-    
-    // Append trace version information
-    loggingBuf.Append( KSpace );
-    loggingBuf.AppendNum( KATTraceVersion, EHex );
-    
-    // Append a new line
-    loggingBuf.Append( KNewLine );
-    
-    // Write the buffer into the file  
-    iError = iFile.Write( loggingBuf );
-    
-    // Return, if an error occured
-    if ( iError )
-        {
-        iStorageServer.RemoveProcessL( processId );
-        return iError;
-        }
-    
-    LOGMEM;
-    
-    // Set the process ID value for this logging session
-    iProcessId = processId;
-    // Set logging session started
-    iLoggingOngoing = ETrue;
-    
-    return iError;
-    }
-    
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogProcessStartTraceL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::LogProcessStartTraceL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogProcessStartTraceL()" );
-    
-    // Panic the client and return, if this method has already been called for this
-    // session object
-    if ( iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    iError = KErrNone;
-    
-    LOGMEM;
-    
-    // READ THE SECOND ARGUMENT (descriptor)
-    // The first argument, file name, is ignored when logging thru trace  
-    
-    // Length of the second argument (index 1)
-    TInt length = aMessage.GetDesLength( 1 );
-    
-    LOGSTR2( "STSE length of the processName: %i", length );
-
-    // Return if errors
-    if ( length == KErrArgument || length == KErrBadDescriptor )
-        {
-        return length;
-        }
-
-    HBufC8* processName = HBufC8::NewL( length );
-    TPtr8 bufPtr( processName->Des() );
-
-    // Read the client side's descriptor at index 1 
-    iError = aMessage.Read( 1, bufPtr );
-  
-    if ( iError != KErrNone )
-        {
-        // Delete local objects and return
-        delete processName;
-        return iError;
-        }
-    
-    // READ THE THIRD ARGUMENT (integer, a process ID)    
-    TInt processId = aMessage.Int2();
-
-    // Get the home time for the configuration UI
-    iTime.HomeTime();
-    
-    // Add the process into the server's array of processes
-    iError = iStorageServer.AddProcessL( *processName, processId, this,
-                                             iTime.Int64() );
-    
-    // Return without logging, if an error occured
-    if ( iError )
-        {
-        // Remove, if something was added regardless of the error
-        // However, we must not remove an existing process
-        if ( iError != KErrAlreadyExists )
-            {
-            iStorageServer.RemoveProcessL( processId );
-            }
-        return iError;
-        }
-
-    // Make a buffer that will be logged
-    TBuf8<KProcessStartBufLength> loggingBuf;
-    
-    loggingBuf.Format( KProcessStart, processName, processId );
-    
-    delete processName;
-    
-    // Get the current universal time      
-    TInt64 timeFrom1970( GetTime() );
-    
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format
-    loggingBuf.AppendNum( timeFrom1970, EHex );
-    
-    // Append udeb/urel information to the process start
-    loggingBuf.Append( KSpace );
-    loggingBuf.AppendNum( iIsUdeb, EHex );
-    
-    // Append version number
-    loggingBuf.Append( KSpace );  
-    loggingBuf.AppendNum( KATTraceVersion, EHex );
-    
-    // Append a new line
-    loggingBuf.Append( KNewLine );
-    
-    // Log to trace
-    TBuf<KProcessStartBufLength> traceBuf;
-    traceBuf.Copy( loggingBuf );
-    RDebug::Print( KTraceMessage, processId ,&traceBuf );
-    
-    LOGMEM;
-    
-    // Set the process ID value for this logging session
-    iProcessId = processId;
-    // Set logging session started
-    iLoggingOngoing = ETrue;
-    
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogDllLoadedL()
-// Logs to the file opened by the function LogProcessStartedL()
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::LogDllLoadedL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogDllLoadedL()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    iError = KErrNone;
-    
-    // Read the length of the first argument (index 0)   
-    TInt length = aMessage.GetDesLength( 0 );
-    
-    // Return if errors
-    if ( length == KErrArgument || length == KErrBadDescriptor )
-        {
-        return length;
-        }
-    
-    HBufC8* dllName = HBufC8::NewL( length );
-    TPtr8 bufPtr( dllName->Des() );
-
-    // Read the client side's descriptor (the argument 0) 
-    iError = aMessage.Read( 0, bufPtr );
-  
-    if ( iError != KErrNone )
-        {
-        delete dllName;
-        return iError;
-        }
-    
-    // Get the current universal time
-	TInt64 timeFrom1970( GetTime() );
-        
-    // Add this dll into the server's array
-    TUint32 startAddress( aMessage.Int1() );        
-    TUint32 endAddress( aMessage.Int2() );
-    iError = iStorageServer.AddDllL( iProcessId, 
-    		TATDllInfo( startAddress, endAddress, timeFrom1970, *dllName ) );
-    
-    // Return without logging, if an error occured
-    if ( iError )
-        {
-        delete dllName;
-        return iError;
-        }
-    
-    // Make a buffer that will be logged into the opened logging file
-    TBuf8<KDllLoadBufLength> loggingBuf;
-    loggingBuf.Format( KDllLoad, dllName, timeFrom1970, startAddress, endAddress );
-    
-    delete dllName;
-    
-    // Write the buffer into a file and return the error code   
-    return iFile.Write( loggingBuf );
-    }
-    
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogDllLoadTraceL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::LogDllLoadTraceL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogDllLoadTraceL()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    iError = KErrNone;
-    
-    // Read the length of the first argument (index 0)
-    TInt length = aMessage.GetDesLength( 0 );
-    
-    // Return if errors
-    if ( length == KErrArgument || length == KErrBadDescriptor )
-        {
-        return length;
-        }
-    
-    HBufC8* dllName = HBufC8::NewL( length );
-    TPtr8 bufPtr( dllName->Des() );
-
-    // Read the client side's descriptor (the argument 0) 
-    iError = aMessage.Read( 0, bufPtr );
-  
-    if ( iError != KErrNone )
-        {
-        delete dllName;
-        return iError;
-        }
-    // Get the current universal time
-	TInt64 timeFrom1970( GetTime() );
-    	
-    TUint32 startAddress( aMessage.Int1() );
-    TUint32 endAddress( aMessage.Int2() );
-        
-    // Add this dll into the server's array 
-    iError = iStorageServer.AddDllL( iProcessId, 
-    		TATDllInfo( startAddress, endAddress, timeFrom1970, *dllName ) );
-    
-    // Return without logging, if an error occured
-    if ( iError )
-        {
-        delete dllName;
-        return iError;
-        }
-    
-    // Make a buffer that will be logged
-    TBuf8<KDllLoadBufLength> loggingBuf;
-    loggingBuf.Format( KDllLoad, dllName, timeFrom1970, startAddress, endAddress );
-    
-    delete dllName;
-    
-    TBuf<KDllLoadBufLength> traceBuf;
-    traceBuf.Copy( loggingBuf );
-    RDebug::Print( KTraceMessage, iProcessId ,&traceBuf );
-    return iError;
-    }
-    
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogDllUnloadedL()
-// Logs to the file opened by the function LogProcessStartedL()
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::LogDllUnloadedL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogDllUnloadedL()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    iError = KErrNone;
-    
-    // Read the length of the first argument (index 0)   
-    TInt length = aMessage.GetDesLength( 0 );
-    
-    LOGSTR2( "STSE length %i", length );
-    
-    // Return if errors
-    if ( length == KErrArgument || length == KErrBadDescriptor )
-        {
-        return length;
-        }
-    
-    HBufC8* dllName = HBufC8::NewL( length );
-    TPtr8 bufPtr( dllName->Des() );
-
-    // Read the client side's descriptor (the argument 0) 
-    iError = aMessage.Read( 0, bufPtr );
-  
-    if ( iError != KErrNone )
-        {
-        delete dllName;
-        return iError;
-        }
-       
-    TUint32 startAddress = aMessage.Int1();
-    TUint32 endAddress = aMessage.Int2();
-    
-    // Get the current universal time
-    TInt64 timeFrom1970( GetTime() );
-        
-    // Make a buffer that will be logged into the opened logging file
-    TBuf8<KDllUnloadBufLength> loggingBuf;
-    loggingBuf.Format( KDllUnload, dllName, timeFrom1970, startAddress, endAddress );
-    
-    // Remove this dll from the server's array
-    iError = iStorageServer.RemoveDllL( iProcessId, bufPtr );
-    
-    delete dllName;
-    
-    // Return without logging, if an error occured
-    if ( iError )
-        {
-        return iError;
-        }
-     
-    // Write the buffer into a file and return the error code   
-    return iFile.Write( loggingBuf );
-    }
- 
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogDllUnloadTraceL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::LogDllUnloadTraceL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogDllUnloadTraceL()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-        
-    iError = KErrNone;
-    
-    // Read the length of the first argument (index 0)   
-    TInt length = aMessage.GetDesLength( 0 );
-    
-    LOGSTR2( "STSE length %i", length );
-    
-    // Return if errors
-    if ( length == KErrArgument || length == KErrBadDescriptor )
-        {
-        return length;
-        }
-    
-    HBufC8* dllName = HBufC8::NewL( length );
-    TPtr8 bufPtr( dllName->Des() );
-
-    // Read the client side's descriptor (the argument 0) 
-    iError = aMessage.Read( 0, bufPtr );
-  
-    if ( iError != KErrNone )
-        {
-        delete dllName;
-        return iError;
-        }
-    
-    TUint32 startAddress = aMessage.Int1();
-    TUint32 endAddress = aMessage.Int2();
-    
-    // Get the current universal time
-    TInt64 timeFrom1970( GetTime() );
-        
-    // Make a buffer that will be logged
-    TBuf8<KDllUnloadBufLength> loggingBuf;
-    loggingBuf.Format( KDllUnload, dllName, timeFrom1970, startAddress, endAddress );
-    
-    // Remove this dll from the server's array
-    iError = iStorageServer.RemoveDllL( iProcessId, bufPtr );
-    
-    delete dllName;
-    
-    // Return without logging, if an error occured
-    if ( iError )
-        {
-        return iError;
-        }
-    
-    TBuf<KDllLoadBufLength> traceBuf;
-    traceBuf.Copy( loggingBuf );
-    RDebug::Print( KTraceMessage, iProcessId ,&traceBuf );
-    return iError;
-    }
-    
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogMemoryAllocatedL()
-// Constructs a CATMemoryEntry object and appends it into iLeakArray.
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::LogMemoryAllocatedL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogMemoryAllocatedL()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }     
-    
-    // A pointer to a buffer of call stack's memory addresses
-    CBufFlat* stackBuf = NULL;
-    
-    iError = KErrNone;
-    
-    // Get the current universal time
-    TInt64 timeFrom1970( GetTime() );
-    
-    // Read the first argument (index 0)
-    TUint32 memAddress = aMessage.Int0();
-    if ( memAddress == 0 )
-        {
-        return KErrNotSupported;
-        }
-    
-    // Read the length of the descriptor argument (index 1) that should include
-    // call stack memory addresses associated with this memory allocation
-    TInt bufferLength = aMessage.GetDesLength( 1 );
-    
-    // Construct a buffer for aCallstack
-    stackBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( stackBuf );
-    
-    // Buffer position
-    TInt pos = 0;
-    
-    stackBuf->ExpandL( pos, bufferLength );
-
-    TPtr8 bufPtr = stackBuf->Ptr( pos );
-
-    // Read the descriptor argument into the buffer
-    aMessage.ReadL( 1, bufPtr );
-
-    // Read the third argument (index 2) that tells the size of this allocation
-    TInt size = aMessage.Int2();
-    
-    // Construct a new CATMemoryEntry object.   
-    // The ownership of the current stackBuf object is given to the "entry" object.
-    CATMemoryEntry* entry = 
-        new (ELeave) CATMemoryEntry( memAddress, stackBuf, timeFrom1970, size );
-    
-    // Pop stackBuf from CleanupStack and set it to NULL, because it is not used anymore.
-    CleanupStack::Pop( stackBuf );
-    stackBuf = NULL;
-    
-    // Make sure that the same memory area is not tryed to be allocated a second time
-    TIdentityRelation<CATMemoryEntry> matcher( CATMemoryEntry::Match );
-
-    TInt index = iLeakArray.Find( entry, matcher );
-    
-    if ( index == KErrNotFound )
-        {
-        TLinearOrder<CATMemoryEntry> order( CATMemoryEntry::Compare );
-        
-        // Insert the "entry" object into "iLeakArray". The ownership of
-        // the "entry" object is given to the array.
-        iError = iLeakArray.InsertInOrderAllowRepeats( entry, order );
-               
-        // If an insertion to the array was not successful, delete the created
-        // entry manually and return.
-        if ( iError )
-            {
-            delete entry;
-            return iError;
-            }
-        
-        // Make a TAllocInfo object, and give values for its members.
-        TAllocInfo allocInfo( memAddress, size );
-
-        // Insert the allocInfo object into iAllocInfoArray
-        iError = iAllocInfoArray.InsertInUnsignedKeyOrder( allocInfo );
-    
-        // If an insertion to the array was not successful, delete the created entry
-        // and remove its pointer from iLeakArray.
-        if ( iError )
-            {
-            index = iLeakArray.Find( entry, matcher );
-            // Delete the entry object and remove remove the pointer from the array
-            delete entry;
-            // The index should be in a legal range, because the earlier insertion of
-            // the entry was successful
-            iLeakArray.Remove( index );
-            }
-        
-        // Otherwise update the iCurAllocSize, iMaxAllocs and iMaxAllocSize variables
-        
-        iCurAllocSize += size;
-        
-        // The count can never be negative => associate it to an unsigned int
-        TUint allocCount = iAllocInfoArray.Count();
-        if ( allocCount > iMaxAllocs )
-            {
-            iMaxAllocs = allocCount;
-            }
-        
-        if ( iCurAllocSize > iMaxAllocSize )
-            {
-            iMaxAllocSize = iCurAllocSize;
-            }
-        
-        return iError;
-        }
-        
-    // This shouldn't happen, because the same memory area shouldn't be allocated
-    // more than once (without deallocating it first)
-    else
-        {
-        delete entry;
-        return KErrAlreadyExists;
-        }
-    }
-    
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogMemoryAllocTraceL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::LogMemoryAllocTraceL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogMemoryAllocTraceL()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    // Read the first argument (index 0)
-    TUint32 memAddress = aMessage.Int0();
-    if ( memAddress == 0 )
-        {
-        return KErrNotSupported;
-        }
-    
-    // Read the third argument (index 2) that tells the size of this allocation
-    TInt size = aMessage.Int2();
-    
-    // Append this allocation into the iAllocInfoArray array. This array is for
-    // providing the configuration UI with information on allocations
-    
-    // Make a TAllocInfo object, and give values for its members.
-    TAllocInfo allocInfo( memAddress, size );
-
-    // Insert the allocInfo object into iAllocInfoArray
-    iError = iAllocInfoArray.InsertInUnsignedKeyOrder( allocInfo );
-    
-    // Log debug message if duplicated allocation.
-    if ( iError == KErrAlreadyExists )
-        {
-        LOGSTR2( "STSE TInt CATStorageServerSession::LogMemoryAllocTraceL() Error, duplicate allocation :%i", memAddress );
-        }
-
-    // A pointer to a buffer of call stack's memory addresses
-    CBufFlat* stackBuf = NULL;
-    
-    // Get the current universal time           
-    TInt64 timeFrom1970( GetTime() );     
-    
-    // Read the length of the descriptor argument (index 1) that should include
-    // call stack memory addresses associated with this memory allocation
-    TInt bufferLength = aMessage.GetDesLength( 1 );
-    
-    // Construct a buffer for aCallstack
-    stackBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( stackBuf );
-    
-    // Buffer position
-    TInt pos( 0 );    
-    stackBuf->ExpandL( pos, bufferLength );
-    
-    TPtr8 bufPtr = stackBuf->Ptr( pos );
-    
-    // Read the descriptor argument (index 1) into the buffer
-    aMessage.ReadL( 1, bufPtr );
-    
-    // Variable for the number of memory addresses in the call stack
-    TInt addrCount( 0 );    
-    TUint32 callStackAddr;
-    
-    // Read the first word of the buffer. This includes the number of
-    // memory addresses stored in the current stackBuf   
-    stackBuf->Read( pos, &addrCount, KWordSize );
-    
-    // Move the position one word onwards.    
-    pos += KWordSize;
-    
-    // Create a 16-bit buffer, and a pointer descriptor for it    
-    // ALLOCH <Memory address> <Time stamp> <Allocation size> <Call stack address count> 
-    // <Call stack address> <Call stack address> ...
-    HBufC* traceBuf = HBufC::NewL( KMemAllocBufLength );
-    TPtr tracePtr( traceBuf->Des() );
-    
-    // Pop stackBuf from CleanupStack, since no leavable operations will be done
-    // anymore
-    CleanupStack::Pop( stackBuf );
-    
-    // Append the tag implying a memory allocation line in the data file
-    tracePtr.Append( KMemoryAllocHeader );
-    
-    // Append the start address of this allocation in the 32-bit (max 8 characters)
-    // hexadecimal text format.
-    tracePtr.AppendNum( memAddress, EHex );
-    
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format
-    tracePtr.Append( KSpaceTrace );
-    tracePtr.AppendNum( timeFrom1970, EHex );
-    
-    // Append the size of the allocation in the 32-bit (max 8 characters) hexadecimal
-    // text format.
-    tracePtr.Append( KSpaceTrace );
-    tracePtr.AppendNum( size, EHex );
-    
-    // Append call stack address count
-    tracePtr.Append( KSpaceTrace );
-    tracePtr.AppendNum( addrCount, EHex );
-    
-    // Calculate last item length
-    TInt lastItemLength( KTraceMessage().Length() + KHexa32Length + 
-            KSpaceLength + KNewlineLength );
-    
-    TUint packetNumber( 1 );
-    
-    // Go through all call stack's memory addresses associated with
-    // this memory allocation 
-    for ( TInt j = 0; j < addrCount; j++ )
-        {
-        // ALLOCF <Memory address> <Time stamp> <Packet number> 
-        // <Call stack address> <Call stack address> ...
-        if ( tracePtr.Length() <= 0 )
-            {                
-            // Create alloc fragment message header
-            tracePtr.Append( KMemoryAllocFragment );
-            tracePtr.AppendNum( memAddress, EHex );
-            tracePtr.Append( KSpaceTrace );
-            tracePtr.AppendNum( timeFrom1970, EHex );
-            tracePtr.Append( KSpaceTrace );        
-            tracePtr.AppendNum( packetNumber, EHex );
-            // Increase packet number
-            packetNumber++;
-            }
-        
-        // Read the next call stack's memory address stored in the buffer.
-        stackBuf->Read( pos, &callStackAddr, KWordSize );
-        
-        // Append the read memory address as a hexadecimal number
-        tracePtr.AppendFormat( KHexaNumberTrace, callStackAddr );
-        
-        // Move the pos variable one word onwards.
-        pos += KWordSize;
-        
-        // Check if buffer max length exceed
-        if ( lastItemLength + tracePtr.Length() >= KMemAllocBufLength )
-            {
-            tracePtr.Append( KNewLineTrace );
-            // Log through debug channel 
-            RDebug::Print( KTraceMessage, iProcessId, traceBuf );
-            // Empty trace buffer
-            tracePtr.Delete( 0, tracePtr.MaxLength() );
-            }
-        }
-    
-    // Send the last message if exists
-    if ( tracePtr.Length() > 0 )
-        {
-        tracePtr.Append( KNewLineTrace );
-        
-        // Log through debug channel 
-        RDebug::Print( KTraceMessage, iProcessId, traceBuf );
-        }
-    
-    delete traceBuf;
-    delete stackBuf;
-    
-    // Update the iCurAllocSize, iMaxAllocs and iMaxAllocSize variables            
-    iCurAllocSize += size;
-    
-    // The count can never be negative => associate it to an unsigned int
-    TUint allocCount = iAllocInfoArray.Count();
-    if ( allocCount > iMaxAllocs )
-        {
-        iMaxAllocs = allocCount;
-        }
-    
-    if ( iCurAllocSize > iMaxAllocSize )
-        {
-        iMaxAllocSize = iCurAllocSize;
-        }
-    
-    return KErrNone;    
-    }    
-    
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogMemoryFreedL()
-// Removes a TATMemoryEntry object with the specified memory address from 
-// iLeakArray, if found.
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::LogMemoryFreedL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogMemoryFreedL()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    // Get the memory address
-    TUint32 memAddress = aMessage.Int0();
-    
-    // Remove this memory allocation from the leak array
-    TIdentityRelation<CATMemoryEntry> matcher( CATMemoryEntry::Match );
-    CATMemoryEntry* entry = new (ELeave) CATMemoryEntry( memAddress, NULL, 0, 0 );
-    TInt index = iLeakArray.Find( entry, matcher );
-    delete entry;
-    
-    // Return, if the requested memory address was not found
-    // (had not been allocated)
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-    
-    // Delete the CATMemoryEntry object at "index" and remove from the array
-    delete iLeakArray[index];
-    iLeakArray.Remove( index );
-    
-    // Remove this memory allocation also from the allocation info array
-    // Make a TAllocInfo object for a "find" operation
-    TAllocInfo allocInfo( memAddress, 0 );
-    index = iAllocInfoArray.FindInUnsignedKeyOrder( allocInfo );
-    
-    // The index should not be KErrNotFound, because an object with this memory address
-    // was found in the iLeakArray array. If the index is out of range, something is
-    // badly wrong, so it would be alright to panic in that case.
-    if ( index == KErrNotFound )
-        {
-        PanicClient( EAToolInternalError, aMessage );
-        return KErrCancel;
-        }
-    
-    // Decrease the current alloc size and remove the requested allocation
-    // from iAllocInfoArray
-    iCurAllocSize -= iAllocInfoArray[index].iAllocSize;
-    iAllocInfoArray.Remove( index );
-    
-    // If we are here, everything has gone alright
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::IsMemoryAdded()
-// Check a memory allocation (memory address) from an internal array.
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::IsMemoryAdded( const RMessage2& aMessage, 
-    const TBool aRemoveAlloc )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::IsMemoryAdded()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-        
-    // Read the first argument (index 0)
-    TUint32 memAddress = aMessage.Int0();
-    
-    // Try to find this memory allocation from the allocation info array
-    
-    // Make a TAllocInfo object for a "find" operation
-    TAllocInfo allocInfo( memAddress, 0 );
-    TInt index( iAllocInfoArray.FindInUnsignedKeyOrder( allocInfo ) );
-    
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-    else if ( aRemoveAlloc )
-        {
-        // Otherwise decrease the current alloc size and remove the requested allocation
-        // from iAllocInfoArray
-        iCurAllocSize -= iAllocInfoArray[index].iAllocSize;
-        iAllocInfoArray.Remove( index );
-        }
-    
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogMemoryFreedTraceL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::LogMemoryFreedTraceL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogMemoryFreedTraceL()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    // A pointer to a buffer of call stack's memory addresses
-    CBufFlat* stackBuf = NULL;        
-    iError = KErrNone;    
-    
-    // Read the first argument (index 0)
-    TUint32 memAddress = aMessage.Int0();
-
-    // Remove address from allocation table and its size from alloc size,
-    // if found from table.
-    TAllocInfo allocInfo( memAddress, 0 ); // Dummy info for search.
-    TInt index( iAllocInfoArray.FindInUnsignedKeyOrder( allocInfo ) );
-    if ( index != KErrNotFound )
-        {
-        // Decrease the current alloc size and remove the requested allocation
-        // from table.
-        iCurAllocSize -= iAllocInfoArray[index].iAllocSize;
-        iAllocInfoArray.Remove( index );
-        }
-    else
-        {
-        LOGSTR2( "STSE TInt CATStorageServerSession::LogMemoryFreedTrace() Error, cannot find alloc for free: %i", memAddress );
-        }
-    
-    // Read the length of the descriptor argument (index 1) that should include
-    // call stack memory addresses associated with this memory allocation
-    TInt bufferLength = aMessage.GetDesLength( 1 );
-    
-    // Construct a buffer for aCallstack
-    stackBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( stackBuf );
-    
-    // Buffer position
-    TInt pos = 0;
-    
-    stackBuf->ExpandL( pos, bufferLength );
-
-    TPtr8 bufPtr = stackBuf->Ptr( pos );
-
-    // Read the descriptor argument (index 1) into the buffer
-    aMessage.ReadL( 1, bufPtr );
-    
-    // Variable for the number of memory addresses in the call stack
-    TInt addrCount( 0 );    
-    TUint32 callStackAddr( 0 );
-
-    // Read the first word of the buffer. This includes the number of
-    // memory addresses stored in the current stackBuf
-    stackBuf->Read( pos, &addrCount, KWordSize );
-
-    // Move the position one word onwards.
-    pos += KWordSize;
-    
-    // Create a 16-bit buffer, and a pointer descriptor for it
-    HBufC* traceBuf = HBufC::NewL( KMemFreedBufLength );
-    TPtr tracePtr( traceBuf->Des() );
-    
-    // Pop stackBuf from CleanupStack, since no leavable operations will be done
-    // anymore
-    CleanupStack::Pop( stackBuf );
-    
-	// Get the current universal time		
-	TInt64 timeFrom1970( GetTime() );
-			
-    // Memory deallocation header message.
-    // FREEH <Memory address> <Time stamp> <Call stack address count> <Call stack address>
-    // <Call stack address> ...
-
-    // Append the tag implying a memory free line in the data file
-    tracePtr.Append( KMemoryFreedHeader );
-    
-    // Append the start address of this allocation in the 32-bit (max 8 characters)
-    // hexadecimal text format.
-    tracePtr.AppendNum( memAddress, EHex );    
-    
-	// Append the current time in the 64-bit (max 16 characters) hexadecimal text
-	// format
-	tracePtr.Append( KSpaceTrace );
-	tracePtr.AppendNum( timeFrom1970, EHex );
-			
-    // Append call stack address count
-    tracePtr.Append( KSpaceTrace );
-    tracePtr.AppendNum( addrCount, EHex );
-    
-    // Packet number
-    TUint packetNumber( 1 );
-    
-    // Calculate last item length
-    TInt lastItemLength( KTraceMessage().Length() + KHexa32Length + 
-            KSpaceLength + KNewlineLength );
-    
-    // Go through all call stack's memory addresses associated with
-    // this memory allocation 
-    for ( TInt j = 0; j < addrCount; j++ )
-        {
-        if ( tracePtr.Length() <= 0 )
-            {
-            // Memory deallocation fragment message.
-            // FREEF <Memory address> <Time stamp> <Packet number> <Call stack address count>
-            // <Call stack address>...
-            // Create free fragment message header
-            tracePtr.Append( KMemoryFreedFragment );
-            tracePtr.AppendNum( memAddress, EHex );
-            tracePtr.Append( KSpaceTrace );    
-			tracePtr.AppendNum( timeFrom1970, EHex );
-			tracePtr.Append( KSpaceTrace );	
-            tracePtr.AppendNum( packetNumber, EHex );
-            // Increase packet number
-            packetNumber++;
-            }
-        
-        // Read the next call stack's memory address stored in the buffer.
-        stackBuf->Read( pos, &callStackAddr, KWordSize );
-        
-        // Append the read memory address as a hexadecimal number
-        tracePtr.AppendFormat( KHexaNumberTrace, callStackAddr );
-        
-        // Move the pos variable one word onwards.
-        pos += KWordSize;
-        
-        // Check if buffer max length exceed
-        if ( lastItemLength + tracePtr.Length() >= KMemFreedBufLength )
-            {
-            tracePtr.Append( KNewLineTrace );
-            // Log through debug channel 
-            RDebug::Print( KTraceMessage, iProcessId, traceBuf );
-            // Empty trace buffer
-            tracePtr.Delete( 0, tracePtr.MaxLength() );
-            }
-        }
-    
-    // Send the last message if exists
-    if ( tracePtr.Length() > 0 )
-        {
-        tracePtr.Append( KNewLineTrace );
-        
-        // Log through debug channel 
-        RDebug::Print( KTraceMessage, iProcessId, traceBuf );
-        }
-        
-    delete traceBuf;
-    delete stackBuf;
-    // If we are here, everything has gone alright
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogProcessEndedL()
-// Prints memory leaks and information on process end into a file opened by the
-// function LogProcessStartedL()
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::LogProcessEndedL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogProcessEndedL()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    iError = KErrNone;
-    
-    // Read the sent process ID
-    TUint processId = aMessage.Int0();
- 
-    // The process ID got from the client should equal iProcessId.
-    // If it does not, return KErrNotSupported
-    if ( processId != iProcessId )
-        {
-        return KErrNotSupported;
-        }
-    
-    //////////////////////////////////////////////
-    // Log memory leaks
-    //////////////////////////////////////////////  
-    
-    // Print the information on the memory allocations that were never freed
-    iError = PrintLeaksL( aMessage );
-    
-    if ( iError != KErrNone )
-        {
-        return iError;
-        }    
-    
-    //////////////////////////////////////////////
-    // Log handle leaks
-    ////////////////////////////////////////////// 
-
-    TUint handleLeakCount = aMessage.Int1();
-    
-    if( handleLeakCount == 0 )
-        {
-        LOGSTR1( "STSE TInt CATStorageServerSession::LogProcessEndedL() No handle leaks to report" );
-        }
-    else
-        {
-        // Make a buffer that will be logged
-        TBuf8<KHandleLeakBufLength> loggingBuf;
-        
-        // Set handle leak module name to unknown since it can not be defined.
-        // Write the handle leak count from aMessage.
-        loggingBuf.Format( KHandleLeak, &KUnknownModule, handleLeakCount );
-    
-        // Write the constructed string into the data file and return if error
-        iError = iFile.Write( loggingBuf );
-    
-        if ( iError != KErrNone )
-            {
-            return iError;
-            }
-        }
-    
-    //////////////////////////////////////////////
-    // Log process end
-    //////////////////////////////////////////////
-           
-    // Make a buffer that will be logged into the opened logging file
-    TBufC8<KProcessEndBufLength> processEndBuf;
-    
-    TPtr8 bufPtr = processEndBuf.Des();
-    
-    bufPtr.AppendFormat( KProcessEnd, iProcessId );
-    
-    // Get the current universal time       
-    TInt64 timeFrom1970( GetTime() );
-    
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format         
-    bufPtr.AppendNum( timeFrom1970, EHex );
-    
-    // Append a new line
-    bufPtr.Append( KNewLine );
-    
-    // Write the buffer into a file and return the error code   
-    iError = iFile.Write( processEndBuf );
-    
-    // Close the file and the handle to the file server
-    CloseFsAndFile();
-    
-    // Remove the process from the server's array of processes
-    iError = iStorageServer.RemoveProcessL( processId );
-    
-    // Reset iProcesssId and set the logging flag false
-    iProcessId = KNullProcessId;
-    iLoggingOngoing = EFalse;
-    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogProcessEndTraceL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::LogProcessEndTraceL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogProcessEndTraceL()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    iError = KErrNone;
-    
-    // Read the sent process ID
-    TUint processId = aMessage.Int0();
- 
-    // The process ID got from the client should equal iProcessId.
-    // If it does not, return KErrNotSupported
-    if ( processId != iProcessId )
-        {
-        return KErrNotSupported;
-        }
-    
-    //////////////////////////////////////////////
-    // Log handle leaks
-    ////////////////////////////////////////////// 
-
-    TUint handleLeakCount = aMessage.Int1();
-
-    if( handleLeakCount == 0 )
-        {
-        LOGSTR1( "STSE TInt CATStorageServerSession::LogProcessEndTraceL() No handle leaks to report" );
-        }
-    else
-        {
-        // Make a buffer that will be logged
-        TBuf8<KHandleLeakBufLength> loggingBuf;
-        
-        // Make a 16-bit buffer that can be logged using RDebug
-        TBuf<KHandleLeakBufLength> traceBuf;
-        
-        // Set handle leak module name to unknown since it can not be defined.
-        // Write the handle leak count from aMessage.
-        loggingBuf.Format( KHandleLeak, &KUnknownModule, handleLeakCount );
-        
-        traceBuf.Copy( loggingBuf );
-    
-        // Log through debug channel 
-        RDebug::Print( KTraceMessage, iProcessId , &traceBuf );
-        }
-
-    //////////////////////////////////////////////
-    // Log process end
-    //////////////////////////////////////////////
-    
-    // Make a buffer that will be logged
-    TBuf<KProcessEndBufLength> processEndBuf;    
-    processEndBuf.AppendFormat( KProcessEndTrace, iProcessId );
-    
-    // Get the current universal time
-    TInt64 timeFrom1970( GetTime() );
-    
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format
-    processEndBuf.AppendNum( timeFrom1970, EHex );
-    
-    // Append a new line
-    processEndBuf.Append( KNewLineTrace );
-    
-    // Log through debug channel
-    RDebug::Print( KTraceMessage, iProcessId, &processEndBuf );
-
-    // Remove the process from the server's array of processes
-    iError = iStorageServer.RemoveProcessL( iProcessId );
-
-    // Reset iProcesssId and set the logging flag false
-    iProcessId = KNullProcessId;
-    iLoggingOngoing = EFalse;
-    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::CheckMemoryAddressL()
-// Checks if given memory address can be found
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::CheckMemoryAddressL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::CheckMemoryAddressL()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    iError = KErrNone;
-    
-    // Check if memory address can be found in iLeakArray
-    TUint32 memAddress = aMessage.Int0();
-    TIdentityRelation<CATMemoryEntry> matcher( CATMemoryEntry::Match );
-    CATMemoryEntry* entry = new (ELeave) CATMemoryEntry( memAddress, NULL, 0, 0 );
-    
-    // Get the index or an error code
-    iError = iLeakArray.Find( entry, matcher );
-    delete entry;
-    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::CheckMemoryAddressTrace()
-// Checks if some memory address can be found
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::CheckMemoryAddressTrace( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::CheckMemoryAddressTrace()" );
-    
-    // Panic the client and return, if a logging session is not ongoing
-    // ( can be started by calling the client's LogProcessStarted() )
-    if ( !iLoggingOngoing )
-        {
-        PanicClient( EAToolNotAllowed, aMessage );
-        return KErrCancel;
-        }
-    
-    // Always return KErrNone in this mode
-    return KErrNone;
-    }
- 
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::GetProcessesL()
-// Checks if some memory address can be found
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::GetProcessesL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::GetProcessesL()" );
-    
-    iError = KErrNone;
-    
-    TInt processInfoSize = sizeof( TATProcessInfo );
-    
-    CBufFlat* processInfoBuf;
-    
-    // Buffer position
-    TInt pos( 0 );
-    
-    // Calculate the length of the buffer to be constructed for processes
-    // One word will be reserved for the length of the array.
-    TInt bufferLength = KWordSize + KATMaxProcesses * processInfoSize;
-    
-    // Construct processInfoBuf and expand it before the beginning (index 0)
-    processInfoBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( processInfoBuf );
-    processInfoBuf->ExpandL( pos, bufferLength );
-    
-    RArray<TATProcessInfo> processArray = iStorageServer.ProcessInfoArray();
-
-    // Variable for the number of TATProcessInfo objects in processArray
-    TInt count = processArray.Count();
-    
-    // The count cannot be greater than KATMaxProcesses, because the client
-    // has reserved a buffer of this size to be filled by the server
-    if ( count > KATMaxProcesses )
-        {
-        count = KATMaxProcesses;
-        }
-
-    // Write the count (4 bytes) into the beginning of processInfoBuf
-    processInfoBuf->Write( pos, &count, KWordSize );
-    
-    // Move the position one word onwards.    
-    pos += KWordSize;
-    
-    // Write all the process info objects into the buffer 
-    for ( TInt i = 0; i < count; i++ )
-        {
-        TATProcessInfo& processInfo = processArray[i];
-        
-        // Write the current process info into the buffer
-        processInfoBuf->Write( pos, &processInfo, processInfoSize );
-        
-        // Move the pos variable onwards.
-        pos += processInfoSize;
-        }
-    
-    // Make a pointer descriptor pointing to the start of processInfoBuf
-    TPtr8 bufPtr( processInfoBuf->Ptr(0) );
-    
-    // Write the buffer into aMessage at index 0 for the client
-    aMessage.WriteL( 0, bufPtr );
-    
-    CleanupStack::PopAndDestroy( processInfoBuf );
-    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::GetDllsL()
-// Checks if some memory address can be found
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::GetDllsL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::GetDllsL()" );
-    
-    // Read the process ID at index 0
-    TUint processId = aMessage.Int0();
-    
-    // Size of a DLL descriptor
-    TInt sizeOfDllDesc = sizeof( TBuf8<KMaxLibraryName> );
-    
-    // Buffer position
-    TInt pos( 0 );
-    
-    // Calculate the length of the buffer to be constructed for DLL names.
-    // One word will be reserved for the length of the array.
-    TInt bufferLength = KWordSize + KATMaxDlls * sizeOfDllDesc;
-    
-    CBufFlat* dllBuf;
-    // Construct dllBuf and expand it before the beginning (index 0)
-    dllBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( dllBuf );
-    dllBuf->ExpandL( pos, bufferLength );
-
-    RPointerArray<CATDynProcessInfo> dynProcessArray =
-                                             iStorageServer.DynProcessInfoArray();
-    
-    // Construct a CATDynProcessInfo object with the given process ID for searching
-    CATDynProcessInfo* dynProcessInfo = new (ELeave) CATDynProcessInfo( processId );
-    
-    // Find the index of a CATDynProcessInfo object with the given process ID
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    TInt index = dynProcessArray.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-    
-    // Return, if a process with the requested process ID was not found 
-    if ( index == KErrNotFound )
-        {
-        CleanupStack::PopAndDestroy( dllBuf );
-        return index;
-        }
-    
-    // Get the wanted dynamic process info 
-    dynProcessInfo = dynProcessArray[index];
- 
-    // Fetch a reference to the desired DLL array
-    RArray<TATDllInfo>& dllArray = dynProcessInfo->iDlls;
-    
-    // Take the count of names in the array 
-    TInt count = dllArray.Count();
-
-    // The count cannot be greater than KATMaxDlls, because the client
-    // has reserved a buffer of this size to be filled by the server
-    if ( count > KATMaxDlls )
-        {
-        count = KATMaxDlls;
-        }
-
-    // Write the count (4 bytes) into the beginning of dllBuf
-    dllBuf->Write( pos, &count, KWordSize );
-    
-    // Move the position one word onwards.
-    pos += KWordSize;
-
-    // Go through all DLL names objects sent to the server 
-    for ( TInt i = 0; i < count; i++ )
-        {
-        TBuf8<KMaxLibraryName>& dllName = dllArray[i].iName;
-        
-        // Write the current DLL name into the buffer
-        dllBuf->Write( pos, &dllName, sizeOfDllDesc );
-        
-        // Move the pos variable onwards.
-        pos += sizeOfDllDesc;
-        }  
-    
-    // Make a pointer descriptor pointing to the start of dllBuf
-    TPtr8 bufPtr( dllBuf->Ptr(0) );
-    
-    // Write the whole buffer into aMessage at index 1 for the client
-    aMessage.WriteL( 1, bufPtr );
-    
-    CleanupStack::PopAndDestroy( dllBuf );
-
-    // The dynProcessInfo object will not be deleted, because it is still owned by the
-    // server object's dynamic process info array.  
-    dynProcessInfo = NULL;
-    
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::GetLoggingModeL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::GetLoggingModeL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::GetLoggingModeL()" );
-    
-    iError = KErrNone;
-    
-    // Read the process ID at index 0
-    TUint processId = aMessage.Int0();
-    
-    // Buffer position
-    TInt pos( 0 );
-    
-    // The length of the buffer to be constructed for logging mode
-    TInt bufferLength = KWordSize;
-    
-    // Get the dynamic process info array
-    RPointerArray<CATDynProcessInfo> dynProcessArray =
-                                             iStorageServer.DynProcessInfoArray();
-    
-    // Construct a CATDynProcessInfo object with the given process ID for searching
-    CATDynProcessInfo* dynProcessInfo = new (ELeave) CATDynProcessInfo( processId );
-    
-    // Find the index of a CATDynProcessInfo object with the given process ID
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    TInt index = dynProcessArray.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-    
-    // Return, if a process with the requested process ID was not found 
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-    
-    // Otherwise get the wanted dynamic process info
-    dynProcessInfo = dynProcessArray[index];
-
-    // Get the desired process's associated session object
-    CATStorageServerSession* sessionObject = dynProcessInfo->iSessionObject;
-    CBufFlat* loggingModeBuf;
-    // Construct allocInfoBuf and expand it before the beginning (index 0)
-    loggingModeBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( loggingModeBuf );
-    loggingModeBuf->ExpandL( 0, bufferLength );
-    
-    // Write the current logging mode of the requested process into the buffer.
-    loggingModeBuf->Write( pos, &sessionObject->iLogOption, KWordSize );
-    
-    // Make a pointer descriptor that points to the data of allocInfoBuf
-    TPtr8 bufPtr( loggingModeBuf->Ptr(0) );
-    
-    // Write the whole buffer into aMessage at index 1 for the client
-    aMessage.WriteL( 1, bufPtr );
-    
-    CleanupStack::PopAndDestroy( loggingModeBuf );
-    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::StartSubtestL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::StartSubtestL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::StartSubtestL()" );
-    
-    iError = KErrNone;
-    
-    // Read the process ID at index 0
-    TUint processId = aMessage.Int0();
-    
-    // Read the sub test ID at index 1
-    TBuf8<KATMaxSubtestIdLength> subTestName;
-    iError = aMessage.Read( 1, subTestName );
-    
-    // Return if reading was not successful
-    if ( iError != KErrNone )
-        {
-        return iError;
-        }
-    
-    // Create another (non-8-bit) descriptor for logging to trace
-    // and copy the contents
-    TBuf<KATMaxSubtestIdLength> subTestNameTrace;
-    subTestNameTrace.Copy( subTestName );
-
-    // Read the handle count at index 2
-    TInt handleCount = aMessage.Int2();
-    
-    // FIND THE REQUESTED PROCESS
-    
-    // Get the dynamic process array
-    RPointerArray<CATDynProcessInfo> dynProcessArray =
-                                             iStorageServer.DynProcessInfoArray();
-    
-    // Construct a CATDynProcessInfo object with the given process ID for searching
-    CATDynProcessInfo* dynProcessInfo = new (ELeave) CATDynProcessInfo( processId );
-    
-    // Find the index of a CATDynProcessInfo object with the given process ID
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    TInt index = dynProcessArray.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-    
-    // Return, if a process with the requested process ID was not found
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-    
-    // Get the wanted dynamic process info
-    dynProcessInfo = dynProcessArray[index];
-    
-    // Get the desired process's associated session object
-    const CATStorageServerSession* sessionObject = dynProcessInfo->iSessionObject;
-  
-    // Make a buffer for logging thru trace
-    TBuf<KTestStartBufLength> loggingBuf;
-    
-    // Copy the line tag into the buffer  
-    loggingBuf.Copy( KSubtestStart );
-    
-    // Get the current universal time
-    TInt64 timeFrom1970( GetTime() );
-    
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format
-    loggingBuf.AppendNum( timeFrom1970, EHex );
-    
-    // Append a space
-    loggingBuf.Append( KSpaceTrace );
-    
-    // Append the sub test ID
-    loggingBuf.Append( subTestNameTrace );
-
-    // Append a space
-    loggingBuf.Append( KSpaceTrace );
-    
-    // Append current handle leak count
-    loggingBuf.AppendNum( handleCount );
-    
-    // Append a new line
-    loggingBuf.Append( KNewLineTrace );
-    
-    // Log the string through trace
-    iError = sessionObject->LogThroughTrace( loggingBuf );
-        
-    // *******************
-    // Send loaded DLL's
-    // *******************
-    
-    // Fetch a reference to the desired DLL array
-	RArray<TATDllInfo>& dllArray = dynProcessInfo->iDlls;
-	
-	// Take the count of dll info items
-	TInt count( dllArray.Count() );
-	LOGSTR2( "STSE > dllArray.Count( %i )", count );
-	
-	// Create buffers
-	TBuf<KDllLoadBufLength> traceBuf;
-	TBuf8<KDllLoadBufLength> dllBuf;
-	
-	for ( TInt x = 0; x < count; x++ )
-		{
-		dllBuf.Format( KDllLoad, &dllArray[x].iName, dllArray[x].iLoadTime,
-				dllArray[x].iStartAddress, dllArray[x].iEndAddress );
-		traceBuf.Copy( dllBuf );
-		
-		// Log the string through trace
-		iError = sessionObject->LogThroughTrace( traceBuf );
-		if ( iError != KErrNone )
-			{
-			LOGSTR2( "STSE > LogThroughTrace() err( %i )", iError );
-			}
-		}
-    sessionObject = NULL;
-    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::StopSubtestL()
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::StopSubtestL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::StopSubtestL()" );
-    
-    iError = KErrNone;
-    
-    // Read the process ID at index 0
-    TUint processId = aMessage.Int0();
-    
-    // Read the sub test ID at index 1
-    TBuf8<KATMaxSubtestIdLength> subTestName;
-    iError = aMessage.Read( 1, subTestName );
-    
-    // Return if reading was not successful
-    if ( iError != KErrNone )
-        {
-        return iError;
-        }
-
-    // Create another (non-8-bit) descriptor for logging to trace,
-    // and copy the contents
-    TBuf<KATMaxSubtestIdLength> subTestNameTrace;
-    subTestNameTrace.Copy( subTestName );
-
-    // Read the handle count at index 2
-    TInt handleCount = aMessage.Int2();
-    
-    // FIND THE REQUESTED PROCESS
-    
-    // Get the dynamic process array
-    RPointerArray<CATDynProcessInfo> dynProcessArray =
-                                             iStorageServer.DynProcessInfoArray();
-    
-    // Construct a CATDynProcessInfo object with the given process ID for searching
-    CATDynProcessInfo* dynProcessInfo = new (ELeave) CATDynProcessInfo( processId );
-    
-    // Find the index of a CATDynProcessInfo object with the given process ID
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    TInt index = dynProcessArray.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-    
-    // Return, if a process with the requested process ID was not found
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-    
-    // Get the wanted dynamic process info
-    dynProcessInfo = dynProcessArray[index];
-    
-    // Get the desired process's associated session object
-    const CATStorageServerSession* sessionObject = dynProcessInfo->iSessionObject;
-  
-    // Make a buffer for logging thru trace
-    TBuf<KTestEndBufLength> loggingBuf;
-    
-    // Copy the line tag into the buffer  
-    loggingBuf.Copy( KSubtestEnd );
-    
-    // Get the current universal time
-    TInt64 timeFrom1970( GetTime() );
-    
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format
-    loggingBuf.AppendNum( timeFrom1970, EHex );
-    
-    // Append a space
-    loggingBuf.Append( KSpaceTrace );
-    
-    // Append the sub test ID
-    loggingBuf.Append( subTestNameTrace );
-
-    // Append a space
-    loggingBuf.Append( KSpaceTrace );
-    
-    // Append current handle leak count
-    loggingBuf.AppendNum( handleCount );
-    
-    // Append a new line
-    loggingBuf.Append( KNewLineTrace );
-    
-    // Log the string through trace
-    iError = sessionObject->LogThroughTrace( loggingBuf );
-    
-    sessionObject = NULL;
-    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::StartSubtest2L()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::StartSubtest2L( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::StartSubtest2L()" );
-    
-    iError = KErrNone;
-    
-    // Read the sub test ID at index 0
-    TBuf8<KATMaxSubtestIdLength> subTestName;
-    iError = aMessage.Read( 0, subTestName );
-    
-    // Return if reading was not successful
-    if ( iError != KErrNone )
-        {
-        return iError;
-        }
-    
-    // Create another (non-8-bit) descriptor for logging to trace
-    // and copy the contents
-    TBuf<KATMaxSubtestIdLength> subTestNameTrace;
-    subTestNameTrace.Copy( subTestName );
-
-    // Make a buffer for logging thru trace
-    TBuf<KTestStartBufLength> loggingBuf;
-    
-    // Copy the line tag into the buffer  
-    loggingBuf.Copy( KSubtestStart );
-    
-    // Get the current universal time
-    TInt64 timeFrom1970( GetTime() );
-    
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format
-    loggingBuf.AppendNum( timeFrom1970, EHex );
-    
-    // Append a space
-    loggingBuf.Append( KSpaceTrace );
-    
-    // Append the sub test ID
-    loggingBuf.Append( subTestNameTrace );
-    
-    // Append a new line
-    loggingBuf.Append( KNewLineTrace );
-    
-    // Log the string through trace
-    iError = LogThroughTrace( loggingBuf );
-    
-    // *******************
-	// Send loaded DLL's
-	// *******************
-	
-    // Get the dynamic process array
-	RPointerArray<CATDynProcessInfo> dynProcessArray =
-		iStorageServer.DynProcessInfoArray();
-	
-	// Construct a CATDynProcessInfo object with the given process ID for searching
-	CATDynProcessInfo* dynProcessInfo = new (ELeave) CATDynProcessInfo( iProcessId );
-	
-	// Find the index of a CATDynProcessInfo object with the given process ID
-	TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-	TInt index = dynProcessArray.FindInOrder( dynProcessInfo, order );
-	delete dynProcessInfo;
-	dynProcessInfo = NULL;
-	 
-	// Return, if a process with the requested process ID was not found
-	if ( index == KErrNotFound )
-		{
-		return index;
-		}
-	
-	// Get the wanted dynamic process info
-	dynProcessInfo = dynProcessArray[index];
-        
-	// Fetch a reference to the desired DLL array
-	RArray<TATDllInfo>& dllArray = dynProcessInfo->iDlls;
-	
-	// Take the count of dll info items
-	TInt count( dllArray.Count() );
-	LOGSTR2( "STSE > dllArray.Count( %i )", count );
-	
-	// Create buffers
-	TBuf<KDllLoadBufLength> traceBuf;
-	TBuf8<KDllLoadBufLength> dllBuf;
-	
-	for ( TInt x = 0; x < count; x++ )
-		{
-		dllBuf.Format( KDllLoad, &dllArray[x].iName, dllArray[x].iLoadTime,
-				dllArray[x].iStartAddress, dllArray[x].iEndAddress );
-		traceBuf.Copy( dllBuf );
-		
-		// Log the string through trace
-		iError = LogThroughTrace( traceBuf );
-		if ( iError != KErrNone )
-			{
-			LOGSTR2( "STSE > LogThroughTrace() err( %i )", iError );
-			}
-		}
-    	
-    return iError;
-    }
-    
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::StopSubtest2()
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::StopSubtest2( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::StopSubtest2()" );
-    
-    iError = KErrNone;
-    
-    // Read the sub test ID at index 0
-    TBuf8<KATMaxSubtestIdLength> subTestName;
-    iError = aMessage.Read( 0, subTestName );
-    
-    // Return if reading was not successful
-    if ( iError != KErrNone )
-        {
-        return iError;
-        }
-
-    // Create another (non-8-bit) descriptor for logging to trace,
-    // and copy the contents
-    TBuf<KATMaxSubtestIdLength> subTestNameTrace;
-    subTestNameTrace.Copy( subTestName );
-
-    // Make a buffer for logging thru trace
-    TBuf<KTestEndBufLength> loggingBuf;
-    
-    // Copy the line tag into the buffer  
-    loggingBuf.Copy( KSubtestEnd );
-    
-    // Get the current universal time    
-    TInt64 timeFrom1970( GetTime() );
-    
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format
-    loggingBuf.AppendNum( timeFrom1970, EHex );
-    
-    // Append a space
-    loggingBuf.Append( KSpaceTrace );
-    
-    // Append the sub test ID
-    loggingBuf.Append( subTestNameTrace );
-    
-    // Append a new line
-    loggingBuf.Append( KNewLineTrace );
-    
-    // Log the string through trace
-    iError = LogThroughTrace( loggingBuf );
-    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::GetCurrentAllocsL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::GetCurrentAllocsL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::GetCurrentAllocsL()" );
-    
-    iError = KErrNone;
-    
-    // Read the process ID at index 0
-    TUint processId = aMessage.Int0();
-    TUint32 allocNumber( 0 );
-    TUint32 allocSize( 0 );
-    
-    // Buffer position
-    TInt pos( 0 );
-    
-    // The length of the buffer to be constructed for allocation number and size
-    TInt bufferLength = KWordSize + KWordSize;
-    
-    // Get the dynamic process info array
-    RPointerArray<CATDynProcessInfo> dynProcessArray =
-                                             iStorageServer.DynProcessInfoArray();
-    
-    // Construct a CATDynProcessInfo object with the given process ID for searching
-    CATDynProcessInfo* dynProcessInfo = new (ELeave) CATDynProcessInfo( processId );
-    
-    // Find the index of a CATDynProcessInfo object with the given process ID
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    TInt index = dynProcessArray.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-    
-    // Return, if a process with the requested process ID was not found
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-    
-    // Otherwise get the wanted dynamic process info
-    dynProcessInfo = dynProcessArray[index];
-
-    // Get the desired process's associated session object
-    CATStorageServerSession* sessionObject = dynProcessInfo->iSessionObject;
-    
-    // Get the alloc info array of that session object
-    RArray<TAllocInfo> allocInfo = sessionObject->AllocInfoArray();
-    
-    // Get the values for current allocations number and size
-    allocNumber = allocInfo.Count();
-    
-    // Calculate the total size of the current allocations
-    for ( TUint32 i = 0; i < allocNumber; i++ )
-        {
-        allocSize += allocInfo[i].iAllocSize;
-        }
-    
-    LOGSTR2( "STSE allocSize: %u", allocSize );
-    LOGSTR2( "STSE iCurAllocSize: %u", iCurAllocSize );
-    
-    CBufFlat* allocInfoBuf;
-    // Construct allocInfoBuf and expand it before the beginning (index 0)
-    allocInfoBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( allocInfoBuf );
-    allocInfoBuf->ExpandL( 0, bufferLength );
-    
-    // Write the current number of allocations of the requested process into the buffer.
-    allocInfoBuf->Write( pos, &allocNumber, KWordSize );
-    
-    // Move the position one word onwards
-    pos += KWordSize;
-    
-    // Write the current total size of the allocations of the requested process into the
-    // buffer.
-    allocInfoBuf->Write( pos, &allocSize, KWordSize );
-    
-    // Make a pointer descriptor that points to the data of allocInfoBuf
-    TPtr8 bufPtr( allocInfoBuf->Ptr(0) );
-    
-    // Write the whole buffer into aMessage at index 1 for the client
-    aMessage.WriteL( 1, bufPtr );
-    
-    CleanupStack::PopAndDestroy( allocInfoBuf );
-                    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::GetMaxAllocsL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::GetMaxAllocsL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::GetMaxAllocsL()" );
-    
-    iError = KErrNone;
-    
-    // Read the process ID at index 0
-    TUint processId = aMessage.Int0();
-    TUint32 allocNumber( 0 );
-    TUint32 allocSize( 0 );
-    
-    // Buffer position
-    TInt pos( 0 );
-    
-    // The length of the buffer to be constructed for allocation number and size
-    TInt bufferLength = KWordSize + KWordSize;
-    
-    // Get the dynamic process info array
-    RPointerArray<CATDynProcessInfo> dynProcessArray =
-                                             iStorageServer.DynProcessInfoArray();
-    
-    // Construct a CATDynProcessInfo object with the given process ID for searching
-    CATDynProcessInfo* dynProcessInfo = new (ELeave) CATDynProcessInfo( processId );
-    
-    // Find the index of a CATDynProcessInfo object with the given process ID
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    TInt index = dynProcessArray.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-    
-    // Return, if a process with the requested process ID was not found 
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-    
-    // Otherwise get the wanted dynamic process info 
-    dynProcessInfo = dynProcessArray[index];
-
-    // Get the desired process's associated session object
-    CATStorageServerSession* sessionObject = dynProcessInfo->iSessionObject;
-    
-    // Get values for the maximum allocations number and size
-    allocNumber = sessionObject->iMaxAllocs;
-    allocSize = sessionObject->iMaxAllocSize;
-    
-    CBufFlat* allocInfoBuf;
-    // Construct allocInfoBuf and expand it before the beginning (index 0)
-    allocInfoBuf = CBufFlat::NewL( bufferLength );
-    CleanupStack::PushL( allocInfoBuf );
-    allocInfoBuf->ExpandL( 0, bufferLength );
-    
-    // Write the maximum number of allocations of the requested process into the buffer.
-    allocInfoBuf->Write( pos, &allocNumber, KWordSize );
-    
-    // Move the position one word onwards
-    pos += KWordSize;
-    
-    // Write the maximum total size of the allocations of the requested process into the
-    // buffer.
-    allocInfoBuf->Write( pos, &allocSize, KWordSize );
-    
-    // Make a pointer descriptor that points to the data of allocInfoBuf
-    TPtr8 bufPtr( allocInfoBuf->Ptr(0) );
-    
-    // Write the whole buffer into aMessage at index 1 for the client
-    aMessage.WriteL( 1, bufPtr );
-    
-    CleanupStack::PopAndDestroy( allocInfoBuf );
-                    
-    return iError;
-    }
-  
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::CancelLoggingL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::CancelLoggingL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::CancelLoggingL()" );
-    
-    iError = KErrNone;
-    
-    // Read the process ID at index 0
-    TUint processId = aMessage.Int0();
-        
-    // FIND THE REQUESTED PROCESS
-    
-    // Get the dynamic process array
-    RPointerArray<CATDynProcessInfo> dynProcessArray =
-                                             iStorageServer.DynProcessInfoArray();
-    
-    // Construct a CATDynProcessInfo object with the given process ID for searching
-    CATDynProcessInfo* dynProcessInfo = new (ELeave) CATDynProcessInfo( processId );
-    
-    // Find the index of a CATDynProcessInfo object with the given process ID
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    TInt index = dynProcessArray.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-     
-    // Return, if a process with the requested process ID was not found
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-    
-    // Otherwise get the wanted dynamic process info
-    dynProcessInfo = dynProcessArray[index];
-    
-    // Get the session object of the requested process
-    CATStorageServerSession* sessionObject = dynProcessInfo->iSessionObject;
-      
-    // Get the current universal time
-    TInt64 timeFrom1970( GetTime() );
-    
-    // Make a buffer for logging "logging cancelled"
-    TBuf8<KCancelBufLength> loggingBuf;
-    
-    // Copy the "logging cancelled" tag into the buffer with the current time 
-    loggingBuf.AppendFormat( KLoggingCancelled, timeFrom1970 );
-    
-    // Log the buffer eather to a file or to debug channel depending on the current
-    // logging mode
-    
-    if ( sessionObject->iLoggingOngoing && 
-         sessionObject->iLogOption == EATLogToFile )
-        {
-        // Write the buffer into the file  
-        sessionObject->iFile.Write( loggingBuf );
-        }
-    
-    else if ( sessionObject->iLoggingOngoing &&
-              sessionObject->iLogOption == EATLogToTrace )
-        {
-        // Make a buffer for logging to trace
-        TBuf<KCancelBufLength> traceBuf;
-        traceBuf.Copy( loggingBuf );
-        
-        // Write the buffer into the debug channel
-        RDebug::Print( KTraceMessage, processId ,&traceBuf );
-        }
-    
-    // Switch off logging of the requested process 
-    sessionObject->iLogOption = EATLoggingOff;
-    
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::HandleError
-// Internally used for handling error situations.
-// -----------------------------------------------------------------------------
-// 
-void CATStorageServerSession::HandleError( TInt aError )
-    {
-    LOGSTR1( "STSE void CATStorageServerSession::HandleError()" );
-      
-    // Get the current universal time
-    TInt64 timeFrom1970( GetTime() );
-        
-    // Make a buffer that will be logged into the opened logging file
-    TBufC8<KErrOccuredBufLength> loggingBuf;
-    
-    TPtr8 bufPtr( loggingBuf.Des() );
-     
-    // Write the error code to the buffer  
-    bufPtr.Format( KErrorOccured, aError );
-       
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format
-    bufPtr.AppendNum( timeFrom1970, EHex );
-    
-    // Append a new line
-    bufPtr.Append( KNewLine );
-            
-    // Write the buffer into a file (if possible in the current condition)
-    iFile.Write( loggingBuf );
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::HandleErrorTrace()
-// Internally used for handling error situations.
-// -----------------------------------------------------------------------------
-//    
-void CATStorageServerSession::HandleErrorTrace( TInt aError )
-    {
-    LOGSTR1( "STSE void CATStorageServerSession::HandleErrorTrace()" );
-    
-     // Get the current universal time
-    TInt64 timeFrom1970( GetTime() );
-        
-    // Make a buffer that will be logged
-    TBuf<KErrOccuredBufLength> traceBuf;
-     
-    // Write the error code to the buffer  
-    traceBuf.Format( KErrorOccuredTrace, aError );
-       
-    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-    // format
-    traceBuf.AppendNum( timeFrom1970, EHex );
-    
-    // Append a new line
-    traceBuf.Append( KNewLineTrace );
-                 
-    RDebug::Print( KTraceMessage, iProcessId , &traceBuf );
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::OpenFsAndFile
-// Internally used for opening a handle to the file server and a file
-// -----------------------------------------------------------------------------
-// 
-TInt CATStorageServerSession::OpenFsAndFile( const TDesC& aFileName, 
-    const TDesC8& aProcessName )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::OpenFsAndFile()" );
-    
-    // Connect file server, return if error occured
-    iError = iFileServer.Connect();
-    if ( iError )
-        {
-        iFileServer.Close();
-        return iError;
-        }
-
-    // Open a file
-    TBuf<KMaxFileName> fileNameBuf;    
-    iError = TATDriveInfo::CreatePath( fileNameBuf, aFileName, iFileServer );
-                        
-    // Return, if an error occured, and it
-    // is not KErrAlreadyExists
-    if ( iError && iError != KErrAlreadyExists )
-        {
-        iFileServer.Close();
-        return iError;
-        }
-    
-    // Save the file name for this session
-    CnvUtfConverter::ConvertFromUnicodeToUtf8( iLogFile, fileNameBuf );
-        
-    // Try to open file
-    CheckIfFileAlreadyExist( fileNameBuf );
-    
-    // If a data file with the requested name already existed, and was opened
-    // successfully, check the version of the file. If the line telling the version of
-    // the file is not the expected, replace the file
-    // If cannot open the file(error is KErrInUse), generate new filename and 
-    // then try to create new file.
-    if ( iError == KErrNone )
-        {
-        CheckFileVersion( fileNameBuf );
-        }    
-    else if ( iError == KErrInUse )
-        {
-        GenerateNewFileName( fileNameBuf, aProcessName );
-        
-        // Save the file name for this session
-        CnvUtfConverter::ConvertFromUnicodeToUtf8( iLogFile, fileNameBuf );
-        }
-    LOGSTR2( "STSE > iError(%i)", iError );
-        
-    // If the file does not exist, create it. Write also the version number of
-    // the file at the beginning of the new file
-    if ( iError == KErrNotFound )
-        {
-        iError = iFile.Create( iFileServer, fileNameBuf, EFileWrite );
-        
-        if ( !iError )
-            {
-            iError = iFile.Write( KDataFileVersion );
-            }
-        }   
-       
-    if ( iError )
-        {
-        iFile.Close();
-        iFileServer.Close();
-        return iError;
-        }
-        
-    // Seek the end of the file and set the current file position there
-    TInt offset = 0;
-    iError = iFile.Seek( ESeekEnd, offset );
-    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::GenerateNewFileName
-// Called internally when need generate new file name.
-// -----------------------------------------------------------------------------
-//                     
-void CATStorageServerSession::GenerateNewFileName( TDes& aFileName,
-    const TDesC8& aProcessName )
-    {    
-    LOGSTR1( "STSE void CATStorageServerSession::GenerateNewFileName()" );
-        
-    // Extension
-    TBuf<KExtensionLength> extension;
-
-    // Parse file extension
-    ParseExtension( aFileName, extension );
-
-    // Try to find UID3 from current process name
-    TInt uidErr( KErrBadName );
-    TBuf<KMaxFileName> unicodeFile;
-
-    // Converts text encoded using the Unicode transformation format UTF-8 
-    // into the Unicode UCS-2 character set. 
-    CnvUtfConverter::ConvertToUnicodeFromUtf8( unicodeFile, aProcessName );
-    LOGSTR2( "STSE > unicodeFile(%S)", &unicodeFile );
-
-    // Find square brackets
-    TInt sPos( unicodeFile.Find( KOpenSquareBracket ) );
-    TInt ePos( unicodeFile.Find( KCloseSquareBracket ) );
-    LOGSTR3( "STSE > sPos(%i), ePos(%i)", sPos, ePos );
-            
-    if ( sPos != KErrNotFound && ePos != KErrNotFound )
-        {
-        TBuf<KProcessUidLength> processUid;
-        TInt pEnd( ePos - sPos - KOpenSquareBracket().Length() );
-        LOGSTR2( "STSE > pEnd(%i)", pEnd );
-        
-        // Copy UID value
-        if ( pEnd > 0 )
-            {
-            processUid.Copy( unicodeFile.Mid( 
-                    sPos + KOpenSquareBracket().Length(), pEnd ) );
-            LOGSTR2( "STSE > processUid(%S)", &processUid );
-            }
-        
-        if ( aFileName.Find( processUid ) == KErrNotFound )
-            {
-            // UID not exist, create new filename
-            // Append uid to filename (<file name>_<uid>.<extension>)
-            aFileName.Append( KUnderLine );
-            aFileName.Append( processUid );
-            aFileName.Append( extension );
-            // Try to open file
-            CheckIfFileAlreadyExist( aFileName );
-
-            if ( iError == KErrNone )
-                {
-                uidErr = KErrNone;
-                CheckFileVersion( aFileName );
-                }
-            }
-        }
-
-    if ( uidErr == KErrBadName && iError != KErrNotFound )
-        {
-        // Need re-create file name, add end off file _xx (xx=01, 02...)
-        LOGSTR2( "STSE > Re-create file name, aFileName(%S)", &aFileName );
-                
-        // Parse file extension if exists.
-        ParseExtension( aFileName, extension );
-        
-        // Temp file name
-        TBuf<KMaxFileName> tempName;
-        
-        for ( TInt i = KNameIndexStart; i < KNameIndexEnd; i++ )
-            {
-            tempName.Delete( 0, tempName.MaxLength() );
-            tempName.Format( KFormat, &aFileName, &KUnderLine, i, &extension );
-            LOGSTR2( "STSE > tempName(%S)", &tempName );
-            // Try to open file
-            CheckIfFileAlreadyExist( tempName );
-            
-            if ( iError == KErrNone || iError == KErrNotFound )
-                {
-                aFileName.Copy( tempName );
-                break;
-                }
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::ParseExtension
-// Method is used to parse file name extension.
-// -----------------------------------------------------------------------------
-//                     
-void CATStorageServerSession::ParseExtension( 
-    TDes& aFileName, TDes& aExtension )
-    {    
-    LOGSTR2( "STSE void CATStorageServerSession::ParseExtension(%S)", 
-            &aFileName );
-
-    // Parse current file name
-    TParse parse;
-    // Set up the TParse object 
-    parse.Set( aFileName, NULL, NULL );
-
-    // Tests whether an extension is present.
-    if ( parse.ExtPresent() )
-        {
-        // Gets the extension
-        aExtension.Copy( parse.Ext() );
-        // Remove extension from file name
-        TInt pos( aFileName.Find( aExtension ) );
-        aFileName.Delete( pos, aFileName.Length() );
-        LOGSTR3( "STSE > aFileName(%S), aExtension(%S)", 
-                &aFileName, &aExtension );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::CheckIfFileAlreadyExist
-// Method is used to check that file exists and is valid.
-// -----------------------------------------------------------------------------
-//                     
-void CATStorageServerSession::CheckIfFileAlreadyExist( 
-    const TDes& aFileName )
-    {    
-    LOGSTR2( "STSE void CATStorageServerSession::CheckIfFileAlreadyExist(%S)", 
-            &aFileName );
-    
-    iError = iFile.Open( iFileServer, aFileName, EFileWrite );
-    LOGSTR2( "STSE > iError(%i)", iError );
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::CheckFileVersion
-// Method is used to check file version.
-// -----------------------------------------------------------------------------
-//                     
-void CATStorageServerSession::CheckFileVersion( 
-    const TDes& aFileName )
-    {    
-    LOGSTR2( "STSE void CATStorageServerSession::CheckFileVersion(%S)", 
-            &aFileName );
-
-    TBuf8<KVersionStringLength> versionString;
-
-    // Read version information from the beginning of the file (offset 0)
-    iFile.Read( 0, versionString, KVersionStringLength );
-
-    // Delete the existing file, if the version string read from the file does not
-    // match with KDataFileVersion.
-    if ( versionString.Compare( KDataFileVersion ) != 0 )
-        {
-        // Close the existing, opened file, and delete it
-        iFile.Close();
-        iError = iFileServer.Delete( aFileName );
-        
-        // If the deletion was successful, set iError = KErrNotFound, so a new
-        // file will be created in the next few lines 
-        if ( iError == KErrNone )
-            {
-            iError = KErrNotFound;
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::CloseFsAndFile
-// Internally used for closing a handle to the file server and a file
-// -----------------------------------------------------------------------------
-// 
-void CATStorageServerSession::CloseFsAndFile()
-    {
-    LOGSTR1( "STSE void CATStorageServerSession::CloseFsAndFile()" );
-    
-    // Close the file    
-    iFile.Close();
-                 
-    // Close the server session and return the error code   
-    iFileServer.Close();
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::PrintLeaksL()
-// Called internally when a process is closed. Prints possible memory leaks
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::PrintLeaksL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::PrintLeaksL()" );
-    
-    // Panic both the client and the server, if this method is called in a wrong
-    // state (logging should be ongoing, and the system should be logging into a file,
-    // not into debug channel)
-    if ( !iLoggingOngoing || iLogOption != EATLogToFile )
-        {
-        PanicClient( EAToolInternalError, aMessage );
-        StorageServerPanic( KCategoryServer, EAToolInternalError );
-        }
-   
-    LOGMEM;
-
-    // A pointer to a buffer of call stack's memory addresses
-    CBufFlat* stackBuf = NULL;
-    
-    iError = KErrNone;
-    
-    TUint32 callStackAddr;
-    
-    // Number of leaks
-    TInt leakCount = iLeakArray.Count();
-    
-    // Variable for the number of memory addresses in the call stack
-    TInt addrCount( 0 );
-    
-    // Buffer position
-    TInt pos( 0 );
-                     
-    // Go through all the leaks 
-    for ( TInt i = 0; i < leakCount; i++ ) 
-        {   
-        pos = 0;
-        
-        // Get the call stack buffer of the the leak i.
-        stackBuf = const_cast<CBufFlat*>( iLeakArray[i]->iCallstackBuf );
-    
-        // Read the first word of the buffer. This includes the number of
-        // memory addresses stored in the current stackBuf
-        stackBuf->Read( pos, &addrCount, KWordSize );
-    
-        // Move the position one word onwards.
-        pos += KWordSize;
-         
-        // Construct a buffer for the string to be written into the logging file
-        // because of this memory leak. MEM_LEAK: <Memory address> <Time stamp>
-        // <Allocation size> <Call stack address> <Call stack address> ...
-        HBufC8* leakString = 
-            HBufC8::NewL( KMemleakLength +
-                          KHexa32Length +
-                          KSpaceLength + KHexa64Length +
-                          KSpaceLength + KHexa32Length +
-                          ( addrCount * (KSpaceLength + KHexa32Length) ) +
-                          KNewlineLength 
-                        );
-            
-        // Make a pointer descriptor that points to leakString
-        TPtr8 leakStringPtr( leakString->Des() );
-        
-        // Append the tag implying a memory leak line in the data file
-        leakStringPtr.Append( KMemoryLeak );
-        
-        // Append the address of the memory leak         
-        TUint32 memAddress = iLeakArray[i]->iMemAddress;
-        leakStringPtr.AppendNum( memAddress, EHex );
-        
-        // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-        // format
-        leakStringPtr.Append( KSpace );
-        TInt64 allocTime = iLeakArray[i]->iAllocTime;
-        leakStringPtr.AppendNum( allocTime, EHex );
-        
-        // Append the size of the allocation in the 32-bit (max 8 characters) hexadecimal
-        // text format.
-        leakStringPtr.Append( KSpace );
-        TInt allocSize = iLeakArray[i]->iAllocSize;
-        leakStringPtr.AppendNum( allocSize, EHex );
-        
-        // Go through all call stack's memory addresses associated with
-        // the current memory leak 
-        for ( TInt j = 0; j < addrCount; j++ )
-            {
-            // Read the next call stack's memory address stored in the buffer.
-            stackBuf->Read( pos, &callStackAddr, KWordSize );
-            
-            // Append the read memory address as a hexadecimal number
-            leakStringPtr.AppendFormat( KHexaNumber,  callStackAddr );
-    
-            // Move the pos variable one word onwards.
-            pos += KWordSize;
-            }
-        
-        leakStringPtr.Append( KNewLine );
-        
-        // Set stackBuf to NULL, because it is not used anymore.
-        stackBuf = NULL;
-        
-        // Write the constructed string into the data file and return if error
-        iError = iFile.Write( *leakString );
-        
-        delete leakString;
-          
-        if ( iError != KErrNone )
-            {
-            return iError;
-            }
-              
-        } // The outer for
-   
-    LOGSTR1( "STSE End of CATStorageServerSession::PrintLeaks()" );
-    LOGMEM;
-   
-    // Empty the leak array and delete the referenced objects
-    iLeakArray.ResetAndDestroy();
-   
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::SetLogOption()
-// For setting the logging mode.
-// -----------------------------------------------------------------------------
-//
-void CATStorageServerSession::SetLogOption( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE void CATStorageServerSession::SetLogOption()" );
-        
-    // Panic both the client and the server, if this method is called in a wrong
-    // state (logging must not be ongoing when changing the mode of operation).
-    // So, the mode cannot be changed "on the fly".
-    if ( iLoggingOngoing )
-        {
-        PanicClient( EAToolInternalError, aMessage );
-        StorageServerPanic( KCategoryServer, EAToolInternalError );
-        }    
-
-    iLogOption = static_cast<TATLogOption>( aMessage.Int3() );
-    
-    // The default is EATLogToFile
-    if ( iLogOption == EATUseDefault )
-        {
-        iLogOption = KDefaultLoggingMode;
-        } 
-    }
-    
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogThroughTrace()
-// -----------------------------------------------------------------------------
-//
-TInt CATStorageServerSession::LogThroughTrace( const TDesC& aLogString ) const
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::LogThroughTrace()" );
-
-    // Return KErrNotSupported, if a logging session is not currently ongoing, or
-    // the logging mode is not EATLogToTrace
-    if ( !iLoggingOngoing || iLogOption != EATLogToTrace)
-        {
-        return KErrNotSupported;
-        }
-        
-    RDebug::Print( KTraceMessage, iProcessId, &aLogString );
-    
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::AllocInfoArray
-// -----------------------------------------------------------------------------
-// 
-RArray<TAllocInfo>& CATStorageServerSession::AllocInfoArray()
-    {
-    LOGSTR1( "STSE RArray<TAllocInfo>& CATStorageServerSession::AllocInfoArray()" );
-     
-    return iAllocInfoArray;
-    }    
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::PanicClient
-// Creates a panic in the associated client's code.
-// -----------------------------------------------------------------------------
-//
-void CATStorageServerSession::PanicClient( TInt aPanic, const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE void CATStorageServerSession::PanicClient()" );
-    
-    aMessage.Panic( KCategoryClient, aPanic );
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::GetLoggingFileL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::GetLoggingFileL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::GetLoggingFileL()" );
-    
-    iError = KErrNone;
-    
-    // Read the process ID at index 0
-    TUint processId = aMessage.Int0();
-    
-    // Get the dynamic process info array
-    RPointerArray<CATDynProcessInfo> dynProcessArray =
-                                             iStorageServer.DynProcessInfoArray();
-    
-    // Construct a CATDynProcessInfo object with the given process ID for searching
-    CATDynProcessInfo* dynProcessInfo = new (ELeave) CATDynProcessInfo( processId );
-    
-    // Find the index of a CATDynProcessInfo object with the given process ID
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    TInt index = dynProcessArray.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-    
-    // Return, if a process with the requested process ID was not found 
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-    
-    // Otherwise get the wanted dynamic process info
-    dynProcessInfo = dynProcessArray[index];
-
-    // Get the desired process's associated session object
-    CATStorageServerSession* sessionObject = dynProcessInfo->iSessionObject;
-            
-    // Write the whole buffer into aMessage at index 1 for the client
-    aMessage.WriteL( 1, sessionObject->iLogFile );
-                    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::GetUdebL()
-// -----------------------------------------------------------------------------
-//    
-TInt CATStorageServerSession::GetUdebL( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE TInt CATStorageServerSession::GetUdebL()" );
-    
-    iError = KErrNone;
-    
-    // Read the process ID at index 0
-    TUint processId = aMessage.Int0();
-    
-    // Get the dynamic process info array
-    RPointerArray<CATDynProcessInfo> dynProcessArray =
-                                             iStorageServer.DynProcessInfoArray();
-    
-    // Construct a CATDynProcessInfo object with the given process ID for searching
-    CATDynProcessInfo* dynProcessInfo = new (ELeave) CATDynProcessInfo( processId );
-    
-    // Find the index of a CATDynProcessInfo object with the given process ID
-    TLinearOrder<CATDynProcessInfo> order( CATDynProcessInfo::Compare );
-    TInt index = dynProcessArray.FindInOrder( dynProcessInfo, order );
-    delete dynProcessInfo;
-    dynProcessInfo = NULL;
-    
-    // Return, if a process with the requested process ID was not found 
-    if ( index == KErrNotFound )
-        {
-        return index;
-        }
-    
-    // Otherwise get the wanted dynamic process info
-    dynProcessInfo = dynProcessArray[index];
-
-    // Get the desired process's associated session object
-    CATStorageServerSession* sessionObject = dynProcessInfo->iSessionObject;
-    
-    TBuf8<KMaxVersionName> isUdeb;
-    if ( sessionObject->iIsUdeb == 1 )
-        {
-        isUdeb.Copy( KUdeb() );
-        }
-    else if ( sessionObject->iIsUdeb == 0 )
-        {
-        isUdeb.Copy( KUrel() );
-        }
-    else
-        {
-        return KErrNotFound;
-        }
-    // Write the whole buffer into aMessage at index 1 for the client
-    aMessage.WriteL( 1, isUdeb );
-    
-    return iError;
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::SetUdeb()
-// -----------------------------------------------------------------------------
-//    
-void CATStorageServerSession::SetUdeb( const RMessage2& aMessage )
-    {
-    LOGSTR1( "STSE void CATStorageServerSession::SetUdeb()" );
- 
-    iIsUdeb = aMessage.Int0();
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::LogAbnormalEnd()
-// -----------------------------------------------------------------------------
-//    
-void CATStorageServerSession::LogAbnormalEnd()
-    {
-    LOGSTR1( "STSE void CATStorageServerSession::LogAbnormalEnd()" );
-    
-    // Get the current universal time     
-    TInt64 timeFrom1970( GetTime() );
-        
-    switch ( iLogOption )
-        {
-        case EATLogToTrace:
-            {            
-            // Make a buffer that will be logged
-            TBuf<KEndAbnormalBufLength> traceBuf;
-            
-            // Write the process id to the buffer  
-            traceBuf.Format( KProcessEndAbnormalTrace, iProcessId );
-            
-            // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-            // format         
-            traceBuf.AppendNum( timeFrom1970, EHex );
-                
-            // Append a new line
-            traceBuf.Append( KNewLineTrace );
-            
-            // Write the buffer into the debug channel
-            RDebug::Print( KTraceMessage, iProcessId, &traceBuf );
-            }
-        break;
-        
-        case EATLogToFile:
-            {            
-            // Make a buffer that will be logged
-            TBuf8<KEndAbnormalBufLength> loggingBuf;
-            
-            // Write the process id to the buffer  
-            loggingBuf.Format( KProcessEndAbnormal, iProcessId );
-            
-            // Append the current time in the 64-bit (max 16 characters) hexadecimal text
-            // format         
-            loggingBuf.AppendNum( timeFrom1970, EHex );
-                
-            // Append a new line
-            loggingBuf.Append( KNewLine );
-            
-            // Write the buffer into a file (if possible in the current condition)
-            iFile.Write( loggingBuf );
-            }
-        break;
-              
-        default:
-            break;
-        }    
-    }
-
-// -----------------------------------------------------------------------------
-// CATStorageServerSession::GetTime()
-// Get the current universal time
-// -----------------------------------------------------------------------------
-//    
-TInt64 CATStorageServerSession::GetTime()
-    {
-    LOGSTR1( "STSE void CATStorageServerSession::GetTime()" );
-    
-    // Get the current universal time
-    iTime.UniversalTime();
-        
-    // Change the time format that tells the number of microseconds from January First,
-    // 0 AD nominal Gregorian, into a format that tells the number of microseconds from
-    // January First, 1970 AD nominal Gregorian. This is a more generic format and
-    // can be directly exploited by the PC code parsing the data file that this
-    // server generates.        
-    return ( iTime.Int64() - iMicroSecondsAt1970 );        
-    }
-
-//  End of File
--- a/analyzetool/storageserver/sis/atstorageserver.pkg	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-;
-; 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:
-;
-;
-; An installation file for AnalyzeTool StorageServer
-;
-
-;Language - standard language definitions
-&EN
-
-; standard SIS file header
-#{"ATStorageServer"},(0xA22E6C80),1,8,1
-
-;Localised Vendor name
-%{"Vendor-EN"}
-
-;Unique Vendor name
-:"Vendor"
-
-;Supports Series 60 v 3.0
-[0x101F7961], 0, 0, 0, {"Series60ProductID"}
-
-; 4 Files to install
-"\epoc32\release\armv5\urel\atoolstorageserver.exe"-"!:\sys\bin\atoolstorageserver.exe"
-"\epoc32\release\armv5\urel\atoolstorageserverclnt.dll"-"!:\sys\bin\atoolstorageserverclnt.dll"
--- a/analyzetool/storageserver/sis/atstorageserver_udeb.pkg	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-;
-; 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:
-;
-;
-; An installation file for AnalyzeTool StorageServer
-;
-
-;Language - standard language definitions
-&EN
-
-; standard SIS file header
-#{"ATStorageServer"},(0xA22E6C80),1,8,1
-
-;Localised Vendor name
-%{"Vendor-EN"}
-
-;Unique Vendor name
-:"Vendor"
-
-;Supports Series 60 v 3.0
-[0x101F7961], 0, 0, 0, {"Series60ProductID"}
-
-; 4 Files to install
-"\epoc32\release\armv5\udeb\atoolstorageserver.exe"-"!:\sys\bin\atoolstorageserver.exe"
-"\epoc32\release\armv5\udeb\atoolstorageserverclnt.dll"-"!:\sys\bin\atoolstorageserverclnt.dll"
--- a/memspy/CommandLine/Include/MemSpyCommandLine.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/CommandLine/Include/MemSpyCommandLine.h	Wed Sep 15 13:53:27 2010 +0300
@@ -22,6 +22,9 @@
 #include <e32base.h>
 #include <f32file.h>
 #include <badesca.h>
+#include <e32cons.h>
+
+#include "MemSpyCommands.h"
 
 #ifdef _DEBUG
 #   define TRACE( x ) x
@@ -36,21 +39,28 @@
 class RFs;
 class CCommandLineArguments;
 class RMemSpyEngineClientInterface;
+class CConsoleBase;
+class RMemSpySession;
 
-class CMemSpyCommandLine : public CBase
+class CMemSpyCommandLine :  public CActive
     {
 public:
-    static CMemSpyCommandLine* NewLC();
+    //static CMemSpyCommandLine* NewLC();
+	static CMemSpyCommandLine* NewLC( CConsoleBase& aConsole );
     ~CMemSpyCommandLine();
 
 private:
-    CMemSpyCommandLine();
+    //CMemSpyCommandLine();
+    CMemSpyCommandLine( CConsoleBase& aConsole );
     void ConstructL();
 
 public: // API
-    void PerformBatchL( const TDesC& aFileName );
+    //void PerformBatchL( const TDesC& aFileName ); 	//support of the batch files removed 
     void PerformOpL( const CCommandLineArguments& aCommandLine );
     void PerformSingleOpL( const TDesC& aCommand, const CDesCArray& aParameters );
+    //
+    //AO request method
+    void WaitForInput();
 
 private: // Internal methods
     void ConnectToMemSpyL();
@@ -60,10 +70,26 @@
     TInt FindBatchFile( TDes &aFileName );
     TInt FindFile( TDes &aFileName, const TDesC &aDirPath );
 
+private: // Console write methods
+    void RedrawInputPrompt();
+    void RedrawStatusMessage();
+    void RedrawStatusMessage( const TDesC& aMessage );
+    void ProcessCommandBufferL();
+    void RunL(); // from CActive
+    TInt RunError( TInt aError );
+    void DoCancel();
+    
 private: // Data members
     RFs iFsSession;
     RMemSpyEngineClientInterface* iMemSpy;
+    RMemSpySession* iMemSpySession;
     TBool iIsBatch; // For avoiding recursion
+    
+private: // Data members - console - write status messages
+    CConsoleBase& iConsole;
+    TPoint iCommandPromptPos;
+    TPoint iStatusMessagePos;
+    TBuf<KMemSpyMaxInputBufferLength> iCommandBuffer;
     };
 
 
--- a/memspy/CommandLine/Include/MemSpyCommands.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/CommandLine/Include/MemSpyCommands.h	Wed Sep 15 13:53:27 2010 +0300
@@ -18,39 +18,77 @@
 #ifndef MEMSPYCOMMANDS_H
 #define MEMSPYCOMMANDS_H
 
+// Literal constants
+_LIT( KMemSpyCLINewLine, "\r\n" );
+_LIT( KMemSpyCLIName, "MemSpy CommandLineInterpreter" );
+_LIT( KMemSpyCLIInputPrompt, " > %S" );
+_LIT( KMemSpyCLIWildcardCharacter, "*" );
 
-// Literal constants
-_LIT( KMemSpyCmdHeapDump, "CmdHeap_Dump" );
-_LIT( KMemSpyCmdHeapDumpKernel, "CmdHeap_Dump_Kernel" );
-_LIT( KMemSpyCmdHeapCompact, "CmdHeap_Compact" );
-_LIT( KMemSpyCmdSWMTForceUpdate, "CmdSWMT_ForceUpdate" );
-_LIT( KMemSpyCmdSWMTReset, "CmdSWMT_Reset" );
-_LIT( KMemSpyCmdOpenFile, "CmdOpenFile" );
-_LIT( KMemSpyCmdContainer, "CmdContainer" );
-_LIT( KMemSpyCmdBitmapsSave, "CmdBitmaps_Save" );
-_LIT( KMemSpyCmdRamDisableAknIconCache, "CmdRAM_DisableAknIconCache" );
-_LIT( KMemSpyCmdOutputToFile, "CmdOutput_ToFile" );
-_LIT( KMemSpyCmdOutputToTrace, "CmdOutput_ToTrace" );
+// Numerical constants
+const TInt KMemSpyMaxDisplayLengthThreadName = 48;
+const TInt KMemSpyMaxDisplayLengthSizeText = 14;
+const TInt KMemSpyMaxInputBufferLength = 200;
+
+// Key constants (S60)
+const TInt KMemSpyUiS60KeyCodeButtonOk = 2000;
+const TInt KMemSpyUiS60KeyCodeButtonCancel = 2001;
+const TInt KMemSpyUiS60KeyCodeRockerEnter = 63557;
 
+// Status messages
+_LIT( KOutputChangeMessage, "Change output mode opetarion in progress" );
+_LIT( KHeapDumpMessage, "Heap dump opetarion in progress" );
+_LIT( KSWMTMessage, "System Wide Memory Tracking opetarion in progress" );
 
-_LIT( KMemSpyCmdUiSendToBackground, "CmdUI_Background" );
-_LIT( KMemSpyCmdUiBringToForeground, "CmdUI_Foreground" );
+// Help text
+_LIT( KHelpMessage, "=== MemSpy CommandLineInterpreter Help ===\r\n" );
+_LIT( KHelpOutputCommand, "Change output mode to trace: 'memspy output trace'\r\n" );
+_LIT( KHelpOutputToFileCommand, "Change output mode to trace: 'memspy output file'\r\n" );
+_LIT( KHelpHeapDumpCommand, "Heap dump: 'memspy heapdup <all | kernel | user heap filter >'\r\n" );
+_LIT( KHelpSwmtCommand, "SWMT: 'memspy swmt <starttimer <value in seconds> | stop timer | dumpnow > <categories>'\r\n" );
+_LIT( KHelpKillServerCommand, "Kill server: 'memspy killserver'\r\n" );
+_LIT( KHelpCommand, "Press 'c' to continue" );
+
+//new commands
 
-_LIT( KMemSpyCmdUiExit, "CmdUI_Exit" );
+//HELP
+_LIT( KMemSpyCmdHelp1, "-?" );
+_LIT( KMemSpyCmdHelp2, "-h" );
+_LIT( KMemSpyCmdHelp3, "-help" );
+_LIT( KMemSpyCmdHelp4, "--help" );
+
+//OUTPUT
+_LIT( KMemSpyCmdOutput, "output" );
+_LIT( KMemSpyCmdOutputParameterTrace, "trace" );
+_LIT( KMemSpyCmdOutputParameterFile, "file" );
+//<directory> //parameter to be parsed
+
+//HEAP DUMP
+_LIT( KMemSpyCmdHeapDump, "heapdump" );
+_LIT( KMemSpyCmdHeapDumpParameterAll, "all" ); //default
+_LIT( KMemSpyCmdHeapDumpParameterKernel, "kernel" ); //kernel heap dump
 
-_LIT( KMemSpyCmdSWMTTypeHeap,                    "HEAP" );
-_LIT( KMemSpyCmdSWMTTypeChunk,                   "CHNK" );
-_LIT( KMemSpyCmdSWMTTypeCode,                    "CODE" );
-_LIT( KMemSpyCmdSWMTTypeStack,                   "STAK" );
-_LIT( KMemSpyCmdSWMTTypeGlobalData,              "GLOD" );
-_LIT( KMemSpyCmdSWMTTypeRamDrive,                "RAMD" );
-_LIT( KMemSpyCmdSWMTTypeOpenFile,                "FILE" );
-_LIT( KMemSpyCmdSWMTTypeDiskSpace,               "DISK" );
-_LIT( KMemSpyCmdSWMTTypeHandleGeneric,           "HGEN" );
-_LIT( KMemSpyCmdSWMTTypeFbserv,                  "FABS" );
-_LIT( KMemSpyCmdSWMTTypeFileServerCache,         "F32C" );
-_LIT( KMemSpyCmdSWMTTypeSystemMemory,            "SYSM" );
-_LIT( KMemSpyCmdSWMTTypeWindowGroup,             "WNDG" );
-_LIT( KMemSpyCmdSWMTTypeHeapFilter,              "HEAPFilter:" );
+//SWMT
+_LIT( KMemSpyCmdSwmt, "swmt" );
+_LIT( KMemSpyCmdSwmtParameterStarttimer, "starttimer" ); //<value in seconds> optionaly
+_LIT( KMemSpyCmdSwmtParameterStoptimer, "stoptimer" );
+_LIT( KMemSpyCmdSwmtParameterDumpnow, "dumpnow" );
+
+//KILL SERVER
+_LIT( KMemSpyCmdKillServer, "killserver"); //kills the server in case of it is running
 
+//SWMT CATEGORIES (TYPES)
+_LIT( KMemSpyCmdSWMTTypeHeap,                    "heap" );
+_LIT( KMemSpyCmdSWMTTypeChunk,                   "chnk" );
+_LIT( KMemSpyCmdSWMTTypeCode,                    "code" );
+_LIT( KMemSpyCmdSWMTTypeStack,                   "stak" );
+_LIT( KMemSpyCmdSWMTTypeGlobalData,              "glob" );
+_LIT( KMemSpyCmdSWMTTypeRamDrive,                "ramd" );
+_LIT( KMemSpyCmdSWMTTypeOpenFile,                "file" );
+_LIT( KMemSpyCmdSWMTTypeDiskSpace,               "disk" );
+_LIT( KMemSpyCmdSWMTTypeHandleGeneric,           "hgen" );
+_LIT( KMemSpyCmdSWMTTypeFbserv,                  "fabs" );
+_LIT( KMemSpyCmdSWMTTypeFileServerCache,         "f32c" );
+_LIT( KMemSpyCmdSWMTTypeSystemMemory,            "sysm" );
+_LIT( KMemSpyCmdSWMTTypeWindowGroup,             "wndg" );
+_LIT( KMemSpyCmdSWMTTypeAll,					 "all"	); //default value, dumps all categories expect heap dumps	
 #endif
--- a/memspy/CommandLine/Source/MemSpyCommandLine.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/CommandLine/Source/MemSpyCommandLine.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -21,148 +21,52 @@
 #include <bacline.h>
 #include <bautils.h>
 #include <memspyengineclientinterface.h>
+#include <memspysession.h>
 #include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h>
 
 // User includes
 #include "MemSpyCommands.h"
 
-
+/*
 CMemSpyCommandLine::CMemSpyCommandLine()
-    {
+    {	
     }
+*/
 
+CMemSpyCommandLine::CMemSpyCommandLine( CConsoleBase& aConsole )
+	: CActive( EPriorityHigh ), iConsole( aConsole )
+    {	
+	CActiveScheduler::Add( this );
+    }
 
 CMemSpyCommandLine::~CMemSpyCommandLine()
     {
-    if ( iMemSpy )
+	Cancel();
+	
+    if ( iMemSpySession )
         {
-        iMemSpy->Close();
+        iMemSpySession->Close();
         }
-    delete iMemSpy;
+    delete iMemSpySession;
     iFsSession.Close();
     }
 
 
 void CMemSpyCommandLine::ConstructL()
     {
-    User::LeaveIfError( iFsSession.Connect() );
-    iMemSpy = new(ELeave) RMemSpyEngineClientInterface();
-    ConnectToMemSpyL();
+    User::LeaveIfError( iFsSession.Connect() );   
+    iMemSpySession = new(ELeave) RMemSpySession();
+    ConnectToMemSpyL();                    
     }
 
-
-CMemSpyCommandLine* CMemSpyCommandLine::NewLC()
+CMemSpyCommandLine* CMemSpyCommandLine::NewLC( CConsoleBase& aConsole )
     {
-    CMemSpyCommandLine* self = new(ELeave) CMemSpyCommandLine();
+    CMemSpyCommandLine* self = new(ELeave) CMemSpyCommandLine( aConsole );
     CleanupStack::PushL( self );
     self->ConstructL();
     return self;
     }
 
-
-void CMemSpyCommandLine::PerformBatchL( const TDesC& aFileName )
-    {
-    TInt err = KErrNone;
-    RFile file;
-    err = file.Open( iFsSession, aFileName, EFileRead );
-    TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformBatchL() - START - this: 0x%08x, openErr: %d, fileName: %S"), this, err, &aFileName ) );
-    User::LeaveIfError( err );
-
-    CleanupClosePushL( file );
-    CDesCArray* lines = ReadLinesL( file );
-    CleanupStack::PopAndDestroy( &file );
-    CleanupStack::PushL( lines );
-    
-    const TInt count = lines->Count();
-    TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - got %d lines", count ) );
-    iIsBatch = ETrue;
-    for( TInt i=0; i<count; i++ )
-        {
-        const TPtrC pLine( (*lines)[ i ] );
-        TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - processing line[%03d] \"%S\""), i, &pLine ) );
-    
-        // Must be at least 3 chars big, i.e. '[' and <command> and then ']'
-        if  ( pLine.Length() <= 2 || pLine[ 0 ] != '[' )
-            {
-            TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - ignoring line: \"%S\""), &pLine ) );
-            }
-        else if  ( pLine[0] == '[' )
-            {
-            // Try to find end of command...
-            const TInt posOfClosingArgChar = pLine.Locate( ']' );
-            if  ( posOfClosingArgChar >= 2 )
-                {
-                // Get command
-                const TPtrC pCommand( pLine.Mid( 1, posOfClosingArgChar - 1 ) );
-                TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - got command: %S"), &pCommand ) );
-
-                // Next, try to get any args
-                CDesCArrayFlat* args = new(ELeave) CDesCArrayFlat( 2 );
-                CleanupStack::PushL( args );
-
-                // There must be a mandatory space between closing ] and start of args...
-                // E.g.:
-                //
-                //  [CMD] ARG
-                //
-                const TInt remainderLength = pLine.Length() - posOfClosingArgChar;
-                if  ( remainderLength > 1 )
-                    {
-                    const TPtrC remainder( pLine.Mid( posOfClosingArgChar + 1 ) );
-                    TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - got remainder: %S"), &pLine ) );
-
-                    // Extract arguments separated by tabs or space characters
-                    // and store in arguments array
-                    HBufC* argText = HBufC::NewLC( pLine.Length() + 1 );
-                    TPtr pArgText( argText->Des() );
-                    for( TInt j=0; j<remainder.Length(); j++ )
-                        {
-                        const TChar c( remainder[ j ] );
-                        //
-                        if  ( c == '\t' || c == ' ' )
-                            {
-                            pArgText.Trim();
-                            if  ( pArgText.Length() )
-                                {
-                                TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - arg[%02d] %S"), args->Count(), &pArgText ) );
-                                args->AppendL( pArgText );
-                                pArgText.Zero();
-                                }
-                            }
-                        else
-                            {
-                            pArgText.Append( c );
-                            }
-                        }
-
-                    // Save leftovers...
-                    pArgText.Trim();
-                    if  ( pArgText.Length() )
-                        {
-                        TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - arg[%02d] %S"), args->Count(), &pArgText ) );
-                        args->AppendL( pArgText );
-                        }
-
-                    CleanupStack::PopAndDestroy( argText );
-                    }
-
-                // Now we can perform the operation!
-                PerformSingleOpL( pCommand, *args );
-
-                CleanupStack::PopAndDestroy( args );
-                }
-            }
-
-        TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - processing line: \"%S\""), &pLine ) );
-        }
-
-    iIsBatch = EFalse;
-    
-    CleanupStack::PopAndDestroy( lines );
-    TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformBatchL() - END - this: 0x%08x, fileName: %S"), this, &aFileName ) );
-    }
-
-
 void CMemSpyCommandLine::PerformOpL( const CCommandLineArguments& aCommandLine )
     {
     const TInt count = aCommandLine.Count();
@@ -218,125 +122,187 @@
     batchFile.Append( aCommand );
     
     TInt err = KErrNotSupported;
-    if  ( aCommand.CompareF( KMemSpyCmdSWMTForceUpdate ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - SWMT_ForceUpdate", this ) );
-        if ( paramCount > 0 )
-            {
-            TInt categories( 0 );
-            TName threadNameFilter;
-            TRAP( err, ParseSWMTParametersL( aParameters, categories, threadNameFilter ) );            
-            if ( !err )
-                {
-                err = iMemSpy->SystemWideMemoryTrackerCategoriesSet( categories );
-                if ( !err && threadNameFilter.Length() > 0 )
-                    {
-                    err = iMemSpy->SystemWideMemoryTrackerThreadFilterSet( threadNameFilter );
-                    }
-                }
-            }
-        if ( !err )
-            {
-            err = iMemSpy->PerformOperation( EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate );
-            }
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdSWMTReset ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - SWMT_Reset", this ) );
-        err = iMemSpy->PerformOperation( EMemSpyClientServerOpSystemWideMemoryTrackingReset );
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdHeapDumpKernel ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_DumpKernel", this ) );
-        err = iMemSpy->PerformOperation( EMemSpyClientServerOpHeapData, KMemSpyClientServerThreadIdKernel );
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdHeapCompact ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Compact", this ) );
-        err = iMemSpy->PerformOperation( EMemSpyClientServerOpHeapInfoCompact );
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdContainer ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Container", this ) );
-        err = iMemSpy->PerformOperation( EMemSpyClientServerOpEnumerateKernelContainerAll );
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdBitmapsSave ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Bitmaps_Save", this ) );
-        err = iMemSpy->SaveAllBitmaps();
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdRamDisableAknIconCache ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Ram_DisableAknIconCache", this ) );
-        err = iMemSpy->DisableAknIconCache();
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdOutputToFile ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Output_ToFile", this ) );
-        err = iMemSpy->SwitchOutputModeFile();
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdOutputToTrace ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Output_ToTrace", this ) );
-        err = iMemSpy->SwitchOutputModeTrace();
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdUiSendToBackground ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - UI_Background", this ) );
-        err = iMemSpy->SendToBackground();
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdUiBringToForeground ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - UI_Foreground", this ) );
-        err = iMemSpy->BringToForeground();
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdUiExit ) == 0 )
-        {
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - UI_Exit", this ) );
-        err = iMemSpy->Exit();
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdHeapDump ) == 0 )
-        {
-        if  ( paramCount == 0 )
-            {
-            // Dump heap data for all threads
-            TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Dump (all threads)", this ) );
-            err = iMemSpy->PerformOperation( EMemSpyClientServerOpHeapData );
-            }
-        else if ( paramCount >= 1 )
-            {
-            // Dump heap data for named thread
-            const TPtrC pThreadName( aParameters[ 0 ] );
-            TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Dump (%S)"), this, &pThreadName ) );
-            err = iMemSpy->PerformOperation( EMemSpyClientServerOpHeapData, pThreadName );
-            }
-        }
-    else if ( aCommand.CompareF( KMemSpyCmdOpenFile ) == 0 )
-        {
-        if  ( paramCount == 0 )
-            {
-            // Dump heap data for all threads
-            TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - OpenFile (all threads)", this ) );
-            err = iMemSpy->PerformOperation( EMemSpyClientServerOpOpenFiles );
-            }
-        else if ( paramCount >= 1 )
-            {
-            // Dump heap data for named thread
-            const TPtrC pThreadName( aParameters[ 0 ] );
-            TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - OpenFile (%S)"), this, &pThreadName ) );
-            err = iMemSpy->PerformOperation( EMemSpyClientServerOpOpenFiles, pThreadName );
-            }
-        }
-    else if ( !iIsBatch && FindBatchFile( batchFile ) == KErrNone )
-        {
-        TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Batch file: %S"), this, &batchFile ) );
-        PerformBatchL( batchFile );
-        }
-    else
-        {
-        TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Unsupported Command: %S"), this, &aCommand ) );
-        }
+    TInt error = KErrNotSupported;
+    
+    // --- HELP
+    if ( aCommand.CompareF( KMemSpyCmdHelp1) == 0 || 
+    	 aCommand.CompareF( KMemSpyCmdHelp2) == 0 ||
+    	 aCommand.CompareF( KMemSpyCmdHelp3) == 0 ||
+    	 aCommand.CompareF( KMemSpyCmdHelp4) == 0 )
+    	{
+		iConsole.Write( KHelpMessage );
+		iConsole.Write( KMemSpyCLINewLine );		
+		iConsole.Write( KHelpOutputCommand );
+		iConsole.Write( KHelpOutputToFileCommand );
+		iConsole.Write( KHelpHeapDumpCommand );
+		iConsole.Write( KHelpSwmtCommand );
+		iConsole.Write( KHelpKillServerCommand );
+		iConsole.Write( KMemSpyCLINewLine );
+		iConsole.Write( KHelpCommand );
 
+	    // Show input prompt.
+	    iCommandPromptPos = iConsole.CursorPos();
+	    RedrawInputPrompt();
+	    WaitForInput();
+	    
+	    CActiveScheduler::Start();
+    	}
+    // --- OUTPUT
+    //TODO: directory option to be added
+    else if  ( aCommand.CompareF( KMemSpyCmdOutput ) == 0 )	//change output mode   
+    	{    						
+		if( paramCount >= 1 )
+			{
+			if( aParameters[0].CompareF( KMemSpyCmdOutputParameterFile ) == 0 )
+				{
+				if( paramCount == 2 )
+					{
+					TBuf<KMaxFileName> directory;
+					directory.Copy( aParameters[1] );
+					iMemSpySession->SwitchOutputToFileL( directory );
+					}
+				else
+					{
+					iMemSpySession->SwitchOutputToFileL( KNullDesC );
+					}
+				}
+			else if( aParameters[0].CompareF( KMemSpyCmdOutputParameterTrace ) == 0)
+				{
+				TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Output Trace", this ) );
+				iMemSpySession->SwitchOutputToTraceL();
+				}
+			}		           
+    	}    	
+    // --- HEAP DUMP    
+    else if ( aCommand.CompareF( KMemSpyCmdHeapDump) == 0 )    	
+		{		
+		RedrawStatusMessage( KHeapDumpMessage );
+		
+		if( paramCount == 0 ) // no parameter - dump all heap data + kernel heap at the end
+			{		
+		
+			TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Dump (all threads)", this ) );			
+			// Dump heap data for all threads - Thread agnostic operation					
+			iMemSpySession->OutputHeapData();
+			// Dump kernel heap data
+			iMemSpySession->OutputThreadHeapDataL( KMemSpyClientServerThreadIdKernel );					
+			}
+		else if( paramCount >= 1)
+			{
+			if( aParameters[0].CompareF( KMemSpyCmdHeapDumpParameterAll ) == 0 )
+				{
+				iMemSpySession->OutputHeapData();				
+				iMemSpySession->OutputThreadHeapDataL( KMemSpyClientServerThreadIdKernel );				
+				}
+			else if( aParameters[0].CompareF( KMemSpyCmdHeapDumpParameterKernel ) == 0 )
+				{
+				TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_DumpKernel", this ) );
+				iMemSpySession->OutputThreadHeapDataL( KMemSpyClientServerThreadIdKernel );				
+				}
+			else
+				{				
+				// Dump heap data for named thread - filter
+				const TPtrC pThreadName( aParameters[0] );
+				TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Dump (%S)"), this, &pThreadName ) );				
+				iMemSpySession->OutputThreadHeapDataL( pThreadName );
+				}
+  			}
+		}
+    
+    // --- SYSTEM WIDE MEMORY TRACKING    
+    else if( aCommand.CompareF( KMemSpyCmdSwmt ) == 0 )
+    	{    
+		RedrawStatusMessage( KSWMTMessage );
+    		
+		TInt categories( 0 );
+		TName threadNameFilter;
+		
+		if( paramCount == 0 ) //default state -> "dumpnow" command with "all" categories
+			{
+			TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - dumpnow command", this ) );
+			TInt category = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll;
+			iMemSpySession->SetSwmtCategoriesL( category );			
+			iMemSpySession->ForceSwmtUpdateL();			
+			}
+		else if( paramCount >= 1)
+			{
+			const TPtrC pParam( aParameters[0] );
+			if( pParam.CompareF( KMemSpyCmdSwmtParameterStarttimer) == 0 ) // "starttimer" - start tracking
+				{
+				TInt result(0);
+				categories = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll;
+				iMemSpySession->SetSwmtTimerIntervalL( KMemSpySysMemTrackerConfigMinTimerPeriod );
+				
+				if( paramCount >= 2 ) // user gave some optional parameters - <categories> or <value in seconds>
+					{					
+					TLex lex( aParameters[1] );
+				    if ( lex.Val( result ) == KErrNone ) //if 2nd parameter is not number, then parse parameters
+				    	{
+						if( result >= KMemSpySysMemTrackerConfigMinTimerPeriod && result <= KMemSpySysMemTrackerConfigMaxTimerPeriod )
+							{
+							iMemSpySession->SetSwmtTimerIntervalL( result );							;
+							}											
+				    	}				   
+				    TRAP( err, ParseSWMTParametersL( aParameters, categories, threadNameFilter) );
+					}																				
+				
+				//if( !err )
+				//	{
+					/*
+					_LIT( KPressS, "Press 's' to stop the timer " );
+					iConsole.Write( KPressS );
+					
+					iCommandPromptPos = iConsole.CursorPos();					
+					RedrawInputPrompt();					
+					WaitForInput();
+					*/
+					    
+					iMemSpySession->StartSwmtTimerL();
+					
+					//CActiveScheduler::Start();									
+				//	}	
+				}
+			else if( pParam.CompareF( KMemSpyCmdSwmtParameterStoptimer) == 0 ) // "stoptime" - stop tracking
+				{
+				iMemSpySession->StopSwmtTimerL();
+				}
+			else if( pParam.CompareF( KMemSpyCmdSwmtParameterDumpnow ) == 0 ) // "dumpnow" - runs one tracking cycle (CmdSWMT_ForceUpdate before)
+				{
+				categories = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll;
+				if( paramCount >= 2 ) // user gave some optional parameters - <categories>
+					{
+					TRAP( err, ParseSWMTParametersL( aParameters, categories, threadNameFilter) );
+					}				
+																
+				if( !err )
+					{
+					iMemSpySession->SetSwmtCategoriesL( categories );
+					iMemSpySession->ForceSwmtUpdateL();
+					}												
+				}							
+			else //no parameters ("starttimer / stoptimer / dumpnow"), just categories / thread filter
+				 //so dumpnow is used as default with category / thread specified
+				{
+				TRAP( err, ParseSWMTParametersL( aParameters, categories, threadNameFilter) );
+				if( !err )
+					{
+					iMemSpySession->SetSwmtCategoriesL( categories );
+					if( threadNameFilter.Length() > 0 )
+						{
+						iMemSpySession->SetSwmtFilter( threadNameFilter );
+						}
+					}								
+					iMemSpySession->ForceSwmtUpdateL();				
+				}
+			}
+    	}
+    // --- KILL SERVER
+    else if ( aCommand.CompareF( KMemSpyCmdKillServer ) == 0 )
+    	{    
+    	}
+    
+   // RedrawStatusMessage();   
+    
     TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - END - err: %d, this: 0x%08x, cmd: %S" ), err, this, &aCommand ) );
 
     // Calculate duration
@@ -364,7 +330,7 @@
     {
     TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ConnectToMemSpyL() - START - this: 0x%08x", this ) );
 
-    TInt err = iMemSpy->Connect();
+    TInt err = iMemSpySession->Connect();
     TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ConnectToMemSpyL() - connect #1 err: %d, this: 0x%08x", err, this ) );
 
     if  ( err == KErrNotFound )
@@ -390,47 +356,48 @@
 
     TInt err = KErrGeneral;
     RProcess proc;
-
-    // First try with s60 UI
-    err = proc.Create( KMemSpyProcessName1, KNullDesC );
-    if  ( err == KErrNone )
-        {
-        TFullName fullName;
-        proc.FullName( fullName );
-        TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Create S60 UI process successfully... - this: 0x%08x, name: %S"), this, &fullName ) );
+    
+    // Try to run server first
+    err = proc.Create( KMemSpyProcessName0, KNullDesC );
+    if ( err == KErrNone )
+    	{
+		TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Create server process successfully... - this: 0x%08x", this ) );
 
-        TRequestStatus status;
-        proc.Rendezvous( status );
-        proc.Resume();
+		TRequestStatus status;
+		proc.Rendezvous( status );
+		proc.Resume();
+
+		TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - MemSpy resumed, waiting for Rendezvous... - this: 0x%08x", this ) );
 
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - MemSpy resumed, waiting for Rendezvous... - this: 0x%08x", this ) );
-        User::WaitForRequest( status );
-        err = status.Int();
-        proc.Close();
+		User::WaitForRequest( status );
+		err = status.Int();
+		proc.Close();
+
+		TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Rendezvous complete: %d, this: 0x%08x", err, this ) );
+    	}
 
-        TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Rendezvous complete: %d, this: 0x%08x", err, this ) );
-        }
-    if  ( err != KErrNone )
-        {
-        // Try console UI
-        err = proc.Create( KMemSpyProcessName2, KNullDesC );
-        if  ( err == KErrNone )
-            {
-            TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Create Console UI process successfully... - this: 0x%08x", this ) );
-
-            TRequestStatus status;
-            proc.Rendezvous( status );
-            proc.Resume();
-
-            TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - MemSpy resumed, waiting for Rendezvous... - this: 0x%08x", this ) );
-
-            User::WaitForRequest( status );
-            err = status.Int();
-            proc.Close();
-
-            TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Rendezvous complete: %d, this: 0x%08x", err, this ) );
-            }
-        }
+    // If server is not available, try with s60 UI
+    if ( err != KErrNone )
+    	{
+		err = proc.Create( KMemSpyProcessName1, KNullDesC );
+		if  ( err == KErrNone )
+			{
+			TFullName fullName;
+			proc.FullName( fullName );
+			TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Create S60 UI process successfully... - this: 0x%08x, name: %S"), this, &fullName ) );
+	
+			TRequestStatus status;
+			proc.Rendezvous( status );
+			proc.Resume();
+	
+			TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - MemSpy resumed, waiting for Rendezvous... - this: 0x%08x", this ) );
+			User::WaitForRequest( status );
+			err = status.Int();
+			proc.Close();
+	
+			TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Rendezvous complete: %d, this: 0x%08x", err, this ) );
+			}
+    	}
 
     TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - final error: %d, this: 0x%08x", err, this ) );
     User::LeaveIfError( err );
@@ -534,11 +501,12 @@
     // In that case other parameters are ignored.
     TLex lex( aParameters[ 0 ] );
     if ( lex.Val( result ) != KErrNone )
-        {
+        {		
         // Parameters were given in text form:
         const TInt count( aParameters.Count() );
         for ( TInt i = 0; i < count ; i++ )
             {
+			lex = aParameters[ i ]; //check if num.
             if ( aParameters[i].CompareF( KMemSpyCmdSWMTTypeHeap ) == 0 )
                 result |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserHeap |
                           TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryKernelHeap;
@@ -565,17 +533,31 @@
                 result |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryFileServerCache;
             else if ( aParameters[i].CompareF( KMemSpyCmdSWMTTypeSystemMemory ) == 0 )
                 result |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategorySystemMemory;
-            else if ( aParameters[i].CompareF( KMemSpyCmdSWMTTypeWindowGroup ) == 0 )
-                result |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryWindowGroups;
-            else if ( aParameters[i].Find( KMemSpyCmdSWMTTypeHeapFilter ) == 0 )
-                {
-                aFilter.Copy( aParameters[i].Right( aParameters[i].Length() -11 ) );
+            else if ( aParameters[i].CompareF( KMemSpyCmdSWMTTypeWindowGroup ) == 0 )            	
+                result |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryWindowGroups;            
+            else if ( aParameters[i].CompareF( KMemSpyCmdSWMTTypeAll) == 0 ) //"all" category added
+            	result = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll;
+            else if ( aParameters[i].CompareF( KMemSpyCmdSwmtParameterDumpnow) == 0 || 
+            		aParameters[i].CompareF( KMemSpyCmdSwmtParameterStarttimer) == 0 || 
+            		aParameters[i].CompareF( KMemSpyCmdSwmtParameterStoptimer) == 0 )
+            	{    
+				TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine:: command parameter") );
+            	}
+            else if ( lex.Val( result ) == KErrNone )
+            	{
+				TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine:: number - timer period") );
+            	}
+            else// if ( aParameters[i].Find( KMemSpyCmdSWMTTypeHeapFilter ) == 0 )
+                {				
+                aFilter.Copy( aParameters[i].Right( aParameters[i].Length() -11 ) );              
                 }
-            else
-                User::Leave( KErrNotSupported );
+          /*  else
+            	{
+                //User::Leave( KErrNotSupported );            	            
+            	}*/
             }
         }
-    else if ( aParameters.Count() > 1 && aParameters[1].Find( KMemSpyCmdSWMTTypeHeapFilter ) == 0 )
+    else if ( aParameters.Count() > 1 )//&& aParameters[1].Find( KMemSpyCmdSWMTTypeHeapFilter ) == 0 )
         {
         aFilter.Copy( aParameters[1].Right( aParameters[1].Length() -11 ) );
         }
@@ -607,3 +589,110 @@
     return err;
     }
 
+
+//CLI status messages methods
+void CMemSpyCommandLine::RedrawInputPrompt()
+    {
+    iConsole.SetCursorPosAbs( iCommandPromptPos );
+    iConsole.ClearToEndOfLine();
+    iConsole.Printf( KMemSpyCLIInputPrompt, &iCommandBuffer );
+    }
+
+
+void CMemSpyCommandLine::RedrawStatusMessage()
+    {
+    RedrawStatusMessage( KNullDesC );
+    }
+
+
+void CMemSpyCommandLine::RedrawStatusMessage( const TDesC& aMessage )
+    {
+    iConsole.SetCursorPosAbs( iStatusMessagePos );
+    iConsole.ClearToEndOfLine();
+    iConsole.Write( aMessage );
+    iConsole.Write( KMemSpyCLINewLine );
+    }
+
+void CMemSpyCommandLine::WaitForInput()
+    {
+    ASSERT( !IsActive() );
+    iConsole.Read( iStatus );
+    SetActive();
+    }
+
+void CMemSpyCommandLine::DoCancel()
+    {
+    iConsole.ReadCancel();
+    }
+
+void CMemSpyCommandLine::RunL()
+    {
+    TKeyCode key = iConsole.KeyCode();
+    //
+    if  ( key == EKeyEnter || key == KMemSpyUiS60KeyCodeButtonOk || key == KMemSpyUiS60KeyCodeRockerEnter )
+        {
+        TRAP_IGNORE( ProcessCommandBufferL() );
+        }
+    else
+        {
+        TChar character( key );
+        if  ( character.IsPrint() )
+            {
+            if  ( iCommandBuffer.Length() < iCommandBuffer.MaxLength() )
+                {
+                iCommandBuffer.Append( TChar( key ) );
+                }
+
+            RedrawInputPrompt();
+            }
+        }
+
+    WaitForInput();
+    }
+
+TInt CMemSpyCommandLine::RunError( TInt aError )
+	{	
+	return KErrNone;
+	}
+
+void CMemSpyCommandLine::ProcessCommandBufferL()
+    {
+    iCommandBuffer.Trim();
+    //
+#ifdef _DEBUG
+    RDebug::Print( _L("[MCon] CMemSpyConsoleMenu::ProcessCommandBufferL() - cmd: [%S]"), &iCommandBuffer );
+#endif
+    //
+    TBool validCommand = EFalse;
+    if  ( iCommandBuffer.Length() == 1 )
+        {
+        // Reset if not recognised...
+        validCommand = ETrue;
+
+        const TChar cmd = iCommandBuffer[ 0 ]; 
+        switch( cmd )
+            {
+        	case 's':
+        	case 'S':
+        		{
+        		iMemSpy->PerformOperation( EMemSpyClientServerOpSystemWideMemoryTrackingTimerStop );
+        		
+        		CActiveScheduler::Stop();
+        		return;
+        		}
+        	case 'c':
+        	case 'C':
+        		CActiveScheduler::Stop();
+        		return;            
+        	default:
+        		validCommand = EFalse;
+        		break;
+            }
+        }    
+    if  ( !validCommand )
+        {
+        _LIT( KInvalidEntry, "*** ERROR - Invalid Command ***" );
+        RedrawStatusMessage( KInvalidEntry );
+        RedrawInputPrompt();
+        }
+    }
--- a/memspy/CommandLine/Source/MemSpyCommandLineMain.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/CommandLine/Source/MemSpyCommandLineMain.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -25,7 +25,7 @@
 
 // User includes
 #include "MemSpyCommandLine.h"
-
+#include "MemSpyCommands.h"
 
 // ---------------------------------------------------------------------------
 // DoMainL()
@@ -38,21 +38,27 @@
     CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
     CActiveScheduler::Install( scheduler );
     CleanupStack::PushL( scheduler );
-
+    
     // Get command line 
     CCommandLineArguments* args = CCommandLineArguments::NewLC();
-
+    
+    //--
+    CConsoleBase* console = Console::NewL( KMemSpyCLIName, TSize( KConsFullScreen, KConsFullScreen ) );
+    CleanupStack::PushL( console );
+    //--
+    
     // Command line manager
-    CMemSpyCommandLine* commandLineMgr = CMemSpyCommandLine::NewLC();
+    CMemSpyCommandLine* commandLineMgr = CMemSpyCommandLine::NewLC( *console );
 
     // Play nicely with external processes
     RProcess::Rendezvous( KErrNone );
 
     // Perform op
-    commandLineMgr->PerformOpL( *args );
-
+    commandLineMgr->PerformOpL( *args );  
+        
     // Tidy up
-    CleanupStack::PopAndDestroy( 3, scheduler ); // scheduler, args, commandLineMgr
+    //CleanupStack::PopAndDestroy( 3, scheduler ); // scheduler, args, commandLineMgr
+    CleanupStack::PopAndDestroy( 4 ); // scheduler, args,  console, commandLineMgr
     }
    
 
--- a/memspy/CommandLine/group/MemSpyCommandLine.mmp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/CommandLine/group/MemSpyCommandLine.mmp	Wed Sep 15 13:53:27 2010 +0300
@@ -25,7 +25,7 @@
 VENDORID		VID_DEFAULT
 SMPSAFE
 
-CAPABILITY			none
+CAPABILITY		WriteDeviceData
 
 SOURCEPATH      ../Source
 SOURCE          MemSpyCommandLine.cpp
@@ -37,6 +37,12 @@
 
 OS_LAYER_SYSTEMINCLUDE
 
-LIBRARY					euser.lib efsrv.lib bafl.lib 
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         MemSpyClient.lib
+
+LIBRARY					euser.lib 
+LIBRARY 				efsrv.lib 
+LIBRARY 				bafl.lib 
 
 
--- a/memspy/Console/Include/ConsoleMenu.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Console/Include/ConsoleMenu.h	Wed Sep 15 13:53:27 2010 +0300
@@ -26,22 +26,22 @@
 // Engine includes
 #include <memspy/engine/memspyengine.h>
 #include <memspy/engine/memspyengineobserver.h>
-
+#include <memspysession.h>
 // User includes
 #include "ConsoleConstants.h"
 
 // Classes referenced
 class CConsoleBase;
-
+class RMemSpySession;
 
 class CMemSpyConsoleMenu : public CActive, public MMemSpyEngineObserver
     {
 public:
-    static CMemSpyConsoleMenu* NewLC( CMemSpyEngine& aEngine, CConsoleBase& aConsole );
+    static CMemSpyConsoleMenu* NewLC( RMemSpySession& aSession, CConsoleBase& aConsole );
     ~CMemSpyConsoleMenu();
 
 private:
-    CMemSpyConsoleMenu( CMemSpyEngine& aEngine, CConsoleBase& aConsole );
+    CMemSpyConsoleMenu( RMemSpySession& aEngine, CConsoleBase& aConsole );
     void ConstructL();
 
 public: // API
@@ -74,8 +74,10 @@
     void InitiateMemSpyClientServerOperationL( TInt aOpCode );
 
 private: // Data members
-    CMemSpyEngine& iEngine;
+    RMemSpySession& iSession;
     CConsoleBase& iConsole;
+    
+    TMemSpyOutputType iOutputType;
     //
     TBuf<KMemSpyMaxInputBufferLength> iCommandBuffer;
     TPoint iCommandPromptPos;
--- a/memspy/Console/Source/ConsoleDWOperation.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Console/Source/ConsoleDWOperation.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -56,7 +56,7 @@
 #endif
 
     iWaiter = new(ELeave) CActiveSchedulerWait();
-    iOperation = CMemSpyDeviceWideOperations::NewL( iEngine, *this, aOperation );
+    //iOperation = CMemSpyDeviceWideOperations::NewL( iEngine, *this, aOperation );
 
 #ifdef _DEBUG
     RDebug::Printf("[MCon] CMemSpyDeviceWideOperationWaiter::ExecuteL() - starting scheduler wait..." );
--- a/memspy/Console/Source/ConsoleMain.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Console/Source/ConsoleMain.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -26,6 +26,7 @@
 
 // Engine includes
 #include <memspy/engine/memspyengine.h>
+#include <memspysession.h>
 
 // User includes
 #include "ConsoleMenu.h"
@@ -54,11 +55,12 @@
 	CleanupStack::PushL( console );
 
     // Engine
-    CMemSpyEngine* engine = CMemSpyEngine::NewL( fsSession );
-    CleanupStack::PushL( engine );
+    RMemSpySession session;
+    User::LeaveIfError(session.Connect());
+    CleanupClosePushL(session);
 
     // Menu & event handler AO
-    CMemSpyConsoleMenu::NewLC( *engine, *console );
+    CMemSpyConsoleMenu::NewLC( session, *console );
 
     // Play nicely with external processes
     RProcess::Rendezvous( KErrNone );
--- a/memspy/Console/Source/ConsoleMenu.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Console/Source/ConsoleMenu.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -39,18 +39,17 @@
 #include "ConsoleDWOperation.h"
 
 
-CMemSpyConsoleMenu::CMemSpyConsoleMenu( CMemSpyEngine& aEngine, CConsoleBase& aConsole )
-:   CActive( EPriorityHigh ), iEngine( aEngine ), iConsole( aConsole )
+CMemSpyConsoleMenu::CMemSpyConsoleMenu( RMemSpySession& aSession, CConsoleBase& aConsole )
+:   CActive( EPriorityHigh ), iSession( aSession ), iConsole( aConsole ), iOutputType(EOutputTypeDebug)
     {
     CActiveScheduler::Add( this );
-    iEngine.SetObserver( this );
+    // TODO: iEngine.SetObserver( this );
     }
 
 
 CMemSpyConsoleMenu::~CMemSpyConsoleMenu()
     {
     Cancel();
-    iEngine.SetObserver( NULL );
     }
 
 
@@ -61,9 +60,9 @@
     }
 
 
-CMemSpyConsoleMenu* CMemSpyConsoleMenu::NewLC( CMemSpyEngine& aEngine, CConsoleBase& aConsole )
+CMemSpyConsoleMenu* CMemSpyConsoleMenu::NewLC( RMemSpySession& aSession, CConsoleBase& aConsole )
     {
-    CMemSpyConsoleMenu* self = new(ELeave) CMemSpyConsoleMenu( aEngine, aConsole );
+    CMemSpyConsoleMenu* self = new(ELeave) CMemSpyConsoleMenu( aSession, aConsole );
     CleanupStack::PushL( self );
     self->ConstructL();
     return self;
@@ -76,7 +75,7 @@
    
     // First line - sink type (defaults to file)
     _LIT( KLine1, "1 or T. Toggle output mode between file or trace [%S]" );
-    if  ( iEngine.SinkType() == ESinkTypeDebug )
+    if  ( iOutputType == EOutputTypeDebug )
         {
         _LIT( KLine1Trace, "Trace" );
         iConsole.Printf( KLine1, &KLine1Trace );
@@ -204,14 +203,7 @@
 
 void CMemSpyConsoleMenu::OnCmdSinkTypeToggleL()
     {
-    if  ( iEngine.SinkType() == ESinkTypeDebug )
-        {
-        iEngine.InstallSinkL( ESinkTypeFile );
-        }
-    else
-        {
-        iEngine.InstallSinkL( ESinkTypeDebug );
-        }
+	iOutputType = iOutputType == EOutputTypeFile ? EOutputTypeDebug : EOutputTypeFile;
     }
 
 
@@ -224,7 +216,7 @@
     _LIT( KMsg, "Ouputting Kernel data..." );
     RedrawStatusMessage( KMsg );
 
-    iEngine.HelperHeap().OutputHeapDataKernelL();
+    iSession.OutputKernelHeapDataL( iOutputType );
 
     RedrawStatusMessage( KNullDesC );
     }
@@ -239,14 +231,7 @@
     _LIT( KMsg, "Ouputting Kernel Object listing..." );
     RedrawStatusMessage( KMsg );
     //
-    CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers();
-    CMemSpyEngineGenericKernelObjectContainer* model = kernelContainerManager.ObjectsAllL();
-    CleanupStack::PushL( model );
-    //
-    CMemSpyEngineOutputSink& sink = iEngine.Sink();
-    model->OutputL( sink );
-    //
-    CleanupStack::PopAndDestroy( model );
+    iSession.OutputKernelObjectsL( iOutputType );
 
     RedrawStatusMessage( KNullDesC );
     }
@@ -258,7 +243,7 @@
     RDebug::Printf( "[MCon] CMemSpyConsoleMenu::OnCmdCSVListingStackL() - START" );
 #endif
 
-    iEngine.HelperStack().OutputStackInfoForDeviceL();
+    iSession.OutputCompactStackInfoL( iOutputType );
     }
 
 
@@ -268,7 +253,7 @@
     RDebug::Printf( "[MCon] CMemSpyConsoleMenu::OnCmdCSVListingHeapL() - START" );
 #endif
 
-    iEngine.HelperHeap().OutputHeapInfoForDeviceL();
+    iSession.OutputCompactHeapInfoL( iOutputType );
     }
 
 
@@ -296,44 +281,34 @@
         TPtr pCmdBuf( cmdBuf->Des() );
         pCmdBuf.Copy( iCommandBuffer );
         pCmdBuf.Append( KMemSpyConsoleWildcardCharacter );
-        //
-        CMemSpyEngineObjectContainer& container = iEngine.Container();
-        const TInt count = container.Count();
-        TFullName fullThreadName;
+        
+        TInt err;
+        TProcessId procId;
+        TRAP(err, procId = iSession.GetProcessIdByNameL(pCmdBuf));
         //
-        TInt index = 0;
-#ifdef _DEBUG
-        RDebug::Printf( "[MCon] CMemSpyConsoleMenu::OnCmdHeapDataUserL() - procCount: %d", count );
-#endif
-
-        while( index < count )
-            {
-            CMemSpyProcess& process = container.At( index );
-            const TPtrC processName( process.Name() );
-#ifdef _DEBUG
-            RDebug::Print( _L("[MCon] CMemSpyConsoleMenu::OnCmdHeapDataUserL() - procName: 0x%08x %S"), &process, &processName );
-#endif
-
-            //
-            if  ( processName.MatchF( pCmdBuf ) >= 0 )
-                {
-                _LIT( KProcessingRequest, "** Dumping Heap Data for thread: %S" );
-                const TInt threadCount = process.Count();
-                for( TInt i=0; i<threadCount; i++ )
+        if (err == KErrNone) 
+        	{
+        	RArray<CMemSpyApiThread*> threads;
+        	
+        	TRAP(err, iSession.GetThreadsL(procId, threads));
+        	if (err == KErrNone)
+        		{
+				_LIT( KProcessingRequest, "** Dumping Heap Data for thread: %S" );     	
+				TFullName fullThreadName;
+				
+                for( TInt i=0; i<threads.Count(); i++ )
                     {
-                    CMemSpyThread& thread = process.At( i );
+                    CMemSpyApiThread* thread = threads[i];
                     //
-                    fullThreadName = thread.FullName();
+                    fullThreadName = thread->Name();
                     iConsole.Printf( KProcessingRequest, &fullThreadName );
                     iConsole.Write( KMemSpyConsoleNewLine );
                     //
-                    TRAP_IGNORE( iEngine.HelperHeap().OutputHeapDataUserL( thread ) );
+                    TRAP_IGNORE( iSession.OutputThreadHeapDataL(iOutputType, thread->Id()) );
+                    
+                    delete thread;
                     }
-
-                break;
                 }
-            
-            ++index;
             }
 
         CleanupStack::PopAndDestroy( cmdBuf );
@@ -369,38 +344,36 @@
         TPtr pCmdBuf( cmdBuf->Des() );
         pCmdBuf.Copy( iCommandBuffer );
         pCmdBuf.Append( KMemSpyConsoleWildcardCharacter );
-        //
-        CMemSpyEngineObjectContainer& container = iEngine.Container();
-        const TInt count = container.Count();
-        TFullName fullThreadName;
-        //
-        TInt index = 0;
-        while( index < count )
-            {
-            CMemSpyProcess& process = container.At( index );
-            const TPtrC processName( process.Name() );
-            //
-            if  ( processName.MatchF( pCmdBuf ) >= 0 )
-                {
-                _LIT( KProcessingRequest, "** Dumping Heap Cell List for thread: %S" );
-                const TInt threadCount = process.Count();
-                for( TInt i=0; i<threadCount; i++ )
-                    {
-                    CMemSpyThread& thread = process.At( i );
-                    //
-                    fullThreadName = thread.FullName();
-                    iConsole.Printf( KProcessingRequest, &fullThreadName );
-                    iConsole.Write( KMemSpyConsoleNewLine );
-                    //
-                    TRAP_IGNORE( iEngine.HelperHeap().OutputCellListingUserL( thread ) );
-                    }
-
-                break;
-                }
-            
-            ++index;
-            }
-
+        
+        TInt err;
+		TProcessId procId;
+		TRAP(err, procId = iSession.GetProcessIdByNameL(pCmdBuf));
+		//
+		if (err == KErrNone) 
+			{
+			RArray<CMemSpyApiThread*> threads;
+			
+			TRAP(err, iSession.GetThreadsL(procId, threads));
+			if (err == KErrNone)
+				{
+				_LIT( KProcessingRequest, "** Dumping Heap Cell List for thread: %S" );     	
+				TFullName fullThreadName;
+				
+				for( TInt i=0; i<threads.Count(); i++ )
+					{
+					CMemSpyApiThread* thread = threads[i];
+					//
+					fullThreadName = thread->Name();
+					iConsole.Printf( KProcessingRequest, &fullThreadName );
+					iConsole.Write( KMemSpyConsoleNewLine );
+					//
+					TRAP_IGNORE( iSession.OutputThreadCellListL(iOutputType, thread->Id()) );
+					
+					delete thread;
+					}
+				}
+			}
+        
         CleanupStack::PopAndDestroy( cmdBuf );
         DrawMenuL();
         }
@@ -604,71 +577,72 @@
 
 void CMemSpyConsoleMenu::InitiateMemSpyClientServerOperationL( TInt aOpCode )
     {
-#ifdef _DEBUG
-    RDebug::Printf( "[MCon] CMemSpyConsoleMenu::InitiateMemSpyClientServerOperationL() - START - aOpCode: %d, iRunningDeviceWideOperation: %d", aOpCode, iRunningDeviceWideOperation );
-#endif
-    //
-    if ( aOpCode == EMemSpyClientServerOpExit )
-        {
-        // Exit console app UI
-        CActiveScheduler::Stop();
-        }
-    else
-        {
-        CMemSpyDeviceWideOperations::TOperation op = CMemSpyDeviceWideOperations::EPerEntityGeneralSummary;
-        switch( aOpCode )
-            {
-        case EMemSpyClientServerOpSummaryInfo:
-            op = CMemSpyDeviceWideOperations::EPerEntityGeneralSummary;
-            break;
-        case EMemSpyClientServerOpSummaryInfoDetailed:
-            op = CMemSpyDeviceWideOperations::EPerEntityGeneralDetailed;
-            break;
-        //
-        case EMemSpyClientServerOpHeapInfo:
-            op = CMemSpyDeviceWideOperations::EPerEntityHeapInfo;
-            break;
-        case EMemSpyClientServerOpHeapCellListing:
-            op = CMemSpyDeviceWideOperations::EPerEntityHeapCellListing;
-            break;
-        case EMemSpyClientServerOpHeapData:
-            op = CMemSpyDeviceWideOperations::EPerEntityHeapData;
-            break;
-        //
-        case EMemSpyClientServerOpStackInfo:
-            op = CMemSpyDeviceWideOperations::EPerEntityStackInfo;
-            break;
-        case EMemSpyClientServerOpStackDataUser:
-            op = CMemSpyDeviceWideOperations::EPerEntityStackDataUser;
-            break;
-        case EMemSpyClientServerOpStackDataKernel:
-            op = CMemSpyDeviceWideOperations::EPerEntityStackDataKernel;
-            break;
-        
-        // These are not supported by the console UI
-        default:
-        case EMemSpyClientServerOpBitmapsSave:
-        case EMemSpyClientServerOpSendToBackground:
-        case EMemSpyClientServerOpBringToForeground:
-            User::Leave( KErrNotSupported );
-            break;
-            }
-
-        if  ( iRunningDeviceWideOperation )
-            {
-            User::Leave( KErrInUse );
-            }
-        else
-            {
-            iRunningDeviceWideOperation = ETrue;
-            TRAP_IGNORE( CMemSpyDeviceWideOperationWaiter::ExecuteLD( iEngine, op ) );
-            iRunningDeviceWideOperation = EFalse;
-            }
-        }
-
-#ifdef _DEBUG
-    RDebug::Printf( "[MCon] CMemSpyConsoleMenu::InitiateMemSpyClientServerOperationL() - END - aOpCode: %d", aOpCode );
-#endif
+	// TODO: ....
+//#ifdef _DEBUG
+//    RDebug::Printf( "[MCon] CMemSpyConsoleMenu::InitiateMemSpyClientServerOperationL() - START - aOpCode: %d, iRunningDeviceWideOperation: %d", aOpCode, iRunningDeviceWideOperation );
+//#endif
+//    //
+//    if ( aOpCode == EMemSpyClientServerOpExit )
+//        {
+//        // Exit console app UI
+//        CActiveScheduler::Stop();
+//        }
+//    else
+//        {
+//        CMemSpyDeviceWideOperations::TOperation op = CMemSpyDeviceWideOperations::EPerEntityGeneralSummary;
+//        switch( aOpCode )
+//            {
+//        case EMemSpyClientServerOpSummaryInfo:
+//            op = CMemSpyDeviceWideOperations::EPerEntityGeneralSummary;
+//            break;
+//        case EMemSpyClientServerOpSummaryInfoDetailed:
+//            op = CMemSpyDeviceWideOperations::EPerEntityGeneralDetailed;
+//            break;
+//        //
+//        case EMemSpyClientServerOpHeapInfo:
+//            op = CMemSpyDeviceWideOperations::EPerEntityHeapInfo;
+//            break;
+//        case EMemSpyClientServerOpHeapCellListing:
+//            op = CMemSpyDeviceWideOperations::EPerEntityHeapCellListing;
+//            break;
+//        case EMemSpyClientServerOpHeapData:
+//            op = CMemSpyDeviceWideOperations::EPerEntityHeapData;
+//            break;
+//        //
+//        case EMemSpyClientServerOpStackInfo:
+//            op = CMemSpyDeviceWideOperations::EPerEntityStackInfo;
+//            break;
+//        case EMemSpyClientServerOpStackDataUser:
+//            op = CMemSpyDeviceWideOperations::EPerEntityStackDataUser;
+//            break;
+//        case EMemSpyClientServerOpStackDataKernel:
+//            op = CMemSpyDeviceWideOperations::EPerEntityStackDataKernel;
+//            break;
+//        
+//        // These are not supported by the console UI
+//        default:
+//        case EMemSpyClientServerOpBitmapsSave:
+//        case EMemSpyClientServerOpSendToBackground:
+//        case EMemSpyClientServerOpBringToForeground:
+//            User::Leave( KErrNotSupported );
+//            break;
+//            }
+//
+//        if  ( iRunningDeviceWideOperation )
+//            {
+//            User::Leave( KErrInUse );
+//            }
+//        else
+//            {
+//            iRunningDeviceWideOperation = ETrue;
+//            TRAP_IGNORE( CMemSpyDeviceWideOperationWaiter::ExecuteLD( iEngine, op ) );
+//            iRunningDeviceWideOperation = EFalse;
+//            }
+//        }
+//
+//#ifdef _DEBUG
+//    RDebug::Printf( "[MCon] CMemSpyConsoleMenu::InitiateMemSpyClientServerOperationL() - END - aOpCode: %d", aOpCode );
+//#endif
     }
 
 
--- a/memspy/Console/group/MemSpyConsole.mmp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Console/group/MemSpyConsole.mmp	Wed Sep 15 13:53:27 2010 +0300
@@ -25,8 +25,8 @@
 
 #include		"../../group/MemSpyCapabilities.mmh"
 
-EPOCSTACKSIZE   0x4000
-EPOCHEAPSIZE	0x100000 0x4000000
+//EPOCSTACKSIZE   0x4000
+//EPOCHEAPSIZE	0x100000 0x4000000
 
 
 SOURCEPATH      ../Source
@@ -41,6 +41,5 @@
 LIBRARY         euser.lib
 LIBRARY         efsrv.lib 
 
-LIBRARY         memspydriverclient.lib
-LIBRARY         memspyengine.lib 
-
+LIBRARY		MemSpyClient.lib
+LIBRARY     MemSpyEngine.lib
\ No newline at end of file
--- a/memspy/Console/group/bld.inf	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Console/group/bld.inf	Wed Sep 15 13:53:27 2010 +0300
@@ -23,4 +23,4 @@
 
 
 PRJ_MMPFILES
-MemSpyConsole.mmp
+//MemSpyConsole.mmp
--- a/memspy/Driver/BWINS/memspydriverclientu.def	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/BWINS/memspydriverclientu.def	Wed Sep 15 13:53:27 2010 +0300
@@ -67,4 +67,5 @@
 	?WalkHeapReadCellData@RMemSpyDriverClient@@QAEHPAXAAVTDes8@@H@Z @ 66 NONAME ; int RMemSpyDriverClient::WalkHeapReadCellData(void *, class TDes8 &, int)
 	?GetCondVarSuspendedThreads@RMemSpyDriverClient@@QAEHPAXPAPAXAAH@Z @ 67 NONAME ; int RMemSpyDriverClient::GetCondVarSuspendedThreads(void *, void * *, int &)
 	?GetCondVarSuspendedThreadInfo@RMemSpyDriverClient@@QAEHPAXAAVTMemSpyDriverCondVarSuspendedThreadInfo@@@Z @ 68 NONAME ; int RMemSpyDriverClient::GetCondVarSuspendedThreadInfo(void *, class TMemSpyDriverCondVarSuspendedThreadInfo &)
+	?GetHeapInfoUser@RMemSpyDriverClient@@QAEHAAVTMemSpyHeapInfo@@IAAV?$RArray@VTMemSpyDriverFreeCell@@@@H@Z @ 69 NONAME ; int RMemSpyDriverClient::GetHeapInfoUser(class TMemSpyHeapInfo &, unsigned int, class RArray<class TMemSpyDriverFreeCell> &, int)
 
--- a/memspy/Driver/Kernel/Include/MemSpyDriverHeap.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Include/MemSpyDriverHeap.h	Wed Sep 15 13:53:27 2010 +0300
@@ -28,104 +28,39 @@
 #include "MemSpyDriverObjectsInternal.h"
 
 // Constants
+// We shouldn't be using any of these any more! -Tomsci
 const TUint KRHeapObjectSize = 0x74;
 const TUint KRAllocatorAndRHeapMemberDataOffset = 4; // 4 bytes past start of allocator address, i.e. skipping the vtable
 const TUint KRHeapMemberDataSize = KRHeapObjectSize - KRAllocatorAndRHeapMemberDataOffset;
 
 // Classes referenced
 class DMemSpyDriverOSAdaption;
-
+namespace LtkUtils
+	{
+	class RAllocatorHelper;
+	}
 
 /**
  * Essentially a mirror of RAllocator and RHeap's layout.
  */
 class RMemSpyDriverRHeapBase
 	{
-public:
-	struct SCell
-        {
-        TInt len; 
-        SCell* next;
-        };
-
-    struct SDebugCell
-        {
-        TInt len;
-        TInt nestingLevel;
-        TInt allocCount;
-        };
-
-    struct _s_align {char c; double d;};
-
-    struct SHeapCellInfo { RHeap* iHeap; TInt iTotalAlloc;	TInt iTotalAllocSize; TInt iTotalFree; TInt iLevelAlloc; SDebugCell* iStranded; };
-	
-    enum {ECellAlignment = sizeof(_s_align)-sizeof(double)};
-	enum {EFreeCellSize = sizeof(SCell)};
-	enum TDebugOp {EWalk=128};
-	enum TCellType
-		{EGoodAllocatedCell, EGoodFreeCell, EBadAllocatedCellSize, EBadAllocatedCellAddress,
-		EBadFreeCellAddress, EBadFreeCellSize};
-	
-    enum TDebugHeapId {EUser=0, EKernel=1};
-
 protected:
     RMemSpyDriverRHeapBase();
 
-public: // Inlines
-    inline TUint8* Base() const { return iBase; }
-    inline TInt Size() const { return iTop - iBase; }
-    inline TInt MaxLength() const { return iMaxLength; }
-
 public: // API
     void PrintInfo();
-    void CopyObjectDataTo( TMemSpyHeapObjectDataRHeap& aData );
+	LtkUtils::RAllocatorHelper* Helper();
+	TMemSpyHeapInfo::THeapImplementationType GetTypeFromHelper() const;
 
 public: // Virtual API
     virtual void Reset();
-    virtual void AssociateWithKernelChunk( DChunk* aChunk, TLinAddr aAddress, TUint32 aMappingAttributes ) = 0;
-    virtual void DisassociateWithKernelChunk() = 0;
+	virtual void Close();
     virtual DChunk& Chunk() = 0;
     virtual const DChunk& Chunk() const = 0;
-    virtual TLinAddr ChunkKernelAddress() const = 0;
-    virtual TBool ChunkIsInitialised() const = 0;
-    virtual TUint ClientToKernelDelta() const = 0;
-    virtual void GetHeapSpecificInfo( TMemSpyHeapInfo& /*aInfo*/ ) const { }
 
-public: // Utilities
-    TBool CheckCell( TAny* aCellAddress, TInt aLength ) const;
-    static TInt AllocatedCellHeaderSize( TBool aDebugLibrary );
-    static TInt FreeCellHeaderSize();
-    static TInt CellHeaderSize( const TMemSpyDriverInternalWalkHeapParamsCell& aCell, TBool aDebugEUser );
-
-public: // From RAllocator
-	TInt iAccessCount;
-	TInt iHandleCount;
-	TInt* iHandles;
-	TUint32 iFlags;
-	TInt iCellCount;
-	TInt iTotalAllocSize;
-
-public: // From RHeap
-	TInt iMinLength;
-	TInt iMaxLength;
-	TInt iOffset;
-	TInt iGrowBy;
-	TInt iChunkHandle;
-	RFastLock iLock;
-	TUint8* iBase;
-	TUint8* iTop;
-	TInt iAlign;
-	TInt iMinCell;
-	TInt iPageSize;
-	SCell iFree;
-	TInt iNestingLevel;
-	TInt iAllocCount;
-    RAllocator::TAllocFail iFailType;
-	TInt iFailRate;
-	TBool iFailed;
-	TInt iFailAllocCount;
-	TInt iRand;
-	TAny* iTestData;
+protected:
+	LtkUtils::RAllocatorHelper* iHelper;
     };
 
 
@@ -137,17 +72,12 @@
     RMemSpyDriverRHeapReadFromCopy( DMemSpyDriverOSAdaption& aOSAdaption );
 
 public: // New API
-    TInt ReadFromUserAllocator( DThread& aThread );
+    void AssociateWithKernelChunk( DChunk* aChunk, TLinAddr aAddress, TUint32 aMappingAttributes );
 
 public: // From RMemSpyDriverRHeapBase
     void Reset();
-    void AssociateWithKernelChunk( DChunk* aChunk, TLinAddr aAddress, TUint32 aMappingAttributes );
-    void DisassociateWithKernelChunk();
     DChunk& Chunk();
     const DChunk& Chunk() const;
-    TLinAddr ChunkKernelAddress() const;
-    TBool ChunkIsInitialised() const;
-    TUint ClientToKernelDelta() const;
 
 protected:
     inline DMemSpyDriverOSAdaption& OSAdaption() { return iOSAdaption; }
@@ -162,7 +92,7 @@
 
     // Calculated delta between client's address space values and actual kernel
     // address of the heap chunk.
-    TUint iClientToKernelDelta;
+    //TUint iClientToKernelDelta;
     };
 
 
@@ -171,13 +101,21 @@
 
 
 
-class RMemSpyDriverRHeapUser : public RMemSpyDriverRHeapReadFromCopy
+class RMemSpyDriverRHeapUser : public RMemSpyDriverRHeapBase
 	{
 public:
     RMemSpyDriverRHeapUser( DMemSpyDriverOSAdaption& aOSAdaption );
+	TInt OpenUserHeap(DThread& aThread, TBool aEuserUdeb);
 
-public: // New API
-    TInt ReadFromUserAllocator( DThread& aThread );
+	DChunk& Chunk() { return *iChunk; }
+	const DChunk& Chunk() const { return *iChunk; }
+
+private:
+    inline DMemSpyDriverOSAdaption& OSAdaption() { return iOSAdaption; }
+
+private:
+    DMemSpyDriverOSAdaption& iOSAdaption;
+	DChunk* iChunk;
     };
 
 
@@ -191,8 +129,8 @@
     void SetKernelHeap( RHeapK& aKernelHeap );
 
 public: // From RMemSpyDriverRHeapBase
-    void DisassociateWithKernelChunk();
-    void GetHeapSpecificInfo( TMemSpyHeapInfo& aInfo ) const;
+    //void DisassociateWithKernelChunk();
+	void Close();
 
 private:
     RHeapK* iKernelHeap;
@@ -204,50 +142,19 @@
     {
 public:
     RMemSpyDriverRHeapKernelInPlace();
+	TInt OpenKernelHeap();
     
-public: // API
-    void FailNext();
-    void SetKernelHeap( RHeapK& aKernelHeap );
 
 public: // From RMemSpyDriverRHeapBase
-    void Reset();
-    void AssociateWithKernelChunk( DChunk* aChunk, TLinAddr aAddress, TUint32 aMappingAttributes );
-    void DisassociateWithKernelChunk();
+    void Close();
+
     DChunk& Chunk();
     const DChunk& Chunk() const;
-    TLinAddr ChunkKernelAddress() const;
-    TBool ChunkIsInitialised() const;
-    TUint ClientToKernelDelta() const;
-    void GetHeapSpecificInfo( TMemSpyHeapInfo& aInfo ) const;
 
-private: // Internal methods
-    void CopyMembersFromKernelHeap();
-
-private: // Internal class
-
-    /**
-     * Used when opening the kernel heap
-     */
-#ifndef __SYMBIAN_KERNEL_HYBRID_HEAP__
-    class RHeapKExtended : public RHeapK
-        {
-    public:
-        inline void FailNext()
-            {
-            SetFailType( RAllocator::EFailNext );
-            SetFailRate( 1 );
-            ResetFailed();
-            ResetFailAllocCount();
-            }
-        inline void SetFailType( TAllocFail aType ) { iFailType = aType; }
-        inline void SetFailRate( TInt aRate ) { iFailRate = aRate; }
-        inline void ResetFailed() { iFailed = EFalse; }
-        inline void ResetFailAllocCount() { iFailAllocCount = 0; }
-        };
-#endif
+	// Only important member data is the base class's RAllocatorHelper
+	// We do cache the chunk though
 private:
-    RHeapK* iKernelHeap;
-    DChunk* iChunk;
+	DChunk* iChunk;
     };
 
 	
--- a/memspy/Driver/Kernel/Include/MemSpyDriverHeapStatistics.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Include/MemSpyDriverHeapStatistics.h	Wed Sep 15 13:53:27 2010 +0300
@@ -69,7 +69,8 @@
     TUint iLargestCellAddressFreePrevious;
 
     // The overhead associated with a free cell (header length)
-    TUint iFreeCellOverheadHeaderLength;
+    //TUint iFreeCellOverheadHeaderLength;
+	TUint iReserved1;
 
     // The slace space at the end of the heap
     TUint iSlackSpace;
@@ -93,7 +94,8 @@
     TLinAddr iLargestCellAddressAlloc;
    
     // The overhead associated with an allocated cell (header length)
-    TUint iAllocCellOverheadHeaderLength;
+    //TUint iAllocCellOverheadHeaderLength;
+	TUint iReserved2;
 
 public: // Common
 
--- a/memspy/Driver/Kernel/Include/MemSpyDriverHeapWalker.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Include/MemSpyDriverHeapWalker.h	Wed Sep 15 13:53:27 2010 +0300
@@ -29,32 +29,23 @@
 #include "MemSpyDriverHeap.h"
 #include "MemSpyDriverHeapStatistics.h"
 
+#include "heaputils.h"
+using namespace LtkUtils;
 
 // Heap walker observer interface - can be used to make a record of each cell
 class MMemSpyHeapWalkerObserver
     {
 public:
-    virtual TBool HandleHeapCell( TInt aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber ) = 0;
+    virtual TBool HandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber) = 0;
     virtual void HandleHeapWalkInit() = 0;
     };
 
 
-
-// A null observer that is used to collect basic statistics
-class TMemSpyHeapWalkerNullObserver : public MMemSpyHeapWalkerObserver
-    {
-public:
-    TBool HandleHeapCell( TInt /*aCellType*/, TAny* /*aCellAddress*/, TInt /*aLength*/, TInt /*aNestingLevel*/, TInt /*aAllocNumber*/ ) { return ETrue; }
-    void HandleHeapWalkInit() { }
-    };
-
-
 // Heap walker - allows in-place walking of any heap
 class RMemSpyDriverHeapWalker
     {
 public:
-    RMemSpyDriverHeapWalker( RMemSpyDriverRHeapBase& aHeap, TBool aDebugAllocator );
-    RMemSpyDriverHeapWalker( RMemSpyDriverRHeapBase& aHeap, TBool aDebugAllocator, MMemSpyHeapWalkerObserver& aObserver );
+	RMemSpyDriverHeapWalker(RMemSpyDriverRHeapBase& aHeap, MMemSpyHeapWalkerObserver* aObserver=NULL);
 		
 public: // API
     TInt Traverse();
@@ -63,12 +54,9 @@
     inline void SetPrintDebug() { iPrintDebug = ETrue; }
     inline const TMemSpyHeapWalkStatistics& Stats() const { return iStats; }
 
-public: // Utility functions
-    static TAny* KernelAddress( TAny* aUserAddress, TUint aDelta );
-    static TAny* UserAddress( TAny* aKernelAddress, TUint aDelta );
-    static RMemSpyDriverRHeapBase::SCell* CellByUserAddress( TAny* aAddress, TUint aDelta );
-
 private: // Internal methods
+	static TBool CellCallback(RAllocatorHelper& aHelper, TAny* aContext, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellAddress, TInt aLength);
+	TBool DoCellCallback(RAllocatorHelper& aHelper, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellAddress, TInt aLength);
     TBool NotifyCell( TMemSpyDriverCellType aType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel = -1, TInt aAllocNumber = -1 );
     //
     void UpdateStats( TMemSpyDriverCellType aType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber );
@@ -76,14 +64,10 @@
     void FinaliseStats();
     void PrintStats();
     //
-    TAny* KernelAddress( TAny* aUserAddress ) const;
-    TAny* UserAddress( TAny* aKernelAddress ) const;
-    //
     inline TBool PrintDebug() const { return iPrintDebug; }
 
 private:
     RMemSpyDriverRHeapBase& iHeap;
-    TBool iIsDebugAllocator;
     TBool iPrintDebug;
     MMemSpyHeapWalkerObserver* iObserver;
     TMemSpyHeapWalkStatistics iStats;
--- a/memspy/Driver/Kernel/Include/MemSpyDriverInspectedProcess.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Include/MemSpyDriverInspectedProcess.h	Wed Sep 15 13:53:27 2010 +0300
@@ -138,6 +138,8 @@
     void ResetPendingChanges();
     void PrintChunkInfo( DChunk& aChunk ) const;
     TBool IsChunkRelevantToOurProcess( DChunk& aChunk ) const;
+	void Lock() const;
+	void Unlock() const;
 
 public: // Queue link for process manager
 	SDblQueLink iPMLink;
--- a/memspy/Driver/Kernel/Include/MemSpyDriverLog.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Include/MemSpyDriverLog.h	Wed Sep 15 13:53:27 2010 +0300
@@ -119,5 +119,6 @@
 #   define TRACE_CHUNK( x )
 #endif
 
+#define LOG(args...) TRACE(Kern::Printf(args))
 
 #endif
--- a/memspy/Driver/Kernel/Include/MemSpyDriverOSAdaption.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Include/MemSpyDriverOSAdaption.h	Wed Sep 15 13:53:27 2010 +0300
@@ -106,7 +106,7 @@
     TUint GetId( DProcess& aObject ) const;
     MemSpyObjectIx* GetHandles( DProcess& aObject ) const;
     TExitType GetExitType( DProcess& aObject ) const;
-    DThread* GetFirstThread( DProcess& aObject ) const;
+    DThread* OpenFirstThread( DProcess& aObject ) const;
     TUint32 GetSID( DProcess& aObject ) const;
     TUint GetSecurityZone( DProcess& aObject ) const;
     SSecurityInfo& GetSecurityInfo( DProcess& aObject ) const;
@@ -122,6 +122,7 @@
     TUint8* GetAddressOfOwningProcess( DProcess& aObject ) const;
     TUint8* GetAddressOfDataBssStackChunk( DProcess& aObject ) const;
     TBool IsHandleIndexValid( DProcess& aObject ) const;
+	TBool IsKernProcess(DProcess& aProcess) const;
 
 private: // Data members
     };
--- a/memspy/Driver/Kernel/Include/MemSpyDriverObjectIx.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Include/MemSpyDriverObjectIx.h	Wed Sep 15 13:53:27 2010 +0300
@@ -126,8 +126,8 @@
 	// common operations
     RMemSpyObjectIx();
 
-    static void Wait();
-	static void Signal();
+    //static void Wait();
+	//static void Signal();
 
     inline TInt Count()
 		{ return iCount; }
@@ -137,7 +137,7 @@
 public:
 	// uncommon operations
 	DObject* operator[](TInt aIndex);
-	TInt At(DObject* aObject);
+	TBool Find(DObject* aObject);
 
 private:
 	TRWSpinLock		iRWL;
@@ -171,11 +171,11 @@
 public:
 	DObject* At(TInt aHandle,TInt aUniqueID);
 	DObject* At(TInt aHandle);
-	TInt At(DObject* aObject);
+	TBool Find(DObject* aObject);
 	TInt Count(DObject* aObject);
 	DObject* operator[](TInt aIndex);
-	static void Wait( DMemSpyObjectIx* aObjectIndex );
-	static void Signal( DMemSpyObjectIx* aObjectIndex );
+	//static void Wait( DMemSpyObjectIx* aObjectIndex );
+	//static void Signal( DMemSpyObjectIx* aObjectIndex );
 	inline TInt Count();
 	inline TInt ActiveCount();
 
@@ -206,24 +206,24 @@
 #if MCL_ROBJECTIX_DUPLICATION
 
     #define MemSpyObjectIx                                          RMemSpyObjectIx
-    #define MemSpyObjectIx_Wait( IX )                               RMemSpyObjectIx::Wait()
-    #define MemSpyObjectIx_Signal( IX )                             RMemSpyObjectIx::Signal()
+    //#define MemSpyObjectIx_Wait( IX )                               RMemSpyObjectIx::Wait()
+    //#define MemSpyObjectIx_Signal( IX )                             RMemSpyObjectIx::Signal()
     #define MemSpyObjectIx_GetHandlePointer_Thread( DTHREAD )       reinterpret_cast< MemSpyObjectIx* >( &DTHREAD.iHandles )
     #define MemSpyObjectIx_GetHandlePointer_Process( DPROCESS )     reinterpret_cast< MemSpyObjectIx* >( &DPROCESS.iHandles )
 
 #elif MCL_DOBJECTIX_DUPLICATION
 
     #define MemSpyObjectIx                                          DMemSpyObjectIx
-    #define MemSpyObjectIx_Wait( IX )                               DMemSpyObjectIx::Wait( IX )
-    #define MemSpyObjectIx_Signal( IX )                             DMemSpyObjectIx::Signal( IX )
+    //#define MemSpyObjectIx_Wait( IX )                               DMemSpyObjectIx::Wait( IX )
+    //#define MemSpyObjectIx_Signal( IX )                             DMemSpyObjectIx::Signal( IX )
     #define MemSpyObjectIx_GetHandlePointer_Thread( DTHREAD )       reinterpret_cast< MemSpyObjectIx* >( DTHREAD.iHandles )
     #define MemSpyObjectIx_GetHandlePointer_Process( DPROCESS )     reinterpret_cast< MemSpyObjectIx* >( DPROCESS.iHandles )
 
 #else
 
     #define MemSpyObjectIx                  DObjectIx
-    #define MemSpyObjectIx_Wait( IX )       
-    #define MemSpyObjectIx_Signal( IX )     
+    //#define MemSpyObjectIx_Wait( IX )       
+    //#define MemSpyObjectIx_Signal( IX )     
     #define MemSpyObjectIx_IsValid_Thread( DTHREAD )    ( DTHREAD.iHandles != NULL )
     #define MemSpyObjectIx_IsValid_Process( DPROCESS )  ( DPROCESS.iHandles != NULL )
     #define MemSpyObjectIx_GetHandlePointer_Thread( DTHREAD )       reinterpret_cast< MemSpyObjectIx* >( DTHREAD.iHandles )
@@ -231,4 +231,7 @@
 
 #endif
 
+#define MemSpyObjectIx_HandleLookupLock()							NKern::LockSystem()
+#define MemSpyObjectIx_HandleLookupUnlock()							NKern::UnlockSystem()
+
 #endif
--- a/memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanContainerBase.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanContainerBase.h	Wed Sep 15 13:53:27 2010 +0300
@@ -42,8 +42,8 @@
 protected: // Internal methods
     static TObjectType ObjectTypeFromMemSpyContainerType( TMemSpyDriverContainerType aType );
 
-    /** Returns with System Locked */
-    DObject* CheckIfObjectIsInContainer( TMemSpyDriverContainerType aContainerType, DObject* aSearchFor, TBool aQuick = EFalse );
+	// Must be in critical section to call
+	DObject* CheckedOpen(TMemSpyDriverContainerType aContainerType, DObject* aObject, TBool aQuick=EFalse);
 
 protected: // Internal methods
     void ResetTempHandles();
--- a/memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanHeapBase.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanHeapBase.h	Wed Sep 15 13:53:27 2010 +0300
@@ -61,33 +61,20 @@
 protected: // Capability checks for heap access
     TDrmMatchType IsDrmThread( DThread& aThread );
 
-private: // From MHeapWalkerObserver
+protected: // From MHeapWalkerObserver
     void HandleHeapWalkInit();
-    TBool HandleHeapCell( TInt aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber );
+    TBool HandleHeapCell( TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber );
 
 protected: // Heap utility functions
     TInt OpenKernelHeap( RHeapK*& aHeap, DChunk*& aChunk, TDes8* aClientHeapChunkName = NULL );
-    TInt OpenKernelHeap( RMemSpyDriverRHeapKernelInPlace& aHeap, TDes8* aClientHeapChunkName = NULL );
     TInt OpenKernelHeap( RMemSpyDriverRHeapKernelFromCopy& aHeap, TDes8* aClientHeapChunkName = NULL );
-    TInt OpenUserHeap( DThread& aClientThread, TUint aExpectedHeapVTable, RMemSpyDriverRHeapUser& aHeap, DChunk*& aUserHeapChunk, TDes8* aClientHeapChunkName = NULL );
-    TBool GetUserHeapHandle( DThread& aThread, RMemSpyDriverRHeapUser& aHeap, TUint aExpectedVTable );
-    TBool IsDebugKernel();
-    TBool IsDebugKernel( RMemSpyDriverRHeapKernelInPlace& aHeap );
-    TInt GetHeapInfoKernel( RMemSpyDriverRHeapBase& aHeap, TBool aIsDebugAllocator, const TDesC8& aChunkName, TMemSpyHeapInfo* aHeapInfo, TDes8* aTransferBuffer );
+    TInt GetHeapInfoKernel(RMemSpyDriverRHeapBase& aHeap, TMemSpyHeapInfo* aHeapInfo, TDes8* aTransferBuffer);
     void PrintHeapInfo( const TMemSpyHeapInfo& aInfo );
 
-protected: // Free cells
-    void ReleaseFreeCells();
-    TInt PrepareFreeCellTransferBuffer();
-	TInt FetchFreeCells( TDes8* aBufferSink );
-    TInt CalculateFreeCellBufferSize() const;
-
 private: // Data members
-	RArray< TMemSpyDriverFreeCell > iFreeCells;
 
     // Points to stack-based object whilst walking in progress
     RMemSpyMemStreamWriter* iStackStream;
-    RMemSpyMemStreamWriter* iHeapStream;
     TInt iFreeCellCount;
 	};
 
--- a/memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanHeapInfo.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanHeapInfo.h	Wed Sep 15 13:53:27 2010 +0300
@@ -53,13 +53,22 @@
 private: // Channel operation handlers
     TInt GetHeapInfoUser( TMemSpyDriverInternalHeapRequestParameters* aParams );
     TInt GetHeapInfoKernel( TMemSpyDriverInternalHeapRequestParameters* aParams, TDes8* aTransferBuffer );
-    TInt GetIsDebugKernel( TBool* aIsDebugKernel );
+    TInt GetIsDebugKernel(TAny* aIsDebugKernel);
+
+private: // From MHeapWalkerObserver
+    void HandleHeapWalkInit();
+    TBool HandleHeapCell( TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber );
 
 private: // Internal methods
-    TUint32 CalculateFreeCellBufferSize() const;
+	void ReleaseCellList();
+    TInt PrepareCellListTransferBuffer();
+	TInt FetchCellList(TDes8* aBufferSink);
+    TInt CalculateCellListBufferSize() const;
 
 private: // Data members
     TMemSpyDriverInternalHeapRequestParameters iHeapInfoParams;
+	RArray<TMemSpyDriverCell> iCellList;
+    RMemSpyMemStreamWriter* iHeapStream;
 	};
 
 
--- a/memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanHeapWalk.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Include/SubChannels/MemSpyDriverLogChanHeapWalk.h	Wed Sep 15 13:53:27 2010 +0300
@@ -61,7 +61,7 @@
     const TMemSpyDriverInternalWalkHeapParamsCell* CellInfoForSpecificAddress( TAny* aAddress ) const;
 
 private: // Heap walker callback
-    TBool WalkerHandleHeapCell( TInt aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber );
+    TBool WalkerHandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber );
 
 private:
     TBool iHeapWalkInitialised;
@@ -85,7 +85,7 @@
 
 public: // From MHeapWalkerObserver
     void HandleHeapWalkInit() { }
-    TBool HandleHeapCell( TInt aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber )
+    TBool HandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber )
         {
         return iChannel.WalkerHandleHeapCell( aCellType, aCellAddress, aLength, aNestingLevel, aAllocNumber );
         }
--- a/memspy/Driver/Kernel/Source/MemSpyDriverEventMonitor.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/MemSpyDriverEventMonitor.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -170,6 +170,7 @@
 TUint DMemSpyEventMonitor::HandleEvent( TKernelEvent aType, TAny* a1, TAny* /*a2*/ )
 	{ 
 	// TRACE_EM( Kern::Printf("DMemSpyEventMonitor::HandleEvent() - PRE WAIT"));
+	NKern::ThreadEnterCS();
 	Kern::MutexWait(*iLock);
 	// TRACE_EM( Kern::Printf("DMemSpyEventMonitor::HandleEvent() - POST WAIT"));
 
@@ -250,6 +251,7 @@
 
 	// TRACE_EM( Kern::Printf("DMemSpyEventMonitor::HandleEvent() - PRE SIGNAL "));
 	Kern::MutexSignal( *iLock );
+	NKern::ThreadLeaveCS();
 	// TRACE_EM( Kern::Printf("DMemSpyEventMonitor::HandleEvent() - POST SIGNAL "));
 
 	// Allow other handlers to see this event
--- a/memspy/Driver/Kernel/Source/MemSpyDriverHeap.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/MemSpyDriverHeap.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -23,129 +23,62 @@
 // User includes
 #include "MemSpyDriverOSAdaption.h"
 #include "MemSpyDriverUtils.h"
+#include "heaputils.h"
 
-// Defines
-#define __NEXT_CELL(p)				((RMemSpyDriverRHeapBase::SCell*)(((TUint8*)p)+p->len))
-#define __NEXT_CELL2(p,l)			((RMemSpyDriverRHeapBase::SCell*)(((TUint8*)p)+l))
 
 
 RMemSpyDriverRHeapBase::RMemSpyDriverRHeapBase()
+	: iHelper(NULL)
     {
     Reset();
     }
 
+LtkUtils::RAllocatorHelper* RMemSpyDriverRHeapBase::Helper()
+	{
+	return iHelper;
+	}
+
+TMemSpyHeapInfo::THeapImplementationType RMemSpyDriverRHeapBase::GetTypeFromHelper() const
+	{
+	if (iHelper)
+		{
+		LtkUtils::RAllocatorHelper::TType type = iHelper->GetType();
+		switch (type)
+			{
+			case LtkUtils::RAllocatorHelper::ETypeRHeap:
+				return TMemSpyHeapInfo::ETypeRHeap;
+			case LtkUtils::RAllocatorHelper::ETypeRHybridHeap:
+				return TMemSpyHeapInfo::ETypeRHybridHeap;
+			case LtkUtils::RAllocatorHelper::ETypeUnknown:
+			default:
+				return TMemSpyHeapInfo::ETypeUnknown;
+			}
+		}
+	return TMemSpyHeapInfo::ETypeUnknown;
+	}
 
 void RMemSpyDriverRHeapBase::Reset()
     {
-	iAccessCount = 0;
-	iHandleCount = 0;
-	iHandles = NULL;
-	iFlags = 0;
-	iCellCount = 0;
-	iTotalAllocSize = 0;
-    
-    iMinLength = 0;
-	iMaxLength = 0;
-	iOffset = 0;
-	iGrowBy = 0;
-	iChunkHandle = 0;
-	// iLock needs no initialisation due to default ctor
-	iBase = NULL;
-	iTop = NULL;
-	iAlign = 0;
-	iMinCell = 0;
-	iPageSize = 0;
-	iFree.len = 0;
-	iFree.next = NULL;
-	iNestingLevel = 0;
-	iAllocCount = 0;
-    iFailType = RAllocator::EReset;
-	iFailRate = 0;
-	iFailed = EFalse;
-	iFailAllocCount = 0;
-	iRand = 0;
-	iTestData = NULL;
-    }
-
-
-TBool RMemSpyDriverRHeapBase::CheckCell( TAny* aCellAddress, TInt aLength ) const
-	{
-	const TLinAddr m = TLinAddr(iAlign - 1);
-    TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapBase::CheckCell() - cell: 0x%08x, len: %8d, iAlign: %d, m: %d", aCellAddress, aLength, iAlign, m) );
-
-    TBool isValid = ETrue;
-    //
-    if ( isValid && (aLength & m) )
-        {
-    	TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapBase::CheckCell() - ERROR - length is odd: %d, iAlign: %d, m: %d", aLength, iAlign, m) );
-        isValid = EFalse;
-        }
-    if ( isValid && aLength < iMinCell )
-        {
-    	TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapBase::CheckCell() - ERROR - length: %d, is less than min cell size (%d)", aLength, iMinCell) );
-        isValid = EFalse;
-        }
-    if ( isValid && (TUint8*)aCellAddress < iBase )
-        {
-    	TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapBase::CheckCell() - ERROR - cell address: 0x%08x, is before start address: 0x%08x", (TUint8*) aCellAddress, iBase) );
-        isValid = EFalse;
-        }
-
-    if  ( isValid )
-        {
-        const TUint8* nextCell = (TUint8*)__NEXT_CELL2(aCellAddress, aLength);
-        if  ( nextCell > iTop )
-            {
-        	TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapBase::CheckCell() - ERROR - nextCell: 0x%08x is after the top of the heap: 0x%08x", nextCell, iTop) );
-            isValid = EFalse;
-            }
-        }
-    //
-    return isValid;
+	Close();
 	}
 
-
-TInt RMemSpyDriverRHeapBase::AllocatedCellHeaderSize( TBool aDebugLibrary )
-    {
-    // Allocated cells are only 4 bytes in UREL, but 12 bytes in UDEB.
-    TInt size = sizeof(SCell*);
-    //
-    if  ( aDebugLibrary )
-        {
-        size = sizeof(SDebugCell);
-        }
-    //
-    return size;
+void RMemSpyDriverRHeapBase::Close()
+	{
+	if (iHelper)
+		{
+	    NKern::ThreadEnterCS();
+		iHelper->Close();
+		delete iHelper;
+		iHelper = NULL;
+		NKern::ThreadLeaveCS();
+		}
     }
 
-
-TInt RMemSpyDriverRHeapBase::FreeCellHeaderSize()
-    {
-    // Free cells remain the same size in UREL and UDEB builds.
-    const TInt size = sizeof(SCell);
-    return size; 
-    }
-
-
-TInt RMemSpyDriverRHeapBase::CellHeaderSize( const TMemSpyDriverInternalWalkHeapParamsCell& aCell, TBool aDebugLibrary )
-    {
-    TInt size = 0;
-    //
-    if  ( aCell.iCellType == EMemSpyDriverGoodAllocatedCell )
-        {
-        size = AllocatedCellHeaderSize( aDebugLibrary );
-        }
-    else if ( aCell.iCellType == EMemSpyDriverGoodFreeCell ) 
-        {
-        size = FreeCellHeaderSize();
-        }
-    //
-    return size;
-    }
-
-
 void RMemSpyDriverRHeapBase::PrintInfo()
     {
+	/* TOMSCI TODO replace with tracing based on latest struct info. See DMemSpyDriverLogChanHeapBase::PrintHeapInfo
+	 * Alternatively just call DMemSpyDriverLogChanHeapBase::PrintHeapInfo() somehow?
+	 
 #if defined(TRACE_TYPE_KERNELHEAP) || defined(TRACE_TYPE_USERHEAP)
     Kern::Printf(" " );
     Kern::Printf("RMemSpyDriverRHeapBase::PrintInfo - RAllocator - iAccessCount:    0x%08x", iAccessCount );
@@ -173,70 +106,11 @@
     Kern::Printf(" " );
     Kern::Printf(" " );
 #endif
-    }
-
-
-void RMemSpyDriverRHeapBase::CopyObjectDataTo( TMemSpyHeapObjectDataRHeap& aData )
-    {
-    TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapBase::CopyObjectDataTo() - START" ) );
-
-    TUint8* sourceAddress = reinterpret_cast< TUint8* >( this );
-    sourceAddress += KRAllocatorAndRHeapMemberDataOffset;
-    memcpy( &aData, sourceAddress, KRHeapObjectSize );
-
-    TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapBase::CopyObjectDataTo() - END") );
+	*/
     }
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 RMemSpyDriverRHeapReadFromCopy::RMemSpyDriverRHeapReadFromCopy( DMemSpyDriverOSAdaption& aOSAdaption )
-:   iOSAdaption( aOSAdaption ), iChunk( NULL ), iChunkAddress( 0 ), iChunkMappingAttributes( 0 ), iClientToKernelDelta( 0 )
+:   iOSAdaption( aOSAdaption ), iChunk( NULL ), iChunkAddress( 0 ), iChunkMappingAttributes( 0 ) /*, iClientToKernelDelta( 0 )*/
     {
     }
 
@@ -248,7 +122,7 @@
     iChunk = NULL;
     iChunkAddress = 0;
     iChunkMappingAttributes = 0;
-    iClientToKernelDelta = 0;
+    //iClientToKernelDelta = 0;
     }
 
 
@@ -263,13 +137,13 @@
     // Calculate start of real heap data (skipping over embedded RHeap object)
     // Since we must operate with kernel-side addressing into our cloned heap chunk,
     // we must use aAddress (the kernel address of the chunk) rather than aChunk->iBase
-    iClientToKernelDelta = ( (TUint8*) aAddress ) - ( Base() - KRHeapObjectSize );
+    //TOMSCI iClientToKernelDelta = ( (TUint8*) aAddress ) - ( Base() - KRHeapObjectSize );
 
     TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapReadFromCopy::AssociateWithKernelChunk() - END - delta between client's user-side base address (base: 0x%08x), kernel-side base address (base: 0x%08x), and kernel-side chunk (base: 0x%08x) is: 0x%08x", Base(), aChunk->iBase, aAddress, iClientToKernelDelta) );
     }
 
 
-void RMemSpyDriverRHeapReadFromCopy::DisassociateWithKernelChunk()
+/*void RMemSpyDriverRHeapReadFromCopy::DisassociateWithKernelChunk()
     {
     TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapReadFromCopy::DisassociateWithKernelChunk() - START - iChunk: 0x%08x", iChunk ) );
 
@@ -283,7 +157,7 @@
 
     TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapReadFromCopy::DisassociateWithKernelChunk() - END") );
     }
-
+*/
 
 DChunk& RMemSpyDriverRHeapReadFromCopy::Chunk()
     {
@@ -297,7 +171,7 @@
     }
 
 
-TLinAddr RMemSpyDriverRHeapReadFromCopy::ChunkKernelAddress() const
+/*TLinAddr RMemSpyDriverRHeapReadFromCopy::ChunkKernelAddress() const
     {
     return iChunkAddress;
     }
@@ -308,118 +182,49 @@
     return iChunk != NULL;
     }
 
-
 TUint RMemSpyDriverRHeapReadFromCopy::ClientToKernelDelta() const
     {
     return iClientToKernelDelta;
     }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+*/
 
 
 
 
 
 RMemSpyDriverRHeapUser::RMemSpyDriverRHeapUser( DMemSpyDriverOSAdaption& aOSAdaption )
-:   RMemSpyDriverRHeapReadFromCopy( aOSAdaption )
+	: RMemSpyDriverRHeapBase(), iOSAdaption(aOSAdaption)
     {
     }
 
 
-TInt RMemSpyDriverRHeapUser::ReadFromUserAllocator( DThread& aThread )
-    {
-    TBuf8<KRHeapMemberDataSize> memberData;
-    memberData.SetMax();
-
-    NKern::ThreadEnterCS();
-    NKern::LockSystem();
-    RAllocator* allocator = OSAdaption().DThread().GetAllocator( aThread );
-    NKern::UnlockSystem();
-  	NKern::ThreadLeaveCS();
-
-    TUint8* memberDataAddress = (TUint8*) allocator + KRAllocatorAndRHeapMemberDataOffset;
-	TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapUser::ReadFromUserAllocator() - START - allocator addr: 0x%08x, therefore going to read %d bytes from address 0x%08x within client thread (0x%08x + %4d bytes)", allocator, KRHeapMemberDataSize, memberDataAddress, allocator, KRAllocatorAndRHeapMemberDataOffset ) );
-
-    const TInt error = Kern::ThreadRawRead( &aThread, memberDataAddress, (TAny*) memberData.Ptr(), KRHeapMemberDataSize );
-    TRACE_DATA( MemSpyDriverUtils::DataDump("%lS", memberData.Ptr(), KRHeapMemberDataSize, KRHeapMemberDataSize ) );
-
-    if  ( error == KErrNone )
-        {
-        TUint8* destinationAddress = reinterpret_cast< TUint8* >( this );
-
-        // Skip over our vTable too...
-        destinationAddress += KRAllocatorAndRHeapMemberDataOffset;
-
-        // Now copy data into this object
-        TPtr8 self( destinationAddress, KRHeapMemberDataSize, KRHeapMemberDataSize );
-        self.Copy( memberData );
-
-        PrintInfo();
-        }
-    else
-        {
-        }
-
-	TRACE_HEAP( Kern::Printf("RMemSpyDriverRHeapUser::ReadFromUserAllocator() - END - read error: %d", error ) );
-    return error;
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+TInt RMemSpyDriverRHeapUser::OpenUserHeap(DThread& aThread, TBool aEuserUdeb)
+	{
+	TLinAddr allocatorAddr = (TLinAddr)OSAdaption().DThread().GetAllocator(aThread);
+	NKern::ThreadEnterCS();
+	LtkUtils::RKernelSideAllocatorHelper* helper = new LtkUtils::RKernelSideAllocatorHelper;
+	if (!helper)
+		{
+		NKern::ThreadLeaveCS();
+		return KErrNoMemory;
+		}
+	TInt err = helper->OpenUserHeap(OSAdaption().DThread().GetId(aThread), allocatorAddr, aEuserUdeb);
+	if (!err)
+		{
+		iChunk = helper->OpenUnderlyingChunk();
+		if (!iChunk) err = KErrNotFound;
+		}
+	if (err)
+		{
+		delete helper;
+		}
+	else
+		{
+		iHelper = helper;
+		}
+	NKern::ThreadLeaveCS();
+	return err;
+	}
 
 RMemSpyDriverRHeapKernelFromCopy::RMemSpyDriverRHeapKernelFromCopy( DMemSpyDriverOSAdaption& aOSAdaption )
 :   RMemSpyDriverRHeapReadFromCopy( aOSAdaption )
@@ -448,6 +253,7 @@
     }
 
 
+/*
 void RMemSpyDriverRHeapKernelFromCopy::DisassociateWithKernelChunk()
     {
     TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelFromCopy::DisassociateWithKernelChunk() - START - iKernelHeap: 0x%08x", iKernelHeap ));
@@ -455,93 +261,55 @@
     RMemSpyDriverRHeapReadFromCopy::DisassociateWithKernelChunk();
     TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelFromCopy::DisassociateWithKernelChunk() - END") );
     }
-
+*/
 
-void RMemSpyDriverRHeapKernelFromCopy::GetHeapSpecificInfo( TMemSpyHeapInfo& aInfo ) const
-    {
-    TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelFromCopy::GetHeapSpecificInfo() - START - iKernelHeap: 0x%08x", iKernelHeap ));
-    //
-    if  ( iKernelHeap )
-        {
-        const TUint32* pHeap = reinterpret_cast< TUint32* >( iKernelHeap );
-        //
-        TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap();
-        TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
-        rHeapMetaData.SetVTable( *pHeap );
-        rHeapMetaData.SetClassSize( KRHeapObjectSize );
-        //
-        TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelFromCopy::GetHeapSpecificInfo() - RHeapK vtable is: 0x%08x", *pHeap ));
-        }
-    //
-    TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelFromCopy::GetHeapSpecificInfo() - END") );
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+void RMemSpyDriverRHeapKernelFromCopy::Close()
+	{
+	//TOMSCI TODO close the chunk
+	}
 
 RMemSpyDriverRHeapKernelInPlace::RMemSpyDriverRHeapKernelInPlace()
-:   iKernelHeap( NULL ), iChunk( NULL )
+	: iChunk(NULL)
     {
     }
 
-
-void RMemSpyDriverRHeapKernelInPlace::SetKernelHeap( RHeapK& aKernelHeap )
-    {
-    iKernelHeap = &aKernelHeap;
-    CopyMembersFromKernelHeap();
-    }
-
+TInt RMemSpyDriverRHeapKernelInPlace::OpenKernelHeap()
+	{
+	NKern::ThreadEnterCS();
+	LtkUtils::RAllocatorHelper* helper = new LtkUtils::RAllocatorHelper;
+	if (!helper)
+		{
+		NKern::ThreadLeaveCS();
+		return KErrNoMemory;
+		}
+	TInt err = helper->OpenKernelHeap();
+	if (!err)
+		{
+		iChunk = helper->OpenUnderlyingChunk();
+		if (!iChunk) err = KErrNotFound;
+		}
 
-void RMemSpyDriverRHeapKernelInPlace::FailNext()
-    {
-#ifndef __SYMBIAN_KERNEL_HYBRID_HEAP__
-    RMemSpyDriverRHeapKernelInPlace::RHeapKExtended* heap = reinterpret_cast< RMemSpyDriverRHeapKernelInPlace::RHeapKExtended* >( iKernelHeap );
-    heap->FailNext();
-#endif
-    }
+	if (err)
+		{
+		delete helper;
+		}
+	else
+		{
+		iHelper = helper;
+		}
+	NKern::ThreadLeaveCS();
+	return err;
+	}
 
-
-void RMemSpyDriverRHeapKernelInPlace::Reset()
+void RMemSpyDriverRHeapKernelInPlace::Close()
     {
-    RMemSpyDriverRHeapBase::Reset();
-	//
-    iChunk = NULL;
-    }
-
-
-void RMemSpyDriverRHeapKernelInPlace::AssociateWithKernelChunk( DChunk* aChunk, TLinAddr /*aAddress*/, TUint32 /*aMappingAttributes*/ )
-    {
-    TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelInPlace::AssociateWithKernelChunk() - START - aChunk: %O, aChunk base: 0x%08x", aChunk, aChunk->iBase ) );
-    iChunk = aChunk;
+	NKern::ThreadEnterCS();
+	iChunk->Close(NULL);
+	iChunk = NULL;
+	RMemSpyDriverRHeapBase::Close();
+	NKern::ThreadLeaveCS();
     }
 
-
-void RMemSpyDriverRHeapKernelInPlace::DisassociateWithKernelChunk()
-    {
-    TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelInPlace::DisassociateWithKernelChunk() - START - iChunk: 0x%08x", iChunk ));
-    iChunk = NULL;
-    iKernelHeap = NULL;
-    TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelInPlace::DisassociateWithKernelChunk() - END") );
-    }
-
-
 DChunk& RMemSpyDriverRHeapKernelInPlace::Chunk()
     {
     return *iChunk;
@@ -553,68 +321,3 @@
     return *iChunk;
     }
 
-
-TLinAddr RMemSpyDriverRHeapKernelInPlace::ChunkKernelAddress() const
-    {
-    const TLinAddr ret = reinterpret_cast< TLinAddr >( iChunk->iBase );
-    return ret;
-    }
-
-
-TBool RMemSpyDriverRHeapKernelInPlace::ChunkIsInitialised() const
-    {
-    return iChunk != NULL;
-    }
-
-
-TUint RMemSpyDriverRHeapKernelInPlace::ClientToKernelDelta() const
-    {
-    // We're operating in kernel address space, there is no delta.
-    return 0;
-    }
-
-
-void RMemSpyDriverRHeapKernelInPlace::CopyMembersFromKernelHeap()
-    {
-    TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelInPlace::CopyMembersFromKernelHeap() - START" ) );
-
-    // Perform a copy operation in order to populate base class with a duplicate of the kernel's heap info.
-    RHeapK* kernelHeap = iKernelHeap;
-
-    // Source address
-    TUint8* sourceAddress = (TUint8*) kernelHeap + KRAllocatorAndRHeapMemberDataOffset;
-    TUint8* destinationAddress = (TUint8*) this + KRAllocatorAndRHeapMemberDataOffset;
-
-    // Copy 
-    memcpy( destinationAddress, sourceAddress, KRHeapMemberDataSize );
-
-    // And print info in debug builds for verification...
-    PrintInfo();
-
-    TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelInPlace::CopyMembersFromKernelHeap() - END" ) );
-    }
-
-
-void RMemSpyDriverRHeapKernelInPlace::GetHeapSpecificInfo( TMemSpyHeapInfo& aInfo ) const
-    {
-    TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelInPlace::GetHeapSpecificInfo() - START - iKernelHeap: 0x%08x", iKernelHeap ));
-    //
-    if  ( iKernelHeap )
-        {
-        const TUint32* pHeap = reinterpret_cast< TUint32* >( iKernelHeap );
-        //
-        TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap();
-        TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
-        rHeapMetaData.SetVTable( *pHeap );
-        rHeapMetaData.SetClassSize( KRHeapObjectSize );
-        //
-        TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelInPlace::GetHeapSpecificInfo() - RHeapK vtable is: 0x%08x", *pHeap ));
-        }
-    //
-    TRACE_KH( Kern::Printf("RMemSpyDriverRHeapKernelInPlace::GetHeapSpecificInfo() - END") );
-    }
-
-
-
-
-
--- a/memspy/Driver/Kernel/Source/MemSpyDriverHeapWalker.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/MemSpyDriverHeapWalker.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -21,22 +21,14 @@
 #include "MemSpyDriverUtils.h"
 
 // Defines
-#define __NEXT_CELL(p)				((RMemSpyDriverRHeapBase::SCell*)(((TUint8*)p)+p->len))
 #define PRINTDEBUG( a ) { if ( PrintDebug() ) a; }
 
 
-RMemSpyDriverHeapWalker::RMemSpyDriverHeapWalker( RMemSpyDriverRHeapBase& aHeap, TBool aDebugAllocator )
-:   iHeap( aHeap ), iIsDebugAllocator( aDebugAllocator ), iPrintDebug( EFalse ), iObserver( NULL )
-    {
-    InitialiseStats();
-    }
-
-
-RMemSpyDriverHeapWalker::RMemSpyDriverHeapWalker( RMemSpyDriverRHeapBase& aHeap, TBool aDebugAllocator, MMemSpyHeapWalkerObserver& aObserver )
-:   iHeap( aHeap ), iIsDebugAllocator( aDebugAllocator ), iPrintDebug( EFalse ), iObserver( &aObserver )
-    {
-    InitialiseStats();
-    }
+RMemSpyDriverHeapWalker::RMemSpyDriverHeapWalker(RMemSpyDriverRHeapBase& aHeap, MMemSpyHeapWalkerObserver* aObserver)
+	: iHeap(aHeap), iPrintDebug(EFalse), iObserver(aObserver)
+	{
+	InitialiseStats();
+	}
 
 
 TInt RMemSpyDriverHeapWalker::Traverse()
@@ -44,7 +36,7 @@
 // Walk the heap calling the info function.
 //
 	{
-    PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - START - delta: 0x%08x", iHeap.ClientToKernelDelta() ));
+    PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - START"));
     InitialiseStats();
     if  ( iObserver )
         {
@@ -53,135 +45,64 @@
         }
 
     PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - heap walk init complete" ));
-    TAny* heapBase = KernelAddress( iHeap.iBase );
-    TAny* heapTop = KernelAddress( iHeap.iTop );
-	PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - kernel-side chunk address: 0x%08x, chunkBase: 0x%08x, heapBase: 0x%08x, heapTop: 0x%08x", iHeap.ChunkKernelAddress(), iHeap.Chunk().iBase, heapBase, heapTop));
-
-    TRACE_DATA( MemSpyDriverUtils::DataDump("%lS", (TUint8*) iHeap.ChunkKernelAddress(), iHeap.Chunk().iSize, iHeap.Chunk().iSize ) );
-   
-	TInt nestingLevel = 0;
-	TInt allocationNumber = 0;
-	//
-	RMemSpyDriverRHeapBase::SCell* pC = (RMemSpyDriverRHeapBase::SCell*) heapBase;		// allocated cells
-	RMemSpyDriverRHeapBase::SCell* pF = &iHeap.iFree;				            // free cells
-	PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - before while loop entry - pC: 0x%08x, pF: 0x%08x, heapBase: 0x%08x, heapTop: 0x%08x", pC, pF, heapBase, heapTop));
-    //
-    while( ( pF == &iHeap.iFree ) || ( pF >= heapBase && pF < heapTop ) )
-		{
-        pF = (RMemSpyDriverRHeapBase::SCell*) KernelAddress( pF->next );				// next free cell
-	    PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - pC: 0x%08x, pF: 0x%08x, heapBase: 0x%08x, heapTop: 0x%08x", pC, pF, heapBase, heapTop));
-
-        if  ( pF )
-        	{
-            PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - freeCell:       0x%08x", pF ));
 
-            if  ( pF >= heapBase && pF < heapTop )
-                {
-                PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - freeCell->next: 0x%08x", pF->next ));
-                PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - freeCell->len:  0x%08x", pF->len ));
-                }
-            else
-                {
-                PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - FATAL ERROR - freeCell:  0x%08x is outside heap bounds!", pF ));
-                }
+	TInt err = iHeap.Helper()->Walk(&CellCallback, this);
+    FinaliseStats();
+    //PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - END - pF: 0x%08x, pC: 0x%08x, heapBase: 0x%08x, heapTop: 0x%08x", pF, pC, heapBase, heapTop));
+	return err;
+	}
 
-            PRINTDEBUG( Kern::Printf(" "));
-            }
-		
-        if  (!pF)
-            {
-            PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - next free cell address is NULL"));
-			pF = (RMemSpyDriverRHeapBase::SCell*) heapTop;		// to make size checking work
-            }
-		else if (  (TUint8*) pF < heapBase || (TUint8*) pF >= heapTop || (KernelAddress( pF->next ) && KernelAddress( pF->next ) <= pF ) )
-			{
-			// free cell pointer off the end or going backwards
-            PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EBadFreeCellAddress: 0x%08x", pF ));
-            NotifyCell( EMemSpyDriverBadFreeCellAddress, UserAddress(pF), 0 );
-			return KErrAbort;
-			}
-		else
-			{
-			TInt l = pF->len;
-			if ( l< iHeap.iMinCell || (l & (iHeap.iAlign-1)))
-				{
-				// free cell length invalid
-                PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EBadFreeCellSize: 0x%08x", pF ));
-		        NotifyCell( EMemSpyDriverBadFreeCellSize, UserAddress(pF), l );
-			    return KErrAbort;
-				}
-			}
+TBool RMemSpyDriverHeapWalker::CellCallback(RAllocatorHelper& aHelper, TAny* aContext, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellAddress, TInt aLength)
+	{
+	return static_cast<RMemSpyDriverHeapWalker*>(aContext)->DoCellCallback(aHelper, aCellType, aCellAddress, aLength);
+	}
 
-        while ( pC != pF )				// walk allocated cells up to next free cell
-			{
-    	    if  ( pC )
-        	    {
-                // The 'next' cell field is only applicable if the cell is a 'free' cell, hence we only print the cell's
-                // address, its length, and its _calculated_ next cell (based upon address + length). Calc length is done
-                // a bit later on...
-                PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - allocCell:       0x%08x", pC ));
-                PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - allocCell->len:  0x%08x", pC->len ));
-                PRINTDEBUG( Kern::Printf(" "));
-                }
-            
-            TInt l = pC->len;
-			if (l<iHeap.iMinCell || (l & (iHeap.iAlign-1)))
-				{
-				// allocated cell length invalid
-                PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EBadAllocatedCellSize: 0x%08x", pC ));
-		        NotifyCell( EMemSpyDriverBadAllocatedCellSize, UserAddress(pC), l );
-			    return KErrAbort;
-				}
-
-            // ALLOCATED CELL
-            if  ( iIsDebugAllocator )
-                {
-                RMemSpyDriverRHeapBase::SDebugCell* debugCell = (RMemSpyDriverRHeapBase::SDebugCell*) pC;
-                nestingLevel = debugCell->nestingLevel;
-                allocationNumber = debugCell->allocCount;
-                }
-
-            PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EGoodAllocatedCell: 0x%08x", pC ));
-	        if  ( NotifyCell( EMemSpyDriverGoodAllocatedCell, UserAddress(pC), l, nestingLevel, allocationNumber ) == EFalse )
-                {
-                PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - END1 - KErrAbort on NotifyCell..."));
-			    return KErrAbort;
-                }
-
-			RMemSpyDriverRHeapBase::SCell* pN = (RMemSpyDriverRHeapBase::SCell*) __NEXT_CELL( pC );
-            PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - allocCell next:  0x%08x", pN ));
-			if (pN > pF)
-				{
-				// cell overlaps next free cell
-                PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EBadAllocatedCellAddress: 0x%08x", pC ));
-		        NotifyCell( EMemSpyDriverBadAllocatedCellAddress, UserAddress(pC), l );
-			    return KErrAbort;
-				}
-
-            pC = pN;
-			}
-
-        PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - freeCell before exit check is: 0x%08x", pF ));
-        if  ((TUint8*) pF >= heapTop )
-            {
-            PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - freeCell reached top of heap -> done"));
-			break;		// reached end of heap
-            }
-		
-        pC = (RMemSpyDriverRHeapBase::SCell*) __NEXT_CELL(pF);	// step to next allocated cell
-
-        // FREE CELL
-        PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EGoodFreeCell: 0x%08x", pF ));
-        if  ( NotifyCell( EMemSpyDriverGoodFreeCell, UserAddress(pF), pF->len ) == EFalse )
-            {
-            PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - END2 - KErrAbort on NotifyCell..."));
-			return KErrAbort;
-            }
+TBool RMemSpyDriverHeapWalker::DoCellCallback(RAllocatorHelper& aHelper, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellAddress, TInt aLength)
+	{
+	TAny* cellAddress = (TAny*)aCellAddress;
+	TMemSpyDriverCellType memspyCellType = (TMemSpyDriverCellType)aCellType; // We make sure these use the same values
+	switch (aCellType)
+		{
+		case RAllocatorHelper::EHeapBadFreeCellAddress:
+			PRINTDEBUG(Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EBadFreeCellAddress: 0x%08x", cellAddress));
+			NotifyCell(memspyCellType, cellAddress, 0);
+			return EFalse;
+		case RAllocatorHelper::EHeapBadFreeCellSize:
+			PRINTDEBUG(Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EBadFreeCellSize: 0x%08x", cellAddress));
+			NotifyCell(memspyCellType, cellAddress, aLength);
+			return EFalse;
+		case RAllocatorHelper::EHeapBadAllocatedCellSize:
+			PRINTDEBUG(Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EBadAllocatedCellSize: 0x%08x", cellAddress));
+			NotifyCell(memspyCellType, cellAddress, aLength);
+			return EFalse;
+		case RAllocatorHelper::EHeapBadAllocatedCellAddress:
+			PRINTDEBUG(Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EBadAllocatedCellAddress: 0x%08x", cellAddress));
+			NotifyCell(memspyCellType, cellAddress, aLength);
+			return EFalse;
+		default:
+			break;
 		}
 
-    FinaliseStats();
-    PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - END - pF: 0x%08x, pC: 0x%08x, heapBase: 0x%08x, heapTop: 0x%08x", pF, pC, heapBase, heapTop));
-    return KErrNone;
+	if (aCellType & RAllocatorHelper::EAllocationMask)
+		{
+		PRINTDEBUG(Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EGoodAllocatedCell: 0x%08x", cellAddress));
+		TInt nestingLevel = -1;
+		aHelper.GetCellNestingLevel(cellAddress, nestingLevel);
+		TInt allocCount = aHelper.AllocCountForCell(cellAddress);
+		if (allocCount < 0) allocCount = -1; // This is what NotifyCell expects
+		return NotifyCell(memspyCellType, cellAddress, aLength, nestingLevel, allocCount);
+		}
+	else if (aCellType & RAllocatorHelper::EFreeMask)
+		{
+		PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::Traverse() - EGoodFreeCell: 0x%08x", cellAddress));
+		return NotifyCell(memspyCellType, cellAddress, aLength);
+		}
+	else if (aCellType & RAllocatorHelper::EBadnessMask)
+		{
+		NotifyCell(memspyCellType, cellAddress, aLength);
+		return EFalse;
+		}
+	return ETrue; // For any new types that get added
 	}
 
 
@@ -219,9 +140,7 @@
     alloc.SetLargestCellAddress( (TAny*) iStats.iLargestCellAddressAlloc );
     alloc.SetLargestCellSize( iStats.iLargestCellSizeAlloc );
 
-    // Copy common info
-    TMemSpyHeapStatisticsRHeapCommon& common = aStats.StatsCommon();
-    common.SetTotalCellCount( iStats.iNumberOfWalkedCells );
+	aStats.iCommittedFreeSpace = iHeap.Helper()->CommittedFreeSpace();
 
 	PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::CopyStatsTo() - END"));
     }
@@ -233,56 +152,6 @@
     iObserver = aObserver;
     }
 
-
-TAny* RMemSpyDriverHeapWalker::KernelAddress( TAny* aUserAddress, TUint aDelta )
-    {
-    TAny* ret = NULL;
-    //
-    if  ( aUserAddress )
-        {
-	    TRACE_HEAP( Kern::Printf("RMemSpyDriverHeapWalker::KernelAddress() - aUserAddress: 0x%08x", aUserAddress));
-        ret = (TUint8*) aUserAddress + aDelta;
-        }
-    //
-	TRACE_HEAP( Kern::Printf("RMemSpyDriverHeapWalker::KernelAddress() - ret: 0x%08x", ret));
-    return ret;
-    }
-
- 
-TAny* RMemSpyDriverHeapWalker::UserAddress( TAny* aKernelAddress, TUint aDelta )
-    {
-    TAny* ret = NULL;
-    //
-    if  ( aKernelAddress )
-        {
-	    TRACE_HEAP( Kern::Printf("RMemSpyDriverHeapWalker::UserAddress() - aKernelAddress: 0x%08x", aKernelAddress));
-        ret = (TUint8*) aKernelAddress - aDelta;
-        }
-    //
-	TRACE_HEAP( Kern::Printf("RMemSpyDriverHeapWalker::UserAddress() - ret: 0x%08x", ret));
-    return ret;
-    }
-
-
-TAny* RMemSpyDriverHeapWalker::KernelAddress( TAny* aUserAddress) const
-    {
-    return KernelAddress( aUserAddress, iHeap.ClientToKernelDelta() );
-    }
-
-
-TAny* RMemSpyDriverHeapWalker::UserAddress( TAny* aKernelAddress ) const
-    {
-    return UserAddress( aKernelAddress, iHeap.ClientToKernelDelta() );
-    }
-
-
-RMemSpyDriverRHeapBase::SCell* RMemSpyDriverHeapWalker::CellByUserAddress( TAny* aAddress, TUint aDelta )
-    {
-    RMemSpyDriverRHeapBase::SCell* ret = (RMemSpyDriverRHeapBase::SCell*) KernelAddress( aAddress, aDelta );
-    return ret;
-    }
-
-
 TBool RMemSpyDriverHeapWalker::NotifyCell( TMemSpyDriverCellType aType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber )
     {
     // Update stats first
@@ -301,32 +170,9 @@
 
 void RMemSpyDriverHeapWalker::UpdateStats( TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber )
     {
-    switch( aCellType )
-        {
-    case EMemSpyDriverGoodAllocatedCell:
-        PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::UpdateStats - EGoodAllocatedCell       - 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d", aCellAddress, aLength, aNestingLevel, aAllocNumber ));
-        break;
-    case EMemSpyDriverGoodFreeCell:
-        PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::UpdateStats - EGoodFreeCell            - 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d", aCellAddress, aLength, aNestingLevel, aAllocNumber ));
-        break;
-    case EMemSpyDriverBadAllocatedCellSize:
-        Kern::Printf("RMemSpyDriverHeapWalker::UpdateStats - EBadAllocatedCellSize    - 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d", aCellAddress, aLength, aNestingLevel, aAllocNumber );
-        break;
-    case EMemSpyDriverBadAllocatedCellAddress:
-        Kern::Printf("RMemSpyDriverHeapWalker::UpdateStats - EBadAllocatedCellAddress - 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d", aCellAddress, aLength, aNestingLevel, aAllocNumber );
-        break;
-    case EMemSpyDriverBadFreeCellAddress:
-        Kern::Printf("RMemSpyDriverHeapWalker::UpdateStats - EBadFreeCellAddress      - 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d", aCellAddress, aLength, aNestingLevel, aAllocNumber );
-        break;
-    case EMemSpyDriverBadFreeCellSize:
-        Kern::Printf("RMemSpyDriverHeapWalker::UpdateStats - EBadFreeCellSize         - 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d", aCellAddress, aLength, aNestingLevel, aAllocNumber );
-        break;
-    default:
-        Kern::Printf("RMemSpyDriverHeapWalker::UpdateStats - UHANDLED TYPE!           - 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d, type: %d", aCellAddress, aLength, aNestingLevel, aAllocNumber, aCellType );
-        break;
-        }
+    PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::UpdateStats - type: %d address: 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d", aCellType, aCellAddress, aLength, aNestingLevel, aAllocNumber ));
 
-    if  ( aCellType == EMemSpyDriverGoodFreeCell )
+    if (aCellType & EMemSpyDriverFreeCellMask)
         {
         // Update checksum
         iStats.iFreeCellCRC = iStats.iFreeCellCRC ^ reinterpret_cast<TUint32>( aCellAddress );
@@ -355,7 +201,7 @@
             iStats.iFirstFreeCellAddress = (TLinAddr) aCellAddress;
             }
         }
-    else if ( aCellType == EMemSpyDriverGoodAllocatedCell )
+    else if (aCellType & EMemSpyDriverAllocatedCellMask)
         {
         // Track cell counts and length
         ++iStats.iAllocCellCount;
@@ -372,14 +218,10 @@
             iStats.iLargestCellAddressAlloc = (TLinAddr) aCellAddress;
             }
         }
-    else
-        {
-        iStats.iLastFreeCellLength = aLength;
-        }
 
     iStats.iLastCellType = aCellType;
     iStats.iLastCellAddress = (TLinAddr) aCellAddress;
-    iStats.iLastCellWasFreeCell = ( aCellType == EMemSpyDriverGoodFreeCell );
+    iStats.iLastCellWasFreeCell = (aCellType & EMemSpyDriverFreeCellMask);
     ++iStats.iNumberOfWalkedCells;
     }
 
@@ -390,7 +232,7 @@
     iStats.iNumberOfWalkedCells = 0;
     iStats.iFirstFreeCellAddress = 0;
     iStats.iFirstFreeCellLength = 0;
-    iStats.iLastCellType = EMemSpyDriverGoodAllocatedCell;
+    iStats.iLastCellType = EMemSpyDriverAllocatedCellMask;
     iStats.iLastCellWasFreeCell = EFalse;
     iStats.iLastFreeCellLength = 0;
     iStats.iTotalFreeSpace = 0;
@@ -406,10 +248,6 @@
     iStats.iLargestCellAddressFreePrevious = 0;
     iStats.iSpackSpaceCellAddress = 0;
     iStats.iLastCellAddress = 0;
-
-    // These two can be identified up front
-    iStats.iFreeCellOverheadHeaderLength = RMemSpyDriverRHeapBase::FreeCellHeaderSize();
-    iStats.iAllocCellOverheadHeaderLength = RMemSpyDriverRHeapBase::AllocatedCellHeaderSize( iIsDebugAllocator );
     }
 
 
@@ -447,4 +285,3 @@
     PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::PrintStats - iLargestCellAddressAlloc     : 0x%08x", iStats.iLargestCellAddressAlloc ) );
     PRINTDEBUG( Kern::Printf("RMemSpyDriverHeapWalker::PrintStats - iFreeCellCRC                 : 0x%08x", iStats.iFreeCellCRC ) );
     }
-
--- a/memspy/Driver/Kernel/Source/MemSpyDriverInspectedProcess.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/MemSpyDriverInspectedProcess.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -78,6 +78,7 @@
 
 TInt DMemSpyInspectedProcess::Open( DProcess* aProcess )
     {
+	__ASSERT_CRITICAL;
     TRACE( Kern::Printf("DMemSpyInspectedProcess::Open() - START - this: 0x%08x, aProcess: 0x%08x (%O)", this, aProcess, aProcess ));
 
     TInt error = KErrNone;
@@ -128,7 +129,7 @@
 
 TInt DMemSpyInspectedProcess::NotifyOnChange( DThread* aThread, TRequestStatus* aRequestStatus, TMemSpyDriverProcessInspectionInfo* aInfo )
     {
-	Kern::MutexWait( *iLock );
+	Lock();
 
     TInt err = KErrInUse;
     const TBool notificationQueued = NotifyOnChangeQueued();
@@ -158,9 +159,7 @@
 			CompleteClientsRequest( KErrNone, &cachedChange->iInfo );
 			
 			// Discard cached entry
-            NKern::ThreadEnterCS();
 			delete cachedChange;
-            NKern::ThreadLeaveCS();
 			}
         else if ( iAmDead )
             {
@@ -174,14 +173,14 @@
 	//
     TRACE( Kern::Printf("DMemSpyInspectedProcess::NotifyOnChange() - END - this: 0x%08x, err: %d", this, err ) );
 
-	Kern::MutexSignal( *iLock );
+	Unlock();
     return err;
     }
 
 
 TInt DMemSpyInspectedProcess::NotifyOnChangeCancel()
     {
-	Kern::MutexWait( *iLock );
+	Lock();
     TRACE( Kern::Printf("DMemSpyInspectedProcess::NotifyOnChangeCancel() - START - this: 0x%08x, queued: %d, iChangeObserverThread: 0x%08x, iChangeObserverRS: 0x%08x", this, NotifyOnChangeQueued(), iChangeObserverThread, iChangeObserverRS ) );
     //
     if  ( NotifyOnChangeQueued() )
@@ -194,7 +193,7 @@
         }
 	//
     TRACE( Kern::Printf("DMemSpyInspectedProcess::NotifyOnChangeCancel() - END - this: 0x%08x", this ) );
-	Kern::MutexSignal( *iLock );
+	Unlock();
 
     return KErrNone;
     }
@@ -204,9 +203,9 @@
     {
     TRACE( Kern::Printf("DMemSpyInspectedProcess::NotifyOnChangeQueued() - START - this: 0x%08x", this ) );
     //
-	Kern::MutexWait( *iLock );
+	Lock();
     const TBool queued = ( iChangeObserverRS != NULL );
-	Kern::MutexSignal( *iLock );
+	Unlock();
     //
     TRACE( Kern::Printf("DMemSpyInspectedProcess::NotifyOnChangeQueued() - END - this: 0x%08x, queued: %d", this, queued ) );
     return queued;
@@ -449,10 +448,9 @@
     const TUint procId = iDevice.OSAdaption().DProcess().GetId( aProcess );
     if  ( procId == iProcessId )
         {
-	    Kern::MutexWait( *iLock );
+	    Lock();
 
         TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleProcessUpdated() - START - this: 0x%08x, iProcess: 0x%08x (%O)", this, iProcess, iProcess ) );
-	    NKern::ThreadEnterCS();
 
         // Mark all tracked chunks as dirty whilst we work out
         // what is and isn't mapped into the process
@@ -476,10 +474,9 @@
             CompleteClientsRequest( KErrNone, &iInfoCurrent );
             }
 
-        NKern::ThreadLeaveCS();
         TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleProcessUpdated() - END - this: 0x%08x", this ) );
 
-        Kern::MutexSignal( *iLock );
+        Unlock();
         }
     }
 
@@ -491,10 +488,9 @@
 
     if  ( pid == iProcessId )
         {
-	    Kern::MutexWait( *iLock );
+	    Lock();
 
         TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleProcessRemoved() - START - this: 0x%08x", this ) );
-	    NKern::ThreadEnterCS();
 
         // We will implement a multi phased approach to the process being removed.
         //
@@ -529,10 +525,9 @@
         // Stop listening to events since we've drained everything now...
         iAmDead = ETrue;
 
-        NKern::ThreadLeaveCS();
         TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleProcessRemoved() - END - this: 0x%08x", this ) );
 
-        Kern::MutexSignal( *iLock );
+        Unlock();
         }
     }
 
@@ -600,7 +595,7 @@
 
 void DMemSpyInspectedProcess::EMHandleThreadChanged( DThread& /*aThread*/ )
     {
-	Kern::MutexWait( *iLock );
+	Lock();
 
     TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleThreadChanged() - START - this: 0x%08x", this ) );
 
@@ -608,7 +603,6 @@
     // We must be careful to only access the members of aThread that still
     // exist as if it is being destroyed, the object may be in an intermediate
     // state.
-	NKern::ThreadEnterCS();
 
     // All we are really interested in is recalculating the stack usage
     // for the process... 
@@ -617,19 +611,17 @@
     // Always inform observer about new results.
     CompleteClientsRequest( KErrNone, &iInfoCurrent );
 
-    NKern::ThreadLeaveCS();
     TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleThreadChanged() - END - this: 0x%08x", this ) );
 
-    Kern::MutexSignal( *iLock );
+    Unlock();
     }
 
 
 void DMemSpyInspectedProcess::EMHandleChunkAdd( DChunk& aChunk )
     {
-	Kern::MutexWait( *iLock );
+	Lock();
 
     TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleChunkAdd() - START - this: 0x%08x, aChunk: 0x%08x (%O)", this, &aChunk, &aChunk ) );
-	NKern::ThreadEnterCS();
 
     // Is this chunk related to our process somehow?
     if  ( IsChunkRelevantToOurProcess( aChunk ) )
@@ -656,19 +648,17 @@
             }
         }
 
-    NKern::ThreadLeaveCS();
     TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleChunkAdd() - END - this: 0x%08x", this ) );
 
-    Kern::MutexSignal( *iLock );
+    Unlock();
     }
 
 
 void DMemSpyInspectedProcess::EMHandleChunkUpdated( DChunk& aChunk )
     {
-	Kern::MutexWait( *iLock );
+	Lock();
 
     TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleChunkUpdated() - START - this: 0x%08x, aChunk: 0x%08x [S: %8d] (%O)", this, &aChunk, aChunk.Size(), &aChunk ) );
-	NKern::ThreadEnterCS();
 
     // Is this chunk mapped into our process?
     TMemSpyTrackedChunk* trackedEntry = TrackedChunkByHandle( &aChunk );
@@ -712,19 +702,17 @@
             }
         }
 
-    NKern::ThreadLeaveCS();
     TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleChunkUpdated() - END - this: 0x%08x", this ) );
 
-    Kern::MutexSignal( *iLock );
+    Unlock();
     }
 
 
 void DMemSpyInspectedProcess::EMHandleChunkDeleted( DChunk& aChunk )
     {
-	Kern::MutexWait( *iLock );
+	Lock();
 
     TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleChunkDeleted() - START - this: 0x%08x", this ) );
-	NKern::ThreadEnterCS();
 
     // Is this chunk mapped into our process?
     TMemSpyTrackedChunk* trackedEntry = TrackedChunkByHandle( &aChunk );
@@ -742,10 +730,9 @@
             }
         }
 
-    NKern::ThreadLeaveCS();
     TRACE( Kern::Printf("DMemSpyInspectedProcess::EMHandleChunkDeleted() - END - this: 0x%08x", this ) );
 
-    Kern::MutexSignal( *iLock );
+    Unlock();
     }
 
 
@@ -884,6 +871,7 @@
         TRACE( Kern::Printf("DMemSpyInspectedProcess::IsHeapChunk() - firstThread: 0x%08x (%O)", firstThread, firstThread ) );
         if  ( firstThread != NULL )
             {
+			NKern::ThreadEnterCS();
             TInt err = firstThread->Open();
             TRACE( Kern::Printf("DMemSpyInspectedProcess::IsHeapChunk() - firstThread open result: %d", err ) );
 
@@ -912,6 +900,7 @@
                 TRACE( Kern::Printf("DMemSpyInspectedProcess::IsHeapChunk() - closing first thread..." ) );
             	Kern::SafeClose( (DObject*&) firstThread, NULL );
                 }
+			NKern::ThreadLeaveCS();
             }
         }
     //
@@ -1116,6 +1105,7 @@
 
 void DMemSpyInspectedProcess::FindChunks( DProcess& aProcess )
     {
+	__ASSERT_CRITICAL;
     TRACE( Kern::Printf("DMemSpyInspectedProcess::FindChunks() - START - this: 0x%08x", this ) );
   
     DMemSpyDriverOSAdaptionDChunk& chunkAdaption = iDevice.OSAdaption().DChunk();
@@ -1125,9 +1115,11 @@
     if  ( processAdaption.IsHandleIndexValid( aProcess ) )
         {
 	    MemSpyObjectIx* processHandles = processAdaption.GetHandles( aProcess );
-        MemSpyObjectIx_Wait( processHandles );
+		
+		MemSpyObjectIx_HandleLookupLock();
+        const TInt count = processHandles->Count();
+		MemSpyObjectIx_HandleLookupUnlock();
 
-        const TInt count = processHandles->Count();
         TRACE( Kern::Printf("DMemSpyInspectedProcess::FindChunks() - got: %d handles...", count ) );
 
 	    for( TInt i=0; i<count; i++ )
@@ -1135,9 +1127,11 @@
             TRACE( Kern::Printf("DMemSpyInspectedProcess::FindChunks() - checking handle index: %2d", i ) );
 
     	    // Get a handle from the process container...
-            NKern::LockSystem();
+            MemSpyObjectIx_HandleLookupLock();
+			if (i >= processHandles->Count()) break; // Count may have changed in the meantime
     	    DObject* object = (*processHandles)[ i ];
-            NKern::UnlockSystem();
+			if (object && object->Open() != KErrNone) object = NULL;
+			MemSpyObjectIx_HandleLookupUnlock();
 
             const TObjectType objectType = ( object ? chunkAdaption.GetObjectType( *object ) : EObjectTypeAny );
             TRACE( Kern::Printf("DMemSpyInspectedProcess::FindChunks() - object: 0x%08x, type: %2d (%O)", object, objectType, object ) );
@@ -1179,9 +1173,8 @@
                         }
                     }
                 }
+			if (object) object->Close(NULL);
     	    }
-
-        MemSpyObjectIx_Signal( processHandles );
         }
 
     TRACE( Kern::Printf("DMemSpyInspectedProcess::FindChunks() - END - this: 0x%08x", this ) );
@@ -1235,6 +1228,17 @@
     }
 
 
+void DMemSpyInspectedProcess::Lock() const
+	{
+	NKern::ThreadEnterCS();
+	Kern::MutexWait(*iLock);
+	}
+
+void DMemSpyInspectedProcess::Unlock() const
+	{
+	Kern::MutexSignal(*iLock);
+	NKern::ThreadLeaveCS();
+	}
 
 
 
--- a/memspy/Driver/Kernel/Source/MemSpyDriverLogicalChannel.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/MemSpyDriverLogicalChannel.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -51,10 +51,10 @@
 
     NKern::ThreadEnterCS();
     SubChannelsDestroy();
-    NKern::ThreadLeaveCS();
 
     TRACE( Kern::Printf("DMemSpyDriverLogicalChannel::~DMemSpyDriverLogicalChannel() - closing client thread..."));
     Kern::SafeClose( (DObject*&) iClientThread, NULL );
+    NKern::ThreadLeaveCS();
 
     TRACE( Kern::Printf("DMemSpyDriverLogicalChannel::~DMemSpyDriverLogicalChannel() - calling device to cleanup..."));
     MemSpyDevice().Cleanup();
--- a/memspy/Driver/Kernel/Source/MemSpyDriverOSAdaption.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/MemSpyDriverOSAdaption.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -22,20 +22,10 @@
 #include <nk_plat.h>
 
 #ifdef __MARM__
-
 #include <arm.h>
-// Necessary when accessing data members by steam via offsets in order
-// to prevent potential unaligned data aborts
+#endif
 
-#ifdef __CC_ARM
-#define UNALIGNED_DATA_MEMBER __packed
-#endif /* __CC_ARM */
-
-#endif /* __MARM__ */
-
-#ifndef UNALIGNED_DATA_MEMBER
-#define UNALIGNED_DATA_MEMBER
-#endif
+// I've removed UNALIGNED_DATA_MEMBER in preference for just using memcpy to get round the potential unaligned access. -TomS
 
 // User includes
 #include "MemSpyDriverLog.h"
@@ -43,7 +33,7 @@
 #include "MemSpyDriverDevice.h"
 
 // Internal constants
-const TInt KMemSpyLocalThreadDataSizeEstimate = 0x80; // The amount of user stack that MemSpy attempts to scan for the RHeaep vTable
+const TInt KMemSpyLocalThreadDataSizeEstimate = 0x80; // The amount of user stack that MemSpy attempts to scan for the RHeap vTable
 
 
 
@@ -164,10 +154,9 @@
     {
     DThread* dThread = &aObject;
     TUint32 pTarget = reinterpret_cast<TUint32>( dThread ) + iOffset_ExitType;
-    UNALIGNED_DATA_MEMBER TExitType* pRet = reinterpret_cast< TExitType* >( pTarget );
-    TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetExitType() - aObject: 0x%08x, ret: 0x%08x", &aObject, pRet ) );
-    TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetExitType() - value: %d", *pRet ) );
-    return *pRet;
+	TUint8 exitType = *reinterpret_cast<TUint8*>(pTarget);
+    TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetExitType() - aObject: 0x%08x, ret: %d", &aObject, (TInt)exitType ) );
+    return (TExitType)exitType;
     }
 
 
@@ -175,10 +164,11 @@
     {
     DThread* dThread = &aObject;
     TUint32 pTarget = reinterpret_cast<TUint32>( dThread ) + iOffset_SupervisorStackBase;
-    UNALIGNED_DATA_MEMBER TUint32* pRet = reinterpret_cast< TUint32* >( pTarget );
-    TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetSupervisorStackBase() - aObject: 0x%08x, ret: 0x%08x", &aObject, pRet ) );
-    TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetSupervisorStackBase() - 0x%08x: %d", *pRet ) );
-    return *pRet;
+
+	TUint32 ret;
+	memcpy(&ret, (const TAny*)pTarget, sizeof(TUint32));
+    TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetSupervisorStackBase() - aObject: 0x%08x, ret: 0x%08x", &aObject, ret ) );
+    return ret;
     }
 
 
@@ -186,10 +176,11 @@
     {
     DThread* dThread = &aObject;
     TUint32 pTarget = reinterpret_cast<TUint32>( dThread ) + iOffset_SupervisorStackSize;
-    UNALIGNED_DATA_MEMBER TInt* pRet = reinterpret_cast< TInt* >( pTarget );
-    TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetSupervisorStackSize() - aObject: 0x%08x, ret: 0x%08x", &aObject, pRet ) );
-    TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetSupervisorStackSize() - value: %d", *pRet ) );
-    return *pRet;
+	
+	TInt ret;
+	memcpy(&ret, (const TAny*)pTarget, sizeof(TInt));
+    TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetSupervisorStackSize() - aObject: 0x%08x, ret: %d", &aObject, ret ) );
+    return ret;
     }
 
 
@@ -211,6 +202,7 @@
     }
 
 
+// TODO try to rework this without inspecting the stack!
 CActiveScheduler* DMemSpyDriverOSAdaptionDThread::GetActiveScheduler( DThread& aObject ) const
     {
     TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetActiveScheduler() - START" ) );
@@ -334,18 +326,19 @@
         }
     }
 
-
-RAllocator* DMemSpyDriverOSAdaptionDThread::GetAllocatorAndStackAddress( DThread& aObject, TUint32& aStackAddress ) const
+// TODO re-work this without inspecting the stack.
+// In particular we can get the allocator from the DThread object's iAllocator object
+RAllocator* DMemSpyDriverOSAdaptionDThread::GetAllocatorAndStackAddress( DThread& aThread, TUint32& aStackAddress ) const
     {
-    TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetAllocatorAndStackAddress() - START" ) );
+    TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetAllocatorAndStackAddress() - START for aThread 0x%08x with ID %d", &aThread, aThread.iId ) );
     //
     aStackAddress = 0;
     RAllocator* ret = NULL;
 
     // We will assume the thread is running and that the user-side stack has been set up
     // accordingly.
-    const TUint32 base = GetUserStackBase( aObject );
-    const TInt size = GetUserStackSize( aObject );
+    const TUint32 base = GetUserStackBase( aThread );
+    const TInt size = GetUserStackSize( aThread );
     TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetAllocatorAndStackAddress() - base: 0x%08x, size: %d, KMemSpyLocalThreadDataSizeEstimate: %d", base, size, KMemSpyLocalThreadDataSizeEstimate ) );
     const TUint32 top = base + size;
 
@@ -363,12 +356,20 @@
         //
         TUint32* ptr = reinterpret_cast< TUint32* >( addr );
         //
-        r = Kern::ThreadRawRead( &aObject, ptr, &value, sizeof( value ) );
+        r = Kern::ThreadRawRead( &aThread, ptr, &value, sizeof( value ) );
         if  ( r == KErrNone )
             {
-            Kern::ThreadRawRead( &aObject, reinterpret_cast< const TAny* >( value ), &possibleVTable, sizeof( possibleVTable ) );
+            r = Kern::ThreadRawRead( &aThread, reinterpret_cast< const TAny* >( value ), &possibleVTable, sizeof( possibleVTable ) );
             }
-        TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetAllocatorAndStackAddress() - stack[0x%08x] 0x%08x, vTable: 0x%08x (offset: %04d)", addr, value, possibleVTable, top - addr ) );
+
+        if ( r == KErrNone )
+            {
+            TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetAllocatorAndStackAddress() - stack[0x%08x] 0x%08x, vTable: 0x%08x (offset: %04d)", addr, value, possibleVTable, top - addr ) );
+            }
+        else
+            {
+            TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetAllocatorAndStackAddress() - stack[0x%08x] 0x%08x, (offset: %04d) read failed: %d", addr, value, top - addr, r ) );
+            }
         }
 #endif
 
@@ -379,7 +380,7 @@
         //
         TUint32* ptr = reinterpret_cast< TUint32* >( addr );
         //
-        r = Kern::ThreadRawRead( &aObject, ptr, &value, sizeof( value ) );
+        r = Kern::ThreadRawRead( &aThread, ptr, &value, sizeof( value ) );
         TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetAllocatorAndStackAddress() - read from: 0x%08x, result: %d, value: 0x%08x", addr, r, value ) );
         //
         if  ( r == KErrNone )
@@ -388,7 +389,7 @@
             // the TLD class holds an RAllocator* and we need to ascertain the vTable of the RAllocator* matches the
             // only supported vTable that MemSpy understands (RHeap*).
             TUint32 possibleVTable = 0;
-            r = Kern::ThreadRawRead( &aObject, reinterpret_cast< const TAny* >( value ), &possibleVTable, sizeof( possibleVTable ) );
+            r = Kern::ThreadRawRead( &aThread, reinterpret_cast< const TAny* >( value ), &possibleVTable, sizeof( possibleVTable ) );
             TRACE( Kern::Printf( "DMemSpyDriverOSAdaptionDThread::GetAllocatorAndStackAddress() - possible vtable read from: 0x%08x, result: %d, possibleVTable: 0x%08x", value, r, possibleVTable ) );
             if  ( r == KErrNone && possibleVTable == rHeapVTable )
                 {
@@ -448,9 +449,23 @@
     }
 
 
-DThread* DMemSpyDriverOSAdaptionDProcess::GetFirstThread( DProcess& aObject ) const
+DThread* DMemSpyDriverOSAdaptionDProcess::OpenFirstThread( DProcess& aProcess ) const
     {
-    return aObject.FirstThread();
+	// It appears that the system lock needs to be held while manipulating the iThreadQ
+	DThread* result = NULL;
+	NKern::LockSystem();
+	// We don't use DProcess::FirstThread() as that doesn't appear to do any checking of whether the list is empty, ie if there are no threads at all
+	SDblQueLink* threadLink = aProcess.iThreadQ.First();
+	if (threadLink != NULL && threadLink != &aProcess.iThreadQ.iA)
+		{
+		result = _LOFF(threadLink,DThread,iProcessLink);
+		if (result->Open() != KErrNone)
+			{
+			result = NULL;
+			}
+		}
+	NKern::UnlockSystem();
+    return result;
     }
 
 
@@ -545,6 +560,11 @@
     return (TUint8*)aObject.iDataBssStackChunk;
     }
 
+TBool DMemSpyDriverOSAdaptionDProcess::IsKernProcess(DProcess& aProcess) const
+	{
+	// The kernel process always has pid 1
+	return GetId(aProcess) == 1;
+	}
 
 
 
@@ -566,9 +586,32 @@
     }
 
 
-TUint8* DMemSpyDriverOSAdaptionDChunk::GetBase( DChunk& aObject ) const
+TUint8* DMemSpyDriverOSAdaptionDChunk::GetBase( DChunk& aChunk ) const
     {
-    return aObject.Base();
+    TUint8* base = aChunk.Base();
+	if (base == 0)
+		{
+		// Under flexible memory model, DChunk::Base() will return NULL (for non-fixed chunks anyway, and that means most of them)
+		// A more useful thing to return is the base address in the owning process
+		DProcess* proc = GetOwningProcess(aChunk);
+		NKern::ThreadEnterCS();
+		if (proc && proc->Open() == KErrNone)
+			{
+			// Probably shouldn't call ChunkUserBase for a non-user-owned chunk
+			if (!OSAdaption().DProcess().IsKernProcess(*proc))
+				{
+				DThread* firstThread = OSAdaption().DProcess().OpenFirstThread(*proc);
+				if (firstThread)
+					{
+					base = Kern::ChunkUserBase(&aChunk, firstThread);
+					firstThread->Close(NULL);
+					}
+				}
+			proc->Close(NULL);
+			}
+		NKern::ThreadLeaveCS();
+		}
+	return base; 
     }
 
 
--- a/memspy/Driver/Kernel/Source/MemSpyDriverObjectIx.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/MemSpyDriverObjectIx.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -55,6 +55,30 @@
 	{ Kern::Fault("DOBJECT",aPanic); }
 	
 
+TBool MemSpyObjectIx::Find(DObject* aObj)
+	{
+	//Check preconditions(debug build only)
+	__ASSERT_CRITICAL;
+	__ASSERT_NO_FAST_MUTEX;
+
+	// I don't like the implementation of At() that was here before, it wasn't safe at all without HandleMutex. So I'm replacing it with a simpler
+	// version based on operator[] that only does what we need and does it safely.
+
+	TBool found = EFalse;
+	MemSpyObjectIx_HandleLookupLock();
+	const TInt count = Count();
+	for (TInt i = 0; i < count; i++)
+		{
+		if ((*this)[i] == aObj)
+			{
+			found = ETrue;
+			break;
+			}
+		}
+	MemSpyObjectIx_HandleLookupUnlock();
+	return found;
+	}
+
 #if MCL_ROBJECTIX_DUPLICATION
 
 #define asserta(x)	do { if (!(x)) { __crash(); } } while(0)
@@ -65,17 +89,18 @@
     }
 
 
+/*
 void RMemSpyObjectIx::Wait()
 	{
-//	Kern::MutexWait(*HandleMutex);
+	Kern::MutexWait(*HandleMutex);
 	} // RObjectIx::Wait
 
 
 void RMemSpyObjectIx::Signal()
 	{
-//	Kern::MutexSignal(*HandleMutex);
+	Kern::MutexSignal(*HandleMutex);
 	} // RObjectIx::Signal
-
+*/
 
 DObject* RMemSpyObjectIx::operator[](TInt aIndex)
 	{
@@ -89,73 +114,19 @@
 	} // RObjectIx::operator[]
 
 
-TInt RMemSpyObjectIx::At(DObject* aObj)
-	{
-	//Check preconditions(debug build only)
-	__ASSERT_CRITICAL;
-	__ASSERT_NO_FAST_MUTEX;
-	//__ASSERT_MUTEX(HandleMutex);
-
-	if (iState==ETerminated)
-		{
-		return KErrNotFound;
-		}
-
-	TInt h = KErrNotFound;
-	AcquireWriteLock();
-	iState = (TUint8)ESearching;		// enable monitoring of new handles
-	iModList.iMonitor.iObj = aObj;		// object to check for
-	iModList.iMonitor.iBoundary = 0;	// will change if aObj is added to a slot before this point
-	TInt pos = 0;
-	while (pos<iCount && iActiveCount)	// stop if index empty
-		{
-		TInt limit = pos + EMaxLockedIter;
-		if (limit>iCount)
-			{
-			limit = iCount;
-			}
-		while (pos<limit)
-			{
-			SSlot* slot = iSlots + pos;
-			if (Occupant(slot) == aObj)
-				{
-				// found it, finish
-				h = MakeHandle(pos, slot->iUsed.iAttr);
-				break;
-				}
-			pos++;
-			}
-		if (h>0)
-			{
-			break;	// found it, finish
-			}
-		iModList.iMonitor.iBoundary = pos;	// will change if aObj is added to a slot already checked
-		ReleaseWriteLock();	// let other threads in
-		AcquireWriteLock();
-		pos = iModList.iMonitor.iBoundary;	// next position to check
-		}
-	iState = (TUint8)ENormal;
-	ReleaseWriteLock();
-	return h;
-	} // RObjectIx::At
-
-
-
-
-
-
 #elif MCL_DOBJECTIX_DUPLICATION
 
-void DMemSpyObjectIx::Wait( DMemSpyObjectIx* /*aObjectIndex*/ )
+/*
+void DMemSpyObjectIx::Wait( DMemSpyObjectIx* aObjectIndex )
 	{
 //	Kern::MutexWait(*aObjectIndex->HandleMutex);
 	}
 
-void DMemSpyObjectIx::Signal( DMemSpyObjectIx* /*aObjectIndex*/ )
+void DMemSpyObjectIx::Signal( DMemSpyObjectIx* aObjectIndex )
 	{
 //	Kern::MutexSignal(*aObjectIndex->HandleMutex);
 	}
-
+*/
 
 /** Counts the number of times an object appears in this index.
 
@@ -237,42 +208,6 @@
 	return pS->obj;
 	}
 
-
-
-/**	Looks up an object in the index by object pointer.
-
-	Returns a handle to the object.
-
-	@param	aObj	Pointer to the object to look up.
-	
-	@return	Handle to object (always >0);
-	        KErrNotFound, if object not present in index.
-
-    @pre    Calling thread must be in a critical section.
-    @pre    No fast mutex can be held.
-	@pre	Call in a thread context.
-	@pre	DObject::HandleMutex held.
- */
-TInt DMemSpyObjectIx::At(DObject* aObj)
-	{
-	//Check preconditions(debug build only)
-	__ASSERT_CRITICAL;
-	__ASSERT_NO_FAST_MUTEX;
-
-	if (iCount)
-		{
-		SDObjectIxRec* pS=iObjects;
-		SDObjectIxRec* pE=pS+iCount;
-		TInt i=0;
-		while(pS<pE && pS->obj!=aObj)
-			pS++, i++;
-		if (pS<pE)
-			return(makeHandle(i,pS->str.instance));
-		}
-	return KErrNotFound;
-	}
-
-
 /** Finds the object at a specific position in the index array.
 
 	@param	aIndex	Index into array.
--- a/memspy/Driver/Kernel/Source/MemSpyDriverStreamWriter.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/MemSpyDriverStreamWriter.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -69,7 +69,7 @@
         }
     else
         {
-        TRACE( Kern::Printf( "RMemSpyMemStreamWriter::WriteInt32() - asked to write: 0x%08x from fn: 0x%08x BUT AM FULL", aValue, __return_address() ) );
+        //TRACE( Kern::Printf( "RMemSpyMemStreamWriter::WriteInt32() - asked to write: 0x%08x from fn: 0x%08x BUT AM FULL", aValue, __return_address() ) );
         }
     //
     return ret;
@@ -89,7 +89,7 @@
         }
     else
         {
-        TRACE( Kern::Printf( "RMemSpyMemStreamWriter::WriteUint32() - asked to write: 0x%08x from fn: 0x%08x BUT AM FULL", aValue, __return_address() ) );
+        //TRACE( Kern::Printf( "RMemSpyMemStreamWriter::WriteUint32() - asked to write: 0x%08x from fn: 0x%08x BUT AM FULL", aValue, __return_address() ) );
         }
     //
     return ret;
--- a/memspy/Driver/Kernel/Source/MemSpyDriverSuspensionManager.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/MemSpyDriverSuspensionManager.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -427,10 +427,8 @@
     //
 	if ( iTempObj )
         {
-		NKern::LockSystem();
 		r = iTempObj->Open();
 	    TRACE( Kern::Printf("DMemSpySuspensionManager::OpenTempObject() - open returned: %d", r ));
-		NKern::UnlockSystem();
 		//
         if  ( r == KErrNone )
             {
@@ -499,14 +497,9 @@
 	__ASSERT_DEBUG( iTempObj, MemSpyDriverUtils::Fault( __LINE__ ) );
     if  ( iTempObj )
         {
-	    NKern::ThreadEnterCS();
-        
-        TRACE( Kern::Printf("DMemSpySuspensionManager::CloseTempObject() - in CS..." ));
+		NKern::ThreadEnterCS();
 	    Kern::SafeClose( iTempObj, NULL );
-        TRACE( Kern::Printf("DMemSpySuspensionManager::CloseTempObject() - done safe close..." ));
-	    NKern::ThreadLeaveCS();
-
-        TRACE( Kern::Printf("DMemSpySuspensionManager::CloseTempObject() - left CS" ));
+		NKern::ThreadLeaveCS();
         }
 
     TRACE( Kern::Printf("DMemSpySuspensionManager::CloseTempObject() - END" ));
--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanBase.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanBase.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -143,10 +143,8 @@
     //
 	if ( iTempObj )
         {
-		NKern::LockSystem();
 		r = iTempObj->Open();
 	    TRACE( Kern::Printf("DMemSpyDriverLogChanBase::OpenTempObject() - open returned: %d", r ));
-		NKern::UnlockSystem();
 		//
         if  ( r == KErrNone )
             {
--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanChunks.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanChunks.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -164,15 +164,18 @@
 
 	    // Iterate through each handle in the process
 	    MemSpyObjectIx* processHandles = processAdaption.GetHandles( *process );
-        MemSpyObjectIx_Wait( processHandles );
+		MemSpyObjectIx_HandleLookupLock();
+        const TInt processHandleCount = processHandles->Count();
+		MemSpyObjectIx_HandleLookupUnlock();
 
-        const TInt processHandleCount = processHandles->Count();
 	    for( TInt processHandleIndex = 0; processHandleIndex<processHandleCount && r == KErrNone && currentWriteIndex < maxCount; processHandleIndex++ )
     	    {
     	    // Get a handle from the process container...
-            NKern::LockSystem();
+            MemSpyObjectIx_HandleLookupLock();
+			if (processHandleIndex >= processHandles->Count()) break; // Count may have changed in the meantime
     	    DObject* object = (*processHandles)[ processHandleIndex ];
-            NKern::UnlockSystem();
+			if (object && object->Open() != KErrNone) object = NULL;
+			MemSpyObjectIx_HandleLookupUnlock();
             
             if  ( object )
                 {
@@ -187,11 +190,10 @@
                         ++currentWriteIndex;
                         }
                     }
+				object->Close(NULL);
                 }
     	    }
 
-        MemSpyObjectIx_Signal( processHandles );
-
         // If we were asked for process-related chunks, also check the chunk container
         // for entries which we don't have handles to, but do refer to our process
         // Need a listing of all chunks in the system. Let client filter duplicates.
@@ -276,34 +278,36 @@
 	NKern::ThreadEnterCS();
 
     container->Wait();
-    NKern::LockSystem();
     const TInt count = container->Count();
-    NKern::UnlockSystem();
 
     DChunk* foundChunk = NULL;
     
     for(TInt i=0; i<count; i++)
         {
-        NKern::LockSystem();
         DChunk* chunk = (DChunk*) (*container)[i];
-        NKern::UnlockSystem();
-        //
         if  ( chunk == params.iHandle )
             {
             foundChunk = chunk;
             TRACE( PrintChunkInfo( *chunk ) );
+			r = foundChunk->Open();
             break;
             }
         }
 
     container->Signal();
-	NKern::ThreadLeaveCS();
 
     if  ( foundChunk == NULL )
         {
     	Kern::Printf("DMemSpyDriverLogChanChunks::GetChunkInfo() - END - KErrNotFound - couldnt find chunk");
+		NKern::ThreadLeaveCS();
         return KErrNotFound;
         }
+	if (r)
+		{
+		Kern::Printf("DMemSpyDriverLogChanChunks::GetChunkInfo() - END - %d - Failed to open chunk", r);
+		NKern::ThreadLeaveCS();
+		return r;
+		}
 
     // Prepare return data
     DMemSpyDriverOSAdaptionDChunk& chunkAdaption = OSAdaption().DChunk();
@@ -335,6 +339,10 @@
     // Get type & attribs
     params.iType = IdentifyChunkType( *foundChunk );
     params.iAttributes = chunkAdaption.GetAttributes( *foundChunk );
+
+	// Finished with foundChunk
+	foundChunk->Close(NULL);
+	NKern::ThreadLeaveCS();
     
     // Write back to client
     r = Kern::ThreadRawWrite( &ClientThread(), aParams, &params, sizeof(TMemSpyDriverInternalChunkInfoParams) );
@@ -470,40 +478,36 @@
 
     if  ( process && size >= 4 )
         {
+		NKern::ThreadEnterCS();
         // Chunks are mapped into entire process so any thread within the process is enough...
-        DThread* firstThread = processAdaption.GetFirstThread( *process );
+        DThread* firstThread = processAdaption.OpenFirstThread( *process );
         TRACE( Kern::Printf("DMemSpyDriverLogChanChunks::IsHeapChunk() - firstThread: 0x%08x (%O)", firstThread, firstThread ) );
         if  ( firstThread != NULL )
             {
-            TInt err = firstThread->Open();
-            TRACE( Kern::Printf("DMemSpyDriverLogChanChunks::IsHeapChunk() - firstThread open result: %d", err ) );
-
+            TBuf8<4> allocatorVTableBuffer;
+            TInt err = Kern::ThreadRawRead( firstThread, base, (TUint8*) allocatorVTableBuffer.Ptr(), allocatorVTableBuffer.MaxLength() );
+            TRACE( Kern::Printf("DMemSpyDriverLogChanChunks::IsHeapChunk - read result of vtable data from requested thread is: %d", err ));
+            //
             if  ( err == KErrNone )
                 {
-                TBuf8<4> allocatorVTableBuffer;
-                err = Kern::ThreadRawRead( firstThread, base, (TUint8*) allocatorVTableBuffer.Ptr(), allocatorVTableBuffer.MaxLength() );
-                TRACE( Kern::Printf("DMemSpyDriverLogChanChunks::IsHeapChunk - read result of vtable data from requested thread is: %d", err ));
-                //
-                if  ( err == KErrNone )
-                    {
-                    TRACE( MemSpyDriverUtils::DataDump("possible chunk vtable data - %lS", allocatorVTableBuffer.Ptr(), allocatorVTableBuffer.MaxLength(), allocatorVTableBuffer.MaxLength() ) );
-                    allocatorVTableBuffer.SetLength( allocatorVTableBuffer.MaxLength() );
-                    
-                    const TUint32 vtable =   allocatorVTableBuffer[0] +
-                                            (allocatorVTableBuffer[1] << 8) + 
-                                            (allocatorVTableBuffer[2] << 16) + 
-                                            (allocatorVTableBuffer[3] << 24);
-                    TRACE( Kern::Printf("DMemSpyDriverLogChanChunks::IsHeapChunk - [possible] vTable within chunk is: 0x%08x", vtable) );
+                TRACE( MemSpyDriverUtils::DataDump("possible chunk vtable data - %lS", allocatorVTableBuffer.Ptr(), allocatorVTableBuffer.MaxLength(), allocatorVTableBuffer.MaxLength() ) );
+                allocatorVTableBuffer.SetLength( allocatorVTableBuffer.MaxLength() );
+                
+                const TUint32 vtable =   allocatorVTableBuffer[0] +
+                                        (allocatorVTableBuffer[1] << 8) + 
+                                        (allocatorVTableBuffer[2] << 16) + 
+                                        (allocatorVTableBuffer[3] << 24);
+                TRACE( Kern::Printf("DMemSpyDriverLogChanChunks::IsHeapChunk - [possible] vTable within chunk is: 0x%08x", vtable) );
 
-                    // Check the v-table to work out if it really is an RHeap
-                    isHeap = ( vtable == rHeapVTable );
-                    TRACE( Kern::Printf("DMemSpyDriverLogChanChunks::IsHeapChunk() - isHeap: %d", isHeap ) );
-                    }
+                // Check the v-table to work out if it really is an RHeap
+                isHeap = ( vtable == rHeapVTable );
+                TRACE( Kern::Printf("DMemSpyDriverLogChanChunks::IsHeapChunk() - isHeap: %d", isHeap ) );
+                }
 
-                TRACE( Kern::Printf("DMemSpyDriverLogChanChunks::IsHeapChunk() - closing first thread..." ) );
-            	Kern::SafeClose( (DObject*&) firstThread, NULL );
-                }
+            TRACE( Kern::Printf("DMemSpyDriverLogChanChunks::IsHeapChunk() - closing first thread..." ) );
+            Kern::SafeClose( (DObject*&) firstThread, NULL );
             }
+		NKern::ThreadLeaveCS();
         }
 
     /* We only want RHeap's at the moment
--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanClientServer.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanClientServer.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -96,8 +96,8 @@
     NKern::ThreadEnterCS();
 
     DObject* serverHandle = (DObject*) params.iServerHandle;
-    serverHandle = CheckIfObjectIsInContainer( EMemSpyDriverContainerTypeServer, serverHandle );
-    if  ( serverHandle == NULL )
+    DServer* server = static_cast<DServer*>(CheckedOpen(EMemSpyDriverContainerTypeServer, serverHandle));
+    if (server == NULL)
         {
     	Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionHandles() - END - server not found");
         NKern::ThreadLeaveCS();
@@ -106,47 +106,29 @@
 
 	ResetTempHandles();
 
-    DServer* server = (DServer*) serverHandle;
-    NKern::LockSystem();
-
-    r = server->Open();
-    if  ( r == KErrNone )
+    NKern::LockSystem(); // Iterating session queue requires system lock
+    // Iterate through this server's sessions, writing back session pointer (handle)
+    // to client
+    SDblQue& serverQueue = serverAdaption.GetSessionQueue( *server );
+    SDblQueLink* anchor = &serverQueue.iA;
+    SDblQueLink* link = serverQueue.First();
+    while( link != anchor )
         {
-        // Iterate through this server's sessions, writing back session pointer (handle)
-        // to client
-        SDblQue& serverQueue = serverAdaption.GetSessionQueue( *server );
-        SDblQueLink* anchor = &serverQueue.iA;
-        SDblQueLink* link = serverQueue.First();
-        while( link != anchor )
-        	{
-			DSession* session = serverAdaption.GetSession( link );
+		DSession* session = serverAdaption.GetSession( link );
 
-            // Found a match in the specified container. Write the object's handle (aka the object address)
-            // back to the client address space
-            if  ( session )
-                {
-                AddTempHandle( session );
-                }
-
-            // Get next item
-            link = link->iNext;
+        // Found a match in the specified container. Write the object's handle (aka the object address)
+        // back to the client address space
+        if  ( session )
+            {
+            AddTempHandle( session );
             }
 
-        NKern::ThreadEnterCS();
-        TRACE( Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionHandles() - in CS..." ));
-        //
-	    Kern::SafeClose( (DObject*&) server, NULL );
-        TRACE( Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionHandles() - done safe close..." ));
-        //
-	    NKern::ThreadLeaveCS();
-        TRACE( Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionHandles() - left CS" ));
+        // Get next item
+        link = link->iNext;
         }
-    else
-        {
-    	Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionHandles - error: %d opening server", r);
-        }
-
     NKern::UnlockSystem();
+	server->Close(NULL);
+	NKern::ThreadLeaveCS();
 
     // This variable holds the number of handles that we have already
 	// written to the client-side.
@@ -176,7 +158,6 @@
             }
         }
 
-	NKern::ThreadLeaveCS();
 
 	TRACE( Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionHandles() - END - r: %d", r));
 	return r;
@@ -199,74 +180,48 @@
 
 	NKern::ThreadEnterCS();
 
-    DObject* sessionHandle = (DObject*) aSessionHandle;
-    sessionHandle = CheckIfObjectIsInContainer( EMemSpyDriverContainerTypeSession, sessionHandle );
-    if  ( sessionHandle == NULL )
+    DSession* session = (DSession*)CheckedOpen(EMemSpyDriverContainerTypeSession, (DObject*)aSessionHandle);
+    if (session == NULL )
         {
     	Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionInfo() - END - session not found");
         NKern::ThreadLeaveCS();
         return KErrNotFound;
         }
 
-    DSession* session = (DSession*) sessionHandle;
     session->FullName( params.iName );
 
-    NKern::LockSystem();
-    r = session->Open();
-    if  ( r == KErrNone )
+    // Get owner type and id
+    DObject* sessionOwner = sessionAdaption.GetOwner( *session );
+    if  ( sessionOwner )
         {
-        // Get owner type and id
-        DObject* sessionOwner = sessionAdaption.GetOwner( *session );
-        if  ( sessionOwner )
+        const TObjectType objectType = sessionAdaption.GetObjectType( *sessionOwner );
+        if  ( objectType == EProcess )
             {
-            const TObjectType objectType = sessionAdaption.GetObjectType( *sessionOwner );
-            if  ( objectType == EProcess )
-                {
-                DProcess* sessionProcess = (DProcess*) sessionOwner;
-                //
-                params.iOwnerId = processAdaption.GetId( *sessionProcess );
-                params.iOwnerType = TMemSpyDriverServerSessionInfo::EOwnerProcess;
-                }
-            else if ( objectType == EThread )
-                {
-                DThread* sessionThread = (DThread*) sessionOwner;
-                //
-                params.iOwnerId = threadAdaption.GetId( *sessionThread );
-                params.iOwnerType = TMemSpyDriverServerSessionInfo::EOwnerThread;
-                }
+            DProcess* sessionProcess = (DProcess*) sessionOwner;
+            //
+            params.iOwnerId = processAdaption.GetId( *sessionProcess );
+            params.iOwnerType = TMemSpyDriverServerSessionInfo::EOwnerProcess;
             }
-        else
+        else if ( objectType == EThread )
             {
-            params.iOwnerId = -1;
-            params.iOwnerType = TMemSpyDriverServerSessionInfo::EOwnerNone;
+            DThread* sessionThread = (DThread*) sessionOwner;
+            //
+            params.iOwnerId = threadAdaption.GetId( *sessionThread );
+            params.iOwnerType = TMemSpyDriverServerSessionInfo::EOwnerThread;
             }
-
-        // Other attributes
-        params.iSessionType = sessionAdaption.GetSessionType( *session );
-        params.iAddress = (TUint8*)session;
-
-        NKern::ThreadEnterCS();
-        TRACE( Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionInfo() - in CS..." ));
-        //
-	    Kern::SafeClose( (DObject*&) session, NULL );
-        TRACE( Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionInfo() - done safe close..." ));
-        //
-	    NKern::ThreadLeaveCS();
-        TRACE( Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionInfo() - left CS" ));
         }
     else
         {
-    	Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionInfo - error: %d opening server", r);
+        params.iOwnerId = -1;
+        params.iOwnerType = TMemSpyDriverServerSessionInfo::EOwnerNone;
         }
 
-    NKern::UnlockSystem();
-
-    if  ( r == KErrNone )
-        {
-        r = Kern::ThreadRawWrite( &ClientThread(), aParams, &params, sizeof(TMemSpyDriverServerSessionInfo) );
-        }
-
+    // Other attributes
+    params.iSessionType = sessionAdaption.GetSessionType( *session );
+    params.iAddress = (TUint8*)session;
+	session->Close(NULL);
 	NKern::ThreadLeaveCS();
+    r = Kern::ThreadRawWrite( &ClientThread(), aParams, &params, sizeof(TMemSpyDriverServerSessionInfo) );
 
 	TRACE( Kern::Printf("DMemSpyDriverLogChanClientServer::GetServerSessionInfo() - END - r: %d", r));
 	return r;
--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanContainerBase.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanContainerBase.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -49,58 +49,44 @@
 
 
 
-
-
-
-DObject* DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer( TMemSpyDriverContainerType aContainerType, DObject* aSearchFor, TBool aQuick )
-    {
-	__ASSERT_DEBUG( aSearchFor != NULL, MemSpyDriverUtils::Fault( __LINE__ ) );
-    const TObjectType expectedType = ObjectTypeFromMemSpyContainerType( aContainerType );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer - START - aSearchFor: 0x%08x, expectedType: %d", aSearchFor, expectedType ));
+DObject* DMemSpyDriverLogChanContainerBase::CheckedOpen(TMemSpyDriverContainerType aContainerType, DObject* aObject, TBool aQuick)
+	{
+	__ASSERT_CRITICAL;
+	__ASSERT_DEBUG(aObject != NULL, MemSpyDriverUtils::Fault( __LINE__ ));
+    const TObjectType expectedType = ObjectTypeFromMemSpyContainerType(aContainerType);
 
-    DObject* ret = NULL;
-    
-    // Quick mode means we just check container ids and we trust that the object
-    // will exist.
-    if ( aQuick )
+    // Quick mode means we just check container ids and we trust that the object will exist.
+	// [TomS: not entirely convinced we can ever be certain of that]
+    TInt err = KErrNotFound;
+    if (aQuick)
         {
-        const TObjectType objectType = OSAdaption().DThread().GetObjectType( *aSearchFor );
-        TRACE( Kern::Printf("DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer - aSearchFor.iContainerID: %d", objectType ) );
-        if  ( objectType == expectedType )
+		LOG("quick CheckedOpen of %08x", aObject);
+        const TObjectType objectType = OSAdaption().DThread().GetObjectType(*aObject);
+        if (objectType == expectedType)
             {
-            ret = aSearchFor;
+            err = aObject->Open();
             }
         }
-    else
-        {
-        // Full check to see if the specified object is part of the container
-        DObjectCon* container = Kern::Containers()[ expectedType ];
+	else
+		{
+        DObjectCon* container = Kern::Containers()[expectedType];
         container->Wait();
-        NKern::LockSystem();
-
         const TInt count = container->Count();
-        for(TInt i=0; i<count; i++)
+        for (TInt i = 0; i < count; i++)
             {
-            DObject* object = (*container)[ i ];
-
-            // Do the two match?
-            if  ( object == aSearchFor )
+            DObject* object = (*container)[i];
+            if (object == aObject)
                 {
-                TRACE( Kern::Printf("    found match: %O", object));
-
-                ret = object;
-                break;
-                }
-            }
+                err = aObject->Open();
+				break;
+				}
+			}
+		container->Signal();
+		}
 
-        NKern::UnlockSystem();
-        container->Signal();
-        }
-
-    TRACE( Kern::Printf("DMemSpyDriverLogChanContainerBase::CheckIfObjectIsInContainer - END - ret: 0x%08x", ret ));
-    TRACE( Kern::Printf(" ") );
-    return ret;
-    }
+	LOG("CheckedOpen(%d, 0x%08x, quick=%d) returned error %d", aContainerType, aObject, aQuick, err);
+	return (err == KErrNone) ? aObject : NULL;
+	}
 
 
 
--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanContainers.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanContainers.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -146,7 +146,6 @@
 
         DObjectCon* container = Kern::Containers()[type];
         container->Wait();
-        NKern::LockSystem();
 
         const TInt count = container->Count();
         for(TInt i=0; i<count; i++)
@@ -158,9 +157,7 @@
                 }
             }
 
-        NKern::UnlockSystem();
         container->Signal();
-
     	NKern::ThreadLeaveCS();
         }
     else
@@ -214,34 +211,30 @@
 
                 // Iterate through each handle in the thread/process and add it to the temp handles container if
                 // the handle is of the correct type.
-                MemSpyObjectIx_Wait( handles );
 
-	            TInt handleCount = handles->Count();
+				MemSpyObjectIx_HandleLookupLock();
+				const TInt handleCount = handles->Count();
+				MemSpyObjectIx_HandleLookupUnlock();
                 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetContainerHandles - %d handles in index...", handleCount ));
 
                 for( TInt handleIndex=0; handleIndex<handleCount; handleIndex++ )
     	            {
     	            // Get a handle from the container...
-                    NKern::LockSystem();
-    	            DObject* objectToSearchFor = (*handles)[ handleIndex ];
-                    NKern::UnlockSystem();
+					MemSpyObjectIx_HandleLookupLock();
+					if (handleIndex >= handles->Count()) break; // Count may have changed in the meantime
+    				DObject* objectToSearchFor = (*handles)[ handleIndex ];
+					if (objectToSearchFor && objectToSearchFor->Open() != KErrNone) objectToSearchFor = NULL;
+					MemSpyObjectIx_HandleLookupUnlock();
         
-                    if  ( objectToSearchFor != NULL )
+                    if (objectToSearchFor && OSAdaption().DThread().GetObjectType(*objectToSearchFor) == ObjectTypeFromMemSpyContainerType(params.iContainer))
                         {
-                        // Check to see if this object is of the specified type. We can use quick mode
-                        // because we know the object is valid since it's registered as a handle of the
-                        // thread/process.
-                        DObject* matchResult = CheckIfObjectIsInContainer( params.iContainer, objectToSearchFor, ETrue );
-                        if  ( matchResult )
-                            {
-                            // Found a match in the specified container. Write the object's handle (aka the object address)
-                            // back to the client address space
-                            AddTempHandle( matchResult );
-                            }
+                        // Found a match in the specified container. Write the object's handle (aka the object address)
+                        // back to the client address space
+                        AddTempHandle( objectToSearchFor );
                         }
+					if (objectToSearchFor) objectToSearchFor->Close(NULL);
     	            }
 
-                MemSpyObjectIx_Signal( handles );
                 NKern::ThreadLeaveCS();
                 }
 
@@ -307,30 +300,21 @@
 
     // First, locate the specific DObject in question. Cast the handle, but don't use the object...
     DObject* handleAsObject = (DObject*) params.iHandle;
-    handleAsObject = CheckIfObjectIsInContainer( params.iType, handleAsObject );
+    handleAsObject = CheckedOpen(params.iType, handleAsObject);
     if  ( handleAsObject != NULL )
         {
         // We found the right object. First get generic info.
         handleAsObject->FullName( params.iName );
         handleAsObject->Name( params.iNameDetail );
         
-        NKern::LockSystem();
-        r = handleAsObject->Open();
-        NKern::UnlockSystem();
-        //
-        if  ( r == KErrNone )
-            {
-            // Using threadAddaption to fetch generic info.
-            // Implementations of following get functions are actually in DMemSpyDriverOSAdaptionDObject
-            // so it does not matter what adaption to use for generic info.
-            DMemSpyDriverOSAdaptionDThread& threadAddaption = OSAdaption().DThread();
-            params.iAccessCount = threadAddaption.GetAccessCount( *handleAsObject );
-            params.iUniqueID = threadAddaption.GetUniqueID( *handleAsObject );
-            params.iProtection = threadAddaption.GetProtection( *handleAsObject );
-            params.iAddressOfKernelOwner = threadAddaption.GetAddressOfKernelOwner( *handleAsObject );
-            //
-            handleAsObject->Close( NULL );
-            }
+        // Using threadAddaption to fetch generic info.
+        // Implementations of following get functions are actually in DMemSpyDriverOSAdaptionDObject
+        // so it does not matter what adaption to use for generic info.
+        DMemSpyDriverOSAdaptionDThread& threadAddaption = OSAdaption().DThread();
+        params.iAccessCount = threadAddaption.GetAccessCount( *handleAsObject );
+        params.iUniqueID = threadAddaption.GetUniqueID( *handleAsObject );
+        params.iProtection = threadAddaption.GetProtection( *handleAsObject );
+        params.iAddressOfKernelOwner = threadAddaption.GetAddressOfKernelOwner( *handleAsObject );
         
         // Get type-specific info.
         if  ( params.iType == EMemSpyDriverContainerTypeThread )
@@ -338,76 +322,49 @@
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeThread" ));
 
             DThread* object = (DThread*) handleAsObject;
-	        NKern::LockSystem();
-            r = object->Open();
-    	    NKern::UnlockSystem();
+            DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread();
             //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDThread& threadAdaption = OSAdaption().DThread();
-                //
-                params.iId = threadAdaption.GetId( *object );
-                params.iPriority = threadAdaption.GetPriority( *object );
-                params.iAddressOfOwningProcess = threadAdaption.GetAddressOfOwningProcess( *object );
-                threadAdaption.GetNameOfOwningProcess( *object, params.iNameOfOwner );
-                //
-                object->Close( NULL );
-                }
+            params.iId = threadAdaption.GetId( *object );
+            params.iPriority = threadAdaption.GetPriority( *object );
+            params.iAddressOfOwningProcess = threadAdaption.GetAddressOfOwningProcess( *object );
+            threadAdaption.GetNameOfOwningProcess( *object, params.iNameOfOwner );
             }
         else if ( params.iType == EMemSpyDriverContainerTypeProcess )
             {
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeProcess" ));
 
             DProcess* object = (DProcess*) handleAsObject;
-	        NKern::LockSystem();
-            r = object->Open();
-    	    NKern::UnlockSystem();
+            DMemSpyDriverOSAdaptionDProcess& processAdaption = OSAdaption().DProcess();
+            //
+            params.iId = processAdaption.GetId( *object );
             //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDProcess& processAdaption = OSAdaption().DProcess();
-                //
-                params.iId = processAdaption.GetId( *object );
-                //
-                params.iPriority = processAdaption.GetPriority( *object );
-                params.iAddressOfOwningProcess = processAdaption.GetAddressOfOwningProcess( *object );
-                params.iCreatorId = processAdaption.GetCreatorId( *object );
-                params.iSecurityZone = processAdaption.GetSecurityZone( *object );
-                params.iAttributes = processAdaption.GetAttributes( *object );
-                params.iAddressOfDataBssStackChunk = processAdaption.GetAddressOfDataBssStackChunk( *object );
-                //
-                object->Close( NULL );
-                }
+            params.iPriority = processAdaption.GetPriority( *object );
+            params.iAddressOfOwningProcess = processAdaption.GetAddressOfOwningProcess( *object );
+            params.iCreatorId = processAdaption.GetCreatorId( *object );
+            params.iSecurityZone = processAdaption.GetSecurityZone( *object );
+            params.iAttributes = processAdaption.GetAttributes( *object );
+            params.iAddressOfDataBssStackChunk = processAdaption.GetAddressOfDataBssStackChunk( *object );
             }
         else if ( params.iType == EMemSpyDriverContainerTypeChunk )
             {
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeChunk" ));
 
             DChunk* object = (DChunk*) handleAsObject;
-	        NKern::LockSystem();
-            r = object->Open();
-    	    NKern::UnlockSystem();
+            DMemSpyDriverOSAdaptionDChunk& ca = OSAdaption().DChunk();
             //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDChunk& ca = OSAdaption().DChunk();
-                //
-                params.iSize = ca.GetSize( *object );
-                params.iId = ca.GetOwningProcessId( *object );
-                params.iAddressOfOwningProcess = ca.GetAddressOfOwningProcess( *object );
-                params.iMaxSize = ca.GetMaxSize( *object );
-                params.iBottom = ca.GetBottom( *object );
-                params.iTop = ca.GetTop( *object );
-                params.iAttributes = ca.GetAttributes( *object );
-                params.iStartPos = ca.GetStartPos( *object );
-                params.iControllingOwner = ca.GetControllingOwnerId( *object );
-                params.iRestrictions = ca.GetRestrictions( *object );
-                params.iMapAttr = ca.GetMapAttr( *object );
-                params.iChunkType = ca.GetType( *object );
-                ca.GetNameOfOwningProcess( *object, params.iNameOfOwner );
-                //
-                object->Close( NULL );
-                }
+            params.iSize = ca.GetSize( *object );
+            params.iId = ca.GetOwningProcessId( *object );
+            params.iAddressOfOwningProcess = ca.GetAddressOfOwningProcess( *object );
+            params.iMaxSize = ca.GetMaxSize( *object );
+            params.iBottom = ca.GetBottom( *object );
+            params.iTop = ca.GetTop( *object );
+            params.iAttributes = ca.GetAttributes( *object );
+            params.iStartPos = ca.GetStartPos( *object );
+            params.iControllingOwner = ca.GetControllingOwnerId( *object );
+            params.iRestrictions = ca.GetRestrictions( *object );
+            params.iMapAttr = ca.GetMapAttr( *object );
+            params.iChunkType = ca.GetType( *object );
+            ca.GetNameOfOwningProcess( *object, params.iNameOfOwner );
             }
         else if ( params.iType == EMemSpyDriverContainerTypeLibrary )
             {
@@ -416,28 +373,19 @@
 	        Kern::AccessCode();
             //
             DLibrary* object = (DLibrary*) handleAsObject;
-	        NKern::LockSystem();
-            r = object->Open();
-    	    NKern::UnlockSystem();
+            DMemSpyDriverOSAdaptionDCodeSeg& csa = OSAdaption().DCodeSeg();
+            DCodeSeg* codeSeg = csa.GetCodeSeg( *object );
+            params.iAddressOfCodeSeg = (TUint8*)codeSeg;
+            params.iMapCount = csa.GetMapCount( *object );
+            params.iState = csa.GetState( *object );
             //
-            if  ( r == KErrNone )
+            if  ( codeSeg )
                 {
-                DMemSpyDriverOSAdaptionDCodeSeg& csa = OSAdaption().DCodeSeg();
-                DCodeSeg* codeSeg = csa.GetCodeSeg( *object );
-                params.iAddressOfCodeSeg = (TUint8*)codeSeg;
-                params.iMapCount = csa.GetMapCount( *object );
-                params.iState = csa.GetState( *object );
-                //
-                if  ( codeSeg )
-                    {
-                    params.iSize = csa.GetSize( *codeSeg );
-                    }
-                else
-                    {
-                    r = KErrNotFound;
-                    }
-                //
-                object->Close( NULL );
+                params.iSize = csa.GetSize( *codeSeg );
+                }
+            else
+                {
+                r = KErrNotFound;
                 }
             //
 	        Kern::EndAccessCode();
@@ -447,39 +395,21 @@
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeSemaphore" ));
 
             DSemaphore* object = (DSemaphore*) handleAsObject;
-	        NKern::LockSystem();
-            r = object->Open();
-    	    NKern::UnlockSystem();
-            //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDSemaphore& sa = OSAdaption().DSemaphore();
-                params.iCount = sa.GetCount( *object );
-                params.iResetting = sa.GetResetting( *object );
-                //
-                object->Close( NULL );
-                }
+            DMemSpyDriverOSAdaptionDSemaphore& sa = OSAdaption().DSemaphore();
+            params.iCount = sa.GetCount( *object );
+            params.iResetting = sa.GetResetting( *object );
             }
         else if ( params.iType == EMemSpyDriverContainerTypeMutex )
             {
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeMutex" ));
 
             DMutex* object = (DMutex*) handleAsObject;
-	        NKern::LockSystem();
-            r = object->Open();
-    	    NKern::UnlockSystem();
+            DMemSpyDriverOSAdaptionDMutex& ma = OSAdaption().DMutex();
             //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDMutex& ma = OSAdaption().DMutex();
-                //
-                params.iCount = ma.GetHoldCount( *object );
-                params.iWaitCount = ma.GetWaitCount( *object );
-                params.iResetting = ma.GetResetting( *object );
-                params.iOrder = ma.GetOrder( *object );
-                //
-                object->Close( NULL );
-                }
+            params.iCount = ma.GetHoldCount( *object );
+            params.iWaitCount = ma.GetWaitCount( *object );
+            params.iResetting = ma.GetResetting( *object );
+            params.iOrder = ma.GetOrder( *object );
             }
         else if ( params.iType == EMemSpyDriverContainerTypeTimer )
             {
@@ -487,98 +417,62 @@
 
             // Get timer properties
             DTimer* object = (DTimer*) handleAsObject;
-	        NKern::LockSystem();
-            r = object->Open();
-    	    NKern::UnlockSystem();
+            DMemSpyDriverOSAdaptionDTimer& ta = OSAdaption().DTimer();
             //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDTimer& ta = OSAdaption().DTimer();
-                //
-                params.iTimerType = MapToMemSpyTimerType( ta.GetType( *object ) );
-                params.iTimerState = MapToMemSpyTimerState( ta.GetState( *object ) );
-                //
-                object->Close( NULL );
-                }
+            params.iTimerType = MapToMemSpyTimerType( ta.GetType( *object ) );
+            params.iTimerState = MapToMemSpyTimerState( ta.GetState( *object ) );
             }
         else if ( params.iType == EMemSpyDriverContainerTypeServer )
             {
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeServer" ));
 
             DServer* object = (DServer*) handleAsObject;
-	        NKern::LockSystem();
-            r = object->Open();
-    	    NKern::UnlockSystem();
+            DMemSpyDriverOSAdaptionDServer& sa = OSAdaption().DServer();
             //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDServer& sa = OSAdaption().DServer();
-                //
-                params.iCount = sa.GetSessionCount( *object );
-                params.iId = sa.GetOwningThreadId( *object );
-                params.iSessionType = sa.GetSessionType( *object );
-                params.iAddressOfOwningThread = sa.GetAddressOfOwningThread( *object );
-                sa.GetNameOfOwningThread( *object, params.iNameOfOwner );
-                //
-                object->Close( NULL );
-                }
+            params.iCount = sa.GetSessionCount( *object );
+            params.iId = sa.GetOwningThreadId( *object );
+            params.iSessionType = sa.GetSessionType( *object );
+            params.iAddressOfOwningThread = sa.GetAddressOfOwningThread( *object );
+            sa.GetNameOfOwningThread( *object, params.iNameOfOwner );
             }
         else if ( params.iType == EMemSpyDriverContainerTypeSession )
             {
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeSession" ));
 
             DSession* object = (DSession*) handleAsObject;
-	        NKern::LockSystem();
-            r = object->Open();
-    	    NKern::UnlockSystem();
-            //
-	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - open error: %d", r ));
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDServer& serverAdaption = OSAdaption().DServer();
-                DMemSpyDriverOSAdaptionDSession& sessionAdaption = OSAdaption().DSession();
+            DMemSpyDriverOSAdaptionDServer& serverAdaption = OSAdaption().DServer();
+            DMemSpyDriverOSAdaptionDSession& sessionAdaption = OSAdaption().DSession();
 
-                params.iName.Zero();
+            params.iName.Zero();
 
-                TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting session type..." ));
-                params.iSessionType = sessionAdaption.GetSessionType( *object );
-                params.iAddressOfServer = sessionAdaption.GetAddressOfServer( *object );
-                params.iTotalAccessCount = sessionAdaption.GetTotalAccessCount( *object );
-                params.iSvrSessionType = sessionAdaption.GetSessionType( *object );
-                params.iMsgCount = sessionAdaption.GetMsgCount( *object );
-                params.iMsgLimit = sessionAdaption.GetMsgLimit( *object );
-                
-                // Its more useful in this instance, if the name object
-                // points to the server which the session is connected to
-                // (rather than displaying a process-local name).
-                DServer* server = sessionAdaption.GetServer( *object );
-	            TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting full name, server: 0x%08x", server ));
-                //
-                if  ( server )
+            TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting session type..." ));
+            params.iSessionType = sessionAdaption.GetSessionType( *object );
+            params.iAddressOfServer = sessionAdaption.GetAddressOfServer( *object );
+            params.iTotalAccessCount = sessionAdaption.GetTotalAccessCount( *object );
+            params.iSvrSessionType = sessionAdaption.GetSessionType( *object );
+            params.iMsgCount = sessionAdaption.GetMsgCount( *object );
+            params.iMsgLimit = sessionAdaption.GetMsgLimit( *object );
+            
+            // Its more useful in this instance, if the name object
+            // points to the server which the session is connected to
+            // (rather than displaying a process-local name).
+            DServer* server = (DServer*)CheckedOpen(EMemSpyDriverContainerTypeServer, sessionAdaption.GetServer( *object ));
+	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting full name, server: 0x%08x", server ));
+            //
+            if  ( server )
+                {
+                server->FullName( params.iName );
+
+                // Continue as normal for other items
+	            TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - server: 0x%08x, server->iOwningThread: 0x%08x", server, server->iOwningThread ));
+                DThread* owningThread = serverAdaption.GetOwningThread( *server );
+                if  ( owningThread )
                     {
-	                NKern::LockSystem();
-                    r = server->Open();
-     	            NKern::UnlockSystem();
-
-                    if  ( r == KErrNone )
-                        {
-                        server->FullName( params.iName );
- 
-                        // Continue as normal for other items
-	                    TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - server: 0x%08x, server->iOwningThread: 0x%08x", server, server->iOwningThread ));
-                        DThread* owningThread = serverAdaption.GetOwningThread( *server );
-                        if  ( owningThread )
-                            {
-	                        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting server thread id..." ));
-                            params.iId = serverAdaption.GetOwningThreadId( *server );
-                            }
-
-                        server->Close( NULL );
-                        }
+	                TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - getting server thread id..." ));
+                    params.iId = serverAdaption.GetOwningThreadId( *server );
                     }
 
-                TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - closing session object..." ));
-                object->Close( NULL );
+                server->Close(NULL);
                 }
             }
         else if ( params.iType == EMemSpyDriverContainerTypeLogicalDevice )
@@ -586,39 +480,21 @@
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeLogicalDevice" ));
 
             DLogicalDevice* object = (DLogicalDevice*) handleAsObject;
-	        NKern::LockSystem();
-            r = object->Open();
-    	    NKern::UnlockSystem();
-            //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDLogicalDevice& lda = OSAdaption().DLogicalDevice();
-                params.iOpenChannels = lda.GetOpenChannels( *object );
-                params.iVersion = lda.GetVersion( *object );
-                params.iParseMask = lda.GetParseMask( *object );
-                params.iUnitsMask = lda.GetUnitsMask( *object );
-                //
-                object->Close( NULL );
-                }
+            DMemSpyDriverOSAdaptionDLogicalDevice& lda = OSAdaption().DLogicalDevice();
+            params.iOpenChannels = lda.GetOpenChannels( *object );
+            params.iVersion = lda.GetVersion( *object );
+            params.iParseMask = lda.GetParseMask( *object );
+            params.iUnitsMask = lda.GetUnitsMask( *object );
             }
         else if ( params.iType == EMemSpyDriverContainerTypePhysicalDevice )
             {
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypePhysicalDevice" ));
 	        
 	        DPhysicalDevice* object = (DPhysicalDevice*) handleAsObject;
-            NKern::LockSystem();
-            r = object->Open();
-            NKern::UnlockSystem();
-            //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDPhysicalDevice& pda = OSAdaption().DPhysicalDevice();
-                params.iVersion = pda.GetVersion( *object );
-                params.iUnitsMask = pda.GetUnitsMask( *object );
-                params.iAddressOfCodeSeg = pda.GetAddressOfCodeSeg( *object );
-                //
-                object->Close( NULL );
-                }
+            DMemSpyDriverOSAdaptionDPhysicalDevice& pda = OSAdaption().DPhysicalDevice();
+            params.iVersion = pda.GetVersion( *object );
+            params.iUnitsMask = pda.GetUnitsMask( *object );
+            params.iAddressOfCodeSeg = pda.GetAddressOfCodeSeg( *object );
             }
         else if ( params.iType == EMemSpyDriverContainerTypeLogicalChannel )
             {
@@ -629,37 +505,19 @@
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeChangeNotifier" ));
 
 	        DChangeNotifier* object = (DChangeNotifier*) handleAsObject;
-            NKern::LockSystem();
-            r = object->Open();
-            NKern::UnlockSystem();
-            //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDChangeNotifier& cna = OSAdaption().DChangeNotifier();
-                params.iChanges = cna.GetChanges( *object );
-                params.iAddressOfOwningThread = cna.GetAddressOfOwningThread( *object );
-                cna.GetNameOfOwningThread( *object, params.iNameOfOwner );
-                //
-                object->Close( NULL );
-                }
+            DMemSpyDriverOSAdaptionDChangeNotifier& cna = OSAdaption().DChangeNotifier();
+            params.iChanges = cna.GetChanges( *object );
+            params.iAddressOfOwningThread = cna.GetAddressOfOwningThread( *object );
+            cna.GetNameOfOwningThread( *object, params.iNameOfOwner );
             }
         else if ( params.iType == EMemSpyDriverContainerTypeUndertaker )
             {
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeUndertaker" ));
 	        
             DUndertaker* object = (DUndertaker*) handleAsObject;
-            NKern::LockSystem();
-            r = object->Open();
-            NKern::UnlockSystem();
-            //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDUndertaker& uta = OSAdaption().DUndertaker();
-                params.iAddressOfOwningThread = uta.GetAddressOfOwningThread( *object );
-                uta.GetNameOfOwningThread( *object, params.iNameOfOwner );
-                //
-                object->Close( NULL );
-                }
+            DMemSpyDriverOSAdaptionDUndertaker& uta = OSAdaption().DUndertaker();
+            params.iAddressOfOwningThread = uta.GetAddressOfOwningThread( *object );
+            uta.GetNameOfOwningThread( *object, params.iNameOfOwner );
             }
         else if ( params.iType == EMemSpyDriverContainerTypeMsgQueue )
             {
@@ -674,26 +532,18 @@
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - EMemSpyDriverContainerTypeCondVar" ));
 	        
             DCondVar* object = (DCondVar*) handleAsObject;
-            NKern::LockSystem();
-            r = object->Open();
-            NKern::UnlockSystem();
-            //
-            if  ( r == KErrNone )
-                {
-                DMemSpyDriverOSAdaptionDCondVar& cva = OSAdaption().DCondVar();
-                params.iResetting = cva.GetResetting( *object );
-                params.iAddressOfOwningThread = cva.GetAddressOfMutex( *object );
-                cva.GetNameOfMutex( *object, params.iNameOfOwner );
-                params.iWaitCount = cva.GetWaitCount( *object );
-                //
-                object->Close( NULL );
-                }
+            DMemSpyDriverOSAdaptionDCondVar& cva = OSAdaption().DCondVar();
+            params.iResetting = cva.GetResetting( *object );
+            params.iAddressOfOwningThread = cva.GetAddressOfMutex( *object );
+            cva.GetNameOfMutex( *object, params.iNameOfOwner );
+            params.iWaitCount = cva.GetWaitCount( *object );
             }
         else
             {
 	        TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetGenericHandleInfo() - KErrNotSupported" ));
             r = KErrNotSupported;
             }
+		handleAsObject->Close(NULL);
         }
     else
         {
@@ -881,13 +731,12 @@
 	NKern::ThreadEnterCS();
 
     // First, locate the specific DObject in question. Cast the handle, but don't use the object...
-    // NB: This claims the system lock
-    DObject* object = CheckIfObjectIsInContainer( EMemSpyDriverContainerTypePropertyRef, aHandle );
+    DObject* object = CheckedOpen(EMemSpyDriverContainerTypePropertyRef, aHandle);
     TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::GetPAndSInfo() - handle search returned: 0x%08x", object ));
 
     if  ( object != NULL )
         {
-        NKern::LockSystem();
+        NKern::LockSystem(); // Keep this, the DPropertyRef APIs use it -TomS
 
         DMemSpyDriverOSAdaptionDPropertyRef& pra = OSAdaption().DPropertyRef();
         const TBool isReady = pra.GetIsReady( *object );
@@ -913,6 +762,7 @@
             }
 
         NKern::UnlockSystem();
+		object->Close(NULL);
         }
 
     NKern::ThreadLeaveCS();
@@ -939,7 +789,7 @@
     NKern::ThreadEnterCS();
     
     DObject* condVarHandle = (DObject*) params.iCondVarHandle;
-    condVarHandle = CheckIfObjectIsInContainer( EMemSpyDriverContainerTypeCondVar, condVarHandle );
+    condVarHandle = CheckedOpen(EMemSpyDriverContainerTypeCondVar, condVarHandle);
     if  ( condVarHandle == NULL )
         {
         Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs() - END - condVar not found");
@@ -949,9 +799,9 @@
     
     ResetTempHandles();
         
-    DCondVar* condVar = (DCondVar*) params.iCondVarHandle;;
+    DCondVar* condVar = (DCondVar*) condVarHandle;
     
-    NKern::LockSystem();
+    NKern::LockSystem(); // Keep this, needed for iterating suspended queue -TomS
 
     // Iterate through suspended threads, writing back thread pointer (handle)
     // to client
@@ -1003,6 +853,7 @@
             }
         }
 
+	condVarHandle->Close(NULL);
     NKern::ThreadLeaveCS();
 
     TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrs() - END - r: %d", r));
@@ -1026,7 +877,7 @@
     NKern::ThreadEnterCS();
 
     DObject* threadHandle = (DObject*) aThreadHandle;
-    threadHandle = CheckIfObjectIsInContainer( EMemSpyDriverContainerTypeThread, threadHandle );
+    threadHandle = CheckedOpen(EMemSpyDriverContainerTypeThread, threadHandle);
     if  ( threadHandle == NULL )
         {
         Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrInfo() - END - thread not found");
@@ -1043,6 +894,7 @@
         r = Kern::ThreadRawWrite( &ClientThread(), aParams, &params, sizeof(TMemSpyDriverCondVarSuspendedThreadInfo) );
         }
     
+	threadHandle->Close(NULL);
     NKern::ThreadLeaveCS();
     
     TRACE( Kern::Printf("DMemSpyDriverLogChanMisc::GetCondVarSuspThrInfo() - END - r: %d", r));
@@ -1106,17 +958,13 @@
 
         if  ( handles != NULL )
             {
-            MemSpyObjectIx_Wait( handles );
-            //
-            TInt searchResult = handles->At( aHandleToLookFor );
-	        if  ( searchResult != KErrNotFound )
+            TBool found = handles->Find( aHandleToLookFor );
+	        if (found)
 		        {
                 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchThreadsFor - found handle match in [%O]", thread ));
                 aStream.WriteUint32( (TUint32) thread );
                 ++matches;
 		        }
-            //
-            MemSpyObjectIx_Signal( handles );
             }
         }
 
@@ -1151,17 +999,13 @@
 
         if  ( handles != NULL )
             {
-            MemSpyObjectIx_Wait( handles );
-            //
-            TInt searchResult = handles->At( aHandleToLookFor );
-	        if  ( searchResult != KErrNotFound )
+            TBool found = handles->Find( aHandleToLookFor );
+	        if  ( found )
 		        {
                 TRACE( Kern::Printf("DMemSpyDriverLogChanContainers::SearchProcessFor - found handle match in [%O]", process ));
                 aStream.WriteUint32( (TUint32) process );
                 ++matches;
 		        }
-            //
-            MemSpyObjectIx_Signal( handles );
             }
         }
 
--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapBase.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapBase.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -47,11 +47,6 @@
 
 DMemSpyDriverLogChanHeapBase::~DMemSpyDriverLogChanHeapBase()
 	{
-	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::~DMemSpyDriverLogChanHeapBase() - START - this: 0x%08x", this ));
-
-    ReleaseFreeCells();
-
-	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::~DMemSpyDriverLogChanHeapBase() - END - this: 0x%08x", this ));
 	}
 
 
@@ -173,243 +168,14 @@
 
 
 
-TInt DMemSpyDriverLogChanHeapBase::OpenUserHeap( DThread& aClientThread, TUint aExpectedHeapVTable, RMemSpyDriverRHeapUser& aHeap, DChunk*& aUserHeapChunk, TDes8* aClientHeapChunkName )
-    {
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap() - START - aHeap.ChunkIsInitialised: %d, aExpectedHeapVTable: 0x%08x, aClientThread: %O", aHeap.ChunkIsInitialised(), aExpectedHeapVTable, &aClientThread ));
-    __ASSERT_ALWAYS( aHeap.ChunkIsInitialised() == EFalse, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapChunkAlreadyCloned ) );
-
-    TInt r = KErrNotFound;
-    aUserHeapChunk = NULL;
-    
-    NKern::ThreadEnterCS();
-
-    const TBool allocatorIsReallyRHeap = GetUserHeapHandle( aClientThread, aHeap, aExpectedHeapVTable );
-	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - allocatorIsReallyRHeap: %d", allocatorIsReallyRHeap));
-
-    if  ( allocatorIsReallyRHeap )
-        {
-        RAllocator* allocator = OSAdaption().DThread().GetAllocator( aClientThread );
-
-        // Open client's heap chunk in order to read it's dimensions
-        const TInt clientsHeapChunkHandle = aHeap.iChunkHandle;
-	    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - clientsHeapChunkHandle: 0x%08x, allocatorAddress: 0x%08x", clientsHeapChunkHandle, allocator));
-
- 	    NKern::LockSystem();
-        DChunk* clientsHeapChunk = (DChunk*) Kern::ObjectFromHandle( &aClientThread, clientsHeapChunkHandle, EChunk );
-        NKern::UnlockSystem();
-	    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - clientsHeapChunk: 0x%08x", clientsHeapChunk ));
-       
-        if  ( clientsHeapChunk != NULL )
-            {
-            // Get the chunk name (if the caller asked for it)
-            if  ( aClientHeapChunkName )
-                {
-                clientsHeapChunk->FullName( *aClientHeapChunkName );
-                }
-                
-            // Update the heap chunk pointer. We do this now because this
-            // should point to the _real_ user-side heap chunk, rather than
-            // the copy of the chunk that we are about to make.
-            aUserHeapChunk = clientsHeapChunk;
-
-            // Set up ourselves to duplicate their heap chunk
-            const TInt clientsHeapChunkSize = OSAdaption().DChunk().GetSize( *clientsHeapChunk );
-	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - chunkBase: 0x%08x, size: %8d, maxLen: %8d, chunk: %O", clientsHeapChunk->iBase, clientsHeapChunkSize, clientsHeapChunk->iMaxSize, clientsHeapChunk ));
-
-            // Make a new chunk that is the same size, owned by this thread.
-            TChunkCreateInfo info;
-            info.iType         = TChunkCreateInfo::ESharedKernelSingle;
-            info.iMaxSize      = clientsHeapChunkSize;
-            info.iOwnsMemory   = ETrue; // Use memory from system's free pool
-            info.iDestroyedDfc = NULL;
-        #ifdef __EPOC32__
-            info.iMapAttr      = (TInt)EMapAttrFullyBlocking; // Full caching
-        #endif
-
-            // Holds a copy of the client's heap chunk
-            DChunk* heapCopyChunk;
-            TLinAddr heapCopyChunkAddress;
-            TUint32 heapCopyChunkMappingAttributes;
-            r = Kern::ChunkCreate( info, heapCopyChunk, heapCopyChunkAddress, heapCopyChunkMappingAttributes );
-	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - creating chunk returned: %d", r));
-            //
-            if  ( r == KErrNone )
-                {
-	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - copy chunk base: 0x%08x, heapCopyChunkAddress: 0x%08x", heapCopyChunk->iBase, heapCopyChunkAddress));
-                
-                // Commit memory for entire buffer
-                TUint32 physicalAddress = 0;
-                r = Kern::ChunkCommitContiguous( heapCopyChunk, 0, clientsHeapChunkSize, physicalAddress );
-	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - commiting chunk returned: %d", r));
-
-                if  ( r != KErrNone)
-                    {
-                    // On error, thow away the chunk we have created
-                    Kern::ChunkClose( heapCopyChunk );
-                    heapCopyChunk = NULL;
-                    }
-                else
-                    {
-    	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - heapCopyChunk->iSize: 0x%08x, heapCopyChunk->iBase: 0x%08x, heapCopyChunkAddress: 0x%08x, physicalAddress: 0x%08x", heapCopyChunk->iSize, heapCopyChunk->iBase, heapCopyChunkAddress, physicalAddress));
-    
-                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - trying to copy %d bytes from clients allocator address of 0x%08x", clientsHeapChunkSize, allocator ));
-                    r = Kern::ThreadRawRead( &aClientThread, allocator, (TAny*) heapCopyChunkAddress, clientsHeapChunkSize );
-
-                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - read result of clients heap data is: %d", r));
-                    if  ( r == KErrNone )
-                        {
-                        // Transfer ownership of the copy heap chunk to the heap object. This also calculates the delta
-                        // beween the heap addresses in the client's address space and the kernel address space.
-                        aHeap.AssociateWithKernelChunk( heapCopyChunk, heapCopyChunkAddress, heapCopyChunkMappingAttributes );
-                        }
-                    }
-                }
-            }
-        else
-            {
-	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - could not open clients heap chunk by its handle" ) );
-            r = KErrNotFound;
-            }
-        }
-    else
-        {
-	    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - clients heap is not an RHeap (allocated vTable mismatch)" ) );
-        r = KErrNotSupported;
-        }
-
-    NKern::ThreadLeaveCS();
-
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenUserHeap - r: %d", r ));
-    return r;
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-TBool DMemSpyDriverLogChanHeapBase::GetUserHeapHandle( DThread& aThread, RMemSpyDriverRHeapUser& aHeap, TUint aExpectedVTable )
-    {
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle() - START - aExpectedVTable: 0x%08x", aExpectedVTable) );
-
-    RAllocator* allocator = OSAdaption().DThread().GetAllocator( aThread );
-	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - allocator addr: 0x%08x", allocator) );
-    TUint* pAllocator = (TUint*) allocator;
-    // 
-    TBool vTableOkay = EFalse;
-    TUint vtable = 0;
-
-    // Read a bit more data than is available for debugging purposes
-    TBuf8<32> vtableBuf;
-    TInt r = Kern::ThreadRawRead( &aThread, pAllocator, (TUint8*) vtableBuf.Ptr(), vtableBuf.MaxLength() );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - read result of vtable data from requested thread is: %d", r));
-    if  ( r == KErrNone )
-        {
-        TRACE( MemSpyDriverUtils::DataDump("allocator vtable data - %lS", vtableBuf.Ptr(), vtableBuf.MaxLength(), vtableBuf.MaxLength() ) );
-        vtableBuf.SetLength( vtableBuf.MaxLength() );
-        
-        vtable = vtableBuf[0] +
-                (vtableBuf[1] << 8) + 
-                (vtableBuf[2] << 16) + 
-                (vtableBuf[3] << 24);
-        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - client VTable is: 0x%08x", vtable) );
-
-        // Check the v-table to work out if it really is an RHeap
-        vTableOkay = ( vtable == aExpectedVTable );
-        if  ( vTableOkay )
-            {
-            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - vtables okay") );
-            r = aHeap.ReadFromUserAllocator( aThread );
-            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - after userget, error: %d", r));
-        
-            }
-        else
-            {
-            TRACE( Kern::Printf( "DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - vtables dont match! - aExpectedVTable: 0x%08x, allocator addr: 0x%08x, client VTable is: 0x%08x, aThread: %O", aExpectedVTable, allocator, vtable, &aThread ) );
-            }
-        }
-    else
-        {
-        TRACE( Kern::Printf( "DMemSpyDriverLogChanHeapBase::GetUserHeapHandle - error during client vTable reading: %d, aThread: %O", r, &aThread ) );
-        }
-    //
-    return (vTableOkay && (r == KErrNone));
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 void DMemSpyDriverLogChanHeapBase::PrintHeapInfo( const TMemSpyHeapInfo& aInfo )
     {
     const TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap();
-    const TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
+    //const TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
     const TMemSpyHeapStatisticsRHeap& rHeapStats = rHeapInfo.Statistics();
     const TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
 
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator                                      -" ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iAccessCount:       %d", rHeapObjectData.iAccessCount ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iHandleCount:       %d", rHeapObjectData.iHandleCount ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iHandles:           0x%08x", rHeapObjectData.iHandles ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iFlags:             0x%08x", rHeapObjectData.iFlags ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iCellCount:         %d", rHeapObjectData.iCellCount ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RAllocator::iTotalAllocSize:    %d", rHeapObjectData.iTotalAllocSize ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
-
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap                                           -" ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iMinLength:              %d", rHeapObjectData.iMinLength ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iMaxLength:              %d", rHeapObjectData.iMaxLength ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iOffset:                 %d", rHeapObjectData.iOffset ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iGrowBy:                 %d", rHeapObjectData.iGrowBy ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iChunkHandle:            0x%08x", rHeapObjectData.iChunkHandle ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iBase:                   0x%08x", rHeapObjectData.iBase ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iTop:                    0x%08x", rHeapObjectData.iTop ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iAlign:                  %d", rHeapObjectData.iAlign ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iMinCell:                %d", rHeapObjectData.iAlign ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iPageSize:               %d", rHeapObjectData.iAlign ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iFree.next:              0x%08x", rHeapObjectData.iFree.next ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iFree.len:               %d", rHeapObjectData.iFree.len ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iNestingLevel:           %d", rHeapObjectData.iNestingLevel ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iAllocCount:             %d", rHeapObjectData.iAllocCount ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iFailType:               %d", rHeapObjectData.iFailType ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iFailRate:               %d", rHeapObjectData.iFailRate ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iFailed:                 %d", rHeapObjectData.iFailed ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iFailAllocCount:         %d", rHeapObjectData.iFailAllocCount ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iRand:                   %d", rHeapObjectData.iRand ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - RHeap::iTestData:               0x%08x", rHeapObjectData.iTestData ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
-
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Stats (Free)                                    -" ) );
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell count:                     %d", rHeapStats.StatsFree().TypeCount() ) );
@@ -431,12 +197,6 @@
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
 
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Stats (Common)                                  -" ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - total cell count:               %d", rHeapStats.StatsCommon().TotalCellCount() ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - " ) );
-
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - Misc. Info                                      -" ) );
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() ---------------------------------------------------" ) );
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - chunk size:                     %d", rHeapMetaData.ChunkSize() ) );
@@ -445,73 +205,17 @@
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - debug allocator:                %d", rHeapMetaData.IsDebugAllocator() ) );
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - shared heap:                    %d", rHeapMetaData.IsSharedHeap() ) );
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - user thread:                    %d", rHeapMetaData.IsUserThread() ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (free):        %d", rHeapMetaData.HeaderSizeFree() ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (alloc):       %d", rHeapMetaData.HeaderSizeAllocated() ) );
+    //TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (free):        %d", rHeapMetaData.HeaderSizeFree() ) );
+    //TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - cell header size (alloc):       %d", rHeapMetaData.HeaderSizeAllocated() ) );
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap vTable:                    0x%08x", rHeapMetaData.VTable() ) );
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap object size:               %d", rHeapMetaData.ClassSize() ) );
+    //TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap object size:               %d", rHeapMetaData.ClassSize() ) );
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - heap size:                      %d", rHeapMetaData.iHeapSize ) );
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - allocator address:              0x%08x", rHeapMetaData.iAllocatorAddress ) );
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - min heap size:                  %d", rHeapMetaData.iMinHeapSize ) );
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrintHeapInfo() - max heap size:                  %d", rHeapMetaData.iMaxHeapSize ) );
     }
 
-
-
-
-
-
-
-
-
-
-TBool DMemSpyDriverLogChanHeapBase::IsDebugKernel()
-    {
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - START") );
-    
-    TInt r = KErrNone;
-    TBool debugKernel = EFalse;
-
-    NKern::ThreadEnterCS();
-    RMemSpyDriverRHeapKernelInPlace rHeap;
-    r = OpenKernelHeap( rHeap );
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - open kernel heap returned: %d", r) );
-
-    if  ( r == KErrNone )
-        {
-        debugKernel = IsDebugKernel( rHeap );
-
-        // Tidy up
-        rHeap.DisassociateWithKernelChunk();
-        }
-
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - debugKernel: %d", debugKernel) );
-    NKern::ThreadLeaveCS();
-
- 	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - END - ret: %d", r) );
-    return debugKernel;
-    }
-
-
-TBool DMemSpyDriverLogChanHeapBase::IsDebugKernel( RMemSpyDriverRHeapKernelInPlace& aHeap )
-    {
-    TBool debugKernel = EFalse;
-    //
- 	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - START") );
-    NKern::ThreadEnterCS();
-
-    // Request that the kernel fail the next heap allocation
-    aHeap.FailNext();
-
-    // Allocate a new cell, and in debug builds of the kernel, this should be NULL
-    TInt* cell = new TInt();
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - cell: 0x%08x", cell) );
-    debugKernel = ( cell == NULL );
-    delete cell;
-
-    NKern::ThreadLeaveCS();
- 	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::IsDebugKernel() - END - debugKernel: %d", debugKernel) );
-    //
-    return debugKernel;
-    }
-
-
-TInt DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel( RMemSpyDriverRHeapBase& aHeap, TBool aIsDebugAllocator, const TDesC8& aChunkName, TMemSpyHeapInfo* aHeapInfo, TDes8* aTransferBuffer )
+TInt DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel(RMemSpyDriverRHeapBase& aHeap, TMemSpyHeapInfo* aHeapInfo, TDes8* aTransferBuffer )
     {
     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel() - START - aTransferBuffer: 0x%08x", aTransferBuffer ) );
 
@@ -520,16 +224,13 @@
 
     // This object holds all of the info we will accumulate for the client.
     TMemSpyHeapInfo masterHeapInfo;
-    masterHeapInfo.SetType( TMemSpyHeapInfo::ETypeRHeap );
+    masterHeapInfo.SetType(aHeap.GetTypeFromHelper());
     masterHeapInfo.SetTid( 2 );
     masterHeapInfo.SetPid( 1 );
 
     // This is the RHeap-specific object that contains all RHeap info
     TMemSpyHeapInfoRHeap& rHeapInfo = masterHeapInfo.AsRHeap();
 
-    // This is the object data for the RHeap instance
-    TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
-    aHeap.CopyObjectDataTo( rHeapObjectData );
 
     // When walking the kernel heap we must keep track of the free cells
     // without allocating any more memory (on the kernel heap...)
@@ -544,7 +245,7 @@
 
     // We must walk the client's heap in order to build statistics
     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - calling heap walker constructor..."));
-    RMemSpyDriverHeapWalker heapWalker( aHeap, aIsDebugAllocator );
+    RMemSpyDriverHeapWalker heapWalker(aHeap);
     if  ( aTransferBuffer )
         {
         // This will allow us to identify that we're writing directly to the stream
@@ -564,10 +265,6 @@
         TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - not collecting free cells"));
         }
 
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - locking system..." ));
-    NKern::LockSystem();
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - disabling interrupts..." ));
-    const TInt irq = NKern::DisableAllInterrupts();
     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - starting traversal..." ));
 
 #if defined( TRACE_TYPE_KERNELHEAP )
@@ -575,11 +272,8 @@
 #endif
     r = heapWalker.Traverse();
 
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - restoring interrupts..." ));
-    NKern::RestoreInterrupts( irq );
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - finished traversal - err: %d, iStackStream: 0x%08x, pCount: 0x%08x, isOpen: %d", r, iStackStream, pCount, ( iStackStream == NULL ? 0 : iStackStream->IsOpen() ) ));
-    NKern::UnlockSystem();
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - unlocked system" ));
+    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel - finished traversal - err: %d, iStackStream: 0x%08x, pCount: 0x%08x, isOpen: %d", 
+                            r, iStackStream, pCount, ( iStackStream == NULL ? 0 : iStackStream->IsOpen() ) ));
 
     // Write free cells if requested
     if  ( r == KErrNone && iStackStream && iStackStream->IsOpen() && pCount )
@@ -596,18 +290,19 @@
 
     // Get remaining meta data that isn't stored elsewhere
     TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
-    rHeapMetaData.SetChunkName( aChunkName );
+	TFullName chunkName;
+	aHeap.Chunk().FullName(chunkName);
+    rHeapMetaData.SetChunkName(chunkName);
     rHeapMetaData.SetChunkSize( (TUint) aHeap.Chunk().Size() );
     rHeapMetaData.SetChunkHandle( &aHeap.Chunk() );
-    rHeapMetaData.SetChunkBaseAddress( aHeap.Chunk().Base() );
-    rHeapMetaData.SetDebugAllocator( aIsDebugAllocator );
-    rHeapMetaData.SetHeaderSizeFree( RMemSpyDriverRHeapBase::FreeCellHeaderSize() );
-    rHeapMetaData.SetHeaderSizeAllocated( RMemSpyDriverRHeapBase::AllocatedCellHeaderSize( aIsDebugAllocator ) );
+    rHeapMetaData.SetChunkBaseAddress( OSAdaption().DChunk().GetBase(aHeap.Chunk()) );
+    rHeapMetaData.SetDebugAllocator(aHeap.Helper()->AllocatorIsUdeb());
     rHeapMetaData.SetUserThread( EFalse );
     rHeapMetaData.SetSharedHeap( ETrue );
-
-    // Get any heap-specific info
-    aHeap.GetHeapSpecificInfo( masterHeapInfo );
+	rHeapMetaData.iHeapSize = aHeap.Helper()->CommittedSize();
+	rHeapMetaData.iAllocatorAddress = (TAny*)aHeap.Helper()->AllocatorAddress();
+	rHeapMetaData.iMinHeapSize = aHeap.Helper()->MinCommittedSize();
+	rHeapMetaData.iMaxHeapSize = aHeap.Helper()->MaxCommittedSize();
 
     PrintHeapInfo( masterHeapInfo );
 
@@ -641,17 +336,12 @@
 
 
 
-TBool DMemSpyDriverLogChanHeapBase::HandleHeapCell( TInt aCellType, TAny* aCellAddress, TInt aLength, TInt /*aNestingLevel*/, TInt /*aAllocNumber*/ )
+TBool DMemSpyDriverLogChanHeapBase::HandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt /*aNestingLevel*/, TInt /*aAllocNumber*/)
     {
     TInt error = KErrNone;
     //
-    if  ( aCellType == EMemSpyDriverGoodFreeCell || aCellType == EMemSpyDriverBadFreeCellAddress || aCellType == EMemSpyDriverBadFreeCellSize )
+    if  (aCellType & EMemSpyDriverFreeCellMask)
         {
-        TMemSpyDriverFreeCell cell;
-        cell.iType = aCellType;
-        cell.iAddress = aCellAddress;
-        cell.iLength = aLength;
-        //
         if  ( iStackStream )
             {
             if  ( !iStackStream->IsFull() )
@@ -669,163 +359,16 @@
                 error = KErrAbort;
                 }
             }
-        else
-            {
-            NKern::ThreadEnterCS();
-            error = iFreeCells.Append( cell );
-            NKern::ThreadLeaveCS();
-            //
-            if ( error == KErrNone )
-                {
-                ++iFreeCellCount;
-                }
-            }
-        }
+       }
     //
     return ( error == KErrNone );
     }
 
 
 void DMemSpyDriverLogChanHeapBase::HandleHeapWalkInit()
-    {
-    // Can't delete the free cell list here as we might be walking the kernel heap
-    iFreeCellCount = 0;
-    }
-
-
-
-
-
-
-TInt DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer()
-    {
-    // Transfer free cells immediately from xfer stream
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - START - iHeapStream: 0x%08x", iHeapStream ));
-    __ASSERT_ALWAYS( !iHeapStream, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapFreeCellStreamNotClosed ) );
-    //
-    TInt r = KErrNoMemory;
-    //
-    NKern::ThreadEnterCS();
-    //
-    iHeapStream = new RMemSpyMemStreamWriter();
-    if  ( iHeapStream )
-        {
-        const TInt requiredMemory = CalculateFreeCellBufferSize();
-        r = OpenXferStream( *iHeapStream, requiredMemory );
-        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - requested %d bytes for free cell list, r: %d", requiredMemory, r ));
-
-        if  ( r == KErrNone )
-            {
-            const TInt count = iFreeCells.Count();
-            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - free cell count: %d", count ));
-            //
-            iHeapStream->WriteInt32( count );
-            for( TInt i=0; i<count; i++ )
-                {
-                const TMemSpyDriverFreeCell& cell = iFreeCells[ i ];
-                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - storing entry: %d", i ));
-                //
-                iHeapStream->WriteInt32( cell.iType );
-                iHeapStream->WriteUint32( reinterpret_cast<TUint32>( cell.iAddress ) );
-                iHeapStream->WriteInt32( cell.iLength );
-                }
-
-            // Finished with the array now
-            iFreeCells.Reset();
-
-            // We return the amount of client-side memory that needs to be allocated to hold the buffer
-            r = requiredMemory;
-            }
-        }
-    //
-    NKern::ThreadLeaveCS();
-               
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::PrepareFreeCellTransferBuffer() - END - r: %d", r));
-	return r;
-    }
-
-
-TInt DMemSpyDriverLogChanHeapBase::FetchFreeCells( TDes8* aBufferSink )
-    {
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::FetchFreeCells() - START - iHeapStream: 0x%08x", iHeapStream ));
-    __ASSERT_ALWAYS( iHeapStream, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapFreeCellStreamNotOpen ) );
-
-    TInt r = KErrNone;
-
-    // Write buffer to client
-    NKern::ThreadEnterCS();
-    r = iHeapStream->WriteAndClose( aBufferSink );
-
-    // Tidy up
-    ReleaseFreeCells();
-
-    NKern::ThreadLeaveCS();
-    //
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::FetchFreeCells() - END - r: %d", r));
-	return r;
-    }
-
-
-
-TInt DMemSpyDriverLogChanHeapBase::CalculateFreeCellBufferSize() const
-    {
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::CalculateFreeCellBufferSize() - START" ));
-
-    const TInt count = iFreeCells.Count();
-    const TInt entrySize = sizeof( TInt32 ) + sizeof( TInt32 ) + sizeof( TUint32 );
-    const TInt r = ( count * entrySize ) + sizeof( TInt ); // Extra TInt to hold count
-                
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::CalculateFreeCellBufferSize() - END - r: %d, count: %d, entrySize: %d", r, count, entrySize ));
-	return r;
-    }
-
-
-
-void DMemSpyDriverLogChanHeapBase::ReleaseFreeCells()
-    {
-	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::ReleaseFreeCells() - START - this: 0x%08x", this ));
-
-    // Housekeeping
-    NKern::ThreadEnterCS();
-    iFreeCells.Reset();
-    //
-    iStackStream = NULL;
-    //
-    delete iHeapStream;
-    iHeapStream = NULL;
-    NKern::ThreadLeaveCS();
-
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapBase::ReleaseFreeCells() - END - this: 0x%08x", this ));
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+	{
+	iFreeCellCount = 0;
+	}
 
 TInt DMemSpyDriverLogChanHeapBase::OpenKernelHeap( RHeapK*& aHeap, DChunk*& aChunk, TDes8* aClientHeapChunkName )
     {
@@ -905,7 +448,7 @@
         // Finalise construction of heap 
         if  ( kernelHeap != NULL )
             {
-            TRACE_KH( Kern::Printf( "DMemSpyDriverLogChanHeapBase::OpenKernelHeap - kernelHeap->Base(): 0x%08x, kernelHeapChunk->Base(): 0x%08x", kernelHeap->Base(), kernelHeapChunk->Base() ) );
+            TRACE_KH( Kern::Printf( "DMemSpyDriverLogChanHeapBase::OpenKernelHeap - kernelHeapChunk->Base(): 0x%08x", kernelHeapChunk->Base() ) );
             aHeap = kernelHeap;
             aChunk = kernelHeapChunk;
 
@@ -935,27 +478,6 @@
     return r;
     }
 
-
-TInt DMemSpyDriverLogChanHeapBase::OpenKernelHeap( RMemSpyDriverRHeapKernelInPlace& aHeap, TDes8* aClientHeapChunkName )
-    {
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(IP) - START") );
-
-    RHeapK* heap = NULL;
-    DChunk* chunk = NULL;
-    TInt r = OpenKernelHeap( heap, chunk, aClientHeapChunkName );
-	
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(IP) - open err: %d", r ) );
-    if  ( r == KErrNone )
-        {
-        aHeap.SetKernelHeap( *heap );
-        aHeap.AssociateWithKernelChunk( chunk, TLinAddr( chunk->iBase ), 0 );
-        }
-
-	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(IP) - END - ret: %d", r ) );
-    return r;
-    }
-
-
 TInt DMemSpyDriverLogChanHeapBase::OpenKernelHeap( RMemSpyDriverRHeapKernelFromCopy& aHeap, TDes8* aClientHeapChunkName )
     {
     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - START") );
@@ -1017,7 +539,7 @@
                 NKern::LockSystem();
                 const TUint32 copyLength = heapSize; // TODO Min( heap->Size(), heapSize );
 
-                TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - trying to copy %d (vs orig estimate of %d) bytes from kernel allocator address: 0x%08x", copyLength, heapSize, heap->Base() ));
+                TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapBase::OpenKernelHeap(CP) - trying to copy %d (vs orig estimate of %d) bytes from kernel allocator address: 0x%08x", copyLength, heapSize, heap));
                 memcpy( (TUint8*) heapCopyChunkAddress, heap, copyLength );
 
                 NKern::UnlockSystem();
--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapData.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapData.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -162,25 +162,21 @@
     //
     // The driver leaves kernel context with the copy of the kernel heap still associated with MemSpy's process.
     // The second driver call will copy the chunk data to user side and release the kernel side chunk.
-    const TBool isInit = iKernelHeap.ChunkIsInitialised();
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelInit() - START - isInit: %d", isInit ));
-    __ASSERT_ALWAYS( !isInit, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicKernelHeapDataInitError ) );
+    //const TBool isInit = iKernelHeap.ChunkIsInitialised();
+    //TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelInit() - START - isInit: %d", isInit ));
+    //__ASSERT_ALWAYS( !isInit, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicKernelHeapDataInitError ) );
 
     iKernelHeap.Reset();
     NKern::ThreadEnterCS();
 
-    // We must identify if we have a debug kernel allocator
-    const TBool debugAllocator = IsDebugKernel();
-    TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelInit() - debugAllocator: %d", debugAllocator ) );
-
     TFullName heapChunkName;
     TInt r = OpenKernelHeap( iKernelHeap, &heapChunkName );
     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelInit() - open err: %d", r));
 
     if  ( r == KErrNone )
         {
-        r = GetHeapInfoKernel( iKernelHeap, debugAllocator, heapChunkName, aInfo, aFreeCells );
-        TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoKernel() - base class get heap info: %d", r) );
+        r = GetHeapInfoKernel( iKernelHeap, aInfo, aFreeCells );
+        TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapDataKernelInit() - base class get heap info: %d", r) );
 
         // If everything was okay, we can now return back to user-side, indicating the amount of heap data
         // that they must prepare to read (in the next operation).
@@ -188,12 +184,12 @@
             {
             // Indicate how big a buffer the user-side must prepare.
             r = OSAdaption().DChunk().GetSize( iKernelHeap.Chunk() );
-            TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoKernel() - user side buffer needs to be: %d", r) );
+            TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapDataKernelInit() - user side buffer needs to be: %d", r) );
             }
-        else if ( iKernelHeap.ChunkIsInitialised() )
+        else
             {
             // Error scenario - must close heap
-            iKernelHeap.DisassociateWithKernelChunk();
+            iKernelHeap.Close();
             }
         }
 
@@ -206,12 +202,15 @@
 
 TInt DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch( TDes8* aSink )
     {
+	//TOMSCI TODO this function is fundamentally flawed
+	return KErrNotSupported;
+	/*
     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch() - START"));
 
     NKern::ThreadEnterCS();
 
     // We should already have an initialised copy of the kernel heap
-    const TBool isInit = iKernelHeap.ChunkIsInitialised();
+    const TBool isInit = iKernelHeap.Helper() != NULL;
     TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch() - isInit: %d", isInit ));
     __ASSERT_ALWAYS( isInit, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicKernelHeapDataFetchError ) );
 
@@ -261,6 +260,7 @@
 
 	TRACE_KH( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataKernelFetch() - END - ret: %d", r));
     return r;
+	*/
     }
 
 
@@ -279,7 +279,7 @@
 
 
 
-
+const TInt KPageSize = 4096;
 
 TInt DMemSpyDriverLogChanHeapData::GetHeapDataUser( TMemSpyDriverInternalHeapDataParams& aParams )
     {
@@ -304,135 +304,110 @@
 		    return KErrAccessDenied;
             }
         }
-    
+
     // Check that the process' thread's are suspended
     DThread* thread = (DThread*) TempObject();
     if  ( SuspensionManager().IsSuspended( *thread ) )
         {
-        // Find the chunk with the correct handle
+        // Open the heap
 	    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - thread: %O", thread) );
         RMemSpyDriverRHeapUser heap( OSAdaption() );
-        const TBool allocatorIsReallyRHeap = GetUserHeapHandle( *thread, heap, aParams.iRHeapVTable );
-        if  ( allocatorIsReallyRHeap )
+		r = heap.OpenUserHeap(*thread, aParams.iDebugAllocator);
+		TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - opening heap returned: %d", r) );
+        if  (r == KErrNone)
             {
-            const TInt chunkHandle = heap.iChunkHandle;
-	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - chunkHandle: 0x%08x, thread: %O", chunkHandle, thread) );
-
-  	        NKern::ThreadEnterCS();
- 	        NKern::LockSystem();
-            DChunk* chunk = (DChunk*) Kern::ObjectFromHandle( thread, chunkHandle, EChunk );
-            NKern::UnlockSystem();
-	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - chunk: 0x%08x", chunk ) );
-  	        NKern::ThreadLeaveCS();
-
-            if  ( chunk != NULL )
+            if  ( aParams.iChecksum != 0 )
                 {
-                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - chunkBase: 0x%08x, size: %8d, maxLen: %8d, chunk: %O", chunk->iBase, chunk->iSize, chunk->iMaxSize, chunk) );
-
-                // If the client specified a checksum value, then we must walk the heap just to make sure
-                // it hasn't changed. Expensive operation, but good for paranoia purposes...
-                if  ( aParams.iChecksum != 0 )
-                    {
-                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - checksum validation requested - expecting: 0x%08x", aParams.iChecksum ) );
+                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - checksum validation requested - expecting: 0x%08x", aParams.iChecksum ) );
+                RMemSpyDriverHeapWalker heapWalker(heap);
+                
+                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - starting traversal..." ));
+#if ( defined( TRACE_TYPE_USERHEAP ) && defined( TRACE_TYPE_HEAPWALK ) )
+                heapWalker.SetPrintDebug();
+#endif
+                r = heapWalker.Traverse();
+                const TUint32 calculatedChecksum = heapWalker.Stats().iFreeCellCRC;
+                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - finished traversal - err: %d, checksum: 0x%08x", r, calculatedChecksum ));
 
-                    RMemSpyDriverRHeapUser rHeap( OSAdaption() );
-                    DChunk* userHeapChunk = NULL;
-                    r = OpenUserHeap( *thread, aParams.iRHeapVTable, rHeap, userHeapChunk );
-                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - opening client heap returned: %d", r) );
-                    if  ( r == KErrNone )
-                        {
-                        TMemSpyHeapWalkerNullObserver observer; 
-                        RMemSpyDriverHeapWalker heapWalker( rHeap, aParams.iDebugAllocator );
-                        heapWalker.SetObserver( &observer );
-                        
-                        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - starting traversal..." ));
-#if ( defined( TRACE_TYPE_USERHEAP ) && defined( TRACE_TYPE_HEAPWALK ) )
-                        heapWalker.SetPrintDebug();
-#endif
-                        r = heapWalker.Traverse();
-                        const TUint32 calculatedChecksum = heapWalker.Stats().iFreeCellCRC;
-                        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - finished traversal - err: %d, checksum: 0x%08x", r, calculatedChecksum ));
+                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - comparing CALCULATED: 0x%08x vs EXPECTED: 0x%08x", calculatedChecksum, aParams.iChecksum ));
+                if  ( calculatedChecksum != aParams.iChecksum )
+                    {
+                    Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - comparing CALCULATED: 0x%08x vs EXPECTED: 0x%08x for thread %O", calculatedChecksum, aParams.iChecksum, thread );
+                    r = KErrCorrupt;
+                    }
+                }
 
-                        // Release resources
-                        rHeap.DisassociateWithKernelChunk();
+            // Get user side (MemSpy) descriptor length info
+            if  ( r == KErrNone )
+                {
+                TInt destLen = 0;
+                TInt destMax = 0;
+                TUint8* destPtr = NULL;
+                r = Kern::ThreadGetDesInfo( &ClientThread(), aParams.iDes, destLen, destMax, destPtr, ETrue );
+                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - user side descriptor: 0x%08x (0x%08x), len: %8d, maxLen: %8d, r: %d", aParams.iDes, destPtr, destLen, destMax, r ));
+				destMax = destMax & ~(KPageSize-1); // Round down dest max to page size
+				if (destMax <= 0 || (aParams.iReadAddress & (KPageSize-1))) r = KErrArgument; // If destMax is less than a page or the read address isn't a multiple of page size then we don't want to know
 
-                        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - comparing CALCULATED: 0x%08x vs EXPECTED: 0x%08x", calculatedChecksum, aParams.iChecksum ));
-                        if  ( calculatedChecksum != aParams.iChecksum )
-                            {
-                            Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - comparing CALCULATED: 0x%08x vs EXPECTED: 0x%08x for thread %O", calculatedChecksum, aParams.iChecksum, thread );
-                            r = KErrCorrupt;
-                            }
-                        }
-                    else
-                        {
-                        // Couldn't verify checksum in this situation...
-                        }
-                    }
-
-                // Get user side (MemSpy) descriptor length info
                 if  ( r == KErrNone )
                     {
-                    TInt destLen;
-                    TInt destMax;
-                    TUint8* destPtr = NULL;
-                    r = Kern::ThreadGetDesInfo( &ClientThread(), aParams.iDes, destLen, destMax, destPtr, ETrue );
-                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - user side descriptor: 0x%08x (0x%08x), len: %8d, maxLen: %8d, r: %d", aParams.iDes, destPtr, destLen, destMax, r ));
-
-                    if  ( r == KErrNone )
+					const TLinAddr chunkBase = (TLinAddr)OSAdaption().DChunk().GetBase(heap.Chunk());
+					const TLinAddr chunkMaxAddr = chunkBase + OSAdaption().DChunk().GetMaxSize(heap.Chunk());
+        	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - chunkBase:    0x%08x", chunkBase) );
+        
+					TLinAddr readAddress = aParams.iReadAddress;
+                    if (aParams.iRemaining < 0 )
                         {
-                        // Calculate start of real heap data (skipping over embedded RHeap object)
-                        const TUint8* startOfHeapOffset = heap.iBase;
-        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - startOfHeapOffset:    0x%08x", startOfHeapOffset) );
-            
-                        // Deal with initial case
-                        const TUint heapSize = heap.Size();
-        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - heapSize:               %8d", heapSize) );
-                        if  ( aParams.iRemaining < 0 )
-                            {
-                            // Initial case, remaining initialised to -1
-                            aParams.iRemaining = heapSize;
-                            }
+                        // Initial case, start from the bottom
+                        readAddress = chunkBase;
+						aParams.iRemaining = heap.Helper()->CommittedSize();
+                        }
+
+                    // The remaining number of bytes should allow us to calculate the position
+                    // to read from.
+                    TInt amountToRead = Min( aParams.iRemaining, destMax );
+        	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - amountToRead:           %8d", amountToRead) );
+        
+                    // Do the read from the heap we are spying on into MemSpy's address space
+					// TomS: I didn't know you could do this - you live and learn
+					do
+						{
+						r = Kern::ThreadRawRead( thread, (const void*)readAddress, destPtr, amountToRead );
+        				TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - read result: %d", r) );
 
-                        // The remaining number of bytes should allow us to calculate the position
-                        // to read from.
-                        const TInt amountToRead = Min( aParams.iRemaining, destMax );
-        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - amountToRead:           %8d", amountToRead) );
-                        const TInt readOffset = ( heapSize - aParams.iRemaining );
-        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - readOffset:             %8d", readOffset) );
-                        const TAny* readAddress = startOfHeapOffset + readOffset;
-        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - readAddress:          0x%08x", readAddress) );
-            
-                        // Do the read from the heap we are spying on into MemSpy's address space
-                        r = Kern::ThreadRawRead( thread, readAddress, destPtr, amountToRead );
-        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - read result: %d", r) );
-                        //
-                        if  (r == KErrNone)
-                            {
-                            // Client takes care of updating descriptor length.
-                            r = amountToRead;
-                            }
-                        else if ( r == KErrBadDescriptor )
-                            {
-                            MemSpyDriverUtils::PanicThread( ClientThread(), EPanicBadDescriptor );
-                            }
-            
-                        // Update remaining bytes
-                        aParams.iRemaining -= amountToRead;
-                        aParams.iReadAddress = (TUint) readAddress;
+						if (r == KErrBadDescriptor)
+							{
+							// This is not necessarily an error - it could be we've hit an unmapped page
+							if (amountToRead > KPageSize)
+								{
+								// retry reading a single page instead
+								amountToRead = KPageSize;
+								}
+							else
+								{
+								// Try the next page
+								readAddress += KPageSize;
+								}
+							}
+						} while (r == KErrBadDescriptor && readAddress < chunkMaxAddr);
+                    //
+                    if  (r == KErrNone)
+                        {
+                        // Client takes care of updating descriptor length.
+                        r = amountToRead;
                         }
+        
+                    // Update remaining bytes
+                    aParams.iRemaining -= amountToRead;
+                    aParams.iReadAddress = readAddress;
                     }
                 }
-            else
-                {
-    	        Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - chunk not found! thread: %O", thread );
-                r = KErrNotFound;
-                }
-            }
+			}
         else
             {
-    	    Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - couldnt find heap - vtable mis-match? thread: %O", thread );
+    	    Kern::Printf("DMemSpyDriverLogChanHeapData::GetHeapDataUser - couldnt open heap for thread %O, err=%d", thread, r);
             r = KErrNotSupported;
             }
+		heap.Close();
         }
     else
         {
--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapInfo.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapInfo.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -46,24 +46,18 @@
 DMemSpyDriverLogChanHeapInfo::~DMemSpyDriverLogChanHeapInfo()
 	{
 	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::~DMemSpyDriverLogChanHeapInfo() - START - this: 0x%08x", this ));
+	ReleaseCellList();
 	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::~DMemSpyDriverLogChanHeapInfo() - END - this: 0x%08x", this ));
 	}
 
-
-
-
-
-
-
-
 TInt DMemSpyDriverLogChanHeapInfo::Request( TInt aFunction, TAny* a1, TAny* a2 )
 	{
 	TInt r = DMemSpyDriverLogChanHeapBase::Request( aFunction, a1, a2 );
     if  ( r == KErrNone )
         {
-        if  ( aFunction != EMemSpyDriverOpCodeHeapInfoFetchFreeCells )
+        if  ( aFunction != EMemSpyDriverOpCodeHeapInfoFetchCellList )
             {
-            ReleaseFreeCells();
+            ReleaseCellList();
             }
         //
         switch( aFunction )
@@ -75,10 +69,10 @@
             r = GetHeapInfoKernel( (TMemSpyDriverInternalHeapRequestParameters*) a1, (TDes8*) a2 );
             break;
         case EMemSpyDriverOpCodeHeapInfoGetIsDebugKernel:
-            r = GetIsDebugKernel( (TBool*) a1 );
+            r = GetIsDebugKernel(a1);
             break;
-        case EMemSpyDriverOpCodeHeapInfoFetchFreeCells:
-            r = FetchFreeCells( (TDes8*) a1 );
+        case EMemSpyDriverOpCodeHeapInfoFetchCellList:
+            r = FetchCellList( (TDes8*) a1 );
             break;
 
         default:
@@ -132,50 +126,42 @@
             DThread* thread = (DThread*) TempObject();
             if  ( SuspensionManager().IsSuspended( *thread ) )
                 {
-                TFullName chunkName;
-
                 // Open client's heap
                 RMemSpyDriverRHeapUser rHeap( OSAdaption() );
-                DChunk* userHeapChunk = NULL;
-                r = OpenUserHeap( *thread, iHeapInfoParams.iRHeapVTable, rHeap, userHeapChunk, &chunkName );
+				r = rHeap.OpenUserHeap(*thread, iHeapInfoParams.iDebugAllocator);
                 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoUser - opening client heap returned: %d", r) );
 
                 if  ( r == KErrNone )
                     {
                     // This object holds all of the info we will accumulate for the client.
                     TMemSpyHeapInfo masterHeapInfo;
-                    masterHeapInfo.SetType( TMemSpyHeapInfo::ETypeRHeap );
+                    masterHeapInfo.SetType(rHeap.GetTypeFromHelper());
                     masterHeapInfo.SetTid( iHeapInfoParams.iTid );
                     masterHeapInfo.SetPid( OSAdaption().DThread().GetOwningProcessId( *thread ) );
 
                     // This is the RHeap-specific object that contains all RHeap info
                     TMemSpyHeapInfoRHeap& rHeapInfo = masterHeapInfo.AsRHeap();
 
-                    // This is the object data for the RHeap instance
-                    TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
-                    rHeap.CopyObjectDataTo( rHeapObjectData );
 
                     // We must walk the client's heap in order to build statistics
                     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoUser - calling heap walker constructor..."));
-                    TMemSpyHeapWalkerNullObserver observer; 
-                    RMemSpyDriverHeapWalker heapWalker( rHeap, iHeapInfoParams.iDebugAllocator );
-                    if  ( iHeapInfoParams.iBuildFreeCellList )
+					RMemSpyDriverHeapWalker heapWalker(rHeap);
+                    if  (iHeapInfoParams.iBuildFreeCellList || iHeapInfoParams.iBuildAllocCellList)
                         {
                         heapWalker.SetObserver( this );
-                        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoUser - collecting free cells"));
+                        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoUser - collecting cells"));
                         }
                     else
                         {
-                        heapWalker.SetObserver( &observer );
-                        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoUser - not collecting free cells"));
+                        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoUser - not collecting cells"));
                         }
 
-                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoUser - starting traversal..." ));
+                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoUser - starting traversal openerr: %d...", r));
 
 #if ( defined( TRACE_TYPE_USERHEAP ) && defined( TRACE_TYPE_HEAPWALK ) )
                     heapWalker.SetPrintDebug();
 #endif
-                    r = heapWalker.Traverse();
+                    if (r == KErrNone) r = heapWalker.Traverse();
                     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoUser - finished traversal - err: %d", r ));
 
                     TMemSpyHeapStatisticsRHeap& rHeapStats = rHeapInfo.Statistics();
@@ -183,24 +169,26 @@
 
                     // Get remaining meta data that isn't stored elsewhere
                     TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
-                    rHeapMetaData.SetChunkName( chunkName );
-                    rHeapMetaData.SetChunkSize( (TUint) OSAdaption().DChunk().GetSize( *userHeapChunk ) );
-                    rHeapMetaData.SetChunkHandle( userHeapChunk );
-                    rHeapMetaData.SetChunkBaseAddress( OSAdaption().DChunk().GetBase( *userHeapChunk ) );
-                    rHeapMetaData.SetDebugAllocator( iHeapInfoParams.iDebugAllocator );
-                    rHeapMetaData.SetHeaderSizeFree( RMemSpyDriverRHeapBase::FreeCellHeaderSize() );
-                    rHeapMetaData.SetHeaderSizeAllocated( RMemSpyDriverRHeapBase::AllocatedCellHeaderSize( iHeapInfoParams.iDebugAllocator ) );
+					DChunk& userHeapChunk = rHeap.Chunk();
+					TFullName chunkName;
+					userHeapChunk.FullName(chunkName);
+					rHeapMetaData.SetChunkName( chunkName );
+		            rHeapMetaData.SetChunkSize( (TUint) OSAdaption().DChunk().GetSize( userHeapChunk ) );
+					rHeapMetaData.SetChunkHandle( &userHeapChunk );
+					rHeapMetaData.SetChunkBaseAddress( OSAdaption().DChunk().GetBase( userHeapChunk ) );
+                    rHeapMetaData.SetDebugAllocator(rHeap.Helper()->AllocatorIsUdeb());
                     rHeapMetaData.SetUserThread( ETrue );
-
-                    // Get any heap-specific info
-                    rHeap.GetHeapSpecificInfo( masterHeapInfo );
+					rHeapMetaData.iHeapSize = rHeap.Helper()->CommittedSize();
+					rHeapMetaData.iAllocatorAddress = (TAny*)rHeap.Helper()->AllocatorAddress();
+					rHeapMetaData.iMinHeapSize = rHeap.Helper()->MinCommittedSize();
+					rHeapMetaData.iMaxHeapSize = rHeap.Helper()->MaxCommittedSize();
 
                     PrintHeapInfo( masterHeapInfo );
 
                     // Write free cells if requested
-                    if  ( r == KErrNone && iHeapInfoParams.iBuildFreeCellList )
+                    if  ( r == KErrNone && (iHeapInfoParams.iBuildFreeCellList || iHeapInfoParams.iBuildAllocCellList))
                         {
-                        r = PrepareFreeCellTransferBuffer();
+                        r = PrepareCellListTransferBuffer();
                         }
 
                     // Update info ready for writing back to the user-side
@@ -217,7 +205,7 @@
                         }
 
                     // Release resources
-                    rHeap.DisassociateWithKernelChunk();
+					rHeap.Close();
                     }
                 }
             else
@@ -249,24 +237,23 @@
     if  ( r == KErrNone )
         {
         // Open kernel heap
-        TFullName heapChunkName;
         RMemSpyDriverRHeapKernelInPlace rHeap;
-        r = OpenKernelHeap( rHeap, &heapChunkName );
+        r = rHeap.OpenKernelHeap();
         TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoKernel() - open err: %d", r ) );
 
         if  ( r == KErrNone )
             {
-            // We must identify if we have a debug kernel allocator
-            const TBool debugAllocator = IsDebugKernel( rHeap );
-            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoKernel() - debugAllocator: %d", debugAllocator ) );
-
-            r = DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel( rHeap, debugAllocator, heapChunkName, params.iMasterInfo, aTransferBuffer );
+            r = DMemSpyDriverLogChanHeapBase::GetHeapInfoKernel(rHeap, params.iMasterInfo, aTransferBuffer);
             TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoKernel() - base class get heap info: %d", r) );
             }
+        else 
+            {
+            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoKernel() - open err: %d", r ) );
+            }
         }
     else
         {
-    	Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoKernel() - params read error: %d", r);
+        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoKernel() - params read error: %d", r) );
         }
 
 	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetHeapInfoKernel() - END - ret: %d", r) );
@@ -278,7 +265,7 @@
 
 
 
-TInt DMemSpyDriverLogChanHeapInfo::GetIsDebugKernel( TBool* aIsDebugKernel )
+TInt DMemSpyDriverLogChanHeapInfo::GetIsDebugKernel(TAny* aResult)
     {
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetIsDebugKernel() - START") );
     
@@ -288,22 +275,22 @@
     NKern::ThreadEnterCS();
     
     RMemSpyDriverRHeapKernelInPlace rHeap;
-    r = OpenKernelHeap( rHeap );
+    r = rHeap.OpenKernelHeap();
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetIsDebugKernel() - open kernel heap returned: %d", r) );
 
     if  ( r == KErrNone )
         {
-        debugKernel = IsDebugKernel( rHeap );
+        debugKernel = rHeap.Helper()->AllocatorIsUdeb();
 
         // Tidy up
-        rHeap.DisassociateWithKernelChunk();
+        rHeap.Close();
         }
 
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetIsDebugKernel() - debugKernel: %d", debugKernel) );
 
     // Write back to user-land
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::GetIsDebugKernel() - writing to user-side...") );
-    r = Kern::ThreadRawWrite( &ClientThread(), aIsDebugKernel, &debugKernel, sizeof(TBool) );
+    r = Kern::ThreadRawWrite( &ClientThread(), aResult, &debugKernel, sizeof(TBool) );
 
     NKern::ThreadLeaveCS();
 
@@ -311,39 +298,121 @@
     return r;
     }
 
-
-
+TInt DMemSpyDriverLogChanHeapInfo::PrepareCellListTransferBuffer()
+    {
+    // Transfer free cells immediately from xfer stream
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::PrepareCellListTransferBuffer() - START - iHeapStream: 0x%08x", iHeapStream ));
+    __ASSERT_ALWAYS( !iHeapStream, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapFreeCellStreamNotClosed ) );
+    //
+    TInt r = KErrNoMemory;
+    //
+    NKern::ThreadEnterCS();
+    //
+    iHeapStream = new RMemSpyMemStreamWriter();
+    if  ( iHeapStream )
+        {
+        const TInt requiredMemory = CalculateCellListBufferSize();
+        r = OpenXferStream( *iHeapStream, requiredMemory );
+        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::PrepareCellListTransferBuffer() - requested %d bytes for free cell list, r: %d", requiredMemory, r ));
 
-
+        if  ( r == KErrNone )
+            {
+            const TInt count = iCellList.Count();
+            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::PrepareCellListTransferBuffer() - cell count: %d", count ));
+            //
+            iHeapStream->WriteInt32( count );
+            for( TInt i=0; i<count; i++ )
+                {
+                const TMemSpyDriverCell& cell = iCellList[ i ];
+                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::PrepareCellListTransferBuffer() - storing entry: %d", i ));
+                //
+                iHeapStream->WriteInt32( cell.iType );
+                iHeapStream->WriteUint32( reinterpret_cast<TUint32>( cell.iAddress ) );
+                iHeapStream->WriteInt32( cell.iLength );
+                }
 
+            // Finished with the array now
+            iCellList.Reset();
 
+            // We return the amount of client-side memory that needs to be allocated to hold the buffer
+            r = requiredMemory;
+            }
+        }
+    //
+    NKern::ThreadLeaveCS();
+               
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::PrepareCellListTransferBuffer() - END - r: %d", r));
+	return r;
+    }
 
 
-
+TInt DMemSpyDriverLogChanHeapInfo::FetchCellList( TDes8* aBufferSink )
+    {
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::FetchCellList() - START - iHeapStream: 0x%08x", iHeapStream ));
+    __ASSERT_ALWAYS( iHeapStream, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapFreeCellStreamNotOpen ) );
 
-
+    TInt r = KErrNone;
 
-
+    // Write buffer to client
+    NKern::ThreadEnterCS();
+    r = iHeapStream->WriteAndClose( aBufferSink );
 
+    // Tidy up
+    ReleaseCellList();
 
+    NKern::ThreadLeaveCS();
+    //
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::FetchCellList() - END - r: %d", r));
+	return r;
+    }
 
 
 
-
-
+TInt DMemSpyDriverLogChanHeapInfo::CalculateCellListBufferSize() const
+    {
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::CalculateCellListBufferSize() - START" ));
 
-
-
-
+    const TInt count = iCellList.Count();
+    const TInt entrySize = sizeof( TInt32 ) + sizeof( TInt32 ) + sizeof( TUint32 );
+    const TInt r = ( count * entrySize ) + sizeof( TInt ); // Extra TInt to hold count
+                
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::CalculateCellListBufferSize() - END - r: %d, count: %d, entrySize: %d", r, count, entrySize ));
+	return r;
+    }
 
 
 
-
+void DMemSpyDriverLogChanHeapInfo::ReleaseCellList()
+    {
+	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::ReleaseCellList() - START - this: 0x%08x", this ));
 
+    NKern::ThreadEnterCS();
+    iCellList.Reset();
+    delete iHeapStream;
+    iHeapStream = NULL;
+    NKern::ThreadLeaveCS();
 
-
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapInfo::ReleaseCellList() - END - this: 0x%08x", this ));
+    }
 
-
+TBool DMemSpyDriverLogChanHeapInfo::HandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt /*aNestingLevel*/, TInt /*aAllocNumber*/)
+    {
+	TInt err = KErrNone;
+    if (((aCellType & EMemSpyDriverFreeCellMask) && iHeapInfoParams.iBuildFreeCellList) || 
+        ((aCellType & EMemSpyDriverAllocatedCellMask) && iHeapInfoParams.iBuildAllocCellList))
+		{
+		TMemSpyDriverCell cell;
+		cell.iType = aCellType;
+		cell.iAddress = aCellAddress;
+		cell.iLength = aLength;
 
+		NKern::ThreadEnterCS();
+		err = iCellList.Append(cell);
+		NKern::ThreadLeaveCS();
+		}
+	return err == KErrNone;
+	}
 
-
+void DMemSpyDriverLogChanHeapInfo::HandleHeapWalkInit()
+	{
+	}
--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapWalk.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanHeapWalk.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -124,7 +124,7 @@
 TInt DMemSpyDriverLogChanHeapWalk::WalkHeapInit( TMemSpyDriverInternalWalkHeapParamsInit* aParams )
     {
 	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit() - START"));
-    __ASSERT_ALWAYS( !iHeapWalkInitialised && iWalkHeap.ChunkIsInitialised() == EFalse, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkPending ) );
+    __ASSERT_ALWAYS( !iHeapWalkInitialised && iWalkHeap.Helper() == NULL, MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkPending ) );
 
     TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, &iHeapWalkInitialParameters, sizeof(TMemSpyDriverInternalWalkHeapParamsInit) );
     if  ( r == KErrNone )
@@ -141,8 +141,8 @@
                 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - thread: %O", thread));
 
                 // Open client's heap
-                DChunk* userHeapChunk = NULL;
-                r = OpenUserHeap( *thread, iHeapWalkInitialParameters.iRHeapVTable, iWalkHeap, userHeapChunk );
+                r = iWalkHeap.OpenUserHeap(*thread, iHeapWalkInitialParameters.iDebugAllocator);
+
                 TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - opening client heap returned: %d", r) );
 
                 if  ( r == KErrNone )
@@ -154,7 +154,7 @@
 
                     // Walk the client's heap
                     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - calling heap walker constructor..."));
-                    RMemSpyDriverHeapWalker heapWalker( iWalkHeap, iHeapWalkInitialParameters.iDebugAllocator );
+                    RMemSpyDriverHeapWalker heapWalker(iWalkHeap);
                     
                     TMemSpyDriverLogChanHeapWalkObserver observer( *this );
                     heapWalker.SetObserver( &observer );
@@ -169,7 +169,7 @@
                 if  ( r < KErrNone )
                     {
                     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapInit - error scenario - releasing kernel heap chunk copy" ));
-                    iWalkHeap.DisassociateWithKernelChunk();
+                    iWalkHeap.Close();
                     }
                 }
             else
@@ -199,7 +199,7 @@
     {
     const TInt walkedHeapCellCount = iWalkHeapCells.Count();
 	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapNextCell() - START - current cell count: %d", walkedHeapCellCount));
-    __ASSERT_ALWAYS( iHeapWalkInitialised && iWalkHeap.ChunkIsInitialised(), MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkNotInitialised ) );
+    __ASSERT_ALWAYS( iHeapWalkInitialised && iWalkHeap.Helper(), MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkNotInitialised ) );
 
     // Open the original thread
 	TInt r = OpenTempObject( aTid, EThread );
@@ -257,12 +257,7 @@
         TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapClose - heap walk was still open..."));
       	NKern::ThreadEnterCS();
 
-        if  ( iWalkHeap.ChunkIsInitialised() )
-            {
-            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapClose - removing chunk (%O) from process", &iWalkHeap.Chunk() ) );
-            iWalkHeap.DisassociateWithKernelChunk();
-            iWalkHeap.Reset();
-            }
+		iWalkHeap.Close();
 
         // Discard handled cells
         iWalkHeapCells.Reset();
@@ -279,10 +274,9 @@
 
 TInt DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData(TMemSpyDriverInternalWalkHeapCellDataReadParams* aParams)
     {
-    __ASSERT_ALWAYS( iHeapWalkInitialised && iWalkHeap.ChunkIsInitialised(), MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkNotInitialised ) );
+    __ASSERT_ALWAYS( iHeapWalkInitialised && iWalkHeap.Helper(), MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkNotInitialised ) );
     //
-    const TBool debugEUser = iHeapWalkInitialParameters.iDebugAllocator;
-	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData() - START - thread id: %d, vtable: 0x%08x, debugAllocator: %d", iHeapWalkInitialParameters.iTid, iHeapWalkInitialParameters.iRHeapVTable, debugEUser));
+	TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData() - START - thread id: %d, vtable: 0x%08x", iHeapWalkInitialParameters.iTid, iHeapWalkInitialParameters.iRHeapVTable));
     //
 	TMemSpyDriverInternalWalkHeapCellDataReadParams params;
     TInt r = Kern::ThreadRawRead( &ClientThread(), aParams, &params, sizeof(TMemSpyDriverInternalWalkHeapCellDataReadParams) );
@@ -306,92 +300,58 @@
             {
             // Check we can find the cell in the cell list...
             const TMemSpyDriverInternalWalkHeapParamsCell* cell = CellInfoForSpecificAddress( params.iCellAddress );
-            if  ( cell == NULL )
-                {
-                // Maybe the client tried the base address of the cell data.
-                // try to take the header into account and retry.
-                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - didnt find matching cell for address: 0x%08x... trying address minus allocatedCellHeaderSize", params.iCellAddress ));
-
-                const TUint32 cellHeaderSize = (TUint32) RMemSpyDriverRHeapBase::AllocatedCellHeaderSize( debugEUser );
-        
-                TUint32 addr = (TUint32) params.iCellAddress;
-                addr -= cellHeaderSize;
-                params.iCellAddress = (TAny*) addr;
-                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - new address: 0x%08x", params.iCellAddress ));
-        
-                // Last try
-                cell = CellInfoForSpecificAddress( params.iCellAddress );
-                }
 
             TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - cell: 0x%08x for address: 0x%08x", cell, params.iCellAddress ));
 
             if  ( cell )
                 {
-                const TBool isValidCell = iWalkHeap.CheckCell( cell->iCellAddress, cell->iLength );
-                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - isValidCell: %d", isValidCell ));
-        
-                if  ( isValidCell )
+                const TInt cellLen = cell->iLength;
+                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - cellLen: %d", cellLen ));
+
+                if  ( params.iReadLen <= cellLen )
                     {
-                    // Check the length request is valid
-                    const TInt cellLen = cell->iLength;
-                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - cellLen: %d", cellLen ));
+
+                    // Get user side descriptor length info
+         	        TInt destLen = 0;
+        	        TInt destMax = 0;
+                    TUint8* destPtr = NULL;
 
-                    if  ( params.iReadLen <= cellLen )
+                    r = Kern::ThreadGetDesInfo( &ClientThread(), params.iDes, destLen, destMax, destPtr, ETrue );
+        	        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - user side descriptor: 0x%08x (0x%08x), len: %8d, maxLen: %8d, r: %d", params.iDes, destPtr, destLen, destMax, r ));
+
+                    // Work out the start offset for the data...
+                    if  ( r == KErrNone && destMax >= params.iReadLen )
                         {
-                        const TInt cellHeaderSize = RMemSpyDriverRHeapBase::CellHeaderSize( *cell, debugEUser );
-        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - cellHeaderSize: %8d", cellHeaderSize ));
+                        const TAny* srcPos = ((TUint8*) cell->iCellAddress);
+        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - srcPos: 0x%08x", srcPos ));
 
-                        // Get user side descriptor length info
-         	            TInt destLen = 0;
-        	            TInt destMax = 0;
-                        TUint8* destPtr = NULL;
+                        // Read some data 
+                        r = Kern::ThreadRawRead( thread, srcPos, destPtr, params.iReadLen );
+    	                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - read from thread returned: %d", r));
 
-                        r = Kern::ThreadGetDesInfo( &ClientThread(), params.iDes, destLen, destMax, destPtr, ETrue );
-        	            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - user side descriptor: 0x%08x (0x%08x), len: %8d, maxLen: %8d, r: %d", params.iDes, destPtr, destLen, destMax, r ));
-
-                        // Work out the start offset for the data...
-                        if  ( r == KErrNone && destMax >= params.iReadLen )
+                        if  ( r == KErrNone )
                             {
-                            const TAny* srcPos = ((TUint8*) cell->iCellAddress) + cellHeaderSize;
-        	                TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - srcPos: 0x%08x", srcPos ));
-
-                            // Read some data 
-                            r = Kern::ThreadRawRead( thread, srcPos, destPtr, params.iReadLen );
-    	                    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - read from thread returned: %d", r));
-
-                            if  ( r == KErrNone )
-                                {
-                                // Client will update descriptor length in this situation.
-                                r = params.iReadLen;
-                                }
-                            else if ( r == KErrBadDescriptor )
-                                {
-                                MemSpyDriverUtils::PanicThread( ClientThread(), EPanicBadDescriptor );
-                                }
-                            }
-                        else
-                            {
-                            if  ( r != KErrBadDescriptor )
-                                {
-                                r = KErrArgument;                
-            	                Kern::Printf( "DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - error - user-descriptor isnt big enough for requested data" );
-                                }
-                            else
-                                {
-            	                Kern::Printf( "DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - error - bad or non-writable user-side descriptor" );
-                                }
+                            // Client will update descriptor length in this situation.
+                            r = params.iReadLen;
                             }
                         }
                     else
                         {
-                        r = KErrArgument;
-        	            Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - error - read length is bigger than cell length");
+                        if  ( r != KErrBadDescriptor )
+                            {
+                            r = KErrArgument;                
+            	            Kern::Printf( "DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - error - user-descriptor isnt big enough for requested data" );
+                            }
+                        else
+                            {
+            	            Kern::Printf( "DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - error - bad or non-writable user-side descriptor" );
+                            }
                         }
                     }
                 else
                     {
                     r = KErrArgument;
-                    Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - invalid cell address: 0x%08x", cell);
+        	        Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - error - read length is bigger than cell length");
                     }
                 }
             else
@@ -413,17 +373,16 @@
     	Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData - thread not found");
 		}
     //
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData() - END"));
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapReadCellData() - END result=%d", r));
     return r;
     }
 
 
 TInt DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo( TAny* aCellAddress, TMemSpyDriverInternalWalkHeapParamsCell* aParams )
     {
-    __ASSERT_ALWAYS( iHeapWalkInitialised && iWalkHeap.ChunkIsInitialised(), MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkNotInitialised ) );
+    __ASSERT_ALWAYS( iHeapWalkInitialised && iWalkHeap.Helper(), MemSpyDriverUtils::PanicThread( ClientThread(), EPanicHeapWalkNotInitialised ) );
     //
-    const TBool debugEUser = iHeapWalkInitialParameters.iDebugAllocator;
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo() - START - thread id: %d, vtable: 0x%08x, debugAllocator: %d", iHeapWalkInitialParameters.iTid, iHeapWalkInitialParameters.iRHeapVTable, debugEUser));
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo() - START - thread id: %d, vtable: 0x%08x", iHeapWalkInitialParameters.iTid, iHeapWalkInitialParameters.iRHeapVTable));
     TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - cell: 0x%08x", aCellAddress));
 
     // Open the original thread
@@ -450,16 +409,6 @@
     if  ( cell == NULL )
         {
         TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - no exact match for address: 0x%08x...", aCellAddress));
-
-        // Maybe the client tried the base address of the cell data.
-        // try to take the header into account and retry.
-        const TUint32 cellHeaderSize = (TUint32) RMemSpyDriverRHeapBase::AllocatedCellHeaderSize( debugEUser );
-        TUint32 addr = (TUint32) aCellAddress;
-        addr -= cellHeaderSize;
-        
-        TAny* cellByRawStartingAddress = (TAny*) addr;
-        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - trying to search by start of cell address: 0x%08x (cellHeaderSize: %d)", cellByRawStartingAddress, cellHeaderSize));
-        cell = CellInfoForSpecificAddress( cellByRawStartingAddress );
         
         // If the cell still wasn't found, then let's look for any heap cell that contains
         // the client-specified address (i.e. find the heap cell that contains the specified
@@ -473,18 +422,9 @@
 
     if  ( cell )
         {
-        const TBool isValidCell = iWalkHeap.CheckCell( cell->iCellAddress, cell->iLength );
-        if  ( isValidCell )
-            {
-            // Have enough info to write back to client now
-            TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - returning... cellType: %1d, addr: 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d", cell->iCellType, cell->iCellAddress, cell->iLength, cell->iNestingLevel, cell->iAllocNumber ));
-            r = Kern::ThreadRawWrite( &ClientThread(), aParams, cell, sizeof(TMemSpyDriverInternalWalkHeapParamsCell) );
-            }
-        else
-            {
-            r = KErrArgument;
-            Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - invalid cell address: 0x%08x", cell);
-            }
+        // Have enough info to write back to client now
+        TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo - returning... cellType: %1d, addr: 0x%08x, len: %8d, nestingLev: %8d, allocNum: %8d", cell->iCellType, cell->iCellAddress, cell->iLength, cell->iNestingLevel, cell->iAllocNumber ));
+        r = Kern::ThreadRawWrite( &ClientThread(), aParams, cell, sizeof(TMemSpyDriverInternalWalkHeapParamsCell) );
         }
     else
         {
@@ -494,7 +434,7 @@
     
     CloseTempObject();
     //
-    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo() - END"));
+    TRACE( Kern::Printf("DMemSpyDriverLogChanHeapWalk::WalkHeapGetCellInfo() - END result=%d", r));
     return r;
     }
 
@@ -576,7 +516,7 @@
 
 
 
-TBool DMemSpyDriverLogChanHeapWalk::WalkerHandleHeapCell( TInt aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber )
+TBool DMemSpyDriverLogChanHeapWalk::WalkerHandleHeapCell(TMemSpyDriverCellType aCellType, TAny* aCellAddress, TInt aLength, TInt aNestingLevel, TInt aAllocNumber )
     {
     TInt error = KErrNone;
     //
--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanMisc.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanMisc.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -171,7 +171,6 @@
 
         DObjectCon* container = Kern::Containers()[ EProcess ];
         container->Wait();
-        NKern::LockSystem();
 
         const TInt count = container->Count();
         for(TInt i=0; i<count; i++)
@@ -193,9 +192,7 @@
                 }
             }
 
-        NKern::UnlockSystem();
         container->Signal();
-
     	NKern::ThreadLeaveCS();
         }
 
--- a/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanStack.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Kernel/Source/SubChannels/MemSpyDriverLogChanStack.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -186,10 +186,6 @@
                 stackSize = threadAdaption.GetSupervisorStackSize( *thread );
                 stackBase = threadAdaption.GetSupervisorStackBase( *thread );
                 }
-            //We have a stack so setting it as available
-            if(stackSize!=0 &&  stackBase!=0)
-                stackAvailable=ETrue;
-            
             TRACE( Kern::Printf("DMemSpyDriverLogChanStack::GetStackData() - stackAvailable: %d", stackAvailable ));
             //           
             if  ( stackAvailable )
--- a/memspy/Driver/Shared/MemSpyDriverObjectsInternal.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Shared/MemSpyDriverObjectsInternal.h	Wed Sep 15 13:53:27 2010 +0300
@@ -33,8 +33,7 @@
     {
 public:
     inline TMemSpyDriverInternalHeapRequestParameters()
-        : iTid( 0 ), iRHeapVTable( 0 ), iBuildFreeCellList( EFalse ), iDebugAllocator( EFalse ), 
-          iMasterInfo( NULL )
+        : iTid(0), iRHeapVTable(0), iBuildFreeCellList(EFalse), iBuildAllocCellList(EFalse), iDebugAllocator(EFalse), iMasterInfo(NULL)
         {
         }
 
@@ -42,6 +41,7 @@
     TUint iTid;
     TUint32 iRHeapVTable;
     TBool iBuildFreeCellList;
+	TBool iBuildAllocCellList;
 
 public: // Params IN or OUT (IN in User heap requests, OUT in Kernel heap requests)
     TBool iDebugAllocator;
--- a/memspy/Driver/Shared/MemSpyDriverOpCodes.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/Shared/MemSpyDriverOpCodes.h	Wed Sep 15 13:53:27 2010 +0300
@@ -56,7 +56,7 @@
 	EMemSpyDriverOpCodeHeapInfoGetUser,
 	EMemSpyDriverOpCodeHeapInfoGetKernel,
     EMemSpyDriverOpCodeHeapInfoGetIsDebugKernel,
-    EMemSpyDriverOpCodeHeapInfoFetchFreeCells,
+    EMemSpyDriverOpCodeHeapInfoFetchCellList,
     EMemSpyDriverOpCodeHeapInfoEnd,
 
     // HEAP DATA
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/Driver/Shared/heaputils.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,1684 @@
+// heaputils.cpp
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "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:
+// Accenture - Initial contribution
+//
+#ifdef TEST_HYBRIDHEAP_ASSERTS
+#define private public
+#include <e32def.h>
+#include "slab.h"
+#include "page_alloc.h"
+#include "heap_hybrid.h"
+#endif
+
+#include "heaputils.h"
+
+#ifdef __KERNEL_MODE__
+
+#include <kern_priv.h>
+#define MEM Kern
+__ASSERT_COMPILE(sizeof(LtkUtils::RKernelSideAllocatorHelper) == 10*4);
+#define KERN_ENTER_CS() NKern::ThreadEnterCS()
+#define KERN_LEAVE_CS() NKern::ThreadLeaveCS()
+#define LOG(args...)
+#define HUEXPORT_C
+#else
+
+#include <e32std.h>
+#define MEM User
+#define KERN_ENTER_CS()
+#define KERN_LEAVE_CS()
+//#include <e32debug.h>
+//#define LOG(args...) RDebug::Printf(args)
+#define LOG(args...)
+
+#ifdef STANDALONE_ALLOCHELPER
+#define HUEXPORT_C
+#else
+#define HUEXPORT_C EXPORT_C
+#endif
+
+#endif // __KERNEL_MODE__
+
+using LtkUtils::RAllocatorHelper;
+const TUint KPageSize = 4096;
+__ASSERT_COMPILE(sizeof(RAllocatorHelper) == 9*4);
+
+// RAllocatorHelper
+
+HUEXPORT_C RAllocatorHelper::RAllocatorHelper()
+	: iAllocatorAddress(0), iAllocatorType(EUnknown), iInfo(NULL), iValidInfo(0), iTempSlabBitmap(NULL), iPageCache(NULL), iPageCacheAddr(0)
+#ifdef __KERNEL_MODE__
+	, iChunk(NULL)
+#endif
+	{
+	}
+
+namespace LtkUtils
+	{
+	class THeapInfo
+		{
+	public:
+		THeapInfo()
+			{
+			ClearStats();
+			}
+
+		void ClearStats()
+			{
+			memclr(this, sizeof(THeapInfo));
+			}
+
+		TInt iAllocatedSize; // number of bytes in allocated cells (excludes free cells, cell header overhead)
+		TInt iCommittedSize; // amount of memory actually committed (includes cell header overhead, gaps smaller than an MMU page)
+		TInt iAllocationCount; // number of allocations currently
+		TInt iMaxCommittedSize; // or thereabouts
+		TInt iMinCommittedSize;
+		TInt iUnusedPages;
+		TInt iCommittedFreeSpace;
+		// Heap-only stats
+		TInt iHeapFreeCellCount;
+		// Hybrid-only stats
+		TInt iDlaAllocsSize;
+		TInt iDlaAllocsCount;
+		TInt iDlaFreeSize;
+		TInt iDlaFreeCount;
+		TInt iSlabAllocsSize;
+		TInt iSlabAllocsCount;
+		TInt iPageAllocsSize;
+		TInt iPageAllocsCount;
+		TInt iSlabFreeCellSize;
+		TInt iSlabFreeCellCount;
+		TInt iSlabFreeSlabSize;
+		TInt iSlabFreeSlabCount;
+		};
+	}
+
+const TInt KTempBitmapSize = 256; // KMaxSlabPayload / mincellsize, technically. Close enough.
+
+#ifdef __KERNEL_MODE__
+
+TInt RAllocatorHelper::OpenKernelHeap()
+	{
+	_LIT(KName, "SvHeap");
+	NKern::ThreadEnterCS();
+	DObjectCon* chunkContainer = Kern::Containers()[EChunk];
+	chunkContainer->Wait();
+	const TInt chunkCount = chunkContainer->Count();
+	DChunk* foundChunk = NULL;
+	for(TInt i=0; i<chunkCount; i++)
+		{
+		DChunk* chunk = (DChunk*)(*chunkContainer)[i];
+		if (chunk->NameBuf() && chunk->NameBuf()->Find(KName) != KErrNotFound)
+			{
+			// Found it. No need to open it, we can be fairly confident the kernel heap isn't going to disappear from under us
+			foundChunk = chunk;
+			break;
+			}
+		}
+	iChunk = foundChunk;
+    chunkContainer->Signal();
+#ifdef __WINS__
+	TInt err = OpenChunkHeap((TLinAddr)foundChunk->Base(), 0); // It looks like DChunk::iBase/DChunk::iFixedBase should both be ok for the kernel chunk
+#else
+	// Copied from P::KernelInfo
+	const TRomHeader& romHdr=Epoc::RomHeader();
+	const TRomEntry* primaryEntry=(const TRomEntry*)Kern::SuperPage().iPrimaryEntry;
+	const TRomImageHeader* primaryImageHeader=(const TRomImageHeader*)primaryEntry->iAddressLin;
+	TLinAddr stack = romHdr.iKernDataAddress + Kern::RoundToPageSize(romHdr.iTotalSvDataSize);
+	TLinAddr heap = stack + Kern::RoundToPageSize(primaryImageHeader->iStackSize);
+	TInt err = OpenChunkHeap(heap, 0); // aChunkMaxSize is only used for trying the middle of the chunk for hybrid allocatorness, and the kernel heap doesn't use that (thankfully). So we can safely pass in zero.
+
+#endif
+	if (!err) err = FinishConstruction();
+	NKern::ThreadLeaveCS();
+	return err;
+	}
+
+#else
+
+HUEXPORT_C TInt RAllocatorHelper::Open(RAllocator* aAllocator)
+	{
+	iAllocatorAddress = (TLinAddr)aAllocator;
+	TInt udeb = EuserIsUdeb();
+	if (udeb < 0) return udeb; // error
+
+	TInt err = IdentifyAllocatorType(udeb);
+	if (!err)
+		{
+		err = FinishConstruction(); // Allocate everything up front
+		}
+	if (!err)
+		{
+		// We always stealth our own allocations, again to avoid tripping up allocator checks
+		SetCellNestingLevel(iInfo, -1);
+		SetCellNestingLevel(iTempSlabBitmap, -1);
+		SetCellNestingLevel(iPageCache, -1);
+		}
+	return err;
+	}
+
+#endif
+
+TInt RAllocatorHelper::FinishConstruction()
+	{
+	TInt err = KErrNone;
+	KERN_ENTER_CS();
+	if (!iInfo)
+		{
+		iInfo = new THeapInfo;
+		if (!iInfo) err = KErrNoMemory;
+		}
+	if (!err && !iTempSlabBitmap)
+		{
+		iTempSlabBitmap = (TUint8*)MEM::Alloc(KTempBitmapSize);
+		if (!iTempSlabBitmap) err = KErrNoMemory;
+		}
+	if (!err && !iPageCache)
+		{
+		iPageCache = MEM::Alloc(KPageSize);
+		if (!iPageCache) err = KErrNoMemory;
+		}
+
+	if (err)
+		{
+		delete iInfo;
+		iInfo = NULL;
+		MEM::Free(iTempSlabBitmap);
+		iTempSlabBitmap = NULL;
+		MEM::Free(iPageCache);
+		iPageCache = NULL;
+		}
+	KERN_LEAVE_CS();
+	return err;
+	}
+
+TInt RAllocatorHelper::ReadWord(TLinAddr aLocation, TUint32& aResult) const
+	{
+	// Check if we can satisfy the read from the cache
+	if (aLocation >= iPageCacheAddr)
+		{
+		TUint offset = aLocation - iPageCacheAddr;
+		if (offset < KPageSize)
+			{
+			aResult = ((TUint32*)iPageCache)[offset >> 2];
+			return KErrNone;
+			}
+		}
+
+	// If we reach here, not in page cache. Try and read in the new page
+	if (iPageCache)
+		{
+		TLinAddr pageAddr = aLocation & ~(KPageSize-1);
+		TInt err = ReadData(pageAddr, iPageCache, KPageSize);
+		if (!err)
+			{
+			iPageCacheAddr = pageAddr;
+			aResult = ((TUint32*)iPageCache)[(aLocation - iPageCacheAddr) >> 2];
+			return KErrNone;
+			}
+		}
+
+	// All else fails, try just reading it uncached
+	return ReadData(aLocation, &aResult, sizeof(TUint32));
+	}
+
+TInt RAllocatorHelper::ReadByte(TLinAddr aLocation, TUint8& aResult) const
+	{
+	// Like ReadWord but 8-bit
+
+	// Check if we can satisfy the read from the cache
+	if (aLocation >= iPageCacheAddr)
+		{
+		TUint offset = aLocation - iPageCacheAddr;
+		if (offset < KPageSize)
+			{
+			aResult = ((TUint8*)iPageCache)[offset];
+			return KErrNone;
+			}
+		}
+
+	// If we reach here, not in page cache. Try and read in the new page
+	if (iPageCache)
+		{
+		TLinAddr pageAddr = aLocation & ~(KPageSize-1);
+		TInt err = ReadData(pageAddr, iPageCache, KPageSize);
+		if (!err)
+			{
+			iPageCacheAddr = pageAddr;
+			aResult = ((TUint8*)iPageCache)[(aLocation - iPageCacheAddr)];
+			return KErrNone;
+			}
+		}
+
+	// All else fails, try just reading it uncached
+	return ReadData(aLocation, &aResult, sizeof(TUint8));
+	}
+
+
+TInt RAllocatorHelper::WriteWord(TLinAddr aLocation, TUint32 aWord)
+	{
+	// Invalidate the page cache if necessary
+	if (aLocation >= iPageCacheAddr && aLocation - iPageCacheAddr < KPageSize)
+		{
+		iPageCacheAddr = 0;
+		}
+
+	return WriteData(aLocation, &aWord, sizeof(TUint32));
+	}
+
+TInt RAllocatorHelper::ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const
+	{
+	// RAllocatorHelper base class impl is for allocators in same address space, so just copy it
+	memcpy(aResult, (const TAny*)aLocation, aSize);
+	return KErrNone;
+	}
+
+TInt RAllocatorHelper::WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize)
+	{
+	memcpy((TAny*)aLocation, aData, aSize);
+	return KErrNone;
+	}
+
+#ifdef __KERNEL_MODE__
+
+LtkUtils::RKernelSideAllocatorHelper::RKernelSideAllocatorHelper()
+	: iThread(NULL)
+	{}
+
+void LtkUtils::RKernelSideAllocatorHelper::Close()
+	{
+	NKern::ThreadEnterCS();
+	if (iThread)
+		{
+		iThread->Close(NULL);
+		}
+	iThread = NULL;
+	RAllocatorHelper::Close();
+	NKern::ThreadLeaveCS();
+	}
+
+TInt LtkUtils::RKernelSideAllocatorHelper::ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const
+	{
+	return Kern::ThreadRawRead(iThread, (const TAny*)aLocation, aResult, aSize);
+	}
+
+TInt LtkUtils::RKernelSideAllocatorHelper::WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize)
+	{
+	return Kern::ThreadRawWrite(iThread, (TAny*)aLocation, aData, aSize);
+	}
+
+TInt LtkUtils::RKernelSideAllocatorHelper::TryLock()
+	{
+	return KErrNotSupported;
+	}
+
+void LtkUtils::RKernelSideAllocatorHelper::TryUnlock()
+	{
+	// Not supported
+	}
+
+TInt LtkUtils::RKernelSideAllocatorHelper::OpenUserHeap(TUint aThreadId, TLinAddr aAllocatorAddress, TBool aEuserIsUdeb)
+	{
+	NKern::ThreadEnterCS();
+	DObjectCon* threads = Kern::Containers()[EThread];
+	threads->Wait();
+	iThread = Kern::ThreadFromId(aThreadId);
+	if (iThread && iThread->Open() != KErrNone)
+		{
+		// Failed to open
+		iThread = NULL;
+		}
+	threads->Signal();
+	NKern::ThreadLeaveCS();
+	if (!iThread) return KErrNotFound;
+	iAllocatorAddress = aAllocatorAddress;
+	TInt err = IdentifyAllocatorType(aEuserIsUdeb);
+	if (err) Close();
+	return err;
+	}
+
+#endif // __KERNEL_MODE__
+
+TInt RAllocatorHelper::OpenChunkHeap(TLinAddr aChunkBase, TInt aChunkMaxSize)
+	{
+	iAllocatorAddress = aChunkBase;
+#ifdef __KERNEL_MODE__
+	// Must be in CS
+	// Assumes that this only ever gets called for the kernel heap. Otherwise goes through RKernelSideAllocatorHelper::OpenUserHeap.
+	TInt udeb = EFalse; // We can't figure this out until after we've got the heap
+	TBool isTheKernelHeap = ETrue;
+#else
+	// Assumes the chunk isn't the kernel heap. It's not a good idea to try messing with the kernel heap from user side...
+	TInt udeb = EuserIsUdeb();
+	if (udeb < 0) return udeb; // error
+    TBool isTheKernelHeap = EFalse;
+#endif
+
+	TInt err = IdentifyAllocatorType(udeb, isTheKernelHeap);
+	if (err == KErrNone && iAllocatorType == EAllocator)
+		{
+		// We've no reason to assume it's an allocator because we don't know the iAllocatorAddress actually is an RAllocator*
+		err = KErrNotFound;
+		}
+	if (err && aChunkMaxSize > 0)
+		{
+		TInt oldErr = err;
+		TAllocatorType oldType = iAllocatorType;
+		// Try middle of chunk, in case it's an RHybridHeap
+		iAllocatorAddress += aChunkMaxSize / 2;
+		err = IdentifyAllocatorType(udeb, isTheKernelHeap);
+		if (err || iAllocatorType == EAllocator)
+			{
+			// No better than before
+			iAllocatorAddress = aChunkBase;
+			iAllocatorType = oldType;
+			err = oldErr;
+			}
+		}
+#ifdef __KERNEL_MODE__
+	if (err == KErrNone)
+		{
+		// Now we know the allocator, we can figure out the udeb-ness
+		RAllocator* kernelAllocator = reinterpret_cast<RAllocator*>(iAllocatorAddress);
+		kernelAllocator->DebugFunction(RAllocator::ESetFail, (TAny*)9999, (TAny*)0); // Use an invalid fail reason - this should have no effect on the operation of the heap
+		TInt err = kernelAllocator->DebugFunction(7, NULL, NULL); // 7 is RAllocator::TAllocDebugOp::EGetFail
+		if (err == 9999)
+			{
+			// udeb new hybrid heap
+			udeb = ETrue;
+			}
+		else if (err == KErrNotSupported)
+			{
+			// Old heap - fall back to slightly nasty non-thread-safe method
+			kernelAllocator->DebugFunction(RAllocator::ESetFail, (TAny*)RAllocator::EFailNext, (TAny*)1);
+			TAny* res = Kern::Alloc(4);
+			if (!res) udeb = ETrue;
+			Kern::Free(res);
+			}
+		else
+			{
+			// it's new urel
+			}
+
+		// Put everything back
+		kernelAllocator->DebugFunction(RAllocator::ESetFail, (TAny*)RAllocator::ENone, (TAny*)0);
+		// And update the type now we know the udeb-ness for certain
+		err = IdentifyAllocatorType(udeb, isTheKernelHeap);
+		}
+#endif
+	return err;
+	}
+
+
+// The guts of RAllocatorHelper
+
+enum TWhatToGet
+	{
+	ECommitted = 1,
+	EAllocated = 2,
+	ECount = 4,
+	EMaxSize = 8,
+	EUnusedPages = 16,
+	ECommittedFreeSpace = 32,
+	EMinSize = 64,
+	EHybridStats = 128,
+	};
+
+class RHackAllocator : public RAllocator
+	{
+public:
+	using RAllocator::iHandles;
+	using RAllocator::iTotalAllocSize;
+	using RAllocator::iCellCount;
+	};
+
+class RHackHeap : public RHeap
+	{
+public:
+	// Careful, only allowed to use things that are still in the new RHeap, and are still in the same place
+	using RHeap::iMaxLength;
+	using RHeap::iChunkHandle;
+	using RHeap::iLock;
+	using RHeap::iBase;
+	using RHeap::iAlign;
+	using RHeap::iTop;
+	};
+
+const TInt KChunkSizeOffset = 30*4;
+const TInt KPageMapOffset = 141*4;
+//const TInt KDlOnlyOffset = 33*4;
+const TInt KMallocStateOffset = 34*4;
+const TInt KMallocStateTopSizeOffset = 3*4;
+const TInt KMallocStateTopOffset = 5*4;
+const TInt KMallocStateSegOffset = 105*4;
+const TInt KUserHybridHeapSize = 186*4;
+const TInt KSparePageOffset = 167*4;
+const TInt KPartialPageOffset = 165*4;
+const TInt KFullSlabOffset = 166*4;
+const TInt KSlabAllocOffset = 172*4;
+const TInt KSlabParentOffset = 1*4;
+const TInt KSlabChild1Offset = 2*4;
+const TInt KSlabChild2Offset = 3*4;
+const TInt KSlabPayloadOffset = 4*4;
+const TInt KSlabsetSize = 4;
+
+#ifdef TEST_HYBRIDHEAP_ASSERTS
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iChunkSize) == KChunkSizeOffset);
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iPageMap) == KPageMapOffset);
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iGlobalMallocState) == KMallocStateOffset);
+__ASSERT_COMPILE(sizeof(malloc_state) == 107*4);
+__ASSERT_COMPILE(_FOFF(malloc_state, iTopSize) == KMallocStateTopSizeOffset);
+__ASSERT_COMPILE(_FOFF(malloc_state, iTop) == KMallocStateTopOffset);
+__ASSERT_COMPILE(_FOFF(malloc_state, iSeg) == KMallocStateSegOffset);
+__ASSERT_COMPILE(sizeof(RHybridHeap) == KUserHybridHeapSize);
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iSparePage) == KSparePageOffset);
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iPartialPage) == KPartialPageOffset);
+__ASSERT_COMPILE(_FOFF(RHybridHeap, iSlabAlloc) == KSlabAllocOffset);
+__ASSERT_COMPILE(_FOFF(slab, iParent) == KSlabParentOffset);
+__ASSERT_COMPILE(_FOFF(slab, iChild1) == KSlabChild1Offset);
+__ASSERT_COMPILE(_FOFF(slab, iChild2) == KSlabChild2Offset);
+__ASSERT_COMPILE(_FOFF(slab, iPayload) == KSlabPayloadOffset);
+__ASSERT_COMPILE(sizeof(slabset) == KSlabsetSize);
+#endif
+
+TInt RAllocatorHelper::TryLock()
+	{
+#ifdef __KERNEL_MODE__
+	NKern::ThreadEnterCS();
+	DMutex* m = *(DMutex**)(iAllocatorAddress + _FOFF(RHackHeap, iLock));
+	if (m) Kern::MutexWait(*m);
+	return KErrNone;
+#else
+	if (iAllocatorType != EUnknown && iAllocatorType != EAllocator)
+		{
+		RFastLock& lock = *reinterpret_cast<RFastLock*>(iAllocatorAddress + _FOFF(RHackHeap, iLock));
+		lock.Wait();
+		return KErrNone;
+		}
+	return KErrNotSupported;
+#endif
+	}
+
+void RAllocatorHelper::TryUnlock()
+	{
+#ifdef __KERNEL_MODE__
+	DMutex* m = *(DMutex**)(iAllocatorAddress + _FOFF(RHackHeap, iLock));
+	if (m) Kern::MutexSignal(*m);
+	NKern::ThreadLeaveCS();
+#else
+	if (iAllocatorType != EUnknown && iAllocatorType != EAllocator)
+		{
+		RFastLock& lock = *reinterpret_cast<RFastLock*>(iAllocatorAddress + _FOFF(RHackHeap, iLock));
+		lock.Signal();
+		}
+#endif
+	}
+
+HUEXPORT_C void RAllocatorHelper::Close()
+	{
+	KERN_ENTER_CS();
+	iAllocatorType = EUnknown;
+	iAllocatorAddress = 0;
+	delete iInfo;
+	iInfo = NULL;
+	iValidInfo = 0;
+	MEM::Free(iTempSlabBitmap);
+	iTempSlabBitmap = NULL;
+	MEM::Free(iPageCache);
+	iPageCache = NULL;
+	iPageCacheAddr = 0;
+	KERN_LEAVE_CS();
+	}
+
+TInt RAllocatorHelper::IdentifyAllocatorType(TBool aAllocatorIsUdeb, TBool aIsTheKernelHeap)
+	{
+	iAllocatorType = EUnknown;
+
+	TUint32 handlesPtr = 0;
+	TInt err = ReadWord(iAllocatorAddress + _FOFF(RHackAllocator, iHandles), handlesPtr);
+
+	if (err) return err;
+	if (aIsTheKernelHeap || 
+	    handlesPtr == iAllocatorAddress + _FOFF(RHackHeap, iChunkHandle) || 
+	    handlesPtr == iAllocatorAddress + _FOFF(RHackHeap, iLock))
+		{
+		// It's an RHeap of some kind - I doubt any other RAllocator subclass will use iHandles in this way
+		TUint32 base = 0;
+		err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iBase), base);
+		if (err) return err;
+		TInt objsize = (TInt)base - (TInt)iAllocatorAddress;
+		if (objsize <= 32*4)
+			{
+			// Old RHeap
+			iAllocatorType = aAllocatorIsUdeb ? EUdebOldRHeap : EUrelOldRHeap;
+			}
+		else
+			{
+			// new hybrid heap - bigger than the old one. Likewise figure out if udeb or urel.
+			iAllocatorType = aAllocatorIsUdeb ? EUdebHybridHeap : EUrelHybridHeap;
+			}
+		}
+	else
+		{
+		iAllocatorType = EAllocator;
+		}
+	return KErrNone;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::SetCellNestingLevel(TAny* aCell, TInt aNestingLevel)
+	{
+	TInt err = KErrNone;
+
+	switch (iAllocatorType)
+		{
+		case EUdebOldRHeap:
+		case EUdebHybridHeap:
+			// By this reckoning, they're in the same place amazingly
+			{
+			TLinAddr nestingAddr = (TLinAddr)aCell - 8;
+			err = WriteWord(nestingAddr, aNestingLevel);
+			break;
+			}
+		default:
+			break;
+		}
+	return err;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::GetCellNestingLevel(TAny* aCell, TInt& aNestingLevel)
+	{
+	switch (iAllocatorType)
+		{
+		case EUdebOldRHeap:
+		case EUdebHybridHeap:
+			// By this reckoning, they're in the same place amazingly
+			{
+			TLinAddr nestingAddr = (TLinAddr)aCell - 8;
+			return ReadWord(nestingAddr, (TUint32&)aNestingLevel);
+			}
+		default:
+			return KErrNotSupported;
+		}
+	}
+
+TInt RAllocatorHelper::RefreshDetails(TUint aMask)
+	{
+	TInt err = FinishConstruction();
+	if (err) return err;
+
+	// Invalidate the page cache
+	iPageCacheAddr = 0;
+
+	TryLock();
+	err = DoRefreshDetails(aMask);
+	TryUnlock();
+	return err;
+	}
+
+const TInt KHeapWalkStatsForOldHeap = (EUnusedPages|ECommittedFreeSpace);
+const TInt KHeapWalkStatsForNewHeap = (EAllocated|ECount|EUnusedPages|ECommittedFreeSpace|EHybridStats);
+
+TInt RAllocatorHelper::DoRefreshDetails(TUint aMask)
+	{
+	TInt err = KErrNotSupported;
+	switch (iAllocatorType)
+		{
+		case EUrelOldRHeap:
+		case EUdebOldRHeap:
+			{
+			if (aMask & ECommitted)
+				{
+				// The old RHeap::Size() used to use iTop - iBase, which was effectively chunkSize - sizeof(RHeap)
+				// I think that for CommittedSize we should include the size of the heap object, just as it includes
+				// the size of heap cell metadata and overhead. Plus it makes sure the committedsize is a multiple of the page size
+				TUint32 top = 0;
+				//TUint32 base = 0;
+				//err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iBase), base);
+				//if (err) return err;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iTop), top);
+				if (err) return err;
+
+				//iInfo->iCommittedSize = top - base;
+				iInfo->iCommittedSize = top - iAllocatorAddress;
+				iValidInfo |= ECommitted;
+				}
+			if (aMask & EAllocated)
+				{
+				TUint32 allocSize = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackAllocator, iTotalAllocSize), allocSize);
+				if (err) return err;
+				iInfo->iAllocatedSize = allocSize;
+				iValidInfo |= EAllocated;
+				}
+			if (aMask & ECount)
+				{
+				TUint32 count = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackAllocator, iCellCount), count);
+				if (err) return err;
+				iInfo->iAllocationCount = count;
+				iValidInfo |= ECount;
+				}
+			if (aMask & EMaxSize)
+				{
+				TUint32 maxlen = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iMaxLength), maxlen);
+				if (err) return err;
+				iInfo->iMaxCommittedSize = maxlen;
+				iValidInfo |= EMaxSize;
+				}
+			if (aMask & EMinSize)
+				{
+				TUint32 minlen = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iMaxLength) - 4, minlen); // This isn't a typo! iMinLength is 4 bytes before iMaxLength, on old heap ONLY
+				if (err) return err;
+				iInfo->iMinCommittedSize = minlen;
+				iValidInfo |= EMinSize;
+				}
+			if (aMask & KHeapWalkStatsForOldHeap)
+				{
+				// Need a heap walk
+				iInfo->ClearStats();
+				iValidInfo = 0;
+				err = DoWalk(&WalkForStats, NULL);
+				if (err == KErrNone) iValidInfo |= KHeapWalkStatsForOldHeap;
+				}
+			return err;
+			}
+		case EUrelHybridHeap:
+		case EUdebHybridHeap:
+			{
+			TBool needWalk = EFalse;
+			if (aMask & ECommitted)
+				{
+				// RAllocator::Size uses iChunkSize - sizeof(RHybridHeap);
+				// We can't do exactly the same, because we can't calculate sizeof(RHybridHeap), only ROUND_UP(sizeof(RHybridHeap), iAlign)
+				// And if fact we don't bother and just use iChunkSize
+				TUint32 chunkSize = 0;
+				err = ReadWord(iAllocatorAddress + KChunkSizeOffset, chunkSize);
+				if (err) return err;
+				//TUint32 baseAddr = 0;
+				//err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iBase), baseAddr);
+				//if (err) return err;
+				iInfo->iCommittedSize = chunkSize; // - (baseAddr - iAllocatorAddress);
+				iValidInfo |= ECommitted;
+				}
+			if (aMask & (EAllocated|ECount))
+				{
+				if (iAllocatorType == EUdebHybridHeap)
+					{
+					// Easy, just get them from the counter
+					TUint32 totalAlloc = 0;
+					err = ReadWord(iAllocatorAddress + _FOFF(RHackAllocator, iTotalAllocSize), totalAlloc);
+					if (err) return err;
+					iInfo->iAllocatedSize = totalAlloc;
+					iValidInfo |= EAllocated;
+
+					TUint32 cellCount = 0;
+					err = ReadWord(iAllocatorAddress + _FOFF(RHackAllocator, iCellCount), cellCount);
+					if (err) return err;
+					iInfo->iAllocationCount = cellCount;
+					iValidInfo |= ECount;
+					}
+				else
+					{
+					// A heap walk is needed
+					needWalk = ETrue;
+					}
+				}
+			if (aMask & EMaxSize)
+				{
+				TUint32 maxlen = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iMaxLength), maxlen);
+				if (err) return err;
+				iInfo->iMaxCommittedSize = maxlen;
+				iValidInfo |= EMaxSize;
+				}
+			if (aMask & EMinSize)
+				{
+				TUint32 minlen = 0;
+				err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iAlign) + 4*4, minlen); // iMinLength is in different place to old RHeap
+				if (err) return err;
+				iInfo->iMinCommittedSize = minlen;
+				iValidInfo |= EMinSize;
+				}
+			if (aMask & (EUnusedPages|ECommittedFreeSpace|EHybridStats))
+				{
+				// EAllocated and ECount have already been taken care of above
+				needWalk = ETrue;
+				}
+
+			if (needWalk)
+				{
+				iInfo->ClearStats();
+				iValidInfo = 0;
+				err = DoWalk(&WalkForStats, NULL);
+				if (err == KErrNone) iValidInfo |= KHeapWalkStatsForNewHeap;
+				}
+			return err;
+			}
+		default:
+			return KErrNotSupported;
+		}
+	}
+
+TInt RAllocatorHelper::CheckValid(TUint aMask)
+	{
+	if ((iValidInfo & aMask) == aMask)
+		{
+		return KErrNone;
+		}
+	else
+		{
+		return RefreshDetails(aMask);
+		}
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::CommittedSize()
+	{
+	TInt err = CheckValid(ECommitted);
+	if (err) return err;
+	return iInfo->iCommittedSize;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::AllocatedSize()
+	{
+	TInt err = CheckValid(EAllocated);
+	if (err) return err;
+	return iInfo->iAllocatedSize;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::AllocationCount()
+	{
+	TInt err = CheckValid(ECount);
+	if (err) return err;
+	return iInfo->iAllocationCount;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::RefreshDetails()
+	{
+	return RefreshDetails(iValidInfo);
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::MaxCommittedSize()
+	{
+	TInt err = CheckValid(EMaxSize);
+	if (err) return err;
+	return iInfo->iMaxCommittedSize;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::MinCommittedSize()
+	{
+	TInt err = CheckValid(EMinSize);
+	if (err) return err;
+	return iInfo->iMinCommittedSize;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::AllocCountForCell(TAny* aCell) const
+	{
+	TUint32 allocCount = 0;
+	switch (iAllocatorType)
+		{
+		case EUdebOldRHeap:
+		case EUdebHybridHeap: // Both are in the same place, amazingly
+			{
+			TLinAddr allocCountAddr = (TLinAddr)aCell - 4;
+			TInt err = ReadWord(allocCountAddr, allocCount);
+			if (err) return err;
+			return (TInt)allocCount;
+			}
+		default:
+			return KErrNotSupported;
+		}
+	}
+
+struct SContext3
+	{
+	RAllocatorHelper::TWalkFunc3 iOrigWalkFn;
+	TAny* iOrigContext;
+	};
+
+TBool RAllocatorHelper::DispatchClientWalkCallback(RAllocatorHelper& aHelper, TAny* aContext, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellPtr, TInt aCellLength)
+	{
+	WalkForStats(aHelper, NULL, aCellType, aCellPtr, aCellLength);
+	SContext3* context = static_cast<SContext3*>(aContext);
+	return (*context->iOrigWalkFn)(aHelper, context->iOrigContext, aCellType, aCellPtr, aCellLength);
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::Walk(TWalkFunc3 aCallbackFn, TAny* aContext)
+	{
+	// Might as well take the opportunity of updating our stats at the same time as walking the heap for the client
+	SContext3 context = { aCallbackFn, aContext };
+
+	TInt err = FinishConstruction(); // In case this hasn't been done yet
+	if (err) return err;
+
+	TryLock();
+	err = DoWalk(&DispatchClientWalkCallback, &context);
+	TryUnlock();
+	return err;
+	}
+
+TInt RAllocatorHelper::DoWalk(TWalkFunc3 aCallbackFn, TAny* aContext)
+	{
+	TInt err = KErrNotSupported;
+	switch (iAllocatorType)
+		{
+		case EUdebOldRHeap:
+		case EUrelOldRHeap:
+			err = OldSkoolWalk(aCallbackFn, aContext);
+			break;
+		case EUrelHybridHeap:
+		case EUdebHybridHeap:
+			err = NewHotnessWalk(aCallbackFn, aContext);
+			break;
+		default:
+			err = KErrNotSupported;
+			break;
+		}
+	return err;
+	}
+
+struct SContext
+	{
+	RAllocatorHelper::TWalkFunc iOrigWalkFn;
+	TAny* iOrigContext;
+	};
+
+struct SContext2
+	{
+	RAllocatorHelper::TWalkFunc2 iOrigWalkFn;
+	TAny* iOrigContext;
+	};
+
+#define New2Old(aNew) (((aNew)&RAllocatorHelper::EAllocationMask) ? RAllocatorHelper::EAllocation : ((aNew)&RAllocatorHelper::EFreeMask) ? RAllocatorHelper::EFreeSpace : RAllocatorHelper::EBadness)
+
+TBool DispatchOldTWalkFuncCallback(RAllocatorHelper& /*aHelper*/, TAny* aContext, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellPtr, TInt aCellLength)
+	{
+	SContext* context = static_cast<SContext*>(aContext);
+	return (*context->iOrigWalkFn)(context->iOrigContext, New2Old(aCellType), aCellPtr, aCellLength);
+	}
+
+TBool DispatchOldTWalk2FuncCallback(RAllocatorHelper& aHelper, TAny* aContext, RAllocatorHelper::TExtendedCellType aCellType, TLinAddr aCellPtr, TInt aCellLength)
+	{
+	SContext2* context = static_cast<SContext2*>(aContext);
+	return (*context->iOrigWalkFn)(aHelper, context->iOrigContext, New2Old(aCellType), aCellPtr, aCellLength);
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::Walk(TWalkFunc aCallbackFn, TAny* aContext)
+	{
+	// For backwards compatability insert a compatability callback to map between the different types of callback that clients requested
+	SContext context = { aCallbackFn, aContext };
+	return Walk(&DispatchOldTWalkFuncCallback, &context);
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::Walk(TWalkFunc2 aCallbackFn, TAny* aContext)
+	{
+	SContext2 context = { aCallbackFn, aContext };
+	return Walk(&DispatchOldTWalk2FuncCallback, &context);
+	}
+
+
+TInt RAllocatorHelper::OldSkoolWalk(TWalkFunc3 aCallbackFn, TAny* aContext)
+	{
+	TLinAddr pC = 0;
+	TInt err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iBase), pC); // pC = iBase; // allocated cells
+	if (err) return err;
+	TLinAddr pF = iAllocatorAddress + _FOFF(RHackHeap, iAlign) + 3*4; // pF = &iFree; // free cells
+
+	TLinAddr top = 0;
+	err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iTop), top);
+	if (err) return err;
+	const TInt KAllocatedCellHeaderSize = iAllocatorType == EUdebOldRHeap ? 12 : 4;
+	TInt minCell = 0;
+	err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iAlign) + 4, (TUint32&)minCell);
+	if (err) return err;
+	TInt align = 0;
+	err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iAlign), (TUint32&)align);
+	if (err) return err;
+
+	FOREVER
+		{
+		err = ReadWord(pF+4, pF); // pF = pF->next; // next free cell
+		if (err) return err;
+		TLinAddr pFnext = 0;
+		if (pF) err = ReadWord(pF + 4, pFnext);
+		if (err) return err;
+
+		if (!pF)
+			{
+			pF = top; // to make size checking work
+			}
+		else if (pF>=top || (pFnext && pFnext<=pF) )
+			{
+			// free cell pointer off the end or going backwards
+			//Unlock();
+			(*aCallbackFn)(*this, aContext, EHeapBadFreeCellAddress, pF, 0);
+			return KErrCorrupt;
+			}
+		else
+			{
+			TInt l; // = pF->len
+			err = ReadWord(pF, (TUint32&)l);
+			if (err) return err;
+			if (l<minCell || (l & (align-1)))
+				{
+				// free cell length invalid
+				//Unlock();
+				(*aCallbackFn)(*this, aContext, EHeapBadFreeCellSize, pF, l);
+				return KErrCorrupt;
+				}
+			}
+		
+		while (pC!=pF)				// walk allocated cells up to next free cell
+			{
+			TInt l; // pC->len;
+			err = ReadWord(pC, (TUint32&)l);
+			if (err) return err;
+			if (l<minCell || (l & (align-1)))
+				{
+				// allocated cell length invalid
+				//Unlock();
+				(*aCallbackFn)(*this, aContext, EHeapBadAllocatedCellSize, pC, l);
+				return KErrCorrupt;
+				}
+			TBool shouldContinue = (*aCallbackFn)(*this, aContext, EHeapAllocation, pC + KAllocatedCellHeaderSize, l - KAllocatedCellHeaderSize);
+			if (!shouldContinue) return KErrNone;
+			
+			//SCell* pN = __NEXT_CELL(pC);
+			TLinAddr pN = pC + l;
+			if (pN > pF)
+				{
+				// cell overlaps next free cell
+				//Unlock();
+				(*aCallbackFn)(*this, aContext, EHeapBadAllocatedCellAddress, pC, l);
+				return KErrCorrupt;
+				}
+			pC = pN;
+			}
+		if (pF == top)
+			break;		// reached end of heap
+		TInt pFlen = 0;
+		err = ReadWord(pF, (TUint32&)pFlen);
+		if (err) return err;
+		pC = pF + pFlen; // pC = __NEXT_CELL(pF);	// step to next allocated cell
+		TBool shouldContinue = (*aCallbackFn)(*this, aContext, EHeapFreeCell, pF, pFlen);
+		if (!shouldContinue) return KErrNone;
+		}
+	return KErrNone;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::CountUnusedPages()
+	{
+	TInt err = CheckValid(EUnusedPages);
+	if (err) return err;
+	return iInfo->iUnusedPages;
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::CommittedFreeSpace()
+	{
+	TInt err = CheckValid(ECommittedFreeSpace);
+	if (err) return err;
+	return iInfo->iCommittedFreeSpace;
+	}
+
+#define ROUND_DOWN(val, pow2) ((val) & ~((pow2)-1))
+#define ROUND_UP(val, pow2) ROUND_DOWN((val) + (pow2) - 1, (pow2))
+
+HUEXPORT_C TLinAddr RAllocatorHelper::AllocatorAddress() const
+	{
+	return iAllocatorAddress;
+	}
+
+TBool RAllocatorHelper::WalkForStats(RAllocatorHelper& aSelf, TAny* /*aContext*/, TExtendedCellType aType, TLinAddr aCellPtr, TInt aCellLength)
+	{
+	//ASSERT(aCellLength >= 0);
+	THeapInfo& info = *aSelf.iInfo;
+
+	TInt pagesSpanned = 0; // The number of pages that fit entirely inside the payload of this cell
+	if ((TUint)aCellLength > KPageSize)
+		{
+		TLinAddr nextPageAlignedAddr = ROUND_UP(aCellPtr, KPageSize);
+		pagesSpanned = ROUND_DOWN(aCellPtr + aCellLength - nextPageAlignedAddr, KPageSize) / KPageSize;
+		}
+
+	if (aSelf.iAllocatorType == EUrelOldRHeap || aSelf.iAllocatorType == EUdebOldRHeap)
+		{
+		if (aType & EFreeMask)
+			{
+			info.iUnusedPages += pagesSpanned;
+			info.iCommittedFreeSpace += aCellLength;
+			info.iHeapFreeCellCount++;
+			}
+		}
+	else
+		{
+		if (aType & EAllocationMask)
+			{
+			info.iAllocatedSize += aCellLength;
+			info.iAllocationCount++;
+			}
+		else if (aType & EFreeMask)
+			{
+			// I *think* that DLA will decommit pages from inside free cells...
+			TInt committedLen = aCellLength - (pagesSpanned * KPageSize);
+			info.iCommittedFreeSpace += committedLen;
+			}
+
+		switch (aType)
+			{
+			case EDlaAllocation:
+				info.iDlaAllocsSize += aCellLength;
+				info.iDlaAllocsCount++;
+				break;
+			case EPageAllocation:
+				info.iPageAllocsSize += aCellLength;
+				info.iPageAllocsCount++;
+				break;
+			case ESlabAllocation:
+				info.iSlabAllocsSize += aCellLength;
+				info.iSlabAllocsCount++;
+				break;
+			case EDlaFreeCell:
+				info.iDlaFreeSize += aCellLength;
+				info.iDlaFreeCount++;
+				break;
+			case ESlabFreeCell:
+				info.iSlabFreeCellSize += aCellLength;
+				info.iSlabFreeCellCount++;
+				break;
+			case ESlabFreeSlab:
+				info.iSlabFreeSlabSize += aCellLength;
+				info.iSlabFreeSlabCount++;
+				break;
+			default:
+				break;
+			}
+		}
+
+	return ETrue;
+	}
+
+#define PAGESHIFT 12
+
+TUint RAllocatorHelper::PageMapOperatorBrackets(unsigned ix, TInt& err) const
+	{
+	//return 1U&(iBase[ix>>3] >> (ix&7));
+	TUint32 basePtr = 0;
+	err = ReadWord(iAllocatorAddress + KPageMapOffset, basePtr);
+	if (err) return 0;
+
+	TUint8 res = 0;
+	err = ReadByte(basePtr + (ix >> 3), res);
+	if (err) return 0;
+
+	return 1U&(res >> (ix&7));
+	}
+
+
+TInt RAllocatorHelper::PageMapFind(TUint start, TUint bit, TInt& err)
+	{
+	TUint32 iNbits = 0;
+	err = ReadWord(iAllocatorAddress + KPageMapOffset + 4, iNbits);
+	if (err) return 0;
+
+	if (start<iNbits) do
+		{
+		//if ((*this)[start]==bit)
+		if (PageMapOperatorBrackets(start, err) == bit || err)
+			return start;
+		} while (++start<iNbits);
+	return -1;
+	}
+
+TUint RAllocatorHelper::PagedDecode(TUint pos, TInt& err)
+	{
+	unsigned bits = PageMapBits(pos,2,err);
+	if (err) return 0;
+	bits >>= 1;
+	if (bits == 0)
+		return 1;
+	bits = PageMapBits(pos+2,2,err);
+	if (err) return 0;
+	if ((bits & 1) == 0)
+		return 2 + (bits>>1);
+	else if ((bits>>1) == 0)
+		{
+		return PageMapBits(pos+4, 4,err);
+		}
+	else
+		{
+		return PageMapBits(pos+4, 18,err);
+		}
+	}
+
+TUint RAllocatorHelper::PageMapBits(unsigned ix, unsigned len, TInt& err)
+	{
+	int l=len;
+	unsigned val=0;
+	unsigned bit=0;
+	while (--l>=0)
+		{
+		//val |= (*this)[ix++]<<bit++;
+		val |= PageMapOperatorBrackets(ix++, err) << bit++;
+		if (err) return 0;
+		}
+	return val;
+	}
+
+enum TSlabType { ESlabFullInfo, ESlabPartialInfo, ESlabEmptyInfo };
+
+#ifndef TEST_HYBRIDHEAP_ASSERTS
+#define MAXSLABSIZE		56
+#define	SLABSHIFT		10
+#define	SLABSIZE		(1 << SLABSHIFT)
+const TInt KMaxSlabPayload = SLABSIZE - KSlabPayloadOffset;
+#endif
+
+TInt RAllocatorHelper::NewHotnessWalk(TWalkFunc3 aCallbackFn, TAny* aContext)
+	{
+	// RHybridHeap does paged, slab then DLA, so that's what we do too
+	// Remember Kernel RHybridHeaps don't even have the page and slab members
+
+	TUint32 basePtr;
+	TInt err = ReadWord(iAllocatorAddress + _FOFF(RHackHeap, iBase), basePtr);
+	if (err) return err;
+	if (basePtr < iAllocatorAddress + KUserHybridHeapSize)
+		{
+		// Must be a kernel one - don't do page and slab
+		}
+	else
+		{
+		// Paged
+		TUint32 membase = 0;
+		err = ReadWord(iAllocatorAddress + KPageMapOffset + 8, membase);
+		if (err) return err;
+
+		TBool shouldContinue = ETrue;
+		for (int ix = 0;(ix = PageMapFind(ix,1,err)) >= 0 && err == KErrNone;)
+			{
+			int npage = PagedDecode(ix, err);
+			if (err) return err;
+			// Introduce paged buffer to the walk function 
+			TLinAddr bfr = membase + (1 << (PAGESHIFT-1))*ix;
+			int len = npage << PAGESHIFT;
+			if ( (TUint)len > KPageSize )
+				{ // If buffer is not larger than one page it must be a slab page mapped into bitmap
+				if (iAllocatorType == EUdebHybridHeap)
+					{
+					bfr += 8;
+					len -= 8;
+					}
+				shouldContinue = (*aCallbackFn)(*this, aContext, EPageAllocation, bfr, len);
+				if (!shouldContinue) return KErrNone;
+				}
+			ix += (npage<<1);
+			}
+		if (err) return err;
+
+		// Slab
+		TUint32 sparePage = 0;
+		err = ReadWord(iAllocatorAddress + KSparePageOffset, sparePage);
+		if (err) return err;
+		if (sparePage)
+			{
+			//Walk(wi, iSparePage, iPageSize, EGoodFreeCell, ESlabSpare); // Introduce Slab spare page to the walk function 
+			// This counts as 4 spare slabs
+			for (TInt i = 0; i < 4; i++)
+				{
+				shouldContinue = (*aCallbackFn)(*this, aContext, ESlabFreeSlab, sparePage + SLABSIZE*i, SLABSIZE);
+				if (!shouldContinue) return KErrNone;
+				}
+			}
+
+		//TreeWalk(&iFullSlab, &SlabFullInfo, i, wi);
+		TInt err = TreeWalk(iAllocatorAddress + KFullSlabOffset, ESlabFullInfo, aCallbackFn, aContext, shouldContinue);
+		if (err || !shouldContinue) return err;
+		for (int ix = 0; ix < (MAXSLABSIZE>>2); ++ix)
+			{
+			TUint32 partialAddr = iAllocatorAddress + KSlabAllocOffset + ix*KSlabsetSize;
+			//TreeWalk(&iSlabAlloc[ix].iPartial, &SlabPartialInfo, i, wi);
+			err = TreeWalk(partialAddr, ESlabPartialInfo, aCallbackFn, aContext, shouldContinue);
+			if (err || !shouldContinue) return err;
+			}
+		//TreeWalk(&iPartialPage, &SlabEmptyInfo, i, wi);
+		TreeWalk(iAllocatorAddress + KPartialPageOffset, ESlabEmptyInfo, aCallbackFn, aContext, shouldContinue);
+		}
+
+	// DLA
+#define CHUNK_OVERHEAD (sizeof(TUint))
+#define CHUNK_ALIGN_MASK (7) 
+#define CHUNK2MEM(p)        ((TLinAddr)(p) + 8)
+#define MEM2CHUNK(mem)      ((TLinAddr)(p) - 8)
+/* chunk associated with aligned address A */
+#define ALIGN_OFFSET(A)\
+	((((TLinAddr)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\
+	((8 - ((TLinAddr)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK))
+#define ALIGN_AS_CHUNK(A)   ((A) + ALIGN_OFFSET(CHUNK2MEM(A)))
+#define CINUSE_BIT 2
+#define INUSE_BITS 3
+
+	TUint32 topSize = 0;
+	err = ReadWord(iAllocatorAddress + KMallocStateOffset + KMallocStateTopSizeOffset, topSize);
+	if (err) return err;
+
+	TUint32 top = 0;
+	err = ReadWord(iAllocatorAddress + KMallocStateOffset + KMallocStateTopOffset, top);
+	if (err) return err;
+
+	TInt max = ((topSize-1) & ~CHUNK_ALIGN_MASK) - CHUNK_OVERHEAD;
+	if ( max < 0 )
+		max = 0;
+	
+	TBool shouldContinue = (*aCallbackFn)(*this, aContext, EDlaFreeCell, top, max);
+	if (!shouldContinue) return KErrNone;
+	
+	TUint32 mallocStateSegBase = 0;
+	err = ReadWord(iAllocatorAddress + KMallocStateOffset + KMallocStateSegOffset, mallocStateSegBase);
+	if (err) return err;
+
+	for (TLinAddr q = ALIGN_AS_CHUNK(mallocStateSegBase); q != top; /*q = NEXT_CHUNK(q)*/)
+		{
+		TUint32 qhead = 0;
+		err = ReadWord(q + 4, qhead);
+		if (err) return err;
+		//TInt sz = CHUNKSIZE(q);
+		TInt sz = qhead & ~(INUSE_BITS);
+		if (!(qhead & CINUSE_BIT))
+			{
+			//Walk(wi, CHUNK2MEM(q), sz, EGoodFreeCell, EDougLeaAllocator); // Introduce DL free buffer to the walk function 
+			shouldContinue = (*aCallbackFn)(*this, aContext, EDlaFreeCell, CHUNK2MEM(q), sz);
+			if (!shouldContinue) return KErrNone;
+			}
+		else
+			{
+			//Walk(wi, CHUNK2MEM(q), (sz- CHUNK_OVERHEAD), EGoodAllocatedCell, EDougLeaAllocator); // Introduce DL allocated buffer to the walk function 
+			TLinAddr addr = CHUNK2MEM(q);
+			TInt size = sz - CHUNK_OVERHEAD;
+			if (iAllocatorType == EUdebHybridHeap)
+				{
+				size -= 8;
+				addr += 8;
+				}
+			shouldContinue = (*aCallbackFn)(*this, aContext, EDlaAllocation, addr, size);
+			if (!shouldContinue) return KErrNone;
+			}
+		// This is q = NEXT_CHUNK(q) expanded
+		q = q + sz;
+		}
+	return KErrNone;
+	}
+
+TInt RAllocatorHelper::TreeWalk(TUint32 aSlabRoot, TInt aSlabType, TWalkFunc3 aCallbackFn, TAny* aContext, TBool& shouldContinue)
+	{
+	const TSlabType type = (TSlabType)aSlabType;
+
+	TUint32 s = 0;
+	TInt err = ReadWord(aSlabRoot, s);
+	if (err) return err;
+	//slab* s = *root;
+	if (!s)
+		return KErrNone;
+	
+	for (;;)
+		{
+		//slab* c;
+		//while ((c = s->iChild1) != 0)
+		//	s = c;		// walk down left side to end
+		TUint32 c;
+		for(;;)
+			{
+			err = ReadWord(s + KSlabChild1Offset, c);
+			if (err) return err;
+			if (c == 0) break;
+			else s = c;
+			}
+		for (;;)
+			{
+			//TODOf(s, i, wi);
+			//TODO __HEAP_CORRUPTED_TEST_STATIC
+			TUint32 h;
+			err = ReadWord(s, h); // = aSlab->iHeader;
+			if (err) return err;
+			TUint32 size = (h&0x0003f000)>>12; //SlabHeaderSize(h);
+			TUint debugheadersize = 0;
+			if (iAllocatorType == EUdebHybridHeap) debugheadersize = 8;
+			TUint32 usedCount = (((h&0x0ffc0000)>>18) + 4) / size; // (SlabHeaderUsedm4(h) + 4) / size;
+			switch (type)
+				{
+				case ESlabFullInfo:
+					{
+					TUint32 count = usedCount;
+					TUint32 i = 0;
+					while ( i < count )
+						{
+						TUint32 addr = s + KSlabPayloadOffset + i*size; //&aSlab->iPayload[i*size];
+						shouldContinue = (*aCallbackFn)(*this, aContext, ESlabAllocation, addr + debugheadersize, size - debugheadersize);
+						if (!shouldContinue) return KErrNone;
+						i++;
+						}
+					break;
+					}
+				case ESlabPartialInfo:
+					{
+					//TODO __HEAP_CORRUPTED_TEST_STATIC
+					TUint32 count = KMaxSlabPayload / size;
+					TUint32 freeOffset = (h & 0xff) << 2;
+					if (freeOffset == 0)
+						{
+						// TODO Shouldn't happen for a slab on the partial list
+						}
+					memset(iTempSlabBitmap, 1, KTempBitmapSize); // Everything defaults to in use
+					TUint wildernessCount = count - usedCount;
+					while (freeOffset)
+						{
+						wildernessCount--;
+						TInt idx = (freeOffset-KSlabPayloadOffset)/size;
+						LOG("iTempSlabBitmap freeOffset %d index %d", freeOffset, idx);
+						iTempSlabBitmap[idx] = 0; // Mark it as free
+
+						TUint32 addr = s + freeOffset;
+						TUint8 nextCell = 0;
+						err = ReadByte(addr, nextCell);
+						if (err) return err;
+						freeOffset = ((TUint32)nextCell) << 2;
+						}
+					memset(iTempSlabBitmap + count - wildernessCount, 0, wildernessCount); // Mark the wilderness as free
+					for (TInt i = 0; i < count; i++)
+						{
+						TLinAddr addr = s + KSlabPayloadOffset + i*size;
+						if (iTempSlabBitmap[i])
+							{
+							// In use
+							shouldContinue = (*aCallbackFn)(*this, aContext, ESlabAllocation, addr + debugheadersize, size - debugheadersize);
+							}
+						else
+							{
+							// Free
+							shouldContinue = (*aCallbackFn)(*this, aContext, ESlabFreeCell, addr, size);
+							}
+						if (!shouldContinue) return KErrNone;
+						}
+					break;
+					}
+				case ESlabEmptyInfo:
+					{
+					// Check which slabs of this page are empty
+					TUint32 pageAddr = ROUND_DOWN(s, KPageSize);
+					TUint32 headerForPage = 0;
+					err = ReadWord(pageAddr, headerForPage);
+					if (err) return err;
+					TUint32 slabHeaderPageMap = (headerForPage & 0x00000f00)>>8; // SlabHeaderPagemap(unsigned h)
+					for (TInt slabIdx = 0; slabIdx < 4; slabIdx++)
+						{
+						if (slabHeaderPageMap & (1<<slabIdx))
+							{
+							TUint32 addr = pageAddr + SLABSIZE*slabIdx + KSlabPayloadOffset; //&aSlab->iPayload[i*size];
+							shouldContinue = (*aCallbackFn)(*this, aContext, ESlabFreeSlab, addr, KMaxSlabPayload);
+							if (!shouldContinue) return KErrNone;
+							}
+						}
+					break;
+					}
+				}
+
+			//c = s->iChild2;
+			err = ReadWord(s + KSlabChild2Offset, c);
+			if (err) return err;
+
+			if (c)
+				{	// one step down right side, now try and walk down left
+				s = c;
+				break;
+				}
+			for (;;)
+				{	// loop to walk up right side
+				TUint32 pp = 0;
+				err = ReadWord(s + KSlabParentOffset, pp);
+				if (err) return err;
+				//slab** pp = s->iParent;
+				if (pp == aSlabRoot)
+					return KErrNone;
+#define SlabFor(x) ROUND_DOWN(x, SLABSIZE)
+				s = SlabFor(pp);
+				//if (pp == &s->iChild1)
+				if (pp == s + KSlabChild1Offset)
+					break;
+				}
+			}
+		}
+	}
+
+// Really should be called TotalSizeForCellType(...)
+HUEXPORT_C TInt RAllocatorHelper::SizeForCellType(TExtendedCellType aType)
+	{
+	if (aType & EBadnessMask) return KErrArgument;
+	if (aType == EAllocationMask) return AllocatedSize();
+
+	if (iAllocatorType == EUdebOldRHeap || iAllocatorType == EUrelOldRHeap)
+		{
+		switch (aType)
+			{
+			case EHeapAllocation:
+				return AllocatedSize();
+			case EHeapFreeCell:
+			case EFreeMask:
+				return CommittedFreeSpace();
+			default:
+				return KErrNotSupported;
+			}
+		}
+	else if (iAllocatorType == EUrelHybridHeap || iAllocatorType == EUdebHybridHeap)
+		{
+		TInt err = CheckValid(EHybridStats);
+		if (err) return err;
+
+		switch (aType)
+			{
+			case EHeapAllocation:
+			case EHeapFreeCell:
+				return KErrNotSupported;
+			case EDlaAllocation:
+				return iInfo->iDlaAllocsSize;
+			case EPageAllocation:
+				return iInfo->iPageAllocsSize;
+			case ESlabAllocation:
+				return iInfo->iSlabAllocsSize;
+			case EDlaFreeCell:
+				return iInfo->iDlaFreeSize;
+			case ESlabFreeCell:
+				return iInfo->iSlabFreeCellSize;
+			case ESlabFreeSlab:
+				return iInfo->iSlabFreeSlabSize;
+			case EFreeMask:
+				// Note this isn't the same as asking for CommittedFreeSpace(). SizeForCellType(EFreeMask) may include decommitted pages that lie inside a free cell
+				return iInfo->iDlaFreeSize + iInfo->iSlabFreeCellSize + iInfo->iSlabFreeSlabSize;
+			default:
+				return KErrNotSupported;
+			}
+		}
+	else
+		{
+		return KErrNotSupported;
+		}
+	}
+
+HUEXPORT_C TInt RAllocatorHelper::CountForCellType(TExtendedCellType aType)
+	{
+	if (aType & EBadnessMask) return KErrArgument;
+	if (aType == EAllocationMask) return AllocationCount();
+
+	if (iAllocatorType == EUdebOldRHeap || iAllocatorType == EUrelOldRHeap)
+		{
+		switch (aType)
+			{
+			case EHeapAllocation:
+				return AllocationCount();
+			case EHeapFreeCell:
+			case EFreeMask:
+				{
+				TInt err = CheckValid(ECommittedFreeSpace);
+				if (err) return err;
+				return iInfo->iHeapFreeCellCount;
+				}
+			default:
+				return KErrNotSupported;
+			}
+		}
+	else if (iAllocatorType == EUrelHybridHeap || iAllocatorType == EUdebHybridHeap)
+		{
+		TInt err = CheckValid(EHybridStats);
+		if (err) return err;
+
+		switch (aType)
+			{
+			case EHeapAllocation:
+			case EHeapFreeCell:
+				return KErrNotSupported;
+			case EDlaAllocation:
+				return iInfo->iDlaAllocsCount;
+			case EPageAllocation:
+				return iInfo->iPageAllocsCount;
+			case ESlabAllocation:
+				return iInfo->iSlabAllocsCount;
+			case EDlaFreeCell:
+				return iInfo->iDlaFreeCount;
+			case ESlabFreeCell:
+				return iInfo->iSlabFreeCellCount;
+			case ESlabFreeSlab:
+				return iInfo->iSlabFreeSlabCount;
+			case EFreeMask:
+				// This isn't a hugely meaningful value, but if that's what they asked for...
+				return iInfo->iDlaFreeCount + iInfo->iSlabFreeCellCount + iInfo->iSlabFreeSlabCount;
+			default:
+				return KErrNotSupported;
+			}
+		}
+	else
+		{
+		return KErrNotSupported;
+		}
+	}
+
+HUEXPORT_C TBool LtkUtils::RAllocatorHelper::AllocatorIsUdeb() const
+	{
+	return iAllocatorType == EUdebOldRHeap || iAllocatorType == EUdebHybridHeap;
+	}
+
+
+HUEXPORT_C const TDesC& LtkUtils::RAllocatorHelper::Description() const
+	{
+	_LIT(KRHeap, "RHeap");
+	_LIT(KRHybridHeap, "RHybridHeap");
+	_LIT(KUnknown, "Unknown");
+	switch (iAllocatorType)
+		{
+		case EUrelOldRHeap:
+		case EUdebOldRHeap:
+			return KRHeap;
+		case EUrelHybridHeap:
+		case EUdebHybridHeap:
+			return KRHybridHeap;
+		case EAllocator:
+		case EUnknown:
+		default:
+			return KUnknown;
+		}
+	}
+
+#ifdef __KERNEL_MODE__
+
+DChunk* LtkUtils::RAllocatorHelper::OpenUnderlyingChunk()
+	{
+	// Enter and leave in CS and with no locks held. On exit the returned DChunk has been Open()ed.
+	TInt err = iChunk->Open();
+	if (err) return NULL;
+	return iChunk;
+	}
+
+DChunk* LtkUtils::RKernelSideAllocatorHelper::OpenUnderlyingChunk()
+	{
+	if (iAllocatorType != EUrelOldRHeap && iAllocatorType != EUdebOldRHeap && iAllocatorType != EUrelHybridHeap && iAllocatorType != EUdebHybridHeap) return NULL;
+	// Note RKernelSideAllocatorHelper doesn't use or access RAllocatorHelper::iChunk, because we figure out the chunk handle in a different way.
+	// It is for this reason that iChunk is private, to remove temptation
+	
+	// Enter and leave in CS and with no locks held. On exit the returned DChunk has been Open()ed.
+	TUint32 chunkHandle = 0;
+	TInt err = ReadData(iAllocatorAddress + _FOFF(RHackHeap, iChunkHandle), &chunkHandle, sizeof(TUint32));
+	if (err) return NULL;
+
+	NKern::LockSystem();
+	DChunk* result = (DChunk*)Kern::ObjectFromHandle(iThread, chunkHandle, EChunk);
+	if (result && result->Open() != KErrNone)
+		{
+		result = NULL;
+		}
+	NKern::UnlockSystem();
+	return result;
+	}
+
+LtkUtils::RAllocatorHelper::TType LtkUtils::RAllocatorHelper::GetType() const
+	{
+	switch (iAllocatorType)
+		{
+		case EUrelOldRHeap:
+		case EUdebOldRHeap:
+			return ETypeRHeap;
+		case EUrelHybridHeap:
+		case EUdebHybridHeap:
+			return ETypeRHybridHeap;
+		case EAllocator:
+		case EUnknown:
+		default:
+			return ETypeUnknown;
+		}
+	}
+
+#else
+
+TInt LtkUtils::RAllocatorHelper::EuserIsUdeb()
+	{
+	TAny* buf = User::Alloc(4096);
+	if (!buf) return KErrNoMemory;
+	RAllocator* dummyHeap = UserHeap::FixedHeap(buf, 4096, 4, ETrue);
+	if (!dummyHeap) return KErrNoMemory; // Don't think this can happen
+
+	dummyHeap->__DbgSetAllocFail(RAllocator::EFailNext, 1);
+	TAny* ptr = dummyHeap->Alloc(4);
+	// Because we specified singleThreaded=ETrue we can allow dummyHeap to just go out of scope here
+	User::Free(buf);
+
+	if (ptr)
+		{
+		// Clearly the __DbgSetAllocFail had no effect so we must be urel
+		// We don't need to free ptr because it came from the dummy heap
+		return EFalse;
+		}
+	else
+		{
+		return ETrue;
+		}
+	}
+
+#ifndef STANDALONE_ALLOCHELPER
+
+#include <fshell/ltkutils.h>
+HUEXPORT_C void LtkUtils::MakeHeapCellInvisible(TAny* aCell)
+	{
+	RAllocatorHelper helper;
+	TInt err = helper.Open(&User::Allocator());
+	if (err == KErrNone)
+		{
+		helper.SetCellNestingLevel(aCell, -1);
+		helper.Close();
+		}
+	}
+#endif // STANDALONE_ALLOCHELPER
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/Driver/Shared/heaputils.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,216 @@
+// heaputils.h
+// 
+// Copyright (c) 2010 Accenture. All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of the "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:
+// Accenture - Initial contribution
+//
+
+
+#ifndef FSHELL_HEAP_UTILS_H
+#define FSHELL_HEAP_UTILS_H
+
+#include <e32cmn.h>
+
+#ifdef __KERNEL_MODE__
+class DThread;
+class DChunk;
+#else
+class RMemoryAccess;
+#endif // __KERNEL_MODE__
+
+#if defined(STANDALONE_ALLOCHELPER) || defined(__KERNEL_MODE__)
+#define HUIMPORT_C
+#define HUCLASS(x) NONSHARABLE_CLASS(x)
+#else
+#define HUIMPORT_C IMPORT_C
+#define HUCLASS(x) class x
+#endif
+
+namespace LtkUtils
+	{
+
+class THeapInfo;
+	
+HUCLASS(RAllocatorHelper) // class RAllocatorHelper
+	{
+public:
+	HUIMPORT_C RAllocatorHelper();
+#ifdef __KERNEL_MODE__
+	TInt OpenKernelHeap();
+#else
+	HUIMPORT_C TInt Open(RAllocator* aAllocator);
+#endif
+	HUIMPORT_C TInt SetCellNestingLevel(TAny* aCell, TInt aNestingLevel);
+	HUIMPORT_C TInt GetCellNestingLevel(TAny* aCell, TInt& aNestingLevel);
+	HUIMPORT_C TInt AllocCountForCell(TAny* aCell) const;
+	HUIMPORT_C TLinAddr AllocatorAddress() const;
+	HUIMPORT_C TInt RefreshDetails();
+	
+	HUIMPORT_C TInt CommittedSize();
+	HUIMPORT_C TInt AllocatedSize();
+	HUIMPORT_C TInt AllocationCount();
+	HUIMPORT_C TInt MaxCommittedSize();
+	HUIMPORT_C TInt MinCommittedSize();
+	HUIMPORT_C TInt CountUnusedPages();
+	HUIMPORT_C TInt CommittedFreeSpace();
+
+	enum TCellType
+		{
+		EAllocation, EFreeSpace, EBadness
+		};
+
+	enum TExtendedCellType
+		{
+		EAllocationMask = 0xFF,
+		EFreeMask = 0xFF00,
+		EBadnessMask = 0xFF000000,
+
+		EHeapAllocation = 1,
+		EDlaAllocation = 2,
+		EPageAllocation = 3,
+		ESlabAllocation = 4,
+		
+		EHeapFreeCell = 0x0100,
+		EDlaFreeCell = 0x0200,
+		// There is nothing 'free' in the page allocator
+		ESlabFreeCell = 0x0300, // Used to track free cells in partially-filled slabs
+		ESlabFreeSlab = 0x0400, // Used to track entirely empty slabs (that don't have a specific cell size)
+
+		EHeapBadFreeCellAddress = 0x01000000,
+		EHeapBadFreeCellSize = 0x02000000,
+		EHeapBadAllocatedCellSize = 0x03000000,
+		EHeapBadAllocatedCellAddress = 0x04000000,
+		};
+			
+	// TBool WalkFunc(TAny* aContext, TCellType aCellType, TLinAddr aCellPtr, TInt aCellLength)
+	// aCellPtr points to the start of the cell payload for allocated cells (unlike RHeap's walker, which points to the cell header)
+	// aCellLength is the payload length, ie what AllocLen(aCellPtr) would return
+	// return ETrue to continue walking, EFalse to stop the walk
+	typedef TBool (*TWalkFunc)(TAny*, TCellType, TLinAddr, TInt);
+	typedef TBool (*TWalkFunc2)(RAllocatorHelper&, TAny*, TCellType, TLinAddr, TInt);
+	typedef TBool (*TWalkFunc3)(RAllocatorHelper&, TAny*, TExtendedCellType, TLinAddr, TInt);
+	HUIMPORT_C TInt Walk(TWalkFunc aCallbackFn, TAny* aContext);
+	HUIMPORT_C TInt Walk(TWalkFunc2 aCallbackFn, TAny* aContext); // Like the other but the walk func gives you the RAllocatorHelper pointer too
+	HUIMPORT_C TInt Walk(TWalkFunc3 aCallbackFn, TAny* aContext); // Like the other but the walk func gives you more details about the allocation type
+	HUIMPORT_C TInt SizeForCellType(TExtendedCellType aType);
+	HUIMPORT_C TInt CountForCellType(TExtendedCellType aType);
+	HUIMPORT_C TBool AllocatorIsUdeb() const;
+	HUIMPORT_C const TDesC& Description() const;
+	HUIMPORT_C virtual void Close();
+
+#ifdef __KERNEL_MODE__
+	virtual DChunk* OpenUnderlyingChunk(); // Must be in CS
+	enum TType
+		{
+		ETypeUnknown,
+		ETypeRHeap,
+		ETypeRHybridHeap,
+		};
+	TType GetType() const; // This is for information only, nothing should care about the return value
+#endif
+
+protected:
+	TInt FinishConstruction();
+	TInt IdentifyAllocatorType(TBool aAllocatorIsUdeb, TBool aIsTheKernelHeap=EFalse);
+	TInt OpenChunkHeap(TLinAddr aChunkBase, TInt aChunkMaxSize);
+#ifndef __KERNEL_MODE__
+	static TInt EuserIsUdeb();
+#endif
+	virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
+	virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
+	virtual TInt TryLock();
+	virtual void TryUnlock();
+
+private:
+	TInt ReadWord(TLinAddr aLocation, TUint32& aResult) const;
+	TInt ReadByte(TLinAddr aLocation, TUint8& aResult) const;
+	TInt WriteWord(TLinAddr aLocation, TUint32 aWord);
+	TInt RefreshDetails(TUint aMask);
+	TInt DoRefreshDetails(TUint aMask);
+	TInt CheckValid(TUint aMask);
+	TInt DoWalk(TWalkFunc3 aCallbackFn, TAny* aContext);
+	TInt OldSkoolWalk(TWalkFunc3 aCallbackFn, TAny* aContext);
+	TInt NewHotnessWalk(TWalkFunc3 aCallbackFn, TAny* aContext);
+	static TBool DispatchClientWalkCallback(RAllocatorHelper& aHelper, TAny* aContext, TExtendedCellType aCellType, TLinAddr aCellPtr, TInt aCellLength);
+	static TBool WalkForStats(RAllocatorHelper& aSelf, TAny* aContext, TExtendedCellType aType, TLinAddr aCellPtr, TInt aCellLength);
+	TUint PageMapOperatorBrackets(unsigned ix, TInt& err) const;
+	TInt PageMapFind(TUint start, TUint bit, TInt& err);
+	TUint PageMapBits(unsigned ix, unsigned len, TInt& err);
+	TUint PagedDecode(TUint pos, TInt& err);
+	TInt TreeWalk(TUint32 aSlabRoot, TInt aSlabType, TWalkFunc3 aCallbackFn, TAny* aContext, TBool& shouldContinue);
+protected:
+	TLinAddr iAllocatorAddress;
+	enum TAllocatorType
+		{
+		EUnknown,
+		EAllocator,
+		EUrelOldRHeap,
+		EUdebOldRHeap,
+		EUrelHybridHeap,
+		EUdebHybridHeap,
+		};
+	TAllocatorType iAllocatorType;
+private:
+	THeapInfo* iInfo;
+	TUint iValidInfo;
+	TUint8* iTempSlabBitmap;
+	mutable TAny* iPageCache;
+	mutable TLinAddr iPageCacheAddr;
+#ifdef __KERNEL_MODE__
+	DChunk* iChunk;
+	//TUint iSpare[0];
+#else
+	TUint iSpare[1];
+#endif
+	};
+
+#ifdef __KERNEL_MODE__
+
+class RKernelSideAllocatorHelper : public RAllocatorHelper
+	{
+public:
+	RKernelSideAllocatorHelper();
+	TInt OpenUserHeap(TUint aThreadId, TLinAddr aAllocatorAddress, TBool aEuserIsUdeb);
+	virtual DChunk* OpenUnderlyingChunk(); // Must be in CS
+	virtual void Close();
+
+protected:
+	virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
+	virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
+	virtual TInt TryLock();
+	virtual void TryUnlock();
+private:
+	DThread* iThread;
+	};
+
+#else
+
+class RProxyAllocatorHelper : public RAllocatorHelper
+	{
+public:
+	HUIMPORT_C RProxyAllocatorHelper();
+	HUIMPORT_C TInt Open(RMemoryAccess& aMem, TUint aThreadId);
+	HUIMPORT_C TInt OpenChunkHeap(RMemoryAccess& aMem, TAny* aDChunkPtr);
+	HUIMPORT_C virtual void Close();
+
+protected:
+	virtual TInt ReadData(TLinAddr aLocation, TAny* aResult, TInt aSize) const;
+	virtual TInt WriteData(TLinAddr aLocation, const TAny* aData, TInt aSize);
+	virtual TInt TryLock();
+	virtual void TryUnlock();
+
+private:
+	RMemoryAccess* iMemoryAccess;
+	TUint iThreadId;
+	};
+
+#endif // __KERNEL_MODE__
+
+	} // namespace LtkUtils
+
+#endif
--- a/memspy/Driver/User/Include/RBuildQueryableHeap.h	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
-* 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:
-*
-*/
-
-#ifndef RBUILDQUERYABLEHEAP_H
-#define RBUILDQUERYABLEHEAP_H
-
-// System includes
-#include <e32cmn.h>
-
-// User includes
-#include <memspy/driver/memspydriverenumerationsshared.h>
-
-
-class RBuildQueryableHeap : public RHeap
-    {
-public: // API
-    TBool IsDebugEUser() const;
-    TInt CellHeaderSize( TMemSpyDriverCellType aType ) const;
-    };
-
-
-
-#endif
--- a/memspy/Driver/User/Source/MemSpyDriverClient.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/User/Source/MemSpyDriverClient.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -22,11 +22,11 @@
 
 // User includes
 #include "MemSpyDriverOpCodes.h"
-#include "RBuildQueryableHeap.h"
 #include <memspy/driver/memspydriverconstants.h>
 #include <memspy/driver/memspydriverobjectsshared.h>
 #include "MemSpyDriverStreamReaderImp.h"
 #include "MemSpyDriverObjectsInternal.h"
+#include "heaputils.h"
 
 // Constants
 const TInt KMemSpyClientBufferGrowSize = 0x1000 * 8; // 32kb
@@ -511,7 +511,7 @@
             TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap();
             TMemSpyHeapMetaDataRHeap& metaData = rHeapInfo.MetaData();
             metaData.SetVTable( RHeapVTable() );
-            metaData.SetClassSize( sizeof( RHeap ) );
+            //metaData.SetClassSize( sizeof( RHeap ) );
             }
         }
     else if ( r == KErrNotSupported )
@@ -523,9 +523,14 @@
 	return r;
     }
 
+EXPORT_C TInt RMemSpyDriverClient::GetHeapInfoUser( TMemSpyHeapInfo& aInfo, TUint aTid, RArray< TMemSpyDriverFreeCell >& aFreeCells )
+	{
+	return GetHeapInfoUser(aInfo, aTid, aFreeCells, EFalse);
+	}
 
-EXPORT_C TInt RMemSpyDriverClient::GetHeapInfoUser( TMemSpyHeapInfo& aInfo, TUint aTid, RArray< TMemSpyDriverFreeCell >& aFreeCells )
-    {
+// For the record I don't think this function should be exported, but since the one above was I'm going with the flow. -TomS
+EXPORT_C TInt RMemSpyDriverClient::GetHeapInfoUser(TMemSpyHeapInfo& aInfo, TUint aTid, RArray<TMemSpyDriverCell>& aCells, TBool aCollectAllocatedCellsAsWellAsFree)
+	{
     TMemSpyDriverInternalHeapRequestParameters params;
     //
     params.iTid = aTid;
@@ -533,8 +538,10 @@
     params.iDebugAllocator = DebugEUser();
     params.iMasterInfo = &aInfo;
     params.iBuildFreeCellList = ETrue;
+	params.iBuildAllocCellList = aCollectAllocatedCellsAsWellAsFree;
+
     //
-    aFreeCells.Reset();
+    aCells.Reset();
     ResetStreamBuffer();
 	TInt r = DoControl( EMemSpyDriverOpCodeHeapInfoGetUser, &params );
 	//
@@ -548,7 +555,7 @@
             TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap();
             TMemSpyHeapMetaDataRHeap& metaData = rHeapInfo.MetaData();
             metaData.SetVTable( RHeapVTable() );
-            metaData.SetClassSize( sizeof( RHeap ) );
+            //metaData.SetClassSize( sizeof( RHeap ) );
             }
 
         // Resize transfer buffer to make room for free cells. We only make the buffer
@@ -561,10 +568,10 @@
         // Now fetch the heap data
         if  ( r == KErrNone )
             {
-            r = DoControl( EMemSpyDriverOpCodeHeapInfoFetchFreeCells, &iBuffer );
+            r = DoControl( EMemSpyDriverOpCodeHeapInfoFetchCellList, &iBuffer );
             if  ( r == KErrNone )
                 {
-                TRAP( r, ReadHeapInfoFreeCellsFromXferBufferL( aFreeCells ) );
+                TRAP( r, ReadHeapInfoFreeCellsFromXferBufferL( aCells ) );
                 }
             }
         }
@@ -663,6 +670,7 @@
     params.iDes = &aDest;
     params.iChecksum = aFreeCellChecksum;
     params.iRemaining = -1;
+	params.iReadAddress = 0;
     aDest.Zero();
     //
 	TInt r = DoControl( EMemSpyDriverOpCodeHeapDataGetUser, &params, NULL );
@@ -688,6 +696,7 @@
     params.iDes = &aDest;
     params.iChecksum = 0;
     params.iRemaining = aAmountRemaining;
+	params.iReadAddress = aReadAddress;
     aDest.Zero();
     //
 	TInt r = DoControl( EMemSpyDriverOpCodeHeapDataGetUser, &params, NULL );
@@ -790,7 +799,7 @@
 
 EXPORT_C TInt RMemSpyDriverClient::WalkHeapNextCell( TUint aTid, TMemSpyDriverCellType& aCellType, TAny*& aCellAddress, TInt& aLength, TInt& aNestingLevel, TInt& aAllocNumber, TInt& aCellHeaderSize, TAny*& aCellPayloadAddress )
     {
-    aCellType = EMemSpyDriverGoodAllocatedCell;
+    aCellType = EMemSpyDriverBadCellMask;
     aCellAddress = NULL;
     aLength = 0;
     aNestingLevel = 0;
@@ -803,14 +812,11 @@
     //
 	if  ( r == KErrNone )
 	    {
-        RBuildQueryableHeap* heap = static_cast< RBuildQueryableHeap* >( &User::Allocator() );
-        //
         aCellType = (TMemSpyDriverCellType) params.iCellType;
         aCellAddress = params.iCellAddress;
         aLength = params.iLength;
         aNestingLevel = params.iNestingLevel;
         aAllocNumber = params.iAllocNumber;
-        aCellHeaderSize = heap->CellHeaderSize( aCellType );
         aCellPayloadAddress = ((TUint8*) aCellAddress) + aCellHeaderSize;
         }
     //
@@ -839,7 +845,7 @@
 
 EXPORT_C TInt RMemSpyDriverClient::WalkHeapGetCellInfo( TAny*& aCellAddress, TMemSpyDriverCellType& aCellType, TInt& aLength, TInt& aNestingLevel, TInt& aAllocNumber, TInt& aCellHeaderSize, TAny*& aCellPayloadAddress )
     {
-    aCellType = EMemSpyDriverGoodAllocatedCell;
+    aCellType = EMemSpyDriverBadCellMask;
     aLength = 0;
     aNestingLevel = 0;
     aAllocNumber = 0;
@@ -851,14 +857,11 @@
     //
 	if  ( r == KErrNone )
 	    {
-        RBuildQueryableHeap* heap = static_cast< RBuildQueryableHeap* >( &User::Allocator() );
-        //
         aCellAddress = params.iCellAddress;
         aCellType = (TMemSpyDriverCellType) params.iCellType;
         aLength = params.iLength;
         aNestingLevel = params.iNestingLevel;
         aAllocNumber = params.iAllocNumber;
-        aCellHeaderSize = heap->CellHeaderSize( aCellType );
         aCellPayloadAddress = ((TUint8*) aCellAddress) + aCellHeaderSize;
         }
     //
@@ -1401,10 +1404,15 @@
 
 TBool RMemSpyDriverClient::DebugEUser()
     {
-    RHeap* heap = static_cast< RHeap* >( &User::Allocator() );
-    RBuildQueryableHeap* queryHeap = static_cast< RBuildQueryableHeap* >( heap );
-    const TBool isDebugEUser = queryHeap->IsDebugEUser();
-    return isDebugEUser;
+	LtkUtils::RAllocatorHelper allocHelper;
+	TBool result = EFalse;
+	TInt err = allocHelper.Open(&User::Allocator());
+	if (!err)
+		{
+		result = allocHelper.AllocatorIsUdeb();
+		allocHelper.Close();
+		}
+	return result;
     }
 
 
@@ -1435,7 +1443,7 @@
         for( TInt i=0; i<count; i++ )
             {
             TMemSpyDriverFreeCell entry;
-            entry.iType = stream.ReadInt32L();
+            entry.iType = (TMemSpyDriverCellType)stream.ReadInt32L();
             entry.iAddress = reinterpret_cast< TAny* >( stream.ReadUint32L() );
             entry.iLength = stream.ReadInt32L();
             aFreeCells.AppendL( entry );
@@ -1462,10 +1470,13 @@
     {
 #if defined( _DEBUG ) && !defined( __WINS__ )
     const TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap();
-    const TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
+    //const TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
     const TMemSpyHeapStatisticsRHeap& rHeapStats = rHeapInfo.Statistics();
     const TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
 
+	/*
+	 * TODO update to reflect new memory allocator structs etc
+	 * 
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------");
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RAllocator                                      -");
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------");
@@ -1501,6 +1512,7 @@
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iRand:                   %d", rHeapObjectData.iRand);
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - RHeap::iTestData:               0x%08x", rHeapObjectData.iTestData);
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - ");
+	*/
 
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------");
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - Stats (Free)                                    -");
@@ -1524,12 +1536,6 @@
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - ");
 
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------");
-    RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - Stats (Common)                                  -");
-    RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------");
-    RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - total cell count:               %d", rHeapStats.StatsCommon().TotalCellCount());
-    RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - ");
-
-    RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------");
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - Misc. Info                                      -");
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() ---------------------------------------------------");
     const TPtrC chunkName( rHeapMetaData.ChunkName() );
@@ -1542,8 +1548,8 @@
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - user thread:                    %d", rHeapMetaData.IsUserThread() );
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - thread id:                      %d", aInfo.Tid() );
     RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - process id:                     %d", aInfo.Pid() );
-    RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell header size (free):        %d", rHeapMetaData.HeaderSizeFree());
-    RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell header size (alloc):       %d", rHeapMetaData.HeaderSizeAllocated());
+    //RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell header size (free):        %d", rHeapMetaData.HeaderSizeFree());
+    //RDebug::Printf("RMemSpyDriverClient::PrintHeapInfo() - cell header size (alloc):       %d", rHeapMetaData.HeaderSizeAllocated());
 #else
     (void) aInfo;
 #endif
--- a/memspy/Driver/User/Source/RBuildQueryableHeap.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
-* 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 "RBuildQueryableHeap.h"
-
-// System includes
-#include <e32std.h>
-#include <e32debug.h>
-
-
-TBool RBuildQueryableHeap::IsDebugEUser() const
-    {
-    User::__DbgSetAllocFail( FALSE, RAllocator::EFailNext, 1);
-
-    TInt* cell = new TInt();
-#if defined(_DEBUG) && !defined( __WINS__ )
-    RDebug::Printf("RBuildQueryableHeap::IsDebugEUser() - cell: 0x%08x", cell);
-#endif
-
-    const TBool debugEUser = ( cell == NULL );
-#if defined(_DEBUG) && !defined( __WINS__ )
-    RDebug::Printf("RBuildQueryableHeap::IsDebugEUser() - debugEUser: %d", debugEUser);
-#endif
-
-    delete cell;
-    //
-    return debugEUser;
-    }
-
-
-TInt RBuildQueryableHeap::CellHeaderSize( TMemSpyDriverCellType aType ) const
-    {
-	TInt size = 0;
-	//
-	switch( aType )
-	{
-	case EMemSpyDriverGoodAllocatedCell:
-	case EMemSpyDriverBadAllocatedCellSize:
-	case EMemSpyDriverBadAllocatedCellAddress:
-		{
-		size = sizeof( TInt ); // Allocated UREL cells contain just a length
-		if  ( IsDebugEUser() )
-			{
-			size = sizeof( RHeap::SDebugCell );
-			}
-		break;
-		}
-	case EMemSpyDriverGoodFreeCell:
-	case EMemSpyDriverBadFreeCellAddress:
-	case EMemSpyDriverBadFreeCellSize:
-		size = EFreeCellSize;
-		break;
-	default:
-		break;
-	}
-    //
-    return size;
-    }
-
--- a/memspy/Driver/eabi/memspydriverclientu.def	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/eabi/memspydriverclientu.def	Wed Sep 15 13:53:27 2010 +0300
@@ -67,4 +67,5 @@
 	_ZN22RMemSpyMemStreamReader5ReadLER6TDes16 @ 66 NONAME
 	_ZN19RMemSpyDriverClient26GetCondVarSuspendedThreadsEPvPS0_Ri @ 67 NONAME
 	_ZN19RMemSpyDriverClient29GetCondVarSuspendedThreadInfoEPvR39TMemSpyDriverCondVarSuspendedThreadInfo @ 68 NONAME
+	_ZN19RMemSpyDriverClient15GetHeapInfoUserER15TMemSpyHeapInfojR6RArrayI21TMemSpyDriverFreeCellEi @ 69 NONAME
 
--- a/memspy/Driver/group/MemSpyDriver.mmp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/group/MemSpyDriver.mmp	Wed Sep 15 13:53:27 2010 +0300
@@ -69,6 +69,11 @@
 USERINCLUDE     ../Kernel/Include
 USERINCLUDE     ../Kernel/Include/SubChannels
 
+// New Allocator support
+MACRO			STANDALONE_ALLOCHELPER
+SOURCEPATH      ../Shared
+SOURCE          heaputils.cpp
+
 OS_LAYER_KERNEL_SYSTEMINCLUDE
 
 START WINS
--- a/memspy/Driver/group/MemSpyDriverClient.mmp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Driver/group/MemSpyDriverClient.mmp	Wed Sep 15 13:53:27 2010 +0300
@@ -29,7 +29,6 @@
 
 SOURCEPATH				../User/Source
 SOURCE					MemSpyDriverClient.cpp
-SOURCE					RBuildQueryableHeap.cpp
 SOURCE					MemSpyDriverStreamReader.cpp
 SOURCE					MemSpyDriverStreamReaderImp.cpp
 
@@ -40,6 +39,10 @@
 
 LIBRARY					euser.lib efsrv.lib
 
+// New Allocator support
+MACRO			STANDALONE_ALLOCHELPER
+SOURCEPATH      ../Shared
+SOURCE          heaputils.cpp
 
 
 
--- a/memspy/Engine/BWINS/MemSpyEngineu.def	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/BWINS/MemSpyEngineu.def	Wed Sep 15 13:53:27 2010 +0300
@@ -384,24 +384,44 @@
 	?Type@CMemSpyThreadInfoItemBase@@QBE?AW4TMemSpyThreadInfoItemType@@XZ @ 383 NONAME ; enum TMemSpyThreadInfoItemType CMemSpyThreadInfoItemBase::Type(void) const
 	?TypeAsString@CMemSpyEngineGenericKernelObjectList@@SA?AVTPtrC16@@W4TMemSpyDriverContainerType@@@Z @ 384 NONAME ; class TPtrC16 CMemSpyEngineGenericKernelObjectList::TypeAsString(enum TMemSpyDriverContainerType)
 	?VID@CMemSpyProcess@@QBEKXZ @ 385 NONAME ; unsigned long CMemSpyProcess::VID(void) const
-	?MdcaCount@CMemSpyEngineWindowGroupList@@UBEHXZ @ 386 NONAME ABSENT ; int CMemSpyEngineWindowGroupList::MdcaCount(void) const
-	?GetWindowGroupListL@CMemSpyEngineHelperWindowServer@@QAEXAAV?$RArray@VTMemSpyEngineWindowGroupInfo@@@@@Z @ 387 NONAME ABSENT ; void CMemSpyEngineHelperWindowServer::GetWindowGroupListL(class RArray<class TMemSpyEngineWindowGroupInfo> &)
-	??1CMemSpyEngineWindowGroupList@@UAE@XZ @ 388 NONAME ABSENT ; CMemSpyEngineWindowGroupList::~CMemSpyEngineWindowGroupList(void)
-	?Count@CMemSpyEngineWindowGroupList@@QBEHXZ @ 389 NONAME ABSENT ; int CMemSpyEngineWindowGroupList::Count(void) const
-	?ItemIndex@CMemSpyEngineWindowGroupList@@QBEHABVTMemSpyEngineWindowGroupInfo@@@Z @ 390 NONAME ABSENT ; int CMemSpyEngineWindowGroupList::ItemIndex(class TMemSpyEngineWindowGroupInfo const &) const
-	?WindowGroupListL@CMemSpyEngineHelperWindowServer@@QAEPAVCMemSpyEngineWindowGroupList@@XZ @ 391 NONAME ABSENT ; class CMemSpyEngineWindowGroupList * CMemSpyEngineHelperWindowServer::WindowGroupListL(void)
-	?HelperWindowServer@CMemSpyEngine@@QAEAAVCMemSpyEngineHelperWindowServer@@XZ @ 392 NONAME ABSENT ; class CMemSpyEngineHelperWindowServer & CMemSpyEngine::HelperWindowServer(void)
-	?MdcaPoint@CMemSpyEngineWindowGroupList@@UBE?AVTPtrC16@@H@Z @ 393 NONAME ABSENT ; class TPtrC16 CMemSpyEngineWindowGroupList::MdcaPoint(int) const
-	?At@CMemSpyEngineWindowGroupList@@QBEABVTMemSpyEngineWindowGroupInfo@@H@Z @ 394 NONAME ABSENT ; class TMemSpyEngineWindowGroupInfo const & CMemSpyEngineWindowGroupList::At(int) const
-	?ItemIndex@CMemSpyEngineWindowGroupList@@QBEHABVTMemSpyEngineWindowGroupBasicInfo@@@Z @ 395 NONAME ABSENT ; int CMemSpyEngineWindowGroupList::ItemIndex(class TMemSpyEngineWindowGroupBasicInfo const &) const
-	?At@CMemSpyEngineWindowGroupList@@QBEABVTMemSpyEngineWindowGroupBasicInfo@@H@Z @ 396 NONAME ABSENT ; class TMemSpyEngineWindowGroupBasicInfo const & CMemSpyEngineWindowGroupList::At(int) const
-	?GetWindowGroupListL@CMemSpyEngineHelperWindowServer@@QAEXAAV?$RArray@VTMemSpyEngineWindowGroupBasicInfo@@@@@Z @ 397 NONAME ABSENT ; void CMemSpyEngineHelperWindowServer::GetWindowGroupListL(class RArray<class TMemSpyEngineWindowGroupBasicInfo> &)
-	?GetWindowGroupDetailsL@CMemSpyEngineHelperWindowServer@@QAEXHAAVTMemSpyEngineWindowGroupDetails@@@Z @ 398 NONAME ABSENT ; void CMemSpyEngineHelperWindowServer::GetWindowGroupDetailsL(int, class TMemSpyEngineWindowGroupDetails &)
-	?SwitchToL@CMemSpyEngineHelperWindowServer@@QAEXH@Z @ 399 NONAME ABSENT ; void CMemSpyEngineHelperWindowServer::SwitchToL(int)
+	__E32Dll @ 386 NONAME ABSENT ; int CMemSpyEngineWindowGroupList::MdcaCount(void) const
+	__E32Dll @ 387 NONAME ABSENT ; void CMemSpyEngineHelperWindowServer::GetWindowGroupListL(class RArray<class TMemSpyEngineWindowGroupInfo> &)
+	__E32Dll @ 388 NONAME ABSENT ; CMemSpyEngineWindowGroupList::~CMemSpyEngineWindowGroupList(void)
+	__E32Dll @ 389 NONAME ABSENT ; int CMemSpyEngineWindowGroupList::Count(void) const
+	__E32Dll @ 390 NONAME ABSENT ; int CMemSpyEngineWindowGroupList::ItemIndex(class TMemSpyEngineWindowGroupInfo const &) const
+	__E32Dll @ 391 NONAME ABSENT ; class CMemSpyEngineWindowGroupList * CMemSpyEngineHelperWindowServer::WindowGroupListL(void)
+	__E32Dll @ 392 NONAME ABSENT ; class CMemSpyEngineHelperWindowServer & CMemSpyEngine::HelperWindowServer(void)
+	__E32Dll @ 393 NONAME ABSENT ; class TPtrC16 CMemSpyEngineWindowGroupList::MdcaPoint(int) const
+	__E32Dll @ 394 NONAME ABSENT ; class TMemSpyEngineWindowGroupInfo const & CMemSpyEngineWindowGroupList::At(int) const
+	__E32Dll @ 395 NONAME ABSENT ; int CMemSpyEngineWindowGroupList::ItemIndex(class TMemSpyEngineWindowGroupBasicInfo const &) const
+	__E32Dll @ 396 NONAME ABSENT ; class TMemSpyEngineWindowGroupBasicInfo const & CMemSpyEngineWindowGroupList::At(int) const
+	__E32Dll @ 397 NONAME ABSENT ; void CMemSpyEngineHelperWindowServer::GetWindowGroupListL(class RArray<class TMemSpyEngineWindowGroupBasicInfo> &)
+	__E32Dll @ 398 NONAME ABSENT ; void CMemSpyEngineHelperWindowServer::GetWindowGroupDetailsL(int, class TMemSpyEngineWindowGroupDetails &)
+	__E32Dll @ 399 NONAME ABSENT ; void CMemSpyEngineHelperWindowServer::SwitchToL(int)
 	?Capabilities@CMemSpyProcess@@QBE?AUSCapabilitySet@@XZ @ 400 NONAME ; struct SCapabilitySet CMemSpyProcess::Capabilities(void) const
 	?UIDs@CMemSpyProcess@@QBE?AVTUidType@@XZ @ 401 NONAME ; class TUidType CMemSpyProcess::UIDs(void) const
 	?HelperCondVar@CMemSpyEngine@@QAEAAVCMemSpyEngineHelperCondVar@@XZ @ 402 NONAME ; class CMemSpyEngineHelperCondVar & CMemSpyEngine::HelperCondVar(void)
 	?GetCondVarSuspendedThreadsL@CMemSpyEngineHelperCondVar@@QAEXABVTMemSpyDriverHandleInfoGeneric@@AAV?$RArray@VTMemSpyDriverCondVarSuspendedThreadInfo@@@@@Z @ 403 NONAME ; void CMemSpyEngineHelperCondVar::GetCondVarSuspendedThreadsL(class TMemSpyDriverHandleInfoGeneric const &, class RArray<class TMemSpyDriverCondVarSuspendedThreadInfo> &)
 	?HelperWindowServer@CMemSpyEngine@@QAEAAVMMemSpyEngineHelperWindowServer@@XZ @ 404 NONAME ; class MMemSpyEngineHelperWindowServer & CMemSpyEngine::HelperWindowServer(void)
 	?IsHelperWindowServerSupported@CMemSpyEngine@@QAEHXZ @ 405 NONAME ; int CMemSpyEngine::IsHelperWindowServerSupported(void)
+	__E32Dll @ 406 NONAME ABSENT ; int CMemSpyEngineGenericKernelObjectList::Size(void) const
+	__E32Dll @ 407 NONAME ABSENT ; int CMemSpyEngineGenericKernelObjectList::Size(void)
+	?Size@CMemSpyEngineGenericKernelObjectList@@QBEHXZ @ 408 NONAME ; int CMemSpyEngineGenericKernelObjectList::Size(void) const
+	?NewHeapRawInfo@CMemSpyEngineHelperHeap@@QAEAAVTMemSpyHeapData@@ABVTMemSpyHeapInfo@@@Z @ 409 NONAME ABSENT ; class TMemSpyHeapData & CMemSpyEngineHelperHeap::NewHeapRawInfo(class TMemSpyHeapInfo const &)
+	?NewHeapRawInfo@CMemSpyEngineHelperHeap@@QAE?AVTMemSpyHeapData@@ABVTMemSpyHeapInfo@@@Z @ 410 NONAME ; class TMemSpyHeapData CMemSpyEngineHelperHeap::NewHeapRawInfo(class TMemSpyHeapInfo const &)
+	?ItemsCount@CMemSpyEngineGenericKernelObjectList@@QBEHXZ @ 411 NONAME ; int CMemSpyEngineGenericKernelObjectList::ItemsCount(void) const
+	?Priority@CMemSpyThread@@QBE?AW4TThreadPriority@@XZ @ 412 NONAME ; enum TThreadPriority CMemSpyThread::Priority(void) const
+	?NewL@CMemSpyEngine@@SAPAV1@AAVRFs@@H@Z @ 413 NONAME ; class CMemSpyEngine * CMemSpyEngine::NewL(class RFs &, int)
+	?Value@CMemSpyThreadInfoItemBase@@QBE?AVTPtrC16@@H@Z @ 414 NONAME ; class TPtrC16 CMemSpyThreadInfoItemBase::Value(int) const
+	?ExitType@CMemSpyProcess@@QBE?AW4TExitType@@XZ @ 415 NONAME ; enum TExitType CMemSpyProcess::ExitType(void) const
+	?ExitCategory@CMemSpyProcess@@QBE?AV?$TBuf@$0BA@@@XZ @ 416 NONAME ; class TBuf<16> CMemSpyProcess::ExitCategory(void) const
+	?Priority@CMemSpyProcess@@QBE?AW4TProcessPriority@@XZ @ 417 NONAME ; enum TProcessPriority CMemSpyProcess::Priority(void) const
+	?Caption@CMemSpyThreadInfoItemBase@@QBE?AVTPtrC16@@H@Z @ 418 NONAME ; class TPtrC16 CMemSpyThreadInfoItemBase::Caption(int) const
+	?ExitReason@CMemSpyProcess@@QBEHXZ @ 419 NONAME ; int CMemSpyProcess::ExitReason(void) const
+	?NewL@CMemSpyEngineSinkMetaData@@SAPAV1@ABVTDesC16@@000HHABVTTime@@@Z @ 420 NONAME ; class CMemSpyEngineSinkMetaData * CMemSpyEngineSinkMetaData::NewL(class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, int, int, class TTime const &)
+	?InstallDebugSinkL@CMemSpyEngine@@QAEXXZ @ 421 NONAME ; void CMemSpyEngine::InstallDebugSinkL(void)
+	?NewL@CMemSpyEngineSinkMetaData@@SAPAV1@ABVTDesC16@@000HH@Z @ 422 NONAME ; class CMemSpyEngineSinkMetaData * CMemSpyEngineSinkMetaData::NewL(class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, class TDesC16 const &, int, int)
+	?InstallFileSinkL@CMemSpyEngine@@QAEXABVTDesC16@@@Z @ 423 NONAME ; void CMemSpyEngine::InstallFileSinkL(class TDesC16 const &)
+	?CheckForChangesNowL@CMemSpyEngineHelperSysMemTracker@@QAEXXZ @ 424 NONAME ; void CMemSpyEngineHelperSysMemTracker::CheckForChangesNowL(void)
+	?GetHeapInfoUserL@CMemSpyEngineHelperHeap@@QAEXABVTProcessId@@ABVTThreadId@@AAVTMemSpyHeapInfo@@PAV?$RArray@VTMemSpyDriverFreeCell@@@@H@Z @ 425 NONAME ; void CMemSpyEngineHelperHeap::GetHeapInfoUserL(class TProcessId const &, class TThreadId const &, class TMemSpyHeapInfo &, class RArray<class TMemSpyDriverFreeCell> *, int)
 
--- a/memspy/Engine/Include/ClientServer/MemSpyEngineServer.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Include/ClientServer/MemSpyEngineServer.h	Wed Sep 15 13:53:27 2010 +0300
@@ -23,17 +23,36 @@
 
 // User includes
 #include <memspyengineclientinterface.h>
+#include <memspy/engine/memspydevicewideoperations.h>
 
 // Classes referenced
 class CMemSpyEngine;
+class CMemSpyDwOperationTracker;
 
-
+NONSHARABLE_CLASS( CShutdown ) : public CTimer
+    {
+    enum {KMyShutdownDelay=10 * 1000000};       // 10s
+public:
+    inline CShutdown();
+    inline void ConstructL();
+    inline void Start();
+private:
+    void RunL();
+    };
 
 NONSHARABLE_CLASS( CMemSpyEngineServer ) : public CServer2
     {
 public:
     static CMemSpyEngineServer* NewL( CMemSpyEngine& aEngine );
     ~CMemSpyEngineServer();
+    
+    CMemSpyDwOperationTracker* CurrentOperationTracker() const { return iCurrentOperationTracker; }
+    void SetCurrentOperationTracker(CMemSpyDwOperationTracker* aTracker) { iCurrentOperationTracker = aTracker; }
+    
+    CMemSpyEngine& Engine() { return iEngine; } 
+    
+    void AddSession(TBool aCliRequest);
+    void DropSession(TBool aCliRequest);
 
 private:
     CMemSpyEngineServer( CMemSpyEngine& aEngine );
@@ -44,6 +63,12 @@
 
 private:
     CMemSpyEngine& iEngine;
+    CMemSpyDwOperationTracker* iCurrentOperationTracker;
+    
+    TInt iSessionCount;
+    TBool iCliConnected;
+    
+    CShutdown iShutdown;
     };
 
 
@@ -53,7 +78,9 @@
 public:
 	static CMemSpyEngineSession* NewL( CMemSpyEngine& aEngine, const RMessage2& aMessage );
 	~CMemSpyEngineSession();
-
+	
+	void CreateL();
+	
 private:
 	CMemSpyEngineSession( CMemSpyEngine& aEngine );
 	void ConstructL( const RMessage2& aMessage );
@@ -63,17 +90,54 @@
 
 private: // Internal methods
     void DoServiceL( const RMessage2& aMessage );
+    void DoAsyncServiceL( const RMessage2& aMessage );
+    void DoUiServiceL( const RMessage2& aMessage );
+    void DoCmdServiceL( const RMessage2& aMessage );
     static TInt ValidateFunction( TInt aFunction, TBool aIncludesThreadId, TBool aIncludesThreadName );
     void HandleThreadSpecificOpL( TInt aFunction, const TThreadId& aThreadId );
     void HandleThreadSpecificOpL( TInt aFunction, const TDesC& aThreadName );
     void HandleThreadAgnosticOpL( TInt aFunction, const RMessage2& aMessage );
+    void StartDeviceWideOperationL(CMemSpyDeviceWideOperations::TOperation aOperation, const RMessage2& aMessage);
+    
+    inline CMemSpyEngineServer& Server() const { return *static_cast<CMemSpyEngineServer*>(const_cast<CServer2*>(CSession2::Server())); }
 
 private:
     CMemSpyEngine& iEngine;
     HBufC* iClientThreadName;
     TUint32 iClientThreadId;
+    TBool iIsCliRequest;
     };
 
+/**
+ * CMemSpyDwOperationTracker
+ * Tracks device wide operation progress and calls iOperationMessage.Complete upon completion. 
+ */
+NONSHARABLE_CLASS( CMemSpyDwOperationTracker ) : public MMemSpyDeviceWideOperationsObserver
+	{
+public:
+	static CMemSpyDwOperationTracker* NewL(CMemSpyDeviceWideOperations::TOperation aOperation, 
+			const RMessage2& aOperationMessage,
+			CMemSpyEngineServer& aServer);
+	~CMemSpyDwOperationTracker();
+	
+	void AddNotificationL(const RMessage2& aMessage);
+	
+	void Cancel();
+
+public: // From MMemSpyDeviceWideOperationsObserver
+	void HandleDeviceWideOperationEvent(TEvent aEvent, TInt aParam1, const TDesC& aParam2);
+	
+private:
+	CMemSpyDwOperationTracker(const RMessage2& aOperationMessage, CMemSpyEngineServer& aServer);
+	void ConstructL(CMemSpyDeviceWideOperations::TOperation aOperation);
+	
+private:
+	RMessage2 iOperationMessage;
+	CMemSpyEngineServer& iServer;
+	CArrayFixFlat<RMessage2>* iPendingNotifications;
+	CMemSpyDeviceWideOperations* iOperation;
+	TInt iProgress;
+	};
 
 
 #endif
--- a/memspy/Engine/Include/Sink/MemSpyEngineOutputSinkFile.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Include/Sink/MemSpyEngineOutputSinkFile.h	Wed Sep 15 13:53:27 2010 +0300
@@ -32,12 +32,12 @@
 NONSHARABLE_CLASS( CMemSpyEngineOutputSinkFile ) : public CMemSpyEngineOutputSink
     {
 public:
-    static CMemSpyEngineOutputSinkFile* NewL( CMemSpyEngine& aEngine );
+    static CMemSpyEngineOutputSinkFile* NewL( CMemSpyEngine& aEngine, const TDesC& aRootFolder );
     ~CMemSpyEngineOutputSinkFile();
 
 public:
     CMemSpyEngineOutputSinkFile( CMemSpyEngine& aEngine );
-    void ConstructL();
+    void ConstructL( const TDesC& aRootFolder );
     
 private: // From CMemSpyEngineOutputSink
     void ProcessSuspendedL( TProcessId aId );
@@ -64,6 +64,8 @@
 
     TUint iFileServerProcessId;
     TBool iFileServerSuspended;
+    
+    HBufC* iRoot;
 
 private:
     friend class CMemSpyEngineFileHolder;
@@ -117,4 +119,4 @@
 
 
 
-#endif
\ No newline at end of file
+#endif
--- a/memspy/Engine/Source/ClientServer/MemSpyEngineServer.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/ClientServer/MemSpyEngineServer.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -19,6 +19,9 @@
 
 // System includes
 #include <e32svr.h>
+#include <w32std.h>
+#include <APGTASK.H>
+#include <APGWGNAM.H>  
 
 // User includes
 #include <memspy/engine/memspyengine.h>
@@ -38,7 +41,45 @@
 #include <memspy/engine/memspyenginehelpersysmemtracker.h>
 #include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h>
 #include <memspy/engine/memspyenginehelperkernelcontainers.h>
+#include <memspy/engine/memspyengineobjectthreadinfocontainer.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspyenginehelpersysmemtrackercycle.h>
+#include <memspy/engine/memspyenginehelperserver.h>
+#include <memspy/engine/memspyenginehelperecom.h>
 
+#include <memspy/engine/memspyprocessdata.h>
+#include <memspy/engine/memspythreaddata.h>
+#include <memspy/engine/memspykernelobjectdata.h>
+#include <memspy/engine/memspythreadinfoitemdata.h>
+#include <memspy/engine/memspymemorytrackingcycledata.h>
+#include <memspy/engine/memspyengineoutputsink.h>
+#include <memspy/engine/memspyenginehelperactiveobject.h>
+#include <memspy/engine/memspyserverdata.h>
+#include <memspysession.h>
+#include <memspy/engine/memspyecomdata.h>
+
+inline CShutdown::CShutdown() :CTimer(-1)
+    {
+    CActiveScheduler::Add(this);
+    }
+
+inline void CShutdown::ConstructL()
+    {
+    CTimer::ConstructL();
+    }
+
+inline void CShutdown::Start()
+    {
+    After(KMyShutdownDelay);
+    }
+
+void CShutdown::RunL()
+    //
+    // Initiate server exit when the timer expires
+    //
+    {
+    CActiveScheduler::Stop();
+    }
 
 CMemSpyEngineServer::CMemSpyEngineServer( CMemSpyEngine& aEngine )
 :   CServer2( EPriorityNormal ), iEngine( aEngine )
@@ -54,6 +95,10 @@
 void CMemSpyEngineServer::ConstructL()
     {
     StartL( KMemSpyServerName );
+        
+    iShutdown.ConstructL();
+    // ensure that the server still exits even if the 1st client fails to connect
+    iShutdown.Start();
     }
 
 
@@ -79,6 +124,33 @@
 	return session;
     }
 
+void CMemSpyEngineServer::AddSession(TBool aCliRequest)
+    {
+    if (aCliRequest)
+        {
+        iCliConnected = ETrue;
+        }
+    else
+        {
+        ++iSessionCount;
+        }
+    iShutdown.Cancel();
+    }
+
+void CMemSpyEngineServer::DropSession(TBool aCliRequest)
+    {
+    if (!aCliRequest)
+        {
+        --iSessionCount;
+        }
+    
+    if (iSessionCount == 0 && !iCliConnected)
+        {
+        iShutdown.Start();
+        }
+    }
+
+
 
 
 
@@ -120,6 +192,8 @@
 #endif
 
     delete iClientThreadName;
+        
+    Server().DropSession(iIsCliRequest);
     }
 
 
@@ -138,10 +212,17 @@
     iClientThreadId = thread.Id();
 
     CleanupStack::PopAndDestroy( &thread );
-
+    
+    const TUid KCliUid3 = { 0x2002129D };
+    iIsCliRequest = aMessage.SecureId() == TSecureId(KCliUid3);
+    
     TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::ConstructL() - NEW SESSION - this: 0x%08x, id: %4d, client: %S"), this, iClientThreadId, iClientThreadName ) );
     }
 
+void CMemSpyEngineSession::CreateL()
+    {   
+    Server().AddSession(iIsCliRequest);
+    }
 
 CMemSpyEngineSession* CMemSpyEngineSession::NewL( CMemSpyEngine& aEngine, const RMessage2& aMessage )
     {
@@ -162,13 +243,998 @@
         {
         RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::ServiceL() - SERVICE ERROR - this: 0x%08x, fn: %d, err: %d, client: %S"), this, aMessage.Function(), error, iClientThreadName );
         }
-    aMessage.Complete( error );
+    
+    if ((aMessage.Function() & KMemSpyOpFlagsAsyncOperation) == 0 || error != KErrNone)
+    	{
+		aMessage.Complete( error );
+    	}
 
     TRACE( RDebug::Print( _L("[MemSpy] CMemSpyEngineSession::ServiceL() - END - this: 0x%08x, fn: 0x%08x, id: %4d, client: %S"), this, aMessage.Function(), iClientThreadId, iClientThreadName ) );
 	}
 
+// ---------------------------------------------------------
+// DoServiceL( const RMessage2& aMessage )
+// ---------------------------------------------------------
+//
+void CMemSpyEngineSession::DoServiceL( const RMessage2& aMessage )
+	{
+	TInt function = aMessage.Function() & KMemSpyOpFlagsTypeMask;
+	if (function >= EMemSpyClientServerOpMarkerUiFirst && 
+		function < EMemSpyClientServerOpMarkerUiLast)
+		
+		DoUiServiceL(aMessage);
+	else
+		DoCmdServiceL(aMessage);
+	}
+// ---------------------------------------------------------
+// DoUiServiceL( const RMessage2& aMessage )
+// ---------------------------------------------------------
+//
+void CMemSpyEngineSession::DoUiServiceL( const RMessage2& aMessage )
+    {
+	switch (aMessage.Function() & KMemSpyOpFlagsTypeMask)
+		{
+	    case EMemSpyClientServerOpGetOutputSink:
+	        {
+	        TMemSpySinkType sink = iEngine.SinkType();
+	        TPckgBuf<TMemSpySinkType> type( sink );
+	        
+	        aMessage.WriteL( 0, type );
+	        break;
+	        }
+		case EMemSpyClientServerOpGetProcessCount:
+			{
+			aMessage.WriteL(0, TPckgBuf<TInt>(iEngine.Container().Count()));
+			break;
+			}
+		case EMemSpyClientServerOpGetProcesses:
+			{
+			CMemSpyEngineObjectContainer& list = iEngine.Container();
+			
+			TPckgBuf<TInt> a0;
+			aMessage.ReadL(0, a0);
+			TInt realCount = Min(a0(), list.Count());
+			
+			for(TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyProcessData))
+				{
+				CMemSpyProcess& process = iEngine.Container().At(i);
+				TMemSpyProcessData data;
+				data.iIsDead = process.IsDead();
+				data.iId = process.Id();
+				data.iName.Copy(process.Name().Left(KMaxFullName));
+				data.iThreadCount = process.Count();
+				data.iPriority = process.Priority();
+				data.iExitType = process.ExitType();
+				data.iExitReason = process.ExitReason();
+				data.iExitCategory = process.ExitCategory();
+				data.iSID = process.SID();
+				
+				TPckgBuf<TMemSpyProcessData> buffer(data);
+				aMessage.WriteL(1, buffer, offset);
+				}
+			
+			a0 = list.Count();
+			aMessage.WriteL(0, a0);
 
-void CMemSpyEngineSession::DoServiceL( const RMessage2& aMessage )
+			break;
+			}
+		case EMemSpyClienServerOpGetProcessIdByName:
+			{
+			TFullName processName;
+			aMessage.ReadL(0, processName);
+			
+			TBool found(EFalse);
+			
+			for (TInt i=0; i<iEngine.Container().Count(); i++)
+				{
+				CMemSpyProcess& process = iEngine.Container().At(i);
+				if (process.Name().FindF(processName) >= 0)
+					{
+					found = ETrue;
+					TPckgBuf<TProcessId> procId(process.Id());
+					aMessage.WriteL(1, procId);
+					}
+				}
+			
+			if (!found)
+				{
+				User::Leave(KErrNotFound);
+				}
+			
+			break;
+			}
+		case EMemSpyClientServerOpProcessSystemPermanentOrCritical:
+			{
+			TBool ret = EFalse;
+			TPckgBuf<TProcessId> id;
+			aMessage.ReadL( 0, id );
+			
+			CMemSpyEngineObjectContainer& container = iEngine.Container();
+			CMemSpyProcess& process = container.ProcessByIdL( id() );
+			
+			if  ( process.IsSystemPermanent() || process.IsSystemCritical() )
+				{
+				ret = ETrue;
+				}
+			TPckgBuf<TBool> retBuf( ret );
+			aMessage.WriteL( 1, retBuf );
+			
+			break;
+			}
+		case EMemSpyClientServerOpEndProcess:
+			{
+			TPckgBuf<TProcessId> id;
+			aMessage.ReadL( 0, id );
+			TPckgBuf<TMemSpyEndType> type;
+			aMessage.ReadL( 1, type );
+					
+			CMemSpyEngineObjectContainer& container = iEngine.Container();			
+			CMemSpyProcess& process = container.ProcessByIdL( id() );
+									
+			switch ( type() )
+				{
+				case ETerminate:
+					{
+					process.TerminateL();
+					break;
+					}
+				case EPanic:
+					{
+					process.PanicL();
+					break;
+					}
+				case EKill:
+					{
+					process.KillL();
+					break;
+					}
+				}																
+			break;
+			}
+		case EMemSpyClientServerOpSwitchToProcess:
+			{/*
+			TInt wgCount;
+			RWsSession wsSession;
+			User::LeaveIfError( wsSession.Connect() );
+			CleanupClosePushL( wsSession );
+			User::LeaveIfError( wgCount = wsSession.NumWindowGroups() );
+			RArray<RWsSession::TWindowGroupChainInfo> wgArray;
+			CleanupClosePushL( wgArray );
+			User::LeaveIfError( wsSession.WindowGroupList( &wgArray ) );
+			TApaTask task( wsSession );
+			TBool brought( EFalse );
+			TInt wgId( KErrNotFound );
+			TThreadId threadId;
+			
+			TPckgBuf<TProcessId> id;
+			aMessage.ReadL( 0, id );
+			CMemSpyEngineObjectContainer& container = iEngine.Container();
+			CMemSpyProcess& process = container.ProcessByIdL( id() );
+			
+			// loop trough threads in a process
+			for ( TInt i = 0; i < process.MdcaCount(); i++ )
+				{
+				TInt wgCountLocal = wgCount;
+							
+				// loop trough all window groups and see if a thread id matches
+				while( !brought && wgCountLocal-- )
+					{
+					wgId = wgArray[wgCountLocal].iId;
+					User::LeaveIfError( wsSession.GetWindowGroupClientThreadId( wgId, threadId ) );
+					if ( threadId == process.At( i ).Id() )
+						{
+						CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( wsSession, wgId );
+						task.SetWgId( wgId );
+						if ( !wgName->Hidden() && task.Exists() )
+							{
+							task.BringToForeground();
+							brought = ETrue;                        
+							}
+						CleanupStack::PopAndDestroy( wgName );
+						}
+					}
+				}
+			
+			TPckgBuf<TBool> ret( brought );
+			aMessage.WriteL( 1, ret );
+			
+			break;*/
+			}
+		case EMemSpyClientServerOpGetThreadCount:
+			{
+			TPckgBuf<TProcessId> pid;
+			aMessage.ReadL(1, pid);
+			CMemSpyProcess& process = iEngine.Container().ProcessByIdL(pid());
+			aMessage.WriteL(0, TPckgBuf<TInt>(process.Count()));
+			break;
+			}
+		case EMemSpyClientServerOpGetThreads:
+			{
+			TPckgBuf<TProcessId> pid;
+			aMessage.ReadL(2, pid);
+			
+			CMemSpyProcess& list = iEngine.Container().ProcessByIdL(pid());
+			
+			TPckgBuf<TInt> a0;
+			aMessage.ReadL(0, a0);
+			TInt realCount = Min(a0(), list.Count());
+						
+			for(TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyThreadData))
+				{
+				CMemSpyThread& thread = list.At(i);
+				
+				TMemSpyThreadData data;
+				data.iId = thread.Id();
+				data.iName.Copy(thread.Name().Left(KMaxFullName));
+				data.iThreadPriority = thread.Priority();
+				
+				TPckgBuf<TMemSpyThreadData> buffer(data);
+				aMessage.WriteL(1, buffer, offset);
+				}
+			
+			a0 = list.Count();
+			aMessage.WriteL(0, a0);
+
+			break;
+			}
+		case EMemSpyClientServerOpSetThreadPriority:
+			{
+			TPckgBuf<TThreadId> tid;
+			TPckgBuf<TInt> priority;
+			aMessage.ReadL(0, tid);
+			aMessage.ReadL(1, priority);
+			
+			CMemSpyProcess* process = NULL;
+			CMemSpyThread* thread = NULL; 
+			User::LeaveIfError(iEngine.Container().ProcessAndThreadByThreadId(tid(), process, thread));
+			
+			if (thread)
+				{				
+				thread->SetPriorityL(static_cast<TThreadPriority>(priority()));
+				}					
+			break;
+			}
+		case EMemSpyClientServerOpThreadSystemPermanentOrCritical:
+			{
+			TPckgBuf<TThreadId> id;
+			aMessage.ReadL( 0, id );
+			
+			CMemSpyEngineObjectContainer& container = iEngine.Container();            
+			CMemSpyProcess* process = NULL;
+			CMemSpyThread* thread = NULL; 
+			User::LeaveIfError( container.ProcessAndThreadByThreadId( id(), process, thread ) );
+			
+			TBool ret = thread && ( thread->IsSystemPermanent() || thread->IsSystemCritical() );
+			
+			TPckgBuf<TBool> retBuf( ret );
+			aMessage.WriteL( 1, retBuf );
+							
+			break;
+			}
+		case EMemSpyClientServerOpEndThread:
+			{
+			TPckgBuf<TThreadId> id;
+			aMessage.ReadL( 0, id );
+			TPckgBuf<TMemSpyEndType> type;
+			aMessage.ReadL( 1, type );
+			
+			CMemSpyEngineObjectContainer& container = iEngine.Container();
+			CMemSpyProcess* process = NULL;
+			CMemSpyThread* thread = NULL; 
+			User::LeaveIfError( container.ProcessAndThreadByThreadId( id(), process, thread ) );
+			
+			if( thread )
+				{
+				switch ( type() )
+					{
+					case ETerminate:
+						{
+						thread->TerminateL();
+						break;
+						}
+					case EPanic:
+						{
+						thread->PanicL();
+						break;
+						}
+					case EKill:
+						{
+						thread->KillL();
+						break;
+						}
+					}				
+				}			
+			break;
+			}
+		case EMemSpyClientServerOpSwitchToThread:
+			{
+			TInt wgCount;
+			RWsSession wsSession;
+			User::LeaveIfError( wsSession.Connect() );
+			CleanupClosePushL( wsSession );
+			User::LeaveIfError( wgCount = wsSession.NumWindowGroups() );
+			RArray<RWsSession::TWindowGroupChainInfo> wgArray;
+			CleanupClosePushL( wgArray );
+			User::LeaveIfError( wsSession.WindowGroupList( &wgArray ) );
+			TApaTask task( wsSession );
+			TBool brought( EFalse );
+			TInt wgId( KErrNotFound );
+			TThreadId threadId;
+					
+			TPckgBuf<TThreadId> id;
+			aMessage.ReadL( 0, id );
+					
+			// loop trough all window groups and see if a thread id matches
+			while( !brought && wgCount-- )
+				{
+				wgId = wgArray[wgCount].iId;
+				User::LeaveIfError( wsSession.GetWindowGroupClientThreadId( wgId, threadId ) );
+				if ( threadId == id() )
+					{
+					CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC( wsSession, wgId );
+					task.SetWgId( wgId );
+					if ( !wgName->Hidden() && task.Exists() )
+						{
+						task.BringToForeground();
+						brought = ETrue;                        
+						}
+					CleanupStack::PopAndDestroy( wgName );
+					}
+				}			
+			TPckgBuf<TBool> ret( brought );
+			aMessage.WriteL( 1, ret );															
+					
+			break;
+			}		
+		case EMemSpyClientServerOpGetInfoItemType:
+			{
+			
+			TPckgBuf<TInt> index;
+			aMessage.ReadL( 0, index );			
+			TPckgBuf<TThreadId> id;
+			aMessage.ReadL( 1, id);
+								
+			CMemSpyEngineObjectContainer& container = iEngine.Container();            
+			CMemSpyProcess* process = NULL; //not needed
+			CMemSpyThread* thread = NULL; 
+			User::LeaveIfError( container.ProcessAndThreadByThreadId( id(), process, thread ) );
+		            
+			CMemSpyThreadInfoContainer& threadInfoContainer = thread->InfoContainerForceSyncronousConstructionL();                        
+			TMemSpyThreadInfoItemType retType = threadInfoContainer.Item( index() ).Type();
+			
+			TPckgBuf<TMemSpyThreadInfoItemType> ret( retType );
+			aMessage.WriteL( 2, ret );			
+			
+			break;
+			}
+		case EMemSpyClientServerOpGetThreadInfoItemsCount:
+			{
+			TPckgBuf<TThreadId> id;
+			aMessage.ReadL( 0, id );
+			TPckgBuf<TMemSpyThreadInfoItemType> type;
+			aMessage.ReadL( 1, type );					 
+			
+			CMemSpyEngineObjectContainer& container = iEngine.Container();            
+			CMemSpyProcess* process = NULL;
+			CMemSpyThread* thread = NULL; 
+			
+			container.ProcessAndThreadByThreadId( id(), process, thread );
+			
+			CMemSpyThreadInfoContainer& threadInfoContainer = thread->InfoContainerForceSyncronousConstructionL();                 
+								
+			CMemSpyThreadInfoItemBase& threadInfoItemBase = threadInfoContainer.Item( type() );
+				    
+			TInt count = threadInfoItemBase.MdcaCount();		    
+			TPckgBuf<TInt> tempret( count );
+			aMessage.WriteL( 2, tempret );
+		
+			break;
+			}		
+		case EMemSpyClientServerOpGetThreadInfoItems:
+			{
+			TPckgBuf<TInt> count;
+			aMessage.ReadL( 0, count );						
+			TPckgBuf<TThreadId> id;
+			aMessage.ReadL( 1, id );
+			TPckgBuf<TMemSpyThreadInfoItemType> type;
+			aMessage.ReadL( 2, type );			
+			
+			CMemSpyEngineObjectContainer& container = iEngine.Container();            
+			CMemSpyProcess* process = NULL;
+			CMemSpyThread* thread = NULL; 
+			User::LeaveIfError( container.ProcessAndThreadByThreadId( id() , process, thread ) );
+							  
+			CMemSpyThreadInfoContainer& threadInfoContainer = thread->InfoContainerForceSyncronousConstructionL();      
+
+			CMemSpyThreadInfoItemBase& threadInfoItemBase = threadInfoContainer.Item( type() ); //get ThreadInfoItemBaseByType
+			
+			TInt itemCount = Min(count(), threadInfoItemBase.MdcaCount());
+								
+			for( TInt i=0, offset = 0; i<itemCount; i++, offset += sizeof( TMemSpyThreadInfoItemData ) )
+				{
+				TMemSpyThreadInfoItemData data;
+				
+				TPtrC caption(threadInfoItemBase.MdcaPoint(i).Mid(1));
+				TInt tabPos = caption.Locate('\t');
+				if (tabPos != KErrNotFound)
+					caption.Set(caption.Left(tabPos));
+				
+				TPtrC value(threadInfoItemBase.MdcaPoint(i));
+				tabPos = value.LocateReverse('\t');
+				if (tabPos != KErrNotFound)
+					value.Set(value.Mid(tabPos + 1));
+												
+				data.iCaption.Copy( caption.Left(64) );
+				data.iValue.Copy( value.Left(32) );
+							
+				TPckgBuf<TMemSpyThreadInfoItemData> buffer(data);
+				aMessage.WriteL(3, buffer, offset);				
+				}			
+			aMessage.WriteL(0, count);
+					
+			break;
+			}
+			
+		case EMemSpyClientServerOpGetProcessIdByThreadId:
+			{
+			TPckgBuf<TThreadId> tid;
+			aMessage.ReadL( 1, tid );					
+			
+			CMemSpyProcess* process = NULL;
+			CMemSpyThread* thread = NULL;
+			//
+			const TInt error = iEngine.Container().ProcessAndThreadByThreadId( tid(), process, thread );
+			
+			TProcessId pid = process->Id();
+			
+			TPckgBuf<TProcessId> ret(pid);
+			aMessage.WriteL( 0, ret );
+									
+			break;
+			}
+			
+		// --- KernelObjects related functions ---
+		case EMemSpyClientServerOpGetKernelObjectCount:
+			{
+			TInt iCount = EMemSpyDriverContainerTypeLast - EMemSpyDriverContainerTypeFirst + 1;
+			TPckgBuf<TInt> ret( iCount );
+			aMessage.WriteL(0, ret);			
+			break;
+			}
+		case EMemSpyClientServerOpGetKernelObjects:
+			{
+			TPckgBuf<TInt> count;
+			aMessage.ReadL(0, count);
+			
+			CMemSpyEngineGenericKernelObjectContainer* model = iEngine.HelperKernelContainers().ObjectsAllL(); //contains all the objects
+			CleanupStack::PushL( model );
+			
+			for( TInt i=0, offset = 0; i<count(); i++, offset += sizeof( TMemSpyKernelObjectData ) )
+				{
+				TMemSpyKernelObjectData data;
+				
+				TPtrC name(model->At(i).Name().Mid(1));
+				TInt tabPos = name.Locate('\t');
+				if (tabPos != KErrNotFound)
+					name.Set(name.Left(tabPos));
+												
+				data.iName.Copy(name);
+				data.iType = model->At(i).Type();
+				data.iCount = model->At(i).Count();											
+				data.iSize = model->At(i).Count() * model->At(i).Count();
+
+				TPckgBuf<TMemSpyKernelObjectData> buffer(data);
+				aMessage.WriteL(1, buffer, offset);
+				}			
+			aMessage.WriteL(0, count);
+			CleanupStack::PopAndDestroy( model );
+			break;
+			}
+		case EMemSpyClientServerOpGetKernelObjectItemCount:
+			{
+			TPckgBuf<TMemSpyDriverContainerType> tempType;
+			aMessage.ReadL(1, tempType); //get type of kernel object
+			TMemSpyDriverContainerType type = tempType();
+			
+			CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers();
+			CMemSpyEngineGenericKernelObjectList* iObjectList = kernelContainerManager.ObjectsForSpecificContainerL( type );			
+			
+			TInt count = iObjectList->Count();
+			TPckgBuf<TInt> ret( count );
+			aMessage.WriteL( 0, ret );
+						
+			break;
+			}
+		case EMemSpyClientServerOpGetKernelObjectItems:
+			{
+			TPckgBuf<TInt> count;
+			TPckgBuf<TMemSpyDriverContainerType> tempType;
+			aMessage.ReadL( 0, count ); //get count of items
+			aMessage.ReadL(1, tempType); //get type of kernel object
+			TInt c = count();
+						
+			CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers();
+			CMemSpyEngineGenericKernelObjectList* iObjectList = kernelContainerManager.ObjectsForSpecificContainerL( tempType() );			
+			
+			for( TInt i=0, offset = 0; i<c; i++, offset += sizeof( TMemSpyDriverHandleInfoGeneric ) )
+				{
+				TMemSpyDriverHandleInfoGeneric data;								
+															
+				data = iObjectList->At( i );
+				
+				TPckgBuf<TMemSpyDriverHandleInfoGeneric> buffer(data);
+				aMessage.WriteL(2, buffer, offset);
+				}			
+					
+			break;
+			}
+			
+		case EMemSpyClientServerOpOutputAllContainerContents:
+			{
+			CMemSpyEngineHelperKernelContainers& kernelContainerManager = iEngine.HelperKernelContainers();
+			CMemSpyEngineGenericKernelObjectContainer* model = kernelContainerManager.ObjectsAllL();
+			
+			model->OutputL( iEngine.Sink() );
+
+			break;
+			}
+			
+		case EMemSpyClientServerOpDumpKernelHeap:
+			{
+		    iEngine.HelperHeap().OutputHeapDataKernelL();
+			
+			break;
+			}
+			
+		case EMemSpyClientServerOpOutputInfoHandles:
+			{
+			TPckgBuf<TThreadId> id;
+			aMessage.ReadL(0, id);
+			CMemSpyEngineObjectContainer& container = iEngine.Container();            
+			CMemSpyProcess* process = NULL;
+			CMemSpyThread* thread = NULL; 
+			User::LeaveIfError( container.ProcessAndThreadByThreadId( id() , process, thread ) );
+										  
+			CMemSpyThreadInfoContainer& threadInfoContainer = thread->InfoContainerForceSyncronousConstructionL();
+			
+			threadInfoContainer.PrintL();
+			
+			break;
+			}
+			
+		case EMemSpyClientServerOpOutputAOList:
+			{
+			TPckgBuf<TThreadId> id;
+			TPckgBuf<TMemSpyThreadInfoItemType> type;
+			aMessage.ReadL(0, id);
+			aMessage.ReadL(1, type);
+			
+			CMemSpyEngineObjectContainer& container = iEngine.Container();            
+			CMemSpyProcess* process = NULL;
+			CMemSpyThread* thread = NULL; 
+			User::LeaveIfError( container.ProcessAndThreadByThreadId( id() , process, thread ) );
+										  
+			CMemSpyThreadInfoContainer& threadInfoContainer = thread->InfoContainerForceSyncronousConstructionL();      
+
+			CMemSpyThreadInfoItemBase* threadInfoItem = &threadInfoContainer.Item( type() );
+						
+			CMemSpyThreadInfoActiveObjects* activeObjectArray = static_cast< CMemSpyThreadInfoActiveObjects* >( threadInfoItem );			
+						
+		    // Begin a new data stream
+		    _LIT( KMemSpyContext, "Active Object List - " );
+		    _LIT( KMemSpyFolder, "Active Objects" );
+		    iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
+		    		    
+		    // Set prefix for overall listing
+		    iEngine.Sink().OutputPrefixSetLC( KMemSpyContext );
+
+		    // Create header
+		    CMemSpyEngineActiveObjectArray::OutputDataColumnsL( iEngine );
+		    
+		    // List items
+		    const TInt count = activeObjectArray->Array().Count();
+		    for(TInt i=0; i<count; i++)
+		        {
+		        const CMemSpyEngineActiveObject& object = activeObjectArray->Array().At( i );
+		        //
+		        object.OutputDataL( iEngine );
+		        }
+
+		    // Tidy up
+		    CleanupStack::PopAndDestroy(); // prefix
+
+		    // End data stream		    		    
+		    iEngine.Sink().DataStreamEndL();		    
+			
+			break;
+			}
+			
+		// --- Kernel Heap related functions ---
+		case EMemSpyClientServerOpGetHeap:
+			{
+			TMemSpyHeapInfo heapInfo;			
+			iEngine.HelperHeap().GetHeapInfoKernelL( heapInfo );
+			TMemSpyHeapData data = iEngine.HelperHeap().NewHeapRawInfo( heapInfo );
+			
+			TPckgBuf<TMemSpyHeapData> buffer(data);
+			aMessage.WriteL(0, buffer);
+			
+			break;
+			}
+			
+		case EMemSpyClientServerOpGetServerCount:
+            {
+            CMemSpyEngineServerList* list = iEngine.HelperServer().ServerListL();
+            CleanupStack::PushL(list);
+            // TODO: cache it between calls
+            aMessage.WriteL(0, TPckgBuf<TInt>(list->MdcaCount()));
+            
+            CleanupStack::PopAndDestroy(list);
+            break;
+            }
+        // --- Servers related functions
+        case EMemSpyClientServerOpGetServers:
+            {
+            CMemSpyEngineServerList* list = iEngine.HelperServer().ServerListL();
+            CleanupStack::PushL(list);
+            
+            TPckgBuf<TInt> a0;
+            aMessage.ReadL(0, a0);
+            TInt realCount = Min(a0(), list->MdcaCount());
+            
+            for(TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyServerData))
+                {
+                const CMemSpyEngineServerEntry& server = list->At(i);
+                TMemSpyServerData data;
+                
+                CMemSpyProcess* process = NULL;
+                CMemSpyThread* thread = NULL;
+                TInt error = iEngine.Container().ProcessAndThreadByThreadId( server.Id(), process, thread );
+                if (error == KErrNone && thread)
+                    {
+                    data.iId = thread->Process().Id();
+                    }
+                data.iName.Copy(server.Name().Left(KMaxFullName));
+                data.iSessionCount = server.SessionCount();
+                
+                TPckgBuf<TMemSpyServerData> buffer(data);
+                aMessage.WriteL(1, buffer, offset);
+                }
+            
+            a0 = list->Count();
+            aMessage.WriteL(0, a0);
+            
+            CleanupStack::PopAndDestroy(list);
+
+            break;
+            }
+            
+        case EMemSpyClientServerOpGetSortedServers:
+        	{
+        	CMemSpyEngineServerList* list = iEngine.HelperServer().ServerListL();
+        	CleanupStack::PushL(list);
+        	
+        	TPckgBuf<TSortType> a2;
+        	aMessage.ReadL( 2, a2 );
+        	
+        	//sort the list of the servers
+        	if( a2() == ESortServByName )
+        		list->SortByNameL();
+        	else
+        		list->SortBySessionCountL();
+        	
+        	TPckgBuf<TInt> a0;        	
+        	aMessage.ReadL(0, a0);        	        	        
+        	
+        	TInt realCount = Min(a0(), list->MdcaCount());
+        	            
+        	for(TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyServerData))
+        		{
+				const CMemSpyEngineServerEntry& server = list->At(i);
+				TMemSpyServerData data;
+        	                
+				data.iId = server.Id();
+				data.iName.Copy(server.Name().Left(KMaxFullName));
+				data.iSessionCount = server.SessionCount();
+        	                
+				TPckgBuf<TMemSpyServerData> buffer(data);
+				aMessage.WriteL(1, buffer, offset);
+        		}        	           
+			a0 = list->Count();
+			aMessage.WriteL(0, a0);
+        	            
+			CleanupStack::PopAndDestroy(list);
+			break;
+        	}
+          
+        case EMemSpyClientServerOpServerListOutputGeneric:
+        	{
+            TPckgBuf<TBool> a0;
+            aMessage.ReadL(0, a0);
+        	
+            CMemSpyEngineServerList* list;            
+            list = iEngine.HelperServer().ServerListL();
+            CleanupStack::PushL(list);
+            
+            _LIT( KMemSpyContext, "Server List - " );
+            _LIT( KMemSpyFolder, "Servers" );
+            iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder );
+
+            // Set prefix for overall listing
+            iEngine.Sink().OutputPrefixSetLC( KMemSpyContext );
+
+            // Create header
+            CMemSpyEngineServerList::OutputDataColumnsL( iEngine, a0() );
+               
+            // List items
+            const TInt count = list->Count();
+            for(TInt i=0; i<count; i++)
+            	{
+				const CMemSpyEngineServerEntry& server = list->At( i );
+				//
+				server.OutputDataL( iEngine.HelperServer(), a0() );
+            	}
+
+            // Tidy up
+            CleanupStack::PopAndDestroy(); // prefix
+            
+            // End data stream
+            iEngine.Sink().DataStreamEndL();
+            
+            CleanupStack::PopAndDestroy(list);        	
+        	break;
+        	}        	
+        	
+		case EMemSpyClientServerOpGetMemoryTrackingCycleCount:
+			{
+			TInt count = iEngine.HelperSysMemTracker().CompletedCycles().Count();
+			TPckgBuf<TInt> ret( count );
+			aMessage.WriteL( 0, ret );			
+			break;
+			}		
+			
+		case EMemSpyClientServerOpGetMemoryTrackingCycles:
+			{
+			const RPointerArray<CMemSpyEngineHelperSysMemTrackerCycle>& list = iEngine.HelperSysMemTracker().CompletedCycles();
+
+			TPckgBuf<TInt> a0;
+			aMessage.ReadL(0, a0);
+			TInt realCount = Min(a0(), list.Count());
+			
+			for (TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyMemoryTrackingCycleData))
+				{
+				CMemSpyProcess& process = iEngine.Container().At(i);
+				TMemSpyMemoryTrackingCycleData data;
+				data.iCycleNumber = list[i]->CycleNumber();
+				data.iCaption.Copy(list[i]->Caption().Left(KMaxFullName));
+				data.iTime = list[i]->Time();
+				data.iFreeMemory = list[i]->MemoryFree();
+				data.iMemoryDelta = list[i]->MemoryDelta();
+				data.iPreviousCycleDiff = list[i]->MemoryFreePreviousCycle();
+				data.iChangeCount = list[i]->ChangeCount();
+				
+				TPckgBuf<TMemSpyMemoryTrackingCycleData> buffer(data);
+				aMessage.WriteL(1, buffer, offset);
+				}
+			
+			a0 = list.Count();
+			aMessage.WriteL(0, a0);
+
+		break;
+		}
+
+	case EMemSpyClientServerOpIsSwmtRunning:
+		{
+		TPckgBuf<TBool> running(iEngine.HelperSysMemTracker().IsActive());
+		aMessage.WriteL(0, running);
+		break;
+		}
+		
+	case EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodGet:
+	    {	    			   
+	    // Get current config
+	    TMemSpyEngineHelperSysMemTrackerConfig config;
+	    iEngine.HelperSysMemTracker().GetConfig( config );
+	    TInt time = config.iTimerPeriod.Int();
+	    TPckgBuf<TInt> tim(time);			            
+	    aMessage.WriteL( 0, tim );
+	    break;
+	    }
+	    
+	case EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesGet:
+		{
+		// Get current config
+		TMemSpyEngineHelperSysMemTrackerConfig config;
+		iEngine.HelperSysMemTracker().GetConfig( config );		
+		TInt categories = config.iEnabledCategories;		
+		TPckgBuf<TInt> ret( categories );
+		aMessage.WriteL( 0, ret );						
+		break;
+		}
+		
+	case EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterGet:
+		{
+		TMemSpyEngineHelperSysMemTrackerConfig config;
+		iEngine.HelperSysMemTracker().GetConfig( config );                 
+		TName threadNameFilter = config.iThreadNameFilter;
+		TPckgBuf<TName> name(threadNameFilter);
+		aMessage.WriteL( 0, name );
+		
+		break;
+		}
+		
+	case EMemSpyClientServerOpSystemWideMemoryTrackingHeapDumpGet:
+		{
+		TMemSpyEngineHelperSysMemTrackerConfig config;
+		iEngine.HelperSysMemTracker().GetConfig( config );		           
+		TBool heapDump = config.iDumpData;
+		TPckgBuf<TBool> heap(heapDump);			            
+		aMessage.WriteL( 0, heap );
+		break;
+		}
+						
+	case EMemSpyClientServerOpSystemWideMemoryTrackingModeGet:
+		{
+		TMemSpyEngineHelperSysMemTrackerConfig config;
+		iEngine.HelperSysMemTracker().GetConfig( config );	 		 
+		TPckgBuf<TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode> mod(config.iMode);			             		            
+		aMessage.WriteL(0, mod);	 			 		    
+		break;
+		}			
+		
+	case EMemSpyClientServerOpNotifyDeviceWideOperationProgress:
+		{
+		if (!Server().CurrentOperationTracker())
+			{
+			User::Leave(KErrNotReady);
+			}
+		
+		Server().CurrentOperationTracker()->AddNotificationL(aMessage);
+		break;
+		}
+		
+	case EMemSpyClientServerOpCancelDeviceWideOperation:
+		if (!Server().CurrentOperationTracker())
+			{
+			User::Leave(KErrNotReady);
+			}
+		
+		Server().CurrentOperationTracker()->Cancel();
+		break;
+	
+		
+	case EMemSpyClientServerOpGetEComCategoryCount:
+	    aMessage.WriteL(0, TPckgBuf<TInt>(iEngine.HelperECom().MdcaCount()));
+	    break;
+	    
+
+	case EMemSpyClientServerOpGetEComCategories:
+	    {
+	    TPckgBuf<TInt> a0;
+        aMessage.ReadL(0, a0);
+        TInt realCount = Min(a0(), iEngine.HelperECom().MdcaCount());
+        
+        for (TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyEComCategoryData))
+            {
+            TMemSpyEComCategoryData data;
+            data.iId.iUid = i;
+            data.iName.Copy(iEngine.HelperECom().At(i).Name());
+            data.iInterfaceCount = iEngine.HelperECom().At(i).MdcaCount();
+            
+            TPckgBuf<TMemSpyEComCategoryData> buffer(data);
+            aMessage.WriteL(1, buffer, offset);
+		}
+        
+        a0 = iEngine.HelperECom().MdcaCount();
+        aMessage.WriteL(0, a0);
+	    break;
+    }
+	    
+	case EMemSpyClientServerOpGetEComInterfaceCount:
+	    {
+	    TPckgBuf<TUid> a1;
+        aMessage.ReadL(1, a1);
+        TInt index = a1().iUid;
+        
+        if (index < 0 || index >= iEngine.HelperECom().MdcaCount())
+            {
+            User::Leave(KErrArgument);
+            }
+        
+        aMessage.WriteL(0, TPckgBuf<TInt>(iEngine.HelperECom().At(index).MdcaCount()));
+	    break;
+	    }
+	            
+	case EMemSpyClientServerOpGetEComInterfaces:
+	    {
+	    TPckgBuf<TInt> a0;
+        aMessage.ReadL(0, a0);
+        TInt realCount = Min(a0(), iEngine.HelperECom().MdcaCount());
+        
+        TPckgBuf<TUid> a1;
+        aMessage.ReadL(1, a1);
+        TInt categoryIndex = a1().iUid;
+        
+        if (categoryIndex < 0 || categoryIndex >= iEngine.HelperECom().MdcaCount())
+            {
+            User::Leave(KErrArgument);
+            }
+        
+        CMemSpyEngineEComCategory &category = iEngine.HelperECom().At(categoryIndex);
+        
+        for (TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyEComInterfaceData))
+            {
+            TMemSpyEComInterfaceData data;
+            data.iId.iUid = (TInt32) &category.At(i);
+            data.iCategoryId.iUid = categoryIndex;
+            data.iName.Copy(category.At(i).Name());
+            data.iImplementationCount = category.At(i).MdcaCount();
+            
+            TPckgBuf<TMemSpyEComInterfaceData> buffer(data);
+            aMessage.WriteL(2, buffer, offset);
+            }
+        
+        a0 = realCount;
+        aMessage.WriteL(0, a0);
+        
+        break;
+	    }
+	    
+	case EMemSpyClientServerOpGetEComImplementationCount:
+	    {
+	    TPckgBuf<TUid> a1;
+        aMessage.ReadL(1, a1);
+        CMemSpyEngineEComInterface* interface = reinterpret_cast<CMemSpyEngineEComInterface*>(a1().iUid);
+        
+        // TODO: check if it really is valid interface 
+        
+        aMessage.WriteL(0, TPckgBuf<TInt>(interface->MdcaCount()));
+	    break;
+	    }
+	                
+	case EMemSpyClientServerOpGetEComImplementations:
+	    {
+        TPckgBuf<TUid> a1;
+        aMessage.ReadL(1, a1);
+        CMemSpyEngineEComInterface* interface = reinterpret_cast<CMemSpyEngineEComInterface*>(a1().iUid);
+        
+        TPckgBuf<TInt> a0;
+        aMessage.ReadL(0, a0);
+        TInt realCount = Min(a0(), interface->MdcaCount());
+        
+        
+        for (TInt i=0, offset = 0; i<realCount; i++, offset += sizeof(TMemSpyEComImplementationData))
+            {
+            TMemSpyEComImplementationData data;
+            data.iName.Copy(interface->At(i).Info().DisplayName());
+            data.iImplementationUid = interface->At(i).Info().ImplementationUid();
+            data.iVersion = interface->At(i).Info().Version();
+            data.iDataType.Copy(interface->At(i).Info().DataType());
+            data.iOpaqueData.Copy(interface->At(i).Info().OpaqueData());
+            data.iDrive = interface->At(i).Info().Drive();
+            data.iRomOnly = interface->At(i).Info().RomOnly();
+            data.iRomBased = interface->At(i).Info().RomBased();
+            data.iVendorId = interface->At(i).Info().VendorId();
+            data.iDisabled = interface->At(i).Info().Disabled();
+            
+            TPckgBuf<TMemSpyEComImplementationData> buffer(data);
+            aMessage.WriteL(2, buffer, offset);
+            }
+        
+        a0 = realCount;
+        aMessage.WriteL(0, a0);
+        
+        break;
+	    }
+	    
+		}
+    }
+
+// ---------------------------------------------------------
+// DoCmdServiceL( const RMessage2& aMessage )
+// ---------------------------------------------------------
+//
+void CMemSpyEngineSession::DoCmdServiceL( const RMessage2& aMessage )
     {
     TInt error = KErrNone;
 
@@ -382,16 +1448,31 @@
 void CMemSpyEngineSession::HandleThreadAgnosticOpL( TInt aFunction, const RMessage2& aMessage )
     {
     TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - START" ) );
+    
     //
     if  ( aFunction ==  EMemSpyClientServerOpHeapInfoCompact )
         {
         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpHeapInfoCompact") );
-        iEngine.HelperHeap().OutputHeapInfoForDeviceL();
+        if (aMessage.Function() & KMemSpyOpFlagsAsyncOperation)
+        	{
+			StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EEntireDeviceHeapInfoCompact, aMessage);
+        	}
+        else
+        	{
+			iEngine.HelperHeap().OutputHeapInfoForDeviceL();
+        	}
         }
     else if ( aFunction ==  EMemSpyClientServerOpStackInfoCompact )
         {
         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpStackInfoCompact") );
-        iEngine.HelperStack().OutputStackInfoForDeviceL();
+        if (aMessage.Function() & KMemSpyOpFlagsAsyncOperation)
+			{
+			StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EEntireDeviceStackInfoCompact, aMessage);
+			}
+		else
+			{
+			iEngine.HelperStack().OutputStackInfoForDeviceL();
+			}
         }
     else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart )
         {
@@ -440,6 +1521,7 @@
         // And update config... which will leave if the config is invalid
         iEngine.HelperSysMemTracker().SetConfigL( config );
         }
+    
     else if ( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterSet )
         {
         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterSet") );
@@ -478,15 +1560,48 @@
         // And update config... which will leave if the config is invalid
         iEngine.HelperSysMemTracker().SetConfigL( config );
         }
+    else if( aFunction == EMemSpyClientServerOpSystemWideMemoryTrackingModeSet)
+    	{
+		TMemSpyEngineHelperSysMemTrackerConfig config;
+		iEngine.HelperSysMemTracker().GetConfig( config );
+		
+		TPckgBuf<TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode> mode;
+		aMessage.ReadL( 0, mode );
+		
+		config.iMode = mode();
+			
+		// And update config... which will leave if the config is invalid
+		iEngine.HelperSysMemTracker().SetConfigL( config );
+    	}
+    
     else if ( aFunction == EMemSpyClientServerOpSwitchOutputSinkTrace )
         {
         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSwitchOutputSinkTrace") );
-        iEngine.InstallSinkL( ESinkTypeDebug );
+        iEngine.InstallDebugSinkL();
         }
     else if ( aFunction == EMemSpyClientServerOpSwitchOutputSinkFile )
         {
         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSwitchOutputSinkFile") );
-        iEngine.InstallSinkL( ESinkTypeFile );
+        // Read file name from message.
+        TFileName fileName;
+        RBuf buf;
+		buf.CleanupClosePushL();
+		
+		TInt len = aMessage.GetDesLength( 0 );
+		if ( len > 0 )
+			{
+			buf.CreateL( len );
+			aMessage.ReadL( 0, buf, 0 );
+			
+			iEngine.InstallFileSinkL( buf );           
+			}
+		else
+			{
+			iEngine.InstallFileSinkL( KNullDesC );
+			}
+		
+		CleanupStack::PopAndDestroy( &buf );
+        
         }
     else if ( aFunction == EMemSpyClientServerOpEnumerateKernelContainer )
         {
@@ -517,6 +1632,46 @@
         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpDisableAknIconCache") );
         iEngine.HelperRAM().SetAknIconCacheStatusL( EFalse );
         }
+    else if ( aFunction == EMemSpyClientServerOpSummaryInfo )
+    	{
+		TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSummaryInfo") );
+		StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityGeneralSummary, aMessage);
+    	}
+    else if ( aFunction == EMemSpyClientServerOpSummaryInfoDetailed )
+		{
+		TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpSummaryInfoDetailed") );
+		StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityGeneralDetailed, aMessage);
+		}
+    else if ( aFunction == EMemSpyClientServerOpHeapInfo )
+		{
+		TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpHeapInfo") );
+		StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityHeapInfo, aMessage);
+		}
+    else if ( aFunction == EMemSpyClientServerOpHeapCellListing )
+		{
+		TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpHeapCellListing") );
+		StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityHeapCellListing, aMessage);
+		}
+    else if ( aFunction == EMemSpyClientServerOpHeapData )
+		{
+		TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpHeapData") );
+		StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityHeapData, aMessage);
+		}
+    else if ( aFunction == EMemSpyClientServerOpStackInfo )
+		{
+		TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpStackInfo") );
+		StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityStackInfo, aMessage);
+		}
+    else if ( aFunction == EMemSpyClientServerOpStackDataUser )
+		{
+		TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpStackDataUser") );
+		StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityStackDataUser, aMessage);
+		}
+    else if ( aFunction == EMemSpyClientServerOpStackDataKernel )
+		{
+		TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - EMemSpyClientServerOpStackDataKernel") );
+		StartDeviceWideOperationL(CMemSpyDeviceWideOperations::EPerEntityStackDataKernel, aMessage);
+		}
     else
         {
         TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - [device-wide operation] => invoking UI") );
@@ -526,7 +1681,108 @@
     TRACE( RDebug::Printf("[MemSpy] CMemSpyEngineSession::HandleThreadAgnosticOpL() - END" ) );
     }
 
+void CMemSpyEngineSession::StartDeviceWideOperationL(CMemSpyDeviceWideOperations::TOperation aOperation, const RMessage2& aMessage)
+	{
+	if (Server().CurrentOperationTracker())
+		{
+		User::Leave(KErrInUse);
+		}
+	
+	Server().SetCurrentOperationTracker(CMemSpyDwOperationTracker::NewL(aOperation, aMessage, Server()));
+	}
+
+
+
+
+
 
 
 
 
+CMemSpyDwOperationTracker* CMemSpyDwOperationTracker::NewL(CMemSpyDeviceWideOperations::TOperation aOperation, 
+		const RMessage2& aOperationMessage, CMemSpyEngineServer& aServer)
+	{
+	CMemSpyDwOperationTracker* self = new (ELeave) CMemSpyDwOperationTracker(aOperationMessage, aServer);
+	CleanupStack::PushL( self );
+	self->ConstructL(aOperation);
+	CleanupStack::Pop( self );
+	return self;
+	}
+	
+CMemSpyDwOperationTracker::~CMemSpyDwOperationTracker()
+	{
+	delete iOperation;
+	delete iPendingNotifications;
+	}
+
+CMemSpyDwOperationTracker::CMemSpyDwOperationTracker(const RMessage2& aOperationMessage, CMemSpyEngineServer& aServer) : 
+		iOperationMessage(aOperationMessage),
+		iServer(aServer),
+		iPendingNotifications(0),
+		iOperation(0),
+		iProgress(0)
+	{
+	}
+
+
+void CMemSpyDwOperationTracker::ConstructL(CMemSpyDeviceWideOperations::TOperation aOperation)
+	{
+	iPendingNotifications = new (ELeave) CArrayFixFlat<RMessage2>(3);
+	iOperation = CMemSpyDeviceWideOperations::NewL(iServer.Engine(), *this, aOperation);
+	}
+
+void CMemSpyDwOperationTracker::AddNotificationL(const RMessage2& aMessage)
+	{
+	iPendingNotifications->AppendL(aMessage);
+	}
+
+void CMemSpyDwOperationTracker::Cancel()
+	{
+	iOperation->Cancel();
+	}
+
+void CMemSpyDwOperationTracker::HandleDeviceWideOperationEvent(TEvent aEvent, TInt aParam1, const TDesC& aParam2)
+	{
+	switch( aEvent )
+		{
+	case MMemSpyDeviceWideOperationsObserver::EOperationCompleted:
+	case MMemSpyDeviceWideOperationsObserver::EOperationCancelled:
+		iServer.SetCurrentOperationTracker(0);
+		
+		for (TInt i=0; i<iPendingNotifications->Count(); i++)
+			{
+			iPendingNotifications->At(i).Complete(KErrCancel);
+			}
+		
+		if (iOperationMessage.Function() & KMemSpyOpFlagsAsyncOperation)
+			{
+			iOperationMessage.Complete(
+				aEvent == MMemSpyDeviceWideOperationsObserver::EOperationCompleted ? KErrNone : KErrCancel);
+			}
+		
+		iPendingNotifications->Reset();
+		
+		delete this;
+		break;
+		
+	case MMemSpyDeviceWideOperationsObserver::EOperationProgressEnd:
+		{
+		iProgress += aParam1;
+		for (TInt i=0; i<iPendingNotifications->Count(); i++)
+			{
+			TInt err;
+			TRAP(err, iPendingNotifications->At(i).WriteL(0, TPckgBuf<TInt>( iProgress * 100 / iOperation->TotalOperationSize() )));
+			TRAP(err, iPendingNotifications->At(i).WriteL(1, aParam2));
+			if (err != KErrNone)
+				{
+				// TODO: iPendingProgressNotifications->At(i).Panic()
+				}
+			iPendingNotifications->At(i).Complete(KErrNone);
+			}
+		iPendingNotifications->Reset();
+		break;
+		}
+		
+		}
+	
+	}
--- a/memspy/Engine/Source/DeviceWideOps/MemSpyDeviceWideOperations.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/DeviceWideOps/MemSpyDeviceWideOperations.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -286,9 +286,10 @@
         break;
     case EPerEntityHeapData:
         // Complete op by outputting kernel heap data
-        pType.Set( KMemSpyUiThreadNameKernel );
-        iObserver.HandleDeviceWideOperationEvent( MMemSpyDeviceWideOperationsObserver::EOperationProgressStart, 0, pType );
-        iEngine.HelperHeap().OutputHeapDataKernelL();
+        // TODO: Uncomment after kernel heap dump is fixed
+//        pType.Set( KMemSpyUiThreadNameKernel );
+//        iObserver.HandleDeviceWideOperationEvent( MMemSpyDeviceWideOperationsObserver::EOperationProgressStart, 0, pType );
+//        iEngine.HelperHeap().OutputHeapDataKernelL();
         break;
     default:
         break;
--- a/memspy/Engine/Source/Helpers/MemSpyEngineHelperActiveObject.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/Helpers/MemSpyEngineHelperActiveObject.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -68,7 +68,7 @@
 
 EXPORT_C CMemSpyEngineActiveObjectArray* CMemSpyEngineHelperActiveObject::ActiveObjectListL( const CMemSpyThread& aThread )
     {
-    //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListLC() - START");
+    //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListL() - START");
     CMemSpyEngineActiveObjectArray* array = CMemSpyEngineActiveObjectArray::NewLC();
 
     // Is the thread's process already suspended? If not, we need to do it now.
@@ -76,7 +76,7 @@
     const TBool isSuspended = ( iEngine.SuspendedProcessId() == parentProcessId );
     if  ( !isSuspended )
         {
-        //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListLC() - suspending process");
+        //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListL() - suspending process");
         iEngine.ProcessSuspendLC( parentProcessId );
         }
 
@@ -84,7 +84,7 @@
     CleanupStack::PushL( TCleanupItem( CleanupHeapWalk, this ) );
 
     // Get the thread info
-    //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListLC() - getting thread info...");
+    //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListL() - getting thread info...");
     TMemSpyDriverThreadInfo threadInfo;
     TInt err = iEngine.Driver().GetThreadInfo( aThread.Id(), threadInfo );
     User::LeaveIfError( err );
@@ -95,15 +95,15 @@
 #endif
 
     // Get the heap info - we need this for verification purposes
-    //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListLC() - getting heap info...");
+    //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListL() - getting heap info...");
     err = iEngine.Driver().GetHeapInfoUser( iHeapInfo, aThread.Id() );
     User::LeaveIfError( err );
-    //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListLC() - allocated cell header length is: %d", iHeapInfo.iHeapCellHeaderLengthAllocated);
+    //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListL() - allocated cell header length is: %d", iHeapInfo.iHeapCellHeaderLengthAllocated);
 
     // Do we have a ROM-based scheduler pointer?
-    if  ( scheduler != NULL && iHeapInfo.Type() == TMemSpyHeapInfo::ETypeRHeap )
+    if  ( scheduler != NULL && iHeapInfo.Type() != TMemSpyHeapInfo::ETypeUnknown )
         {
-        //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListLC() - scheduler: 0x%08x", scheduler);
+        //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListL() - scheduler: 0x%08x", scheduler);
 
         // Let's try to get the scheduler's heap cell...
         HBufC8* data = SchedulerHeapCellDataLC( scheduler, aThread.Id() );
@@ -114,14 +114,14 @@
         }
 
     // Tidy up
-    CleanupStack::PopAndDestroy(); // heap walk cleanup item
+    CleanupStack::PopAndDestroy(this); // heap walk cleanup item
     if  ( !isSuspended )
         {
-        iEngine.ProcessResume();
+        CleanupStack::PopAndDestroy(); // will resume the process we suspended earlier
         }
     //
     CleanupStack::Pop( array );
-    //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListLC() - END");
+    //RDebug::Printf("CMemSpyEngineHelperActiveObject::ActiveObjectListL() - END");
     return array;
     }
 
@@ -149,9 +149,9 @@
     //RDebug::Printf("CMemSpyEngineHelperActiveObject::SchedulerHeapCellDataLC() - err: %d, cellLength: %d, cellAllocationNumber: %d, cellType: %d", err, cellLength, cellAllocationNumber, cellType);
     User::LeaveIfError( err );
     
-    if  ( cellType == EMemSpyDriverGoodAllocatedCell )
+	if (cellType & EMemSpyDriverAllocatedCellMask)
         {
-        const TInt payloadLength = cellLength - iHeapInfo.AsRHeap().MetaData().HeaderSizeAllocated();
+        const TInt payloadLength = cellLength;
         HBufC8* data = HBufC8::NewLC( payloadLength );
         TPtr8 pData( data->Des() );
         //
@@ -281,9 +281,9 @@
     //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - err: %d, cellLength: %d, cellAllocationNumber: %d, cellType: %d", err, cellLength, cellAllocationNumber, cellType);
     User::LeaveIfError( err );
     
-    if  ( cellType == EMemSpyDriverGoodAllocatedCell )
+    if (cellType & EMemSpyDriverAllocatedCellMask)
         {
-        const TInt payloadLength = cellLength - iHeapInfo.AsRHeap().MetaData().HeaderSizeAllocated();
+        const TInt payloadLength = cellLength;
         //RDebug::Printf("CMemSpyEngineHelperActiveObject::ReadActiveObjectDataL() - payloadLength: %d", payloadLength);
 
         // const TInt payloadLength = Max( 512, cellLength - iHeapInfo.iHeapCellHeaderLengthAllocated ); // Prevent negative payload lengths?
--- a/memspy/Engine/Source/Helpers/MemSpyEngineHelperFbServ.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/Helpers/MemSpyEngineHelperFbServ.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -300,12 +300,11 @@
     // Get the heap info - we need this for verification purposes
     TMemSpyHeapInfo info;
     TInt err = iEngine.Driver().GetHeapInfoUser( info, aFbServThread.Id() );
-    if ( err == KErrNone && info.Type() != TMemSpyHeapInfo::ETypeRHeap )
+    if ( err == KErrNone && info.Type() == TMemSpyHeapInfo::ETypeUnknown )
         {
         err = KErrNotSupported;
         }
     User::LeaveIfError( err );
-    TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::LocateCFbTopHeapCellDataLC() - allocated cell header length is: %d", info.AsRHeap().MetaData().HeaderSizeAllocated() ));
 
     // Now walk the heap!
     err = iEngine.Driver().WalkHeapInit( aFbServThread.Id() );
@@ -324,13 +323,12 @@
             err = iEngine.Driver().WalkHeapNextCell( aFbServThread.Id(), cellType, cellAddress, cellLength, cellNestingLevel, cellAllocationNumber, cellHeaderSize, cellPayloadAddress );
             TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::LocateCFbTopHeapCellDataLC() - cellIndex[%d] err: %d, cellLength: %d, cellAllocationNumber: %d, cellType: %d", cellIndex, err, cellLength, cellAllocationNumber, cellType));
 
-            if  ( err == KErrNone && cellType == EMemSpyDriverGoodAllocatedCell )
+            if  ( err == KErrNone && (cellType & EMemSpyDriverAllocatedCellMask))
                 {
                 // We know we are looking for a relatively large *allocated* cell.
-                if  ( cellLength >= KFbServExpectedMinimumCellSize && cellLength <= KFbServExpectedMaximumCellSize && cellType == EMemSpyDriverGoodAllocatedCell )
+                if  ( cellLength >= KFbServExpectedMinimumCellSize && cellLength <= KFbServExpectedMaximumCellSize )
                     {
-                    const TInt payloadLength = cellLength - info.AsRHeap().MetaData().HeaderSizeAllocated();
-                    TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::LocateCFbTopHeapCellDataLC() - cell was long enough. Full cell len: %d, header: %d, therefore dataLen: %d", cellLength, info.AsRHeap().MetaData().HeaderSizeAllocated(), payloadLength));
+                    const TInt payloadLength = cellLength;
 
                     // This is *probably* the right cell. Let's get the data and check.
                     HBufC8* data = HBufC8::NewLC( payloadLength );
@@ -345,9 +343,9 @@
                         //iEngine.Sink().OutputBinaryDataL( KHeapDumpDataFormat, pData.Ptr(), (const TUint8*) cellAddress, pData.Length() );
                     
                         // Check the data
-                        const TUint heapSize = info.AsRHeap().ObjectData().Size();
-                        const TUint heapBaseAddress = (TUint) info.AsRHeap().ObjectData().Base();
-                        const TBool correctHeapCellLocated = VerifyCorrectHeapCellL( *data, cellAddress, cellPayloadAddress, heapBaseAddress, heapSize );
+                        const TUint heapMaxSize = info.AsRHeap().MetaData().iMaxHeapSize;
+                        const TUint heapBaseAddress = (TUint) info.AsRHeap().MetaData().ChunkBaseAddress();
+                        const TBool correctHeapCellLocated = VerifyCorrectHeapCellL( *data, cellAddress, cellPayloadAddress, heapBaseAddress, heapMaxSize );
                         TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::LocateCFbTopHeapCellDataLC() - verified: %d", correctHeapCellLocated));
 
                         if  ( correctHeapCellLocated )
@@ -404,7 +402,7 @@
     TInt err = iEngine.Driver().WalkHeapGetCellInfo( aCellAddress, cellType, cellLength, cellNestingLevel, cellAllocationNumber, cellHeaderSize, cellPayloadAddress );
     TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::ReadCObjectConInfoL() - err: %d, cellAddress: 0x%08x, cellLength: %d, cellAllocationNumber: %d, cellType: %d", err, aCellAddress, cellLength, cellAllocationNumber, cellType));
 
-    if  ( err == KErrNone && cellType == EMemSpyDriverGoodAllocatedCell )
+	if (err == KErrNone && (cellType & EMemSpyDriverAllocatedCellMask))
         {
         // Check that the cell size meets our expectations - it should be a CObjectCon cell.
         const TInt expectedCellSize = sizeof(CObjectCon*) + cellHeaderSize;
@@ -520,7 +518,7 @@
     TInt err = iEngine.Driver().WalkHeapGetCellInfo( aArrayCellAddress, cellType, cellLength, cellNestingLevel, cellAllocationNumber, cellHeaderSize, cellPayloadAddress );
     TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::LocateCFbTopHeapCellDataLC() - err: %d, cellAddress: 0x%08x, cellLength: %d, cellAllocationNumber: %d, cellType: %d", err, aArrayCellAddress, cellLength, cellAllocationNumber, cellType));
 
-    if  ( err == KErrNone && cellType == EMemSpyDriverGoodAllocatedCell )
+    if (err == KErrNone && (cellType & EMemSpyDriverAllocatedCellMask))
         {
         // Check that the cell size meets our expectations. 
         // The cell should be a very specific length
@@ -577,13 +575,13 @@
     }
 
 
-TBool CMemSpyEngineHelperFbServ::VerifyCorrectHeapCellL( const TDesC8& aData, TAny* aCellAddress, TAny* aPayloadAddress, TUint aHeapStartingAddress, TUint aHeapSize )
+TBool CMemSpyEngineHelperFbServ::VerifyCorrectHeapCellL( const TDesC8& aData, TAny* aCellAddress, TAny* aPayloadAddress, TUint aHeapStartingAddress, TUint aHeapMaxSize )
     {
     (void) aPayloadAddress;
     (void) aCellAddress;
-    TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::VerifyCorrectHeapCellL() - START - aDataLen: %d, aCellAddress: 0x%08x, aPayloadAddress: 0x%08x, aHeapStartingAddress: 0x%08x, aHeapSize: %d", aData.Length(), aCellAddress, aPayloadAddress, aHeapStartingAddress, aHeapSize ));
+    TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::VerifyCorrectHeapCellL() - START - aDataLen: %d, aCellAddress: 0x%08x, aPayloadAddress: 0x%08x, aHeapStartingAddress: 0x%08x, aHeapSize: %d", aData.Length(), aCellAddress, aPayloadAddress, aHeapStartingAddress, aHeapMaxSize ));
 
-    const TUint KFbServHeapCeilingAddress = aHeapStartingAddress + aHeapSize;
+    const TUint KFbServHeapCeilingAddress = aHeapStartingAddress + aHeapMaxSize;
 
     // Whether we can use this cell's data...
     TBool correctCell = EFalse;
@@ -746,7 +744,7 @@
     TInt err = iEngine.Driver().WalkHeapGetCellInfo( aCellAddress, cellType, cellLength, cellNestingLevel, cellAllocationNumber, cellHeaderSize, cellPayloadAddress );
     TRACE( RDebug::Printf("CMemSpyEngineHelperFbServ::GetBitmapObjectLC() - err: %d, cellAddress: 0x%08x, cellLength: %d, cellAllocationNumber: %d, cellType: %d", err, aCellAddress, cellLength, cellAllocationNumber, cellType));
 
-    if  ( err == KErrNone && cellType == EMemSpyDriverGoodAllocatedCell )
+    if (err == KErrNone && (cellType & EMemSpyDriverAllocatedCellMask))
         {
         // Check that the cell size meets our expectations - it should be a CBitmapObject, but without the additional "this" pointer
         // which we have tacked onto the object.
--- a/memspy/Engine/Source/Helpers/MemSpyEngineHelperHeap.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/Helpers/MemSpyEngineHelperHeap.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -45,6 +45,7 @@
 _LIT( KCellTypeBadAllocatedCellAddress,  "[Bad Allocated Cell Address]");
 _LIT( KCellTypeBadFreeCellAddress,       "[Bad Free Cell Address]     ");
 _LIT( KCellTypeBadFreeCellSize,          "[Bad Free Cell Size]        ");
+_LIT( KCellTypeBad,                      "[Bad Cell]                  ");
 _LIT( KCellTypeUnknown,                  "[Unknown!]                  ");
 _LIT( KCellListLineFormat, "%S cell: 0x%08x, cellLen: %8d, allocNum: %8d, nestingLev: %8d, cellData: 0x%08x, cellDataAddr: 0x%08x, headerSize: %02d");
 _LIT( KMemSpyMarkerHeapData, "<%SMEMSPY_HEAP_DATA_%03d>" );
@@ -104,7 +105,7 @@
         {
         UpdateSharedHeapInfoL( aThread.Process().Id(), aThread.Id(), heapInfo );
         }
-    if  ( error == KErrNone && heapInfo.Type() == TMemSpyHeapInfo::ETypeRHeap )
+    if  ( error == KErrNone && heapInfo.Type() != TMemSpyHeapInfo::ETypeUnknown )
         {
         // Get thread name for context
         const TFullName pName( aThread.FullName() );
@@ -159,36 +160,43 @@
                 TUint fourByteCellData = 0;
                 TPtrC pType(KNullDesC);
                 //
-                switch(cellType)
-                    {
-                case EMemSpyDriverGoodAllocatedCell:
-                    {
+				if (cellType & EMemSpyDriverAllocatedCellMask)
+					{
                     r = iEngine.Driver().WalkHeapReadCellData( cellAddress, cellData, 4 );
                     if  ( r == KErrNone )
                         {
                         fourByteCellData = DescriptorAsDWORD( cellData );
                         }
                     pType.Set(KCellTypeGoodAllocatedCell);
-                    break;
                     }
-                case EMemSpyDriverGoodFreeCell:
+				else if (cellType & EMemSpyDriverFreeCellMask)
+					{
                     pType.Set(KCellTypeGoodFreeCell);
-                    break;
-                case EMemSpyDriverBadAllocatedCellSize:
-                    pType.Set(KCellTypeBadAllocatedCellSize);
-                    break;
-                case EMemSpyDriverBadAllocatedCellAddress:
-                    pType.Set(KCellTypeBadAllocatedCellAddress);
-                    break;
-                case EMemSpyDriverBadFreeCellAddress:
-                    pType.Set(KCellTypeBadFreeCellAddress);
-                    break;
-                case EMemSpyDriverBadFreeCellSize:
-                    pType.Set(KCellTypeBadFreeCellSize);
-                    break;
-                default:
+					}
+				else if (cellType & EMemSpyDriverBadCellMask)
+					{
+					switch (cellType)
+						{
+					case EMemSpyDriverHeapBadAllocatedCellSize:
+						pType.Set(KCellTypeBadAllocatedCellSize);
+						break;
+					case EMemSpyDriverHeapBadAllocatedCellAddress:
+						pType.Set(KCellTypeBadAllocatedCellAddress);
+						break;
+					case EMemSpyDriverHeapBadFreeCellAddress:
+						pType.Set(KCellTypeBadFreeCellAddress);
+						break;
+					case EMemSpyDriverHeapBadFreeCellSize:
+						pType.Set(KCellTypeBadFreeCellSize);
+						break;
+					default:
+						pType.Set(KCellTypeBad);
+						break;
+						}
+					}
+				else
+					{
                     pType.Set(KCellTypeUnknown);
-                    break;
                     }
 
                 if  ( r == KErrNone )
@@ -241,31 +249,30 @@
     // Make sure the process is suspended for the entire time we are manipulating it's heap
     iEngine.ProcessSuspendLC( aThread.Process().Id() );
 
-    // Get the heap info, including free cell information
-    RArray<TMemSpyDriverFreeCell> freeCells;
-    CleanupClosePushL( freeCells );
+    // Get the heap info, including cell information
+    RArray<TMemSpyDriverCell> cells;
+    CleanupClosePushL( cells );
     TMemSpyHeapInfo heapInfo;
     TRACE( RDebug::Printf( "CMemSpyEngineHelperHeap::OutputHeapDataUserL() - checksum1: 0x%08x", heapInfo.AsRHeap().Statistics().StatsFree().Checksum() ) );
-    GetHeapInfoUserL( aThread.Process().Id(), aThread.Id(), heapInfo, &freeCells );
+    GetHeapInfoUserL(aThread.Process().Id(), aThread.Id(), heapInfo, &cells, ETrue);
     TRACE( RDebug::Printf( "CMemSpyEngineHelperHeap::OutputHeapDataUserL() - checksum2: 0x%08x", heapInfo.AsRHeap().Statistics().StatsFree().Checksum() ) );
 
     // Get the heap data
     const TFullName pName( aThread.FullName() );
-    OutputHeapDataUserL( aThread.Process().Id(), aThread.Id(), pName, heapInfo, aCreateDataStream, &freeCells );
-    CleanupStack::PopAndDestroy( &freeCells );
+    OutputHeapDataUserL( aThread.Process().Id(), aThread.Id(), pName, heapInfo, aCreateDataStream, &cells );
+    CleanupStack::PopAndDestroy( &cells );
 
     // Resume process
     CleanupStack::PopAndDestroy();
     }
 
 
-EXPORT_C void CMemSpyEngineHelperHeap::OutputHeapDataUserL( const TProcessId& aPid, const TThreadId& aTid, const TDesC& aThreadName, const TMemSpyHeapInfo& aInfo, const RArray<TMemSpyDriverFreeCell>* aFreeCells )
+EXPORT_C void CMemSpyEngineHelperHeap::OutputHeapDataUserL(const TProcessId& aPid, const TThreadId& aTid, const TDesC& aThreadName, const TMemSpyHeapInfo& aInfo, const RArray<TMemSpyDriverCell>* aCells)
     {
-    OutputHeapDataUserL( aPid, aTid, aThreadName, aInfo, ETrue, aFreeCells );
+    OutputHeapDataUserL(aPid, aTid, aThreadName, aInfo, ETrue, aCells);
     }
 
-
-void CMemSpyEngineHelperHeap::OutputHeapDataUserL( const TProcessId& aPid, const TThreadId& aTid, const TDesC& aThreadName, const TMemSpyHeapInfo& aInfo, TBool aCreateDataStream, const RArray<TMemSpyDriverFreeCell>* aFreeCells )
+void CMemSpyEngineHelperHeap::OutputHeapDataUserL( const TProcessId& aPid, const TThreadId& aTid, const TDesC& aThreadName, const TMemSpyHeapInfo& aInfo, TBool aCreateDataStream, const RArray<TMemSpyDriverCell>* aCells )
     {
     TBuf<KMaxFullName + 100> printFormat;
 
@@ -291,7 +298,7 @@
     iEngine.Sink().OutputPrefixSetFormattedLC( KMemSpyPrefixHeapData, &aThreadName );
 
     // Info section
-    OutputHeapInfoL( aInfo, aThreadName, aFreeCells );
+    OutputHeapInfoL( aInfo, aThreadName, aCells );
 
     // Code segments (needed for map file reading...)
     _LIT(KCellListCodeSegInfoFormat, "CodeSegs - ");
@@ -315,14 +322,25 @@
     TRACE( RDebug::Printf( "CMemSpyEngineHelperHeap::OutputHeapDataUserL() - checksum: 0x%08x", checksum ) );
 
     TInt r = iEngine.Driver().GetHeapData( aTid, checksum, pData, readAddress, remaining );
-    if  ( r == KErrNone )
+	TUint prevEndAddress = readAddress + pData.Length();
+    if (r == KErrNone)
         {
-        while ( r == KErrNone )
+        while (r == KErrNone)
             {
+			if (readAddress > prevEndAddress)
+				{
+				// We've hit a discontinuity, ie one or more unmapped pages
+				_LIT(KBreak, "........");
+				iEngine.Sink().OutputLineL(KBreak);
+				}
             _LIT(KHeapDumpDataFormat, "%S");
-            iEngine.Sink().OutputBinaryDataL( KHeapDumpDataFormat, pData.Ptr(), (const TUint8*) readAddress, pData.Length() );
-            if  ( remaining > 0 )
-                r = iEngine.Driver().GetHeapDataNext( aTid, pData, readAddress, remaining );
+            iEngine.Sink().OutputBinaryDataL(KHeapDumpDataFormat, pData.Ptr(), (const TUint8*) readAddress, pData.Length());
+			readAddress += pData.Length();
+            if (remaining > 0)
+				{
+				prevEndAddress = readAddress;
+                r = iEngine.Driver().GetHeapDataNext(aTid, pData, readAddress, remaining);
+				}
             else
                 break;
             }
@@ -365,11 +383,9 @@
 
 
 
-
-
-EXPORT_C void CMemSpyEngineHelperHeap::OutputHeapInfoL( const TMemSpyHeapInfo& aInfo, const TDesC& aThreadName, const RArray<TMemSpyDriverFreeCell>* aFreeCells )
-    {
-    CMemSpyEngineOutputList* list = NewHeapSummaryExtendedLC( aInfo, aFreeCells );
+EXPORT_C void CMemSpyEngineHelperHeap::OutputHeapInfoL( const TMemSpyHeapInfo& aInfo, const TDesC& aThreadName, const RArray<TMemSpyDriverCell>* aCells )
+	{
+    CMemSpyEngineOutputList* list = NewHeapSummaryExtendedLC(aInfo, aCells);
 
     // Format the thread name according to upper/lower case request parameters
     _LIT( KOverallCaption1, "HEAP INFO FOR THREAD '%S'");
@@ -416,7 +432,6 @@
     {
     const TMemSpyHeapInfoRHeap& rHeapInfo = aInfo.AsRHeap();
     const TMemSpyHeapMetaDataRHeap& rHeapMetaData = rHeapInfo.MetaData();
-    const TMemSpyHeapObjectDataRHeap& rHeapObjectData = rHeapInfo.ObjectData();
     const TMemSpyHeapStatisticsRHeap& rHeapStats = rHeapInfo.Statistics();
 
     // Example:
@@ -456,20 +471,20 @@
                                          aIndex,
                                          aInfo.Tid(),
                                          rHeapMetaData.ChunkHandle(),
-                                         rHeapObjectData.Base(),
-                                         rHeapObjectData.Size(),
-                                         rHeapObjectData.iMinLength,
-                                         rHeapObjectData.iMaxLength,
-                                         rHeapObjectData.iFree.next,
-                                         rHeapObjectData.iFree.len,
+                                         rHeapMetaData.iAllocatorAddress,
+                                         rHeapMetaData.iHeapSize,
+                                         rHeapMetaData.iMinHeapSize,
+                                         rHeapMetaData.iMaxHeapSize,
+                                         NULL, // there's no longer a free list so we can't return the next ptr
+                                         0, // there's no longer a free list so we can't return it's length
                                          rHeapStats.StatsFree().TypeCount(),
                                          rHeapStats.StatsFree().TypeSize(),
                                          rHeapStats.StatsFree().SlackSpaceCellSize(),
                                          rHeapStats.StatsFree().LargestCellSize(),
                                          rHeapStats.StatsAllocated().LargestCellSize(),
-                                         rHeapObjectData.iCellCount,
-                                         rHeapObjectData.iMinCell,
-                                         rHeapObjectData.iTotalAllocSize,
+                                         rHeapStats.StatsAllocated().TypeCount(),
+                                         0, // min cell no longer makes sense
+                                         rHeapStats.StatsAllocated().TypeSize(),
                                          rHeapMetaData.IsSharedHeap(),
                                          &KFmtFields,
                                          aIndex
@@ -519,7 +534,7 @@
         // Get kernel heap info
         GetHeapInfoKernelL( info );
 
-        if ( info.Type() == TMemSpyHeapInfo::ETypeRHeap )
+        if ( info.Type() != TMemSpyHeapInfo::ETypeUnknown )
             {
             TName threadName;
             MemSpyEngineUtils::GetKernelHeapThreadAndProcessNames( threadName, processName );
@@ -546,7 +561,7 @@
                     {
                     UpdateSharedHeapInfoL( process.Id(), thread.Id(), info );
                     }
-                if  ( error == KErrNone && info.Type() == TMemSpyHeapInfo::ETypeRHeap )
+                if  ( error == KErrNone && info.Type() != TMemSpyHeapInfo::ETypeUnknown )
                     {
                     OutputCSVEntryL( index++, info, threadName, processName );
                     }
@@ -577,16 +592,21 @@
 
 
 
-EXPORT_C void CMemSpyEngineHelperHeap::GetHeapInfoUserL( const TProcessId& aProcess, const TThreadId& aThread, TMemSpyHeapInfo& aInfo, RArray<TMemSpyDriverFreeCell>* aFreeCells )
+EXPORT_C void CMemSpyEngineHelperHeap::GetHeapInfoUserL(const TProcessId& aProcess, const TThreadId& aThread, TMemSpyHeapInfo& aInfo, RArray<TMemSpyDriverFreeCell>* aFreeCells)
+    {
+	GetHeapInfoUserL(aProcess, aThread, aInfo, aFreeCells, EFalse);
+	}
+
+EXPORT_C void CMemSpyEngineHelperHeap::GetHeapInfoUserL(const TProcessId& aProcess, const TThreadId& aThread, TMemSpyHeapInfo& aInfo, RArray<TMemSpyDriverCell>* aCells, TBool aCollectAllocatedCellsAsWellAsFree)
     {
     iEngine.ProcessSuspendLC( aProcess );
     TRACE( RDebug::Printf( "CMemSpyEngineHelperHeap::GetHeapInfoUserL() - checksum1: 0x%08x", aInfo.AsRHeap().Statistics().StatsFree().Checksum() ) );
     
     TInt r = KErrNone;
     //
-    if  ( aFreeCells )
+    if  (aCells)
         {
-        r = iEngine.Driver().GetHeapInfoUser( aInfo, aThread, *aFreeCells );
+        r = iEngine.Driver().GetHeapInfoUser( aInfo, aThread, *aCells, aCollectAllocatedCellsAsWellAsFree);
         }
     else
         {
@@ -736,9 +756,11 @@
     _LIT(KHeaderDump, "Heap Data");
     iEngine.Sink().OutputSectionHeadingL( KHeaderDump, '-' );
 
-    _LIT(KHeapDumpDataFormat, "%S");
+    /*TOMSCI TODO this stuff needs fixing
+	_LIT(KHeapDumpDataFormat, "%S");
     const TUint8* heapBaseAddress = info.AsRHeap().ObjectData().Base();
     iEngine.Sink().OutputBinaryDataL( KHeapDumpDataFormat, data->Ptr(), heapBaseAddress, data->Length() );
+	*/
 
     CleanupStack::PopAndDestroy(); // clear prefix
     CleanupStack::PopAndDestroy( data );
@@ -795,22 +817,29 @@
         _LIT( KItem0_Type_Unknown, "Unknown" );
         list->AddItemL( KItem0, KItem0_Type_Unknown );
         }
-    else if ( aInfo.Type() == TMemSpyHeapInfo::ETypeRHeap )
+    else
         {
         const TMemSpyHeapInfoRHeap& rHeap = aInfo.AsRHeap();
         const TMemSpyHeapMetaDataRHeap& metaData = rHeap.MetaData();
-        const TMemSpyHeapObjectDataRHeap& objectData = rHeap.ObjectData();
         const TMemSpyHeapStatisticsRHeap& statistics = rHeap.Statistics();
 
         _LIT( KItem0_Type_RHeap, "RHeap" );
-        list->AddItemL( KItem0, KItem0_Type_RHeap );
+        _LIT( KItem0_Type_RHybridHeap, "RHybridHeap" );
+		if (aInfo.Type() == TMemSpyHeapInfo::ETypeRHeap)
+			{
+	        list->AddItemL( KItem0, KItem0_Type_RHeap );
+			}
+		else
+			{
+	        list->AddItemL( KItem0, KItem0_Type_RHybridHeap );
+			}
 
         // Heap size is the size of the heap minus the size of the embedded (in-place) RHeap. 
         _LIT( KItem1, "Heap size" );
-        list->AddItemL( KItem1, objectData.Size() );
+        list->AddItemL(KItem1, metaData.iHeapSize);
 
-        _LIT( KItem8b, "Heap base address" );
-        list->AddItemHexL( KItem8b, (TUint) objectData.Base() );
+        _LIT( KItem8b, "Allocator address" );
+        list->AddItemHexL( KItem8b, (TUint)metaData.iAllocatorAddress );
         
         _LIT( KItem1b, "Shared" );
         list->AddItemYesNoL( KItem1b, metaData.IsSharedHeap() );
@@ -845,34 +874,21 @@
         // Fragmentation is a measurement of free space scattered throughout the heap, but ignoring
         // any slack space at the end (which can often be recovered, to the granularity of one page of ram)
         _LIT( KItem8a, "Fragmentation" );
-        list->AddItemPercentageL( KItem8a, objectData.Size(), ( statistics.StatsFree().TypeSize()  - statistics.StatsFree().SlackSpaceCellSize() ) );
-
-        _LIT( KItem13, "Header size (A)" );
-        list->AddItemL( KItem13, metaData.HeaderSizeAllocated() );
-
-        _LIT( KItem14, "Header size (F)" );
-        list->AddItemL( KItem14, metaData.HeaderSizeFree() );
+        list->AddItemPercentageL( KItem8a, metaData.iHeapSize, ( statistics.StatsFree().TypeSize()  - statistics.StatsFree().SlackSpaceCellSize() ) );
 
-        _LIT( KItem9a, "Overhead (alloc)" );
-        const TInt allocOverhead = metaData.HeaderSizeAllocated() * statistics.StatsAllocated().TypeCount();
-        list->AddItemL( KItem9a, allocOverhead );
-
-        _LIT( KItem9b, "Overhead (free)" );
-        const TInt freeOverhead = metaData.HeaderSizeFree() * statistics.StatsFree().TypeCount();
-        list->AddItemL( KItem9b, freeOverhead );
 
         _LIT( KItem9c, "Overhead (total)" );
-        const TInt totalOverhead = freeOverhead + allocOverhead;
+		const TInt totalOverhead = metaData.iHeapSize - statistics.StatsAllocated().TypeSize();
         list->AddItemL( KItem9c, totalOverhead );
 
         _LIT( KItem9d, "Overhead" );
-        list->AddItemPercentageL( KItem9d, objectData.Size(), totalOverhead  );
+        list->AddItemPercentageL( KItem9d, metaData.iHeapSize, totalOverhead  );
 
         _LIT( KItem10, "Min. length" );
-        list->AddItemL( KItem10, objectData.iMinLength );
+        list->AddItemL( KItem10, metaData.iMinHeapSize );
 
         _LIT( KItem11, "Max. length" );
-        list->AddItemL( KItem11, objectData.iMaxLength );
+        list->AddItemL( KItem11, metaData.iMaxHeapSize );
 
         _LIT( KItem12, "Debug Allocator Library" );
         list->AddItemYesNoL( KItem12, metaData.IsDebugAllocator() );
@@ -882,23 +898,78 @@
     }
 
 
-EXPORT_C CMemSpyEngineOutputList* CMemSpyEngineHelperHeap::NewHeapSummaryExtendedLC( const TMemSpyHeapInfo& aInfo, const RArray<TMemSpyDriverFreeCell>* aFreeCells )
-    {
+EXPORT_C CMemSpyEngineOutputList* CMemSpyEngineHelperHeap::NewHeapSummaryExtendedLC( const TMemSpyHeapInfo& aInfo, const RArray<TMemSpyDriverCell>* aCells )
+	{
     CMemSpyEngineOutputList* list = CMemSpyEngineOutputList::NewLC( iEngine.Sink() );
     //
     AppendMetaDataL( aInfo, *list );
-    AppendObjectDataL( aInfo, *list );
     AppendStatisticsL( aInfo, *list );
     //
-    if  ( aFreeCells )
+    if  ( aCells )
         {
-        AppendFreeCellsL( *aFreeCells, *list );
+        AppendCellsL( *aCells, *list );
         }
     //
     return list;
     }
 
 
+//cigasto: not formatted - raw heap info 
+EXPORT_C TMemSpyHeapData CMemSpyEngineHelperHeap::NewHeapRawInfo( const TMemSpyHeapInfo& aInfo )
+	{
+	_LIT(KUnknown, "Unknown");
+	TMemSpyHeapData list;
+	list.iType.Copy(KUnknown);
+
+	// Heap type	
+	if (aInfo.Type() != TMemSpyHeapInfo::ETypeUnknown)
+		{
+		const TMemSpyHeapInfoRHeap& rHeap = aInfo.AsRHeap();
+		const TMemSpyHeapMetaDataRHeap& metaData = rHeap.MetaData();
+		const TMemSpyHeapStatisticsRHeap& statistics = rHeap.Statistics();
+
+		_LIT(KRHeap, "RHeap");
+		_LIT(KRHybridHeap, "RHybridHeap");
+		switch (aInfo.Type())
+			{
+			case TMemSpyHeapInfo::ETypeRHeap:
+				list.iType.Copy(KRHeap);
+				break;
+			case TMemSpyHeapInfo::ETypeRHybridHeap:
+				list.iType.Copy(KRHybridHeap);
+				break;
+			default:
+				break;
+			}
+
+	    // Heap size is the total amount of memory committed to the heap, which includes the size of the embedded (in-place) RHeap/RHybridHeap.
+	    list.iSize = metaData.iHeapSize;
+	    list.iBaseAddress = (TUint)metaData.iAllocatorAddress; // TODO we can't do the base address any more, allocator address is the closest thing
+	    list.iShared = metaData.IsSharedHeap();
+	    list.iChunkSize = metaData.ChunkSize();
+	    list.iAllocationsCount = statistics.StatsAllocated().TypeCount();
+	    list.iFreeCount = statistics.StatsFree().TypeCount();
+	    list.iBiggestAllocation = statistics.StatsAllocated().LargestCellSize();
+	    list.iBiggestFree = statistics.StatsFree().LargestCellSize();
+	    list.iTotalAllocations =  statistics.StatsAllocated().TypeSize();	        
+	    list.iTotalFree =  statistics.StatsFree().TypeSize();
+	    list.iSlackFreeSpace = statistics.StatsFree().SlackSpaceCellSize();
+	    list.iFragmentation = statistics.StatsFree().TypeSize() - statistics.StatsFree().SlackSpaceCellSize(); //to calculate percentage value use iSize as 100% value
+	    list.iHeaderSizeA = 0; //metaData.HeaderSizeAllocated();
+	    list.iHeaderSizeF = 0; //metaData.HeaderSizeFree();
+	    TInt allocOverhead = rHeap.Overhead(); //metaData.HeaderSizeAllocated() * statistics.StatsAllocated().TypeCount();
+	    list.iAllocationOverhead = allocOverhead;
+	    //TInt freeOverhead = metaData.HeaderSizeFree() * statistics.StatsFree().TypeCount();
+	    list.iFreeOverhead = 0; // TODO there is no way of calculating this
+	    list.iTotalOverhead = allocOverhead; // freeOverhead + allocOverhead
+	    list.iOverhead = allocOverhead; //freeOverhead + allocOverhead; //to calculate percentage value use iSize as 100% value    
+	    list.iMinLength = metaData.iMinHeapSize;
+	    list.iMaxLength = metaData.iMaxHeapSize;
+	    list.iDebugAllocatorLibrary = metaData.IsDebugAllocator();
+		}
+
+	return list;
+	}
 
 
 
@@ -952,7 +1023,7 @@
 
     // Type
     _LIT( KMetaData_Type,  "Type:" );
-    if ( aInfo.Type() != TMemSpyHeapInfo::ETypeRHeap )
+    if ( aInfo.Type() == TMemSpyHeapInfo::ETypeUnknown )
         {
         _LIT( KMetaData_Type_Unknown,  "Unknown" );
         aList.AddItemL( KMetaData_Type, KMetaData_Type_Unknown );
@@ -963,15 +1034,23 @@
     
         // Type
         _LIT( KMetaData_Type_RHeap,  "Symbian OS RHeap" );
-        aList.AddItemL( KMetaData_Type, KMetaData_Type_RHeap );
+        _LIT( KMetaData_Type_RHybridHeap,  "Symbian OS RHybridHeap" );
+		if (aInfo.Type() == TMemSpyHeapInfo::ETypeRHeap)
+			{
+	        aList.AddItemL( KMetaData_Type, KMetaData_Type_RHeap );
+			}
+		else
+			{
+			aList.AddItemL( KMetaData_Type, KMetaData_Type_RHybridHeap );
+			}
 
         // VTable
-        _LIT( KMetaData_VTable,  "VTable:" );
-        aList.AddItemHexL( KMetaData_VTable, metaData.VTable() );
+        //_LIT( KMetaData_VTable,  "VTable:" );
+        //aList.AddItemHexL( KMetaData_VTable, metaData.VTable() );
 
         // Object size
-        _LIT( KMetaData_ObjectSize,  "Object Size:" );
-        aList.AddItemL( KMetaData_ObjectSize, metaData.ClassSize() );
+        //_LIT( KMetaData_ObjectSize,  "Object Size:" );
+        //aList.AddItemL( KMetaData_ObjectSize, metaData.ClassSize() );
 
         // Chunk name
         _LIT( KMetaData_ChunkName,  "Chunk Name:" );
@@ -990,14 +1069,6 @@
         _LIT( KMetaData_DebugAllocator,  "Debug Allocator:" );
         aList.AddItemYesNoL( KMetaData_DebugAllocator, metaData.IsDebugAllocator() );
 
-        // Cell header overhead (free cells)
-        _LIT( KMetaData_CellHeaderOverheadFree,  "Overhead (Free):" );
-        aList.AddItemL( KMetaData_CellHeaderOverheadFree, metaData.HeaderSizeFree() );
-
-        // Cell header overhead (allocated cells)
-        _LIT( KMetaData_CellHeaderOverheadAlloc,  "Overhead (Alloc):" );
-        aList.AddItemL( KMetaData_CellHeaderOverheadAlloc, metaData.HeaderSizeAllocated() );
-
         // Shared Heap
         _LIT( KMetaData_Shared,  "Shared:" );
         aList.AddItemYesNoL( KMetaData_Shared, metaData.IsSharedHeap() );
@@ -1009,90 +1080,9 @@
     aList.AddBlankItemL( 1 );
     }
 
-
-void CMemSpyEngineHelperHeap::AppendObjectDataL( const TMemSpyHeapInfo& aInfo, CMemSpyEngineOutputList& aList )
-    {
-    if ( aInfo.Type() == TMemSpyHeapInfo::ETypeRHeap )
-        {
-        const TMemSpyHeapInfoRHeap& rHeap = aInfo.AsRHeap();
-        const TMemSpyHeapObjectDataRHeap& objectData = rHeap.ObjectData();
-
-        // Make caption
-        _LIT( KOverallCaption1, "RAllocator" );
-        aList.AddItemL( KOverallCaption1 );
-        aList.AddUnderlineForPreviousItemL( '=', 0 );
-
-        // RAllocator
-        _LIT( KObjectData_RAllocator_iAccessCount,  "RAllocator::iAccessCount" );
-        aList.AddItemL( KObjectData_RAllocator_iAccessCount, objectData.iAccessCount );
-        _LIT( KObjectData_RAllocator_iHandleCount,  "RAllocator::iHandleCount" );
-        aList.AddItemL( KObjectData_RAllocator_iHandleCount, objectData.iHandleCount );
-        _LIT( KObjectData_RAllocator_iHandles,  "RAllocator::iHandles" );
-        aList.AddItemL( KObjectData_RAllocator_iHandles, objectData.iHandles );
-        _LIT( KObjectData_RAllocator_iFlags,  "RAllocator::iFlags" );
-        aList.AddItemHexL( KObjectData_RAllocator_iFlags, objectData.iFlags );
-        _LIT( KObjectData_RAllocator_iCellCount,  "RAllocator::iCellCount" );
-        aList.AddItemL( KObjectData_RAllocator_iCellCount, objectData.iCellCount );
-        _LIT( KObjectData_RAllocator_iTotalAllocSize,  "RAllocator::iTotalAllocSize" );
-        aList.AddItemL( KObjectData_RAllocator_iTotalAllocSize, objectData.iTotalAllocSize );
-
-        aList.AddBlankItemL( 1 );
-
-        // Make caption
-        _LIT( KOverallCaption2, "RHeap" );
-        aList.AddItemL( KOverallCaption2 );
-        aList.AddUnderlineForPreviousItemL( '=', 0 );
-
-        // RHeap
-        _LIT( KObjectData_RHeap_iMinLength,  "RHeap::iMinLength" );
-        aList.AddItemL( KObjectData_RHeap_iMinLength, objectData.iMinLength );
-        _LIT( KObjectData_RHeap_iMaxLength,  "RHeap::iMaxLength" );
-        aList.AddItemL( KObjectData_RHeap_iMaxLength, objectData.iMaxLength );
-        _LIT( KObjectData_RHeap_iOffset,  "RHeap::iOffset" );
-        aList.AddItemL( KObjectData_RHeap_iOffset, objectData.iOffset );
-        _LIT( KObjectData_RHeap_iGrowBy,  "RHeap::iGrowBy" );
-        aList.AddItemL( KObjectData_RHeap_iGrowBy, objectData.iGrowBy );
-        _LIT( KObjectData_RHeap_iChunkHandle,  "RHeap::iChunkHandle" );
-        aList.AddItemHexL( KObjectData_RHeap_iChunkHandle, objectData.iChunkHandle );
-        _LIT( KObjectData_RHeap_iBase,  "RHeap::iBase" );
-        aList.AddItemL( KObjectData_RHeap_iBase, objectData.iBase );
-        _LIT( KObjectData_RHeap_iTop,  "RHeap::iTop" );
-        aList.AddItemL( KObjectData_RHeap_iTop, objectData.iTop );
-        _LIT( KObjectData_RHeap_iAlign,  "RHeap::iAlign" );
-        aList.AddItemL( KObjectData_RHeap_iAlign, objectData.iAlign );
-        _LIT( KObjectData_RHeap_iMinCell,  "RHeap::iMinCell" );
-        aList.AddItemL( KObjectData_RHeap_iMinCell, objectData.iMinCell );
-        _LIT( KObjectData_RHeap_iPageSize,  "RHeap::iPageSize" );
-        aList.AddItemL( KObjectData_RHeap_iPageSize, objectData.iPageSize );
-        _LIT( KObjectData_RHeap_iFree_next,  "RHeap::iFree.next" );
-        aList.AddItemL( KObjectData_RHeap_iFree_next, objectData.iFree.next );
-        _LIT( KObjectData_RHeap_iFree_len,  "RHeap::iFree.len" );
-        aList.AddItemL( KObjectData_RHeap_iFree_len, objectData.iFree.len );
-        _LIT( KObjectData_RHeap_iNestingLevel,  "RHeap::iNestingLevel" );
-        aList.AddItemL( KObjectData_RHeap_iNestingLevel, objectData.iNestingLevel );
-        _LIT( KObjectData_RHeap_iAllocCount,  "RHeap::iAllocCount" );
-        aList.AddItemL( KObjectData_RHeap_iAllocCount, objectData.iAllocCount );
-        _LIT( KObjectData_RHeap_iFailType,  "RHeap::iFailType" );
-        aList.AddItemL( KObjectData_RHeap_iFailType, (TInt) objectData.iFailType );
-        _LIT( KObjectData_RHeap_iFailRate,  "RHeap::iFailRate" );
-        aList.AddItemL( KObjectData_RHeap_iFailRate, objectData.iFailRate );
-        _LIT( KObjectData_RHeap_iFailed,  "RHeap::iFailed" );
-        aList.AddItemTrueFalseL( KObjectData_RHeap_iFailed, objectData.iFailed );
-        _LIT( KObjectData_RHeap_iFailAllocCount,  "RHeap::iFailAllocCount" );
-        aList.AddItemL( KObjectData_RHeap_iFailAllocCount, objectData.iFailAllocCount );
-        _LIT( KObjectData_RHeap_iRand,  "RHeap::iRand" );
-        aList.AddItemL( KObjectData_RHeap_iRand, objectData.iRand );
-        _LIT( KObjectData_RHeap_iTestData,  "RHeap::iTestData" );
-        aList.AddItemL( KObjectData_RHeap_iTestData, objectData.iTestData );
-
-        aList.AddBlankItemL( 1 );
-        }
-    }
-
-
 void CMemSpyEngineHelperHeap::AppendStatisticsL( const TMemSpyHeapInfo& aInfo, CMemSpyEngineOutputList& aList )
     {
-    if ( aInfo.Type() == TMemSpyHeapInfo::ETypeRHeap )
+    if (aInfo.Type() != TMemSpyHeapInfo::ETypeUnknown)
         {
         const TMemSpyHeapInfoRHeap& rHeap = aInfo.AsRHeap();
         const TMemSpyHeapStatisticsRHeap& rHeapStats = rHeap.Statistics();
@@ -1112,10 +1102,13 @@
         aList.AddItemL( KStatsData_CellSize, rHeapStats.StatsFree().TypeSize() );
         aList.AddItemL( KStatsData_LargestCellAddress, rHeapStats.StatsFree().LargestCellAddress() );
         aList.AddItemL( KStatsData_LargestCellSize, rHeapStats.StatsFree().LargestCellSize() );
-        _LIT( KStatsData_Free_SlackCellAddress,  "Slack:" );
-        aList.AddItemL( KStatsData_Free_SlackCellAddress, rHeapStats.StatsFree().SlackSpaceCellAddress() );
-        _LIT( KStatsData_Free_SlackCellSize,  "Slack size:" );
-        aList.AddItemL( KStatsData_Free_SlackCellSize, rHeapStats.StatsFree().SlackSpaceCellSize() );
+		if (aInfo.Type() == TMemSpyHeapInfo::ETypeRHeap)
+			{
+			_LIT( KStatsData_Free_SlackCellAddress,  "Slack:" );
+			aList.AddItemL( KStatsData_Free_SlackCellAddress, rHeapStats.StatsFree().SlackSpaceCellAddress() );
+			_LIT( KStatsData_Free_SlackCellSize,  "Slack size:" );
+			aList.AddItemL( KStatsData_Free_SlackCellSize, rHeapStats.StatsFree().SlackSpaceCellSize() );
+			}
         _LIT( KStatsData_Free_Checksum,  "Checksum:" );
         aList.AddItemHexL( KStatsData_Free_Checksum, rHeapStats.StatsFree().Checksum() );
 
@@ -1132,44 +1125,61 @@
         aList.AddItemL( KStatsData_LargestCellSize, rHeapStats.StatsAllocated().LargestCellSize() );
 
         aList.AddBlankItemL( 1 );
-
-        // Common
-        _LIT( KOverallCaption3, "Common Statistics" );
-        aList.AddItemL( KOverallCaption3 );
-        aList.AddUnderlineForPreviousItemL( '=', 0 );
-
-        _LIT( KStatsData_Common_TotalCellCount,  "Total cell count:" );
-        aList.AddItemL( KStatsData_Common_TotalCellCount, rHeapStats.StatsCommon().TotalCellCount() );
-
-        _LIT( KStatsData_Common_TotalSize,  "Total cell size:" );
-        aList.AddItemL( KStatsData_Common_TotalSize, rHeapStats.StatsAllocated().TypeSize() + rHeapStats.StatsFree().TypeSize() );
-
-        aList.AddBlankItemL( 1 );
-        }
+         }
     }
 
 
-void CMemSpyEngineHelperHeap::AppendFreeCellsL( const RArray<TMemSpyDriverFreeCell>& aFreeCells, CMemSpyEngineOutputList& aList )
+void CMemSpyEngineHelperHeap::AppendCellsL(const RArray<TMemSpyDriverCell>& aCells, CMemSpyEngineOutputList& aList)
     {
-    // Free space
+    // For reasons that may or may not turn out to be sensible, we separate free and allocated cells in the output data
+
     _LIT( KOverallCaption1, "Free Cell List" );
     aList.AddItemL( KOverallCaption1 );
     aList.AddUnderlineForPreviousItemL( '=', 0 );
 
     TBuf<128> caption;
     _LIT( KCaptionFormat, "FC %04d" );
-    _LIT( KValueFormat, "0x%08x %8d %1d" );
+    _LIT( KValueFormat, "0x%08x %8d %d" );
 
-    const TInt count = aFreeCells.Count();
+	TBool foundAllocatedCells = EFalse;
+    const TInt count = aCells.Count();
     for( TInt i=0; i<count; i++ )
         {
-        const TMemSpyDriverFreeCell& cell = aFreeCells[ i ];
-        caption.Format( KCaptionFormat, i + 1 );
-        aList.AddItemFormatL( caption, KValueFormat, cell.iAddress, cell.iLength, cell.iType );
+        const TMemSpyDriverCell& cell = aCells[ i ];
+		if (cell.iType & EMemSpyDriverAllocatedCellMask)
+			{
+			foundAllocatedCells = ETrue;
+			}
+		else if (cell.iType & EMemSpyDriverFreeCellMask)
+			{
+	        caption.Format( KCaptionFormat, i + 1 );
+		    aList.AddItemFormatL( caption, KValueFormat, cell.iAddress, cell.iLength, cell.iType );
+			}
         }
+
+	if (foundAllocatedCells)
+		{
+        aList.AddBlankItemL( 1 );
+		_LIT( KOverallCaption1, "Allocated Cell List" );
+		aList.AddItemL( KOverallCaption1 );
+		aList.AddUnderlineForPreviousItemL( '=', 0 );
+
+		TBuf<128> caption;
+		_LIT( KCaptionFormat, "AC %04d" );
+		_LIT( KValueFormat, "0x%08x %8d %d" );
+
+		for (TInt i = 0; i < count; i++)
+			{
+			const TMemSpyDriverCell& cell = aCells[ i ];
+			if (cell.iType & EMemSpyDriverAllocatedCellMask)
+				{
+				caption.Format( KCaptionFormat, i + 1 );
+				aList.AddItemFormatL( caption, KValueFormat, cell.iAddress, cell.iLength, cell.iType );
+				}
+			}
+		}
     }
 
-
 void CMemSpyEngineHelperHeap::UpdateSharedHeapInfoL( const TProcessId& aProcess, const TThreadId& aThread, TMemSpyHeapInfo& aInfo )
     {
     RArray<TThreadId> threads;
--- a/memspy/Engine/Source/Helpers/MemSpyEngineHelperKernelContainers.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/Helpers/MemSpyEngineHelperKernelContainers.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -247,6 +247,16 @@
     {
     return iType;
     }
+
+EXPORT_C TInt CMemSpyEngineGenericKernelObjectList::Size() const
+    {
+    return iSize;
+    }
+
+EXPORT_C TInt CMemSpyEngineGenericKernelObjectList::ItemsCount() const
+	{
+	return iItems.Count();
+	}
     
 
 EXPORT_C TPtrC CMemSpyEngineGenericKernelObjectList::TypeAsString( TMemSpyDriverContainerType aType )
@@ -392,7 +402,7 @@
     AddItemL( aItem.iHandle );
     iItems.AppendL( aItem );
     //
-    UpdateNameL();
+    //UpdateNameL();
     }
 
 
--- a/memspy/Engine/Source/Helpers/MemSpyEngineHelperStack.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/Helpers/MemSpyEngineHelperStack.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -250,36 +250,22 @@
 
         if  ( r == KErrNone )
             {
-            if ( aType == EMemSpyDriverDomainUser ) {
-                while ( r == KErrNone )
+            while ( r == KErrNone )
+                {
+                iEngine.Sink().OutputBinaryDataL( KStackDataPrefix, pData.Ptr(), (const TUint8*) info.iUserStackBase, pData.Length() );
+                //
+                if  ( remaining > 0 )
                     {
-                    iEngine.Sink().OutputBinaryDataL( KStackDataPrefix, pData.Ptr(), (const TUint8*) info.iUserStackBase, pData.Length() );
-                    //
-                    if  ( remaining > 0 )
-                        {
-                        info.iUserStackBase += pData.Length();
-                        r = iEngine.Driver().GetStackDataNext( aThread.Id(), pData, remaining, aType, aEntireStack );
-                        }
-                    else
-                        {
-                        break;
-                        }
+                    info.iUserStackBase += pData.Length();
+                    r = iEngine.Driver().GetStackDataNext( aThread.Id(), pData, remaining, aType, aEntireStack );
                     }
+                else
+                    {
+                    break;
+                    }
+                }
             }
-            else if ( aType == EMemSpyDriverDomainKernel ) {
-                while ( r == KErrNone ) {
-                
-                    iEngine.Sink().OutputBinaryDataL( KStackDataPrefix, pData.Ptr(), (const TUint8*) info.iSupervisorStackBase, pData.Length() );
-                    //
-                    if  ( remaining > 0 ) {
-                        info.iSupervisorStackBase += pData.Length();
-                        r = iEngine.Driver().GetStackDataNext( aThread.Id(), pData, remaining, aType, aEntireStack );
-                    }
-                    else {
-                         break;
-                    }
-               }
-            }
+
         }
     CleanupStack::PopAndDestroy( data );
 
@@ -290,7 +276,6 @@
     iEngine.Sink().OutputLineFormattedL( KMemSpyMarkerStackData, &KMemSpySinkTagClose, (TUint) aThread.Id() );
     iEngine.Sink().DataStreamEndL();
     }
-}    
 
 
 EXPORT_C void CMemSpyEngineHelperStack::OutputStackInfoForDeviceL()
--- a/memspy/Engine/Source/MemSpyEngine.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/MemSpyEngine.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -67,6 +67,10 @@
     return self;
     }
 
+EXPORT_C CMemSpyEngine* CMemSpyEngine::NewL( RFs& aFsSession, TBool aStartServer )
+    {
+    return NewL(aFsSession);
+    }
 
 EXPORT_C RFs& CMemSpyEngine::FsSession()
     {
@@ -118,9 +122,18 @@
 
 EXPORT_C void CMemSpyEngine::InstallSinkL( TMemSpySinkType aType )
     {
-    iImp->InstallSinkL( aType );
+    iImp->InstallSinkL( aType, KNullDesC );
     }
 
+EXPORT_C void CMemSpyEngine::InstallDebugSinkL()
+    {
+    iImp->InstallSinkL( ESinkTypeDebug, KNullDesC );
+    }
+
+EXPORT_C void CMemSpyEngine::InstallFileSinkL( const TDesC& aRootFolder )
+    {
+    iImp->InstallSinkL( ESinkTypeFile, aRootFolder );
+    }
 
 EXPORT_C void CMemSpyEngine::ListOpenFilesL()
     {
--- a/memspy/Engine/Source/MemSpyEngineImp.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/MemSpyEngineImp.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -52,6 +52,11 @@
 #include <memspy/engine/memspyenginehelperwindowserver.h>
 #include <memspy/engine/memspyenginehelpercondvar.h>
 
+#ifdef _DEBUG
+#define LOG(args...) RDebug::Printf(args)
+#else
+#define LOG(args...)
+#endif
 
 CMemSpyEngineImp::CMemSpyEngineImp( RFs& aFsSession, CMemSpyEngine& aEngine )
 :   iFsSession( aFsSession ), iEngine( aEngine )
@@ -61,18 +66,14 @@
 
 CMemSpyEngineImp::~CMemSpyEngineImp()
     {
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - START" );
-#endif
+    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - START" );
 
     if  ( iMidwife )
         {
         iMidwife->RemoveObserver( *this );
         }
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - deleting helpers..." );
-#endif
+    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - deleting helpers..." );
     delete iHelperSysMemTracker;
     delete iServer;
     delete iHelperKernelContainers;
@@ -94,52 +95,37 @@
     
     iHelperWindowServerLoader.Close();
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - deleting utilities..." );
-#endif
+    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - deleting utilities..." );
     delete iChunkWatcher;
     delete iUndertaker;
     delete iMidwife;
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying containers..." );
-#endif
+    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying containers..." );
     iContainers.ResetAndDestroy();
     iContainers.Close();
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying driver..." );
-#endif
+    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying driver..." );
     if  ( iMemSpyDriver )
         {
         iMemSpyDriver->Close();
         delete iMemSpyDriver;
         }
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying sink..." );
-#endif
+    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - destroying sink..." );
     delete iSink;
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::~CMemSpyEngineImp() - END" );
-#endif
+    LOG( "CMemSpyEngineImp::~CMemSpyEngineImp() - END" );
     }
 
 
 void CMemSpyEngineImp::ConstructL()
     {
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructL() - START" );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructL() - START" );
     //
     iFsSession.SetSessionPath( _L("\\") );
     
-    // Starting the server before the driver connection is made
-    // ensures that only one instance of MemSpy can run (either the S60
-    // UI or the console UI ).
     iServer = CMemSpyEngineServer::NewL( iEngine );
-    //
+    
     iMemSpyDriver = new(ELeave) RMemSpyDriverClient();
     const TInt error = Driver().Open();
     User::LeaveIfError( error );
@@ -163,96 +149,60 @@
     iHelperSysMemTracker = CMemSpyEngineHelperSysMemTracker::NewL( iEngine );
     iMidwife->AddObserverL( *this );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructL() - END" );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructL() - END" );
     }
 
 
 void CMemSpyEngineImp::ConstructHelpersL()
     {
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - START" );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - START" );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Heap..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Heap..." );
     iHelperHeap = CMemSpyEngineHelperHeap::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Stack..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Stack..." );
     iHelperStack = CMemSpyEngineHelperStack::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Code Segments..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Code Segments..." );
     iHelperCodeSegment = CMemSpyEngineHelperCodeSegment::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Chunk..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Chunk..." );
     iHelperChunk = CMemSpyEngineHelperChunk::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Thread..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Thread..." );
     iHelperThread = CMemSpyEngineHelperThread::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Process..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Process..." );
     iHelperProcess = CMemSpyEngineHelperProcess::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Server..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Server..." );
     iHelperServer = CMemSpyEngineHelperServer::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - AO..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - AO..." );
     iHelperActiveObject = CMemSpyEngineHelperActiveObject::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - Kernel Containers..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - Kernel Containers..." );
     iHelperKernelContainers = CMemSpyEngineHelperKernelContainers::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - File System..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - File System..." );
     iHelperFileSystem = CMemSpyEngineHelperFileSystem::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - ECOM..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - ECOM..." );
     iHelperECom = CMemSpyEngineHelperECom::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - FBSERV..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - FBSERV..." );
     iHelperFbServ = CMemSpyEngineHelperFbServ::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - ROM..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - ROM..." );
     iHelperROM = CMemSpyEngineHelperROM::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - RAM..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - RAM..." );
     iHelperRAM = CMemSpyEngineHelperRAM::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - WindowServer..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - WindowServer..." );
     
     TInt err = iHelperWindowServerLoader.Load( _L("memspywindowserverhelper.dll") );
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - WindowServer load err: %d", err );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - WindowServer load err: %d", err );
     if ( !err )
         {
 #ifdef __WINS__ // ordinal is different 
@@ -262,18 +212,19 @@
 #endif
         if ( entry != NULL )
             {
-            iHelperWindowServer = (MMemSpyEngineHelperWindowServer*) entry();
+			typedef MMemSpyEngineHelperWindowServer* (*TEntryFn)(void);
+			TRAP(err, iHelperWindowServer = ((TEntryFn)entry)());
+			if (err)
+				{
+				LOG("err from memspywindowserverhelper.dll - %d", err);
+				}
             }
         }
     
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - CondVar..." );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - CondVar..." );
     iHelperCondVar = CMemSpyEngineHelperCondVar::NewL( iEngine );
 
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::ConstructHelpersL() - END" );
-#endif
+    LOG( "CMemSpyEngineImp::ConstructHelpersL() - END" );
     }
 
 
@@ -334,12 +285,14 @@
     return iSink->Type();
     }
 
+void CMemSpyEngineImp::InstallSinkL( TMemSpySinkType aType )
+	{
+	InstallSinkL( aType, KNullDesC );
+	}
 
-void CMemSpyEngineImp::InstallSinkL( TMemSpySinkType aType )
+void CMemSpyEngineImp::InstallSinkL( TMemSpySinkType aType, const TDesC& aRootFolder )
     {
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::InstallSinkL() - START - switching sink from %d to %d...", (iSink != NULL ? iSink->Type() : -1), aType );
-#endif
+    LOG( "CMemSpyEngineImp::InstallSinkL() - START - switching sink from %d to %d...", (iSink != NULL ? iSink->Type() : -1), aType );
     //
     CMemSpyEngineOutputSink* sink = NULL;
     //
@@ -349,16 +302,14 @@
         sink = CMemSpyEngineOutputSinkDebug::NewL( iEngine );
         break;
     case ESinkTypeFile:
-        sink = CMemSpyEngineOutputSinkFile::NewL( iEngine );
+        sink = CMemSpyEngineOutputSinkFile::NewL( iEngine, aRootFolder );
         break;
         }
     //
     delete iSink;
     iSink = sink;
     //
-#ifdef _DEBUG
-    RDebug::Printf( "CMemSpyEngineImp::InstallSinkL() - END - sink type: %d", iSink->Type() );
-#endif
+    LOG( "CMemSpyEngineImp::InstallSinkL() - END - sink type: %d", iSink->Type() );
     }
 
 
--- a/memspy/Engine/Source/MemSpyEngineUtils.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/MemSpyEngineUtils.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -274,7 +274,7 @@
 
 EXPORT_C TMemSpyPercentText MemSpyEngineUtils::FormatPercentage( TReal aOneHundredPercentValue, TReal aValue )
     {
-    const TReal value = (TInt) (( aValue / aOneHundredPercentValue) * 100.0);
+    const TReal value = (( aValue / aOneHundredPercentValue) * 100.0);
     
     _LIT(KPercentFormat, "%3.2f %%");
 
@@ -365,6 +365,7 @@
 EXPORT_C void MemSpyEngineUtils::GetFolderL( RFs& aFsSession, TDes& aFolder, const CMemSpyEngineSinkMetaData& aMetaData, const TDriveNumber* aForceDrive )
     {
     const TChar KMemSpyDirectorySeparator = '\\';
+    const TChar KMemSpyDriveSeparator = ':';
 
     TDriveList drives;
     User::LeaveIfError( aFsSession.DriveList( drives ) );
@@ -379,7 +380,26 @@
         }
     else
         {
-        logDrive = MemSpyEngineUtils::LocateSuitableDrive( aFsSession );
+		// check if drive is specified in root path
+		if ( aMetaData.Root().Length() > 2 && aMetaData.Root()[1] == KMemSpyDriveSeparator )
+			{
+			TChar drive = aMetaData.Root()[0];
+			
+			// check if drive is valid
+			if (drives.Locate(drive) != KErrNone)
+				{
+				TDriveUnit driveUnit( aMetaData.Root().Left(1) );
+				logDrive = static_cast<TDriveNumber>(static_cast<TInt>(driveUnit));
+				}
+			else
+				{
+				logDrive = MemSpyEngineUtils::LocateSuitableDrive( aFsSession );
+				}
+			}
+		else
+			{
+			logDrive = MemSpyEngineUtils::LocateSuitableDrive( aFsSession );
+			}
         }
 
     // Prepare the drive buffer
@@ -389,7 +409,35 @@
     // Prepare the drive name
     TDriveUnit driveUnit( logDrive );
     pFileName.Append( driveUnit.Name() );
-    pFileName.Append( KMemSpyLogRootPath );
+    
+    if ( aMetaData.Root().Length() == 0 )
+    	{
+		pFileName.Append( KMemSpyLogRootPath );
+    	}
+    else
+    	{
+		TPtrC root( aMetaData.Root() );
+		// check if root path contains drive (e.g. c:) and remove it
+		if ( root.Length() > 2 && root[1] == KMemSpyDriveSeparator )
+			{
+			root.Set( root.Mid( 2 ) );
+			}
+		// check if root starts with \ and remove it
+		if ( root.Length() > 1 && root[0] == KMemSpyDirectorySeparator )
+			{
+			root.Set( root.Mid( 1 ) );
+			}
+		
+		// append root path
+		pFileName.Append( KMemSpyDirectorySeparator );
+		pFileName.Append( root );
+		
+		// add trailing slash if necessary
+		if ( root[root.Length() - 1] != KMemSpyDirectorySeparator )
+			{
+			pFileName.Append( KMemSpyDirectorySeparator );
+			}
+    	}
 
     // Add any custom folder information
     if  ( aMetaData.Folder().Length() > 0 )
--- a/memspy/Engine/Source/Sink/MemSpyEngineOutputList.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/Sink/MemSpyEngineOutputList.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -102,8 +102,18 @@
         for( TInt j=0; j<count; j++ )
             {
             const CMemSpyEngineOutputListItem* item = iItems[ j ];
-            maxLengthCaption = Max( maxLengthCaption, item->Caption().Length() );
-            maxLengthValue = Max( maxLengthValue, item->Value().Length() );
+			if (item->Value().Length())
+				{
+	            maxLengthCaption = Max( maxLengthCaption, item->Caption().Length() );
+	            maxLengthValue = Max( maxLengthValue, item->Value().Length() );
+				}
+			else
+				{
+				// If something doesn't have a value (ie it's a section header, represented as just a caption) then the caption
+				// shouldn't be factored into the maxcaptionlength. But consider it in maxlengthValue to make sure we actually
+				// make the overall buffers big enough
+				maxLengthValue = Max( maxLengthValue, item->Caption().Length() );
+				}
             }
 
         // Second pass - real this time - to print the values
@@ -121,7 +131,15 @@
             HBufC* value = MemSpyEngineUtils::CleanupTextLC( item->Value() );
 
             // Now format the final line, with padding.
-            pLine.Justify( *caption, maxLengthCaption + 3, ELeft, TChar(' ') );
+			if (value->Length()) 
+				{
+	            pLine.Justify( *caption, maxLengthCaption + 3, ELeft, TChar(' ') );
+				}
+			else
+				{
+				// items without value (ie just captions, ie section headers) aren't constrained by the maxLengthCaption restriction
+				pLine.Copy(*caption);
+				}
             pLine.Append( *value );
             CleanupStack::PopAndDestroy( 2, caption );
 
--- a/memspy/Engine/Source/Sink/MemSpyEngineOutputSink.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/Sink/MemSpyEngineOutputSink.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -380,6 +380,7 @@
 
 EXPORT_C CMemSpyEngineSinkMetaData::~CMemSpyEngineSinkMetaData()
     {
+	delete iRoot;
     delete iContext;
     delete iFolder;
     delete iExtension;
@@ -387,8 +388,9 @@
     }
 
 
-void CMemSpyEngineSinkMetaData::ConstructL( const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, const TTime& aFolderTime )
+void CMemSpyEngineSinkMetaData::ConstructL( const TDesC& aRoot, const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, const TTime& aFolderTime )
     {
+	iRoot = aRoot.AllocL();
     iContext = aContext.AllocL();
     iFolder = aFolder.AllocL();
     iExtension = aExtension.AllocL();
@@ -407,15 +409,24 @@
     return CMemSpyEngineSinkMetaData::NewL( KNullDesC, KNullDesC, KNullDesC, ETrue, ETrue );
     }
 
+EXPORT_C CMemSpyEngineSinkMetaData* CMemSpyEngineSinkMetaData::NewL(  const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseFileTimeStamp )
+	{
+	return NewL( KNullDesC, aContext, aFolder, aExtension, aOverwrite, aUseFileTimeStamp );
+	}
 
-EXPORT_C CMemSpyEngineSinkMetaData* CMemSpyEngineSinkMetaData::NewL( const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseFileTimeStamp )
+EXPORT_C CMemSpyEngineSinkMetaData* CMemSpyEngineSinkMetaData::NewL( const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseFileTimeStamp, const TTime& aFolderTimeStamp )
+    {
+    return NewL( KNullDesC, aContext, aFolder, aExtension, aOverwrite, aUseFileTimeStamp, aFolderTimeStamp );
+    }
+
+EXPORT_C CMemSpyEngineSinkMetaData* CMemSpyEngineSinkMetaData::NewL( const TDesC& aRoot, const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseFileTimeStamp )
     {
     // Create a dummy time, we'll clear it after ConstructL() returns...
     TTime now; now.HomeTime();
 
     CMemSpyEngineSinkMetaData* self = new(ELeave) CMemSpyEngineSinkMetaData( aOverwrite, aUseFileTimeStamp );
     CleanupStack::PushL( self );
-    self->ConstructL( aContext, aFolder, aExtension, now );
+    self->ConstructL( aRoot, aContext, aFolder, aExtension, now );
     CleanupStack::Pop( self );
 
     // Clear folder time stamp
@@ -423,14 +434,11 @@
     return self;
     }
 
-
-EXPORT_C CMemSpyEngineSinkMetaData* CMemSpyEngineSinkMetaData::NewL( const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseFileTimeStamp, const TTime& aFolderTimeStamp )
+EXPORT_C CMemSpyEngineSinkMetaData* CMemSpyEngineSinkMetaData::NewL( const TDesC& aRoot, const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseFileTimeStamp, const TTime& aFolderTimeStamp )
     {
     CMemSpyEngineSinkMetaData* self = new(ELeave) CMemSpyEngineSinkMetaData( aOverwrite, aUseFileTimeStamp );
     CleanupStack::PushL( self );
-    self->ConstructL( aContext, aFolder, aExtension, aFolderTimeStamp );
+    self->ConstructL( aRoot, aContext, aFolder, aExtension, aFolderTimeStamp );
     CleanupStack::Pop( self );
     return self;
     }
-
-
--- a/memspy/Engine/Source/Sink/MemSpyEngineOutputSinkFile.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/Sink/MemSpyEngineOutputSinkFile.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -41,6 +41,8 @@
 CMemSpyEngineOutputSinkFile::~CMemSpyEngineOutputSinkFile()
     {
     TRACE( RDebug::Printf( "CMemSpyEngineOutputSinkFile::~CMemSpyEngineOutputSinkFile() - START" ) );
+    
+    delete iRoot;
 
     TRACE( RDebug::Printf( "CMemSpyEngineOutputSinkFile::~CMemSpyEngineOutputSinkFile() - destroying normal logs..." ) );
     iLogs.ResetAndDestroy();
@@ -56,9 +58,11 @@
     }
 
 
-void CMemSpyEngineOutputSinkFile::ConstructL()
+void CMemSpyEngineOutputSinkFile::ConstructL( const TDesC& aRootFolder )
     {
     TRACE( RDebug::Printf( "CMemSpyEngineOutputSinkFile::ConstructL() - START" ) );
+    
+    iRoot = aRootFolder.AllocL();
 
     BaseConstructL();
 
@@ -78,11 +82,11 @@
     }
 
 
-CMemSpyEngineOutputSinkFile* CMemSpyEngineOutputSinkFile::NewL( CMemSpyEngine& aEngine )
+CMemSpyEngineOutputSinkFile* CMemSpyEngineOutputSinkFile::NewL( CMemSpyEngine& aEngine, const TDesC& aRootFolder )
     {
     CMemSpyEngineOutputSinkFile* self = new(ELeave) CMemSpyEngineOutputSinkFile( aEngine );
     CleanupStack::PushL( self );
-    self->ConstructL();
+    self->ConstructL( aRootFolder );
     CleanupStack::Pop( self );
     return self;
     }
@@ -154,7 +158,7 @@
 
 void CMemSpyEngineOutputSinkFile::DataStreamBeginL( const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseTimeStamp )
     {
-    CMemSpyEngineSinkMetaData* meta = CMemSpyEngineSinkMetaData::NewL( aContext, aFolder, aExtension, aOverwrite, aUseTimeStamp );
+    CMemSpyEngineSinkMetaData* meta = CMemSpyEngineSinkMetaData::NewL( iRoot->Des(), aContext, aFolder, aExtension, aOverwrite, aUseTimeStamp );
     CleanupStack::PushL( meta );
 
     TRACE( RDebug::Printf( "CMemSpyEngineOutputSinkFile::DataStreamBeginL() - START - log count: %d, iFileServerSuspended: %d", iLogs.Count(), iFileServerSuspended ) );
@@ -409,7 +413,7 @@
 
     // Make emtpy meta data
     ASSERT( !iMetaData );
-    iMetaData = CMemSpyEngineSinkMetaData::NewL( KNullDesC, KNullDesC, KNullDesC, ETrue, ETrue );
+    iMetaData = CMemSpyEngineSinkMetaData::NewL( iParent.iRoot->Des(), KNullDesC, KNullDesC, KNullDesC, ETrue, ETrue );
 
     // Prepare common details
     CommonConstructL();
--- a/memspy/Engine/Source/SysMemTracker/MemSpyEngineHelperSysMemTracker.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/SysMemTracker/MemSpyEngineHelperSysMemTracker.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -129,7 +129,7 @@
     }
 
 
-void CMemSpyEngineHelperSysMemTracker::CheckForChangesNowL()
+EXPORT_C void CMemSpyEngineHelperSysMemTracker::CheckForChangesNowL()
     {
     iImp->CheckForChangesNowL();
     }
--- a/memspy/Engine/Source/SysMemTracker/MemSpyEngineHelperSysMemTrackerEntryHeap.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/SysMemTracker/MemSpyEngineHelperSysMemTrackerEntryHeap.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -216,15 +216,8 @@
 
 TBool CMemSpyEngineHelperSysMemTrackerEntryHeap::HaveFreeCellsChanged() const
     {
-    TBool changed = 
-        ( iCurrent.AsRHeap().ObjectData().iFree.next != iLast.AsRHeap().ObjectData().iFree.next ) ||
-        ( iCurrent.AsRHeap().ObjectData().iFree.len != iLast.AsRHeap().ObjectData().iFree.len );
-    //
-    if ( !changed )
-        {
-        changed |= ( iCurrent.AsRHeap().Statistics().StatsFree().TypeCount() != iLast.AsRHeap().Statistics().StatsFree().TypeCount() );
-        changed |= ( iCurrent.AsRHeap().Statistics().StatsFree().SlackSpaceCellSize() != iLast.AsRHeap().Statistics().StatsFree().SlackSpaceCellSize() );
-        }
+    TBool changed = ( iCurrent.AsRHeap().Statistics().StatsFree().TypeCount() != iLast.AsRHeap().Statistics().StatsFree().TypeCount() ) ||
+		( iCurrent.AsRHeap().Statistics().StatsFree().TypeSize() != iLast.AsRHeap().Statistics().StatsFree().TypeSize() );
     //
     return changed;
     }
@@ -296,7 +289,7 @@
 
 void CMemSpyEngineHelperSysMemTrackerCycleChangeHeap::OutputHeaderL( CMemSpyEngineOutputSink& aSink, CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ )
     {
-    _LIT( KHeaderHeap, "Type, Thread, Chunk, Handle, Base Addr, Size, Min, Max, 1st Free Addr, 1st Free Len, Alloc Count, Alloc Space, Free Count, Free Space, Free Slack, F.Largest, A.Largest, Attribs");
+    _LIT( KHeaderHeap, "Type, Thread, Chunk, Handle, Heap Addr, Size, Min, Max, 1st Free Addr, 1st Free Len, Alloc Count, Alloc Space, Free Count, Free Space, Free Slack, F.Largest, A.Largest, Attribs");
     aSink.OutputLineL( KHeaderHeap );
     }
 
@@ -315,7 +308,6 @@
     TPtr pBuf(buf->Des());
 
     const TMemSpyHeapMetaDataRHeap& metaData = iCurrent.AsRHeap().MetaData();
-    const TMemSpyHeapObjectDataRHeap& objectData = iCurrent.AsRHeap().ObjectData();
     const TMemSpyHeapStatisticsRHeap& stats = iCurrent.AsRHeap().Statistics();
 
     // Strip any process & thread
@@ -326,12 +318,12 @@
                  iThreadName, 
                  &pChunkName,
                  metaData.ChunkHandle(),
-                 objectData.Base(),
+                 /*objectData.Base(),*/ metaData.iAllocatorAddress,
                  metaData.ChunkSize(),
-                 objectData.iMinLength,
-                 objectData.iMaxLength,
-                 objectData.iFree.next,
-                 objectData.iFree.len,
+                 /*objectData.iMinLength,*/ metaData.iMinHeapSize,
+                 /*objectData.iMaxLength,*/ metaData.iMaxHeapSize,
+                 /*objectData.iFree.next,*/ NULL, //TODO
+                 /*objectData.iFree.len,*/ 0,
                  stats.StatsAllocated().TypeCount(),
                  stats.StatsAllocated().TypeSize(),
                  stats.StatsFree().TypeCount(),
@@ -371,18 +363,22 @@
         {
         // Starts a data Stream
         aCycle.DataStreamBeginL( aSink, *iThreadName );
+        
+        TInt err = KErrNone;
 
         if  ( IsKernel() )
             {
-            engine.HelperHeap().OutputHeapDataKernelL( KMemSpyEngineSinkDoNotCreateOwnDataStream );
+            TRAP(err, engine.HelperHeap().OutputHeapDataKernelL( KMemSpyEngineSinkDoNotCreateOwnDataStream ));
             }
         else if ( thread )
             {
-            engine.HelperHeap().OutputHeapDataUserL( *thread, KMemSpyEngineSinkDoNotCreateOwnDataStream ); 
+            TRAP(err, engine.HelperHeap().OutputHeapDataUserL( *thread, KMemSpyEngineSinkDoNotCreateOwnDataStream )); 
             }
 
         // End the stream (commit the file)
         aCycle.DataStreamEndL( aSink );
+        
+        User::LeaveIfError(err);
         }
     }
 
--- a/memspy/Engine/Source/SysMemTracker/MemSpyEngineHelperSysMemTrackerEntryManager.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/SysMemTracker/MemSpyEngineHelperSysMemTrackerEntryManager.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -443,12 +443,13 @@
     }
 #endif
 
-    if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryBitmapHandles )
-        {
-        RDebug::Print( KMemSpyKeepaliveMessage );
-        // Bitmap
-        CreateSeedItemsBitmapL( *chunks );        
-        }
+// TODO: Uncomment when  bitmap handels are fixed
+//    if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryBitmapHandles )
+//        {
+//        RDebug::Print( KMemSpyKeepaliveMessage );
+//        // Bitmap
+//        CreateSeedItemsBitmapL( *chunks );        
+//        }
 
 #ifdef SYSMEMTRACKERLOGGING
     {
@@ -479,12 +480,13 @@
     }
 #endif
 
-    if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryKernelHeap )
-        {
-        RDebug::Print( KMemSpyKeepaliveMessage );
-        // Look for kernel heaps
-        CreateSeedItemsHeapKernelL( *chunks );
-        }
+//  TODO: Uncomment after fix
+//    if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryKernelHeap )
+//        {
+//        RDebug::Print( KMemSpyKeepaliveMessage );
+//        // Look for kernel heaps
+//        CreateSeedItemsHeapKernelL( *chunks );
+//        }
 
 #ifdef SYSMEMTRACKERLOGGING
     {
@@ -551,12 +553,13 @@
     }
 #endif
 
-    if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserStacks )
-        {
-        RDebug::Print( KMemSpyKeepaliveMessage );
-        // Stacks ($DAT)
-        CreateSeedItemsStacksL( *chunks );        
-        }
+//    TODO: Uncomment after fix
+//    if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserStacks )
+//        {
+//        RDebug::Print( KMemSpyKeepaliveMessage );
+//        // Stacks ($DAT)
+//        CreateSeedItemsStacksL( *chunks );        
+//        }
 
 #ifdef SYSMEMTRACKERLOGGING
      {
@@ -569,12 +572,13 @@
     }
 #endif
 
-    if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryGlobalData )
-        {
-        RDebug::Print( KMemSpyKeepaliveMessage );
-        // Global data (DLL$DATA)
-        CreateSeedItemsGlobalDataL( *chunks );        
-        }
+//  TODO: Uncomment after fix
+//    if ( config.iEnabledCategories & TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryGlobalData )
+//        {
+//        RDebug::Print( KMemSpyKeepaliveMessage );
+//        // Global data (DLL$DATA)
+//        CreateSeedItemsGlobalDataL( *chunks );        
+//        }
 
  #ifdef SYSMEMTRACKERLOGGING
     {
--- a/memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectContainer.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectContainer.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -773,9 +773,9 @@
         for( TInt i=0; i<leftCount; i++ )
             {
             const TMemSpyHeapInfo& info = leftInfos[ i ];
-            if ( info.Type() == TMemSpyHeapInfo::ETypeRHeap )
+            if ( info.Type() != TMemSpyHeapInfo::ETypeUnknown )
                 {
-                leftSize += (TInt) info.AsRHeap().ObjectData().Size();
+                leftSize += (TInt) info.AsRHeap().MetaData().iHeapSize;
                 }
             }
         CleanupStack::PopAndDestroy( &leftInfos );
@@ -789,9 +789,9 @@
         for( TInt i=0; i<rightCount; i++ )
             {
             const TMemSpyHeapInfo& info = rightInfos[ i ];
-            if ( info.Type() == TMemSpyHeapInfo::ETypeRHeap )
+            if ( info.Type() == TMemSpyHeapInfo::ETypeUnknown )
                 {
-                rightSize += (TInt) info.AsRHeap().ObjectData().Size();
+                rightSize += (TInt) info.AsRHeap().MetaData().iHeapSize;
                 }
             }
         CleanupStack::PopAndDestroy( &rightInfos );
--- a/memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectProcess.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectProcess.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -515,6 +515,25 @@
     return iInfo->VID();
     }
 
+EXPORT_C TProcessPriority CMemSpyProcess::Priority() const
+	{
+	return iPriority;
+	}
+
+EXPORT_C TExitCategoryName CMemSpyProcess::ExitCategory() const
+	{
+	return iExitCategory;
+	}
+
+EXPORT_C TInt CMemSpyProcess::ExitReason() const
+	{
+	return iExitReason;
+	}
+
+EXPORT_C TExitType CMemSpyProcess::ExitType() const
+	{
+	return iExitType;
+	}
 
 EXPORT_C TUidType CMemSpyProcess::UIDs() const
     {
--- a/memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectThread.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectThread.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -387,6 +387,11 @@
     return  isDead;
     }
 
+EXPORT_C TThreadPriority CMemSpyThread::Priority() const
+	{
+	return iPriority;
+	}
+
 
 void CMemSpyThread::RefreshL()
     {
--- a/memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectThreadInfoObjects.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/Source/ThreadAndProcess/MemSpyEngineObjectThreadInfoObjects.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -123,6 +123,17 @@
     return TPtrC( item->Combined() );
     }
 
+EXPORT_C TPtrC CMemSpyThreadInfoItemBase::Caption(TInt aIndex ) const
+	{
+	CItem* item = iItems[ aIndex ];
+	return TPtrC( item->Caption() );
+	}
+
+EXPORT_C TPtrC CMemSpyThreadInfoItemBase::Value(TInt aIndex ) const
+	{
+	CItem* item = iItems[ aIndex ];
+	return TPtrC( item->Value() );
+	}
 
 EXPORT_C CMemSpyEngine& CMemSpyThreadInfoItemBase::Engine() const
     {
@@ -1691,20 +1702,18 @@
 #endif
 
     // See if we have an entry with that name...
-    TIdentityRelation<CSessionInfoEntry> comparer( CompareEntries );
-    HBufC* name = aName.AllocLC();
-    CSessionInfoEntry* entry = new(ELeave) CSessionInfoEntry( name );
-    CleanupStack::Pop( name );
-    CleanupStack::PushL( entry );
-    const TInt foundIndex = iServerNames.Find( entry, comparer );
-    CleanupStack::PopAndDestroy( entry );
+    TInt foundIndex = 0;
+    TRAP(ret, foundIndex = FindServerL(aName));
     
-    // If we did, get the count
-    if  ( foundIndex >=0 && foundIndex < iServerNames.Count() )
+    if (ret == KErrNone)
         {
-        ret = iServerNames[ foundIndex ]->iCount;
+        // If we did, get the count
+        if  ( foundIndex >=0 && foundIndex < iServerNames.Count() )
+            {
+            ret = iServerNames[ foundIndex ]->iCount;
+            }
         }
-    //
+
 #ifdef _DEBUG
     RDebug::Printf( "CMemSpyThreadInfoSession::ConnectionCount() - END - ret: %d", ret );
 #endif
@@ -1712,10 +1721,22 @@
     return ret;
     }
 
+TInt CMemSpyThreadInfoSession::FindServerL( const TDesC& aName ) const
+    {
+    TIdentityRelation<CSessionInfoEntry> comparer( CompareEntries );
+    HBufC* name = aName.AllocLC();
+    CSessionInfoEntry* entry = new(ELeave) CSessionInfoEntry( name );
+    CleanupStack::Pop( name ); // don't destroy it as name is now owned by entry 
+    CleanupStack::PushL( entry );
+    const TInt foundIndex = iServerNames.Find( entry, comparer );
+    User::LeaveIfError(foundIndex); // so we only return a real index
+    CleanupStack::PopAndDestroy( entry );
+    return foundIndex;
+    }
 
 void CMemSpyThreadInfoSession::HandleContainerItemL( TMemSpyDriverHandleInfoGeneric& aItem, TInt /*aRefCount*/, TDes& aFullName )
     {
-    // Check whether we have the item already?
+    // Check whether we have the item already
     TIdentityRelation<CSessionInfoEntry> comparer( CompareEntries );
 
     // Prepare object, just in case we don't find it...
--- a/memspy/Engine/eabi/MemSpyEngineu.def	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/eabi/MemSpyEngineu.def	Wed Sep 15 13:53:27 2010 +0300
@@ -536,4 +536,21 @@
 	_ZTI49CMemSpyEngineHelperSysMemTrackerEntryWindowServer @ 535 NONAME ; #<TI>#
 	_ZTV49CMemSpyEngineHelperSysMemTrackerEntryWindowServer @ 536 NONAME ; #<VT>#
 	_ZN13CMemSpyEngine29IsHelperWindowServerSupportedEv @ 537 NONAME
+	_ZN23CMemSpyEngineHelperHeap14NewHeapRawInfoERK15TMemSpyHeapInfo @ 538 NONAME
+	_ZNK36CMemSpyEngineGenericKernelObjectList10ItemsCountEv @ 539 NONAME
+	_ZNK36CMemSpyEngineGenericKernelObjectList4SizeEv @ 540 NONAME
+	_ZNK13CMemSpyThread8PriorityEv @ 541 NONAME
+	_ZN13CMemSpyEngine4NewLER3RFsi @ 542 NONAME
+	_ZNK14CMemSpyProcess10ExitReasonEv @ 543 NONAME
+	_ZNK14CMemSpyProcess12ExitCategoryEv @ 544 NONAME
+	_ZNK14CMemSpyProcess8ExitTypeEv @ 545 NONAME
+	_ZNK14CMemSpyProcess8PriorityEv @ 546 NONAME
+	_ZNK25CMemSpyThreadInfoItemBase5ValueEi @ 547 NONAME
+	_ZNK25CMemSpyThreadInfoItemBase7CaptionEi @ 548 NONAME
+	_ZN13CMemSpyEngine16InstallFileSinkLERK7TDesC16 @ 549 NONAME
+	_ZN13CMemSpyEngine17InstallDebugSinkLEv @ 550 NONAME
+	_ZN25CMemSpyEngineSinkMetaData4NewLERK7TDesC16S2_S2_S2_ii @ 551 NONAME
+	_ZN25CMemSpyEngineSinkMetaData4NewLERK7TDesC16S2_S2_S2_iiRK5TTime @ 552 NONAME
+	_ZN32CMemSpyEngineHelperSysMemTracker19CheckForChangesNowLEv @ 553 NONAME
+	_ZN23CMemSpyEngineHelperHeap16GetHeapInfoUserLERK10TProcessIdRK9TThreadIdR15TMemSpyHeapInfoP6RArrayI21TMemSpyDriverFreeCellEi @ 554 NONAME
 
--- a/memspy/Engine/group/MemSpyEngine.mmp	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/Engine/group/MemSpyEngine.mmp	Wed Sep 15 13:53:27 2010 +0300
@@ -113,15 +113,18 @@
 
 OS_LAYER_SYSTEMINCLUDE
 
+APP_LAYER_SYSTEMINCLUDE
+
 LIBRARY			euser.lib 
 LIBRARY			MemSpyDriverClient.lib hal.lib estor.lib
 LIBRARY			efsrv.lib bafl.lib fbscli.lib
 LIBRARY			ecom.lib xmlframework.lib charconv.lib
-
+LIBRARY			apgrfx.lib
+LIBRARY	 		ws32.lib
 
 
 #include "MemSpyEngine.config"
 
+//EXPORTUNFROZEN
 
 
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/bwins/MemSpyClientu.def	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,221 @@
+EXPORTS
+	?CpuUse@CMemSpyApiThread@@QBEHXZ @ 1 NONAME ; int CMemSpyApiThread::CpuUse(void) const
+	?Name@CMemSpyApiKernelObjectItem@@QBEABVTDesC8@@XZ @ 2 NONAME ; class TDesC8 const & CMemSpyApiKernelObjectItem::Name(void) const
+	?GetThreadInfoItemsL@RMemSpySession@@QAEXAAV?$RArray@PAVCMemSpyApiThreadInfoItem@@@@VTThreadId@@W4TMemSpyThreadInfoItemType@@@Z @ 3 NONAME ; void RMemSpySession::GetThreadInfoItemsL(class RArray<class CMemSpyApiThreadInfoItem *> &, class TThreadId, enum TMemSpyThreadInfoItemType)
+	?Description@TMemSpyDeviceWideOperationProgress@@QBEABVTDesC16@@XZ @ 4 NONAME ; class TDesC16 const & TMemSpyDeviceWideOperationProgress::Description(void) const
+	?TotalOverhead@CMemSpyApiHeap@@QAEHXZ @ 5 NONAME ; int CMemSpyApiHeap::TotalOverhead(void)
+	?OutputDetailedPhoneInfo@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 6 NONAME ; void RMemSpySession::OutputDetailedPhoneInfo(class TRequestStatus &)
+	?UniqueID@CMemSpyApiKernelObjectItem@@QBEHXZ @ 7 NONAME ; int CMemSpyApiKernelObjectItem::UniqueID(void) const
+	?OutputHeapData@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 8 NONAME ; void RMemSpySession::OutputHeapData(class TRequestStatus &)
+	?GetSwmtCategoriesL@RMemSpySession@@QAEXAAH@Z @ 9 NONAME ; void RMemSpySession::GetSwmtCategoriesL(int &)
+	?SessionType@CMemSpyApiKernelObjectItem@@QBE?AW4TIpcSessionType@@XZ @ 10 NONAME ; enum TIpcSessionType CMemSpyApiKernelObjectItem::SessionType(void) const
+	?VID@CMemSpyApiThread@@QBEHXZ @ 11 NONAME ; int CMemSpyApiThread::VID(void) const
+	?OutputStackInfoL@RMemSpySession@@QAEXVTThreadId@@@Z @ 12 NONAME ; void RMemSpySession::OutputStackInfoL(class TThreadId)
+	?FreeMemory@CMemSpyApiMemoryTrackingCycle@@QBEAB_JXZ @ 13 NONAME ; long long const & CMemSpyApiMemoryTrackingCycle::FreeMemory(void) const
+	?ProcessNumberUsing@CMemSpyApiThread@@QBEHXZ @ 14 NONAME ; int CMemSpyApiThread::ProcessNumberUsing(void) const
+	?PreviousCycleDiff@CMemSpyApiMemoryTrackingCycle@@QBE_JXZ @ 15 NONAME ; long long CMemSpyApiMemoryTrackingCycle::PreviousCycleDiff(void) const
+	?OutputStackDataL@RMemSpySession@@QAEXVTThreadId@@W4TMemSpyDriverDomainType@@@Z @ 16 NONAME ; void RMemSpySession::OutputStackDataL(class TThreadId, enum TMemSpyDriverDomainType)
+	?OutputThreadHeapDataL@RMemSpySession@@QAEXVTThreadId@@@Z @ 17 NONAME ; void RMemSpySession::OutputThreadHeapDataL(class TThreadId)
+	?ExitType@CMemSpyApiProcess@@QBE?AW4TExitType@@XZ @ 18 NONAME ; enum TExitType CMemSpyApiProcess::ExitType(void) const
+	?SwitchOutputToFileL@RMemSpySession@@QAEXABVTDesC16@@@Z @ 19 NONAME ; void RMemSpySession::SwitchOutputToFileL(class TDesC16 const &)
+	?OutputHeapCellListing@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 20 NONAME ; void RMemSpySession::OutputHeapCellListing(class TRequestStatus &)
+	?SetThreadPriorityL@RMemSpySession@@QAEXVTThreadId@@H@Z @ 21 NONAME ; void RMemSpySession::SetThreadPriorityL(class TThreadId, int)
+	?Restrictions@CMemSpyApiKernelObjectItem@@QBEIXZ @ 22 NONAME ; unsigned int CMemSpyApiKernelObjectItem::Restrictions(void) const
+	?Id@CMemSpyApiKernelObjectItem@@QBEHXZ @ 23 NONAME ; int CMemSpyApiKernelObjectItem::Id(void) const
+	?Count@CMemSpyApiKernelObjectItem@@QBEHXZ @ 24 NONAME ; int CMemSpyApiKernelObjectItem::Count(void) const
+	?ControllingOwner@CMemSpyApiKernelObjectItem@@QBEIXZ @ 25 NONAME ; unsigned int CMemSpyApiKernelObjectItem::ControllingOwner(void) const
+	?SwmtResetTracking@RMemSpySession@@QAEXXZ @ 26 NONAME ; void RMemSpySession::SwmtResetTracking(void)
+	?Version@CMemSpyApiKernelObjectItem@@QBE?AVTVersion@@XZ @ 27 NONAME ; class TVersion CMemSpyApiKernelObjectItem::Version(void) const
+	?SwitchToProcess@RMemSpySession@@QAEHVTProcessId@@H@Z @ 28 NONAME ; int RMemSpySession::SwitchToProcess(class TProcessId, int)
+	?MaxSize@CMemSpyApiKernelObjectItem@@QBEHXZ @ 29 NONAME ; int CMemSpyApiKernelObjectItem::MaxSize(void) const
+	?IsSwmtRunningL@RMemSpySession@@QAEHXZ @ 30 NONAME ; int RMemSpySession::IsSwmtRunningL(void)
+	?AddressOfOwningProcess@CMemSpyApiKernelObjectItem@@QAEPAEXZ @ 31 NONAME ; unsigned char * CMemSpyApiKernelObjectItem::AddressOfOwningProcess(void)
+	?ExitReason@CMemSpyApiProcess@@QBEHXZ @ 32 NONAME ; int CMemSpyApiProcess::ExitReason(void) const
+	?MsgCount@CMemSpyApiKernelObjectItem@@QBEHXZ @ 33 NONAME ; int CMemSpyApiKernelObjectItem::MsgCount(void) const
+	?AllocationsCount@CMemSpyApiHeap@@QAEHXZ @ 34 NONAME ; int CMemSpyApiHeap::AllocationsCount(void)
+	?WaitCount@CMemSpyApiKernelObjectItem@@QBEHXZ @ 35 NONAME ; int CMemSpyApiKernelObjectItem::WaitCount(void) const
+	?SID@CMemSpyApiProcess@@QBEKXZ @ 36 NONAME ; unsigned long CMemSpyApiProcess::SID(void) const
+	?GetKernelObjectsL@RMemSpySession@@QAEXAAV?$RArray@PAVCMemSpyApiKernelObject@@@@@Z @ 37 NONAME ; void RMemSpySession::GetKernelObjectsL(class RArray<class CMemSpyApiKernelObject *> &)
+	?CycleNumber@CMemSpyApiMemoryTrackingCycle@@QBEHXZ @ 38 NONAME ; int CMemSpyApiMemoryTrackingCycle::CycleNumber(void) const
+	?Size@CMemSpyApiKernelObject@@QBE_JXZ @ 39 NONAME ; long long CMemSpyApiKernelObject::Size(void) const
+	?SetSwmtCategoriesL@RMemSpySession@@QAEXH@Z @ 40 NONAME ; void RMemSpySession::SetSwmtCategoriesL(int)
+	?CancelDeviceWideOperationL@RMemSpySession@@QAEXXZ @ 41 NONAME ; void RMemSpySession::CancelDeviceWideOperationL(void)
+	?TotalAllocations@CMemSpyApiHeap@@QAEHXZ @ 42 NONAME ; int CMemSpyApiHeap::TotalAllocations(void)
+	?Name@CMemSpyApiProcess@@QBEABVTDesC16@@XZ @ 43 NONAME ; class TDesC16 const & CMemSpyApiProcess::Name(void) const
+	?DumpKernelHeap@RMemSpySession@@QAEXXZ @ 44 NONAME ; void RMemSpySession::DumpKernelHeap(void)
+	?GetKernelObjects@RMemSpySession@@QAEHAAV?$RArray@PAVCMemSpyApiKernelObject@@@@@Z @ 45 NONAME ; int RMemSpySession::GetKernelObjects(class RArray<class CMemSpyApiKernelObject *> &)
+	?Priority@CMemSpyApiProcess@@QBE?AW4TProcessPriority@@XZ @ 46 NONAME ; enum TProcessPriority CMemSpyApiProcess::Priority(void) const
+	?HeaderSizeF@CMemSpyApiHeap@@QAEHXZ @ 47 NONAME ; int CMemSpyApiHeap::HeaderSizeF(void)
+	?OutputCompactStackInfoL@RMemSpySession@@QAEXXZ @ 48 NONAME ; void RMemSpySession::OutputCompactStackInfoL(void)
+	?MsgLimit@CMemSpyApiKernelObjectItem@@QBEHXZ @ 49 NONAME ; int CMemSpyApiKernelObjectItem::MsgLimit(void) const
+	?AddressOfDataBssStackChunk@CMemSpyApiKernelObjectItem@@QAEPAEXZ @ 50 NONAME ; unsigned char * CMemSpyApiKernelObjectItem::AddressOfDataBssStackChunk(void)
+	?Top@CMemSpyApiKernelObjectItem@@QBEHXZ @ 51 NONAME ; int CMemSpyApiKernelObjectItem::Top(void) const
+	?Resetting@CMemSpyApiKernelObjectItem@@QBEEXZ @ 52 NONAME ; unsigned char CMemSpyApiKernelObjectItem::Resetting(void) const
+	?GetProcessIdByThreadId@RMemSpySession@@QAEXAAVTProcessId@@VTThreadId@@@Z @ 53 NONAME ; void RMemSpySession::GetProcessIdByThreadId(class TProcessId &, class TThreadId)
+	?HeaderSizeA@CMemSpyApiHeap@@QAEHXZ @ 54 NONAME ; int CMemSpyApiHeap::HeaderSizeA(void)
+	?OutputHeapData@RMemSpySession@@QAEXXZ @ 55 NONAME ; void RMemSpySession::OutputHeapData(void)
+	?TotalAccessCount@CMemSpyApiKernelObjectItem@@QBEGXZ @ 56 NONAME ; unsigned short CMemSpyApiKernelObjectItem::TotalAccessCount(void) const
+	?Changes@CMemSpyApiKernelObjectItem@@QBEIXZ @ 57 NONAME ; unsigned int CMemSpyApiKernelObjectItem::Changes(void) const
+	??0RMemSpySession@@QAE@XZ @ 58 NONAME ; RMemSpySession::RMemSpySession(void)
+	?OutputUserStackData@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 59 NONAME ; void RMemSpySession::OutputUserStackData(class TRequestStatus &)
+	?AddressOfServer@CMemSpyApiKernelObjectItem@@QAEPAEXZ @ 60 NONAME ; unsigned char * CMemSpyApiKernelObjectItem::AddressOfServer(void)
+	?Size@CMemSpyApiHeap@@QAEHXZ @ 61 NONAME ; int CMemSpyApiHeap::Size(void)
+	?GetServersL@RMemSpySession@@QAEXAAV?$RArray@PAVCMemSpyApiServer@@@@@Z @ 62 NONAME ; void RMemSpySession::GetServersL(class RArray<class CMemSpyApiServer *> &)
+	??1CMemSpyApiKernelObject@@QAE@XZ @ 63 NONAME ; CMemSpyApiKernelObject::~CMemSpyApiKernelObject(void)
+	?GetInfoItemType@RMemSpySession@@QAEHHVTThreadId@@AAW4TMemSpyThreadInfoItemType@@@Z @ 64 NONAME ; int RMemSpySession::GetInfoItemType(int, class TThreadId, enum TMemSpyThreadInfoItemType &)
+	??1CMemSpyApiHeap@@QAE@XZ @ 65 NONAME ; CMemSpyApiHeap::~CMemSpyApiHeap(void)
+	?SetSwmtHeapDumpsEnabledL@RMemSpySession@@QAEXH@Z @ 66 NONAME ; void RMemSpySession::SetSwmtHeapDumpsEnabledL(int)
+	?SetSwmtFilter@RMemSpySession@@QAEXABVTDesC16@@@Z @ 67 NONAME ; void RMemSpySession::SetSwmtFilter(class TDesC16 const &)
+	?Size@CMemSpyApiKernelObjectItem@@QBEKXZ @ 68 NONAME ; unsigned long CMemSpyApiKernelObjectItem::Size(void) const
+	?OutputThreadInfoHandlesL@RMemSpySession@@QAEXVTThreadId@@@Z @ 69 NONAME ; void RMemSpySession::OutputThreadInfoHandlesL(class TThreadId)
+	?OutputThreadHeapDataL@RMemSpySession@@QAEXABVTDesC16@@@Z @ 70 NONAME ; void RMemSpySession::OutputThreadHeapDataL(class TDesC16 const &)
+	?Type@CMemSpyApiKernelObject@@QBE?AW4TMemSpyDriverContainerType@@XZ @ 71 NONAME ; enum TMemSpyDriverContainerType CMemSpyApiKernelObject::Type(void) const
+	?Name@CMemSpyApiKernelObject@@QBEABVTDesC16@@XZ @ 72 NONAME ; class TDesC16 const & CMemSpyApiKernelObject::Name(void) const
+	?Fragmentation@CMemSpyApiHeap@@QAEHXZ @ 73 NONAME ; int CMemSpyApiHeap::Fragmentation(void)
+	?TimerType@CMemSpyApiKernelObjectItem@@QBE?AW4TMemSpyDriverTimerType@@XZ @ 74 NONAME ; enum TMemSpyDriverTimerType CMemSpyApiKernelObjectItem::TimerType(void) const
+	?Value@CMemSpyApiThreadInfoItem@@QBEABVTDesC16@@XZ @ 75 NONAME ; class TDesC16 const & CMemSpyApiThreadInfoItem::Value(void) const
+	?SecurityZone@CMemSpyApiKernelObjectItem@@QBEIXZ @ 76 NONAME ; unsigned int CMemSpyApiKernelObjectItem::SecurityZone(void) const
+	?CreatorId@CMemSpyApiKernelObjectItem@@QBEIXZ @ 77 NONAME ; unsigned int CMemSpyApiKernelObjectItem::CreatorId(void) const
+	?Order@CMemSpyApiKernelObjectItem@@QBEEXZ @ 78 NONAME ; unsigned char CMemSpyApiKernelObjectItem::Order(void) const
+	?NameDetail@CMemSpyApiKernelObjectItem@@QBEABVTDesC8@@XZ @ 79 NONAME ; class TDesC8 const & CMemSpyApiKernelObjectItem::NameDetail(void) const
+	?OutputStackInfo@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 80 NONAME ; void RMemSpySession::OutputStackInfo(class TRequestStatus &)
+	?Handle@CMemSpyApiKernelObjectItem@@QBEPAXXZ @ 81 NONAME ; void * CMemSpyApiKernelObjectItem::Handle(void) const
+	?GetProcessesL@RMemSpySession@@QAEXAAV?$RArray@PAVCMemSpyApiProcess@@@@W4TSortType@@@Z @ 82 NONAME ; void RMemSpySession::GetProcessesL(class RArray<class CMemSpyApiProcess *> &, enum TSortType)
+	?ParseMask@CMemSpyApiKernelObjectItem@@QBEIXZ @ 83 NONAME ; unsigned int CMemSpyApiKernelObjectItem::ParseMask(void) const
+	?Attributes@CMemSpyApiKernelObjectItem@@QBEHXZ @ 84 NONAME ; int CMemSpyApiKernelObjectItem::Attributes(void) const
+	?MemoryDelta@CMemSpyApiMemoryTrackingCycle@@QBE_JXZ @ 85 NONAME ; long long CMemSpyApiMemoryTrackingCycle::MemoryDelta(void) const
+	?GetSwmtFilter@RMemSpySession@@QAEXAAV?$TBuf@$0IA@@@@Z @ 86 NONAME ; void RMemSpySession::GetSwmtFilter(class TBuf<128> &)
+	?Caption@CMemSpyApiThreadInfoItem@@QBEABVTDesC16@@XZ @ 87 NONAME ; class TDesC16 const & CMemSpyApiThreadInfoItem::Caption(void) const
+	?DebugAllocatorLibrary@CMemSpyApiHeap@@QAEHXZ @ 88 NONAME ; int CMemSpyApiHeap::DebugAllocatorLibrary(void)
+	?Overhead@CMemSpyApiHeap@@QAEHXZ @ 89 NONAME ; int CMemSpyApiHeap::Overhead(void)
+	?ForceSwmtUpdate@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 90 NONAME ; void RMemSpySession::ForceSwmtUpdate(class TRequestStatus &)
+	?GetHeapL@RMemSpySession@@QAEPAVCMemSpyApiHeap@@XZ @ 91 NONAME ; class CMemSpyApiHeap * RMemSpySession::GetHeapL(void)
+	?ServerListOutputGenericL@RMemSpySession@@QAEXH@Z @ 92 NONAME ; void RMemSpySession::ServerListOutputGenericL(int)
+	?OutputKernelStackData@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 93 NONAME ; void RMemSpySession::OutputKernelStackData(class TRequestStatus &)
+	?GetSwmtTimerIntervalL@RMemSpySession@@QAEXAAH@Z @ 94 NONAME ; void RMemSpySession::GetSwmtTimerIntervalL(int &)
+	?GetSwmtHeapDumpsEnabledL@RMemSpySession@@QAEXAAH@Z @ 95 NONAME ; void RMemSpySession::GetSwmtHeapDumpsEnabledL(int &)
+	?AddressOfOwningThread@CMemSpyApiKernelObjectItem@@QAEPAEXZ @ 96 NONAME ; unsigned char * CMemSpyApiKernelObjectItem::AddressOfOwningThread(void)
+	?ThreadPriority@CMemSpyApiThread@@QBE?AW4TThreadPriority@@XZ @ 97 NONAME ; enum TThreadPriority CMemSpyApiThread::ThreadPriority(void) const
+	?GetHeap@RMemSpySession@@QAEPAVCMemSpyApiHeap@@XZ @ 98 NONAME ; class CMemSpyApiHeap * RMemSpySession::GetHeap(void)
+	??1CMemSpyApiMemoryTrackingCycle@@QAE@XZ @ 99 NONAME ; CMemSpyApiMemoryTrackingCycle::~CMemSpyApiMemoryTrackingCycle(void)
+	?AccessCount@CMemSpyApiKernelObjectItem@@QBEHXZ @ 100 NONAME ; int CMemSpyApiKernelObjectItem::AccessCount(void) const
+	?ChangeCount@CMemSpyApiMemoryTrackingCycle@@QBEHXZ @ 101 NONAME ; int CMemSpyApiMemoryTrackingCycle::ChangeCount(void) const
+	?OutputHeapInfo@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 102 NONAME ; void RMemSpySession::OutputHeapInfo(class TRequestStatus &)
+	?Time@CMemSpyApiMemoryTrackingCycle@@QBEABVTTime@@XZ @ 103 NONAME ; class TTime const & CMemSpyApiMemoryTrackingCycle::Time(void) const
+	?SetSwmtTimerIntervalL@RMemSpySession@@QAEXH@Z @ 104 NONAME ; void RMemSpySession::SetSwmtTimerIntervalL(int)
+	?MaxLength@CMemSpyApiHeap@@QAEHXZ @ 105 NONAME ; int CMemSpyApiHeap::MaxLength(void)
+	?OutputKernelHeapData@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 106 NONAME ; void RMemSpySession::OutputKernelHeapData(class TRequestStatus &)
+	?AddressOfKernelOwner@CMemSpyApiKernelObjectItem@@QAEPAEXZ @ 107 NONAME ; unsigned char * CMemSpyApiKernelObjectItem::AddressOfKernelOwner(void)
+	??1CMemSpyApiThreadInfoItem@@QAE@XZ @ 108 NONAME ; CMemSpyApiThreadInfoItem::~CMemSpyApiThreadInfoItem(void)
+	?FreeCount@CMemSpyApiHeap@@QAEHXZ @ 109 NONAME ; int CMemSpyApiHeap::FreeCount(void)
+	?TotalFree@CMemSpyApiHeap@@QAEHXZ @ 110 NONAME ; int CMemSpyApiHeap::TotalFree(void)
+	?SwitchToThread@RMemSpySession@@QAEHVTThreadId@@H@Z @ 111 NONAME ; int RMemSpySession::SwitchToThread(class TThreadId, int)
+	?GetServersL@RMemSpySession@@QAEXAAV?$RArray@PAVCMemSpyApiServer@@@@W4TSortType@@@Z @ 112 NONAME ; void RMemSpySession::GetServersL(class RArray<class CMemSpyApiServer *> &, enum TSortType)
+	?FreeOverhead@CMemSpyApiHeap@@QAEHXZ @ 113 NONAME ; int CMemSpyApiHeap::FreeOverhead(void)
+	?SwitchOutputToTraceL@RMemSpySession@@QAEXXZ @ 114 NONAME ; void RMemSpySession::SwitchOutputToTraceL(void)
+	?SlackFreeSpace@CMemSpyApiHeap@@QAEHXZ @ 115 NONAME ; int CMemSpyApiHeap::SlackFreeSpace(void)
+	?Priority@CMemSpyApiKernelObjectItem@@QBEHXZ @ 116 NONAME ; int CMemSpyApiKernelObjectItem::Priority(void) const
+	?ForceSwmtUpdateL@RMemSpySession@@QAEXXZ @ 117 NONAME ; void RMemSpySession::ForceSwmtUpdateL(void)
+	?ThreadCount@CMemSpyApiProcess@@QBEHXZ @ 118 NONAME ; int CMemSpyApiProcess::ThreadCount(void) const
+	?RequestCount@CMemSpyApiThread@@QBEHXZ @ 119 NONAME ; int CMemSpyApiThread::RequestCount(void) const
+	?Caption@CMemSpyApiMemoryTrackingCycle@@QBEABVTDesC16@@XZ @ 120 NONAME ; class TDesC16 const & CMemSpyApiMemoryTrackingCycle::Caption(void) const
+	?StopSwmtTimerL@RMemSpySession@@QAEXXZ @ 121 NONAME ; void RMemSpySession::StopSwmtTimerL(void)
+	??1CMemSpyApiProcess@@QAE@XZ @ 122 NONAME ; CMemSpyApiProcess::~CMemSpyApiProcess(void)
+	?MinLength@CMemSpyApiHeap@@QAEHXZ @ 123 NONAME ; int CMemSpyApiHeap::MinLength(void)
+	?ExitCategory@CMemSpyApiProcess@@QBE?AV?$TBuf@$0BA@@@XZ @ 124 NONAME ; class TBuf<16> CMemSpyApiProcess::ExitCategory(void) const
+	?Progress@TMemSpyDeviceWideOperationProgress@@QBEHXZ @ 125 NONAME ; int TMemSpyDeviceWideOperationProgress::Progress(void) const
+	?Count@CMemSpyApiKernelObject@@QBEHXZ @ 126 NONAME ; int CMemSpyApiKernelObject::Count(void) const
+	?IsDead@CMemSpyApiProcess@@QBEHXZ @ 127 NONAME ; int CMemSpyApiProcess::IsDead(void) const
+	?EndThreadL@RMemSpySession@@QAEHVTThreadId@@W4TMemSpyEndType@@@Z @ 128 NONAME ; int RMemSpySession::EndThreadL(class TThreadId, enum TMemSpyEndType)
+	?StartPos@CMemSpyApiKernelObjectItem@@QBEHXZ @ 129 NONAME ; int CMemSpyApiKernelObjectItem::StartPos(void) const
+	?TimerState@CMemSpyApiKernelObjectItem@@QBE?AW4TMemSpyDriverTimerState@@XZ @ 130 NONAME ; enum TMemSpyDriverTimerState CMemSpyApiKernelObjectItem::TimerState(void) const
+	?BaseAddress@CMemSpyApiHeap@@QAEHXZ @ 131 NONAME ; int CMemSpyApiHeap::BaseAddress(void)
+	?ExitType@CMemSpyApiThread@@QBE?AW4TExitType@@XZ @ 132 NONAME ; enum TExitType CMemSpyApiThread::ExitType(void) const
+	?StartSwmtTimerL@RMemSpySession@@QAEXH@Z @ 133 NONAME ; void RMemSpySession::StartSwmtTimerL(int)
+	?Type@CMemSpyApiHeap@@QAEAAVTDesC16@@XZ @ 134 NONAME ; class TDesC16 & CMemSpyApiHeap::Type(void)
+	?GetOutputSink@RMemSpySession@@QAEXAAW4TMemSpySinkType@@@Z @ 135 NONAME ; void RMemSpySession::GetOutputSink(enum TMemSpySinkType &)
+	?Id@CMemSpyApiProcess@@QBE?AVTProcessId@@XZ @ 136 NONAME ; class TProcessId CMemSpyApiProcess::Id(void) const
+	?BiggestAllocation@CMemSpyApiHeap@@QAEHXZ @ 137 NONAME ; int CMemSpyApiHeap::BiggestAllocation(void)
+	??1CMemSpyApiKernelObjectItem@@QAE@XZ @ 138 NONAME ; CMemSpyApiKernelObjectItem::~CMemSpyApiKernelObjectItem(void)
+	?AllocationOverhead@CMemSpyApiHeap@@QAEHXZ @ 139 NONAME ; int CMemSpyApiHeap::AllocationOverhead(void)
+	?NameOfOwner@CMemSpyApiKernelObjectItem@@QBEABVTDesC8@@XZ @ 140 NONAME ; class TDesC8 const & CMemSpyApiKernelObjectItem::NameOfOwner(void) const
+	?OutputAllContainerContents@RMemSpySession@@QAEXXZ @ 141 NONAME ; void RMemSpySession::OutputAllContainerContents(void)
+	?OutputKernelObjectsL@RMemSpySession@@QAEXXZ @ 142 NONAME ; void RMemSpySession::OutputKernelObjectsL(void)
+	?ThreadSystemPermanentOrCritical@RMemSpySession@@QAEHVTThreadId@@H@Z @ 143 NONAME ; int RMemSpySession::ThreadSystemPermanentOrCritical(class TThreadId, int)
+	?Protection@CMemSpyApiKernelObjectItem@@QBEIXZ @ 144 NONAME ; unsigned int CMemSpyApiKernelObjectItem::Protection(void) const
+	?BiggestFree@CMemSpyApiHeap@@QAEHXZ @ 145 NONAME ; int CMemSpyApiHeap::BiggestFree(void)
+	?Attributes@CMemSpyApiThread@@QBEHXZ @ 146 NONAME ; int CMemSpyApiThread::Attributes(void) const
+	?GetSwmtCyclesCount@RMemSpySession@@QAEHXZ @ 147 NONAME ; int RMemSpySession::GetSwmtCyclesCount(void)
+	?Bottom@CMemSpyApiKernelObjectItem@@QBEHXZ @ 148 NONAME ; int CMemSpyApiKernelObjectItem::Bottom(void) const
+	?StartSwmtTimerL@RMemSpySession@@QAEXXZ @ 149 NONAME ; void RMemSpySession::StartSwmtTimerL(void)
+	?EndProcessL@RMemSpySession@@QAEHVTProcessId@@W4TMemSpyEndType@@@Z @ 150 NONAME ; int RMemSpySession::EndProcessL(class TProcessId, enum TMemSpyEndType)
+	?GetKernelObjectItemsL@RMemSpySession@@QAEXAAV?$RArray@PAVCMemSpyApiKernelObjectItem@@@@W4TMemSpyDriverContainerType@@@Z @ 151 NONAME ; void RMemSpySession::GetKernelObjectItemsL(class RArray<class CMemSpyApiKernelObjectItem *> &, enum TMemSpyDriverContainerType)
+	?NotifyDeviceWideOperationProgress@RMemSpySession@@QAEXAAVTMemSpyDeviceWideOperationProgress@@AAVTRequestStatus@@@Z @ 152 NONAME ; void RMemSpySession::NotifyDeviceWideOperationProgress(class TMemSpyDeviceWideOperationProgress &, class TRequestStatus &)
+	?OutputCompactHeapInfo@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 153 NONAME ; void RMemSpySession::OutputCompactHeapInfo(class TRequestStatus &)
+	?OutputPhoneInfo@RMemSpySession@@QAEXXZ @ 154 NONAME ; void RMemSpySession::OutputPhoneInfo(void)
+	?ThreadHandles@CMemSpyApiThread@@QBEHXZ @ 155 NONAME ; int CMemSpyApiThread::ThreadHandles(void) const
+	?SvrSessionType@CMemSpyApiKernelObjectItem@@QBEEXZ @ 156 NONAME ; unsigned char CMemSpyApiKernelObjectItem::SvrSessionType(void) const
+	?SwitchOutputSinkL@RMemSpySession@@QAEXW4TMemSpySinkType@@@Z @ 157 NONAME ; void RMemSpySession::SwitchOutputSinkL(enum TMemSpySinkType)
+	?ChunkType@CMemSpyApiKernelObjectItem@@QBEIXZ @ 158 NONAME ; unsigned int CMemSpyApiKernelObjectItem::ChunkType(void) const
+	?GetSwmtMode@RMemSpySession@@QAEXAAW4TMemSpyEngineSysMemTrackerMode@TMemSpyEngineHelperSysMemTrackerConfig@@@Z @ 159 NONAME ; void RMemSpySession::GetSwmtMode(enum TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode &)
+	?Id@CMemSpyApiThread@@QBE?AVTThreadId@@XZ @ 160 NONAME ; class TThreadId CMemSpyApiThread::Id(void) const
+	?OutputPhoneInfo@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 161 NONAME ; void RMemSpySession::OutputPhoneInfo(class TRequestStatus &)
+	?GetProcessIdByNameL@RMemSpySession@@QAE?AVTProcessId@@ABVTDesC16@@@Z @ 162 NONAME ; class TProcessId RMemSpySession::GetProcessIdByNameL(class TDesC16 const &)
+	?GetMemoryTrackingCyclesL@RMemSpySession@@QAEXAAV?$RArray@PAVCMemSpyApiMemoryTrackingCycle@@@@@Z @ 163 NONAME ; void RMemSpySession::GetMemoryTrackingCyclesL(class RArray<class CMemSpyApiMemoryTrackingCycle *> &)
+	?MapAttr@CMemSpyApiKernelObjectItem@@QBEIXZ @ 164 NONAME ; unsigned int CMemSpyApiKernelObjectItem::MapAttr(void) const
+	?OutputCompactStackInfo@RMemSpySession@@QAEXAAVTRequestStatus@@@Z @ 165 NONAME ; void RMemSpySession::OutputCompactStackInfo(class TRequestStatus &)
+	?VID@CMemSpyApiProcess@@QBEKXZ @ 166 NONAME ; unsigned long CMemSpyApiProcess::VID(void) const
+	?AddressOfCodeSeg@CMemSpyApiKernelObjectItem@@QAEPAEXZ @ 167 NONAME ; unsigned char * CMemSpyApiKernelObjectItem::AddressOfCodeSeg(void)
+	?GetThreadsL@RMemSpySession@@QAEXVTProcessId@@AAV?$RArray@PAVCMemSpyApiThread@@@@W4TSortType@@@Z @ 168 NONAME ; void RMemSpySession::GetThreadsL(class TProcessId, class RArray<class CMemSpyApiThread *> &, enum TSortType)
+	?ProcessId@CMemSpyApiThread@@QBE?AVTProcessId@@XZ @ 169 NONAME ; class TProcessId CMemSpyApiThread::ProcessId(void) const
+	?Type@CMemSpyApiKernelObjectItem@@QBE?AW4TMemSpyDriverContainerType@@XZ @ 170 NONAME ; enum TMemSpyDriverContainerType CMemSpyApiKernelObjectItem::Type(void) const
+	?ChunkSize@CMemSpyApiHeap@@QAEHXZ @ 171 NONAME ; int CMemSpyApiHeap::ChunkSize(void)
+	?UnitsMask@CMemSpyApiKernelObjectItem@@QBEIXZ @ 172 NONAME ; unsigned int CMemSpyApiKernelObjectItem::UnitsMask(void) const
+	?Name@CMemSpyApiServer@@QBEABVTDesC16@@XZ @ 173 NONAME ; class TDesC16 const & CMemSpyApiServer::Name(void) const
+	?State@CMemSpyApiKernelObjectItem@@QBEEXZ @ 174 NONAME ; unsigned char CMemSpyApiKernelObjectItem::State(void) const
+	?Shared@CMemSpyApiHeap@@QAEHXZ @ 175 NONAME ; int CMemSpyApiHeap::Shared(void)
+	?SetSwmtAutoStartProcessList@RMemSpySession@@QAEXPAV?$CArrayFixFlat@VTUid@@@@@Z @ 176 NONAME ; void RMemSpySession::SetSwmtAutoStartProcessList(class CArrayFixFlat<class TUid> *)
+	?OutputCompactHeapInfoL@RMemSpySession@@QAEXXZ @ 177 NONAME ; void RMemSpySession::OutputCompactHeapInfoL(void)
+	?ProcessSystemPermanentOrCritical@RMemSpySession@@QAEHVTProcessId@@H@Z @ 178 NONAME ; int RMemSpySession::ProcessSystemPermanentOrCritical(class TProcessId, int)
+	??1CMemSpyApiServer@@QAE@XZ @ 179 NONAME ; CMemSpyApiServer::~CMemSpyApiServer(void)
+	?SetSwmtMode@RMemSpySession@@QAEXW4TMemSpyEngineSysMemTrackerMode@TMemSpyEngineHelperSysMemTrackerConfig@@@Z @ 180 NONAME ; void RMemSpySession::SetSwmtMode(enum TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode)
+	?OutputKernelHeapDataL@RMemSpySession@@QAEXXZ @ 181 NONAME ; void RMemSpySession::OutputKernelHeapDataL(void)
+	?Id@CMemSpyApiServer@@QBE?AVTProcessId@@XZ @ 182 NONAME ; class TProcessId CMemSpyApiServer::Id(void) const
+	?MapCount@CMemSpyApiKernelObjectItem@@QBEHXZ @ 183 NONAME ; int CMemSpyApiKernelObjectItem::MapCount(void) const
+	?OpenChannels@CMemSpyApiKernelObjectItem@@QAEHXZ @ 184 NONAME ; int CMemSpyApiKernelObjectItem::OpenChannels(void)
+	?ProcessPriority@CMemSpyApiThread@@QBE?AW4TProcessPriority@@XZ @ 185 NONAME ; enum TProcessPriority CMemSpyApiThread::ProcessPriority(void) const
+	?OutputAOListL@RMemSpySession@@QAEXVTThreadId@@W4TMemSpyThreadInfoItemType@@@Z @ 186 NONAME ; void RMemSpySession::OutputAOListL(class TThreadId, enum TMemSpyThreadInfoItemType)
+	?ThreadNumberUsing@CMemSpyApiThread@@QBEHXZ @ 187 NONAME ; int CMemSpyApiThread::ThreadNumberUsing(void) const
+	?OutputHeapInfoUserL@RMemSpySession@@QAEXVTThreadId@@@Z @ 188 NONAME ; void RMemSpySession::OutputHeapInfoUserL(class TThreadId)
+	?OutputThreadCellListL@RMemSpySession@@QAEXVTThreadId@@@Z @ 189 NONAME ; void RMemSpySession::OutputThreadCellListL(class TThreadId)
+	?SessionCount@CMemSpyApiServer@@QBEHXZ @ 190 NONAME ; int CMemSpyApiServer::SessionCount(void) const
+	??1CMemSpyApiThread@@QAE@XZ @ 191 NONAME ; CMemSpyApiThread::~CMemSpyApiThread(void)
+	?Connect@RMemSpySession@@QAEHXZ @ 192 NONAME ; int RMemSpySession::Connect(void)
+	?GetThreadInfoItems@RMemSpySession@@QAEHAAV?$RArray@PAVCMemSpyApiThreadInfoItem@@@@VTThreadId@@W4TMemSpyThreadInfoItemType@@@Z @ 193 NONAME ; int RMemSpySession::GetThreadInfoItems(class RArray<class CMemSpyApiThreadInfoItem *> &, class TThreadId, enum TMemSpyThreadInfoItemType)
+	?SID@CMemSpyApiThread@@QBEHXZ @ 194 NONAME ; int CMemSpyApiThread::SID(void) const
+	?GetKernelObjectItems@RMemSpySession@@QAEHAAV?$RArray@PAVCMemSpyApiKernelObjectItem@@@@W4TMemSpyDriverContainerType@@@Z @ 195 NONAME ; int RMemSpySession::GetKernelObjectItems(class RArray<class CMemSpyApiKernelObjectItem *> &, enum TMemSpyDriverContainerType)
+	?ProcessHandles@CMemSpyApiThread@@QBEHXZ @ 196 NONAME ; int CMemSpyApiThread::ProcessHandles(void) const
+	?Name@CMemSpyApiThread@@QBEABVTDesC16@@XZ @ 197 NONAME ; class TDesC16 const & CMemSpyApiThread::Name(void) const
+	?Id@CMemSpyApiEComCategory@@QBE?AVTUid@@XZ @ 198 NONAME ; class TUid CMemSpyApiEComCategory::Id(void) const
+	??1CMemSpyApiEComCategory@@UAE@XZ @ 199 NONAME ; CMemSpyApiEComCategory::~CMemSpyApiEComCategory(void)
+	?ImplementationUid@CMemSpyApiEComImplementation@@QBE?AVTUid@@XZ @ 200 NONAME ; class TUid CMemSpyApiEComImplementation::ImplementationUid(void) const
+	?DataType@CMemSpyApiEComImplementation@@QBEABVTDesC16@@XZ @ 201 NONAME ; class TDesC16 const & CMemSpyApiEComImplementation::DataType(void) const
+	?OpaqueData@CMemSpyApiEComImplementation@@QBEABVTDesC16@@XZ @ 202 NONAME ; class TDesC16 const & CMemSpyApiEComImplementation::OpaqueData(void) const
+	?GetEComCategoriesL@RMemSpySession@@QAEXAAV?$RArray@PAVCMemSpyApiEComCategory@@@@@Z @ 203 NONAME ; void RMemSpySession::GetEComCategoriesL(class RArray<class CMemSpyApiEComCategory *> &)
+	?Name@CMemSpyApiEComImplementation@@QBEABVTDesC16@@XZ @ 204 NONAME ; class TDesC16 const & CMemSpyApiEComImplementation::Name(void) const
+	?Drive@CMemSpyApiEComImplementation@@QBE?AVTDriveUnit@@XZ @ 205 NONAME ; class TDriveUnit CMemSpyApiEComImplementation::Drive(void) const
+	?VendorId@CMemSpyApiEComImplementation@@QBE?AVTVendorId@@XZ @ 206 NONAME ; class TVendorId CMemSpyApiEComImplementation::VendorId(void) const
+	?Version@CMemSpyApiEComImplementation@@QBEHXZ @ 207 NONAME ; int CMemSpyApiEComImplementation::Version(void) const
+	?Name@CMemSpyApiEComCategory@@QBEABVTDesC16@@XZ @ 208 NONAME ; class TDesC16 const & CMemSpyApiEComCategory::Name(void) const
+	?GetEComImplementationsL@RMemSpySession@@QAEXVTUid@@AAV?$RArray@PAVCMemSpyApiEComImplementation@@@@@Z @ 209 NONAME ; void RMemSpySession::GetEComImplementationsL(class TUid, class RArray<class CMemSpyApiEComImplementation *> &)
+	??1CMemSpyApiEComImplementation@@UAE@XZ @ 210 NONAME ; CMemSpyApiEComImplementation::~CMemSpyApiEComImplementation(void)
+	?InterfaceCount@CMemSpyApiEComCategory@@QBEHXZ @ 211 NONAME ; int CMemSpyApiEComCategory::InterfaceCount(void) const
+	?Id@CMemSpyApiEComInterface@@QBE?AVTUid@@XZ @ 212 NONAME ; class TUid CMemSpyApiEComInterface::Id(void) const
+	?RomBased@CMemSpyApiEComImplementation@@QBEHXZ @ 213 NONAME ; int CMemSpyApiEComImplementation::RomBased(void) const
+	?RomOnly@CMemSpyApiEComImplementation@@QBEHXZ @ 214 NONAME ; int CMemSpyApiEComImplementation::RomOnly(void) const
+	?GetEComInterfacesL@RMemSpySession@@QAEXVTUid@@AAV?$RArray@PAVCMemSpyApiEComInterface@@@@@Z @ 215 NONAME ; void RMemSpySession::GetEComInterfacesL(class TUid, class RArray<class CMemSpyApiEComInterface *> &)
+	?ImplementationCount@CMemSpyApiEComInterface@@QBEHXZ @ 216 NONAME ; int CMemSpyApiEComInterface::ImplementationCount(void) const
+	??1CMemSpyApiEComInterface@@UAE@XZ @ 217 NONAME ; CMemSpyApiEComInterface::~CMemSpyApiEComInterface(void)
+	?Name@CMemSpyApiEComInterface@@QBEABVTDesC16@@XZ @ 218 NONAME ; class TDesC16 const & CMemSpyApiEComInterface::Name(void) const
+	?Disabled@CMemSpyApiEComImplementation@@QBEHXZ @ 219 NONAME ; int CMemSpyApiEComImplementation::Disabled(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/eabi/MemSpyClientu.def	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,236 @@
+EXPORTS
+	_ZN14CMemSpyApiHeap11BaseAddressEv @ 1 NONAME
+	_ZN14CMemSpyApiHeap11BiggestFreeEv @ 2 NONAME
+	_ZN14CMemSpyApiHeap11HeaderSizeAEv @ 3 NONAME
+	_ZN14CMemSpyApiHeap11HeaderSizeFEv @ 4 NONAME
+	_ZN14CMemSpyApiHeap12FreeOverheadEv @ 5 NONAME
+	_ZN14CMemSpyApiHeap13FragmentationEv @ 6 NONAME
+	_ZN14CMemSpyApiHeap13TotalOverheadEv @ 7 NONAME
+	_ZN14CMemSpyApiHeap14SlackFreeSpaceEv @ 8 NONAME
+	_ZN14CMemSpyApiHeap16AllocationsCountEv @ 9 NONAME
+	_ZN14CMemSpyApiHeap16TotalAllocationsEv @ 10 NONAME
+	_ZN14CMemSpyApiHeap17BiggestAllocationEv @ 11 NONAME
+	_ZN14CMemSpyApiHeap18AllocationOverheadEv @ 12 NONAME
+	_ZN14CMemSpyApiHeap21DebugAllocatorLibraryEv @ 13 NONAME
+	_ZN14CMemSpyApiHeap4SizeEv @ 14 NONAME
+	_ZN14CMemSpyApiHeap4TypeEv @ 15 NONAME
+	_ZN14CMemSpyApiHeap6SharedEv @ 16 NONAME
+	_ZN14CMemSpyApiHeap8OverheadEv @ 17 NONAME
+	_ZN14CMemSpyApiHeap9ChunkSizeEv @ 18 NONAME
+	_ZN14CMemSpyApiHeap9FreeCountEv @ 19 NONAME
+	_ZN14CMemSpyApiHeap9MaxLengthEv @ 20 NONAME
+	_ZN14CMemSpyApiHeap9MinLengthEv @ 21 NONAME
+	_ZN14CMemSpyApiHeap9TotalFreeEv @ 22 NONAME
+	_ZN14CMemSpyApiHeapD1Ev @ 23 NONAME
+	_ZN14CMemSpyApiHeapD2Ev @ 24 NONAME
+	_ZN14RMemSpySession10EndThreadLE9TThreadId14TMemSpyEndType @ 25 NONAME
+	_ZN14RMemSpySession11EndProcessLE10TProcessId14TMemSpyEndType @ 26 NONAME
+	_ZN14RMemSpySession11GetServersLER6RArrayIP16CMemSpyApiServerE @ 27 NONAME
+	_ZN14RMemSpySession11GetServersLER6RArrayIP16CMemSpyApiServerE9TSortType @ 28 NONAME
+	_ZN14RMemSpySession11GetSwmtModeERN38TMemSpyEngineHelperSysMemTrackerConfig30TMemSpyEngineSysMemTrackerModeE @ 29 NONAME
+	_ZN14RMemSpySession11GetThreadsLE10TProcessIdR6RArrayIP16CMemSpyApiThreadE9TSortType @ 30 NONAME
+	_ZN14RMemSpySession11SetSwmtModeEN38TMemSpyEngineHelperSysMemTrackerConfig30TMemSpyEngineSysMemTrackerModeE @ 31 NONAME
+	_ZN14RMemSpySession13GetOutputSinkER15TMemSpySinkType @ 32 NONAME
+	_ZN14RMemSpySession13GetProcessesLER6RArrayIP17CMemSpyApiProcessE9TSortType @ 33 NONAME
+	_ZN14RMemSpySession13GetSwmtFilterER4TBufILi128EE @ 34 NONAME
+	_ZN14RMemSpySession13OutputAOListLE9TThreadId25TMemSpyThreadInfoItemType @ 35 NONAME
+	_ZN14RMemSpySession13SetSwmtFilterERK7TDesC16 @ 36 NONAME
+	_ZN14RMemSpySession14DumpKernelHeapEv @ 37 NONAME
+	_ZN14RMemSpySession14IsSwmtRunningLEv @ 38 NONAME
+	_ZN14RMemSpySession14OutputHeapDataER14TRequestStatus @ 39 NONAME
+	_ZN14RMemSpySession14OutputHeapDataEv @ 40 NONAME
+	_ZN14RMemSpySession14OutputHeapInfoER14TRequestStatus @ 41 NONAME
+	_ZN14RMemSpySession14StopSwmtTimerLEv @ 42 NONAME
+	_ZN14RMemSpySession14SwitchToThreadE9TThreadIdi @ 43 NONAME
+	_ZN14RMemSpySession15ForceSwmtUpdateER14TRequestStatus @ 44 NONAME
+	_ZN14RMemSpySession15GetInfoItemTypeEi9TThreadIdR25TMemSpyThreadInfoItemType @ 45 NONAME
+	_ZN14RMemSpySession15OutputPhoneInfoER14TRequestStatus @ 46 NONAME
+	_ZN14RMemSpySession15OutputPhoneInfoEv @ 47 NONAME
+	_ZN14RMemSpySession15OutputStackInfoER14TRequestStatus @ 48 NONAME
+	_ZN14RMemSpySession15StartSwmtTimerLEi @ 49 NONAME
+	_ZN14RMemSpySession15StartSwmtTimerLEv @ 50 NONAME
+	_ZN14RMemSpySession15SwitchToProcessE10TProcessIdi @ 51 NONAME
+	_ZN14RMemSpySession16ForceSwmtUpdateLEv @ 52 NONAME
+	_ZN14RMemSpySession16GetKernelObjectsER6RArrayIP22CMemSpyApiKernelObjectE @ 53 NONAME
+	_ZN14RMemSpySession16OutputStackDataLE9TThreadId23TMemSpyDriverDomainType @ 54 NONAME
+	_ZN14RMemSpySession16OutputStackInfoLE9TThreadId @ 55 NONAME
+	_ZN14RMemSpySession17GetKernelObjectsLER6RArrayIP22CMemSpyApiKernelObjectE @ 56 NONAME
+	_ZN14RMemSpySession17SwitchOutputSinkLE15TMemSpySinkType @ 57 NONAME
+	_ZN14RMemSpySession17SwmtResetTrackingEv @ 58 NONAME
+	_ZN14RMemSpySession18GetEComCategoriesLER6RArrayIP22CMemSpyApiEComCategoryE @ 59 NONAME
+	_ZN14RMemSpySession18GetEComInterfacesLE4TUidR6RArrayIP23CMemSpyApiEComInterfaceE @ 60 NONAME
+	_ZN14RMemSpySession18GetSwmtCategoriesLERi @ 61 NONAME
+	_ZN14RMemSpySession18GetSwmtCyclesCountEv @ 62 NONAME
+	_ZN14RMemSpySession18GetThreadInfoItemsER6RArrayIP24CMemSpyApiThreadInfoItemE9TThreadId25TMemSpyThreadInfoItemType @ 63 NONAME
+	_ZN14RMemSpySession18SetSwmtCategoriesLEi @ 64 NONAME
+	_ZN14RMemSpySession18SetThreadPriorityLE9TThreadIdi @ 65 NONAME
+	_ZN14RMemSpySession19GetProcessIdByNameLERK7TDesC16 @ 66 NONAME
+	_ZN14RMemSpySession19GetThreadInfoItemsLER6RArrayIP24CMemSpyApiThreadInfoItemE9TThreadId25TMemSpyThreadInfoItemType @ 67 NONAME
+	_ZN14RMemSpySession19OutputHeapInfoUserLE9TThreadId @ 68 NONAME
+	_ZN14RMemSpySession19OutputUserStackDataER14TRequestStatus @ 69 NONAME
+	_ZN14RMemSpySession19SwitchOutputToFileLERK7TDesC16 @ 70 NONAME
+	_ZN14RMemSpySession20GetKernelObjectItemsER6RArrayIP26CMemSpyApiKernelObjectItemE26TMemSpyDriverContainerType @ 71 NONAME
+	_ZN14RMemSpySession20OutputKernelHeapDataER14TRequestStatus @ 72 NONAME
+	_ZN14RMemSpySession20OutputKernelObjectsLEv @ 73 NONAME
+	_ZN14RMemSpySession20SwitchOutputToTraceLEv @ 74 NONAME
+	_ZN14RMemSpySession21GetKernelObjectItemsLER6RArrayIP26CMemSpyApiKernelObjectItemE26TMemSpyDriverContainerType @ 75 NONAME
+	_ZN14RMemSpySession21GetSwmtTimerIntervalLERi @ 76 NONAME
+	_ZN14RMemSpySession21OutputCompactHeapInfoER14TRequestStatus @ 77 NONAME
+	_ZN14RMemSpySession21OutputHeapCellListingER14TRequestStatus @ 78 NONAME
+	_ZN14RMemSpySession21OutputKernelHeapDataLEv @ 79 NONAME
+	_ZN14RMemSpySession21OutputKernelStackDataER14TRequestStatus @ 80 NONAME
+	_ZN14RMemSpySession21OutputThreadCellListLE9TThreadId @ 81 NONAME
+	_ZN14RMemSpySession21OutputThreadHeapDataLE9TThreadId @ 82 NONAME
+	_ZN14RMemSpySession21OutputThreadHeapDataLERK7TDesC16 @ 83 NONAME
+	_ZN14RMemSpySession21SetSwmtTimerIntervalLEi @ 84 NONAME
+	_ZN14RMemSpySession22GetProcessIdByThreadIdER10TProcessId9TThreadId @ 85 NONAME
+	_ZN14RMemSpySession22OutputCompactHeapInfoLEv @ 86 NONAME
+	_ZN14RMemSpySession22OutputCompactStackInfoER14TRequestStatus @ 87 NONAME
+	_ZN14RMemSpySession23GetEComImplementationsLE4TUidR6RArrayIP28CMemSpyApiEComImplementationE @ 88 NONAME
+	_ZN14RMemSpySession23OutputCompactStackInfoLEv @ 89 NONAME
+	_ZN14RMemSpySession23OutputDetailedPhoneInfoER14TRequestStatus @ 90 NONAME
+	_ZN14RMemSpySession24GetMemoryTrackingCyclesLER6RArrayIP29CMemSpyApiMemoryTrackingCycleE @ 91 NONAME
+	_ZN14RMemSpySession24GetSwmtHeapDumpsEnabledLERi @ 92 NONAME
+	_ZN14RMemSpySession24OutputThreadInfoHandlesLE9TThreadId @ 93 NONAME
+	_ZN14RMemSpySession24ServerListOutputGenericLEi @ 94 NONAME
+	_ZN14RMemSpySession24SetSwmtHeapDumpsEnabledLEi @ 95 NONAME
+	_ZN14RMemSpySession26CancelDeviceWideOperationLEv @ 96 NONAME
+	_ZN14RMemSpySession26OutputAllContainerContentsEv @ 97 NONAME
+	_ZN14RMemSpySession27SetSwmtAutoStartProcessListEP13CArrayFixFlatI4TUidE @ 98 NONAME
+	_ZN14RMemSpySession31ThreadSystemPermanentOrCriticalE9TThreadIdi @ 99 NONAME
+	_ZN14RMemSpySession32ProcessSystemPermanentOrCriticalE10TProcessIdi @ 100 NONAME
+	_ZN14RMemSpySession33NotifyDeviceWideOperationProgressER34TMemSpyDeviceWideOperationProgressR14TRequestStatus @ 101 NONAME
+	_ZN14RMemSpySession7ConnectEv @ 102 NONAME
+	_ZN14RMemSpySession7GetHeapEv @ 103 NONAME
+	_ZN14RMemSpySession8GetHeapLEv @ 104 NONAME
+	_ZN14RMemSpySessionC1Ev @ 105 NONAME
+	_ZN14RMemSpySessionC2Ev @ 106 NONAME
+	_ZN16CMemSpyApiServerD1Ev @ 107 NONAME
+	_ZN16CMemSpyApiServerD2Ev @ 108 NONAME
+	_ZN16CMemSpyApiThreadD1Ev @ 109 NONAME
+	_ZN16CMemSpyApiThreadD2Ev @ 110 NONAME
+	_ZN17CMemSpyApiProcessD1Ev @ 111 NONAME
+	_ZN17CMemSpyApiProcessD2Ev @ 112 NONAME
+	_ZN22CMemSpyApiEComCategoryD0Ev @ 113 NONAME
+	_ZN22CMemSpyApiEComCategoryD1Ev @ 114 NONAME
+	_ZN22CMemSpyApiEComCategoryD2Ev @ 115 NONAME
+	_ZN22CMemSpyApiKernelObjectD1Ev @ 116 NONAME
+	_ZN22CMemSpyApiKernelObjectD2Ev @ 117 NONAME
+	_ZN23CMemSpyApiEComInterfaceD0Ev @ 118 NONAME
+	_ZN23CMemSpyApiEComInterfaceD1Ev @ 119 NONAME
+	_ZN23CMemSpyApiEComInterfaceD2Ev @ 120 NONAME
+	_ZN24CMemSpyApiThreadInfoItemD1Ev @ 121 NONAME
+	_ZN24CMemSpyApiThreadInfoItemD2Ev @ 122 NONAME
+	_ZN26CMemSpyApiKernelObjectItem12OpenChannelsEv @ 123 NONAME
+	_ZN26CMemSpyApiKernelObjectItem15AddressOfServerEv @ 124 NONAME
+	_ZN26CMemSpyApiKernelObjectItem16AddressOfCodeSegEv @ 125 NONAME
+	_ZN26CMemSpyApiKernelObjectItem20AddressOfKernelOwnerEv @ 126 NONAME
+	_ZN26CMemSpyApiKernelObjectItem21AddressOfOwningThreadEv @ 127 NONAME
+	_ZN26CMemSpyApiKernelObjectItem22AddressOfOwningProcessEv @ 128 NONAME
+	_ZN26CMemSpyApiKernelObjectItem26AddressOfDataBssStackChunkEv @ 129 NONAME
+	_ZN26CMemSpyApiKernelObjectItemD1Ev @ 130 NONAME
+	_ZN26CMemSpyApiKernelObjectItemD2Ev @ 131 NONAME
+	_ZN28CMemSpyApiEComImplementationD0Ev @ 132 NONAME
+	_ZN28CMemSpyApiEComImplementationD1Ev @ 133 NONAME
+	_ZN28CMemSpyApiEComImplementationD2Ev @ 134 NONAME
+	_ZN29CMemSpyApiMemoryTrackingCycleD1Ev @ 135 NONAME
+	_ZN29CMemSpyApiMemoryTrackingCycleD2Ev @ 136 NONAME
+	_ZNK16CMemSpyApiServer12SessionCountEv @ 137 NONAME
+	_ZNK16CMemSpyApiServer2IdEv @ 138 NONAME
+	_ZNK16CMemSpyApiServer4NameEv @ 139 NONAME
+	_ZNK16CMemSpyApiThread10AttributesEv @ 140 NONAME
+	_ZNK16CMemSpyApiThread12RequestCountEv @ 141 NONAME
+	_ZNK16CMemSpyApiThread13ThreadHandlesEv @ 142 NONAME
+	_ZNK16CMemSpyApiThread14ProcessHandlesEv @ 143 NONAME
+	_ZNK16CMemSpyApiThread14ThreadPriorityEv @ 144 NONAME
+	_ZNK16CMemSpyApiThread15ProcessPriorityEv @ 145 NONAME
+	_ZNK16CMemSpyApiThread17ThreadNumberUsingEv @ 146 NONAME
+	_ZNK16CMemSpyApiThread18ProcessNumberUsingEv @ 147 NONAME
+	_ZNK16CMemSpyApiThread2IdEv @ 148 NONAME
+	_ZNK16CMemSpyApiThread3SIDEv @ 149 NONAME
+	_ZNK16CMemSpyApiThread3VIDEv @ 150 NONAME
+	_ZNK16CMemSpyApiThread4NameEv @ 151 NONAME
+	_ZNK16CMemSpyApiThread6CpuUseEv @ 152 NONAME
+	_ZNK16CMemSpyApiThread8ExitTypeEv @ 153 NONAME
+	_ZNK16CMemSpyApiThread9ProcessIdEv @ 154 NONAME
+	_ZNK17CMemSpyApiProcess10ExitReasonEv @ 155 NONAME
+	_ZNK17CMemSpyApiProcess11ThreadCountEv @ 156 NONAME
+	_ZNK17CMemSpyApiProcess12ExitCategoryEv @ 157 NONAME
+	_ZNK17CMemSpyApiProcess2IdEv @ 158 NONAME
+	_ZNK17CMemSpyApiProcess3SIDEv @ 159 NONAME
+	_ZNK17CMemSpyApiProcess3VIDEv @ 160 NONAME
+	_ZNK17CMemSpyApiProcess4NameEv @ 161 NONAME
+	_ZNK17CMemSpyApiProcess6IsDeadEv @ 162 NONAME
+	_ZNK17CMemSpyApiProcess8ExitTypeEv @ 163 NONAME
+	_ZNK17CMemSpyApiProcess8PriorityEv @ 164 NONAME
+	_ZNK22CMemSpyApiEComCategory14InterfaceCountEv @ 165 NONAME
+	_ZNK22CMemSpyApiEComCategory2IdEv @ 166 NONAME
+	_ZNK22CMemSpyApiEComCategory4NameEv @ 167 NONAME
+	_ZNK22CMemSpyApiKernelObject4NameEv @ 168 NONAME
+	_ZNK22CMemSpyApiKernelObject4SizeEv @ 169 NONAME
+	_ZNK22CMemSpyApiKernelObject4TypeEv @ 170 NONAME
+	_ZNK22CMemSpyApiKernelObject5CountEv @ 171 NONAME
+	_ZNK23CMemSpyApiEComInterface19ImplementationCountEv @ 172 NONAME
+	_ZNK23CMemSpyApiEComInterface2IdEv @ 173 NONAME
+	_ZNK23CMemSpyApiEComInterface4NameEv @ 174 NONAME
+	_ZNK24CMemSpyApiThreadInfoItem5ValueEv @ 175 NONAME
+	_ZNK24CMemSpyApiThreadInfoItem7CaptionEv @ 176 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem10AttributesEv @ 177 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem10NameDetailEv @ 178 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem10ProtectionEv @ 179 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem10TimerStateEv @ 180 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem11AccessCountEv @ 181 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem11NameOfOwnerEv @ 182 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem11SessionTypeEv @ 183 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem12RestrictionsEv @ 184 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem12SecurityZoneEv @ 185 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem14SvrSessionTypeEv @ 186 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem16ControllingOwnerEv @ 187 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem16TotalAccessCountEv @ 188 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem2IdEv @ 189 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem3TopEv @ 190 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem4NameEv @ 191 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem4SizeEv @ 192 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem4TypeEv @ 193 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem5CountEv @ 194 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem5OrderEv @ 195 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem5StateEv @ 196 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem6BottomEv @ 197 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem6HandleEv @ 198 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem7ChangesEv @ 199 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem7MapAttrEv @ 200 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem7MaxSizeEv @ 201 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem7VersionEv @ 202 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem8MapCountEv @ 203 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem8MsgCountEv @ 204 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem8MsgLimitEv @ 205 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem8PriorityEv @ 206 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem8StartPosEv @ 207 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem8UniqueIDEv @ 208 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem9ChunkTypeEv @ 209 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem9CreatorIdEv @ 210 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem9ParseMaskEv @ 211 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem9ResettingEv @ 212 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem9TimerTypeEv @ 213 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem9UnitsMaskEv @ 214 NONAME
+	_ZNK26CMemSpyApiKernelObjectItem9WaitCountEv @ 215 NONAME
+	_ZNK28CMemSpyApiEComImplementation10OpaqueDataEv @ 216 NONAME
+	_ZNK28CMemSpyApiEComImplementation17ImplementationUidEv @ 217 NONAME
+	_ZNK28CMemSpyApiEComImplementation4NameEv @ 218 NONAME
+	_ZNK28CMemSpyApiEComImplementation5DriveEv @ 219 NONAME
+	_ZNK28CMemSpyApiEComImplementation7RomOnlyEv @ 220 NONAME
+	_ZNK28CMemSpyApiEComImplementation7VersionEv @ 221 NONAME
+	_ZNK28CMemSpyApiEComImplementation8DataTypeEv @ 222 NONAME
+	_ZNK28CMemSpyApiEComImplementation8DisabledEv @ 223 NONAME
+	_ZNK28CMemSpyApiEComImplementation8RomBasedEv @ 224 NONAME
+	_ZNK28CMemSpyApiEComImplementation8VendorIdEv @ 225 NONAME
+	_ZNK29CMemSpyApiMemoryTrackingCycle10FreeMemoryEv @ 226 NONAME
+	_ZNK29CMemSpyApiMemoryTrackingCycle11ChangeCountEv @ 227 NONAME
+	_ZNK29CMemSpyApiMemoryTrackingCycle11CycleNumberEv @ 228 NONAME
+	_ZNK29CMemSpyApiMemoryTrackingCycle11MemoryDeltaEv @ 229 NONAME
+	_ZNK29CMemSpyApiMemoryTrackingCycle17PreviousCycleDiffEv @ 230 NONAME
+	_ZNK29CMemSpyApiMemoryTrackingCycle4TimeEv @ 231 NONAME
+	_ZNK29CMemSpyApiMemoryTrackingCycle7CaptionEv @ 232 NONAME
+	_ZNK34TMemSpyDeviceWideOperationProgress11DescriptionEv @ 233 NONAME
+	_ZNK34TMemSpyDeviceWideOperationProgress8ProgressEv @ 234 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/group/MemSpyClient.mmp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,57 @@
+/*
+* 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 <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGETTYPE dll
+TARGET MemSpyClient.dll
+UID 0 0x2002EA8E
+VENDORID	VID_DEFAULT
+SMPSAFE
+
+CAPABILITY PowerMgmt SwEvent ReadUserData WriteUserData ReadDeviceData WriteDeviceData CommDD MultimediaDD DRM TrustedUI ProtServ DiskAdmin NetworkControl AllFiles NetworkServices LocalServices Location SurroundingsDD UserEnvironment
+
+SOURCEPATH ../src
+SOURCE 		memspysession.cpp 
+SOURCE 		memspyapiprocess.cpp 
+SOURCE 		memspyapikernelobject.cpp 
+SOURCE		memspyapiheap.cpp 
+SOURCE 		memspyapikernelobjectitem.cpp 
+SOURCE		memspyapithread.cpp 
+SOURCE		memspyapithreadinfoitem.cpp
+SOURCE		memspyapimemorytrackingcycle.cpp
+SOURCE 		memspyapiserver.cpp
+SOURCE 		memspyapiecom.cpp  
+
+USERINCLUDE ../inc
+
+OS_LAYER_SYSTEMINCLUDE
+
+LIBRARY 		euser.lib
+LIBRARY			ecom.lib
+LIBRARY			efsrv.lib
+LIBRARY			estor.lib
+LIBRARY			bafl.lib
+LIBRARY			ws32.lib
+LIBRARY			cone.lib
+LIBRARY			eikcore.lib
+LIBRARY			fbscli.lib 
+LIBRARY 		PlatformEnv.lib
+LIBRARY         MemSpyEngine.lib
+
+//EXPORTUNFROZEN
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/group/bld.inf	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* 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 <platform_paths.hrh>
+
+PRJ_EXPORTS
+// Public API
+../inc/memspysession.h OS_LAYER_PLATFORM_EXPORT_PATH(memspysession.h)
+../inc/memspyprocessdata.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/engine/memspyprocessdata.h)
+../inc/memspykernelobjectdata.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/engine/memspykernelobjectdata.h)
+../inc/memspyheapdata.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/engine/memspyheapdata.h)
+../inc/memspythreaddata.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/engine/memspythreaddata.h)
+../inc/memspythreadinfoitemdata.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/engine/memspythreadinfoitemdata.h)
+../inc/memspymemorytrackingcycledata.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/engine/memspymemorytrackingcycledata.h)
+../inc/memspyserverdata.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/engine/memspyserverdata.h)
+../inc/memspyecomdata.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/engine/memspyecomdata.h)
+
+../inc/memspyapiprocess.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/api/memspyapiprocess.h)
+../inc/memspyapikernelobject.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/api/memspyapikernelobject.h)
+../inc/memspyapikernelobjectitem.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/api/memspyapikernelobjectitem.h)
+../inc/memspyapiheap.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/api/memspyapiheap.h)
+../inc/memspyapithread.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/api/memspyapithread.h)
+../inc/memspyapithreadinfoitem.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/api/memspyapithreadinfoitem.h)
+../inc/memspyapimemorytrackingcycle.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/api/memspyapimemorytrackingcycle.h)
+../inc/memspyapiserver.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/api/memspyapiserver.h)
+../inc/memspyapiecom.h OS_LAYER_PLATFORM_EXPORT_PATH(memspy/api/memspyapiecom.h)
+
+PRJ_MMPFILES
+MemSpyClient.mmp
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyapiecom.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,116 @@
+/*
+* 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:
+* Contains the declaration of  CMemSpyProcess class 
+*/
+
+#ifndef MEMSPYAPIECOM_H
+#define MEMSPYAPIECOM_H
+
+// System includes
+#include <e32base.h>
+#include <f32file.h>
+
+class TMemSpyEComCategoryData;
+class TMemSpyEComInterfaceData;
+class TMemSpyEComImplementationData;
+
+NONSHARABLE_CLASS( CMemSpyApiEComCategory ) : public CBase
+	{
+public:
+	IMPORT_C ~CMemSpyApiEComCategory();
+	
+	static CMemSpyApiEComCategory* NewL(const TMemSpyEComCategoryData& aData);
+
+	static CMemSpyApiEComCategory* NewLC(const TMemSpyEComCategoryData& aData);
+	
+public:
+	IMPORT_C TUid Id() const;
+	
+	IMPORT_C const TDesC& Name() const;
+	
+	IMPORT_C TInt InterfaceCount() const;
+	
+private:
+	void ConstructL(const TMemSpyEComCategoryData& aData);
+		
+private:
+	TMemSpyEComCategoryData *iData;
+};
+
+NONSHARABLE_CLASS( CMemSpyApiEComInterface ) : public CBase
+    {
+public:
+    IMPORT_C ~CMemSpyApiEComInterface();
+    
+    static CMemSpyApiEComInterface* NewL(const TMemSpyEComInterfaceData& aData);
+
+    static CMemSpyApiEComInterface* NewLC(const TMemSpyEComInterfaceData& aData);
+    
+public:
+    IMPORT_C TUid Id() const;
+    
+    IMPORT_C TUid CategoryId() const;
+    
+    IMPORT_C const TDesC& Name() const;
+    
+    IMPORT_C TInt ImplementationCount() const;
+    
+private:
+    void ConstructL(const TMemSpyEComInterfaceData& aData);
+        
+private:
+    TMemSpyEComInterfaceData *iData;
+};
+
+NONSHARABLE_CLASS( CMemSpyApiEComImplementation ) : public CBase 
+    {
+public:
+    IMPORT_C ~CMemSpyApiEComImplementation();
+    
+    static CMemSpyApiEComImplementation* NewL(const TMemSpyEComImplementationData& aData);
+
+    static CMemSpyApiEComImplementation* NewLC(const TMemSpyEComImplementationData& aData);
+    
+public:
+    IMPORT_C TUid ImplementationUid() const;
+        
+    IMPORT_C const TDesC& Name() const;
+    
+    IMPORT_C TInt Version() const;
+    
+    IMPORT_C const TDesC& DataType() const;
+        
+    IMPORT_C const TDesC& OpaqueData() const;
+    
+    IMPORT_C TDriveUnit Drive() const;
+        
+    IMPORT_C TBool RomOnly() const;
+        
+    IMPORT_C TBool RomBased() const;
+        
+    IMPORT_C TVendorId VendorId() const;
+        
+    IMPORT_C TBool Disabled() const;
+    
+private:
+    
+    void ConstructL(const TMemSpyEComImplementationData& aData);
+        
+private:
+    TMemSpyEComImplementationData *iData;
+};
+
+
+#endif // MEMSPYAPIECOM_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyapiheap.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,69 @@
+/*
+* 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:
+* Contains the declaration of  CMemSpyApiHeap class 
+*/
+
+#ifndef MEMSPYAPIHEAP_H
+#define MEMSPYAPIHEAP_H
+
+// System includes
+#include <e32base.h>
+
+class TMemSpyHeapData;
+
+NONSHARABLE_CLASS( CMemSpyApiHeap ) 
+	{
+public:
+	IMPORT_C ~CMemSpyApiHeap();
+	
+	static CMemSpyApiHeap* NewL(const TMemSpyHeapData& aData);
+
+	static CMemSpyApiHeap* NewLC(const TMemSpyHeapData& aData);
+	
+public: //API
+	IMPORT_C TDesC& Type();
+	IMPORT_C TInt Size();
+	IMPORT_C TInt BaseAddress();
+	IMPORT_C TBool Shared();
+	IMPORT_C TInt ChunkSize();
+	IMPORT_C TInt AllocationsCount();
+	IMPORT_C TInt FreeCount();
+	IMPORT_C TInt BiggestAllocation();
+	IMPORT_C TInt BiggestFree();
+	IMPORT_C TInt TotalAllocations();
+	IMPORT_C TInt TotalFree();
+	IMPORT_C TInt SlackFreeSpace();
+	IMPORT_C TInt Fragmentation(); // Percentage value, iSize is 100% - value for calculation
+	IMPORT_C TInt HeaderSizeA();
+	IMPORT_C TInt HeaderSizeF();
+	IMPORT_C TInt AllocationOverhead();
+	IMPORT_C TInt FreeOverhead();
+	IMPORT_C TInt TotalOverhead();
+	IMPORT_C TInt Overhead(); //Percentage value, iSize is 100% - value for calculation
+	IMPORT_C TInt MinLength();
+	IMPORT_C TInt MaxLength();
+	IMPORT_C TBool DebugAllocatorLibrary();
+	
+private:
+	CMemSpyApiHeap();
+	
+	void ConstructL(const TMemSpyHeapData& aData);
+		
+private:
+	TMemSpyHeapData *iHeapData;
+};
+
+	
+#endif // MEMSPYAPIHEAP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyapikernelobject.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,56 @@
+/*
+* 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:
+*  
+*/
+
+#ifndef MEMSPYAPIPKERNELOBJECT_H
+#define MEMSPYAPIPKERNELOBJECT_H
+
+// System includes
+#include <e32base.h>
+
+#include <memspy/driver/memspydriverenumerationsshared.h>
+
+class TMemSpyKernelObjectData;
+
+NONSHARABLE_CLASS( CMemSpyApiKernelObject ) 
+	{
+public:
+	IMPORT_C ~CMemSpyApiKernelObject();
+	
+	static CMemSpyApiKernelObject* NewL(const TMemSpyKernelObjectData& aData);
+
+	static CMemSpyApiKernelObject* NewLC(const TMemSpyKernelObjectData& aData);
+	
+public:
+	IMPORT_C TMemSpyDriverContainerType Type() const;
+	
+	IMPORT_C const TDesC& Name() const;	
+						
+	IMPORT_C TInt Count() const;
+		
+	IMPORT_C TInt64 Size() const;
+	
+private:
+	CMemSpyApiKernelObject();
+	
+	void ConstructL(const TMemSpyKernelObjectData& aData);
+		
+private:
+	TMemSpyKernelObjectData *iKernelObjectData;
+};
+
+	
+#endif // MEMSPYAPIPKERNELOBJECT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyapikernelobjectitem.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,128 @@
+/*
+* 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:
+* Contains the declaration of  CMemSpyProcess class 
+*/
+
+#ifndef MEMSPYAPIKERNELOBJECTITEM_H
+#define MEMSPYAPIKERNELOBJECTITEM_H
+
+// System includes
+#include <e32base.h>
+#include <memspy/driver/memspydriverenumerationsshared.h>
+
+class TMemSpyDriverHandleInfoGeneric;
+//class TMemSpyDriverContainerType;	
+//class TMemSpyDriverTimerType;
+//class TMemSpyDriverTimerState;
+
+NONSHARABLE_CLASS( CMemSpyApiKernelObjectItem ) 
+	{
+public:
+	IMPORT_C ~CMemSpyApiKernelObjectItem();
+	
+	static CMemSpyApiKernelObjectItem* NewL(const TMemSpyDriverHandleInfoGeneric& aData);
+
+	static CMemSpyApiKernelObjectItem* NewLC(const TMemSpyDriverHandleInfoGeneric& aData);
+	
+public:	
+	
+	IMPORT_C const TDesC8& Name() const;	
+	
+	IMPORT_C TAny* Handle() const;
+	
+	IMPORT_C TMemSpyDriverContainerType Type() const;
+	
+    // For Process, thread, chunk (owning process id), server (owning thread id)
+    IMPORT_C TInt Id() const;
+
+    // For Chunk, Library
+    IMPORT_C TUint32 Size() const;
+   
+    // For Semaphore, Mutex, Server
+    IMPORT_C TInt Count() const;
+
+    // For Mutex
+    IMPORT_C TInt WaitCount() const;
+
+    // For Server, Session
+    IMPORT_C TIpcSessionType SessionType() const;
+
+    // For Timer
+    IMPORT_C TMemSpyDriverTimerType TimerType() const;
+    IMPORT_C TMemSpyDriverTimerState TimerState() const;
+
+    // For Logical channel
+    IMPORT_C TInt OpenChannels();
+    
+    // For most of the object types
+    IMPORT_C const TDesC8& NameDetail() const; // Name
+    IMPORT_C TInt AccessCount() const;
+    IMPORT_C TInt UniqueID() const;
+    IMPORT_C TUint Protection() const;
+    IMPORT_C TUint8* AddressOfKernelOwner();
+    IMPORT_C TInt Priority() const;
+    IMPORT_C TUint8* AddressOfOwningProcess();
+    IMPORT_C TUint CreatorId() const;
+    IMPORT_C TUint SecurityZone() const;
+    IMPORT_C TInt Attributes() const;
+    IMPORT_C TUint8* AddressOfDataBssStackChunk();
+
+    // For Server, Session
+    IMPORT_C TUint8* AddressOfOwningThread();
+    IMPORT_C TUint8* AddressOfServer();
+    IMPORT_C TUint16 TotalAccessCount() const;
+    IMPORT_C TUint8 SvrSessionType() const;
+    IMPORT_C TInt MsgCount() const;
+    IMPORT_C TInt MsgLimit() const;
+    
+    // For chunk
+    IMPORT_C TInt MaxSize() const;
+    IMPORT_C TInt Bottom() const;
+    IMPORT_C TInt Top() const;
+    IMPORT_C TInt StartPos() const;
+    IMPORT_C TUint ControllingOwner() const;
+    IMPORT_C TUint Restrictions() const;
+    IMPORT_C TUint MapAttr() const;
+    IMPORT_C TUint ChunkType() const;
+    IMPORT_C const TDesC8& NameOfOwner() const; // chunk, server
+    
+    // For library
+    IMPORT_C TInt MapCount() const;
+    IMPORT_C TUint8 State() const;
+    IMPORT_C TUint8* AddressOfCodeSeg();
+    
+    // Semaphore, mutex, condvar
+    IMPORT_C TUint8 Resetting() const;
+    IMPORT_C TUint8 Order() const;
+    
+    // For Logical/Physical device
+    IMPORT_C TVersion Version() const;
+    IMPORT_C TUint ParseMask() const;
+    IMPORT_C TUint UnitsMask() const;
+    
+    // For change notifier
+    IMPORT_C TUint Changes() const;
+	
+private:
+	CMemSpyApiKernelObjectItem();
+	
+	void ConstructL(const TMemSpyDriverHandleInfoGeneric& aData);
+		
+private:
+	TMemSpyDriverHandleInfoGeneric *iItem;
+};
+
+	
+#endif // MEMSPYAPIKERNELOBJECTITEM_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyapimemorytrackingcycle.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,53 @@
+/*
+* 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:
+* 
+*/
+
+#ifndef MEMSPYAPIMEMORYTRACKINGCYCLE_H_
+#define MEMSPYAPIMEMORYTRACKINGCYCLE_H_
+
+#include <e32base.h>
+
+class TMemSpyMemoryTrackingCycleData;
+
+class CMemSpyApiMemoryTrackingCycle
+	{
+public: // API
+	IMPORT_C TInt CycleNumber() const;
+	IMPORT_C const TTime& Time() const;
+	IMPORT_C const TDesC& Caption() const;
+	IMPORT_C const TInt64& FreeMemory() const;
+	IMPORT_C TInt64 MemoryDelta() const;
+	IMPORT_C TInt64 PreviousCycleDiff() const;
+	IMPORT_C TInt ChangeCount() const;
+	
+public:
+	IMPORT_C ~CMemSpyApiMemoryTrackingCycle();
+	
+	static CMemSpyApiMemoryTrackingCycle* NewL(const TMemSpyMemoryTrackingCycleData& aData);
+
+	static CMemSpyApiMemoryTrackingCycle* NewLC(const TMemSpyMemoryTrackingCycleData& aData);
+	
+private:
+	CMemSpyApiMemoryTrackingCycle();
+	
+	void ConstructL(const TMemSpyMemoryTrackingCycleData& aData);
+	
+private:
+	TMemSpyMemoryTrackingCycleData* iData;
+	
+	};
+
+#endif /* MEMSPYAPIMEMORYTRACKINGCYCLE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyapiprocess.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,67 @@
+/*
+* 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:
+* Contains the declaration of  CMemSpyProcess class 
+*/
+
+#ifndef MEMSPYAPIPROCESS_H
+#define MEMSPYAPIPROCESS_H
+
+// System includes
+#include <e32base.h>
+
+class TMemSpyProcessData;
+
+NONSHARABLE_CLASS( CMemSpyApiProcess ) 
+	{
+public:
+	IMPORT_C ~CMemSpyApiProcess();
+	
+	static CMemSpyApiProcess* NewL(const TMemSpyProcessData& aData);
+
+	static CMemSpyApiProcess* NewLC(const TMemSpyProcessData& aData);
+	
+public:
+	IMPORT_C TProcessId Id() const;
+	
+	IMPORT_C const TDesC& Name() const;	
+	
+	IMPORT_C TExitCategoryName ExitCategory() const;
+	
+	IMPORT_C TInt ExitReason() const;
+	
+	IMPORT_C TExitType ExitType() const;
+	
+	IMPORT_C TInt ThreadCount() const;
+	
+	IMPORT_C TUint32 SID() const;
+	
+	IMPORT_C TUint32 VID() const;
+	
+	IMPORT_C TProcessPriority Priority() const;
+	
+	IMPORT_C TBool IsDead() const;
+	
+	
+private:
+	CMemSpyApiProcess();
+	
+	void ConstructL(const TMemSpyProcessData& aData);
+		
+private:
+	TMemSpyProcessData *iProcessData;
+};
+
+	
+#endif // MEMSPYAPIPROCESS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyapiserver.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* 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:
+* Contains the declaration of  CMemSpyProcess class 
+*/
+
+#ifndef MEMSPYAPISERVER_H
+#define MEMSPYAPISERVER_H
+
+// System includes
+#include <e32base.h>
+
+class TMemSpyServerData;
+
+NONSHARABLE_CLASS( CMemSpyApiServer ) 
+	{
+public:
+	IMPORT_C ~CMemSpyApiServer();
+	
+	static CMemSpyApiServer* NewL(const TMemSpyServerData& aData);
+
+	static CMemSpyApiServer* NewLC(const TMemSpyServerData& aData);
+	
+public:
+	IMPORT_C TProcessId Id() const;
+	
+	IMPORT_C const TDesC& Name() const;	
+	
+	IMPORT_C TInt SessionCount() const;
+	
+private:
+	CMemSpyApiServer();
+	
+	void ConstructL(const TMemSpyServerData& aData);
+		
+private:
+	TMemSpyServerData *iData;
+};
+
+	
+#endif // MEMSPYAPISERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyapithread.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,73 @@
+/*
+* 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:
+* Contains the declaration of  CMemSpyProcessWrapper class and TMemSpyProcess data class
+*/
+
+#ifndef MEMSPYAPITHREAD_H
+#define MEMSPYAPITHREAD_H
+
+// System includes
+#include <e32base.h>
+
+class TMemSpyThreadData;
+
+NONSHARABLE_CLASS( CMemSpyApiThread ) {
+
+public:
+	IMPORT_C ~CMemSpyApiThread();
+	
+	static CMemSpyApiThread* NewL(const TMemSpyThreadData& aData);
+
+	static CMemSpyApiThread* NewLC(const TMemSpyThreadData& aData);
+
+public:
+	IMPORT_C TThreadId Id() const;
+	IMPORT_C TProcessId ProcessId() const;
+	
+	IMPORT_C const TDesC& Name() const;
+		
+	IMPORT_C TInt SID() const;
+	
+	IMPORT_C TInt VID() const;
+	
+	IMPORT_C TThreadPriority ThreadPriority() const;
+	
+	IMPORT_C TProcessPriority ProcessPriority() const;
+	
+	IMPORT_C TInt RequestCount() const;
+	
+	IMPORT_C TInt ThreadHandles() const;
+	
+	IMPORT_C TInt ProcessHandles() const;
+	
+	IMPORT_C TInt ThreadNumberUsing() const;
+	
+	IMPORT_C TInt ProcessNumberUsing() const;
+	
+	IMPORT_C TInt Attributes() const;
+	
+	IMPORT_C TInt CpuUse() const;
+	
+	IMPORT_C TExitType ExitType() const;
+	
+private:
+	CMemSpyApiThread();	
+	
+	void ConstructL(const TMemSpyThreadData& aData);
+private:
+	TMemSpyThreadData* iThreadData;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyapithreadinfoitem.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,50 @@
+/*
+* 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:
+* Contains the declaration of  CMemSpyProcess class 
+*/
+
+#ifndef MEMSPYAPITHREADINFOITEM_H
+#define MEMSPYAPITHREADINFOITEM_H
+
+// System includes
+#include <e32base.h>
+
+class TMemSpyThreadInfoItemData;
+
+NONSHARABLE_CLASS( CMemSpyApiThreadInfoItem ) 
+	{
+public:
+	IMPORT_C ~CMemSpyApiThreadInfoItem();
+	
+	static CMemSpyApiThreadInfoItem* NewL(const TMemSpyThreadInfoItemData& aData);
+
+	static CMemSpyApiThreadInfoItem* NewLC(const TMemSpyThreadInfoItemData& aData);
+	
+public:		
+	IMPORT_C const TDesC& Caption() const;	
+	
+	IMPORT_C const TDesC& Value() const;	
+	
+private:
+	CMemSpyApiThreadInfoItem();
+	
+	void ConstructL(const TMemSpyThreadInfoItemData& aData);
+		
+private:
+	TMemSpyThreadInfoItemData *iInfoItem;
+};
+
+	
+#endif // MEMSPYAPITHREADINFOITEM_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyecomdata.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,68 @@
+/*
+* 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:
+* Contains the declaration of  TMemSpyProcessData class
+*/
+
+#ifndef MEMSPYECOMDATA_H
+#define MEMSPYECOMDATA_H
+
+// TMemSpyProcess data class holds data to be sent to the UI
+class TMemSpyEComCategoryData 
+	{	
+public:
+	//constructor & destructor
+	inline TMemSpyEComCategoryData ()
+		: iInterfaceCount(0)
+		{
+		}
+	
+public:
+    TUid iId;        
+    TFullName iName;
+    TInt iInterfaceCount;
+	};
+
+class TMemSpyEComInterfaceData 
+    {   
+public:
+    //constructor & destructor
+    inline TMemSpyEComInterfaceData ()
+        : iImplementationCount(0)
+        {
+        }
+    
+public:
+    TUid iId;
+    TUid iCategoryId;
+    TFullName iName;
+    TInt iImplementationCount;
+    };
+
+class TMemSpyEComImplementationData 
+    {   
+public:
+    TUid iImplementationUid;
+    TFullName iName;
+    TInt iVersion;
+    TFullName iDataType;
+    TFullName iOpaqueData;
+    TDriveUnit iDrive;
+    TBool iRomOnly;
+    TBool iRomBased;
+    TVendorId iVendorId;    
+    TBool iDisabled;
+    };
+
+#endif // MEMSPYECOMDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyheapdata.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,64 @@
+/*
+* 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:
+* Contains the declaration of  TMemSpyProcessData class
+*/
+
+#ifndef MEMSPYHEAPDATA_H
+#define MEMSPYHEAPDATA_H
+
+#include <memspy/driver/memspydriverobjectsshared.h>
+
+// Constants
+const TInt KBuf = 16;
+
+// TMemSpyProcess data class holds data to be sent to the UI
+class TMemSpyHeapData 
+	{	
+public:
+	//constructor & destructor
+	inline TMemSpyHeapData()		
+	: iSize(0), iBaseAddress(0), iShared(EFalse), iChunkSize(0),
+	iAllocationsCount(0), iFreeCount(0), iBiggestAllocation(0), iBiggestFree(0), iTotalAllocations(0),
+    iTotalFree(0), iSlackFreeSpace(0), iFragmentation(0), iHeaderSizeA(0), iHeaderSizeF(0), iAllocationOverhead(0),
+    iFreeOverhead(0), iTotalOverhead(0), iOverhead(0), iMinLength(0), iMaxLength(0), iDebugAllocatorLibrary(EFalse)
+		{
+		}
+	
+public:
+	TBuf<KBuf> iType;
+	TUint iSize;
+	TLinAddr iBaseAddress;
+	TBool iShared;
+	TUint iChunkSize;
+	TUint iAllocationsCount;
+	TUint iFreeCount;
+	TUint iBiggestAllocation;
+	TUint iBiggestFree;
+    TUint iTotalAllocations;
+    TUint iTotalFree;
+    TUint iSlackFreeSpace;
+    TReal iFragmentation;
+    TUint iHeaderSizeA;
+    TUint iHeaderSizeF;
+    TUint iAllocationOverhead;
+    TUint iFreeOverhead;
+    TUint iTotalOverhead;
+    TReal iOverhead;
+    TInt iMinLength;
+    TInt iMaxLength;
+    TBool iDebugAllocatorLibrary;
+	};
+
+#endif // MEMSPYHEAPDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspykernelobjectdata.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,43 @@
+/*
+* 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:
+* Contains the declaration of  TMemSpyProcessData class
+*/
+
+#ifndef MEMSPYKERNELOBJECTDATA_H
+#define MEMSPYKERNELOBJECTDATA_H
+
+#include <memspy/driver/memspydriverenumerationsshared.h>
+
+// Constants
+const TInt KBufSize = 128;
+
+// TMemSpyProcess data class holds data to be sent to the UI
+class TMemSpyKernelObjectData 
+	{	
+public:
+	//constructor & destructor
+	inline TMemSpyKernelObjectData()
+		: iCount(0), iSize(0)
+		{
+		}
+	
+public:    
+    TMemSpyDriverContainerType iType;
+    TFullName iName;
+    TInt iCount;
+    TInt64 iSize;
+	};
+
+#endif // MEMSPYKERNELOBJECTDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspymemorytrackingcycledata.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* 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:
+* 
+*/
+
+
+#ifndef MEMSPYMEMORYTRACKINGCYCLEDATA_H_
+#define MEMSPYMEMORYTRACKINGCYCLEDATA_H_
+
+struct TMemSpyMemoryTrackingCycleData
+	{
+	TInt iCycleNumber;
+	TTime iTime;
+	TFullName iCaption;
+	TInt64 iFreeMemory;
+	TInt64 iMemoryDelta;
+	TInt64 iPreviousCycleDiff;
+	TInt iChangeCount;
+	};
+
+#endif /* MEMSPYMEMORYTRACKINGCYCLEDATA_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyprocessdata.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,46 @@
+/*
+* 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:
+* Contains the declaration of  TMemSpyProcessData class
+*/
+
+#ifndef MEMSPYPROCESSDATA_H
+#define MEMSPYPROCESSDATA_H
+
+#include <memspy/driver/memspydriverobjectsshared.h>
+
+// TMemSpyProcess data class holds data to be sent to the UI
+class TMemSpyProcessData 
+	{	
+public:
+	//constructor & destructor
+	inline TMemSpyProcessData()
+		: iId(0), iThreadCount(0), iExitCategory(0), iExitReason(0)
+		{
+		}
+	
+public:
+    TProcessId iId;        
+    TFullName iName;
+    TProcessPriority iPriority;
+    TExitCategoryName iExitCategory;
+    TInt iExitReason;
+    TExitType iExitType;
+    TInt iThreadCount;
+    TUint32 iSID;
+    TUint32 iVID;
+    TBool iIsDead;
+	};
+
+#endif // MEMSPYPROCESSDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspyserverdata.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,37 @@
+/*
+* 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:
+* Contains the declaration of  TMemSpyProcessData class
+*/
+
+#ifndef MEMSPYSERVERDATA_H
+#define MEMSPYSERVERDATA_H
+
+// TMemSpyProcess data class holds data to be sent to the UI
+class TMemSpyServerData 
+	{	
+public:
+	//constructor & destructor
+	inline TMemSpyServerData()
+		: iId(0), iSessionCount(0)
+		{
+		}
+	
+public:
+    TProcessId iId;        
+    TFullName iName;
+    TInt iSessionCount;
+	};
+
+#endif // MEMSPYSERVERDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspysession.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,282 @@
+/*
+* 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:
+*
+*/
+
+
+#ifndef MEMSPYSESSION_H
+#define MEMSPYSESSION_H
+
+
+// System includes
+#include <e32base.h>
+#include <u32std.h>
+
+//user includes
+#include <memspy/api/memspyapiprocess.h>
+
+#include <memspy/api/memspyapithread.h>
+#include <memspy/api/memspyapithreadinfoitem.h>
+#include <memspy/engine/memspythreadinfoitemdata.h>
+#include <memspy/engine/memspyengineobjectthreadinfoobjects.h>
+#include <memspy/engine/memspydevicewideoperations.h>
+
+#include <memspy/api/memspyapikernelobject.h>
+
+#include <memspy/api/memspyapikernelobjectitem.h> //for KernelObjectItems
+
+#include <memspy/api/memspyapiheap.h>
+
+#include <memspy/api/memspyapimemorytrackingcycle.h>
+
+#include <memspyengineclientinterface.h>
+#include <memspy/engine/memspyengineoutputsinktype.h>
+
+#include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h>
+
+#include <memspy/api/memspyapiserver.h>
+
+#include <memspy/api/memspyapiecom.h>
+
+// Constants
+const TInt KMemSpyVersion           = 2;
+
+enum TSortType
+	{
+	ESortProcById,
+	ESortProcByName,
+	ESortProcByThreadCount,
+	ESortProcByCodeSegs,
+	ESortProcByHeapUsage,
+	ESortProcByStackUsage,
+	ESortServByName,
+	ESortServBySessionCount
+	};
+
+enum TMemSpyOutputType
+    {
+    EOutputTypeDebug = 0,
+    EOutputTypeFile
+    };
+
+class TMemSpyDeviceWideOperationProgress 
+	{
+public:
+	IMPORT_C TInt Progress() const;
+	IMPORT_C const TDesC& Description() const;
+	
+private:
+	TPckgBuf<TInt> iProgress;
+	TFullName iDescription;
+	
+friend class RMemSpySession;
+	};
+
+
+NONSHARABLE_CLASS( RMemSpySession ) : public RSessionBase
+    {
+public:
+    IMPORT_C RMemSpySession();
+    IMPORT_C TInt Connect();
+    
+public:	//API
+    //Thread speciifc operations
+    IMPORT_C void OutputKernelHeapDataL(); //EMemSpyClientServerOpHeapData
+    
+    IMPORT_C void OutputKernelHeapData(TRequestStatus& aStatus); //EMemSpyClientServerOpHeapData
+    
+    IMPORT_C void OutputThreadHeapDataL(TThreadId aThreadId); //EMemSpyClientServerOpHeapData
+    
+    IMPORT_C void OutputThreadHeapDataL(const TDesC& aThreadName); //EMemSpyClientServerOpHeapData
+    
+    IMPORT_C void OutputThreadCellListL(TThreadId aThreadId);//EMemSpyClientServerOpHeapCellListing    
+    
+    IMPORT_C void OutputHeapInfoUserL(TThreadId aThreadId);	//EMemSpyClientServerOpHeapInfo
+    
+    IMPORT_C void SwitchOutputSinkL( TMemSpySinkType aType); //EMemSpyClientServerOpSwitchOutputSinkFile / EMemSpyClientServerOpSwitchOutputSinkTrace
+    
+    IMPORT_C void SwitchOutputToTraceL(); // EMemSpyClientServerOpSwitchOutputSinkTrace
+    
+    IMPORT_C void SwitchOutputToFileL(const TDesC& aRootFolder); // EMemSpyClientServerOpSwitchOutputSinkFile
+    
+    IMPORT_C void OutputStackInfoL(TThreadId aThreadId); //EMemSpyClientServerOpStackInfo
+    
+    IMPORT_C void OutputStackDataL(TThreadId aThreadId, TMemSpyDriverDomainType aType ); //EMemSpyClientServerOpStackDataUser / EMemSpyClientServerOpStackDataKernel    
+    
+    IMPORT_C void OutputThreadInfoHandlesL(TThreadId aThreadId); //EMemSpyClientServerOpOutputInfoHandles
+    
+    IMPORT_C void OutputAOListL(TThreadId aId, TMemSpyThreadInfoItemType aType);	//EMemSpyClientServerOpOutputAOList    
+    
+    IMPORT_C void OutputKernelObjectsL();// EMemSpyClientServerOpEnumerateKernelContainerAll
+    
+    IMPORT_C void OutputCompactStackInfoL();// EMemSpyClientServerOpStackInfoCompact
+    
+    IMPORT_C void OutputCompactHeapInfoL();// EMemSpyClientServerOpHeapInfoCompact
+    
+    // Device Wide Operations
+    // Synchronous operations - for CLI
+    IMPORT_C void OutputHeapData();
+    
+    // Asynchronous operations
+    IMPORT_C void OutputPhoneInfo(TRequestStatus& aStatus);
+    
+    IMPORT_C void OutputDetailedPhoneInfo(TRequestStatus& aStatus);
+    
+    IMPORT_C void OutputHeapInfo(TRequestStatus& aStatus);
+    
+    IMPORT_C void OutputCompactHeapInfo(TRequestStatus &aStatus);
+    
+    IMPORT_C void OutputHeapCellListing(TRequestStatus& aStatus);
+    
+    IMPORT_C void OutputHeapData(TRequestStatus& aStatus);
+    
+    IMPORT_C void OutputStackInfo(TRequestStatus& aStatus);
+    
+    IMPORT_C void OutputCompactStackInfo(TRequestStatus &aStatus);
+    
+    IMPORT_C void OutputUserStackData(TRequestStatus& aStatus);
+    
+    IMPORT_C void OutputKernelStackData(TRequestStatus& aStatus);
+    
+    IMPORT_C void NotifyDeviceWideOperationProgress(TMemSpyDeviceWideOperationProgress &aProgress, TRequestStatus &aStatus);
+    
+    IMPORT_C void CancelDeviceWideOperationL();
+    
+    // Synchronous operations for MemSpyLauncher
+    IMPORT_C void OutputPhoneInfo();
+    
+    // "Ui" operations
+    
+    IMPORT_C void GetProcessesL(RArray<CMemSpyApiProcess*> &aProcesses, TSortType aSortType = ESortProcById);
+    
+    IMPORT_C TProcessId GetProcessIdByNameL(const TDesC& aProcessName);
+    
+    IMPORT_C void GetThreadsL(TProcessId aProcessId, RArray<CMemSpyApiThread*> &aThreads, TSortType aSortType = ESortProcById);
+    
+    IMPORT_C TInt ProcessSystemPermanentOrCritical( TProcessId aId, TBool aValue ); //aValue -> return value
+    
+    IMPORT_C void SetThreadPriorityL(TThreadId aId, TInt aPriority);
+    
+    IMPORT_C TInt EndProcessL( TProcessId aId, TMemSpyEndType aType );
+    
+    IMPORT_C TInt SwitchToProcess( TProcessId aId, TBool aBrought  );
+    
+    IMPORT_C void GetProcessIdByThreadId( TProcessId& aPID, TThreadId aTID );
+    
+    //SWMT operations
+    
+    IMPORT_C void GetMemoryTrackingCyclesL(RArray<CMemSpyApiMemoryTrackingCycle*>& aCycles);
+    
+    IMPORT_C TInt GetSwmtCyclesCount();
+    
+    IMPORT_C void SetSwmtAutoStartProcessList( CArrayFixFlat<TUid>* aList );
+    
+    IMPORT_C void SetSwmtFilter( const TDesC& aFilter );            
+    
+    IMPORT_C void SetSwmtCategoriesL(TInt aCategories);
+
+    IMPORT_C void SetSwmtHeapDumpsEnabledL(TBool aEnabled);
+    
+    IMPORT_C void SetSwmtMode(TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode aMode);      
+    
+    IMPORT_C void SwmtResetTracking();
+    
+    IMPORT_C void GetOutputSink( TMemSpySinkType& aType );
+           
+    IMPORT_C TBool IsSwmtRunningL();
+    
+    IMPORT_C void StartSwmtTimerL(TInt aPeriod);
+    
+    IMPORT_C void StartSwmtTimerL(); // for CLI
+    
+    IMPORT_C void SetSwmtTimerIntervalL(TInt aPeriod); //for CLI
+    
+    IMPORT_C void StopSwmtTimerL();
+    
+    IMPORT_C void ForceSwmtUpdateL();
+    
+    IMPORT_C void ForceSwmtUpdate(TRequestStatus& aStatus);
+    
+    IMPORT_C void GetSwmtFilter( TName& aFilter );            
+        
+    IMPORT_C void GetSwmtCategoriesL(TInt& aCategories);
+
+    IMPORT_C void GetSwmtHeapDumpsEnabledL(TBool& aEnabled);
+        
+    IMPORT_C void GetSwmtMode(TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode& aMode);
+    
+    IMPORT_C void GetSwmtTimerIntervalL(TInt& aPeriod);
+    
+    //Threads operations
+    /**
+     * 
+     */
+    IMPORT_C void GetThreadsL(TProcessId aProcessId, RArray<CMemSpyApiProcess*> &aThreads, TSortType aSortType = ESortProcById);
+    
+    IMPORT_C TInt ThreadSystemPermanentOrCritical( TThreadId aId, TBool aValue );
+        
+    IMPORT_C TInt EndThreadL( TThreadId aId, TMemSpyEndType aType );
+    
+    IMPORT_C TInt SwitchToThread( TThreadId aId, TBool aBrought );
+    
+    IMPORT_C TInt GetInfoItemType( TInt aIndex, TThreadId aId, TMemSpyThreadInfoItemType &aType );
+    
+    IMPORT_C TInt GetThreadInfoItems( RArray<CMemSpyApiThreadInfoItem*> &aInfoItems, TThreadId aId, TMemSpyThreadInfoItemType aType );
+    
+    IMPORT_C void GetThreadInfoItemsL( RArray<CMemSpyApiThreadInfoItem*> &aInfoItems, TThreadId aId, TMemSpyThreadInfoItemType aType );            
+    
+    //KernelObjects operations
+    
+    IMPORT_C void GetKernelObjectsL( RArray<CMemSpyApiKernelObject*> &aKernelObjects );
+    
+    IMPORT_C TInt GetKernelObjects( RArray<CMemSpyApiKernelObject*> &aKernelObjects );
+    
+    IMPORT_C void GetKernelObjectItemsL( RArray<CMemSpyApiKernelObjectItem*> &aKernelObjectItems, TMemSpyDriverContainerType aForContainer );
+    
+    IMPORT_C TInt GetKernelObjectItems( RArray<CMemSpyApiKernelObjectItem*> &aKernelObjectItems, TMemSpyDriverContainerType aForContainer );
+    
+    IMPORT_C void OutputAllContainerContents();
+    
+    // Heap 
+    
+    IMPORT_C CMemSpyApiHeap* GetHeapL();
+    
+	IMPORT_C CMemSpyApiHeap* GetHeap();
+	
+	IMPORT_C void DumpKernelHeap();
+	
+	// Servers
+	IMPORT_C void GetServersL(RArray<CMemSpyApiServer*> &aServers);
+	
+	IMPORT_C void GetServersL(RArray<CMemSpyApiServer*> &aServers, TSortType aSortType); 
+	
+	IMPORT_C void ServerListOutputGenericL( TBool aDetailed );
+		
+	// ECom
+
+	IMPORT_C void GetEComCategoriesL(RArray<CMemSpyApiEComCategory*> &aCategories);
+	
+	IMPORT_C void GetEComInterfacesL(TUid aCategory, RArray<CMemSpyApiEComInterface*> &aInterfaces);
+	
+	IMPORT_C void GetEComImplementationsL(TUid aInterface, RArray<CMemSpyApiEComImplementation*> &aImplementations);
+	
+private:
+    TInt StartServer();       
+    
+    void SetOutputTypeL(TMemSpyOutputType aOutputType);
+    
+    };
+
+#endif // MEMSPYSESSION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspythreaddata.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,50 @@
+/*
+* 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:
+*
+*/
+
+#ifndef MEMSPYTHREADDATA_H
+#define MEMSPYTHREADDATA_H
+
+//#include <kernel/arm/arm_types.h>
+
+class TMemSpyThreadData {
+public:
+	TMemSpyThreadData()
+	: iId(0), iPid(0), iSID(0), iVID(0), iRequestCount(0), iThreadHandles(0), iProcessHandles(0), iThreadNumberUsing(0), 
+	  iProcessNumberUsing(0), iAttributes(0), iCpuUse(0)
+		{
+		}
+	
+public:
+    TThreadId iId;
+    TProcessId iPid;    
+    TFullName iName;    //name without formatting. Formatting to be moved to the Avkon UI part
+    TInt iSID;
+    TInt iVID;
+    TThreadPriority iThreadPriority;
+    TProcessPriority iProcessPriority;
+    TInt iRequestCount;
+    TInt iThreadHandles;
+    TInt iProcessHandles;
+    TInt iThreadNumberUsing;
+    TInt iProcessNumberUsing;
+    TInt iAttributes;
+    TInt iCpuUse;        
+    TExitType iExitType;
+    RArray<TUint> iRegisters; //containts register contents of the thread (R00-R12, SP, LR, PC, Flags & DACR) - TUint for formating to HEX    
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/inc/memspythreadinfoitemdata.h	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,37 @@
+/*
+* 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:
+* Contains the declaration of  TMemSpyProcessData class
+*/
+
+#ifndef MEMSPYTHREADINFOITEMDATA_H
+#define MEMSPYTHREADINFOITEMDATA_H
+
+#include <memspy/driver/memspydriverobjectsshared.h>
+
+// TMemSpyProcess data class holds data to be sent to the UI
+class TMemSpyThreadInfoItemData 
+	{	
+public:
+	//constructor & destructor
+	inline TMemSpyThreadInfoItemData()		
+		{
+		}
+	
+public:
+    TBuf<64> iCaption;
+    TBuf<32> iValue;
+	};
+
+#endif // MEMSPYTHREADINFOITEMDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/src/memspyapiecom.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,190 @@
+/*
+* 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 <f32file.h>
+#include <memspy/api/memspyapiecom.h>
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyecomdata.h>
+
+
+EXPORT_C CMemSpyApiEComCategory::~CMemSpyApiEComCategory()
+	{
+	delete iData;
+	}
+
+EXPORT_C TUid CMemSpyApiEComCategory::Id() const
+	{
+	return iData->iId;
+	}
+
+EXPORT_C const TDesC& CMemSpyApiEComCategory::Name() const
+	{
+	return iData->iName;
+	}
+
+EXPORT_C TInt CMemSpyApiEComCategory::InterfaceCount() const
+    {
+    return iData->iInterfaceCount;
+    }
+
+void CMemSpyApiEComCategory::ConstructL(const TMemSpyEComCategoryData& aData)
+	{
+	iData = new (ELeave) TMemSpyEComCategoryData( aData );
+	}
+
+CMemSpyApiEComCategory* CMemSpyApiEComCategory::NewL(const TMemSpyEComCategoryData& aData)
+	{
+    CMemSpyApiEComCategory* self = CMemSpyApiEComCategory::NewLC( aData );
+	CleanupStack::Pop(self);
+	return (self);
+	}
+
+CMemSpyApiEComCategory* CMemSpyApiEComCategory::NewLC(const TMemSpyEComCategoryData& aData)
+	{
+    CMemSpyApiEComCategory* self = new (ELeave) CMemSpyApiEComCategory;
+	CleanupStack::PushL( self );
+	self->ConstructL( aData );
+	return ( self );
+	}
+
+
+
+
+
+
+
+
+EXPORT_C CMemSpyApiEComInterface::~CMemSpyApiEComInterface()
+    {
+    delete iData;
+    }
+
+EXPORT_C TUid CMemSpyApiEComInterface::Id() const
+    {
+    return iData->iId;
+    }
+
+EXPORT_C const TDesC& CMemSpyApiEComInterface::Name() const
+    {
+    return iData->iName;
+    }
+
+EXPORT_C TInt CMemSpyApiEComInterface::ImplementationCount() const
+    {
+    return iData->iImplementationCount;
+    }
+
+void CMemSpyApiEComInterface::ConstructL(const TMemSpyEComInterfaceData& aData)
+    {
+    iData = new (ELeave) TMemSpyEComInterfaceData( aData );
+    }
+
+CMemSpyApiEComInterface* CMemSpyApiEComInterface::NewL(const TMemSpyEComInterfaceData& aData)
+    {
+    CMemSpyApiEComInterface* self = CMemSpyApiEComInterface::NewLC( aData );
+    CleanupStack::Pop(self);
+    return (self);
+    }
+
+CMemSpyApiEComInterface* CMemSpyApiEComInterface::NewLC(const TMemSpyEComInterfaceData& aData)
+    {
+    CMemSpyApiEComInterface* self = new (ELeave) CMemSpyApiEComInterface;
+    CleanupStack::PushL( self );
+    self->ConstructL( aData );
+    return ( self );
+    }
+
+
+
+
+
+
+
+EXPORT_C CMemSpyApiEComImplementation::~CMemSpyApiEComImplementation()
+    {
+    delete iData;
+    }
+
+EXPORT_C TUid CMemSpyApiEComImplementation::ImplementationUid() const
+    {
+    return iData->iImplementationUid;
+    }
+    
+EXPORT_C const TDesC& CMemSpyApiEComImplementation::Name() const
+    {
+    return iData->iName;
+    }
+    
+EXPORT_C TInt CMemSpyApiEComImplementation::Version() const
+    {
+    return iData->iVersion;
+    }
+    
+EXPORT_C const TDesC& CMemSpyApiEComImplementation::DataType() const
+    {
+    return iData->iDataType;
+    }
+        
+EXPORT_C const TDesC& CMemSpyApiEComImplementation::OpaqueData() const
+    {
+    return iData->iOpaqueData;
+    }
+    
+EXPORT_C TDriveUnit CMemSpyApiEComImplementation::Drive() const
+    {
+    return iData->iDrive;
+    }
+        
+EXPORT_C TBool CMemSpyApiEComImplementation::RomOnly() const
+    {
+    return iData->iRomOnly;
+    }
+        
+EXPORT_C TBool CMemSpyApiEComImplementation::RomBased() const
+    {
+    return iData->iRomBased;
+    }
+        
+EXPORT_C TVendorId CMemSpyApiEComImplementation::VendorId() const
+    {
+    return iData->iVendorId;
+    }
+        
+EXPORT_C TBool CMemSpyApiEComImplementation::Disabled() const
+    {
+    return iData->iDisabled;
+    }
+
+void CMemSpyApiEComImplementation::ConstructL(const TMemSpyEComImplementationData& aData)
+    {
+    iData = new (ELeave) TMemSpyEComImplementationData( aData );
+    }
+
+CMemSpyApiEComImplementation* CMemSpyApiEComImplementation::NewL(const TMemSpyEComImplementationData& aData)
+    {
+    CMemSpyApiEComImplementation* self = CMemSpyApiEComImplementation::NewLC( aData );
+    CleanupStack::Pop(self);
+    return (self);
+    }
+
+CMemSpyApiEComImplementation* CMemSpyApiEComImplementation::NewLC(const TMemSpyEComImplementationData& aData)
+    {
+    CMemSpyApiEComImplementation* self = new (ELeave) CMemSpyApiEComImplementation;
+    CleanupStack::PushL( self );
+    self->ConstructL( aData );
+    return ( self );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/src/memspyapiheap.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,162 @@
+/*
+* 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 <memspy/api/memspyapiheap.h>
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyheapdata.h>
+
+
+CMemSpyApiHeap::CMemSpyApiHeap() 
+	: iHeapData(0)
+	{
+	}
+
+EXPORT_C CMemSpyApiHeap::~CMemSpyApiHeap()
+	{
+	delete iHeapData;
+	}
+
+void CMemSpyApiHeap::ConstructL(const TMemSpyHeapData& aData)
+	{
+	iHeapData = new (ELeave) TMemSpyHeapData(aData);
+	}
+
+CMemSpyApiHeap* CMemSpyApiHeap::NewL(const TMemSpyHeapData& aData)
+	{
+	CMemSpyApiHeap* self = CMemSpyApiHeap::NewLC(aData);
+	CleanupStack::Pop(self);
+	return (self);
+	}
+
+CMemSpyApiHeap* CMemSpyApiHeap::NewLC(const TMemSpyHeapData& aData)
+	{
+	CMemSpyApiHeap* self = new (ELeave) CMemSpyApiHeap;
+	CleanupStack::PushL(self);
+	self->ConstructL(aData);
+	return (self);
+	}
+
+//api methods
+EXPORT_C TDesC& CMemSpyApiHeap::Type()
+	{
+	return iHeapData->iType;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::Size()
+	{
+	return iHeapData->iSize;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::BaseAddress()
+	{
+	return iHeapData->iBaseAddress;
+	}
+
+EXPORT_C TBool CMemSpyApiHeap::Shared()
+	{
+	return iHeapData->iShared;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::ChunkSize()
+	{
+	return iHeapData->iChunkSize;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::AllocationsCount()
+	{
+	return iHeapData->iAllocationsCount;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::FreeCount()
+	{
+	return iHeapData->iFreeCount;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::BiggestAllocation()
+	{
+	return iHeapData->iBiggestAllocation;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::BiggestFree()
+	{
+	return iHeapData->iBiggestFree;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::TotalAllocations()
+	{
+	return iHeapData->iTotalAllocations;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::TotalFree()
+	{
+	return iHeapData->iTotalFree;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::SlackFreeSpace()
+	{
+	return iHeapData->iSlackFreeSpace;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::Fragmentation()
+	{
+	return iHeapData->iFragmentation;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::HeaderSizeA()
+	{
+	return iHeapData->iHeaderSizeA;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::HeaderSizeF()
+	{
+	return iHeapData->iHeaderSizeF;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::AllocationOverhead()
+	{
+	return iHeapData->iAllocationOverhead;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::FreeOverhead()
+	{
+	return iHeapData->iFreeOverhead;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::TotalOverhead()
+	{
+	return iHeapData->iTotalOverhead;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::Overhead()
+	{
+	return iHeapData->iOverhead;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::MinLength()
+	{
+	return iHeapData->iMinLength;
+	}
+
+EXPORT_C TInt CMemSpyApiHeap::MaxLength()
+	{
+	return iHeapData->iMaxLength;
+	}
+
+EXPORT_C TBool CMemSpyApiHeap::DebugAllocatorLibrary()
+	{
+	return iHeapData->iDebugAllocatorLibrary;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/src/memspyapikernelobject.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,72 @@
+/*
+* 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 <memspy/api/memspyapikernelobject.h>
+#include <memspy/engine/memspykernelobjectdata.h>
+//#include <memspy/engine/memspyengineobjectprocess.h>
+//#include <memspy/engine/memspyengineobjectcontainer.h>
+
+
+EXPORT_C CMemSpyApiKernelObject::~CMemSpyApiKernelObject()
+	{
+	delete iKernelObjectData;
+	}
+
+
+CMemSpyApiKernelObject::CMemSpyApiKernelObject() : iKernelObjectData(0)
+	{
+	}
+
+CMemSpyApiKernelObject* CMemSpyApiKernelObject::NewL(const TMemSpyKernelObjectData& aData)
+	{
+	CMemSpyApiKernelObject* self = CMemSpyApiKernelObject::NewLC(aData);
+	CleanupStack::Pop(self);
+	return (self);
+	}
+
+CMemSpyApiKernelObject* CMemSpyApiKernelObject::NewLC(const TMemSpyKernelObjectData& aData)
+	{
+	CMemSpyApiKernelObject* self = new (ELeave) CMemSpyApiKernelObject;
+	CleanupStack::PushL(self);
+	self->ConstructL(aData);
+	return (self);
+	}
+
+void CMemSpyApiKernelObject::ConstructL(const TMemSpyKernelObjectData& aData)
+	{
+	iKernelObjectData = new (ELeave) TMemSpyKernelObjectData(aData);
+	}
+
+EXPORT_C TMemSpyDriverContainerType CMemSpyApiKernelObject::Type() const
+	{
+	return iKernelObjectData->iType;
+	}
+
+EXPORT_C const TDesC& CMemSpyApiKernelObject::Name() const
+	{
+	return iKernelObjectData->iName;
+	}
+					
+EXPORT_C TInt CMemSpyApiKernelObject::Count() const
+	{
+	return iKernelObjectData->iCount;
+	}
+	
+EXPORT_C TInt64 CMemSpyApiKernelObject::Size() const
+	{
+	return iKernelObjectData->iSize;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/src/memspyapikernelobjectitem.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,309 @@
+/*
+* 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 <memspy/api/memspyapikernelobjectitem.h>
+#include <memspy/driver/memspydriverobjectsshared.h>
+
+EXPORT_C CMemSpyApiKernelObjectItem::~CMemSpyApiKernelObjectItem()
+	{
+	delete iItem;
+	}
+
+
+CMemSpyApiKernelObjectItem::CMemSpyApiKernelObjectItem() : iItem(0)
+	{
+	}
+
+CMemSpyApiKernelObjectItem* CMemSpyApiKernelObjectItem::NewL(const TMemSpyDriverHandleInfoGeneric& aData)
+	{
+	CMemSpyApiKernelObjectItem* self = CMemSpyApiKernelObjectItem::NewLC(aData);
+	CleanupStack::Pop(self);
+	return (self);
+	}
+
+CMemSpyApiKernelObjectItem* CMemSpyApiKernelObjectItem::NewLC(const TMemSpyDriverHandleInfoGeneric& aData)
+	{
+	CMemSpyApiKernelObjectItem* self = new (ELeave) CMemSpyApiKernelObjectItem;
+	CleanupStack::PushL(self);
+	self->ConstructL(aData);
+	return (self);
+	}
+
+void CMemSpyApiKernelObjectItem::ConstructL(const TMemSpyDriverHandleInfoGeneric& aData)
+	{
+	iItem = new (ELeave) TMemSpyDriverHandleInfoGeneric(aData);
+	}
+
+EXPORT_C const TDesC8& CMemSpyApiKernelObjectItem::Name() const
+	{
+	/*
+	TBuf<KMaxName> ret;	
+	ret.Copy( iItem->iName );
+	return ret;
+	*/
+	return iItem->iName;
+	}
+
+EXPORT_C TAny* CMemSpyApiKernelObjectItem::Handle() const
+	{	
+	return iItem->iHandle;
+	}
+
+EXPORT_C TMemSpyDriverContainerType CMemSpyApiKernelObjectItem::Type() const
+	{
+	return iItem->iType;
+	}
+
+// For Process, thread, chunk (owning process id), server (owning thread id)
+EXPORT_C TInt CMemSpyApiKernelObjectItem::Id() const
+	{
+	return iItem->iId;
+	}
+
+// For Chunk, Library
+EXPORT_C TUint32 CMemSpyApiKernelObjectItem::Size() const
+	{
+	return iItem->iSize;
+	}
+
+// For Semaphore, Mutex, Server
+EXPORT_C TInt CMemSpyApiKernelObjectItem::Count() const
+	{
+	return iItem->iCount;
+	}
+
+// For Mutex
+EXPORT_C TInt CMemSpyApiKernelObjectItem::WaitCount() const
+	{
+	return iItem->iWaitCount;
+	}
+
+// For Server, Session
+EXPORT_C TIpcSessionType CMemSpyApiKernelObjectItem::SessionType() const
+	{
+	return iItem->iSessionType;
+	}
+
+// For Timer
+EXPORT_C TMemSpyDriverTimerType CMemSpyApiKernelObjectItem::TimerType() const
+	{
+	return iItem->iTimerType;
+	}
+
+EXPORT_C TMemSpyDriverTimerState CMemSpyApiKernelObjectItem::TimerState() const
+	{
+	return iItem->iTimerState;
+	}
+
+// For Logical channel
+EXPORT_C TInt CMemSpyApiKernelObjectItem::OpenChannels()
+	{
+	return iItem->iOpenChannels;
+	}
+
+// For most of the object types
+EXPORT_C const TDesC8& CMemSpyApiKernelObjectItem::NameDetail() const
+	{
+	/*
+	TBuf<KMaxName> ret;
+	ret.Copy( iItem->iNameDetail );
+	return ret;
+	*/
+	return iItem->iNameDetail;
+	}
+
+EXPORT_C TInt CMemSpyApiKernelObjectItem::AccessCount() const
+	{
+	return iItem->iAccessCount;
+	}
+
+EXPORT_C TInt CMemSpyApiKernelObjectItem::UniqueID() const
+	{
+	return iItem->iUniqueID;
+	}
+
+EXPORT_C TUint CMemSpyApiKernelObjectItem::Protection() const
+	{
+	return iItem->iProtection;
+	}
+		
+EXPORT_C TUint8* CMemSpyApiKernelObjectItem::AddressOfKernelOwner()
+	{
+	return iItem->iAddressOfKernelOwner;
+	}
+
+EXPORT_C TInt CMemSpyApiKernelObjectItem::Priority() const
+	{
+	return iItem->iPriority;
+	}
+
+EXPORT_C TUint8* CMemSpyApiKernelObjectItem::AddressOfOwningProcess()
+	{
+	return iItem->iAddressOfOwningProcess;
+	}
+
+EXPORT_C TUint CMemSpyApiKernelObjectItem::CreatorId() const
+	{
+	return iItem->iCreatorId;
+	}
+
+EXPORT_C TUint CMemSpyApiKernelObjectItem::SecurityZone() const
+	{
+	return iItem->iSecurityZone;
+	}
+
+EXPORT_C TInt CMemSpyApiKernelObjectItem::Attributes() const
+	{
+	return iItem->iAttributes;
+	}
+
+EXPORT_C TUint8* CMemSpyApiKernelObjectItem::AddressOfDataBssStackChunk()
+	{
+	return iItem->iAddressOfDataBssStackChunk;
+	}
+
+// For Server, Session
+EXPORT_C TUint8* CMemSpyApiKernelObjectItem::AddressOfOwningThread()
+	{
+	return iItem->iAddressOfOwningThread;
+	}
+
+EXPORT_C TUint8* CMemSpyApiKernelObjectItem::AddressOfServer()
+	{
+	return iItem->iAddressOfServer;
+	}
+
+EXPORT_C TUint16 CMemSpyApiKernelObjectItem::TotalAccessCount() const
+	{
+	return iItem->iTotalAccessCount;
+	}
+
+EXPORT_C TUint8 CMemSpyApiKernelObjectItem::SvrSessionType() const
+	{
+	return iItem->iSvrSessionType;
+	}
+
+EXPORT_C TInt CMemSpyApiKernelObjectItem::MsgCount() const
+	{
+	return iItem->iMsgCount;
+	}
+
+EXPORT_C TInt CMemSpyApiKernelObjectItem::MsgLimit() const
+	{
+	return iItem->iMsgLimit;
+	}
+
+// For chunk
+EXPORT_C TInt CMemSpyApiKernelObjectItem::MaxSize() const
+	{
+	return iItem->iMaxSize;
+	}
+
+EXPORT_C TInt CMemSpyApiKernelObjectItem::Bottom() const
+	{
+	return iItem->iBottom;
+	}
+
+EXPORT_C TInt CMemSpyApiKernelObjectItem::Top() const
+	{
+	return iItem->iTop;
+	}
+
+EXPORT_C TInt CMemSpyApiKernelObjectItem::StartPos() const
+	{
+	return iItem->iStartPos;
+	}
+
+EXPORT_C TUint CMemSpyApiKernelObjectItem::ControllingOwner() const
+	{
+	return iItem->iControllingOwner;
+	}
+
+EXPORT_C TUint CMemSpyApiKernelObjectItem::Restrictions() const
+	{
+	return iItem->iRestrictions;
+	}
+
+EXPORT_C TUint CMemSpyApiKernelObjectItem::MapAttr() const
+	{
+	return iItem->iMapAttr;
+	}
+
+EXPORT_C TUint CMemSpyApiKernelObjectItem::ChunkType() const
+	{
+	return iItem->iChunkType;
+	}
+
+EXPORT_C const TDesC8& CMemSpyApiKernelObjectItem::NameOfOwner() const
+	{
+	/*
+	TBuf<KMaxName> ret;
+	ret.Copy( iItem->iNameOfOwner );
+	return ret;
+	*/
+	return iItem->iNameOfOwner;
+	}
+
+// For library
+EXPORT_C TInt CMemSpyApiKernelObjectItem::MapCount() const
+	{
+	return iItem->iMapCount;
+	}
+
+EXPORT_C TUint8 CMemSpyApiKernelObjectItem::State() const
+	{
+	return iItem->iState;
+	}
+
+EXPORT_C TUint8* CMemSpyApiKernelObjectItem::AddressOfCodeSeg()
+	{
+	return iItem->iAddressOfCodeSeg;
+	}
+
+// Semaphore, mutex, condvar
+EXPORT_C TUint8 CMemSpyApiKernelObjectItem::Resetting() const
+	{
+	return iItem->iResetting;
+	}
+
+EXPORT_C TUint8 CMemSpyApiKernelObjectItem::Order() const
+	{
+	return iItem->iOrder;
+	}
+
+// For Logical/Physical device
+EXPORT_C TVersion CMemSpyApiKernelObjectItem::Version() const
+	{
+	return iItem->iVersion;
+	}
+
+EXPORT_C TUint CMemSpyApiKernelObjectItem::ParseMask() const
+	{
+	return iItem->iParseMask;	
+	}
+
+EXPORT_C TUint CMemSpyApiKernelObjectItem::UnitsMask() const
+	{
+	return iItem->iUnitsMask;
+	}
+
+// For change notifier
+EXPORT_C TUint CMemSpyApiKernelObjectItem::Changes() const
+	{
+	return iItem->iChanges;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/src/memspyapimemorytrackingcycle.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,83 @@
+/*
+* 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 <memspy/api/memspyapimemorytrackingcycle.h>
+#include <memspy/engine/memspymemorytrackingcycledata.h>
+
+EXPORT_C TInt CMemSpyApiMemoryTrackingCycle::CycleNumber() const
+	{
+	return iData->iCycleNumber;	
+	}
+
+EXPORT_C const TTime& CMemSpyApiMemoryTrackingCycle::Time() const
+	{
+	return iData->iTime;	
+	}
+
+EXPORT_C const TDesC& CMemSpyApiMemoryTrackingCycle::Caption() const
+	{
+	return iData->iCaption;	
+	}
+
+EXPORT_C const TInt64& CMemSpyApiMemoryTrackingCycle::FreeMemory() const
+	{
+	return iData->iFreeMemory;
+	}
+
+EXPORT_C TInt64 CMemSpyApiMemoryTrackingCycle::MemoryDelta() const
+	{
+	return iData->iMemoryDelta;
+	}
+
+EXPORT_C TInt64 CMemSpyApiMemoryTrackingCycle::PreviousCycleDiff() const
+	{
+	return iData->iPreviousCycleDiff;
+	}
+
+EXPORT_C TInt CMemSpyApiMemoryTrackingCycle::ChangeCount() const
+	{
+	return iData->iChangeCount;
+	}
+
+EXPORT_C CMemSpyApiMemoryTrackingCycle::~CMemSpyApiMemoryTrackingCycle()
+	{
+	delete iData;
+	}
+
+CMemSpyApiMemoryTrackingCycle* CMemSpyApiMemoryTrackingCycle::NewL(const TMemSpyMemoryTrackingCycleData& aData)
+	{
+	CMemSpyApiMemoryTrackingCycle* self = CMemSpyApiMemoryTrackingCycle::NewLC(aData);
+	CleanupStack::Pop(self);
+	return (self);
+	}
+
+CMemSpyApiMemoryTrackingCycle* CMemSpyApiMemoryTrackingCycle::NewLC(const TMemSpyMemoryTrackingCycleData& aData)
+	{
+	CMemSpyApiMemoryTrackingCycle* self = new (ELeave) CMemSpyApiMemoryTrackingCycle;
+	CleanupStack::PushL(self);
+	self->ConstructL(aData);
+	return self;
+	}
+
+CMemSpyApiMemoryTrackingCycle::CMemSpyApiMemoryTrackingCycle()
+	{
+	}
+
+void CMemSpyApiMemoryTrackingCycle::ConstructL(const TMemSpyMemoryTrackingCycleData& aData)
+	{
+	iData = new (ELeave) TMemSpyMemoryTrackingCycleData(aData);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/src/memspyapiprocess.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,103 @@
+/*
+* 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 <memspy/api/memspyapiprocess.h>
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyprocessdata.h>
+#include <memspy/engine/memspyengineobjectprocess.h>
+#include <memspy/engine/memspyengineobjectcontainer.h>
+
+
+EXPORT_C CMemSpyApiProcess::~CMemSpyApiProcess()
+	{
+	delete iProcessData;
+	}
+
+EXPORT_C TProcessId CMemSpyApiProcess::Id() const
+	{
+	return iProcessData->iId;
+	}
+
+EXPORT_C const TDesC& CMemSpyApiProcess::Name() const
+	{
+	return iProcessData->iName;
+	}
+
+EXPORT_C TExitCategoryName CMemSpyApiProcess::ExitCategory() const
+	{
+	return iProcessData->iExitCategory;
+	}
+	
+EXPORT_C TInt CMemSpyApiProcess::ExitReason() const
+	{
+	return iProcessData->iExitReason;
+	}
+	
+EXPORT_C TExitType CMemSpyApiProcess::ExitType() const
+	{
+	return iProcessData->iExitType;
+	}
+	
+EXPORT_C TInt CMemSpyApiProcess::ThreadCount() const
+	{
+	return iProcessData->iThreadCount;
+	}
+
+EXPORT_C TUint32 CMemSpyApiProcess::SID() const
+	{
+	return iProcessData->iSID;
+	}
+
+EXPORT_C TUint32 CMemSpyApiProcess::VID() const
+	{
+	return iProcessData->iSID;
+	}
+
+EXPORT_C TProcessPriority CMemSpyApiProcess::Priority() const
+	{
+	return iProcessData->iPriority;
+	}
+
+EXPORT_C TBool CMemSpyApiProcess::IsDead() const
+    {
+    return iProcessData->iIsDead;
+    }
+
+CMemSpyApiProcess::CMemSpyApiProcess() : iProcessData(0)
+	{
+	}
+
+void CMemSpyApiProcess::ConstructL(const TMemSpyProcessData& aData)
+	{
+	iProcessData = new (ELeave) TMemSpyProcessData(aData);
+	}
+
+CMemSpyApiProcess* CMemSpyApiProcess::NewL(const TMemSpyProcessData& aData)
+	{
+	CMemSpyApiProcess* self = CMemSpyApiProcess::NewLC(aData);
+	CleanupStack::Pop(self);
+	return (self);
+	}
+
+CMemSpyApiProcess* CMemSpyApiProcess::NewLC(const TMemSpyProcessData& aData)
+	{
+	CMemSpyApiProcess* self = new (ELeave) CMemSpyApiProcess;
+	CleanupStack::PushL(self);
+	self->ConstructL(aData);
+	return (self);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/src/memspyapiserver.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,65 @@
+/*
+* 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 <memspy/api/memspyapiserver.h>
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspyserverdata.h>
+
+EXPORT_C CMemSpyApiServer::~CMemSpyApiServer()
+	{
+	delete iData;
+	}
+
+EXPORT_C TProcessId CMemSpyApiServer::Id() const
+	{
+	return iData->iId;
+	}
+
+EXPORT_C const TDesC& CMemSpyApiServer::Name() const
+	{
+	return iData->iName;
+	}
+	
+EXPORT_C TInt CMemSpyApiServer::SessionCount() const
+	{
+	return iData->iSessionCount;
+	}
+
+CMemSpyApiServer::CMemSpyApiServer() : iData(0)
+	{
+	}
+
+void CMemSpyApiServer::ConstructL(const TMemSpyServerData& aData)
+	{
+	iData = new (ELeave) TMemSpyServerData(aData);
+	}
+
+CMemSpyApiServer* CMemSpyApiServer::NewL(const TMemSpyServerData& aData)
+	{
+    CMemSpyApiServer* self = CMemSpyApiServer::NewLC(aData);
+	CleanupStack::Pop(self);
+	return (self);
+	}
+
+CMemSpyApiServer* CMemSpyApiServer::NewLC(const TMemSpyServerData& aData)
+	{
+    CMemSpyApiServer* self = new (ELeave) CMemSpyApiServer;
+	CleanupStack::PushL(self);
+	self->ConstructL(aData);
+	return (self);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/src/memspyapithread.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,125 @@
+/*
+* 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 <memspy/api/memspyapithread.h>
+#include <memspy/engine/memspythreaddata.h>
+
+
+EXPORT_C CMemSpyApiThread::~CMemSpyApiThread()
+	{
+	delete iThreadData;
+	}
+
+EXPORT_C TThreadId CMemSpyApiThread::Id() const
+	{
+	return iThreadData->iId;
+	}
+
+EXPORT_C TProcessId CMemSpyApiThread::ProcessId() const
+	{
+	return iThreadData->iPid;
+	}
+
+EXPORT_C const TDesC& CMemSpyApiThread::Name() const
+	{
+	return iThreadData->iName;
+	}
+
+EXPORT_C TInt CMemSpyApiThread::SID() const
+	{
+	return iThreadData->iSID;
+	}
+
+
+EXPORT_C TInt CMemSpyApiThread::VID() const
+	{
+	return iThreadData->iVID;
+	}
+
+EXPORT_C TThreadPriority CMemSpyApiThread::ThreadPriority() const
+	{
+	return iThreadData->iThreadPriority;
+	}
+
+EXPORT_C TProcessPriority CMemSpyApiThread::ProcessPriority() const
+	{
+	return iThreadData->iProcessPriority;
+	}
+
+EXPORT_C TInt CMemSpyApiThread::RequestCount() const
+	{
+	return iThreadData->iRequestCount;
+	}
+
+EXPORT_C TInt CMemSpyApiThread::ThreadHandles() const
+	{
+	return iThreadData->iThreadHandles;
+	}
+
+EXPORT_C TInt CMemSpyApiThread::ProcessHandles() const
+	{
+	return iThreadData->iProcessHandles;
+	}
+
+EXPORT_C TInt CMemSpyApiThread::ThreadNumberUsing() const
+	{
+	return iThreadData->iThreadNumberUsing;
+	}
+
+EXPORT_C TInt CMemSpyApiThread::ProcessNumberUsing() const
+	{
+	return iThreadData->iProcessNumberUsing;
+	}
+
+EXPORT_C TInt CMemSpyApiThread::Attributes() const
+	{
+	return iThreadData->iAttributes;
+	}
+
+EXPORT_C TInt CMemSpyApiThread::CpuUse() const
+	{
+	return iThreadData->iCpuUse;
+	}
+
+EXPORT_C TExitType CMemSpyApiThread::ExitType() const
+	{
+	return iThreadData->iExitType;
+	}
+
+CMemSpyApiThread::CMemSpyApiThread() : iThreadData(0)
+	{
+	}
+
+void CMemSpyApiThread::ConstructL(const TMemSpyThreadData& aData)
+	{
+	iThreadData = new (ELeave) TMemSpyThreadData(aData);
+	}
+
+CMemSpyApiThread* CMemSpyApiThread::NewL(const TMemSpyThreadData& aData)
+	{
+	CMemSpyApiThread* self = CMemSpyApiThread::NewLC(aData);
+	CleanupStack::Pop(self);
+	return (self);
+	}
+
+CMemSpyApiThread* CMemSpyApiThread::NewLC(const TMemSpyThreadData& aData)
+	{
+	CMemSpyApiThread* self = new (ELeave) CMemSpyApiThread;
+	CleanupStack::PushL(self);
+	self->ConstructL(aData);
+	return (self);
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/src/memspyapithreadinfoitem.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,60 @@
+/*
+* 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 <memspy/api/memspyapithreadinfoitem.h>
+#include <memspy/engine/memspyengine.h>
+#include <memspy/engine/memspythreadinfoitemdata.h>
+
+EXPORT_C CMemSpyApiThreadInfoItem::~CMemSpyApiThreadInfoItem()
+	{
+	delete iInfoItem;
+	}
+
+EXPORT_C const TDesC& CMemSpyApiThreadInfoItem::Caption() const
+	{
+	return iInfoItem->iCaption;
+	}
+
+EXPORT_C const TDesC& CMemSpyApiThreadInfoItem::Value() const
+	{
+	return iInfoItem->iValue;
+	}
+
+CMemSpyApiThreadInfoItem::CMemSpyApiThreadInfoItem() : iInfoItem(0)
+	{
+	}
+
+void CMemSpyApiThreadInfoItem::ConstructL(const TMemSpyThreadInfoItemData& aData)
+	{
+	iInfoItem = new (ELeave) TMemSpyThreadInfoItemData(aData);
+	}
+
+CMemSpyApiThreadInfoItem* CMemSpyApiThreadInfoItem::NewL(const TMemSpyThreadInfoItemData& aData)
+	{
+	CMemSpyApiThreadInfoItem* self = CMemSpyApiThreadInfoItem::NewLC(aData);
+	CleanupStack::Pop(self);
+	return (self);
+	}
+
+CMemSpyApiThreadInfoItem* CMemSpyApiThreadInfoItem::NewLC(const TMemSpyThreadInfoItemData& aData)
+	{
+	CMemSpyApiThreadInfoItem* self = new (ELeave) CMemSpyApiThreadInfoItem;
+	CleanupStack::PushL(self);
+	self->ConstructL(aData);
+	return (self);
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyClient/src/memspysession.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,908 @@
+/*
+* 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 "memspysession.h"
+
+#include <memspyengineclientinterface.h>
+// API
+#include <memspy/engine/memspyprocessdata.h>
+#include <memspy/engine/memspythreaddata.h> 
+#include <memspy/engine/memspykernelobjectdata.h>
+#include <memspy/engine/memspyheapdata.h>
+#include <memspy/engine/memspymemorytrackingcycledata.h>
+//KernelObjects
+#include <memspy/driver/memspydriverenumerationsshared.h>
+// Servers
+#include <memspy/engine/memspyserverdata.h>
+// ECom
+#include <memspy/engine/memspyecomdata.h>
+
+// IMPLEMENTATION
+
+EXPORT_C RMemSpySession::RMemSpySession()
+    {
+    }
+
+
+EXPORT_C TInt RMemSpySession::Connect()
+    {
+	TInt error(KErrNone);
+	
+	for (TInt i=0; i<2; i++) // Two retries max
+		{
+		TInt error = CreateSession(KMemSpyServerName, TVersion(KMemSpyVersion, 0, 0));
+		
+		if (error != KErrNotFound && error != KErrServerTerminated)
+			return error;
+		
+		error = StartServer();
+		
+		if (error != KErrNone && error != KErrAlreadyExists)
+			return error;
+		}
+	
+	return error;	
+    }
+
+TInt RMemSpySession::StartServer()
+	{
+	RProcess server;
+	_LIT(KCommand, "start");
+	const TUid KServerUid3 = {0xE5883BC2};
+	TInt error = server.Create(KMemSpyServerName, KCommand);//, KServerUid3);
+	
+	if (error != KErrNone)
+		return error;
+	
+	TRequestStatus startStatus, stopStatus;
+	server.Logon(stopStatus);
+	if (stopStatus != KRequestPending)
+		{
+		User::WaitForRequest(stopStatus);
+		server.Kill(0);
+		server.Close();
+		return stopStatus.Int();
+		}
+	
+	server.Rendezvous(startStatus);
+	server.Resume();
+	User::WaitForRequest(startStatus, stopStatus);
+	if (startStatus == KRequestPending)
+		{
+		// not started yet, i.e. stopStatus was signaled
+		server.Close();
+		return stopStatus.Int();
+		}
+	
+	// Rendezvous was called - the server is ready
+	
+	// We first need to cancel Logon
+	server.LogonCancel(stopStatus);
+	// We don't need this anymore
+	server.Close();
+	// Wait for LogonCancel to complete
+	User::WaitForRequest(stopStatus);
+
+	// Everything went OK
+	return KErrNone;
+	}
+
+EXPORT_C void RMemSpySession::GetProcessesL(RArray<CMemSpyApiProcess*> &aProcesses, TSortType aSortType)
+	{
+	TPckgBuf<TInt> count;
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetProcessCount, TIpcArgs(&count)));
+	
+	TInt requestedCount = count();
+	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyProcessData));
+	TPtr8 bufferPtr(buffer->Des());
+	
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetProcesses, TIpcArgs(&count, &bufferPtr)));
+	aProcesses.Reset();
+	
+	TInt receivedCount = Min(count(), requestedCount);
+	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyProcessData))
+		{
+		TPckgBuf<TMemSpyProcessData> data;
+		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyProcessData));
+		aProcesses.AppendL(CMemSpyApiProcess::NewLC(data()));
+		}
+	CleanupStack::Pop(aProcesses.Count());
+	CleanupStack::PopAndDestroy(buffer);
+	}
+
+EXPORT_C TProcessId RMemSpySession::GetProcessIdByNameL(const TDesC& aProcessName)
+	{
+	TPckgBuf<TProcessId> procId;
+	User::LeaveIfError(SendReceive(EMemSpyClienServerOpGetProcessIdByName, 
+			TIpcArgs(&aProcessName, &procId)));
+	
+	return procId();
+	}
+
+EXPORT_C TInt RMemSpySession::ProcessSystemPermanentOrCritical( TProcessId aId, TBool aValue )
+	{
+	TPckgBuf<TProcessId> arg1( aId );
+	TPckgBuf<TBool> arg2( aValue );
+	TIpcArgs args( &arg1, &arg2 );
+		
+	TInt error = SendReceive( EMemSpyClientServerOpProcessSystemPermanentOrCritical, args );
+	
+	aValue = arg2();
+	
+	return error;
+	}
+
+EXPORT_C TInt RMemSpySession::EndProcessL( TProcessId aId, TMemSpyEndType aType )
+	{
+	TPckgBuf<TProcessId> arg1( aId );
+	TPckgBuf<TMemSpyEndType> arg2( aType );
+	TIpcArgs args( &arg1, &arg2 );
+	
+	TInt error = SendReceive( EMemSpyClientServerOpEndProcess, args );
+	
+	return error;
+	}
+
+EXPORT_C TInt RMemSpySession::SwitchToProcess( TProcessId aId, TBool aBrought )
+	{
+	TPckgBuf<TProcessId> arg1( aId );
+	TPckgBuf<TBool> arg2( aBrought );
+	TIpcArgs args( &arg1, &arg2 );
+	
+	TInt error = SendReceive( EMemSpyClientServerOpSwitchToProcess, args );
+	
+	return error;	
+	}
+
+// Threads related methods
+EXPORT_C void RMemSpySession::GetThreadsL(TProcessId aProcessId, RArray<CMemSpyApiThread*> &aThreads, TSortType aSortType)
+	{
+	TPckgBuf<TInt> count;
+	TPckgBuf<TProcessId> pid(aProcessId);
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetThreadCount, TIpcArgs(&count, &pid)));
+	
+	TInt requestedCount = count();
+	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyThreadData));
+	TPtr8 bufferPtr(buffer->Des());
+	
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetThreads, TIpcArgs(&count, &bufferPtr, &pid)));
+	aThreads.Reset();
+	
+	TInt receivedCount = Min(count(), requestedCount);
+	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyThreadData))
+		{
+		TPckgBuf<TMemSpyThreadData> data;
+		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyThreadData));
+		aThreads.AppendL(CMemSpyApiThread::NewLC(data()));
+		}
+	CleanupStack::Pop(aThreads.Count());
+	CleanupStack::PopAndDestroy(buffer);
+	}
+
+EXPORT_C void RMemSpySession::SetThreadPriorityL(TThreadId aId, TInt aPriority)
+	{
+	TPckgBuf<TThreadId> arg1( aId );
+	TPckgBuf<TInt> arg2( aPriority );
+	
+	User::LeaveIfError(SendReceive( EMemSpyClientServerOpSetThreadPriority, TIpcArgs(&arg1, &arg2)));
+	}
+
+EXPORT_C TInt RMemSpySession::ThreadSystemPermanentOrCritical( TThreadId aId, TBool aValue )
+	{
+	TPckgBuf<TThreadId> arg1( aId );
+	TPckgBuf<TBool> arg2( aValue );
+	TIpcArgs args( &arg1, &arg2 );
+	
+	TInt error = SendReceive( EMemSpyClientServerOpThreadSystemPermanentOrCritical, args );
+	
+	aValue = arg2();
+	
+	return error;
+	}
+
+EXPORT_C TInt RMemSpySession::EndThreadL( TThreadId aId, TMemSpyEndType aType )
+	{
+	TPckgBuf<TThreadId> arg1( aId );
+	TPckgBuf<TMemSpyEndType> arg2( aType );
+	TIpcArgs args( &arg1, &arg2 );
+	
+	TInt error = SendReceive( EMemSpyClientServerOpEndThread, args );
+	
+	return error;
+	}
+
+EXPORT_C TInt RMemSpySession::SwitchToThread( TThreadId aId, TBool aBrought )
+	{
+	TPckgBuf<TThreadId> arg1( aId );
+	TPckgBuf<TBool> arg2( aBrought );
+	TIpcArgs args( &arg1, &arg2 );
+	
+	TInt error = SendReceive( EMemSpyClientServerOpSwitchToThread, args );
+	
+	return error;	
+	}
+
+EXPORT_C TInt RMemSpySession::GetInfoItemType( TInt aIndex, TThreadId aId, TMemSpyThreadInfoItemType &aType )
+	{
+	TPckgBuf<TInt> arg1( aIndex );
+	TPckgBuf<TThreadId> arg2( aId );
+	TPckgBuf<TMemSpyThreadInfoItemType> arg3;
+	TIpcArgs args( &arg1, &arg2, &arg3 );
+		
+	TInt error = SendReceive( EMemSpyClientServerOpGetInfoItemType, args );
+	
+	aType = arg3();
+	
+	return error;
+	}
+
+EXPORT_C void RMemSpySession::GetThreadInfoItemsL( RArray<CMemSpyApiThreadInfoItem*> &aInfoItems, TThreadId aId, TMemSpyThreadInfoItemType aType )
+	{
+	TPckgBuf<TThreadId> id( aId );	
+	TPckgBuf<TMemSpyThreadInfoItemType> type( aType );
+	TPckgBuf<TInt> count;	
+	
+	TInt error = SendReceive( EMemSpyClientServerOpGetThreadInfoItemsCount, TIpcArgs( &id, &type, &count ) );
+	TInt itemCount = count();
+	
+	if( error == KErrNone )
+		{		
+		if( itemCount == 0 )
+			{
+			aInfoItems.Reset();
+			}
+		else
+			{
+			HBufC8* buffer = HBufC8::NewLC( itemCount * sizeof(TMemSpyThreadInfoItemData) );
+			TPtr8 bufferPtr(buffer->Des());
+			
+			TPckgBuf<TInt> requestedCount( itemCount );
+			
+			TIpcArgs args( &requestedCount, &id, &type, &bufferPtr );
+			TInt error = SendReceive( EMemSpyClientServerOpGetThreadInfoItems, args ); // TODO check error
+			
+			aInfoItems.Reset();
+		
+			for(TInt i=0, offset = 0; i < itemCount; i++, offset+=sizeof(TMemSpyThreadInfoItemData))
+				{
+				TPckgBuf<TMemSpyThreadInfoItemData> data;
+				data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyThreadInfoItemData));
+				aInfoItems.AppendL(CMemSpyApiThreadInfoItem::NewLC(data()));
+				}
+			
+			CleanupStack::Pop(aInfoItems.Count());
+			CleanupStack::PopAndDestroy(buffer);
+			}
+		}
+	
+	User::LeaveIfError(error);
+	}
+
+EXPORT_C TInt RMemSpySession::GetThreadInfoItems( RArray<CMemSpyApiThreadInfoItem*> &aInfoItems, TThreadId aId, TMemSpyThreadInfoItemType aType )
+	{
+	TRAPD(error, GetThreadInfoItemsL(aInfoItems, aId, aType));
+	return error;
+	}
+
+EXPORT_C void RMemSpySession::GetProcessIdByThreadId( TProcessId& aPID, TThreadId aTID )
+	{	
+	TPckgBuf<TProcessId> pid(aPID);
+	TPckgBuf<TThreadId> tid(aTID);
+	
+	TIpcArgs args( &pid, &tid );
+	User::LeaveIfError( SendReceive( EMemSpyClientServerOpGetProcessIdByThreadId, args ) );
+	aPID = pid();
+	}
+
+//Kernel Objects specific operations
+EXPORT_C void RMemSpySession::GetKernelObjectsL( RArray<CMemSpyApiKernelObject*> &aKernelObjects )
+	{		
+	TPckgBuf<TInt> count;
+	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjectCount, TIpcArgs(&count) ));
+	
+	TInt requestedCount = count();
+	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyKernelObjectData));
+	TPtr8 bufferPtr(buffer->Des());
+		
+	TIpcArgs args( &count, &bufferPtr );
+	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjects, args ));
+	
+	aKernelObjects.Reset();
+	
+	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyKernelObjectData))
+		{
+		TPckgBuf<TMemSpyKernelObjectData> data;
+		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyKernelObjectData));
+		aKernelObjects.AppendL(CMemSpyApiKernelObject::NewLC(data()));
+		}
+	
+	CleanupStack::Pop(aKernelObjects.Count());
+	CleanupStack::PopAndDestroy(buffer);
+	}
+
+EXPORT_C TInt RMemSpySession::GetKernelObjects( RArray<CMemSpyApiKernelObject*> &aKernelObjects )
+	{
+	TRAPD(error, GetKernelObjectsL(aKernelObjects));
+	return error;
+	}
+
+EXPORT_C void RMemSpySession::GetKernelObjectItemsL( RArray<CMemSpyApiKernelObjectItem*> &aKernelObjectItems, TMemSpyDriverContainerType aForContainer )
+	{
+	TPckgBuf<TInt> count;
+	TPckgBuf<TMemSpyDriverContainerType> type(aForContainer);
+	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjectItemCount, TIpcArgs(&count, &type) ));
+
+	TInt requestedCount = count();
+	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyDriverHandleInfoGeneric));
+	TPtr8 bufferPtr(buffer->Des());
+	
+	TIpcArgs args( &count, &type, &bufferPtr );
+	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjectItems, args ));
+	
+	aKernelObjectItems.Reset();
+	
+	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyDriverHandleInfoGeneric))
+		{
+		TPckgBuf<TMemSpyDriverHandleInfoGeneric> data;
+		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyDriverHandleInfoGeneric));
+		aKernelObjectItems.AppendL( CMemSpyApiKernelObjectItem::NewLC( data() ) );
+		}
+	CleanupStack::Pop(aKernelObjectItems.Count());
+	CleanupStack::PopAndDestroy(buffer);
+	}
+
+EXPORT_C TInt RMemSpySession::GetKernelObjectItems( RArray<CMemSpyApiKernelObjectItem*> &aKernelObjectItems, TMemSpyDriverContainerType aForContainer )
+	{
+	TRAPD(error, GetKernelObjectItemsL(aKernelObjectItems, aForContainer));
+	return error;
+	}
+
+EXPORT_C void RMemSpySession::GetMemoryTrackingCyclesL(RArray<CMemSpyApiMemoryTrackingCycle*>& aCycles)
+	{
+	TPckgBuf<TInt> count;
+	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetMemoryTrackingCycleCount, TIpcArgs(&count) ));
+	
+	TInt requestedCount = count();
+	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyMemoryTrackingCycleData));
+	TPtr8 bufferPtr(buffer->Des());
+		
+	TIpcArgs args( &count, &bufferPtr );
+	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetMemoryTrackingCycles, args ));
+	
+	aCycles.Reset();
+	
+	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyMemoryTrackingCycleData))
+		{
+		TPckgBuf<TMemSpyMemoryTrackingCycleData> data;
+		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyMemoryTrackingCycleData));
+		aCycles.AppendL(CMemSpyApiMemoryTrackingCycle::NewLC(data()));
+		}
+	
+	CleanupStack::Pop(aCycles.Count());
+	CleanupStack::PopAndDestroy(buffer);
+	}
+
+EXPORT_C void RMemSpySession::OutputAllContainerContents()
+	{
+	SendReceive( EMemSpyClientServerOpOutputAllContainerContents );
+	}
+
+
+//Heap specific operations
+
+EXPORT_C CMemSpyApiHeap* RMemSpySession::GetHeapL()
+	{
+	CMemSpyApiHeap* aHeap;
+	
+	HBufC8* buffer = HBufC8::NewLC( sizeof(TMemSpyHeapData) );
+	TPtr8 bufferPtr(buffer->Des());
+	TIpcArgs args( &bufferPtr );
+	
+	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetHeap, args ));
+	
+	TPckgBuf<TMemSpyHeapData> data;
+	data.Copy(bufferPtr.Ptr(), sizeof(TMemSpyHeapData));		
+	aHeap = CMemSpyApiHeap::NewL( data() );
+	
+	CleanupStack::PopAndDestroy(buffer);
+		
+	return aHeap;
+	}
+
+EXPORT_C CMemSpyApiHeap* RMemSpySession::GetHeap()
+	{
+	CMemSpyApiHeap *result = NULL;
+	TRAPD(error, result = GetHeapL());
+	return error == KErrNone ? result : NULL;
+	}
+
+
+
+EXPORT_C void RMemSpySession::GetEComCategoriesL(RArray<CMemSpyApiEComCategory*> &aCategories)
+    {
+    TPckgBuf<TInt> count;
+    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComCategoryCount, TIpcArgs(&count)));
+    
+    TInt requestedCount = count();
+    HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyEComCategoryData));
+    TPtr8 bufferPtr(buffer->Des());
+    
+    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComCategories, TIpcArgs(&count, &bufferPtr)));
+    aCategories.Reset();
+    
+    TInt receivedCount = Min(count(), requestedCount);
+    for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyEComCategoryData))
+        {
+        TPckgBuf<TMemSpyEComCategoryData> data;
+        data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyEComCategoryData));
+        aCategories.AppendL(CMemSpyApiEComCategory::NewLC(data()));
+        }
+    CleanupStack::Pop(aCategories.Count());
+    CleanupStack::PopAndDestroy(buffer);
+    }
+    
+EXPORT_C void RMemSpySession::GetEComInterfacesL(TUid aCategory, RArray<CMemSpyApiEComInterface*> &aInterfaces)
+    {
+    TPckgBuf<TInt> count;
+    TPckgBuf<TUid> category(aCategory);
+    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComInterfaceCount, TIpcArgs(&count, &category)));
+    
+    TInt requestedCount = count();
+    HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyEComInterfaceData));
+    TPtr8 bufferPtr(buffer->Des());
+    
+    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComInterfaces, TIpcArgs(&count, &category, &bufferPtr)));
+    aInterfaces.Reset();
+    
+    TInt receivedCount = Min(count(), requestedCount);
+    for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyEComInterfaceData))
+        {
+        TPckgBuf<TMemSpyEComInterfaceData> data;
+        data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyEComInterfaceData));
+        aInterfaces.AppendL(CMemSpyApiEComInterface::NewLC(data()));
+        }
+    CleanupStack::Pop(aInterfaces.Count());
+    CleanupStack::PopAndDestroy(buffer);
+    }
+
+EXPORT_C void RMemSpySession::GetEComImplementationsL(TUid aInterface, RArray<CMemSpyApiEComImplementation*> &aImplementations)
+    {
+    TPckgBuf<TInt> count;
+    TPckgBuf<TUid> interface(aInterface);
+    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComImplementationCount, TIpcArgs(&count, &interface)));
+    
+    TInt requestedCount = count();
+    HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyEComImplementationData));
+    TPtr8 bufferPtr(buffer->Des());
+    
+    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComImplementations, TIpcArgs(&count, &interface, &bufferPtr)));
+    aImplementations.Reset();
+    
+    TInt receivedCount = Min(count(), requestedCount);
+    for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyEComImplementationData))
+        {
+        TPckgBuf<TMemSpyEComImplementationData> data;
+        data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyEComImplementationData));
+        aImplementations.AppendL(CMemSpyApiEComImplementation::NewLC(data()));
+        }
+    CleanupStack::Pop(aImplementations.Count());
+    CleanupStack::PopAndDestroy(buffer);
+    }
+
+EXPORT_C void RMemSpySession::DumpKernelHeap()
+	{
+	SendReceive( EMemSpyClientServerOpDumpKernelHeap );
+	}
+
+EXPORT_C void RMemSpySession::OutputKernelHeapDataL()
+	{		
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadId,
+			TIpcArgs(KMemSpyClientServerThreadIdKernel)));
+	
+	}
+
+EXPORT_C void RMemSpySession::OutputKernelHeapData(TRequestStatus& aStatus)
+	{
+	SendReceive(EMemSpyClientServerOpHeapData,
+		TIpcArgs(KMemSpyClientServerThreadIdKernel),
+		aStatus);
+	}
+
+EXPORT_C void RMemSpySession::OutputThreadHeapDataL( TThreadId aThreadId)
+	{			
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadId,
+			TIpcArgs(aThreadId)));
+	}
+
+EXPORT_C void RMemSpySession::OutputThreadHeapDataL(const TDesC& aThreadName)
+	{	
+	const TIpcArgs args( &aThreadName );
+	        
+	User::LeaveIfError( SendReceive( EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadName, args ));	
+	}
+
+EXPORT_C void RMemSpySession::OutputThreadCellListL(TThreadId aThreadId)
+	{	
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapCellListing | KMemSpyOpFlagsIncludesThreadId,
+			TIpcArgs(aThreadId)));
+	}
+
+EXPORT_C void RMemSpySession::OutputHeapInfoUserL(TThreadId aThreadId)
+	{
+	User::LeaveIfError(SendReceive( EMemSpyClientServerOpHeapInfo | KMemSpyOpFlagsIncludesThreadId,
+			TIpcArgs(aThreadId)));
+	}
+
+EXPORT_C void RMemSpySession::SwitchOutputSinkL( TMemSpySinkType aType )
+	{
+	TInt op;
+	if( aType == ESinkTypeFile )
+		op = EMemSpyClientServerOpSwitchOutputSinkFile;
+	else
+		op = EMemSpyClientServerOpSwitchOutputSinkTrace;
+			
+	User::LeaveIfError(SendReceive( op ));
+	}
+
+EXPORT_C void RMemSpySession::SwitchOutputToTraceL()
+	{
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSwitchOutputSinkTrace));
+	}
+    
+EXPORT_C void RMemSpySession::SwitchOutputToFileL(const TDesC& aRootFolder)
+	{
+	TIpcArgs args;
+	if (aRootFolder.Length())
+		{
+		args.Set(0, &aRootFolder);
+		}
+	
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSwitchOutputSinkFile, args));
+	}
+
+EXPORT_C void RMemSpySession::OutputStackInfoL(TThreadId aThreadId)
+	{
+	User::LeaveIfError(SendReceive( EMemSpyClientServerOpStackInfo | KMemSpyOpFlagsIncludesThreadId,
+			TIpcArgs(aThreadId)));
+	}
+
+EXPORT_C void RMemSpySession::OutputStackDataL(TThreadId aThreadId, TMemSpyDriverDomainType aType )
+	{
+	TInt op;
+	if( aType == EMemSpyDriverDomainUser )
+		op = EMemSpyClientServerOpStackDataUser;
+	else
+		op = EMemSpyClientServerOpStackDataKernel;
+	
+	User::LeaveIfError(SendReceive( op | KMemSpyOpFlagsIncludesThreadId,
+			TIpcArgs(aThreadId, aType)));
+		
+	}
+
+EXPORT_C void RMemSpySession::OutputThreadInfoHandlesL(TThreadId aThreadId)
+	{
+	TPckgBuf<TThreadId> id(aThreadId);
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpOutputInfoHandles, TIpcArgs( &id )));	
+	}
+
+EXPORT_C void RMemSpySession::OutputAOListL(TThreadId aId, TMemSpyThreadInfoItemType aType)
+	{
+	TPckgBuf<TThreadId> id(aId);
+	TPckgBuf<TMemSpyThreadInfoItemType> type(aType);
+	
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpOutputAOList, TIpcArgs( &id, &type )));
+	}
+
+EXPORT_C void RMemSpySession::OutputKernelObjectsL()
+	{
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpEnumerateKernelContainerAll));
+	}
+
+EXPORT_C void RMemSpySession::OutputCompactStackInfoL()
+	{
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpStackInfoCompact)); 
+	}
+
+EXPORT_C void RMemSpySession::OutputCompactHeapInfoL()
+	{
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapInfoCompact)); 
+	}
+// Asynchronous operations
+EXPORT_C void RMemSpySession::OutputPhoneInfo(TRequestStatus& aStatus)
+	{	
+	SendReceive(EMemSpyClientServerOpSummaryInfo | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
+	}
+
+EXPORT_C void RMemSpySession::OutputDetailedPhoneInfo(TRequestStatus& aStatus)
+	{	
+	SendReceive(EMemSpyClientServerOpSummaryInfoDetailed | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
+	}
+
+EXPORT_C void RMemSpySession::OutputHeapInfo(TRequestStatus& aStatus)
+	{	
+	SendReceive(EMemSpyClientServerOpHeapInfo | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
+	}
+
+EXPORT_C void RMemSpySession::OutputCompactHeapInfo(TRequestStatus& aStatus)
+	{	
+	SendReceive(EMemSpyClientServerOpHeapInfoCompact | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
+	}
+
+EXPORT_C void RMemSpySession::OutputHeapCellListing(TRequestStatus& aStatus)
+	{	
+	SendReceive(EMemSpyClientServerOpHeapCellListing | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
+	}
+
+EXPORT_C void RMemSpySession::OutputHeapData(TRequestStatus& aStatus)
+	{	
+	SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
+	}
+
+// synchronous version of the operation - for CLI
+EXPORT_C void RMemSpySession::OutputHeapData()
+	{
+	SendReceive(EMemSpyClientServerOpHeapData);
+	}
+
+EXPORT_C void RMemSpySession::OutputStackInfo(TRequestStatus& aStatus)
+	{	
+	SendReceive(EMemSpyClientServerOpStackInfo | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
+	}
+
+EXPORT_C void RMemSpySession::OutputCompactStackInfo(TRequestStatus& aStatus)
+	{	
+	SendReceive(EMemSpyClientServerOpStackInfoCompact | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
+	}
+
+EXPORT_C void RMemSpySession::OutputUserStackData(TRequestStatus& aStatus)
+	{	
+	SendReceive(EMemSpyClientServerOpStackDataUser | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
+	}
+
+EXPORT_C void RMemSpySession::OutputKernelStackData(TRequestStatus& aStatus)
+	{	
+	SendReceive(EMemSpyClientServerOpStackDataKernel | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
+	}
+
+// Synchronous operations
+EXPORT_C void RMemSpySession::OutputPhoneInfo()
+	{	
+	SendReceive( EMemSpyClientServerOpSummaryInfo , TIpcArgs() );
+	}
+
+EXPORT_C TInt RMemSpySession::GetSwmtCyclesCount()
+	{
+	TPckgBuf<TInt> count;
+	TIpcArgs args( &count );
+		
+	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetMemoryTrackingCycleCount, args ));
+	
+	return count();
+	}
+
+EXPORT_C void RMemSpySession::SetSwmtAutoStartProcessList( CArrayFixFlat<TUid>* aList )
+	{
+	TInt count = aList->Count();
+	TIpcArgs args( &aList, &count );
+	
+	SendReceive( EMemSpyClientServerOpSetSwmtAutoStartProcessList, args );
+	}
+
+EXPORT_C void RMemSpySession::SwmtResetTracking()
+	{
+	SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingReset );
+	}
+
+EXPORT_C void RMemSpySession::GetOutputSink( TMemSpySinkType& aType )
+	{
+	TPckgBuf<TMemSpySinkType> type( aType );
+	TIpcArgs args( &type );
+	
+	SendReceive( EMemSpyClientServerOpGetOutputSink, args );
+	
+	aType = type();
+	}
+
+EXPORT_C void RMemSpySession::NotifyDeviceWideOperationProgress(TMemSpyDeviceWideOperationProgress &aProgress, TRequestStatus &aStatus)
+	{
+	SendReceive(EMemSpyClientServerOpNotifyDeviceWideOperationProgress | KMemSpyOpFlagsAsyncOperation,
+			TIpcArgs(&aProgress.iProgress, &aProgress.iDescription), 
+			aStatus);
+	}
+
+EXPORT_C void RMemSpySession::CancelDeviceWideOperationL()
+	{
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpCancelDeviceWideOperation));
+	}
+
+// SWMT operations
+EXPORT_C void RMemSpySession::SetSwmtCategoriesL(TInt aCategories)
+	{
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesSet,
+			TIpcArgs(aCategories)));
+	}
+
+EXPORT_C void RMemSpySession::SetSwmtHeapDumpsEnabledL(TBool aEnabled)
+	{
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingHeapDumpSet,
+			TIpcArgs(aEnabled)));
+	}
+
+EXPORT_C void RMemSpySession::SetSwmtMode(TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode aMode)
+	{
+	TPckgBuf<TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode> mode( aMode );
+	TIpcArgs args(&mode);
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingModeSet, args));
+	}
+
+EXPORT_C TBool RMemSpySession::IsSwmtRunningL()
+	{
+	TPckgBuf<TBool> ret;
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpIsSwmtRunning, TIpcArgs(&ret)));
+	
+	return ret();
+	}
+
+EXPORT_C void RMemSpySession::StartSwmtTimerL(TInt aPeriod)
+	{
+	SetSwmtTimerIntervalL(aPeriod);
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart));
+	}
+
+EXPORT_C void RMemSpySession::StartSwmtTimerL()
+	{
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart));
+	}
+
+EXPORT_C void RMemSpySession::SetSwmtTimerIntervalL(TInt aPeriod)
+	{
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodSet,
+			TIpcArgs(aPeriod)));
+	}
+
+EXPORT_C void RMemSpySession::StopSwmtTimerL()
+	{
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerStop));
+	}
+
+
+EXPORT_C void RMemSpySession::ForceSwmtUpdateL()
+	{
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate));
+	}
+
+EXPORT_C void RMemSpySession::ForceSwmtUpdate(TRequestStatus& aStatus)
+	{
+	SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate, 
+			TIpcArgs(),
+			aStatus);
+	}
+
+EXPORT_C void RMemSpySession::SetSwmtFilter( const TDesC& aFilter )
+	{	
+	TIpcArgs args( &aFilter );
+	User::LeaveIfError( SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterSet, args ) );
+	}
+
+EXPORT_C void RMemSpySession::GetSwmtFilter( TName& aFilter )
+	{
+    TPckgBuf<TName> name;
+    TIpcArgs args( &name );
+		User::LeaveIfError( SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterGet, args ) );
+	aFilter = name();
+	}
+        
+EXPORT_C void RMemSpySession::GetSwmtCategoriesL(TInt& aCategories)
+	{
+	TPckgBuf<TInt> cat;	
+	TIpcArgs args( &cat );
+		User::LeaveIfError( SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesGet, args ) );
+	aCategories = cat();
+	}
+
+EXPORT_C void RMemSpySession::GetSwmtHeapDumpsEnabledL(TBool& aEnabled)
+	{
+	TPckgBuf<TBool> enabled;
+	TIpcArgs args( &enabled );
+		User::LeaveIfError( SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingHeapDumpGet, args ) );
+		
+	aEnabled = enabled();
+	}
+        
+EXPORT_C void RMemSpySession::GetSwmtMode(TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode& aMode)
+	{
+	TPckgBuf<TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode> mode;
+	TIpcArgs args( &mode );
+		User::LeaveIfError( SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingModeGet, args ) );
+	aMode = mode();
+	}
+    
+EXPORT_C void RMemSpySession::GetSwmtTimerIntervalL(TInt& aPeriod)
+	{
+	TPckgBuf<TInt> time;
+	TIpcArgs args( &time );
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodGet,
+			args));
+	aPeriod = time();
+	}
+
+EXPORT_C TInt TMemSpyDeviceWideOperationProgress::Progress() const 
+	{
+	return iProgress();
+	}
+
+EXPORT_C const TDesC& TMemSpyDeviceWideOperationProgress::Description() const
+	{
+	return iDescription;
+	}
+
+// Servers
+EXPORT_C void RMemSpySession::GetServersL(RArray<CMemSpyApiServer*> &aServers)
+    {
+    TPckgBuf<TInt> count;
+    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetServerCount, TIpcArgs(&count)));
+    
+    TInt requestedCount = count();
+    HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyServerData));
+    TPtr8 bufferPtr(buffer->Des());
+    
+    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetServers, TIpcArgs(&count, &bufferPtr)));
+    aServers.Reset();
+    
+    TInt receivedCount = Min(count(), requestedCount);
+    for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyServerData))
+        {
+        TPckgBuf<TMemSpyServerData> data;
+        data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyServerData));
+        aServers.AppendL(CMemSpyApiServer::NewLC(data()));
+        }
+    CleanupStack::Pop(aServers.Count());
+    CleanupStack::PopAndDestroy(buffer);
+    }
+
+EXPORT_C void RMemSpySession::GetServersL(RArray<CMemSpyApiServer*> &aServers, TSortType aSortType)
+	{
+	TPckgBuf<TInt> count;
+	TPckgBuf<TSortType> sort( aSortType );
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetServerCount, TIpcArgs(&count)));
+	    	
+	TInt requestedCount = count();
+	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyServerData));
+	TPtr8 bufferPtr(buffer->Des());
+	    
+	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetSortedServers, TIpcArgs(&count, &bufferPtr, &sort)));
+	aServers.Reset();
+	    
+	TInt receivedCount = Min(count(), requestedCount);
+	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyServerData))
+		{
+		TPckgBuf<TMemSpyServerData> data;
+		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyServerData));
+		aServers.AppendL(CMemSpyApiServer::NewLC(data()));
+		}
+	CleanupStack::Pop(aServers.Count());
+	CleanupStack::PopAndDestroy(buffer);
+	}
+
+EXPORT_C void RMemSpySession::ServerListOutputGenericL( TBool aDetailed )
+	{
+	TPckgBuf<TBool> detailed( aDetailed );
+	TIpcArgs args( &detailed );
+	User::LeaveIfError( SendReceive( EMemSpyClientServerOpServerListOutputGeneric, args ) );
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyServer/Source/MemSpyServerMain.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,75 @@
+/*
+* 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:
+* MemSpyServer Main class
+*/
+
+// System includes
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+
+// Engine includes
+#include <memspy/engine/memspyengine.h>
+
+// User includes
+//#include "MemSpyServer.h"
+
+static void RunServerL()
+    {
+    // Scheduler
+    CActiveScheduler* scheduler = new (ELeave) CActiveScheduler();
+    CleanupStack::PushL( scheduler );    
+    CActiveScheduler::Install( scheduler );    
+    
+    // F32
+    RFs fsSession;
+    User::LeaveIfError(fsSession.Connect());
+    CleanupClosePushL(fsSession);
+    
+    // MemSpyEngine initialization
+    CMemSpyEngine* engine = CMemSpyEngine::NewL(fsSession);
+    CleanupStack::PushL(engine);
+    
+    // Play nicely with external processes
+    RProcess::Rendezvous( KErrNone );       
+
+    // Start wait loop.
+    CActiveScheduler::Start();
+    
+    // Tidy up
+    CleanupStack::PopAndDestroy( 3, scheduler );
+    }
+
+TInt E32Main()
+    {
+    __UHEAP_MARK;
+
+    CTrapCleanup* cleanupTrap = CTrapCleanup::New();
+    
+	TInt r = KErrNoMemory;
+	if ( cleanupTrap )
+		{
+		TRAPD(err, RunServerL());		
+		if  ( err != KErrNone )
+		        {
+		        RDebug::Print(_L("[MemSpyCmdLine] E32Main() - MemSpyServer - error: %d"), err);
+		        }
+		delete cleanupTrap;
+		}  
+
+    __UHEAP_MARKEND;
+
+    return r;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyServer/data/MemSpyEComInterfaceIds.xml	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,18 @@
+<?xml version="1.0" standalone="yes"?>
+<memspy_ecom_sections>
+
+    <category name="Messaging">
+		<interface uid="0xABCD1234" name="Watchers" />
+    </category>
+
+    <category name="App-Protocols">
+		<interface uid="0x101F446D" name="HTTP Filters" />
+		<interface uid="0x1000A449" name="HTTP Protocol" />
+    </category>
+
+    <category name="S60 AIW">
+		<interface uid="0x101F8650" name="AIW Class Base" />
+		<interface uid="0x101F8652" name="AIW Class Menu" />
+    </category>
+
+</memspy_ecom_sections>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyServer/group/MemSpyServer.mmp	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,58 @@
+/*
+* 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 <bldvariant.hrh>
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGETTYPE EXE
+TARGET MemSpyServer.exe
+UID 0 0x2002EA8D
+SECUREID     0xE5883BC2
+VENDORID	 0x101FB657 // Nokia
+
+EPOCSTACKSIZE 0x4000
+EPOCHEAPSIZE 0x100000 0x4000000
+
+
+SOURCEPATH ../Source
+SOURCE		MemSpyServerMain.cpp 
+
+USERINCLUDE ../Include
+
+CAPABILITY ReadUserData WriteUserData ReadDeviceData WriteDeviceData PowerMgmt
+
+OS_LAYER_SYSTEMINCLUDE
+
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         MemSpyDriverClient.lib
+LIBRARY         MemSpyEngine.lib
+
+LIBRARY 		euser.lib
+LIBRARY			ecom.lib
+LIBRARY			efsrv.lib
+LIBRARY			estor.lib
+LIBRARY			bafl.lib
+LIBRARY			ws32.lib
+LIBRARY			cone.lib
+LIBRARY			eikcore.lib
+LIBRARY			fbscli.lib 
+LIBRARY 		PlatformEnv.lib
+LIBRARY 		flogger.lib
+LIBRARY			apgrfx.lib
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memspy/MemSpyServer/group/bld.inf	Wed Sep 15 13:53:27 2010 +0300
@@ -0,0 +1,26 @@
+/*
+* 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:
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../data/MemSpyEComInterfaceIds.xml									z:/private/E5883BC2/memspyecominterfaceids.xml
+
+
+PRJ_MMPFILES
+MemSpyServer.mmp
--- a/memspy/group/ReleaseNotes_MemSpy.txt	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/group/ReleaseNotes_MemSpy.txt	Wed Sep 15 13:53:27 2010 +0300
@@ -1,7 +1,7 @@
 ===============================================================================
 
-RELEASE NOTES - MEMSPY v1.2.1
-RELEASED 15th June 2010 
+RELEASE NOTES - MEMSPY v2.2.0
+RELEASED 24th August 2010 
 
 SUPPORTS S60 5.0+
 
@@ -28,10 +28,11 @@
 
 ===============================================================================
 
-What's New in v1.2.1
+What's New in v2.2.0
 ====================
-- Fix: Stack dumps fixed.
-
+- Feature: Servers view to display a list of running servers.
+- Feature: ECom view to display ECom categories, interfaces and implementations.
+- Feature: Processes can be now terminated.
 
 ===============================================================================
 
@@ -93,8 +94,19 @@
 
 Version History:
 ================
-Version 1.2.0 - 27th October 2009
+
+Version 2.1.0 - 15th June 2010 
 ------------------------------
+- Feature: Folder where log files are saved can now be set in settings.
+- Feature: Introduced new Orbit based user interface.
+- Change: Servers, Ecom, Window groups, System info and Automatic Capture were
+  removed.
+- Change: Console interface was removed.
+- Change: Command line interface commands were changed to be more user 
+  friendly.
+
+Version 1.2.0 - 27th October 2009 
+---------------------------------
 - Feature: Tracking modes introduced for simplify System Wide Memory Tracking
   settings.
 - Feature: System Wide Memory Tracking categories can now be selected.
--- a/memspy/group/bld.inf	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/group/bld.inf	Wed Sep 15 13:53:27 2010 +0300
@@ -29,10 +29,12 @@
 // Commandline includes
 #include "../CommandLine/group/bld.inf"
 
-// Console UI
-#include "../Console/group/bld.inf"
+// MemSpyServer
+#include "../MemSpyServer/group/bld.inf"
 
+// MemSpyClient
+#include "../MemSpyClient/group/bld.inf"
 
 PRJ_EXPORTS
 ../rom/memspy.iby      CORE_IBY_EXPORT_PATH(tools,memspy.iby)
-../rom/memspy_rom.iby  CORE_IBY_EXPORT_PATH(tools/rom,memspy_rom.iby)
+../rom/memspy_rom.iby  CORE_IBY_EXPORT_PATH(tools/rom,memspy_rom.iby)
\ No newline at end of file
--- a/memspy/memspy_plat/memspy_api/include/MemSpyEngineClientInterface.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/MemSpyEngineClientInterface.h	Wed Sep 15 13:53:27 2010 +0300
@@ -45,11 +45,12 @@
 const TInt KMemSpyOpFlagsInclusionMask          = 0xFFFF0000;
 const TInt KMemSpyOpFlagsIncludesThreadId       = 0x00010000;
 const TInt KMemSpyOpFlagsIncludesThreadName     = 0x00020000;
-
+const TInt KMemSpyOpFlagsAsyncOperation         = 0x00040000;
 // Literal constants
 _LIT( KMemSpyServerName, "MemSpyServer" );
+_LIT( KMemSpyProcessName0, "MemSpyServer.exe" );
 _LIT( KMemSpyProcessName1, "MemSpyUI.exe" );
-_LIT( KMemSpyProcessName2, "MemSpyConsole.exe" );
+//_LIT( KMemSpyProcessName2, "MemSpyConsole.exe" );
 
 //
 // Supported MemSpy operation types
@@ -256,14 +257,143 @@
      * [INTERNAL REQUEST]
      */
     EMemSpyClientServerOpSystemWideMemoryTrackingHeapDumpSet,
-    
+        
     /**
      * [INTERNAL REQUEST]
      */
+    EMemSpyClientServerOpSystemWideMemoryTrackingModeSet,        
+    
+    /**
+	 * [INTERNAL REQUEST]
+	 */
+	EMemSpyClientServerOpMarkerUiFirst,
+	
+	EMemSpyClientServerOpGetProcessCount = EMemSpyClientServerOpMarkerUiFirst,
+	
+	EMemSpyClientServerOpGetProcesses,
+	
+	EMemSpyClienServerOpGetProcessIdByName,
+	
+	EMemSpyClientServerOpGetThreadCount,
+	
+	EMemSpyClientServerOpGetThreads,
+	
+	EMemSpyClientServerOpSetThreadPriority,
+	
+	EMemSpyClientServerOpProcessSystemPermanentOrCritical,
+	
+	EMemSpyClientServerOpEndProcess,
+	
+	EMemSpyClientServerOpSwitchToProcess,
+	
+	//Threads operations
+	EMemSpyClientServerOpThreadSystemPermanentOrCritical,
+	
+	EMemSpyClientServerOpEndThread,
+	
+	EMemSpyClientServerOpSwitchToThread,
+	
+	EMemSpyClientServerOpGetInfoItemType,
+	
+	EMemSpyClientServerOpGetProcessIdByThreadId,
+	
+	EMemSpyClientServerOpGetThreadInfoItemsCount,
+	
+	EMemSpyClientServerOpGetThreadInfoItems,
+	
+	EMemSpyClientServerOpOutputInfoHandles,
+	
+	EMemSpyClientServerOpOutputAOList,
+		
+	
+	//Kernel Objects operations
+	EMemSpyClientServerOpGetKernelObjectCount,
+	
+	EMemSpyClientServerOpGetKernelObjects,
+	
+	EMemSpyClientServerOpGetKernelObjectItemCount,
+	
+	EMemSpyClientServerOpGetKernelObjectItems,
+	
+	EMemSpyClientServerOpGetHeap,
+	
+	EMemSpyClientServerOpGetMemoryTrackingCycleCount,
+	
+	EMemSpyClientServerOpGetMemoryTrackingCycles,
+	
+	EMemSpyClientServerOpGetMemoryTrackingMdcaCount,
+	/**
+	 * [INTERNAL REQUEST]
+	 * Register for notifications of device wide operation progress.
+	 */
+	EMemSpyClientServerOpNotifyDeviceWideOperationProgress,
+	
+	/**
+	 * [INTERNAL REQUEST]
+	 * Cancel current device wide operation
+	 */
+	EMemSpyClientServerOpCancelDeviceWideOperation,	
+	
+	EMemSpyClientServerOpOutputAllContainerContents,
+	    
+	EMemSpyClientServerOpDumpKernelHeap,
+	
+	EMemSpyClientServerOpSetSwmtAutoStartProcessList,
+		
+	EMemSpyClientServerOpGetOutputSink,
+	
+	/**
+	 * [INTERNAL REQUEST]
+	 * Check if system wide memory tracking timer is running.
+	 */
+	EMemSpyClientServerOpIsSwmtRunning,
+	
+	EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodGet,
+
+	EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterGet,
+    
+    EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesGet,
+    
+    EMemSpyClientServerOpSystemWideMemoryTrackingHeapDumpGet,
+
+    EMemSpyClientServerOpSystemWideMemoryTrackingModeGet,   
+	
+    //Servers methods
+	EMemSpyClientServerOpGetServerCount,
+	
+	EMemSpyClientServerOpGetServers,
+	
+	EMemSpyClientServerOpGetSortedServers,
+	
+	EMemSpyClientServerOpServerListOutputGeneric,
+	
+	EMemSpyClientServerOpGetEComCategoryCount,
+	    
+	EMemSpyClientServerOpGetEComCategories,
+	
+	EMemSpyClientServerOpGetEComInterfaceCount,
+	        
+	EMemSpyClientServerOpGetEComInterfaces,
+	
+	EMemSpyClientServerOpGetEComImplementationCount,
+	            
+	EMemSpyClientServerOpGetEComImplementations,
+	
+	EMemSpyClientServerOpMarkerUiLast,		
+	
+	/**
+	 * [INTERNAL REQUEST]
+	 */
     EMemSpyClientServerOpMarkerLast,
     };
 
 
+enum TMemSpyEndType
+	{
+	ETerminate,
+	EKill,
+	EPanic
+	};
 
 
 
--- a/memspy/memspy_plat/memspy_api/include/memspy/driver/shared/MemSpyDriverEnumerationsShared.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/driver/shared/MemSpyDriverEnumerationsShared.h	Wed Sep 15 13:53:27 2010 +0300
@@ -24,12 +24,24 @@
 // Enumerations
 enum TMemSpyDriverCellType
 	{
-	EMemSpyDriverGoodAllocatedCell = 0,
-	EMemSpyDriverGoodFreeCell,
-	EMemSpyDriverBadAllocatedCellSize,
-	EMemSpyDriverBadAllocatedCellAddress,
-	EMemSpyDriverBadFreeCellAddress,
-	EMemSpyDriverBadFreeCellSize
+	EMemSpyDriverAllocatedCellMask	= 0x000000FF,
+	EMemSpyDriverFreeCellMask		= 0x0000FF00,
+	EMemSpyDriverBadCellMask		= 0xFF000000,
+
+	EMemSpyDriverHeapAllocation		= 0x00000001,
+	EMemSpyDriverDlaAllocation		= 0x00000002,
+	EMemSpyDriverPageAllocation		= 0x00000003,
+	EMemSpyDriverSlabAllocation		= 0x00000004,
+	
+	EMemSpyDriverHeapFreeCell		= 0x00000100,
+	EMemSpyDriverDlaFreeCell		= 0x00000200,
+	EMemSpyDriverSlabFreeCell		= 0x00000300, // Used to track free cells in partially-filled slabs
+	EMemSpyDriverSlabFreeSlab		= 0x00000400, // Used to track entirely empty slabs (that don't have a specific cell size)
+
+	EMemSpyDriverHeapBadFreeCellAddress			= 0x01000000,
+	EMemSpyDriverHeapBadFreeCellSize			= 0x02000000,
+	EMemSpyDriverHeapBadAllocatedCellSize		= 0x03000000,
+	EMemSpyDriverHeapBadAllocatedCellAddress	= 0x04000000,
 	};
 
 
--- a/memspy/memspy_plat/memspy_api/include/memspy/driver/shared/MemSpyDriverObjectsShared.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/driver/shared/MemSpyDriverObjectsShared.h	Wed Sep 15 13:53:27 2010 +0300
@@ -349,7 +349,8 @@
     enum THeapImplementationType
         {
         ETypeUnknown = 0,
-        ETypeRHeap
+        ETypeRHeap = 1,
+		ETypeRHybridHeap = 2,
         };
 
 public: // Constructor & destructor
@@ -426,17 +427,19 @@
     };
 
 
-
 /**
- * Free cell information
+ * cell information
  */
 class TMemSpyDriverFreeCell
-    {
+	{
 public:
-    TInt iType;
-    TAny* iAddress;
-    TInt iLength;
-    };
+	TMemSpyDriverCellType iType;
+	TAny* iAddress;
+	TInt iLength;
+	};
+
+// For compatibility I can't change TMemSpyDriverCell to be the class and typdef/derive TMemSpyDriverFreeCell. Sigh...
+typedef TMemSpyDriverFreeCell TMemSpyDriverCell;
 
 
 /** 
--- a/memspy/memspy_plat/memspy_api/include/memspy/driver/shared/MemSpyDriverObjectsSharedRHeap.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/driver/shared/MemSpyDriverObjectsSharedRHeap.h	Wed Sep 15 13:53:27 2010 +0300
@@ -35,80 +35,6 @@
 class CTrapCleanup;
 
 
-
-class TMemSpyHeapObjectDataRHeap
-    {
-public:
-    inline TMemSpyHeapObjectDataRHeap()
-        : iAccessCount( 0 ),
-          iHandleCount( 0 ),
-          iHandles( NULL ),
-          iFlags( 0 ),
-          iCellCount( 0 ),
-          iTotalAllocSize ( 0 ),
-          //
-          iMinLength( 0 ),
-          iMaxLength( 0 ),
-          iOffset ( 0 ),
-          iGrowBy( 0 ),
-          iChunkHandle ( 0 ),
-          iBase( NULL ),
-          iTop( NULL ),
-          iAlign( 0 ),
-          iMinCell( 0 ),
-          iPageSize( 0 ),
-          iNestingLevel( 0 ),
-          iAllocCount( 0 ),
-          iFailRate( 0 ),
-          iFailed( EFalse ),
-          iFailAllocCount( 0 ),
-          iRand( 0 ),
-          iTestData( NULL )
-        {
-        }
-
-public: // API
-    inline TUint8* Base() const { return iBase; }
-    inline TUint Size() const { return iTop - iBase; }
-
-public: // From RAllocator
-	TInt iAccessCount;
-	TInt iHandleCount;
-	TInt* iHandles;
-	TUint32 iFlags;
-	TInt iCellCount;
-	TInt iTotalAllocSize;
-
-public: // From RHeap
-	TInt iMinLength;
-	TInt iMaxLength;
-	TInt iOffset;
-	TInt iGrowBy;
-	TInt iChunkHandle;
-    RFastLock iLock;
-	TUint8* iBase;
-	TUint8* iTop;
-	TInt iAlign;
-	TInt iMinCell;
-	TInt iPageSize;
-#ifdef __SYMBIAN_KERNEL_HYBRID_HEAP__
-	struct SCell { TInt len; SCell* next };
-    SCell iFree;
-#else
-    RHeap::SCell iFree;
-#endif
-	TInt iNestingLevel;
-	TInt iAllocCount;
-    RAllocator::TAllocFail iFailType;
-	TInt iFailRate;
-	TBool iFailed;
-	TInt iFailAllocCount;
-	TInt iRand;
-	TAny* iTestData;
-    };
-
-
-
 /**
  * Base class for MemSpy RHeap statistics
  */
@@ -205,33 +131,6 @@
     TUint32 iChecksum;
     };
 
-
-
-
-
-/**
- * RHeap statistics for common cell types
- */
-class TMemSpyHeapStatisticsRHeapCommon
-    {
-public: // Constructors
-    inline TMemSpyHeapStatisticsRHeapCommon()
-        : iTotalCellCount( 0 )
-        {
-        }
-
-public:
-    inline TUint TotalCellCount() const { return iTotalCellCount; }
-    inline void SetTotalCellCount( TUint aValue ) { iTotalCellCount = aValue; }
-
-private:
-    TUint iTotalCellCount;
-    };
-
-
-
-
-
 /**
  * RHeap statistics class
  */
@@ -239,6 +138,7 @@
     {
 public: // Constructors
     inline TMemSpyHeapStatisticsRHeap()
+		: iCommittedFreeSpace(0)
         {
         }
 
@@ -248,14 +148,14 @@
     //
     inline TMemSpyHeapStatisticsRHeapAllocated& StatsAllocated() { return iStatisticsAllocated; }
     inline const TMemSpyHeapStatisticsRHeapAllocated& StatsAllocated() const { return iStatisticsAllocated; }
-    //
-    inline TMemSpyHeapStatisticsRHeapCommon& StatsCommon() { return iStatisticsCommon; }
-    inline const TMemSpyHeapStatisticsRHeapCommon& StatsCommon() const { return iStatisticsCommon; }
+
 
 private: // Data members
-    TMemSpyHeapStatisticsRHeapCommon iStatisticsCommon;
     TMemSpyHeapStatisticsRHeapFree iStatisticsFree;
     TMemSpyHeapStatisticsRHeapAllocated iStatisticsAllocated;
+
+public: // I am fed up of all these pointless inline accessors...
+	TInt iCommittedFreeSpace; // The amount of committed memory that isn't payload data in allocated or free cells
     };
 
 
@@ -275,10 +175,15 @@
           iChunkHandle( NULL ),
           iChunkBaseAddress( NULL ),
           iDebugAllocator( EFalse ),
-          iHeaderSizeFree( 0 ),
-          iHeaderSizeAllocated( 0 ),
+          //iHeaderSizeFree( 0 ),
+          //iHeaderSizeAllocated( 0 ),
           iIsUserThread( ETrue ),
-          iSharedHeap( EFalse )
+		  iVTable(0),
+          iSharedHeap( EFalse ),
+          iHeapSize(0),
+          iAllocatorAddress(NULL),
+		  iMinHeapSize(0),
+		  iMaxHeapSize(0)
         {
         }
 
@@ -358,12 +263,6 @@
     inline TAny* ChunkBaseAddress() const { return iChunkBaseAddress; }
     inline void SetChunkBaseAddress( TAny* aValue ) { iChunkBaseAddress = aValue; }
     //
-    inline TUint HeaderSizeFree() const { return iHeaderSizeFree; }
-    inline void SetHeaderSizeFree( TUint aValue ) { iHeaderSizeFree = aValue; }
-    //
-    inline TUint HeaderSizeAllocated() const { return iHeaderSizeAllocated; }
-    inline void SetHeaderSizeAllocated( TUint aValue ) { iHeaderSizeAllocated = aValue; }
-    //
     inline TBool IsDebugAllocator() const { return iDebugAllocator; }
     inline void SetDebugAllocator( TBool aValue ) { iDebugAllocator = aValue; }
     //
@@ -375,30 +274,24 @@
     //
     inline TUint VTable() const { return iVTable; }
     inline void SetVTable( TUint aValue ) { iVTable = aValue; }
-    //
-    inline TUint ClassSize() const { return iClassSize; }
-    inline void SetClassSize( TUint aValue ) { iClassSize = aValue; }
 
 private: // Data members
     TBuf8< KMaxFullName * 2 > iChunkName;
+public:
     TUint iChunkSize;
     TAny* iChunkHandle;
     TAny* iChunkBaseAddress;
     TBool iDebugAllocator;
-    TUint iHeaderSizeFree;
-    TUint iHeaderSizeAllocated;
     TBool iSharedHeap;
     TBool iIsUserThread;
     TUint iVTable;
-    TUint iClassSize;
+	TUint iHeapSize; // Committed size - generally the same as iChunkSize (except maybe for kernel heap)
+	TAny* iAllocatorAddress; // replacement for things using the RHeap base address
+	TUint iMinHeapSize; // Minimum committed size
+	TUint iMaxHeapSize; // Max committed size
     };
 
 
-
-
-
-
-
 /**
  *
  */
@@ -413,15 +306,17 @@
     inline TMemSpyHeapMetaDataRHeap& MetaData() { return iMetaData; }
     inline const TMemSpyHeapMetaDataRHeap& MetaData() const { return iMetaData; }
     //
-    inline TMemSpyHeapObjectDataRHeap& ObjectData() { return iObjectData; }
-    inline const TMemSpyHeapObjectDataRHeap& ObjectData() const { return iObjectData; }
+    //inline TMemSpyHeapObjectDataRHeap& ObjectData() { return iObjectData; }
+    //inline const TMemSpyHeapObjectDataRHeap& ObjectData() const { return iObjectData; }
     //
     inline TMemSpyHeapStatisticsRHeap& Statistics() { return iStatistics; }
     inline const TMemSpyHeapStatisticsRHeap& Statistics() const { return iStatistics; }
 
+	inline TInt Overhead() const { return iMetaData.iHeapSize - iStatistics.StatsAllocated().TypeSize() - iStatistics.iCommittedFreeSpace; }
+
 private: // Data members
     TMemSpyHeapMetaDataRHeap iMetaData;
-    TMemSpyHeapObjectDataRHeap iObjectData;
+    //TMemSpyHeapObjectDataRHeap iObjectData;
     TMemSpyHeapStatisticsRHeap iStatistics;
     };
 
--- a/memspy/memspy_plat/memspy_api/include/memspy/driver/user/MemSpyDriverClient.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/driver/user/MemSpyDriverClient.h	Wed Sep 15 13:53:27 2010 +0300
@@ -157,6 +157,7 @@
      */
     IMPORT_C TInt GetHeapInfoUser( TMemSpyHeapInfo& aInfo, TUint aTid );
     IMPORT_C TInt GetHeapInfoUser( TMemSpyHeapInfo& aInfo, TUint aTid, RArray<TMemSpyDriverFreeCell>& aFreeCells );
+	IMPORT_C TInt GetHeapInfoUser(TMemSpyHeapInfo& aInfo, TUint aTid, RArray<TMemSpyDriverCell>& aCells, TBool aCollectAllocatedCellsAsWellAsFree);
 
     /**
      *
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperECom.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperECom.h	Wed Sep 15 13:53:27 2010 +0300
@@ -194,6 +194,7 @@
     inline const TDesC& Name() const { return *iName; }
     inline const TDesC& Caption() const { return *iCaption; }
     inline CMemSpyEngineEComInterface& Interface() const { return iInterface; }
+    inline CImplementationInformation& Info() const { return *iInfo; }
 
 public: // From MDesCArray
     IMPORT_C TInt MdcaCount() const;
@@ -212,4 +213,4 @@
 
 
 
-#endif
\ No newline at end of file
+#endif
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperFbServ.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperFbServ.h	Wed Sep 15 13:53:27 2010 +0300
@@ -74,7 +74,7 @@
     HBufC8* LocateBitmapArrayHeapCellDataLC( TAny*& aArrayCellAddress, TInt aArrayAllocCount );
     void ReadCObjectConInfoL( TAny* aCellAddress, RArray<TAny*>& aContainerObjects, TInt& aCount, TInt& aAllocated );
     static void ParseCellDataAndExtractHandlesL( const TDesC8& aData, RArray<TInt>& aHandles, TInt aArrayEntryCount );
-    static TBool VerifyCorrectHeapCellL( const TDesC8& aData, TAny* aCellAddress, TAny* aPayloadAddress, TUint aHeapStartingAddress, TUint aHeapSize );
+    static TBool VerifyCorrectHeapCellL( const TDesC8& aData, TAny* aCellAddress, TAny* aPayloadAddress, TUint aHeapStartingAddress, TUint aHeapMaxSize );
     static TUint OffsetToCObjectConBitmapCon();
     static TUint OffsetToCObjectConFontCon();
     static TUint OffsetToBitmapHandleArray();
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperHeap.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperHeap.h	Wed Sep 15 13:53:27 2010 +0300
@@ -26,6 +26,9 @@
 // Driver includes
 #include <memspy/driver/memspydriverobjectsshared.h>
 
+// MemSpyClient includes
+#include <memspy/engine/memspyheapdata.h>
+
 // Classes referenced
 class CMemSpyThread;
 class CMemSpyEngine;
@@ -44,7 +47,8 @@
     void ConstructL();
 
 public: // API - User Heap 
-    IMPORT_C void GetHeapInfoUserL( const TProcessId& aProcess, const TThreadId& aThread, TMemSpyHeapInfo& aInfo, RArray<TMemSpyDriverFreeCell>* aFreeCells = NULL );
+    IMPORT_C void GetHeapInfoUserL( const TProcessId& aProcess, const TThreadId& aThread, TMemSpyHeapInfo& aInfo, RArray<TMemSpyDriverCell>* aCells = NULL );
+	IMPORT_C void GetHeapInfoUserL(const TProcessId& aProcess, const TThreadId& aThread, TMemSpyHeapInfo& aInfo, RArray<TMemSpyDriverCell>* aCells, TBool aCollectAllocatedCellsAsWellAsFree);
     IMPORT_C void GetHeapInfoUserL( const CMemSpyProcess& aProcess, RArray<TMemSpyHeapInfo >& aInfos );
     IMPORT_C void OutputHeapInfoUserL( const CMemSpyThread& aThread );
     IMPORT_C void OutputHeapDataUserL( const CMemSpyThread& aThread );
@@ -57,10 +61,12 @@
     IMPORT_C void OutputHeapDataKernelL();
 
 public: // API - Common
-    IMPORT_C void OutputHeapInfoL( const TMemSpyHeapInfo& aInfo, const TDesC& aThreadName, const RArray<TMemSpyDriverFreeCell>* aFreeCells = NULL );
+    IMPORT_C void OutputHeapInfoL( const TMemSpyHeapInfo& aInfo, const TDesC& aThreadName, const RArray<TMemSpyDriverCell>* aCells = NULL );
     IMPORT_C void OutputHeapInfoForDeviceL( TBool aIncludeKernel = ETrue );
     IMPORT_C CMemSpyEngineOutputList* NewHeapSummaryShortLC( const TMemSpyHeapInfo& aInfo );
-    IMPORT_C CMemSpyEngineOutputList* NewHeapSummaryExtendedLC( const TMemSpyHeapInfo& aInfo, const RArray<TMemSpyDriverFreeCell>* aFreeCells = NULL );
+    IMPORT_C CMemSpyEngineOutputList* NewHeapSummaryExtendedLC( const TMemSpyHeapInfo& aInfo, const RArray<TMemSpyDriverCell>* aCells = NULL );
+    //cigasto    
+    IMPORT_C TMemSpyHeapData NewHeapRawInfo( const TMemSpyHeapInfo& aInfo ); //not formatted heap info
 
 public: // But not exported
     void OutputHeapDataKernelL( TBool aCreateDataStream );
@@ -70,9 +76,8 @@
 private:
     static TUint DescriptorAsDWORD( const TDesC8& aItem );
     void AppendMetaDataL( const TMemSpyHeapInfo& aInfo, CMemSpyEngineOutputList& aList );
-    void AppendObjectDataL( const TMemSpyHeapInfo& aInfo, CMemSpyEngineOutputList& aList );
     void AppendStatisticsL( const TMemSpyHeapInfo& aInfo, CMemSpyEngineOutputList& aList );
-    void AppendFreeCellsL( const RArray<TMemSpyDriverFreeCell>& aFreeCells, CMemSpyEngineOutputList& aList );
+	void AppendCellsL(const RArray<TMemSpyDriverCell>& aCells, CMemSpyEngineOutputList& aList);
     void OutputCSVEntryL( TInt aIndex, const TMemSpyHeapInfo& aInfo, const TDesC& aThreadName, const TDesC& aProcessName );
     void UpdateSharedHeapInfoL( const TProcessId& aProcess, const TThreadId& aThread, TMemSpyHeapInfo& aInfo );
 
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperKernelContainers.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/Helpers/MemSpyEngineHelperKernelContainers.h	Wed Sep 15 13:53:27 2010 +0300
@@ -87,6 +87,8 @@
     IMPORT_C static TPtrC TypeAsString( TMemSpyDriverContainerType aType );
     IMPORT_C TPtrC Name() const;
     IMPORT_C void OutputL( CMemSpyEngineOutputSink& aSink ) const;
+    IMPORT_C TInt Size() const;
+    IMPORT_C TInt ItemsCount() const;
 
 public: // But not exported
     TAny* HandleAt( TInt aIndex ) const;
@@ -137,4 +139,5 @@
 
 
 
-#endif
\ No newline at end of file
+#endif
+
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/MemSpyEngine.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/MemSpyEngine.h	Wed Sep 15 13:53:27 2010 +0300
@@ -60,6 +60,7 @@
     {
 public:
     IMPORT_C static CMemSpyEngine* NewL( RFs& aFsSession );
+    IMPORT_C static CMemSpyEngine* NewL( RFs& aFsSession, TBool aStartServer );
     IMPORT_C ~CMemSpyEngine();
 
 private:
@@ -80,6 +81,8 @@
     IMPORT_C CMemSpyEngineOutputSink& Sink();
     IMPORT_C TMemSpySinkType SinkType();
     IMPORT_C void InstallSinkL( TMemSpySinkType aType );
+    IMPORT_C void InstallDebugSinkL();
+    IMPORT_C void InstallFileSinkL( const TDesC& aRootFolder );
 
 public: // Misc
     IMPORT_C void ListOpenFilesL();
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/MemSpyEngineImp.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/MemSpyEngineImp.h	Wed Sep 15 13:53:27 2010 +0300
@@ -80,6 +80,7 @@
     CMemSpyEngineOutputSink& Sink();
     TMemSpySinkType SinkType();
     void InstallSinkL( TMemSpySinkType aType );
+    void InstallSinkL( TMemSpySinkType aType, const TDesC& aRootFolder );
 
 public: // Misc
     void ListOpenFilesL();
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/Sink/MemSpyEngineOutputSink.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/Sink/MemSpyEngineOutputSink.h	Wed Sep 15 13:53:27 2010 +0300
@@ -48,13 +48,16 @@
     IMPORT_C static CMemSpyEngineSinkMetaData* NewL();
     IMPORT_C static CMemSpyEngineSinkMetaData* NewL( const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseFileTimeStamp );
     IMPORT_C static CMemSpyEngineSinkMetaData* NewL( const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseFileTimeStamp, const TTime& aFolderTimeStamp );
+    IMPORT_C static CMemSpyEngineSinkMetaData* NewL( const TDesC& aRoot, const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseFileTimeStamp );
+    IMPORT_C static CMemSpyEngineSinkMetaData* NewL( const TDesC& aRoot, const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, TBool aOverwrite, TBool aUseFileTimeStamp, const TTime& aFolderTimeStamp );
     IMPORT_C ~CMemSpyEngineSinkMetaData();
 
 private:
     CMemSpyEngineSinkMetaData( TBool aOverwrite, TBool aUseTimeStamp );
-    void ConstructL( const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, const TTime& aFolderTime );
+    void ConstructL( const TDesC& aRoot, const TDesC& aContext, const TDesC& aFolder, const TDesC& aExtension, const TTime& aFolderTime );
 
 public: // Access
+    inline const TDesC& Root() const { return *iRoot; }
     inline const TDesC& Context() const { return *iContext; }
     inline const TDesC& Folder() const { return *iFolder; }
     inline const TDesC& Extension() const { return *iExtension; }
@@ -63,6 +66,7 @@
     inline const TBool UseFileTimeStamp() const { return iUseFileTimeStamp; }
 
 private: // Data members
+    HBufC* iRoot;
     HBufC* iContext;
     HBufC* iFolder;
     HBufC* iExtension;
@@ -146,4 +150,4 @@
 
 
 
-#endif
\ No newline at end of file
+#endif
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/SysMemTracker/MemSpyEngineHelperSysMemTracker.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/SysMemTracker/MemSpyEngineHelperSysMemTracker.h	Wed Sep 15 13:53:27 2010 +0300
@@ -58,9 +58,10 @@
     //
     IMPORT_C const RPointerArray< CMemSpyEngineHelperSysMemTrackerCycle >& CompletedCycles() const;
 
+    IMPORT_C void CheckForChangesNowL();
+
 public: // But not exported
     void Reset();
-    void CheckForChangesNowL();
 
 public: // From MDesCArray
     IMPORT_C TInt MdcaCount() const;
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/SysMemTracker/MemSpyEngineHelperSysMemTrackerConfig.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/SysMemTracker/MemSpyEngineHelperSysMemTrackerConfig.h	Wed Sep 15 13:53:27 2010 +0300
@@ -23,6 +23,7 @@
 
 // Constants
 const TInt KMemSpySysMemTrackerConfigMinTimerPeriod = 30; // Seconds
+const TInt KMemSpySysMemTrackerConfigMaxTimerPeriod = 60; // Seconds
 
 
 NONSHARABLE_CLASS( TMemSpyEngineHelperSysMemTrackerConfig )
@@ -90,4 +91,4 @@
     };
 
 
-#endif
\ No newline at end of file
+#endif
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/ThreadAndProcess/MemSpyEngineObjectProcess.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/ThreadAndProcess/MemSpyEngineObjectProcess.h	Wed Sep 15 13:53:27 2010 +0300
@@ -65,7 +65,11 @@
     IMPORT_C TBool IsDead() const;
     IMPORT_C TUint32 SID() const;
     IMPORT_C TUint32 VID() const;
-
+    IMPORT_C TProcessPriority Priority() const;
+    IMPORT_C TExitCategoryName ExitCategory() const;
+    IMPORT_C TInt ExitReason() const;
+    IMPORT_C TExitType ExitType() const;
+    
 public: // API - misc
     IMPORT_C void KillL();
     IMPORT_C void TerminateL();
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/ThreadAndProcess/MemSpyEngineObjectThread.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/ThreadAndProcess/MemSpyEngineObjectThread.h	Wed Sep 15 13:53:27 2010 +0300
@@ -56,6 +56,7 @@
     IMPORT_C TBool IsSystemPermanent() const;
     IMPORT_C TBool IsSystemCritical() const;
     IMPORT_C TBool IsDead() const;
+    IMPORT_C TThreadPriority Priority() const;
 
 public: // API - misc
     IMPORT_C void KillL();
@@ -105,4 +106,4 @@
 
 
 
-#endif
\ No newline at end of file
+#endif
--- a/memspy/memspy_plat/memspy_api/include/memspy/engine/ThreadAndProcess/MemSpyEngineObjectThreadInfoObjects.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/memspy_plat/memspy_api/include/memspy/engine/ThreadAndProcess/MemSpyEngineObjectThreadInfoObjects.h	Wed Sep 15 13:53:27 2010 +0300
@@ -98,6 +98,8 @@
 public: // From MDesCArray
     IMPORT_C TInt MdcaCount() const;
     IMPORT_C TPtrC MdcaPoint(TInt aIndex) const;
+    IMPORT_C TPtrC Caption(TInt aIndex ) const;
+    IMPORT_C TPtrC Value(TInt aIndex ) const;
 
 protected:
     class CItem : public CBase
@@ -504,7 +506,8 @@
 
 private: // Internal methods
     static TBool CompareEntries( const CSessionInfoEntry& aLeft, const CSessionInfoEntry& aRight );
-
+    TInt FindServerL( const TDesC& aName ) const;
+    
 private:
     RPointerArray<CSessionInfoEntry> iServerNames;
     };
--- a/memspy/rom/memspy.iby	Wed Sep 15 00:19:18 2010 +0300
+++ b/memspy/rom/memspy.iby	Wed Sep 15 13:53:27 2010 +0300
@@ -22,12 +22,17 @@
 file=ABI_DIR\BUILD_DIR\MemSpyDriverClient.dll									SHARED_LIB_DIR\MemSpyDriverClient.dll
 file=ABI_DIR\BUILD_DIR\MemSpyEngine.dll											SHARED_LIB_DIR\MemSpyEngine.dll
 
+// Client - server
+file=ABI_DIR\BUILD_DIR\MemSpyServer.exe											SHARED_LIB_DIR\MemSpyServer.exe
+file=ABI_DIR\BUILD_DIR\MemSpyClient.dll											SHARED_LIB_DIR\MemSpyClient.dll
+data=ZPRIVATE\\E5883BC2\MemSpyEComInterfaceIds.xml							    \private\E5883BC2\MemSpyEComInterfaceIds.xml
+
 // Commandline
 file=ABI_DIR\BUILD_DIR\MemSpy.exe									            SHARED_LIB_DIR\MemSpy.exe
 
 // Console UI
-file=ABI_DIR\BUILD_DIR\MemSpyConsole.exe										SHARED_LIB_DIR\MemSpyConsole.exe
-data=ZPRIVATE\\2002129E\MemSpyEComInterfaceIds.xml							    \private\2002129E\MemSpyEComInterfaceIds.xml
-data=ZPRIVATE\\2002129E\MemSpyProcessMemoryTrackingAutoStartConfig.xml		    \private\2002129E\MemSpyProcessMemoryTrackingAutoStartConfig.xml
+//file=ABI_DIR\BUILD_DIR\MemSpyConsole.exe										SHARED_LIB_DIR\MemSpyConsole.exe
+//data=ZPRIVATE\\2002129E\MemSpyEComInterfaceIds.xml							    \private\2002129E\MemSpyEComInterfaceIds.xml
+//data=ZPRIVATE\\2002129E\MemSpyProcessMemoryTrackingAutoStartConfig.xml		    \private\2002129E\MemSpyProcessMemoryTrackingAutoStartConfig.xml
 
 #endif
--- a/piprofiler/engine/inc/SamplerController.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/piprofiler/engine/inc/SamplerController.h	Wed Sep 15 13:53:27 2010 +0300
@@ -81,7 +81,7 @@
 
 	TInt GetPluginList(TDes* aList);
 	
-    TInt SetSamplerSettingsL(TInt aUid, TSamplerAttributes aAttributes);
+    TInt SetSamplerSettingsL(TInt aUid, TSamplerAttributes& aAttributes);
 
     void GetSamplerAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributes);
 	
--- a/piprofiler/engine/src/ProfilerEshell.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/piprofiler/engine/src/ProfilerEshell.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -35,7 +35,7 @@
 static void PrintUsageInfo(const TDesC& aAdditionalInfo)
     {
     _LIT(KConsoleName, "Console");
-    _LIT(KLegalNote, "PIProfiler Version 2.2.0.2 Copyright @ 2009 Nokia\n");
+    _LIT(KLegalNote, "PIProfiler Version 2.2.2 Copyright @ 2009 Nokia\n");
     _LIT(KUsageNote, "Usage: PIProfiler [start/end/timed] settingsfile [time to run]\n");
     _LIT(KExample, "Example: PIProfiler timed C:\\data\\piprofilersettings.txt 60\n");
 
--- a/piprofiler/engine/src/SamplerController.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/piprofiler/engine/src/SamplerController.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -129,7 +129,7 @@
     return err;
     }
 
-TInt CSamplerController::SetSamplerSettingsL(TInt aUid, TSamplerAttributes aAttributes)
+TInt CSamplerController::SetSamplerSettingsL(TInt aUid, TSamplerAttributes& aAttributes)
     {
     // parse right plugin based on UID
     CSamplerPluginInterface* plugin = GetPlugin(TUid::Uid(aUid));
Binary file piprofiler/group/ReleaseNotes_PIProfiler.txt has changed
--- a/piprofiler/piprofiler_plat/inc/SamplerPluginInterface.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/piprofiler/piprofiler_plat/inc/SamplerPluginInterface.h	Wed Sep 15 13:53:27 2010 +0300
@@ -174,7 +174,7 @@
     * Method for setting configurations of single sampler attributes
     * @param aAttributes contains settings of a single sampler plugin 
     */
-    virtual TInt SetAttributesL(TSamplerAttributes aAttributes) = 0; 
+    virtual TInt SetAttributesL(TSamplerAttributes& aAttributes) = 0; 
     
     /**
     * Method for parsing text formatted settings block and converting
--- a/piprofiler/plugins/BUPplugin/inc/BupPlugin.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/piprofiler/plugins/BUPplugin/inc/BupPlugin.h	Wed Sep 15 13:53:27 2010 +0300
@@ -84,7 +84,7 @@
     TInt    GetSamplerType();
 	
 	void    GetAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributes);
-    TInt    SetAttributesL(TSamplerAttributes aAttributes);
+    TInt    SetAttributesL(TSamplerAttributes& aAttributes);
     void    InitiateSamplerAttributesL();
 	
     TInt    ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aSingleSettingArray);
--- a/piprofiler/plugins/BUPplugin/src/BupPlugin.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/piprofiler/plugins/BUPplugin/src/BupPlugin.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -116,7 +116,7 @@
     aAttributes->AppendL(iSamplerAttributes->At(0));
     }
 
-TInt CBupPlugin::SetAttributesL(TSamplerAttributes aAttributes)
+TInt CBupPlugin::SetAttributesL(TSamplerAttributes& aAttributes)
     {
     TSamplerAttributes attr;
 
--- a/piprofiler/plugins/GeneralsPlugin/inc/GeneralsPlugin.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/piprofiler/plugins/GeneralsPlugin/inc/GeneralsPlugin.h	Wed Sep 15 13:53:27 2010 +0300
@@ -110,7 +110,7 @@
 	TInt 	SubId( TUid aSubId ) const;	// internal
 
 	void    GetAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributes);
-	TInt    SetAttributesL(TSamplerAttributes aAttributes);
+	TInt    SetAttributesL(TSamplerAttributes& aAttributes);
 	void    InitiateSamplerAttributesL();
 	
 	TInt    ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aSingleSettingArray);
--- a/piprofiler/plugins/GeneralsPlugin/src/GeneralsPlugin.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/piprofiler/plugins/GeneralsPlugin/src/GeneralsPlugin.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -275,7 +275,7 @@
         }
     }
 
-TInt CGeneralsPlugin::SetAttributesL(TSamplerAttributes aAttributes)
+TInt CGeneralsPlugin::SetAttributesL(TSamplerAttributes& aAttributes)
     {
     TSamplerAttributes attr;
 
--- a/piprofiler/plugins/GeneralsPlugin/src/MemSamplerImpl.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/piprofiler/plugins/GeneralsPlugin/src/MemSamplerImpl.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -339,7 +339,6 @@
             // this chunk has not been tagged yet
             name.Zero();
             c->TraceAppendName(name,false);
-            const TUint8* ptr = name.Ptr();
             
             TAG(c) = (PROFILER_CHUNK_MARK);
             this->heapChunkNamesToReport[iNewChunkCount] = c;
@@ -463,7 +462,6 @@
             // this library has not been tagged yet
             name.Zero();
             l->TraceAppendName(name,false);
-            const TUint8* ptr = name.Ptr();
             
             TAG(l) = (PROFILER_LIBRARY_MARK);
             this->libraryNamesToReport[iNewLibraryCount] = l;
--- a/piprofiler/plugins/PWRplugin/inc/PwrPlugin.h	Wed Sep 15 00:19:18 2010 +0300
+++ b/piprofiler/plugins/PWRplugin/inc/PwrPlugin.h	Wed Sep 15 13:53:27 2010 +0300
@@ -74,7 +74,7 @@
     TInt    CreateFirstSample();
 
     void    GetAttributesL(CArrayFixFlat<TSamplerAttributes>* aAttributes);
-    TInt    SetAttributesL(TSamplerAttributes aAttributes);
+    TInt    SetAttributesL(TSamplerAttributes& aAttributes);
     void    InitiateSamplerAttributesL();
 
     TInt    ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aSingleSettingArray);
@@ -108,9 +108,9 @@
 };
 
 #ifdef PWR_SAMPLER_BACKLIGHT
-class CProfilerPowerListener : public MHWRMBatteryPowerObserver, public MHWRMLightObserver
+class CProfilerPowerListener : public CBase, public MHWRMBatteryPowerObserver, public MHWRMLightObserver
 #else
-class CProfilerPowerListener : public MHWRMBatteryPowerObserver
+class CProfilerPowerListener : public CBase, public MHWRMBatteryPowerObserver
 #endif
 {
 public:
--- a/piprofiler/plugins/PWRplugin/src/PwrPlugin.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/piprofiler/plugins/PWRplugin/src/PwrPlugin.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -133,7 +133,7 @@
     aAttributes->AppendL(iSamplerAttributes->At(0));
     }
 
-TInt CPwrPlugin::SetAttributesL(TSamplerAttributes aAttributes)
+TInt CPwrPlugin::SetAttributesL(TSamplerAttributes& aAttributes)
     {
     TSamplerAttributes attr;