Add initial version of AnalyzeTool client under EPL
authorMatti Laitinen <matti.t.laitinen@nokia.com>
Thu, 11 Feb 2010 15:51:35 +0200
changeset 0 f0f2b8682603
child 1 3ff3fecb12fe
Add initial version of AnalyzeTool client under EPL
memana/analyzetoolclient/commandlineengine/install/addr2line.exe
memana/analyzetoolclient/commandlineengine/install/atool.exe
memana/analyzetoolclient/commandlineengine/install/binutils-2.19.1-src.zip
memana/analyzetoolclient/commandlineengine/install/xerces-c_2_7.dll
memana/analyzetoolclient/commandlineengine/internal/group/atool.vcproj
memana/analyzetoolclient/commandlineengine/internal/inc/ATCommonDefines.h
memana/analyzetoolclient/commandlineengine/internal/inc/CATBase.h
memana/analyzetoolclient/commandlineengine/internal/inc/CATDatParser.h
memana/analyzetoolclient/commandlineengine/internal/inc/CATDataSaver.h
memana/analyzetoolclient/commandlineengine/internal/inc/CATMemoryAddress.h
memana/analyzetoolclient/commandlineengine/internal/inc/CATMmp.h
memana/analyzetoolclient/commandlineengine/internal/inc/CATModule2.h
memana/analyzetoolclient/commandlineengine/internal/inc/CATParseTraceFile.h
memana/analyzetoolclient/commandlineengine/internal/inc/CATParseXML.h
memana/analyzetoolclient/commandlineengine/internal/inc/CATProject.h
memana/analyzetoolclient/commandlineengine/internal/inc/cataddr2line.h
memana/analyzetoolclient/commandlineengine/internal/inc/cataddr2lineserver.h
memana/analyzetoolclient/commandlineengine/internal/inc/catalloc.h
memana/analyzetoolclient/commandlineengine/internal/inc/catallocs.h
memana/analyzetoolclient/commandlineengine/internal/inc/catdbghelper.h
memana/analyzetoolclient/commandlineengine/internal/inc/catfilereader.h
memana/analyzetoolclient/commandlineengine/internal/inc/catromsymbol.h
memana/analyzetoolclient/commandlineengine/internal/inc/iaddresstoline.h
memana/analyzetoolclient/commandlineengine/internal/inc/stdafx.h
memana/analyzetoolclient/commandlineengine/internal/lib/xerces-c_2.lib
memana/analyzetoolclient/commandlineengine/internal/src/CATBase.cpp
memana/analyzetoolclient/commandlineengine/internal/src/CATDatParser.cpp
memana/analyzetoolclient/commandlineengine/internal/src/CATDataSaver.cpp
memana/analyzetoolclient/commandlineengine/internal/src/CATMemoryAddress.cpp
memana/analyzetoolclient/commandlineengine/internal/src/CATMmp.cpp
memana/analyzetoolclient/commandlineengine/internal/src/CATModule2.cpp
memana/analyzetoolclient/commandlineengine/internal/src/CATParseTraceFile.cpp
memana/analyzetoolclient/commandlineengine/internal/src/CATParseXML.cpp
memana/analyzetoolclient/commandlineengine/internal/src/CATProject.cpp
memana/analyzetoolclient/commandlineengine/internal/src/arguments.cpp
memana/analyzetoolclient/commandlineengine/internal/src/atool.cpp
memana/analyzetoolclient/commandlineengine/internal/src/cataddr2line.cpp
memana/analyzetoolclient/commandlineengine/internal/src/cataddr2lineserver.cpp
memana/analyzetoolclient/commandlineengine/internal/src/catalloc.cpp
memana/analyzetoolclient/commandlineengine/internal/src/catallocs.cpp
memana/analyzetoolclient/commandlineengine/internal/src/catdbghelper.cpp
memana/analyzetoolclient/commandlineengine/internal/src/catfilereader.cpp
memana/analyzetoolclient/commandlineengine/internal/src/catromsymbol.cpp
memana/analyzetoolclient/commandlineengine/internal/src/helps.cpp
memana/analyzetoolclient/commandlineengine/internal/src/librarychecks.cpp
memana/analyzetoolclient/commandlineengine/internal/src/stdafx.cpp
memana/analyzetoolclient/commandlineengine/internal/src/utility.cpp
memana/analyzetoolclient/commandlineengine/internal/src/version.cpp
memana/analyzetoolclient/configurationappgui/data/atconfigurationappgui.l01
memana/analyzetoolclient/configurationappgui/data/atconfigurationappgui.loc.hrh
memana/analyzetoolclient/configurationappgui/data/atconfigurationappgui.rss
memana/analyzetoolclient/configurationappgui/data/atconfigurationappgui_reg.rss
memana/analyzetoolclient/configurationappgui/data/atconfigurationappguilistbox.rssi
memana/analyzetoolclient/configurationappgui/data/atconfigurationappguiprocesscontainer.rssi
memana/analyzetoolclient/configurationappgui/data/atconfigurationappguisettingitemlist.rssi
memana/analyzetoolclient/configurationappgui/group/atconfigurationappgui.mmp
memana/analyzetoolclient/configurationappgui/group/atool_aif_icons.mk
memana/analyzetoolclient/configurationappgui/group/bld.inf
memana/analyzetoolclient/configurationappgui/icons/qgn_menu_atconfigurationappgui.svg
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappgui.hrh
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappgui.pan
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguiapplication.h
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguiappui.h
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguidocument.h
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguilistbox.h
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguilistbox.hrh
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguilistboxview.h
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguiprocesscontainer.h
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguiprocesscontainer.hrh
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguiprocessview.h
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguisettingitemlist.h
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguisettingitemlist.hrh
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguisettingitemlistsettings.h
memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguisettingitemlistview.h
memana/analyzetoolclient/configurationappgui/sis/atconfigurationappgui.pkg
memana/analyzetoolclient/configurationappgui/sis/backup_registration.xml
memana/analyzetoolclient/configurationappgui/src/atconfigurationappguiapplication.cpp
memana/analyzetoolclient/configurationappgui/src/atconfigurationappguiappui.cpp
memana/analyzetoolclient/configurationappgui/src/atconfigurationappguidocument.cpp
memana/analyzetoolclient/configurationappgui/src/atconfigurationappguilistbox.cpp
memana/analyzetoolclient/configurationappgui/src/atconfigurationappguilistboxview.cpp
memana/analyzetoolclient/configurationappgui/src/atconfigurationappguiprocesscontainer.cpp
memana/analyzetoolclient/configurationappgui/src/atconfigurationappguiprocessview.cpp
memana/analyzetoolclient/configurationappgui/src/atconfigurationappguisettingitemlist.cpp
memana/analyzetoolclient/configurationappgui/src/atconfigurationappguisettingitemlistsettings.cpp
memana/analyzetoolclient/configurationappgui/src/atconfigurationappguisettingitemlistview.cpp
memana/analyzetoolclient/consoleui/group/atconsoleui.mmp
memana/analyzetoolclient/consoleui/group/bld.inf
memana/analyzetoolclient/consoleui/inc/atconsoleui.h
memana/analyzetoolclient/consoleui/inc/atconsoleviews.h
memana/analyzetoolclient/consoleui/src/atconsoleui.cpp
memana/analyzetoolclient/consoleui/src/atconsoleviews.cpp
memana/analyzetoolclient/doc/S60_Analyze_Tool_Users_Guide.pdf
memana/analyzetoolclient/dynamicmemoryhook/bwins/atoolmemoryhooku.def
memana/analyzetoolclient/dynamicmemoryhook/eabi/atoolmemoryhooku.def
memana/analyzetoolclient/dynamicmemoryhook/group/atoolmemoryhook.mmp
memana/analyzetoolclient/dynamicmemoryhook/group/bld.inf
memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolallocator.h
memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetooleventhandler.h
memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetooleventhandlernotifier.h
memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolfastlog.h
memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolmainallocator.h
memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolmainallocator.inl
memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolmemoryallocator.h
memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolmemoryallocator.inl
memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolpanics.pan
memana/analyzetoolclient/dynamicmemoryhook/inc/codeblock.h
memana/analyzetoolclient/dynamicmemoryhook/inc/customuser.h
memana/analyzetoolclient/dynamicmemoryhook/inc/threadstack.h
memana/analyzetoolclient/dynamicmemoryhook/sis/analyzetoolmemoryhook.pkg
memana/analyzetoolclient/dynamicmemoryhook/src/analyzetoolallocator.cpp
memana/analyzetoolclient/dynamicmemoryhook/src/analyzetooleventhandler.cpp
memana/analyzetoolclient/dynamicmemoryhook/src/analyzetoolfastlog.cpp
memana/analyzetoolclient/dynamicmemoryhook/src/analyzetoolmainallocator.cpp
memana/analyzetoolclient/dynamicmemoryhook/src/analyzetoolmemoryallocator.cpp
memana/analyzetoolclient/dynamicmemoryhook/src/codeblock.cpp
memana/analyzetoolclient/dynamicmemoryhook/src/customuser.cpp
memana/analyzetoolclient/dynamicmemoryhook/src/threadstack.cpp
memana/analyzetoolclient/group/ReleaseNotes_AnalyzeTool.txt
memana/analyzetoolclient/group/atool_stub_sis.mk
memana/analyzetoolclient/group/bld.inf
memana/analyzetoolclient/inc/atlog.h
memana/analyzetoolclient/kerneleventhandler/group/atoolkerneleventhandler.mmp
memana/analyzetoolclient/kerneleventhandler/group/bld.inf
memana/analyzetoolclient/kerneleventhandler/inc/analyzetool.h
memana/analyzetoolclient/kerneleventhandler/inc/analyzetool.inl
memana/analyzetoolclient/kerneleventhandler/inc/analyzetoolchannel.h
memana/analyzetoolclient/kerneleventhandler/inc/analyzetooldevice.h
memana/analyzetoolclient/kerneleventhandler/inc/analyzetooleventhandler.h
memana/analyzetoolclient/kerneleventhandler/inc/analyzetooltraceconstants.h
memana/analyzetoolclient/kerneleventhandler/inc/atcommon.h
memana/analyzetoolclient/kerneleventhandler/sis/analyzetooldevicedriver.pkg
memana/analyzetoolclient/kerneleventhandler/src/analyzetoolchannel.cpp
memana/analyzetoolclient/kerneleventhandler/src/analyzetooldevice.cpp
memana/analyzetoolclient/kerneleventhandler/src/analyzetooleventhandler.cpp
memana/analyzetoolclient/rom/analyzetool.iby
memana/analyzetoolclient/rom/analyzetool_rom.iby
memana/analyzetoolclient/sis/AnalyzeTool.pkg
memana/analyzetoolclient/sis/AnalyzeTool_udeb.pkg
memana/analyzetoolclient/sis/AnalyzeTool_udeb_s60-mcl.sis
memana/analyzetoolclient/sis/AnalyzeTool_urel_s60-mcl.sis
memana/analyzetoolclient/sis/analyzeTool_stub.pkg
memana/analyzetoolclient/staticlib/group/atoolstaticlib.mmp
memana/analyzetoolclient/staticlib/group/bld.inf
memana/analyzetoolclient/staticlib/src/atoolstaticlib.cpp
memana/analyzetoolclient/storageserver/client/bwins/atoolstorageserverclntu.def
memana/analyzetoolclient/storageserver/client/eabi/atoolstorageserverclntu.def
memana/analyzetoolclient/storageserver/client/group/atoolstorageserverclnt.mmp
memana/analyzetoolclient/storageserver/client/inc/atstorageserverclnt.h
memana/analyzetoolclient/storageserver/client/src/atstorageserverclnt.cpp
memana/analyzetoolclient/storageserver/group/bld.inf
memana/analyzetoolclient/storageserver/inc/atstorageservercommon.h
memana/analyzetoolclient/storageserver/server/group/atoolstorageserver.mmp
memana/analyzetoolclient/storageserver/server/inc/atdllinfo.h
memana/analyzetoolclient/storageserver/server/inc/atdriveinfo.h
memana/analyzetoolclient/storageserver/server/inc/atdynprocessinfo.h
memana/analyzetoolclient/storageserver/server/inc/atmemoryentry.h
memana/analyzetoolclient/storageserver/server/inc/atstorageserver.h
memana/analyzetoolclient/storageserver/server/inc/atstorageserversession.h
memana/analyzetoolclient/storageserver/server/src/atdllinfo.cpp
memana/analyzetoolclient/storageserver/server/src/atdriveinfo.cpp
memana/analyzetoolclient/storageserver/server/src/atdynprocessinfo.cpp
memana/analyzetoolclient/storageserver/server/src/atmemoryentry.cpp
memana/analyzetoolclient/storageserver/server/src/atstorageserver.cpp
memana/analyzetoolclient/storageserver/server/src/atstorageserversession.cpp
memana/analyzetoolclient/storageserver/sis/atstorageserver.pkg
memana/analyzetoolclient/storageserver/sis/atstorageserver_udeb.pkg
memana/analyzetoolclient/symbian_version.hrh
Binary file memana/analyzetoolclient/commandlineengine/install/addr2line.exe has changed
Binary file memana/analyzetoolclient/commandlineengine/install/atool.exe has changed
Binary file memana/analyzetoolclient/commandlineengine/install/binutils-2.19.1-src.zip has changed
Binary file memana/analyzetoolclient/commandlineengine/install/xerces-c_2_7.dll has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/group/atool.vcproj	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,375 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="atool"
+	ProjectGUID="{2C50DD86-958B-4189-8DA2-DB388C71F65F}"
+	RootNamespace="atool"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				TreatWChar_tAsBuiltInType="false"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderThrough="..\inc\stdafx.h"
+				WarningLevel="4"
+				Detect64BitPortabilityProblems="false"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="..\lib\xerces-c_2.lib ..\lib\dbghelp.lib"
+				OutputFile="..\..\install\atool.exe"
+				LinkIncremental="2"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile="$(OutDir)/atool.pdb"
+				SubSystem="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="..\"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				RuntimeLibrary="0"
+				TreatWChar_tAsBuiltInType="false"
+				UsePrecompiledHeader="0"
+				WarningLevel="4"
+				Detect64BitPortabilityProblems="false"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="..\lib\xerces-c_2.lib ..\lib\dbghelp.lib"
+				OutputFile="..\..\install\atool.exe"
+				LinkIncremental="1"
+				GenerateDebugInformation="true"
+				SubSystem="1"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\src\arguments.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\atool.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\cataddr2line.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\cataddr2lineserver.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\catalloc.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\catallocs.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\CATBase.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\CATDataSaver.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\CATDatParser.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\catdbghelper.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\catfilereader.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\CATMemoryAddress.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\CATMmp.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\CATModule2.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\CATParseTraceFile.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\CATParseXML.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\CATProject.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\catromsymbol.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\helps.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\librarychecks.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\stdafx.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\utility.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\src\version.cpp"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\inc\ATCommonDefines.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\cataddr2line.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\cataddr2lineserver.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\catalloc.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\catallocs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\CATBase.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\CATDataSaver.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\CATDatParser.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\catdbghelper.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\catfilereader.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\CATMemoryAddress.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\CATMmp.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\CATModule2.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\CATParseTraceFile.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\CATParseXML.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\CATProject.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\catromsymbol.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\iaddresstoline.h"
+				>
+			</File>
+			<File
+				RelativePath="..\inc\stdafx.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+		<File
+			RelativePath=".\ReadMe.txt"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/ATCommonDefines.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,563 @@
+/*
+* 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 defines for cpp files.
+*
+*/
+
+
+#ifndef __ATCOMMONDEFINES_H__
+#define __ATCOMMONDEFINES_H__
+
+#include "../inc/stdafx.h"
+
+using namespace std;
+
+// CLI return codes.
+// Note! Do not change the values. Used in extension.
+struct AT_RETURN_CODE {
+	enum RETURN_CODE {
+		/* basic */
+		OK = 0,							/* All ok. */
+		INVALID_ARGUMENT_ERROR = 1,		/* Arguments failty. */
+		AT_LIBS_MISSING = 2,			/* Missing at libraries cannot compile hooked apps. */
+		CANNOT_FIND_EPOCROOT = 3,		/* Epocroot not set. */
+		UNHANDLED_EXCEPTION = 4,		/* General return code when unhandled exception occurs. */
+		/* compile errors */
+		MAKEFILE_ERROR = 5,				/* Cannot read/create etc makefiles sbs1/2. */
+		COMPILE_ERROR = 6,				/* Some error related to compilation of code. */
+		UNKNOWN = 7,					/* General compilation error not specific. */
+		NO_SUPPORTED_MODULES_ERROR = 8,	/* Cannot find supported modules from project. */
+		KERNEL_SIDE_MODULE_ERROR = 9,	/* Cannot find supported modules from project because kernel side. */
+		/* Analyze errors */
+		WRONG_DATA_FILE_VERSION = 10,	/* Invalid data file version in internal gathering mode. */
+		INVALID_DATA_FILE = 11,			/* Data file content invalid. */
+		ANALYZE_ERROR = 12,				/* General error in analyze part not specific. */
+		EMPTY_DATA_FILE = 13,			/* Data file is empty. */
+		SYMBOL_FILE_ERROR = 14,			/* Symbol file content invalid or do not exist. */
+		/* building&releasing errors */
+		RELEASABLES_ERROR = 20,			/* Cannot find the binaries of module. */
+		RESTORE_MODULES_ERROR = 21,		/* Error restoring mmp file to original. */
+		CREATING_TEMP_CPP_ERROR = 22,	/* Error creating temporary cpps to store variables to s60 core.*/
+		CLEANING_TEMP_ERROR = 23,		/* Error cleaning atool_temp folder from module. */
+		READ_MAKEFILE_ERROR = 24,		/* Some error when reading makefile of module / project (sbs1/2). */
+		MODIFY_MODULES_ERROR = 25,		/* Error modifying module mmp file. */
+		INVALID_MMP_DEFINED = 27,		/* Specified module does not exist in project. */
+		/* Attribute file related */
+		WRITE_ATTRIBUTES_ERROR = 30,	/* Error writing the cfg file into atool_temp folder (contains arguments).*/
+		READ_ATTRIBUTES_ERROR = 31,		/* Error reading hooking related arguments from cfg file. */
+		/* User issued exit */
+		USER_ISSUED_EXIT = 40,			/* User aborted the run of application. */
+		/* HTI */
+		HTI_NO_CONNECTION = 50,			/* No hti connection defined */
+		HTI_NO_AT_FOLDER = 51,			/* Cannot find analyzetool folder from device. */
+		HTI_NO_FILE_DEFINED = 52		/* No file defined to be fetched. */
+	};
+};
+
+// Debug logging to console
+extern bool g_bDebugConsole;
+// Debug logging to windows api debug
+extern bool g_bDebugDbgView;
+// Debug (low level functions).
+extern bool g_bDebugLowLevel;
+
+// Temporary directory definition's.
+const char AT_TEMP_DIR[] = "atool_temp";
+const char AT_TEMP_LST_DIR[] = "atool_temp\\static_lsts\\";
+
+// makefile dir is used in atool.cpp to check will we use sbs2 (in analyze and clear)
+#define RAPTOR_MAKEFILE_DIR "atool_temp\\build"
+
+// Atool version number and date
+#define ATOOL_VERSION "1.8.0" // NOTE! This version number is written also to temporary cpp file.
+#define ATOOL_DATE "1st December 2009"
+
+// Default/min/max call stack sizes
+const int AT_ALLOC_CALL_STACK_SIZE_DEFAULT = 40;
+const int AT_FREE_CALL_STACK_SIZE_DEFAULT = 0;
+const int AT_CALL_STACK_SIZE_MIN = 0;
+const int AT_CALL_STACK_SIZE_MAX = 256;
+
+// What version of data file contains timestamps in dll's.
+const int AT_DLL_TIMESTAMP_DATA_VERSION = 2;
+
+// Constant compatibility string in temporary cpp.
+// Api version ; current version.
+#define ATOOL_COMPATIBILITY_STRING "1.7.4;1.8.0"
+
+// Datafile version
+#define AT_DATA_FILE_VERSION "DATA_FILE_VERSION 11"
+
+// Build summary constants
+const string AT_BUILD_SUMMARY_HEADER = "\n###  AnalyzeTool  ###\n### Build Summary ###\n\n";
+const string AT_BUILD_SUMMARY_INSTRUMENTED_BUILD_COMPLETE = "Instrumented build complete: ";
+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_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.";
+const string AT_BUILD_SUMMARY_UNSUPPORTED_COMPILE_DEFINITION = "\tModule defined unsupported compile definition.";
+const string AT_BUILD_SUMMARY_BUILD_TYPE = "Build type: ";
+const string AT_BUILD_SUMMARY_BUILD_TARGET = "Build target: ";
+const string AT_BUILD_SUMMARY_BUILD_PLATFORM = "Build platform: ";
+const string AT_BUILD_SUMMARY_BUILD_VARIANT = "Build variant: ";
+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_S60 = "monitored internal";
+const string AT_BUILD_SUMMARY_XTI = "monitored external";
+const string AT_BUILD_SUMMARY_XTI_FAST = "external";
+
+const string AT_UNSUPPORTED_TARGET_TYPE = "\tModule has unsupported target type.";
+const string AT_UNSUPPORTED_COMPILE_DEFINITION = "\tModule defined unsupported compile definition.";
+
+// List of locations under epocroot where analyzetool.h can be found.
+// Add all possible to this list so core version information can be read
+// from file.
+const string AT_CORE_INCLUDE_FILE_WITH_VERSION_NUMBER[] = {
+	"epoc32\\include\\domain\\osextensions\\analyzetool\\analyzetool.h",
+	"epoc32\\include\\oem\\analyzetool\\analyzetool.h",
+	"epoc32\\include\\platform\\analyzetool\\analyzetool.h"
+};
+const string AT_CORE_VERSION_NUMBER_TAG = "ANALYZETOOL_CORE_VERSION_FOR_CLE";
+
+// Temporary cpp name
+const char AT_TEMP_CPP_LOWER_START[] = "0a1b2c3d_atool_temp_";
+const char AT_TEMP_CPP_LOWER_END[] = ".cpp";
+
+const char TAB_CHAR_VALUE = 9;
+const char SPACE_CHAR_VALUE = 32;
+
+// Bldmake error msg
+#define AT_BLDMAKE_ERROR "AnalyzeTool : bldmake bldfiles error.\n"
+
+// File copy/move/etc... message definitions
+#define AT_MSG "AnalyzeTool : "
+#define AT_MSG_SYSTEM_CALL "AnalyzeTool : System call, "
+#define AT_FILE_TO " to "
+
+// -c messages
+#define AT_CLEANING_DONE "AnalyzeTool : Cleaning done."
+#define AT_CLEANING_NOTHING_FOUND "AnalyzeTool : Nothing found to clean."
+
+// Analyzing data without process start or dll load
+#define AT_ANALYZE_INSUFFICIENT_LOGGING_DATA "Insufficient logging data to locate code lines for memory addresses.\nLogging has been started after process start."
+#define AT_ANALYZE_NO_PROCESS_START "AnalyzeTool : No processes start information found in test run data."
+#define AT_ANALYZE_NO_DLL_LOAD "AnalyzeTool : No dll load information found in test run data."
+#define AT_ANALYZE_CANNOT_PINPOINT "AnalyzeTool : Memory addresses cannot be pinpointed."
+#define AT_ANALYZE_ABNORMAL_EXIT "Abnormal process end"
+
+// Analyzing without map / lst files
+#define AT_ANALYZE_MISSING_LST_MAP_FILES "AnalyzeTool : Missing lst or map files, memory addresses shown only to module level.\n"
+//#define AT_UNINSTRUMENT_FAILED_IN_ANALYZE_MESSAGE "AnalyzeTool: Error creating map/lst files, leaks shown only to module level.\nRun atool -u to try create lst/map files again after binaries build successfully.\n"
+
+// Mmp error msg
+#define INVALID_MMP_ERROR "AnalyzeTool : Error, Specified mmp is invalid.\n"
+
+// Make error msg
+#define MAKE_ERROR "AnalyzeTool : Error, Running make.\n"
+
+#define AT_NOT_BEEN_BUILD_ERROR "AnalyzeTool : Error, project has not been build using AnalyzeTool.\n"
+
+// Makefile errors
+#define LEVEL1_MAKEFILE_ERROR "AnalyzeTool : Error, reading level 1 makefile.\n"
+#define LEVEL2_MAKEFILE_ERROR "AnalyzeTool : Error, reading level 2 makefile.\n"
+#define MAKEFILE_ERROR_TIP "AnalyzeTool : Tip, your environment might require you to use -variant [target] argument.\n";
+
+//Variant messages
+#define INVALID_VARIANT_ERROR "AnalyzeTool : Error,Specified variant is invalid.\n"
+#define USING_DEFAULT_VARIANT_MESSAGE "AnalyzeTool : Note, Using DEFAULT variant.\n"
+#define NO_DEFAULT_VARIANT_ERROR "AnalyzeTool : Error, environment does not specify DEFAULT variant (No variant support?).\n"
+
+// Variant dir is the dir where all variants are defined
+#define VARIANT_DIR "\\epoc32\\tools\\variant\\"
+
+// Variants defined extension name of the variant must equal filename
+#define VARIANT_FILE_EXTENSION ".VAR"
+
+//Max file name length
+const int MAX_FILENAME_LENGTH = 1024;
+
+//Max line length when reading lines from text file.2048 should be enought.
+const int MAX_LINE_LENGTH = 2048*8;
+
+// ATs project file name to store project attributes
+#define AT_PROJECT_ATTRIBUTES_FILE_NAME "project.cfg"
+const string AT_PROJECT_ATTRIBUTES_SEPARATOR( ":$:" );
+
+// ATs level1 makefile name
+#define AT_LEVEL_1_MAKEFILE_NAME "main.at"
+
+// ATs level2 makefiles extension
+#define AT_LEVEL_2_MAKEFILE_EXT "atm"
+
+//Default logging level
+const int DEFAULT_LOGGING_LEVEL = 3;
+
+//Minimun value of logging level 
+const int MIN_LOGGING_LEVEL = 0;
+
+//Maximun value of logging level
+const int MAX_LOGGING_LEVEL = 3;
+
+//Const char represeting dash
+const char DASH = '\\';
+
+/* Table of file extension not to delete
+ * from atools temp directory when compiling
+ * note define all in lowercase
+ */
+const string TEMP_EXTENSION_NO_DELETE[] = {
+	"xml",
+	"dat",
+	"tmp",
+	"cpp",
+	"at",
+	"atm",
+	"cfg"
+};
+
+// Allowed characters/digits, other than these will be filtered out when using CATBase FilterString
+const char CFILTERSTRING[] = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
+
+/* Table of unsupported target types
+ * (i.e. mmp file syntax targettype in makefile)
+ * List of target types which will not be hooked:
+*/
+const string UNSUPPORTED_TARGET_TYPES[] = {
+	"CTL",
+	"ECOMIIC",
+	"IMPLIB",
+	"KDLL",
+	"KEXT",
+	"KLIB",
+	"LDD",
+	/* "LIB",  currently have own vector in project.*/
+	"MDA",
+	"MDL",
+	"NONE",
+	"NOTIFIER",
+	"PDD",
+	"RDL",
+	"STDLIB",
+	"VAR"
+};
+
+/**
+* Kernel side target types
+*/
+const string KERNEL_SIDE_TARGET_TYPES[] = {
+	"VAR",
+	"LDD",
+	"PDD",
+	"KEXT"
+};
+
+// Kernel mode compile definition
+const string KERNEL_MODE_COMPILE_DEFINITION = "__KERNEL_MODE__";
+
+/**
+* MMP file changes for AT
+* Note "SOURCE            0a1b2c3d_atool_temp_TARGET.cpp" is added also.
+*/
+const string MMPFILECHANGES[] = {
+	"//*** AnalyzeTool changes start ***",
+	"SOURCEPATH        atool_temp",
+	"LIBRARY           AToolMemoryHook.lib",
+	"STATICLIBRARY     AToolStaticLib.lib",
+	"OPTION ARMCC --interleave",
+	"//*** AnalyzeTool changes end ***"
+};
+
+//MMP file changes for AT
+//For targettype Dll
+const string MMPFILECHANGES_DLL[] = {
+	"//*** AnalyzeTool changes start ***",
+	"OPTION ARMCC --interleave",
+	"//*** AnalyzeTool changes end ***"
+};
+
+// 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_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_LOGGING_CANCELLED "LOGGING_CANCELLED"
+
+// AddressToLine related constants
+
+#define LABEL_ABNORMAL "ABNORMAL"
+const int FUNCTIONS_OFFSET_IN_MAP_FILE_ARMV5 = 0x8000;
+const int FUNCTIONS_OFFSET_IN_GCCE = 0x8000;
+const int FUNCTIONS_OFFSET_IN_MAP_FILE_WINSCW = 0x400000;
+#define TEXT_NO_HANDLE_LEAKS "No handle leaks."
+
+// Make file constant labels
+#define MAKEFILE_TARGETTYPE_STRING "# TargetType "
+#define MAKEFILE_BASIC_TARGETTYPE_STRING "# BasicTargetType "
+#define MAKEFILE_TARGET_STRING "# Target "
+#define MAKEFILE_FEATURE_VARIANT_NAME "# FeatureVariantName "
+#define MAKEFILE_FEATURE_VARIANT_UREL_LABEL "# FeatureVariantURELLabel "
+#define MAKEFILE_FEATURE_VARIANT_UDEB_LABEL "# FeatureVariantUDEBLabel "
+#define UDEB_OPTIMIZATION_LEVEL 0
+
+// Listing file contant labels
+#define LST_FILE_SOURCE_FILE_LABEL "Source file:"
+
+/**
+* Struct for saving module info from .dat file and number of leaks in module.
+*
+*/
+struct DLL_LOAD_INFO
+{
+	string sModuleName;
+	unsigned long iStartAddress;
+	unsigned long iEndAddress;
+	int iLeaks;
+	unsigned long iPID;
+	int iSubTestStartOpenHandles;
+	int iSubTestEndOpenHandles;
+	// Load/Unload times, note these are micro seconds from 1970 so size is huge.
+	unsigned long long iLoadTime;
+	unsigned long long iUnloadTime;
+	DLL_LOAD_INFO() {
+		iStartAddress = 0;
+		iEndAddress = 0;
+		iLeaks = 0;
+		iPID = 0;
+		iSubTestStartOpenHandles = 0;
+		iSubTestEndOpenHandles = 0;
+		iLoadTime = 0;
+		iUnloadTime = 0;
+	};
+};
+
+/**
+* Struct for saving symbol information from listing file
+*/
+struct LINE_IN_FILE
+{
+	int iLine;
+	string sFileName;
+	string sFunction;
+	string sMangledName;
+	string sLstName;
+};
+
+/**
+* Struct for saving symbol information from map file
+*/
+struct MAP_FUNC_INFO
+{
+	int iAddress;
+	int iFuncLength;
+	string sMangledName;
+	string sWholeLine;
+	string sFunctionName;
+};
+
+/**
+* State that represents the outcome
+* of locating memory address code line from module
+*/
+enum ADDRESS_TO_LINE_STATE {
+	no_map_data = 0, /* Map data was missing */
+	out_of_function_range, /* Could not locate it to any function */
+	mangled_symbol_name,
+	only_function_name, /* Only got function name not code line */
+	succesfull /* Have line number, function, etc...*/
+};
+
+/**
+* Struct to store detail data and state when
+* locating memory addresses code lines
+*/
+struct ADDRESS_TO_LINE_ITEM {
+	ADDRESS_TO_LINE_STATE eState; /* outcome*/
+	string sFileName; /* Filename of address*/
+	string sFunctionName; /* Function name of address*/
+	string sMangledFunctionName; /* function/Symbol name */
+	int iFunctionLineNumber; /* Functions line number */
+	int iExactLineNumber; /* Exact line number of address */
+};
+
+/**
+* Struct to store  memory leaks
+* call stack entry data
+*/
+struct CALL_STACK_ITEM {
+	string sAddress; /* Address in string */
+	int iAddress; /* Address in number (converted)*/
+	int iLocation; /* Location. i.e. corresponds m_vDllLoadModList's index*/
+	int iCalculatedLeakAddress;
+	bool bBuildUdeb; /* Optimization level */
+	string sModuleName; /* Modules name were leak is*/
+	ADDRESS_TO_LINE_ITEM addressToLine; /* Data from locating code line for memory address */
+};
+
+/**
+* Enumerations used in argument structure.
+*/
+enum MAIN_SWITCH
+{
+	SWITCH_UNKNOWN = 0,
+	SWITCH_ANALYZE = 1,
+	SWITCH_HOOK = 2,
+	SWITCH_UNHOOK = 3,
+	SWITCH_OLD_HOOK = 4,
+	SWITCH_PARSE_TRACE = 5,
+	SWITCH_CLEAN = 6,
+	SWITCH_HTI_GET = 7,
+	SWITCH_HTI_DELETE = 8,
+	SWITCH_VERSION = 9,
+	SWITCH_HELP = 10
+};
+enum HOOK_SWITCH
+{
+	HOOK_UNKNOWN = 0,
+	HOOK_INTERNAL,
+	HOOK_EXTERNAL, 
+	HOOK_EXTERNAL_FAST,
+	HOOK_EXTENSION_INTERNAL,
+	HOOK_EXTENSION_EXTERNAL,
+	HOOK_EXTENSION_EXTERNAL_FAST,
+	HOOK_EXTENSION_UNINSTRUMENT,
+	HOOK_EXTENSION_FAILED,
+	HOOK_OLD_EXTENSION_INSTRUMENT,
+	HOOK_OLD_EXTENSION_UNINSTRUMENT,
+	HOOK_OLD_EXTENSION_FAILED
+};
+
+// Hook.
+struct ARGUMENTS_HOOK
+{
+	bool bNoBuild;
+	bool bDataFileName; //Internal data gathering filename defined.
+	string sDataFileName; //Internal data gathering filename.
+	int iBuildSystem; //1 = sbs, 2 = raptor.
+	int iLoggingMode; //Just for old parameter parsing. 1=xti, 2=s60, 0=?.
+	int iAllocCallStackSize;
+	int iFreeCallStackSize;
+	string sBuildCmd; //Original build command.
+	vector<string> vBuildCmd; //Build command split in vector.
+	string sPlatform; //Platform.
+	string sBuildType; //Build type (udeb/urel).
+	string sFeatureVariant;
+	vector<string> vTargetPrograms;
+	ARGUMENTS_HOOK()
+	{
+		bNoBuild = false;
+		bDataFileName = false;
+		sDataFileName = "";
+		iBuildSystem = 0;
+		iLoggingMode = 0;
+		iAllocCallStackSize = AT_ALLOC_CALL_STACK_SIZE_DEFAULT;
+		iFreeCallStackSize = AT_FREE_CALL_STACK_SIZE_DEFAULT;
+		sBuildCmd = "";
+		sPlatform = "";
+		sBuildType = "";
+		sFeatureVariant = "";
+		vTargetPrograms.clear();
+	};
+};
+// Analyze.
+struct ARGUMENTS_ANALYZE
+{
+	string sDataFile;
+	string sOutputFile;
+	bool bSymbolFile;
+	vector<string> vSymbolFiles;
+	int iLoggingLevel;
+	ARGUMENTS_ANALYZE()
+	{
+		sDataFile = "";
+		sOutputFile = "";
+		bSymbolFile = false;
+		iLoggingLevel = 3;
+	};
+};
+//Parsing trace.
+struct ARGUMENTS_PARSE
+{
+	bool bDataFile;
+	string sDataFile;
+	bool bOutputFile;
+	string sOutputFile;
+	ARGUMENTS_PARSE()
+	{
+		bDataFile = false;
+		sDataFile = "";
+		bOutputFile = false;
+		sOutputFile = "";
+	};
+};
+//Hti get file.
+struct ARGUMENTS_HTI
+{
+	string sFile;
+	ARGUMENTS_HTI()
+	{
+		sFile = "";
+	};
+};
+/**
+* Struct to store parsed arguments from console.
+*/
+struct ARGUMENTS
+{
+	// Base arguments.
+	MAIN_SWITCH eMainSwitch; // main switch
+	HOOK_SWITCH eHookSwitch;
+	bool bHelp; //Show help.
+	bool bDebugConsole; //Debug logging to console.
+	bool bDebugDbgView; //Debug logging to win api.
+	bool bDebugLowLevel; //Debug also low level functions.
+	bool bEnableSbs2; //Use raptor.
+	ARGUMENTS_HOOK HOOK;
+	ARGUMENTS_ANALYZE ANALYZE;
+	ARGUMENTS_PARSE PARSE;
+	ARGUMENTS_HTI HTI;
+	ARGUMENTS()
+	{
+		eMainSwitch = SWITCH_UNKNOWN;
+		eHookSwitch = HOOK_UNKNOWN;
+		bHelp = false;
+		bDebugConsole = false;
+		bDebugDbgView = false;
+		bEnableSbs2 = false;
+	};
+};
+// DEBUG MACROS
+// constant string for all beginning of all debug messages
+const char START_LOG_MESSAGE[] = "*** CLE ";
+// Log normal function entry (AAA = class::function )
+#define LOG_FUNC_ENTRY( AAA ) { if( g_bDebugDbgView) { stringstream strs; strs << START_LOG_MESSAGE << "ENTRY: " << AAA << endl; OutputDebugString( strs.str().c_str() );  } else if ( g_bDebugConsole ) { stringstream strs; strs << START_LOG_MESSAGE << "ENTRY: " << AAA << endl; cout << strs.str();  } }
+// Log normal function exit
+#define LOG_FUNC_EXIT( AAA ){ if( g_bDebugDbgView) { stringstream strs; strs << START_LOG_MESSAGE << "EXIT: " << AAA << endl; OutputDebugString( strs.str().c_str() ); } else if ( g_bDebugConsole ) { stringstream strs; strs << START_LOG_MESSAGE << "EXIT: " << AAA << endl; cout << strs.str(); } }
+// Log low level function entry
+#define LOG_LOW_FUNC_ENTRY( AAA ) { if ( g_bDebugLowLevel ) { if( g_bDebugDbgView) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; OutputDebugString( strs.str().c_str() ); } else if ( g_bDebugConsole ) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; cout << strs.str(); } } }
+// Log low level function exit
+#define LOG_LOW_FUNC_EXIT( AAA ) {  if ( g_bDebugLowLevel ) { if( g_bDebugDbgView) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; OutputDebugString( strs.str().c_str() ); } else if ( g_bDebugConsole ) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; cout << strs.str(); } } }
+// Log stringstream (string, int, etc..) i.e. string1 << int1 << "log this"
+#define LOG_STRING( AAA ) { if( g_bDebugDbgView) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; OutputDebugString( strs.str().c_str() ); } else if ( g_bDebugConsole ) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; cout << strs.str(); } }
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/CATBase.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,384 @@
+/*
+* 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 base class CATBase.
+*
+*/
+
+#ifndef __CATBASE_H__
+#define __CATBASE_H__
+
+#include "../inc/ATCommonDefines.h"
+
+/**
+* The base class.
+* This class implements lot of utility type of functions used all around atool project.
+*/
+class CATBase
+{
+public:
+	
+	/**
+	* Constructor
+	*/
+	CATBase();
+
+	/**
+	* Destructor
+	*/
+	virtual ~CATBase(void);
+
+public:
+	
+	/**
+	* FilterExtraSpaces
+	* Filters/replaces multiple continuous spaces with single. Won't leave
+	* spaces in start or end of string.
+	* @param sString to filter.
+	* @return void.
+	*/
+	static void FilterExtraSpaces( string& sString );
+
+	/**
+	* Convert hex value in string to decimal.
+	* @param sHex
+	* @param ulDec
+	* @return true if successful
+	*/
+	static bool hexToDec( string& sHex, int& iDec );
+	static bool hexToDec( string& sHex, unsigned int& iDec );
+	static bool hexToDec( string& sHex, unsigned long& ulDec );
+	static bool hexToDec( string& sHex, unsigned long long& ullDec );
+
+	/**
+	* Convert hex value to integer
+	* @param value
+	* @return unsigned long
+	*/
+	static unsigned long _httoi(const TCHAR *value);
+
+	/**
+	* Convert integer to hex string.
+	* @param i
+	* @return hex string
+	*/
+	static string NumberToHexString( unsigned int i );
+
+	/**
+	* Convert long to hex string.
+	* @param i
+	* @return hex string
+	*/
+	static string NumberToHexString( unsigned long i );
+
+	/**
+	* Helper function checks is given character hex.
+	* @param value value to check.
+	* @return true if value is hex char.
+	*/
+	static bool IsHexCharacter(const TCHAR *value);
+
+	/**
+	* Remove spaces and tabulatures from beginning and
+	* end of given string.
+	* @param sInput String to trim.
+	*/
+	static void TrimString( string& sInput );
+
+	/**
+	*/
+	static string GetFileNameUsingExt( const char* pPathAndExt );
+
+	/**
+	* Changes all BackSlash characters to Slash character from string.
+	* @param sInput String including backslashes.
+	* @return String without backslashes.
+	*/
+	static string ChangeSlashToBackSlash( string sInput );
+
+	/**
+	* Changes given string to uppercase
+	* @param sInput
+	*/
+	static void ChangeToUpper( string& sInput );
+
+	/**
+	* Converts any uppercase letter to lowercase.
+	*
+	* @param sInput Reference to string.
+	*/
+	static void ChangeToLower( string& sInput );
+
+	/**
+	* Filter string out of unwanted characters. The list of allowed
+	* characters is defined in CFILTERSTRING.
+	* @param sString string to filter.
+	* @return filtered string.
+	*/
+	static string FilterString( const string& sString );
+
+	/**
+	* Removes path and extension from given filename string
+	* @param sFileName
+	* @param bReverseFindExt if true extension will be looked starting from end
+	* @return string
+	*/
+	static string RemovePathAndExt( string sFileName, bool bReverseFindExt = false );
+
+	/**
+	* Check if given file exists.
+	* @param pFilename Pointer to file name.
+	* @return False If file does not exists.
+	*/
+	static bool FileExists( const char* pFilename );
+
+	/**
+	* Check if given file is flagged read only.
+	* @param pFilename Pointer to file name.
+	* @return true if read only flag set.
+	*/
+	static bool IsFileReadOnly( const char* pFileName );
+
+	/**
+	* Set file read only.
+	* @param pFilename Pointer to file name.
+	* @return true if successful.
+	*/
+	static bool SetFileReadOnly( const char* pFileName );
+
+	/**
+	* Set file writable (remove read only flag).
+	*
+	* @param pFilename Pointer to file name.
+	* @return true if successful.
+	*/
+	static bool SetFileWritable( const char* pFileName );
+
+	/**
+	* Copy file to given path
+	* @param sFile
+	* @param sToPath
+	* @return true if successful
+	*/
+	static bool FileCopyToPath(const string& sFile, const string& sToPath);
+
+	/**
+	* Move file to given path
+	* @param sFile File to be moved
+	* @param sToPath path where to move file
+	* @return true if successful
+	*/
+	static bool FileMoveToPath(const string& sFile, const string& sToPath);
+
+	/**
+	* Delete file
+	* Note! if file does not exists no error message is displayed
+	* but function returns false
+	* @param sFile File to be deleted
+	* @param bPrint display messages or not, default true
+	* @return true if successful
+	*/
+	static bool FileDelete(const string& sFile, bool bPrint = true );
+    
+	/**
+	* Delete dir
+	* Note! if dir does not exists no error message is displayed
+	* but function returns false.
+	* This function wont delete directory if string does not contain
+	* AT_TEMP...
+	* @param sDir Directory to be deleted
+	* @param bPrint display message or not, default true
+	* @return true if successful
+	*/
+	static bool DirDelete(const string& sDir, bool bPrint = true );
+
+	/**
+	* Create dir
+	* Note! if dir cannot be created no error message is displayed
+	* but function returns false.
+	* @param sDir Directory to be deleted
+	* @param bPrint display message or not, default true
+	* @return true if successful
+	*/
+	static bool DirCreate(const string& sDir, bool pPrint = true );
+
+	/**
+	* Create temp path string for given
+	* mmpfile (full path+mmpname)
+	* @param sMmpFileWithPath
+	* @return string containing full path to
+	* AnalyzeTool temporary directory
+	*/
+	static string CreateTempPath(const string& sMmpFileWithPath);
+
+	/**
+	* Search files with extensions from given path.
+	* @param sPathAndExt
+	* @param bPrintErrors
+	* @param sErrorLog
+	* @return true if found.
+	*/
+	static bool SearchFileWithExtension( const char* pPathAndExt, bool bPrintErrors, string& sErrorLog );
+
+	/**
+	* Helper function to parse filename or path from given string
+	* @param bFileName if true returns filename otherwise the path
+	* @param sInput string where to get path or filename
+	* @return string filename or path
+	*/
+	static string GetPathOrFileName( bool bFileName, string sInput );
+
+	/**
+	* Function returns string from begin of given string until next space,
+	* characters until next space are removed from sInput string.
+	*
+	* @param sInput Line where data is separated with spaces.
+	* @param bEraseFromInput If true characters before space will be removed.
+	* @return string String until next space.
+	*/
+	static string GetStringUntilNextSpace( string& sInput, bool bEraseFromInput = true );
+
+	/**
+	* Convert unix path to windows
+	* @param sPath
+	*/
+	static void ConvertUnixPathToWin( string& sPath );
+
+	/**
+	* Create Temporary AT Cpp file
+	* @param sId unique id to add in file name
+	* @param sPath where to create
+	* @param sS60FileName of the logging file
+	* @param iLogOption logging mode
+	* @param iIsDebug build type
+	* @param iAllocCallStackSize.
+	* @param iFreeCallStackSize.
+	* @return true if successful
+	*/
+	static bool CreateTemporaryCpp( const string& sId
+								 ,const string& sPath
+								 ,const string& sS60FileName
+								 ,int iLogOption
+								 ,int iIsDebug
+								 ,int iAllocCallStackSize
+								 ,int iFreeCallStackSize );
+	/**
+	* Acquire a list of files in given directory
+	* @param sDirectory can end to \ or x but not to *
+	* @param bListDirs if true directories will be listed as well, default false
+	* @param bAddPathToFile if true given sDirectory path is added to file string, default false
+	* @return vector<string> list of files in folder
+	*/
+	static vector<string> DirList(const string& sDirectory, bool bListDirs = false, bool bAddPathToFile = false);
+
+	/**
+	* Get extension from given "file" string
+	* returns string after last . if any otherwise returns same
+	* what was given
+	* @param sString 
+	* @return string string after last '.' if no '.' returns given string
+	*/
+	static string GetExtension(const string& sString);
+
+	/**
+	* Convert TCHAR pointer to string
+	* @param charArray to convert
+	* @return string
+	*/
+	static string ConvertTCHARtoString(TCHAR* charArray);
+
+	/**
+	* if given string contains two dots '.' this will remove
+	* all characters after first '.'
+	*/
+	static void RemoveAllAfterDotIfTwoDots(string& sString);
+
+	/**
+	* checks given file is it data file
+	* @param sFile
+	* @return true if it is datafile
+	*/
+	static bool IsDataFile( 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
+	* @param sPathString
+	* @return void
+	*/
+	static void ParseRelativePathString(string& sPathString);
+
+	/**
+	* Remove relative path ".." from string
+	* @param sString string to remove from
+	* @param iDots index of ".."
+	* @return void
+	*/
+	static void RemoveRelativePath(string& sString, size_t iDots);
+
+	/**
+	* Check if given directory exists.
+	*
+	* @param pDirname Pointer to directory name.
+	* @return False If directory does not exists.
+	*/	
+	static bool DirectoryExists( const char* pDirname );
+
+	/**
+	* Checks from constant array is this targettype
+	* unsupported by AT
+	* @param sTargetType type to check
+	* @return true if it is supported by atool
+	*/
+	static bool IsTargetTypeSupported(string sTargetType);
+
+	/**
+	* Checks from constant array is this targettype
+	* kernel side.
+	* @param sTargetType type to check
+	* @return true if it is kernel type
+	*/
+	static bool IsTargetTypeKernelSide(string sTargetType);
+
+	/**
+	* Check is given variant defined in environment.(SBS v.1)
+	* @param sEpocRoot
+	* @param sVariantName
+	* @return true if it is.
+	*/
+	static bool CheckVariant( const string& sEpocroot, const string& sVariantName );
+
+	/**
+	* Check has the environment defined "DEFAULT" variant
+	* @param sEpocRoot
+	* @return true if it is
+	*/
+	static  bool IsDefaultVariant( const string& sEpocRoot );
+
+	/**
+	* Check is all character ascii
+	* @param pInput, pointer to characters
+	* @param iLength, length of the string
+	* @return true if all character are ascii
+	*/
+	static bool IsAscii( const char* pInput, const unsigned int iLength );
+
+	/**
+	* Get current environments epocroot.
+	* @param sEpocRoot value is stored in this if successful.
+	* @return true if successful.
+	*/
+	static bool GetEpocRoot( string& sEpocRoot );
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/CATDatParser.h	Thu Feb 11 15:51:35 2010 +0200
@@ -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:  Class responsible to parse data files
+*
+*/
+
+
+#ifndef __CATDatParser_H__
+#define __CATDatParser_H__
+
+// Includes.
+#include "ATCommonDefines.h"
+#include "CATBase.h"
+#include "CATDataSaver.h"
+
+// Forward declarations.
+class CATModule2;
+class CATMemoryAddress;
+class CATRomSymbol;
+
+/**
+* CATDatParser creates analysis report from AnalyzeTool data file.
+* This class is used from CATProject/CATFindSourceline classes.
+* Uses either CATFindSourceLine/CATModule2's to locate memory addresses to codelines.
+* Uses CATDataSaver to store report data to basic and xml output.
+*/
+class CATDatParser : public CATBase
+{
+
+public:
+	// enumeration representing the "mode" depending on build system
+	enum ANALYZE_MODE
+	{
+		SBS_1 = 0,
+		SBS_2 = 1
+	};
+	// Representing current process state
+	enum PROCESS_STATE
+	{
+		not_started = 0,
+		ongoing = 1,
+		stopped = 2
+	};
+
+	/**
+	* Constructor.
+	*/
+	CATDatParser();
+
+#ifndef MODULE_TEST
+private:
+#endif
+	/**
+	* Real constructor.
+	*/
+	void Construct();
+	
+	/**
+	* Prevent copy
+	*/
+	CATDatParser& operator =( const CATDatParser& /*other*/ ) { }
+	CATDatParser( const CATDatParser& /*other*/ ) { }
+	
+public:
+	/**
+	* Constructor for SBS2
+	* @param pModules pointer to vector containing project modules
+	*/
+	CATDatParser( vector<CATModule2*>* pModules );
+
+	/**
+	* Destructor
+	*/
+	~CATDatParser();
+
+	/**
+	* Set offset to be used with mapfiles
+	* @param iOffSet
+	*/
+	void SetOffSet( int iOffSet );
+
+	/**
+	* Get offset value
+	* @return int
+	*/
+	int GetOffSet( ) const;
+	
+	/**
+	* Analyze data file set
+	* This method includes try/catch in parsing
+	* @return int error codes specified in CATProject (0=OK)
+	*/
+	int Analyze();
+
+	/**
+	* Set log level
+	* @param iLogLevel
+	*/
+	void SetLogLevel(int iLogLevel);
+	/**
+	* Get Log level
+	* @return int
+	*/
+	int GetLogLevel() const ;
+
+	/**
+	* Set data file to be analyzed
+	* @param sInputFile
+	*/
+	void SetInputFile(const string& sInputFile);
+
+	/**
+	* Set output file
+	* @param sOutputFile
+	*/
+	void SetOutputFile(const string& sOutputFile);
+
+	/**
+	* Set rom symbol file(s).
+	* @param sRomSymbolFile
+	*/
+	void SetRomSymbolFiles(const vector<string>& vRomSymbolFile);
+
+	/**
+	* Set print flag
+	* @param pPringFlag
+	*/
+	void SetPringFlag( bool bPrintFlag );
+
+	/**
+	* Set addr2line.exe pinpoint state
+	* @param bInput
+	*/
+	void SetAddr2lineExeState( bool bInput );
+
+	/**
+	* Set project platform.
+	* @param sPlatform platform.
+	*/
+	void SetProjectPlatform( const string& sPlatform );
+
+	/**
+	* Set projects build type. Use enumeration defined in CATProject.
+	* @param eBuildType.
+	*/
+	void SetProjectBuildType( int eBuildType );
+
+	//Define this class as a friend class for test class.
+	friend class CATTester;
+#ifndef MODULE_TEST
+private:
+#endif
+
+	/**
+	* Start parsing datafile
+	* @return error codes defined in CATProject
+	*/
+	int Parse();
+	
+	/**
+	* Helper functio to print header of report
+	*/
+	void Header();
+
+	/**
+	* Helper functio to print footer of report
+	*/
+	void Footer();
+
+	/**
+	* Helper function reseting/clearing all
+	* member variables related to parsing
+	*/
+	void ClearParsingVariables();
+
+	// Helpers for data file tags
+	bool ParseProcessStart( string& sLine );
+	bool ParseDllLoad( string& sLine );
+	bool ParseDllUnload( string& sLine );
+	bool ParseMemLeak( string& sLine );
+	bool ParseProcessEnd( string& sLine );
+	bool ParseHandleLeak( string& sLine );
+	bool ParseTestStart( string& sLine );
+	bool ParseTestEnd( string& sLine );
+	bool ParseLoggingCancelled( string& sLine );
+	bool ParseErrorOccured( string& sLine );
+
+	void PrintMemLeak(const string& sTime,
+					   const string& sLeakSize,
+					   const string& sLeakAddr,
+					   const string& sModuleName);
+
+	// Utilities
+	string ConvertTimeToLocalTime( string sInputTime );
+
+	/**
+	* Create a winscw module into pModules vector.
+	* Used when we have dll load of module not in project to create them
+	* after this they are used in locating code lines.
+	* @param sBinaryName name of the binary with extension.
+	* @return true if successful.
+	*/
+	bool CreateWinscwModule( const string& sBinaryName );
+
+#ifndef MODULE_TEST
+private:
+#endif
+	vector<string> ParseStringToVector( const string& sInput, char separator );
+	void CleanMemoryAddresses();
+
+	// Members
+	unsigned int m_iDataVersion; // Version of data file.
+	int m_eProcess_state; // is process started, etc..
+	bool m_bProcessStartFound;
+	bool m_bDllLoadFound;
+	int m_iLogLevel; // specified logging level
+	string m_sInputFile; // input file
+	vector<string> m_vRomSymbolFiles; // Rom symbol file.
+	string m_sOutputFile; // output file
+	string m_sInputFileTemp; // temporary input file (parsed from trace)
+	ifstream m_In; // Handle to input file
+	// Datasaver
+	CATDataSaver m_DataSaver;
+
+	// Modules to be used in pinpointing
+	vector<CATModule2*>* m_pModules;
+
+	// Rom symbol file.
+	CATRomSymbol* m_pRomSymbol;
+
+	// Build type from dat.
+	int m_eBuildType;
+	// Build type from project.
+	int m_eProjectBuildType;
+	// Offset of map file.
+	int m_iOffSet;
+	// Platform of project.
+	string m_sProjectPlatform;
+
+	// Process related
+	unsigned long m_iCurrentProcessId;
+	string m_sCurrentProcessName;
+	int m_iTotalRuns;
+	int m_iSuccesfullRuns;
+	
+	// Leak counting related
+	int m_iTotalNumberOfLeaks;
+	bool m_bSubtestOnGoing;
+	int m_iPinPointedLeaks;
+	int m_iPinPointedSubTestLeaks;
+	int m_iLeakNumber;
+	
+	// Handle count related
+	int m_iSubtestStartHandleCount;
+	vector<string> m_vHandleLeaks;
+
+	// Module related
+	vector<DLL_LOAD_INFO> m_vDllLoadModList;
+	vector<DLL_LOAD_INFO> m_vDllLoadModListSubTest;
+	
+	// Sbs 1 support functions
+	int FindModuleUsingAddress( unsigned long iAddress ) const;
+	//int FindModuleUsingPID( unsigned long iPID ) const;
+	int FindModuleUsingName( const char* pModName );
+
+	// Memory addresses
+	vector<CATMemoryAddress*> m_vMemoryAddress;
+
+};
+#endif
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/CATDataSaver.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,187 @@
+/*
+* 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:  Declarations for the class CATDataSaver.
+*
+*/
+
+
+#ifndef __CATDATASAVER_H__
+#define __CATDATASAVER_H__
+
+#include <xercesc/dom/DOM.hpp>
+#include <xercesc/framework/LocalFileFormatTarget.hpp>
+#include "ATCommonDefines.h"
+
+enum element_types
+{
+	RESULT = 0,
+	RUN,
+	LEAK,
+	CALLSTACK,
+	ITEM,
+	RUN_END,
+	ERROR_IN_RUN,
+	MEM_LEAKS,
+	MEM_LEAK_MODULE,
+	HANDLE_LEAKS,
+	HANDLE_LEAK_MODULE,
+	TEST_START,
+	TEST_END,
+	SUBTEST_MEM_LEAKS,
+	SUBTEST_MEM_LEAK_MODULE,
+	LOGGING_CANCELLED,
+	SUBTEST_HANDLE_LEAKS
+};
+
+//#define CARBIDE_DATA 0
+#define XML_DATA     1
+#define TEXT_DATA    2
+
+/**
+* CATDataSaver saves analysis report data same time to basic (console) output and xml.
+*/
+class CATDataSaver
+{
+
+public:
+
+	/**
+	* Constructor.
+	*/
+	CATDataSaver( void );
+
+	/**
+	* Destructor.
+	*/
+	~CATDataSaver(void);
+
+	/**
+	* Save all lines to file with given format.
+	*
+	* @param pFileName Pointer to file name.
+	* @param iDataToSave Format of data.
+	*/
+	void SaveLinesToFile( const char* pFileName, int iDataToSave );
+
+	/**
+	* Prints all saved lines to screen.
+	*/
+	void PrintLinesToScreen( void );
+
+	/**
+	* Adds saved line to first in database.
+	*/
+	void AddLineToFirst( void );
+
+	/**
+	* Adds saved line to last in database.
+	*/
+	void AddLineToLast();
+
+	/**
+	* Adds string to current line.
+	*/
+	void AddString( const char* pData, bool bSaveCarbideData = false );
+
+	/**
+	* Converts integer to string and adds it to current line.
+	*/
+	void AddInteger( int iValue, bool bSaveCarbideData = false );
+
+	/**
+	* Sets logging level.
+	* If value is invalid DEFAULT_LOGGING_LEVEL is used
+	* value must be between MIN_LOGGING_LEVEL and MAX_LOGGING_LEVEL
+	* @param iLoggingLevel Logging level.
+	*/
+	void SetLoggingLevel( int iLoggingLevel );
+
+	/**
+	* Gets logging level.
+	*
+	* @return Logging level.
+	*/
+	int GetLoggingLevel( void );
+
+	/**
+	* Sets print immediately flag.
+	*/
+	void SetPrintFlag( bool bPrintImmediately );
+
+	/**
+	* Sets data header for carbide data.
+	*/
+	void SaveCarbideDataHeader( void );
+
+	/**
+	* Initializes xercer xml parser.
+	*/
+	bool InitXML( void );
+
+	/**
+	* Writes data to xml tree.
+	*/
+	void SaveXML( string sInput, int iElementType );
+
+	/**
+	* Converts char* -> wchar_t*.
+	*/
+	static LPWSTR CharToWChar( const char* str );
+
+	/**
+	* Converts wchar_t* -> char*.
+	*/
+	static void WCharToChar( string& sInput, const WCHAR* Source );
+
+	void SetBuild( bool bUdebBuild );
+
+	void AddCarbideData( const string& sInput );
+
+	static string IntegerToString( int iValueToConvert );
+
+	//Define this class as a friend class for test class.
+	friend class CATTester;
+#ifndef MODULE_TEST
+private:
+#endif
+	vector<string> m_vLines;
+	string m_sLine;
+	string m_sCarbideDataLine;
+
+	string m_sCarbideDataHeader;
+
+	int m_iLoggingLevel;
+	int m_iRunNumber;
+	bool m_bPrintImmediately;
+	bool m_bXMLInitOk;
+	bool m_bUdebBuild;
+
+	xercesc::DOMDocument* m_pDomDoc;
+	xercesc::DOMElement* m_pRootElem;
+	xercesc::DOMElement* m_pCurrentLeakElem;
+	xercesc::DOMWriter* m_Serializer;
+	xercesc::DOMElement* m_pRunElement;
+	xercesc::DOMElement* m_pMemoryLeaks;
+	xercesc::DOMElement* m_pHandleLeaks;
+	xercesc::DOMElement* m_pCurrentSubTestElem;
+	xercesc::DOMElement* m_pSubtestMemoryLeaks;
+
+	/**
+	* Constructor.
+	*/
+	string GetStringUntilNextGivenChar( string& sInput, char cCharacter );
+
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/CATMemoryAddress.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,130 @@
+/*
+* 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:  Class representing a memory address and its details.
+*
+*/
+
+
+#ifndef __CATMEMORYADDRESS_H__
+#define __CATMEMORYADDRESS_H__
+
+#include "../inc/ATCommonDefines.h"
+
+class CATMemoryAddress
+{
+public:
+	// Enumeration representing the state of locating code lines.
+	enum ADDRESS_TO_LINE_STATE
+	{
+		OUT_OF_PROCESS = 0, /* Not located code line.*/
+		OUT_OF_RANGE, /* Outside functions range. */
+		SYMBOL, /* Symbol/ Function located (no codeline) */
+		FUNCTION, /* Function and line number.*/
+		EXACT /* Exact code line located with all information.*/
+	};
+
+	/**
+	* Constructor
+	* @param sAddress
+	* @param iOffSet value used if need to use offset value
+	*/
+	CATMemoryAddress( string& sAddress, unsigned long iOffSet );
+
+	/**
+	* Destructor
+	*/
+	virtual ~CATMemoryAddress();
+
+	/**
+	* Find which binary this address belongs to.
+	* Sets also the offsetfrommodulestart.
+	* @param vDlls container of binarys to find from.
+	* @return true if found
+	*/
+	bool FindSetModuleName(vector<DLL_LOAD_INFO>* vDlls);
+
+	/**
+	* Get vector index to which module we found this address to belong to.
+	* @return -1 if not set.
+	*/
+	int GetDllLoadInfoIndex();
+
+	/**
+	* Note return value includes the set offset.
+	* So this value is not binary start - address.
+	* Instead it is.
+	* memory address - binary start address + offset
+	* @return adress
+	*/
+	unsigned long GetOffSetFromModuleStart();
+
+	/**
+	* Get the binary start address
+	* @return binary start address
+	*/
+	unsigned long GetModuleStartAddress() const;
+	
+
+	/**
+	* Simple get and sets for member variables.
+	*/
+	void SetTime( unsigned long long& ullTime );
+	unsigned long long GetTime();
+	void SetAddress( string& sAddress );
+	string GetAddressString();
+	void SetAddress( unsigned long iAddress );
+	unsigned long GetAddress();
+	void SetModuleName( string& sModuleName );
+	string GetModuleName();
+	void SetAddressToLineState( ADDRESS_TO_LINE_STATE eState );
+	int GetAddressToLineState();
+	void SetFileName(string& sFileName);
+	string GetFileName();
+	void SetFunctionName(string& sFunctionName);
+	string GetFunctionName();
+	void SetFunctionLineNumber(int iFunctionLineNumber);
+	int GetFunctionLineNumber();
+	void SetExactLineNumber(int iExactLineNumber);
+	int GetExactLineNumber();
+	void SetModuleStartAddress(unsigned long iAddress);
+
+#ifndef MODULE_TEST
+private:
+#endif
+	// Used offset to add to addresses
+	unsigned long m_iOffSet;
+	// Address related members
+	string m_sAddress;
+	unsigned long m_iAddress;
+
+	// Time (microseconds from 1970)
+	unsigned long long m_iTime;
+
+	// Module related members(if FindSetModule is successful)
+	string m_sModuleName;
+	unsigned long m_iOffSetFromModuleStart;
+	unsigned long m_iModuleStartAddress;
+
+	// Module to which address belong.
+	int m_iDllLoadinfoIndex;
+
+	// Pin pointing related members
+	int m_ePinPointState;
+	string m_sFileName;
+	string m_sFunctionName;
+
+	int m_iFunctionLineNumber;
+	int m_iExactLineNumber;
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/CATMmp.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,109 @@
+/*
+* 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:  Class responsible of handling mmp files.
+*
+*/
+
+
+#ifndef __CATMMP_H__
+#define __CATMMP_H__
+
+// Includes
+#include "ATCommonDefines.h"
+#include "CATBase.h"
+
+/**
+* CATMmp represents mmp file of module.
+* All mmp file related actions are done using this class.
+* @author
+*/
+class CATMmp : public CATBase
+{
+
+public:
+
+	// Constructor
+	CATMmp();
+	
+	// Destructor
+	~CATMmp();
+	
+	// MMP file.
+	string m_sMmpFile;
+
+	/**
+	* Makes AnalyzeTool changes to given mmp file.
+	* @param sTargetType target type of module i.e. exe / dll
+	* @param sId unique identification string added to source file name
+	* @return true if editing was successful.
+	*/
+	bool EditMmpFile(const string& sTargetType, const string& sId);
+
+	/**
+	* Backups mmp file to atool_temp/file
+	* to path/atool_temp/filename.mmp.tmp.
+	* Calling this function results always to 
+	* none edited mmp & none edited backup.
+	* @return true if successful.
+	*/
+	bool BackupMmpFile();
+
+	/**
+	* Restores backup from temporary directory (replacing current).
+	* @return true if successful.
+	*/
+	bool RestoreMmpFile();
+
+	/**
+	* VerifyAndRecover mmp file.
+	* Wont change mmp if it is not edited
+	* Replaces mmp file using backup if it exists and it is
+	* not edited otherwise removes changes from mmp file.
+	* @return true if successful
+	*/
+	bool VerifyAndRecover();
+
+#ifndef MODULE_TEST
+private:
+#endif
+		/**
+	* Checks if the given mmp file is modified by AT
+	* @param bBackup if true checks backup
+	* @return bool true if it is edited
+	*/
+	bool IsMmpEdited(bool bBackup = false );
+
+	/**
+	* CreateBackupPath creates string containinig
+	* full path to backup mmp file
+	*/
+	string CreateMmpBackupPath();
+
+	/**
+	* Removes AnalyzeTool changes from given file
+	* @param bBackup if true removes changes from backup
+	* @return true if successfully removed changes
+	*/
+	bool RemoveMmpFileChanges(bool bBackup = false);
+
+	/**
+	* Removes write protections from mmp file and its backup if exists.
+	* @return true if successful.
+	*/
+	bool RemoveWriteProtections();
+
+	//Define this class as a friend class for test class.
+	friend class CATTester;
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/CATModule2.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,547 @@
+/*
+* 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:  Class representing a module in project (sbs2).
+*
+*/
+
+
+// Note, module testing methods are not declared as friend.
+#ifndef __CATMODULE2_H__
+#define __CATMODULE2_H__
+
+// Includes.
+#include "ATCommonDefines.h"
+#include "CATBase.h"
+#include "CATMmp.h"
+
+// Forward declarations.
+class CATMemoryAddress;
+class IAddressToLine;
+
+/**
+* CATModule2 represents a module (single binary) in project.
+* This class is used with the SBS v.2.
+* @author
+*/
+class CATModule2 : public CATBase
+{
+
+public:
+	/**
+	* Constructor.
+	*/
+	CATModule2(void);
+	
+	/**
+	* Destructor.
+	*/
+	~CATModule2(void);
+	
+	/**
+	* Read modules attributes from SBS v.1 makefile.
+	* Also copies makefile to temporary directory if successful.
+	*/
+	bool ReadMakeFile();
+
+	/**
+	* Read modules attributes from SBS v.1 makefile.
+	* From make file which is in modules temporary directory.
+	*/
+	bool ReadMakeFileFromTemp();
+
+	/**
+	* Add sources using line where source files separated by spaces.
+	* @param sSourceLine.
+	*/
+	void AddSources(string& sSourceLine);
+
+	/**
+	* Add sources by giving source file and its corresponding listing file.
+	* @param sSourceFile
+	* @param sLstFile
+	*/
+	void AddSource(const string& sSourceFile, const string& sLstFile);
+
+	/**
+	* Create AT temporary cpp file for module.
+	* @param sS60FileName.
+	* @param eLoggingMode.
+	* @param eBuildType.
+	* @param iAllocCallStackSize.
+	* @param iFreeCallStackSize.
+	* @return true if successful.
+	*/
+	bool CreateTempCpp(const string& sS60FileName
+		, int eLoggingMode
+		, int eBuildType
+		, int iAllocCallStackSize
+		, int iFreeCallStackSize );
+
+	/**
+	* Add AT changes to modules mmp file.
+	* @return true if successful.
+	*/
+	bool ModifyMmp();
+
+	/**
+	* Restore any changes made to modules mmp file.
+	* @return true if successful.
+	*/
+	bool RestoreMmp();
+
+	/**
+	* Verify tha mmp does not contain AnalyzeTool made changes.
+	* If it does contain them will remove them manually or using backup.
+	* @return true if successful.
+	*/
+	bool VerifyAndRecoverMmp();
+
+	/**
+	* Copy modules releasables to its temporary dir.
+	* This includes map & lst files.
+	* @return true if successful.
+	*/
+	bool CopyReleasables();
+
+	/**
+	* Copy modules listing files to given directory.
+	* After copy they will be deleted.
+	* @param sDir target directory.
+	* @return true if successful.
+	*/
+	bool CopyLstFilesToDir( const string& sDir );
+
+	/**
+	* Delete modules lst files from their source
+	* directories.
+	* @return true if succesfful.
+	*/
+	bool DeleteLstFilesFromSrc();
+
+	/**
+	* Clean modules temporary directory of files,
+	* not defined in UNDELETE list.
+	* @return true if successful
+	*/
+	bool CleanTemporaryDir();
+
+	/**
+	* Delete modules temporary directory.
+	* @return true if successful.
+	*/
+	bool DeleteTemporaryDir();
+
+	/**
+	* Locate codeline of given memory address.
+	* Given address must be calculated to correspond map file addresses.
+	* @param pMemoryAddress object where to store results.
+	* @return true if successful.
+	*/
+	bool AddressToLine(CATMemoryAddress* pMemoryAddress);
+
+	/**
+	* Check does modules symbol file(s) exist.
+	* @return true if it exists.
+	*/
+	bool SymbolFileExist( void );
+
+	/**
+	* Check does modules map file(s) exists.
+	* @return true if it exists.
+	*/
+	bool MapFileExist( void );
+
+	/**
+	* Check does modules binary file(s) exist.
+	* @return true if it exists.
+	*/
+	bool BinaryFileExist( void );
+
+#ifndef MODULE_TEST
+private:
+#endif
+
+	/**
+	* Read modules attributes from make file.
+	*/
+	bool ReadMakeFilePrivate();
+
+	/**
+	* Locate codeline of given memory address (winscw platform).
+	* Given address must be calculated to correspond map file addresses.
+	* @param pMemoryAddress object where to store results.
+	* @return true if successful.
+	*/
+	bool AddressToLineWinscw(CATMemoryAddress* pMemoryAddress );
+
+	/**
+	* Locate codeline of given memory address (armv5 platform).
+	* Given address must be calculated to correspond map file addresses.
+	* @param pMemoryAddress object where to store results.
+	* @return true if successful.
+	*/
+	bool AddressToLineArmv5(CATMemoryAddress* pMemoryAddress );
+
+	/**
+	* Locate codeline of given memory address.
+	* Given address must be calculated to correspond map file addresses.
+	* @param pMemoryAddress object where to store results.
+	* @return true if successful.
+	*/
+	bool AddressToLineAddr2lineExe( CATMemoryAddress* pMemoryAddress );
+
+	/**
+	* Search map file data (symbols) using given address.
+	* @param iAddress memory address.
+	* @return index of the symbol or -1 if not found.
+	*/
+	int GetSymbolIndexUsingAddress(unsigned long iAddress) const;
+
+	/**
+	* Search listing  files data using the given symbol name.
+	* @param sSymbolName symbols name to find.
+	* @return index of the found lst data or -1 if not found.
+	*/
+	int GetLineInFileIndexUsingSymbolName(const string& sSymbolName) const;
+	
+	/**
+	* Search the exact code line from given file.
+	* @param sFileName listing file to search from.
+	* @param iLine functions line number.
+	* @param iFromFuncAddress how many bytes from functions start.
+	* @return line number or -1 if not found.
+	*/
+	int FindLeakCodeLine( string& sFileName, int iLine, unsigned long iFromFuncAddress ) const;
+
+public:
+
+	/**
+	* Set used build system (CATProject::BUILD_SYSTEM).
+	* @param eBuildSystem.
+	*/
+	void SetBuildSystem( int eBuildSystem );
+
+	/**
+	* Get defined build system.
+	* @return int CATProject::BUILD_SYSTEM
+	*/
+	int GetBuildSystem( void ) const ;
+
+	/**
+	* Set SBS v.1 makefile.
+	* @param sMakeFile
+	*/
+	void SetMakeFile( const string& sMakeFile );
+	
+	/**
+	* Get SBS v.1 makefile.
+	* @return string makefile.
+	*/
+	string GetMakeFile( void ) const;
+
+	/**
+	* Initialize module ready for locating code lines.
+	* with memory addresses (reads map and listing files).
+	* return true if successful.
+	*/
+	bool InitializeAddressToLine();
+	
+	/**
+	* Set modules mmp file.
+	* This also creates temporary dir if it is missing.
+	* @return true if successful.
+	*/
+	bool SetMmpFile(const string& sMmpFile);
+
+	/**
+	* Create modules own temporary directory.
+	* @return true if successful.
+	*/
+	bool CreateTemporaryDirectory();
+
+	/**
+	* Get modules mmp file.
+	* @return mmp file.
+	*/
+	string GetMmpFile() const;
+
+	/**
+	* Get modules atool_temp directory path.
+	* @return atool_temp directory path.
+	*/
+	string GetTempPath() const;
+
+	/**
+	* Get S60 logging file name.
+	* @return s60 logging file name.
+	*/
+	string GetS60FileName() const;
+
+	/**
+	* Set target binary name.
+	* @param sTarget binary file name.
+	*/
+	void SetTarget(const string& sTarget);
+
+	/**
+	* Get target binary name.
+	* @return modules binary file name.
+	*/
+	string GetTarget() const;
+
+	/**
+	* Set binary target type.
+	* @param sTargetType binary target type.
+	*/
+	void SetTargetType(const string& sTargetType);
+
+	/**
+	* Get binary target type.
+	* @return binary target type.
+	*/
+	string GetTargetType() const;
+
+	/**
+	* Set requested binary target file extension.
+	* @param sRequestedTargetExt binary target file extension.
+	*/
+	void SetRequestedTargetExt( const string& sRequestedTargetExt );
+
+	/**
+	* Get requested binary target file extension.
+	* @return binary target file extension.
+	*/
+	string GetRequestedTargetExt() const;
+
+	/**
+	* Get full name of modules binary.
+	* @return modules binary files full name.
+	*/
+	string GetBinaryName() const;
+
+	/**
+	* Set variant platform.
+	* @param sVariantPlatform variant platform.
+	*/
+	void SetVariantPlatform(const string& sVariantPlatform);
+
+	/**
+	* Get variant platform.
+	* @return variant platform.
+	*/
+	string GetVariantPlatform() const;
+
+	/**
+	* Set variant type.
+	* @param sVariantType variant type.
+	*/
+	void SetVariantType(const string& sVariantType);
+
+	/**
+	* Get variant type.
+	* @return variant type.
+	*/
+	string GetVariantType() const;
+
+	/**
+	* Set feature variant.
+	* @param sFeatureVariant feature variant.
+	*/
+	void SetFeatureVariant(const string& sFeatureVariant);
+
+	/**
+	* Get feature variant.
+	* @return feature variant.
+	*/
+	string GetFeatureVariant() const;
+
+	/**
+	* Set feature variant name.
+	* @param sFeatureVariantName feature variant name.
+	*/
+	void SetFeatureVariantName(const string& sFeatureVariantName);
+
+	/**
+	* Get feature variant name.
+	* @return feature variant name.
+	*/
+	string GetFeatureVariantName() const;
+
+	/**
+	* Set release path.
+	* @param sReleasePath release path.
+	*/
+	void SetReleasePath(const string& sReleasePath);
+
+	/**
+	* Get release path.
+	* @return release path.
+	*/
+	string GetReleasePath() const;
+
+	/**
+	* Set full variant path.
+	* @param sFullVariantPath full variant path.
+	*/
+	void SetFullVariantPath(const string& sFullVariantPath);
+
+	/**
+	* Get full variant path.
+	* @return full variant path.
+	*/
+	string GetFullVariantPath() const;
+
+	/**
+	* Set compile definition(s) of the module.
+	* @param sCompileDefinitions
+	*/
+	void SetCompileDefinitions( const string& sCompileDefinitions );
+
+	/**
+	* Get compile definition(s) of the module.
+	* @return compile definition(s).
+	*/
+	string GetCompileDefinitions() const;
+
+	/**
+	* Is modules target type udeb?
+	* @return true if modules target type is udeb.
+	*/
+	bool IsUDEB() const;
+
+	/**
+	* Is module build successfully?
+	* This includes check of listing and map files from temporary directory.
+	* @return true if module build successfully.
+	*/
+	bool IsMakeSuccessfull();
+
+	/**
+	* Get error string. This includes possible erros what are generated when
+	* IsMakeSuccesfull is called.
+	* @return error string.
+	*/
+	string GetErrors() const;
+
+	/**
+	* Create build complete file to modules temporary directory.
+	* @return true if build complete file created successfully.
+	*/
+	bool CreateBuildCompleteFile( void );
+
+	/**
+	* Read map file (armv5 platform).
+	* @return true if map file read successfully.
+	*/
+	bool ReadMapFileArmv5();
+
+	/**
+	* Set compile info text
+	* @param sCompileInfoText
+	*/
+	void SetCompileInfoText( string sCompileInfoText );
+
+	/**
+	* Get compile info text
+	* @return compile info text
+	*/
+	string GetCompileInfoText() const;
+
+#ifndef MODULE_TEST
+private:
+#endif
+
+	/**
+	* Struct for saving source information
+	* sCpp is source file.
+	* sLst sources corresponding lst file.
+	* bStatic true if source information from static library.
+	*/
+	struct SOURCE
+	{
+		bool bStatic;
+		string sCpp;
+		string sLst;
+		SOURCE() : bStatic(false), sCpp(""), sLst("") {}
+	};
+
+	// Build system
+	int m_eBuildSystem;
+	// Sbs v.1 makefile
+	string m_sMakeFile;
+	// Mmp file.
+	CATMmp m_Mmp;
+	// Temporary directory with path.
+	string m_sTempPath;
+	// Target.
+	string m_sTarget;
+	// Target type.
+	string m_sTargetType;
+	// True target extension.
+	string m_sRequestedTargetExt;
+	// Variant platform.
+	string m_sVariantPlatform;
+	// Variant type.
+	string m_sVariantType;
+	// Feature variant.
+	string m_sFeatureVariant;
+	// Feature variant name.
+	string m_sFeatureVariantName;
+	// Release path (releasables).
+	string m_sReleasePath;
+	// Full variant path (path to releasables).
+	string m_sFullVariantPath;
+	// String to store information of compile
+	string m_sCompileInfoText;
+	// String to store possible error messages.
+	string m_sErrors;
+	// Compile definition(s)
+	string m_sCompileDefinitions;
+	// Source files.
+	vector<SOURCE> m_vSources;
+	// Listing data.
+	vector<LINE_IN_FILE> m_vLineInFile;
+	// Modules map data (symbols).
+	vector<MAP_FUNC_INFO> m_vMapFileFuncList;
+	// S60 logging mode filename.
+	string m_sS60FileName;
+	// Is all data loaded for address to code line functions.
+	bool m_bAddressToLineInitialized;
+	// Read listing files (armv5 platform).
+	bool ReadListingFilesArmv5();
+	// Get listing file name of given source file.
+    string GetLstNameOfSource(string sSource) const;
+	// Copy listing files to temporary directory.
+	bool CopyLstFilesToTemp();
+	// Copy map file to temporary directory.
+	bool CopyMapFileToTemp();
+	// Get full map file name.
+	string GetMapFile() const;
+	// Get full symbol file name.
+	string GetSymbolFile() const;
+	// Get full binary file name.
+	string GetBinaryFile() const;
+	// Helper function to check is platform armv5.
+	bool IsPlatformArmv5() const;
+	// Get "unique" id of module
+	string GetUniqueId() const;
+	// Sbs v.1 variant urel label.
+	string m_sFeatureVariantURELLabel;
+	// Sbs v.1 variant udeb label.
+	string m_sFeatureVariantUDEBLabel;
+	// Object used to get codelines of memory addresses.
+	IAddressToLine* m_pAddressToLine;
+};
+#endif
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/CATParseTraceFile.h	Thu Feb 11 15:51:35 2010 +0200
@@ -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:  Definitions for class CATParseTrace.
+*
+*/
+
+
+#ifndef __CATPARSETRACEFILE_H__
+#define __CATPARSETRACEFILE_H__
+
+#include "../inc/ATCommonDefines.h"
+#include "../inc/CATDataSaver.h"
+#include "../inc/CATBase.h"
+#include "../inc/catallocs.h"
+
+/**
+* Class that parses trace data to data file.
+*/
+class CATParseTraceFile : public CATBase
+{
+public:
+	CATParseTraceFile();
+
+	/**
+	* 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 );
+
+	CATDataSaver* GetDataSaver(void);	
+
+#ifndef MODULE_TEST
+private:
+#endif
+	CATDataSaver m_DataSaver;
+};
+
+class CSubTestData : public CATAllocs
+{
+public:
+	bool bRunning;
+	vector<string> vData;
+	string sSubTestName;
+	string sStartTime;
+	string sEndTime;
+	string sSubTestStartHandleCount;
+	string sSubTestEndHandleCount;
+};
+
+class CProcessData : public CATAllocs
+{
+public:
+	bool bProcessOnGoing;
+	int iProcessID;
+	vector<string> vData;
+	vector<string> vHandleLeaks;
+	vector<CSubTestData> vSubTests;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/CATParseXML.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,47 @@
+/*
+* 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:  Declarations for the class CATParseXML.
+*
+*/
+
+
+#ifndef __CATPARSEXML_H__
+#define __CATPARSEXML_H__
+
+#include "../inc/ATCommonDefines.h"
+
+/**
+* CATParseXML is used to parse xml data.
+* @author
+*/
+class CATParseXML
+{
+public:
+	/**
+	* Constructor
+	*/
+	CATParseXML(void);
+	
+	/**
+    * Destructor
+    */
+	virtual ~CATParseXML(void);
+
+	/**
+	* Find epocroot path in xml file
+	* @param sourcePath Location of the xml file
+	*/
+	string GetEpocRootPathFromXML(const char* sourcePath);
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/CATProject.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,626 @@
+/*
+* 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:  Class representing a project.
+*
+*/
+
+
+#ifndef __CATPROJECT_H__
+#define __CATPROJECT_H__
+
+#include "ATCommonDefines.h"
+#include "CATBase.h"
+
+class CATModule2;
+class CATDatParser;
+
+// Raptor cmd and makefile constants used
+#define RAPTOR_CMD_BASE "sbs -b bld.inf  --makefile=atool_temp/build/make_build --config="
+#define RAPTOR_MAKEFILE "atool_temp\\build\\make_build.default"
+#define RAPTOR_MAKEFILE_LOG " --logfile=atool_temp\\build\\makefile.xml"
+#define RAPTOR_BUILD_LOG " --logfile=atool_temp\\build\\build.xml"
+#define RAPTOR_REALLYCLEAN_LOG " --logfile=atool_temp\\build\\reallyclean.xml"
+#define RAPTOR_BUILD_LOG_NAME "atool_temp\\build\\build.xml"
+#define RAPTOR_LISTING_LOG " --logfile=atool_temp\\build\\listing.xml"
+
+#define RAPTOR_NOBUILD_SWITCH " --nobuild"
+#define RAPTOR_MAKEFILE_SWITCH "--makefile=atool_temp/build/make_build"
+
+
+// Raptor makefile constant variable names
+#define RAPTOR_PROJECT_META "PROJECT_META:="
+#define RAPTOR_SOURCE "SOURCE:="
+#define RAPTOR_TARGET "TARGET:="
+#define RAPTOR_TARGETYPE "TARGETTYPE:="
+#define RAPTOR_REQUESTEDTARGETEXT "REQUESTEDTARGETEXT:="
+#define RAPTOR_VARIANTPLATFORM "VARIANTPLATFORM:="
+#define RAPTOR_VARIANTTYPE "VARIANTTYPE:="
+#define RAPTOR_FEATUREVARIANT "FEATUREVARIANT:="
+#define RAPTOR_FEATUREVARIANTNAME "FEATUREVARIANTNAME:="
+#define RAPTOR_RELEASEPATH "RELEASEPATH:="
+#define RAPTOR_FULLVARIANTPATH "FULLVARIANTPATH:="
+#define RAPTOR_COMPILE_DEFINITIONS "CDEFS:="
+
+// Sbs v.1 makefile constants.
+#define MAKEFILE_SEARCH_STRING "@perl -S checksource.pl"
+#define MMPFILE_SEARCH_STRING "PRJ_MMPFILES MMP"
+#define SOURCE_PATH "SOURCEPATH";
+#define SOURCE_STRING "SOURCE";
+#define TARGET_STRING "TARGET";
+
+/**
+* CATProject represents a project (collection of modules).
+* It has to be set mode in which it operates like
+* compile / analyze and necessary parameters for that.
+* Then call Run method which also returs error codes
+* defined in AT_ERROR_CODES enumeration.
+* @author
+*/
+class CATProject : public CATBase
+{
+public:
+	
+	/**
+	* Enumeration representing used build systems
+	*/
+	enum BUILD_SYSTEM {
+		SBS_V1 = 1,
+		SBS_V2 = 2
+	};
+
+	/**
+	* Enumeration representing the mode project is run.
+	*/
+	enum PROJECT_MODE {
+		COMPILE = 0,
+		INSTRUMENT = 1,
+		UNINSTRUMENT = 2,
+		UNINSTRUMENT_FAILED =3,
+		FAILED = 4,
+		CLEAN = 5,
+		ANALYZE = 6,
+		INSTRUMENT_CONSOLE = 7,
+		UNINSTRUMENT_CONSOLE = 8,
+		FAILED_CONSOLE = 9,
+		NOT_DEFINED = 10
+	};
+
+	/**
+	* Enumeration repserenting the logging mode.
+	*/
+	enum LOGGING_MODE {
+		DEFAULT = 0,
+		S60 = 1,
+		XTI = 2,
+		XTI_FAST = 3
+	};
+
+	/**
+	* Enumeration representing build type.
+	*/
+	enum BUILD_TYPE {
+		UREL = 0,
+		UDEB = 1
+	};
+
+public:
+
+	/**
+	* Constructor
+	*/
+	CATProject();
+
+	/**
+	* Destructor
+	*/
+	~CATProject();
+
+	/**
+	* Set arguments.
+	* @param arguments.
+	* @return true if arguments ok.
+	*/
+	bool SetArguments( ARGUMENTS& arguments );
+
+	/**
+	* Set build system to be used with project.
+	* See BUILD_SYSTEM enumeration for available systems.
+	* @param eSystem system.
+	*/
+	void SetBuildSystem( BUILD_SYSTEM eSystem );
+
+	/**
+	* Set mode which to run.
+	* See PROJECT_MODE enumeration for available modes.
+	* @param eMode mode.
+	*/
+	void SetMode(PROJECT_MODE eMode);
+
+	/**
+	* Get project mode.
+	* @return mode of project.
+	*/
+	int GetMode() const;
+
+	/**
+	* Set epocroot.
+	* @param sEpocroot
+	*/
+	void SetEpocRoot( const string& sEpocRoot );
+
+	/**
+	* Set project platform.
+	* @param sPlatform platform.
+	*/
+	void SetPlatform( const string& sPlatform );
+
+	/**
+	* Set variant.
+	* @sVariant variant.
+	*/
+	void SetVariant( const string& sVariant );
+
+	/**
+	* Set logging mode. See LOGGING_MODE enumeration for available modes.
+	* @param eLogginMode logging mode.
+	*/
+	void SetLoggingMode( LOGGING_MODE eLoggingMode);
+
+	/**
+	* Set build type. See BUILD_TYPE enumeration for available types.
+	* @param eType build type.
+	*/
+	void SetBuildType( BUILD_TYPE eType );
+	
+	/**
+	* Set S60 logging filename.
+	* @param sFileName filename.
+	*/
+	void SetS60FileName( const string& sFileName);
+
+	/**
+	* Set target module.
+	* @param sTargetModule target module name.
+	*/
+	void SetTargetModule( const string& sTargetModule );
+
+	/**
+	* Set multiple target modules used in project.
+	* @param vTargetModules target module names.
+	*/
+	void SetTargetModules( const vector<string>& vTargetModules );
+
+	/**
+	* Set Binary target name to create analysis results to.
+	* @param sBinaryTarget binary target name.
+	*/
+	void SetBinaryTarget( const string& sBinaryTarget );
+
+	/**
+	* Set data file to analyze.
+	* @param sDataFile datafile.
+	*/
+	void SetDataFile( const string& sDataFile );
+
+	/**
+	* Set rom symbol file(s) used in analyze.
+	* @param sRomSymbolFile.
+	*/
+	void SetRomSymbolFiles(const vector<string>& vRomSymbolFiles);
+
+	/**
+	* Set the logging level of analysis report.
+	* @param iLogLevel log level.
+	*/
+	void SetLogLevel( int iLogLevel );
+
+	/**
+	* Set the size of allocation call stack to be written in temporary cpp.
+	* @param iAllocCallStackSize
+	*/
+	void SetAllocCallStackSize( int iAllocCallStackSize );
+
+	/**
+	* Set the size of free call stack to be written in temporary cpp.
+	* @param iFreeCallStackSize
+	*/
+	void SetFreeCallStackSize( int iFreeCallStackSize );
+
+	/**
+	* Set the output file name to store analyse report.
+	* @param sDataFileOutput data file name.
+	*/
+	void SetDataFileOutput( const string& sDataFileOutput );
+
+	/**
+	* Set build command used in compile phase.
+	* @param sBuildCommand build command.
+	*/
+	void SetBuildCommand( const string& sBuildCommand );
+
+	/**
+	* Run the set mode.
+	* @return error code.
+	*/
+	int Run();
+
+	/**
+	* Run recovery, used when "instatly" need to recover modules and exit.
+	*/
+	int RunRecoveryAndExit();
+
+	/**
+	* Get build type string.
+	* @param eType type from which to get correponding string.
+	* @return types corresponding string.
+	*/
+	static string GetBuildTypeString( int eType );
+
+	/**
+	* Reads projects configuration file if it exists.
+	* @return false in case the data contains information that project is uninstrumented. Otherwise returns always true.
+	*/
+	bool IsUninstrumented();
+
+#ifndef MODULE_TEST
+private:
+#endif
+	/**
+	* Run compiling in console.
+	* @return error code.
+	*/
+	int RunCompile( void );
+
+	/**
+	* Run cleaning project.
+	* @return error code.
+	*/
+	int RunClean( void );
+
+	/**
+	* Run running analyze.
+	* @return error code.
+	*/
+	int RunAnalyze( void );
+
+	/**
+    * Run instrumenting of project for Carbide extension (pre-build).
+	* @return error code.
+	*/
+	int RunInstrument( void );
+
+	/**
+	* Run uninstrumenting of project for Carbide extension (post-build).
+	* @return error code.
+	*/
+	int RunUninstrument( void );
+
+	/**
+	* Run uninstrumenting of project for Carbide extension(post-build), when build failed.
+	* @return error code.
+	*/
+	int RunUninstrumentFailed( void );
+
+	/**
+	* Run console instrumenting.
+	* @return error code.
+	*/
+	int RunInstrumentConsole( void );
+
+	/**
+	* Run Console uninstrumenting.
+	* @return error code.
+	*/
+	int RunUninstrumentConsole( void );
+
+	/**
+	* Run console uninstrumenting, when build failed.
+	* @return error code.
+	*/
+	int RunFailedConsole( void );
+
+	/**
+	* Show summary of compilation.
+	*/
+	void DisplayCompileSummary( void );
+
+	/**
+	* Show summary, build target, build type, logging mode...
+	*/
+	void DisplayBuildSummary( void );
+
+	/**
+	* Create make files.
+	* @return true if successful
+	*/
+	bool CreateMakeFile( void );
+	/**
+	* Create SBS v.1 make files.
+	* @return true if successful.
+	*/
+	bool CreateMakeFileSbs1( void );
+	/**
+	* Copy sbs1 makefile to temporary folder.
+	* @return true if successful.
+	*/
+	bool CopyMakeFileSbs1ToTemporaryFolder( void );
+	/**
+	* Run really clean in SBS v.1.
+	* @return true if successful.
+	*/
+	bool RunReallyCleanSbs1( void );
+	/**
+	* Run really clean in SBS v.2.
+	* @return true if successful.
+	*/
+	bool RunReallyCleanSbs2( void );
+	/**
+	* Run export in SBS v.1.
+	* @return true if successful.
+	*/
+	bool RunExportSbs1( void );
+	/**
+	* Create make files (level2) SBS v.1.
+	* @return true if successful.
+	*/
+	bool CreateMakeFileSbs1Level2( void );
+	/**
+	* Create makefile SBS v.2.
+	* @return true if successful.
+	*/
+	bool CreateMakeFileSbs2( void );
+	/**
+	* Read makefile.
+	* @return true if successful.
+	*/
+	bool ReadMakeFile( void );
+	/**
+	* Read SBS v.1 makefile.
+	* @return true if successful.
+	*/
+	bool ReadMakeFileSbs1( void );
+	/**
+	* Read SBS v.1 makefile (Level1).
+	* @return true if successful.
+	*/
+	bool ReadMakeFileSbs1Level1( void );
+	/**
+	* Read SBS v.2 makefiles.
+	* @return true if successful.
+	*/
+	bool ReadMakeFileSbs2( void );
+	/**
+	* Read specified SBS v.2 makefile.
+	* @param sMakeFile makefile to be read.
+	* @return true if succesful.
+	*/
+	bool ReadMakeFileSbs2( string& sMakeFile );
+
+	/**
+	* Filter unsupported and static libraries to their own vectors.
+	* Unsupported include kernel types, modules with kernel mode compile definition.
+	* @return true if successful.
+	*/
+	bool FilterModules();
+
+	/**
+	* Creates temporary directories for all modules
+	* in member vector.
+	* @return true if successful.
+	*/
+	bool CreateTemporaryDirectories();
+
+	/**
+	* Creates tempororary cpp files for all modules
+	* in member vector.
+	* @return true if successful.
+	*/
+	bool CreateTemporaryCpps();
+
+	/**
+	* Hooks all modules in member vector
+	* (modifies mmp files)
+	* @return true if successful
+	*/
+	bool ModifyModules( void );
+
+	/**
+	* Unhooks all modules in member vector
+	* (removes changes from mmp files)
+	* @return true if successful
+	*/
+	bool RestoreModules( void );
+
+	/**
+	* Verifys that member vectors modules
+	* mmp files unchanged. Restores if they are
+	* from backup or from original.
+	* @return true if successful
+	*/
+	bool VerifyAndRecoverModules( void );
+
+	/**
+	* Runs compilation.
+	* @return true if successful.
+	*/
+	bool Compile( void );
+	/**
+	* @return true if successful.
+	*/
+	bool CompileSbs1( void );
+	/**
+	* @return true if successful.
+	*/
+	bool CompileSbs2( void );
+
+	/**
+	* Runs listing creatation.
+	* @return true if successful
+	*/
+	bool CreateListings( void );
+	/**
+	* @return true if successful.
+	*/
+	bool CreateListingsSbs1( void );
+	/**
+	* @return true if successful.
+	*/
+	bool CreateListingsSbs2( void );
+	/**
+	* Copies releasables of modules including lst & map files
+	* for all modules in project to their temporary directories.
+	* @return true if successful.
+	*/
+	bool CopyReleasables( void );
+	/**
+	* Deletes all atool_temp directories
+	* of member vector modules.
+	* @return true if successful.
+	*/
+	bool DeleteTemporaryDirs( void );
+	/**
+	* Deletes files from atool_temp directory
+	* of member vector modules which extension not defined
+	* in TEMP_EXTENSION_NO_DELETE table.
+	* @return true if successful.
+	*/
+	bool CleanTemporaryDirs( void );
+	/**
+	* Writes class attributes to a file
+	* under atool_temp directory.
+	* @return true if successful.
+	*/
+	bool WriteAttributes( void ) const;
+	/**
+	* Read class attributes from a file
+	* under atool_temp directory.
+	* @return true if successful.
+	*/
+	bool ReadAttributes( void );
+
+	/**
+	* Creates atool_temp directory if it does not
+	* exist in current directory.
+	* @return true if successful.
+	*/
+	bool MakeTempDirIfNotExist( void );
+
+#ifndef MODULE_TEST
+private:
+#endif
+
+	/**
+	* Clean all module vectors.
+	*/
+	void CleanModuleVectors();
+
+	/**
+	* Get build type as string.
+	* @return buildtype string.
+	*/
+	string GetBuildTypeString();
+
+	/**
+	* Helper function to add target module(s)
+	* if any defined in class to given sbs command.
+	* @param sCmd command to add modules to.
+	*/
+	void AddTargetModuleIfDefined(string& sCmd);
+
+	/**
+	* Run given system/abld command to all defined target modules in vector.
+	* Space char (if its missing) will be added to given command + one target
+	* module at a time.
+	* @param sCommand sCommand to run.
+	* @return true if none system call sets error level other than 0.
+	*/
+	bool RunAbldCommandToAllTargets( const string& sCommand );
+
+	/**
+	* Check is target module in project.
+	* If no modules / targets defined return value is true.
+	* @return true if target module is in project.
+	*/
+	bool IsTargetModuleInProject( void ) const;
+
+	/**
+	* Initializes member make file variable with correct full path to point (epoc32/build)...
+	* @return true if successful.
+	*/
+	bool InitSbs1MakeFileWithPath();
+
+	/**
+	* Initializes member make file variable with correct full path to (atoo_temp...)
+	* @return true if successful.
+	*/
+	bool InitSbs1MakeFileWithPathToTemp();
+
+#ifndef MODULE_TEST
+private:
+#endif
+	// System current directory.
+	char m_cCurrentDir[ MAX_LINE_LENGTH ];
+	// Projects build system
+	int m_eBuildSystem;
+	// Project modules.
+	vector<CATModule2*> m_vModules;
+	// Static libraries.
+	vector<CATModule2*> m_vStaticLibraries;
+	// Unsupported project modules.
+	vector<CATModule2*> m_vUnsupportedModules;
+	// Run mode.
+	int m_eMode;
+	// Logging level (used in analyse).
+	int m_iLoggingLevel;
+	// Is project unsinstrumented.
+	bool m_bUninstrumented;
+	// Build command.
+	string m_sBuildCommand;
+	// Epocroot
+	string m_sEpocRoot;
+	// Platform i.e. armv5.
+	string m_sPlatform;
+	// SBS2 variant.
+	string m_sVariant;
+	// Logging mode (used in compile,instrumenting).
+	int m_eLoggingMode;
+	// Allocation call stack size
+	int m_iAllocCallStackSize;
+	// Free call stack size
+	int m_iFreeCallStackSize;
+	// Build type udeb / urel.
+	int m_eBuildType;
+	// Sbs v.1 level 1 make file
+	string m_sMakeFile;
+	// User given S60 log file name.
+	string m_sS60FileName;
+	// Target module.
+	string m_sTargetModule;
+	// Target modules (used in carbide instrumenting).
+	vector<string> m_vTargetModules;
+	// Binary target (used in analyse).
+	string m_sBinaryTarget;
+	// User given datafile to analyse.
+	string m_sDataFile;
+	//
+	vector<string> m_vRomSymbolFiles;
+	// Temporary data file name if user gave trace file.
+	string m_sDataFileTemp;
+	// User given output file to store analyse results.
+	string m_sDataFileOutput;
+	// Analyser object.
+	CATDatParser* m_pAnalyzer;
+};
+#endif
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/cataddr2line.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,124 @@
+/*
+* 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:  Windows debug api implementation for IAddressToLine interface.
+*
+*/
+
+#ifndef __CATADDR2LINE_H__
+#define __CATADDR2LINE_H__
+
+#include "iaddresstoline.h"
+#include "../inc/cataddr2lineserver.h"
+
+// Allowed characters in output.
+//const char ADDR2LINEALLOWEDCHARS[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :/\\_.-";
+
+class CATAddr2line : public IAddressToLine
+{
+
+public:
+	
+	/**
+	* Constructor
+	*/
+	CATAddr2line();
+
+	/**
+	* Open binary.
+	* @sString Full filename with path to binary.
+	* @iLong base address of binary.
+	* @return true if successful.
+	*/
+	bool Open( const string& sString, const unsigned long iLong);
+
+	/**
+	* Get error string. In case of any method failed use this to acquire details on error.
+	* @return error string.
+	*/
+	string GetError( void );
+
+	/**
+	* Close binary.
+	* @return true if succesful.
+	*/
+	bool Close( void );
+
+	/**
+	* Locate code line and file for given address.
+	* @result
+	* @return true if successful.
+	*/
+	bool AddressToLine( CATMemoryAddress* result );
+
+#ifndef MODULE_TEST
+private:
+#endif
+
+	// Modules map data (symbols).
+	vector<MAP_FUNC_INFO> m_vMapFileFuncList;
+
+	//Map file name
+	string m_sMapFileName;
+
+	//Addr2line server class
+	CATAddr2lineServer server;
+
+	/**
+	* Get function name for given address.
+	* @iAddress Memory address as unsigned long.
+	* @return Function name as string or empty string if not found.
+	*/
+	string GetFunctionNameUsingAddress( unsigned long iAddress );
+
+	/**
+	* Read map file (armv5 platform).
+	* @return true if map file read successfully.
+	*/
+	bool ReadMapFileArmv5();
+
+	//Note: New filtering functions commented out until they are taken into use.
+	/**
+	* Filter any char not defined in constant
+	* ADDR2LINEALLOWEDCHARS from given string.
+	* @param sString string to be filtered.
+	*/
+	//void FilterString( string &sString );
+
+	/**
+	* Find first occurence of LF/CR from string.
+	* @param sString string to find LF/CR.
+	* @return position of first occurence.
+	*/
+	//size_t FindLineFeed( const string& sString );
+
+	/**
+	* Erase all LF/CR from start of the string until other
+	* characters are found.
+	* @param sString string to erase LF/CR.
+	*/
+	//void EraseUntilNoLineFeed( string& sString );
+
+	/**
+	* Split string containing multiple lines with mixed line feeds to
+	* vector of lines.
+	* @sMultiLineString string containing multiple lines.
+	* @return vector containing one line per cell.
+	*/
+	//vector<string> SplitToStrings( string& sMultiLineString );
+	
+	//Debugging for addr2line task.
+	//ofstream debug;
+};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/cataddr2lineserver.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,89 @@
+/*
+* 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:  Class representing a server that uses addr2line.exe.
+*
+*/
+
+#ifndef __CATADDR2LINESERVER_H__
+#define __CATADDR2LINESERVER_H__
+
+// Includes.
+#include "ATCommonDefines.h"
+
+#define BUFSIZE 4096
+ 
+class CATAddr2lineServer
+{
+public:
+
+	//Creator
+	CATAddr2lineServer();
+	
+	//Destructor
+	~CATAddr2lineServer();
+
+	/**
+	* Get function name for given address.
+	* @sFullPathAndBinaryName
+	* @return True if initialization succesfull.
+	*/
+	bool Initialize( const string& sFullPathAndBinaryName );
+
+	/**
+	* Write data to a pipe.
+	* @sAddress
+	*/
+	VOID WriteToPipe( const string& sAddress );
+
+	/**
+	* Read data to a pipe.
+	* @return Data from pipe.
+	*/
+	string ReadFromPipe(VOID);
+
+	/**
+	* Gets process created state.
+	* @return True if process created successfully.
+	*/
+	bool GetProcessCreatedState( void );
+
+#ifndef MODULE_TEST
+private:
+#endif
+
+	HANDLE m_hChildStdinRd, m_hChildStdinWr, m_hChildStdinWrDup, 
+	       m_hChildStdoutRd, m_hChildStdoutWr, m_hChildStdoutRdDup, 
+	       m_hChildErroutRd, m_hChildErroutWr, m_hChildErroutRdDup, 
+           m_hSaveStdin, m_hSaveStdout, m_hSaveErrout; 
+
+    SECURITY_ATTRIBUTES m_saAttr;
+    string m_sFullPathAndBinaryName;
+	bool m_bProcessCreated;
+
+	/**
+	* Creates child process for addr2line.exe.
+	* @return True if process created successfully.
+	*/
+	BOOL CreateChildProcess(VOID); 
+
+	/**
+	* Prints error and returns false.
+	* @param sInput error string.
+	* @return false.
+	*/
+	bool PrintErrorAndExit( const string sInput );
+
+
+};
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/catalloc.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,54 @@
+/*
+* 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: Class representing memory allocation in
+*               external data gathering.
+*
+*/
+
+
+#ifndef __CATALLOC_H__
+#define __CATALLOC_H__
+
+#include "../inc/ATCommonDefines.h"
+
+class CATAlloc
+{
+public:
+	/**
+	* Constructor.
+	*/
+	CATAlloc() : m_iCSCount(0) {}
+
+	/**
+	* Destructor.
+	*/
+	~CATAlloc(){}
+
+	// Allocation time.
+	string m_sTime;
+
+	// Allocation size.
+	string m_sSize;
+
+	// Call stack address count.
+	unsigned long m_iCSCount;
+
+	// Call stack where packet number is key.
+	map<unsigned long,string> m_vCallStack;
+
+	// Get alloc string after address ( time, size, call stack).
+	string GetAllocString( void );
+};
+#endif
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/catallocs.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,85 @@
+/*
+* 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: Class representing collection of memory allocations
+*              in external data gathering.
+*/
+
+#ifndef __CATALLOCS_H__
+#define __CATALLOCS_H__
+
+#include "../inc/ATCommonDefines.h"
+#include "../inc/CATBase.h"
+#include "../inc/catalloc.h"
+
+// Memory allocates and frees handling class.
+class CATAllocs : public CATBase
+{
+public:
+	
+	/**
+	* "old" alloc message (prior to 1.6).
+	* @param sAllocString allocation string.
+	*/
+	void Alloc( const string& sAllocString );
+
+	/*
+	* Alloc header message (multimessage call stack).
+	* @param sAllocHString allocation string.
+	*/
+	void AllocH( const string& sAllocHString );
+
+	/*
+	* Alloc fragment message (fragment of call stack in multimessage alloc).
+	* @param sAllocFString allocation string.
+	*/
+	void AllocF( const string& sAllocFString );
+
+	/**
+	* Free message.
+	* @param sFreeString string.
+	*/
+	void Free( const string& sFreeString );
+	
+	/**
+	* Free header message.
+	* (not implemented yeat.)
+	* @param sFreeHString string.
+	*/
+	void FreeH( const string& sFreeHString );
+
+	/**
+	* Free fragment message.
+	* (not implemented yeat.)
+	* @param sFreeFString string.
+	*/
+	void FreeF( const string& sFreeFString );
+
+	/**
+	* Get "leak" list ordered by allocation time.
+	* @param vLeaklist container where leaks stored.
+	*/
+	void GetLeakList( vector<string>& vLeakList);
+	
+	/**
+	* Clear leaks.
+	*/
+	void ClearAllocs( void );
+#ifndef MODULE_TEST
+private:
+#endif
+	// Allocation storage.
+	map<string, CATAlloc> m_vAllocs;
+};
+#endif
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/catdbghelper.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,93 @@
+/*
+* 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:  Windows debug api implementation for IAddressToLine interface.
+*
+*/
+
+
+#include "iaddresstoline.h"
+// Static variable to represent state of dbghelper api.
+static bool CDBGHELPER_OPEN = false;
+static unsigned int CDBGHELPER_CLIENTS = 0;
+
+// Used "virtual" offset for all loaded modules and addresses.
+// This is used so no module is loaded to the binary address range of atool.exe.
+const unsigned long AT_VIRTUAL_OFFSET_DBGHELPER = 0x1000000;
+
+class CATDbgHelper : public IAddressToLine
+{
+
+public:
+	
+	/**
+	* Constructor
+	*/
+	CATDbgHelper();
+	
+	/**
+	* Destructor
+	*/
+	~CATDbgHelper();
+
+	/**
+	* Open binary.
+	* @sString Full filename with path to binary.
+	* @iLong base address of binary.
+	* @return true if successful.
+	*/
+	bool Open( const string& sString, const unsigned long iLong);
+	
+	/**
+	* Get error string. In case of any method failed use this to acquire details on error.
+	* @return error string.
+	*/
+	string GetError( void );
+
+	/**
+	* Close binary.
+	* @return true if succesful.
+	*/
+	bool Close( void );
+
+	/**
+	* Read map file for function's.
+	*/
+	void ReadMapFile( const string sMapFileName );
+
+	/**
+	* Locate code line and file for given address.
+	* @result
+	* @return true if successful.
+	*/
+	bool AddressToLine( CATMemoryAddress* result );
+
+	/**
+	* Try get function name for address (only when map is read).
+	* @result
+	* @return true if succesful.
+	*/
+	bool AddressToFunction( CATMemoryAddress* result );
+
+#ifndef MODULE_TEST
+private:
+#endif
+	// Base address used.
+	DWORD64 m_BaseAddress;
+	// Map file read?
+	bool m_bMap;
+	// Map file functions.
+	vector<MAP_FUNC_INFO> m_vMapFileFuncList;
+	// Binary in file system.
+	PSTR m_pBinaryFile;
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/catfilereader.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,80 @@
+/*
+* 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:  Class used to read text files iterating lines.
+*
+*/
+
+
+#ifndef __CATFILEREADER_H__
+#define __CATFILEREADER_H__
+
+#include "ATCommonDefines.h"
+
+class CATFileReader
+{
+public:
+	/**
+	* Constructor.
+	*/
+	CATFileReader();
+	/**
+	* Destructor.
+	*/
+	~CATFileReader();
+#ifndef MODULE_TEST
+private:
+#endif
+	/**
+	* Prevent copy of this class.
+	*/
+	CATFileReader& operator =( const CATFileReader& /*other*/ ) { }
+	CATFileReader( const CATFileReader& /*other*/ ) { }
+public:
+	/**
+	* Open/Read file.
+	* @param cFile file to be read/opened.
+	* @return true if succesful.
+	*/
+	bool Open( const char* cFile );
+	/**
+	* Close file.
+	* @return true if succesful.
+	*/
+	bool Close( void );
+	/**
+	* Get line from file.
+	* @sLine where line content is stored.
+	* @return true if lines left.
+	*/
+	bool GetLine( string& sLine );
+	/**
+	* Set the line delimiter.
+	* @param cDelimiter char that ends the line.
+	*/
+	void SetDelimiter( char cDelimiter );
+	/**
+	* Get current line delimiter.
+	* @return char that ends the line.
+	*/
+	char GetDelimiter() const;
+#ifndef MODULE_TEST
+private:
+#endif
+	// Stream where file content is stored.
+	stringstream m_stream;
+	// Line delimiting character used.
+	char m_cDelimiter;
+};
+#endif
+// EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/catromsymbol.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,146 @@
+/*
+* 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:  Locates symbols/functions for memory addresses
+*               which are located in given rom/rofs symbol file.
+*
+*/
+
+
+#ifndef __CATROMSYMBOL_H__
+#define __CATROMSYMBOL_H__
+
+#include "ATCommonDefines.h"
+#include "iaddresstoline.h"
+
+const string ROM_SYMBOL_IDENTIFY_STRING = "80";
+const string ROFS_SYMBOL_IDENTIFY_STRING = "00";
+const int IDENTIFY_MAX_LINES_READ = 20;
+
+// Symbol structure.
+struct Symbol
+{
+	// Start address.
+	unsigned long iStartAddress;
+	// End address.
+	unsigned long iEndAddress;
+	// Function/Symbol name.
+	string sFunction;
+	// Default constructor for structure.
+	Symbol() { iStartAddress=0; iEndAddress=0; sFunction = ""; }
+	~Symbol() {}
+};
+
+// Rofs binary item class
+class RofsBinary {
+public:
+	string m_sBinary;
+	vector<Symbol*> vSymbols;
+	RofsBinary();
+	RofsBinary( const string& sbinary );
+	~RofsBinary();
+};
+
+
+class CATRomSymbol : public IAddressToLine
+{
+public:
+	/**
+	* Constructor.
+	*/
+	CATRomSymbol();
+	/**
+	* Destructor.
+	*/
+	virtual ~CATRomSymbol();
+	/**
+	* "Flag" will we show progress when reading files.
+	*/
+	bool m_bShowProgressMessages;
+	/**
+	* Empty functions does nothing returns false always.
+	* @return true if successful.
+	*/
+	bool Open( const string& sString, const unsigned long iLong);
+	/**
+	* Set symbol files.
+	* This also checks that files exists and identifies them as rom/rofs.
+	* @vSymbols.
+	*/
+	bool SetSymbols( const vector<string>& vSymbols);
+	/**
+	* Get error string. In case of any method failed use this to acquire details on error.
+	* @return error string.
+	*/
+	string GetError( void );
+	/**
+	* Close rom symbol file.
+	* @return true if succesful.
+	*/
+	bool Close( void );
+	/**
+	* Locates symbol and binary name for given address if found in rom.
+	* @result memory address object.
+	* @return true if successful.
+	*/
+	bool AddressToLine( CATMemoryAddress* result );
+#ifndef MODULE_TEST
+private:
+#endif
+	enum SYMBOL_FILE_TYPE {
+		SYMBOL_FILE_INVALID = 0,
+		SYMBOL_FILE_ROM,
+		SYMBOL_FILE_ROFS
+	};
+	// Identify symbol file
+	int IdentifySymbolFile( const string& sFile );
+	// Locate symbol and binary name for given address if found in rom.
+	bool AddressToLineRom( CATMemoryAddress* result );
+	// Locate symbol and binary name for given address if found in rofs.
+	bool AddressToLineRofs( CATMemoryAddress* result );
+	// Reads rom file.
+	bool ReadRomFiles();
+	bool ReadRomFile( const string& sFile );
+	// Read rofs file.
+	bool ReadRofsFiles();
+	bool ReadRofsFile( const string& sFile );
+	// Parse symbol from a line in rom/rofs file.
+	void ParseSymbolFromLine( const string& sLine, Symbol* pSymbol );
+#ifndef MODULE_TEST
+private:
+#endif
+	// Have we identified symbol file(s).
+	bool m_bFilesIdentified;
+	// Have we read symbol file(s).
+	bool m_bSymbolsRead;
+
+	// Rom symbol file(s).
+	vector<string> m_vRomFiles;
+	// Cached rom symbols.
+	vector<Symbol*> m_vRomCache;
+	// All rom symbols.
+	vector<Symbol*> m_vRomSymbols;
+	// Rom start address.
+	unsigned long m_iRomStartAddress;
+	// Rom end address.
+	unsigned long m_iRomEndAddress;
+
+	// Rofs symbol file(s)
+	vector<string> m_vRofsFiles;
+	// Rofs binaries
+	vector<RofsBinary*> m_vRofsBinaries;
+
+	// Error message.
+	string m_sErrorMessage;
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/iaddresstoline.h	Thu Feb 11 15:51:35 2010 +0200
@@ -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:  Interface definition for locating code lines using memory addresses.
+*
+*/
+#ifndef __IADDRESSTOLINE_H__
+#define __IADDRESSTOLINE_H__
+
+#include "ATCommonDefines.h"
+
+class CATMemoryAddress;
+
+class IAddressToLine
+{
+public:
+	IAddressToLine() {};
+	virtual ~IAddressToLine() {};
+	/**
+	* Open binary.
+	* @sString
+	* @iNumber
+	* @return true if successful.
+	*/
+	virtual bool Open( const string& sString, const unsigned long iLong) = 0;
+	
+	/**
+	* Get error string. In case of any method failed use this to acquire details on error.
+	* @return error string.
+	*/
+	virtual string GetError( void ) = 0;
+
+	/**
+	* Close binary.
+	* @return true if succesful.
+	*/
+	virtual bool Close( void ) = 0;
+
+	/**
+	* Locate code line and file for given address.
+	* @result
+	* @return true if successful.
+	*/
+	virtual bool AddressToLine( CATMemoryAddress* result ) = 0;
+};
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/inc/stdafx.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2008 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 file for standard system include files,
+*                or project specific include files that are used frequently, but
+*                are changed infrequently.
+*  Version     : %version: % 
+*
+*/
+
+
+#pragma once
+
+// MemoryLeak checking function.
+// Note! Do not comming in svn with this flag enabled.
+//#define MEM_LEAK_CHECK
+
+// Compile with HTI functions.
+//#define HTI_SUPPORT
+
+// Addr2line binary used.
+//#define ADDR2LINE
+
+#ifdef MEM_LEAK_CHECK
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h>
+#include <crtdbg.h>
+#endif
+
+#include <tchar.h>
+#include <fstream>   //ifstream,ofstream
+#include <windows.h>
+#include <string>    //string
+#include <vector>    //string
+#include <sstream>   //stringstream
+#include <iostream>  // cout
+#include <map> // map
+#include <time.h>
\ No newline at end of file
Binary file memana/analyzetoolclient/commandlineengine/internal/lib/xerces-c_2.lib has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/CATBase.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,1245 @@
+/*
+* 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 CATBase.
+*
+*/
+
+
+#include "../inc/CATBase.h"
+#include "../inc/CATParseXML.h"
+
+// -----------------------------------------------------------------------------
+// CATBase::CATBase
+// Constructor.
+// -----------------------------------------------------------------------------
+CATBase::CATBase(void)
+{
+	LOG_FUNC_ENTRY("CATBase::CATBase");
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::~CATBase
+// Destructor.
+// -----------------------------------------------------------------------------
+CATBase::~CATBase(void)
+{
+	LOG_FUNC_ENTRY("CATBase::~CATBase");
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::ChangeToLower
+// Converts any uppercase letter to lowercase.
+// -----------------------------------------------------------------------------
+void CATBase::ChangeToLower( string& sInput )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::ChangeToLower");
+	int iLength = (int)sInput.size();
+	for( int i = 0 ; i < iLength ; i++ )
+	{
+		sInput[i] = (char)tolower( sInput[i] );
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::ChangeToUpper
+// Converts any uppercase letter to lowercase.
+// -----------------------------------------------------------------------------
+void CATBase::ChangeToUpper( string& sInput )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::ChangeToUpper");
+	int iLength = (int)sInput.size();
+	for( int i = 0 ; i < iLength ; i++ )
+	{
+		sInput[i] = (char)toupper( sInput[i] );
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::TrimString
+// Remove spaces and tabulatures from beginning and
+// end of given string.
+// -----------------------------------------------------------------------------
+void CATBase::TrimString( string& sInput )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::TrimString");
+	if( sInput.empty() )
+		return;
+	//Remove spaces and tabulatures from beginning of string
+	while( !sInput.empty() && ( sInput[0] == SPACE_CHAR_VALUE || sInput[0] == TAB_CHAR_VALUE ) )
+	{
+		sInput.erase( 0, 1 );
+	}
+	//Remove spaces and tabulatures from end of string
+	while( !sInput.empty() && ( sInput[sInput.size()-1] == SPACE_CHAR_VALUE || sInput[sInput.size()-1] == TAB_CHAR_VALUE ) )
+	{
+		sInput.erase( sInput.size()-1, 1 );
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::SearchFileWithExtension
+// Searches files with given extension from path.
+// -----------------------------------------------------------------------------
+bool CATBase::SearchFileWithExtension( const char* pPathAndExt, bool bPrintErrors, string& sErrorLog )
+{
+	LOG_FUNC_ENTRY("CATBase::SearchFileWithExtension");
+	WIN32_FIND_DATA FindFileData;
+	HANDLE hFind;
+	string sTemp( pPathAndExt );
+
+	//Find file
+	hFind = FindFirstFile( sTemp.c_str(), &FindFileData );
+	if (hFind == INVALID_HANDLE_VALUE)
+	{
+		string sErrorString( "No " );
+		//Get extension
+		string sExt( pPathAndExt );
+		sExt.erase( 0, sExt.find_last_of( "." ) );
+
+		sErrorString.append( sExt );
+		sErrorString.append( " files in directory: " );
+
+		string sWithoutExt( pPathAndExt );
+		sWithoutExt.erase( sWithoutExt.find_last_of( "." )-1, string::npos );
+		sErrorString.append( sWithoutExt );
+
+		if( bPrintErrors )
+		{
+			//string sTemp( pPathAndExt );
+			//printf( "Can not find: %s.\n", pPathAndExt );
+			printf( sErrorString.c_str() );
+		}
+		else
+		{
+			//Add line change if sErrorString not empty
+			if( !sErrorLog.empty() )
+				sErrorString.insert( 0, "\n" );
+			sErrorLog.append( sErrorString );
+		}
+		return false;
+	} 
+	else 
+	{
+		FindClose(hFind);
+		return true;
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::GetPathOrFileName
+// Returns path to file or file name.
+// -----------------------------------------------------------------------------
+string CATBase::GetPathOrFileName( bool bFileName, string sInput )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::GetPathOrFileName");
+	string sRet;
+	size_t iPos = sInput.size();
+
+	sInput = ChangeSlashToBackSlash( sInput );
+
+	//Find character '\' starting from end of string
+	while( iPos > 0 && sInput[iPos] != '\\' )
+	{
+		iPos--;
+	}
+	if( iPos > 0 )
+	{
+		//Return file name
+		if( bFileName )
+		{
+			sInput.erase( 0, iPos+1 );
+			sRet = sInput;
+		}
+		else //Return file path
+		{
+			sInput.erase( iPos+1, string::npos );
+			sRet = sInput;
+		}
+	}
+	else
+	{
+		if( !bFileName )
+			return sRet;
+		sRet = sInput;
+	}
+	return sRet;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::GetFileNameUsingExt
+// Searches files with given extension from path.
+// -----------------------------------------------------------------------------
+string CATBase::GetFileNameUsingExt( const char* pPathAndExt )
+{
+	LOG_FUNC_ENTRY("CATBase::GetFileNameUsingExt");
+	WIN32_FIND_DATA FindFileData;
+	HANDLE hFind;
+	string sRet;
+
+	//Find file
+	hFind = FindFirstFile( pPathAndExt, &FindFileData );
+	if (hFind == INVALID_HANDLE_VALUE)
+	{
+		//if( bPrintErrors )
+		printf( "Can not find: %s.\n", pPathAndExt );
+		return sRet;
+	} 
+	else 
+	{
+		sRet.append( FindFileData.cFileName );
+		FindClose(hFind);
+		return sRet;
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::GetStringUntilNextSpace
+// Function returns string from begin of given string until next space,
+// characters until next space are removed from sInput string.
+// -----------------------------------------------------------------------------
+string CATBase::GetStringUntilNextSpace( string& sInput, bool bEraseFromInput )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::GetStringUntilNextSpace");
+	string sTemp( sInput );
+	size_t iSize = sTemp.find_first_of(' ');
+	if( iSize != string::npos )
+	{
+		sTemp.resize( iSize );
+		if( bEraseFromInput )
+			sInput.erase( 0, (iSize+1) );
+	}
+	else
+	{
+		if ( bEraseFromInput )
+			sInput.clear();
+	}
+	return sTemp;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::ChangeSlashToBackSlash
+// Function changes all BackSlash characters to Slash character from
+// given string.
+// -----------------------------------------------------------------------------
+string CATBase::ChangeSlashToBackSlash( string sInput )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::ChangeSlashToBackSlash");
+	for( unsigned int i = 0 ; i < sInput.length() ; i++ )
+	{
+		if( sInput[i] == '/' )
+		{
+			sInput[i] = '\\';
+		}
+	}
+	return sInput;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::FileExists
+// Check if given file exists.
+// -----------------------------------------------------------------------------
+bool CATBase::FileExists( const char * pFilename )
+{
+	LOG_FUNC_ENTRY("CATBase::FileExists");
+	DWORD dwRet = GetFileAttributes( pFilename );
+	if( dwRet == INVALID_FILE_ATTRIBUTES )
+	{
+		return false;
+	}
+	else
+	{
+		//Is file directory?
+		if( dwRet & FILE_ATTRIBUTE_DIRECTORY )
+		{
+			return false;
+		}
+	}
+	return true;
+}
+
+bool CATBase::IsFileReadOnly( const char* pFilename )
+{
+	LOG_FUNC_ENTRY("CATBase::IsFileReadOnly");
+	DWORD dwRet = GetFileAttributes( pFilename );
+	if( dwRet == INVALID_FILE_ATTRIBUTES )
+		return false;
+	if( dwRet & FILE_ATTRIBUTE_READONLY )
+		return true;
+	return false;
+}
+
+bool CATBase::SetFileReadOnly( const char* pFileName )
+{
+	LOG_FUNC_ENTRY("CATBase::SetFileReadOnly");
+	DWORD dw = GetFileAttributes( pFileName );
+	if( dw == INVALID_FILE_ATTRIBUTES )
+		return false;
+	if( dw & FILE_ATTRIBUTE_READONLY )
+		return true;
+	dw = dw | FILE_ATTRIBUTE_READONLY ;
+	if ( SetFileAttributes( pFileName, dw ) )
+		return true;
+	return false;
+}
+bool CATBase::SetFileWritable( const char* pFileName )
+{
+	LOG_FUNC_ENTRY("CATBase::SetFileWritable");
+	DWORD dw = GetFileAttributes( pFileName );
+	if( dw == INVALID_FILE_ATTRIBUTES )
+		return false;
+	if( ! dw & FILE_ATTRIBUTE_READONLY )
+		return true;
+	dw = dw ^ FILE_ATTRIBUTE_READONLY ;
+	if ( SetFileAttributes( pFileName, dw ) )
+		return true;
+	return false;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::FileCopyToPath
+// Copies file to given path
+// -----------------------------------------------------------------------------
+bool CATBase::FileCopyToPath(const string& sFile, const string& sToPath)
+{
+	LOG_FUNC_ENTRY("CATBase::FileCopyToPath");
+	// Display message
+	cout << AT_MSG << "Copy " << sFile << AT_FILE_TO << sToPath << endl;
+	if ( sFile.empty() || sToPath.empty() )
+	{
+		LOG_FUNC_EXIT("CATBase::FileCopyToPath Error, empty parameter");
+		return false;
+	}
+	// Copy using windows api (seems not to work when relavite path ..
+	/*
+	// Full path where to copy
+	string sDestination = sToPath;
+	// Append '\' to string if not exists
+	if ( sDestination.length() > 1 )
+	{
+		const char cLastChar = sDestination[ sDestination.length() -1 ];
+		if ( cLastChar != DASH )
+			sDestination.append("\\");
+	}
+	int iRet = 0;
+	iRet = CopyFile( sFile.c_str(), sDestination.c_str(), false );
+	if ( iRet != 0 )
+	{
+		return false;
+	}
+	*/
+	string sCommand;
+	sCommand.append( "copy /Y \"");
+	sCommand.append( sFile );
+	sCommand.append( "\" \"" );
+	sCommand.append( sToPath );
+	sCommand.append( "\" > nul 2>&1" );
+	LOG_STRING( sCommand );
+	int iRet = 0;
+	iRet = (int)system( sCommand.c_str() );
+	if ( iRet != 0 )
+		return false;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::FileMoveToPath
+// Copies file to given path
+// -----------------------------------------------------------------------------
+bool CATBase::FileMoveToPath(const string& sFile, const string& sToPath)
+{
+	LOG_FUNC_ENTRY("CATBase::FileMoveToPath");
+	// Display message
+	cout << AT_MSG << "Move " << sFile << AT_FILE_TO << sToPath << endl;
+	if ( sFile.empty() || sToPath.empty() )
+	{
+		LOG_FUNC_EXIT("CATBase::FileMoveToPath Error, empty parameter");
+		return false;
+	}
+	// Move (again windows api function does not support relative path .. in it
+	/*
+	// Get filename from sFile
+	string sFileName = GetPathOrFileName( true, sFile );
+	// Full path where to copy
+	string sDestination = sToPath;
+	// Append '\' to string if not exists
+	if ( sDestination.length() > 1 )
+	{
+		const char cLastChar = sDestination[ sDestination.length() -1 ];
+		if ( cLastChar != DASH )
+			sDestination.append("\\");
+	}
+	int iRet = 0;
+	iRet = MoveFile( sFile.c_str(), sDestination.c_str());
+	if ( iRet != 0 )
+	{
+		return false;
+	}
+	*/
+	string sCommand;
+	sCommand.append( "move /Y \"");
+	sCommand.append( sFile );
+	sCommand.append( "\" \"" );
+	sCommand.append( sToPath );
+	sCommand.append( "\" > nul 2>&1" );
+	LOG_STRING( sCommand );
+	int iRet = 0;
+	iRet = (int)system( sCommand.c_str() );
+	if ( iRet != 0 )
+		return false;
+	return true;
+}
+// -----------------------------------------------------------------------------
+// CATBase::CreateTempPath
+// Creates temporary directory path for given mmp file
+// -----------------------------------------------------------------------------
+string CATBase::CreateTempPath(const string& sMmpFileWithPath)
+{
+	LOG_FUNC_ENTRY("CATBase::CreateTempPath");
+	string sTempPath = GetPathOrFileName( false, sMmpFileWithPath );
+	sTempPath.append( AT_TEMP_DIR );
+	sTempPath.append( "\\" );
+	return sTempPath;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::RemovePathAndExt
+// Removes extension from file name and returns file name without extension.
+// -----------------------------------------------------------------------------
+string CATBase::RemovePathAndExt( string sFileName, bool bReverseFindExt)
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::RemovePathAndExt");
+	string sRet;
+	sFileName = GetPathOrFileName( true, sFileName );
+	if ( bReverseFindExt )
+	{
+		// Remove extension from reverse
+		size_t iPos = sFileName.find_last_of('.');
+		if( iPos != string::npos )
+		{
+			sFileName.resize( sFileName.find_last_of('.') );
+			sRet = sFileName;
+		}
+	}
+	else
+	{
+		// Remove extension finding first .
+		size_t iPos = sFileName.find_first_of('.');
+		if( iPos != string::npos )
+		{
+			sFileName.resize( sFileName.find_first_of('.') );
+			sRet = sFileName;
+		}
+	}
+	return sRet;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::IsTargetTypeSupported
+// Checks from constant array is this target unsupported
+// -----------------------------------------------------------------------------
+bool CATBase::IsTargetTypeSupported(string sTargetType)
+{
+	LOG_FUNC_ENTRY("CATBase::IsTargetTypeSupported");
+	// compare to list
+	int iArraySize = sizeof( UNSUPPORTED_TARGET_TYPES ) / sizeof( string );
+	for ( int i=0 ; i < iArraySize ; i++ )
+	{
+		string sUnsupported = UNSUPPORTED_TARGET_TYPES[i];
+		// lowercase both
+		ChangeToLower(sTargetType);
+		ChangeToLower(sUnsupported);
+		// compare
+		if ( sUnsupported.compare( sTargetType ) == 0 )
+		{
+			return false;
+		}
+	}
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::IsTargetTypeKernelSide
+// Checks from constant array is this target type kernel side
+// -----------------------------------------------------------------------------
+bool CATBase::IsTargetTypeKernelSide(string sTargetType)
+{
+	LOG_FUNC_ENTRY("CATBase::IsTargetTypeKernelSide");
+	// compare to list
+	int iArraySize = sizeof( KERNEL_SIDE_TARGET_TYPES ) / sizeof( string );
+	for ( int i=0 ; i < iArraySize ; i++ )
+	{
+		string sUnsupported = KERNEL_SIDE_TARGET_TYPES[i];
+		// lowercase both
+		ChangeToLower(sTargetType);
+		ChangeToLower(sUnsupported);
+		// compare
+		if ( sUnsupported.compare( sTargetType ) == 0 )
+		{
+			return true;
+		}
+	}
+	return false;
+}
+
+bool CATBase::CheckVariant( const string& sEpocRoot, const string& sVariant )
+{
+	LOG_FUNC_ENTRY("CATBase::CheckVariant");
+	string sFileToCheck;
+	// Add epoc root
+	if( sEpocRoot.size() > 1 )
+		sFileToCheck.append( sEpocRoot );
+	// Add path
+	sFileToCheck.append( VARIANT_DIR ) ;
+	// Add variant
+	sFileToCheck.append( sVariant );
+	// Add extension
+	sFileToCheck.append( VARIANT_FILE_EXTENSION );
+	// check does FileExists
+	return FileExists( sFileToCheck.c_str() );
+}
+bool CATBase::IsDefaultVariant( const string& sEpocRoot )
+{
+	LOG_FUNC_ENTRY("CATBase::IsDefaultVariant");
+	string sFileToCheck;
+	// Add epoc root
+	if( sEpocRoot.size() > 1 )
+		sFileToCheck.append( sEpocRoot );
+	// Add path
+	sFileToCheck.append( VARIANT_DIR ) ;
+	// Add variant
+	sFileToCheck.append( "DEFAULT" );
+	// Add extension
+	sFileToCheck.append( VARIANT_FILE_EXTENSION );
+	// check does FileExists
+	return FileExists( sFileToCheck.c_str() );
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::FileDelete
+// FileDelete
+// -----------------------------------------------------------------------------
+bool CATBase::FileDelete(const string& sFile, bool bPrint )
+{
+	LOG_FUNC_ENTRY("CATBase::FileDelete");
+	// does file even exists
+	if ( !FileExists( sFile.c_str() ) )
+		return false;
+	// delete file
+	int iRet = _unlink( sFile.c_str() );
+	// if print on display error
+	if ( iRet  && bPrint )
+	{
+		cout << AT_MSG << "Error, deleting file " << sFile
+			<< endl;
+	}
+	// if print on display message
+	else if ( !iRet && bPrint )
+	{
+		cout << AT_MSG << "Delete " << sFile << endl;
+	}
+	// return
+	if ( iRet )
+		return false;
+	return true;
+}
+// -----------------------------------------------------------------------------
+// CATBase::DirDelete
+// Delelete directory
+// -----------------------------------------------------------------------------
+bool CATBase::DirDelete(const string& sDir, bool bPrint )
+{
+	LOG_FUNC_ENTRY("CATBase::DirDelete");
+	if ( sDir.find( AT_TEMP_DIR) == string::npos )
+		return false;
+	
+	if ( sDir.length() < 2 )
+		return false;
+
+	string sDir2;
+	if ( sDir.at(1) != ':' )
+	{
+		char cDir[MAX_LINE_LENGTH];
+		GetCurrentDirectory( MAX_LINE_LENGTH , cDir );
+		sDir2.append( cDir );
+		sDir2.append( "\\" );
+		sDir2.append( sDir );
+	}
+	else
+		sDir2.append( sDir );
+
+	// does directory exists
+	DWORD dwRet = GetFileAttributes( sDir2.c_str() );
+	if ( dwRet == INVALID_FILE_ATTRIBUTES )
+		return false;
+	else if ( ! (dwRet & FILE_ATTRIBUTE_DIRECTORY) )
+	{
+		return false;
+	}
+	// Delete dir
+	string sCmd( "rmdir /S /Q " );
+	sCmd.append( sDir2 );
+	sCmd.append( " > nul 2>&1" );
+	int iRet = (int)system( sCmd.c_str() );
+	if ( iRet && bPrint)
+	{
+		cout << AT_MSG << "Error, deleting directory " << sDir2 << endl;
+	}
+	else if ( !iRet && bPrint )
+	{
+		cout << AT_MSG << "Delete directory " << sDir2 << endl;
+	}
+	if ( iRet )
+		return false;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::DirCreate
+// Create directory
+// -----------------------------------------------------------------------------
+bool CATBase::DirCreate(const string& sDir, bool bPrint )
+{
+	LOG_FUNC_ENTRY("CATBase::DirCreate");
+
+	if ( sDir.length() < 2 )
+		return false;
+
+	string sDir2;
+	if ( sDir.at(1) != ':' )
+	{
+		char cDir[MAX_LINE_LENGTH];
+		GetCurrentDirectory( MAX_LINE_LENGTH , cDir );
+		sDir2.append( cDir );
+		sDir2.append( "\\" );
+		sDir2.append( sDir );
+	}
+	else
+		sDir2.append( sDir );
+
+	// does directory exists
+	DWORD dwRet = GetFileAttributes( sDir2.c_str() );
+	if ( dwRet != INVALID_FILE_ATTRIBUTES )
+	{
+		if( dwRet & FILE_ATTRIBUTE_DIRECTORY )
+			return false;
+	}
+	// Create dir
+	string sCmd( "mkdir " );
+	sCmd.append( sDir2 );
+	sCmd.append( " > nul 2>&1" );
+	int iRet = (int)system( sCmd.c_str() );
+	if ( iRet && bPrint)
+	{
+		cout << AT_MSG << "Error, creating directory " << sDir2 << endl;
+	}
+	else if ( !iRet && bPrint )
+	{
+		cout << AT_MSG << "Directory " << sDir2 << " created" << endl;
+	}
+	if ( iRet )
+		return false;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::ConvertTCHARtoString
+// Convert TCHAR* to std::string
+// -----------------------------------------------------------------------------
+string CATBase::ConvertTCHARtoString(TCHAR* charArray)
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::ConvertTCHARtoString");
+	// Loop char array
+	stringstream ss;
+	int iIndex = 0;
+	char c = (char) charArray[iIndex];
+	// until null termination
+	while ( c != '\0' )
+	{
+		ss << c;
+		iIndex++;
+		c = (char) charArray[iIndex];
+	}
+	// return string
+	return ss.str();
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::ConvertTCHARtoString
+// Get list of files in directory
+// -----------------------------------------------------------------------------
+vector<string> CATBase::DirList(const string& sDirectory
+								, bool bListDirs, bool bAddPathToFile)
+{
+	LOG_FUNC_ENTRY("CATBase::DirList");
+	// Create string to modify it
+	string sDir = sDirectory;
+	// Add if missing '\' & '*' to the sDirectory
+	if ( sDir.at( sDir.size()-1 ) != '\\' )
+		sDir.append( "\\" );
+	// Path to add to file string if specified
+	string sPath = sDir;
+	// Add * to for windows api to find all files
+	sDir.append( "*" );
+	// convert directory string to LPCSTR
+	LPCSTR dir( sDir.c_str() );
+	// vector to store file list
+	vector<string> vFileList;
+	// Using win32 api to find list of files in directory
+	// file data "container"
+	WIN32_FIND_DATA fileData;
+	// handle to directory
+	HANDLE hFinder = FindFirstFile( dir, &fileData );
+	if ( hFinder == INVALID_HANDLE_VALUE )
+	{
+		// no files found
+		return vFileList;
+	}
+	// loop files add to vector and return
+	while( FindNextFile(hFinder, &fileData ) )
+	{
+		DWORD dw = fileData.dwFileAttributes;
+		// skip if its directory and bListDirs not specified
+		if ( dw & FILE_ATTRIBUTE_DIRECTORY && ! bListDirs)
+			continue;
+		// add files to vector
+		string sFile = ConvertTCHARtoString( fileData.cFileName );
+		// Add given path to file string if specified
+		if ( bAddPathToFile )
+			sFile.insert( 0, sPath );
+		vFileList.push_back( sFile );
+	}
+	// Close file find handler
+	FindClose( hFinder );
+	return vFileList;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::ParseRelativePathToString
+// ParseRelative
+// -----------------------------------------------------------------------------
+void CATBase::ParseRelativePathString(string& sPathString)
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::ParseRelativePathString");
+	string sParsed;
+	// find ..
+	size_t iDots = sPathString.find( ".." );
+	while ( iDots != string::npos )
+	{
+		RemoveRelativePath( sPathString, iDots );
+		iDots = sPathString.find( ".." );
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::RemoveRelativePath
+// Remove relative path from string (using given index)
+// -----------------------------------------------------------------------------
+void CATBase::RemoveRelativePath(string& sString, size_t iDots)
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::RemoveRelativePath");
+	// Chck if accidentally given wrong parameter
+	if ( iDots == string::npos 
+		|| iDots < 1 )
+		return;
+	// Parsed string
+	string sParsed;
+	// Find position of last backslash before dots
+	size_t i = sString.rfind("\\", iDots-2 );
+	// Pickup start part (depending is the backslash at last parts first char)
+	if ( sString.at(iDots+2) != '\\' )
+		sParsed = sString.substr( 0, i+1 ) ;
+	else
+		sParsed = sString.substr( 0, i );
+	// Pick up last part
+	sParsed.append( sString.substr( iDots+2, sString.size() ) );
+	sString = sParsed;
+}
+
+// -----------------------------------------------------------------------------
+// Get extension from given string
+// -----------------------------------------------------------------------------
+string CATBase::GetExtension(const string& sString)
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::GetExtension");
+	// find last .
+	size_t iDot = sString.find_last_of( "." );
+	// return string after . if found
+	if ( iDot != string::npos )
+		return sString.substr(iDot+1, sString.length()-(iDot+1) );
+	// otherwise return given string
+	return sString;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::DirectoryExists
+// Check if given directory exists.
+// -----------------------------------------------------------------------------
+bool CATBase::DirectoryExists( const char* pDirname )
+{
+	LOG_FUNC_ENTRY("CATBase::DirectoryExists");
+	size_t iLenght = strlen( pDirname );
+	
+	if ( iLenght < 2 )
+		return false;
+
+	string sDir;
+	if ( pDirname[1] != ':' )
+	{
+		char cDir[MAX_LINE_LENGTH];
+		GetCurrentDirectory( MAX_LINE_LENGTH , cDir );
+		sDir.append( cDir );
+		sDir.append( "\\" );
+		sDir.append( pDirname );
+	}
+	else
+		sDir.append( pDirname );
+
+	DWORD dwRet = GetFileAttributes( sDir.c_str() );
+	if( dwRet == INVALID_FILE_ATTRIBUTES )
+	{
+		return false;
+	}
+	else
+	{
+		//Is file directory?
+		if( dwRet & FILE_ATTRIBUTE_DIRECTORY )
+		{
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::ConvertUnixPathToWin
+// -----------------------------------------------------------------------------
+void CATBase::ConvertUnixPathToWin( string& sPath )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::ConvertUnixPathToWin");
+	size_t iSpot = 0;
+	// convert '/' to '\'
+	iSpot = sPath.find( "/" );
+	while( iSpot != string::npos )
+	{
+		sPath.replace(iSpot,1, "\\");
+		iSpot = sPath.find( "/", iSpot+1 );
+	}
+	// convert '\\' to '\'
+	iSpot = sPath.find( "\\\\" );
+	while( iSpot != string::npos )
+	{
+		sPath.replace(iSpot,2,"\\");
+		iSpot = sPath.find( "\\\\" );
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::RemoveAllAfterDotIfTwoDots
+// Removes all after first '.'
+// if given string contains 2 '.' or more
+// -----------------------------------------------------------------------------
+void CATBase::RemoveAllAfterDotIfTwoDots(string& sModName)
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::RemoveAllAfterDotIfTwoDots");
+	// did we find variable?
+	size_t found;
+	// Find first '.'
+	found = sModName.find(".");
+	if ( found != string::npos )
+	{
+		// Try find second '.'
+		found = sModName.find(".", found+1);
+		if ( found != string::npos )
+		{
+			// Remove all after first '.'
+			sModName = sModName.substr(0, sModName.find(".")+1 );
+		}
+	}
+}
+// -----------------------------------------------------------------------------
+// CATBase::CreateTemporaryCpp
+// -----------------------------------------------------------------------------
+bool CATBase::CreateTemporaryCpp( const string& sId,
+								 const string& sPath
+								 ,const string& sS60FileName
+								 ,int iLogOption
+								 ,int iIsDebug
+								 ,int iAllocCallStackSize
+								 ,int iFreeCallStackSize )
+{
+	LOG_FUNC_ENTRY("CATBase::CreateTemporaryCpp");
+	// Add slash to path if missing
+	string sTempCpp = sPath;
+	if( sTempCpp.at( sTempCpp.length() - 1 ) != '\\' )
+		sTempCpp.append("\\");
+
+	// append temporary cpp name with id in middle
+	sTempCpp.append( AT_TEMP_CPP_LOWER_START );
+	sTempCpp.append( sId );
+	sTempCpp.append( AT_TEMP_CPP_LOWER_END );
+
+	//Open and truncate temporary cpp
+	ofstream out( sTempCpp.c_str() , ios::trunc );
+	if ( ! out.good() )
+	{
+		out.close();
+		return false;
+	}
+	out << "#include <e32base.h>";
+	out << "\n\n// CONSTANTS\n";
+	out << "\n/* The filename for log file */";
+	out << "\n_LIT( KFileName, \"";
+	//Set data file name
+	out << sS60FileName;
+	out << "\" );\n";
+	// Version number
+	out << "\n/* The AnalyzeTool version number used. */";
+	out << "\n_LIT( KAtoolVersion, \"";
+	out << ATOOL_COMPATIBILITY_STRING;
+	out << "\" );\n";
+	
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n// LogFileName()";
+	out << "\n// Returns the log filename.";
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n//";
+	out << "\nconst TFileName LogFileName()";
+	out << "\n    {";
+	out << "\n    return TFileName( KFileName() );";
+	out << "\n    }";
+
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n// AllocCallStackSize()";
+	out << "\n// Returns the call stack size gathered in alloc.";
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n//";
+	out << "\nTUint32 AllocCallStackSize()";
+	out << "\n    {";
+	out << "\n    return TUint32( ";
+	out << iAllocCallStackSize;
+	out << " );\n";
+	out << "\n    }";
+	
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n// FreeCallStackSize()";
+	out << "\n// Returns the call stack size gathered in free.";
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n//";
+	out << "\nTUint32 FreeCallStackSize()";
+	out << "\n    {";
+	out << "\n    return TUint32( ";
+	out << iFreeCallStackSize;
+	out << " );\n";
+	out << "\n    }";
+
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n// AtoolVersion()";
+	out << "\n// Returns the version number of AnalyzeTool used.";
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n//";
+	out << "\nconst TFileName AtoolVersion()";
+	out << "\n    {";
+	out << "\n    return TFileName( KAtoolVersion() );";
+	out << "\n    }";
+
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n// LogOption()";
+	out << "\n// Returns the log option.";
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n//    ";
+	out << "\nTUint32 LogOption()";
+	out << "\n    {";
+	out << "\n    return TUint32( ";
+	//Set logging target
+	out << iLogOption;
+	out << " );";
+	out << "\n    }";
+	
+	//Write build mode function
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n// IsDebug()";
+	out << "\n// Return build mode";
+	out << "\n// -----------------------------------------------------------------------------";
+	out << "\n//";
+	out << "\nTUint32 IsDebug()";
+	out << "\n    {";
+	out << "\n    return TUint32( ";
+	//Set logging target
+	out << iIsDebug;
+	out << " );";
+	out << "\n    }";
+	out << "\n\n// End of File\n";
+	out.close();
+	cout << AT_MSG << "Created " << sTempCpp << endl;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::IsDataFile
+// -----------------------------------------------------------------------------
+bool CATBase::IsDataFile( 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( "DATA_FILE_VERSION" ) != string::npos )
+		return true;
+	else
+		return false;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::FilterString
+// Filter string out of unwanted characters. The list of allowed
+// characters is defined in CFILTERSTRING.
+// -----------------------------------------------------------------------------
+string CATBase::FilterString( const string& sString )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::FilterString");
+	string sFiltered;
+	for( size_t i = 0 ; i < sString.length() ; i++ )
+	{
+		const char p = sString.at( i );
+		if ( strchr( CFILTERSTRING, p ) !=  0 )
+			sFiltered.push_back( p );
+	}
+	return sFiltered;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::FilterExtraSpaces
+// Replaces multiple continuous spaces with single. Won't leave
+// spaces in start or end of string.
+// -----------------------------------------------------------------------------
+void CATBase::FilterExtraSpaces( string& sString )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::FilterExtraSpaces");
+	string sFiltered;
+	// Loop thru char array.
+	for( size_t i = 0 ; i < sString.length(); i++ )
+	{
+		// Is char space?
+		if ( sString.at( i ) == ' ' )
+		{
+			// Pick up space if filtered does not contain char as last.
+			if ( sFiltered.rbegin() == sFiltered.rend() )
+				sFiltered.push_back( sString.at( i ) );
+			else if ( * ( sFiltered.rbegin() ) != ' ' )
+				sFiltered.push_back( sString.at( i ) );
+		}
+		else
+			sFiltered.push_back( sString.at( i ) );
+	}
+
+	// Remove first and/or last character if it is space.
+	if ( sFiltered.begin() != sFiltered.end() )
+	{
+		if( * ( sFiltered.begin() ) == ' ' )
+			sFiltered.erase( 0, 1 );
+	}
+	if ( sFiltered.rbegin() != sFiltered.rend() )
+	{
+		if( * ( sFiltered.rbegin() ) == ' ' )
+			sFiltered.resize( sFiltered.length()-1 );
+	}
+	sString = sFiltered;
+}
+
+
+bool CATBase::hexToDec( string& sHex, unsigned int& iDec )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::hexToDec");
+	istringstream ss( sHex );
+	ss.setf( ios::hex, ios::basefield );
+	if( ( ss >> iDec ) )
+		return true;
+	return false;
+}
+
+bool CATBase::hexToDec( string& sHex, int& iDec )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::hexToDec");
+	istringstream ss( sHex );
+	ss.setf( ios::hex, ios::basefield );
+	if( ( ss >> iDec ) )
+		return true;
+	return false;
+}
+
+bool CATBase::hexToDec( string& sHex, unsigned long& ulDec )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::hexToDec");
+	istringstream ss( sHex );
+	ss.setf( ios::hex, ios::basefield );
+	if( ( ss >> ulDec ) )
+		return true;
+	return false;
+}
+
+bool CATBase::hexToDec( string& sHex, unsigned long long& ullDec )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::hexToDec");
+	istringstream ss( sHex );
+	ss.setf( ios::hex, ios::basefield );
+	if( ( ss >> ullDec ) )
+		return true;
+	return false;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::_httoi
+// -----------------------------------------------------------------------------
+struct CHexMap
+{
+	char chr;
+	int value;
+};
+unsigned long CATBase::_httoi(const char *value)
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::_httoi");
+	unsigned long l;
+	string s( value );
+	if ( CATBase::hexToDec( s, l ) )
+		return l;
+	return 0;
+}
+
+
+// -----------------------------------------------------------------------------
+// CATBase::NumberToHexString(int)
+// -----------------------------------------------------------------------------
+string CATBase::NumberToHexString( unsigned int i )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::IntToHexString");
+	stringstream ss;
+	ss << "0x" << hex << i;
+	string retval; retval = ss.str().c_str();
+	return retval;
+}
+// -----------------------------------------------------------------------------
+// CATBase::NumberToHexString(long)
+// -----------------------------------------------------------------------------
+string CATBase::NumberToHexString( unsigned long i )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::IntToHexString");
+	stringstream ss;
+	ss << "0x" << hex << i;
+	string retval; retval = ss.str().c_str();
+	return retval;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::IsHexCharacter
+// -----------------------------------------------------------------------------
+bool CATBase::IsHexCharacter(const TCHAR *value)
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::IsHexCharacter");
+	const int HexMapL = 22;
+	CHexMap HexMap[HexMapL] =
+	{
+	    {'0', 0}, {'1', 1},
+		{'2', 2}, {'3', 3},
+		{'4', 4}, {'5', 5},
+		{'6', 6}, {'7', 7},
+		{'8', 8}, {'9', 9},
+		{'A', 10}, {'B', 11},
+		{'C', 12}, {'D', 13},
+		{'E', 14}, {'F', 15},
+		{'a', 10}, {'b', 11},
+		{'c', 12}, {'d', 13},
+		{'e', 14}, {'f', 15}
+	};
+	bool found = false;
+	for (int i = 0; i < HexMapL; i++)
+	{
+		if(HexMap[i].chr == *value)
+		{
+			found = true;
+			break;
+		}
+	}
+	return found;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::IsAscii(const char*,const unsigned int)
+// -----------------------------------------------------------------------------
+bool CATBase::IsAscii( const char* pInput, const unsigned int iLength )
+{
+	LOG_LOW_FUNC_ENTRY("CATBase::IsAscii");
+	bool bRet = true;
+	const char* pPoint = pInput;
+	for( unsigned int i = 0 ; i < iLength ; i++)
+	{
+		if(	!__isascii(*pPoint) )
+		{
+			bRet = false;
+			break;
+		}
+		pPoint++;
+	}
+	return bRet;
+}
+
+// -----------------------------------------------------------------------------
+// CATBase::GetEpocRoot( string& sEpocRoot )
+// -----------------------------------------------------------------------------
+bool CATBase::GetEpocRoot( string& sEpocRoot )
+{
+	LOG_FUNC_ENTRY( "CATBase::GetEpocRoot" );
+	bool bRet = true;
+	//Find EPOCROOT from environment variable
+	char* pEpocRoot = getenv ("EPOCROOT");
+	if( pEpocRoot == NULL )
+	{
+		const char pDevicesPath[] = "C:\\Program Files\\Common Files\\Symbian\\devices.xml";
+		CATParseXML parser;
+		//Find EPOCROOT from devices
+		sEpocRoot = parser.GetEpocRootPathFromXML(pDevicesPath);
+		if( sEpocRoot.empty() )
+		{
+			printf("EPOCROOT not set to environment variables.\n");
+			bRet = false;
+		}
+	}
+	else
+	{
+		sEpocRoot.append( pEpocRoot );
+		LOG_STRING( "EpocRoot :" << sEpocRoot );
+	}
+	//Remove trailing slash
+	if ( sEpocRoot.size() > 1 && sEpocRoot[ sEpocRoot.length()-1 ] == '\\' )
+		sEpocRoot.resize( sEpocRoot.length()-1 );
+	return bRet;
+}
+//End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/CATDatParser.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,1575 @@
+/*
+* 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:  Class responsible to parse data files
+*
+*/
+
+
+#include "../inc/CATDatParser.h"
+#include "../inc/CATProject.h"
+#include "../inc/CATModule2.h"
+#include "../inc/CATMemoryAddress.h"
+#include "../inc/catromsymbol.h"
+
+// -----------------------------------------------------------------------------
+// CATDatParser::CATDatParser
+// Constructor only for testing!
+// (No module vector defined so no locating codelines / call stacks)
+// -----------------------------------------------------------------------------
+CATDatParser::CATDatParser()
+{
+	LOG_FUNC_ENTRY("CATDatParser::CATDatParser");
+	Construct();
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::CATDatParser
+// Constructor
+// -----------------------------------------------------------------------------
+CATDatParser::CATDatParser(vector<CATModule2*>* pModules )
+{
+	LOG_FUNC_ENTRY("CATDatParser::CATDatParser");
+	Construct();
+	m_pModules = pModules;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::Construct
+// "Real" constructor
+// -----------------------------------------------------------------------------
+void CATDatParser::Construct()
+{
+	LOG_FUNC_ENTRY("CATDatParser::Construct");
+
+	m_iDataVersion = 1; // Default version of data.
+	m_bDllLoadFound = false;
+	m_bProcessStartFound = false;
+	m_bSubtestOnGoing = false;
+
+	m_DataSaver.InitXML();
+	
+	m_eBuildType = -2;
+	m_eProcess_state = not_started;
+	m_eProjectBuildType = -1;
+
+	m_iCurrentProcessId = 0;
+	m_iLeakNumber = 0;
+	m_iLogLevel = 3;
+	m_iOffSet = 0;
+
+	m_iPinPointedLeaks = 0;
+	m_iPinPointedSubTestLeaks = 0;
+	m_iSubtestStartHandleCount = 0;
+	m_iSuccesfullRuns = 0;
+	m_iTotalNumberOfLeaks = 0;
+	m_iTotalRuns = 0;
+
+	m_pRomSymbol = 0;
+	m_pModules = 0;
+
+	m_sCurrentProcessName = "";
+	m_sInputFile = "";
+	m_sInputFileTemp = "";
+	m_sOutputFile = "";
+	m_sProjectPlatform = "";
+	m_vRomSymbolFiles.clear();
+	m_vDllLoadModList.clear();
+	m_vDllLoadModListSubTest.clear();
+	m_vHandleLeaks.clear();
+	m_vMemoryAddress.clear();
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::~CATDatParser
+// Destructor
+// -----------------------------------------------------------------------------
+CATDatParser::~CATDatParser()
+{
+	LOG_FUNC_ENTRY("CATDatParser::~CATDatParser");
+
+	if ( m_In.is_open() )
+		m_In.close();
+	// Delete temporary input file if any
+	if ( !m_sInputFileTemp.empty() )
+	{
+		if ( FileExists( m_sInputFileTemp.c_str() ) )
+			FileDelete( m_sInputFileTemp, false );
+	}
+	// Clean memory addresses if any
+	CleanMemoryAddresses();
+	// Delete rom symbol.
+	if ( m_pRomSymbol )
+	{
+        delete m_pRomSymbol;
+		m_pRomSymbol = NULL;
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::Analyze
+// Analyze given data file
+// -----------------------------------------------------------------------------
+int CATDatParser::Analyze()
+{
+	LOG_FUNC_ENTRY("CATDatParser::Analyze");
+	// Return if input file not set
+	if ( m_sInputFile.empty() )
+		return AT_RETURN_CODE::INVALID_DATA_FILE;
+	// If open close first
+	if ( m_In.is_open() )
+		m_In.close();
+	// Open file
+	m_In.open( m_sInputFile.c_str() );
+	if ( ! m_In.good() )
+		return AT_RETURN_CODE::INVALID_DATA_FILE;
+	try {
+		// If rom symbol file specified.
+		if ( ! m_vRomSymbolFiles.empty() )
+		{
+			// Create new rom symbol file "parser".
+			m_pRomSymbol = new CATRomSymbol();
+			m_pRomSymbol->m_bShowProgressMessages = true;
+			// Set symbol files.
+			if ( ! m_pRomSymbol->SetSymbols( m_vRomSymbolFiles ) )
+			{
+				cout << AT_MSG << "Rom/Rofs symbols error: " << m_pRomSymbol->GetError() << endl;
+				// If file open fails we delete it and will not use it.
+				delete m_pRomSymbol;
+				m_pRomSymbol = NULL;
+				cout << AT_MSG << "Analyze aborted." << endl;
+				return AT_RETURN_CODE::SYMBOL_FILE_ERROR;
+			}
+		}
+		// Return code
+		int iRet = 0;
+		// Clear variables
+		ClearParsingVariables();
+		// If output defined disable printing
+		if ( ! m_sOutputFile.empty() )
+			m_DataSaver.SetPrintFlag( false );
+		// Header
+		Header();
+		// Parsing
+		iRet = Parse();
+		// Footer
+		if ( iRet == AT_RETURN_CODE::OK )
+			Footer();
+		// If output defined save xml
+		if ( ! m_sOutputFile.empty() )
+			m_DataSaver.SaveLinesToFile( m_sOutputFile.c_str(), XML_DATA );
+		// Return
+		return iRet;
+	} catch ( int i )
+	{
+		cout << AT_MSG << "Error, Analyze failed. : " << i << endl;
+		return AT_RETURN_CODE::UNHANDLED_EXCEPTION;
+	}
+}
+// -----------------------------------------------------------------------------
+// CATDatParser::Header
+// Print header of report
+// -----------------------------------------------------------------------------
+void CATDatParser::Header()
+{
+	LOG_FUNC_ENTRY("CATDatParser::Header");
+	// Analyze report header
+	m_DataSaver.AddString( "Atool.exe v." );
+	m_DataSaver.AddString( ATOOL_VERSION );
+	m_DataSaver.AddString( "\n" );
+	m_DataSaver.AddString( "Analyzing memory leaks..." );
+	m_DataSaver.AddLineToLast();
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::Footer
+// Print footer of report
+// -----------------------------------------------------------------------------
+void CATDatParser::Footer()
+{
+	LOG_FUNC_ENTRY("CATDatParser::Footer");
+	m_DataSaver.AddString( "\nTotal Runs: " );
+	m_DataSaver.AddInteger( m_iTotalRuns );
+	m_DataSaver.AddLineToLast();
+
+	int iFailedRuns = m_iTotalRuns - m_iSuccesfullRuns;
+	m_DataSaver.AddString( "Failed Runs: " );
+	m_DataSaver.AddInteger( iFailedRuns );
+	m_DataSaver.AddLineToLast();
+
+	char cTemp[128];
+	string sResult( itoa( m_iTotalRuns, cTemp, 10 ) );
+	sResult.append( ";" );
+	sResult.append( itoa( iFailedRuns, cTemp, 10 ) );
+	sResult.append( ";" );
+
+	m_DataSaver.SaveXML( sResult, RESULT );
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ClearParsingVariables
+// Clear/Reset all member variables related to parsing data file
+// -----------------------------------------------------------------------------
+void CATDatParser::ClearParsingVariables()
+{
+	LOG_FUNC_ENTRY("CATDatParser::ClearParsingVariables");
+	// Clear variables related to analyze
+	m_eProcess_state = PROCESS_STATE::not_started;
+	m_bProcessStartFound = false;
+	m_bDllLoadFound = false;
+	m_iTotalNumberOfLeaks = 0;
+	m_iPinPointedLeaks = 0;
+	m_iLeakNumber = 0;
+	m_iTotalRuns = 0;
+	m_iSuccesfullRuns = 0;
+	m_bSubtestOnGoing = false;
+	m_iSubtestStartHandleCount = 0;
+	CleanMemoryAddresses();
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::Parse
+// Parses data file. Note! header and footer of the report are done in 
+// separate functions.
+// -----------------------------------------------------------------------------
+int CATDatParser::Parse()
+{
+	LOG_FUNC_ENTRY("CATDatParser::Parse");
+	// Read all lines
+	char cLine[MAX_LINE_LENGTH];
+	do
+	{
+		string sLine;
+		try {
+			m_In.getline( cLine, MAX_LINE_LENGTH );
+			sLine = cLine ;
+		} catch(...)
+		{
+			LOG_STRING( AT_MSG << "Unexpected error, reading data file." );
+			continue;
+		}
+		if( sLine.find( LABEL_DATA_FILE_VERSION ) != string::npos )
+		{
+			// Check data file version
+			if(  sLine.find( AT_DATA_FILE_VERSION ) == string::npos )
+			{
+				return AT_RETURN_CODE::WRONG_DATA_FILE_VERSION;
+			}
+		}
+		else if( sLine.find( LABEL_PROCESS_START ) != string::npos )
+		{
+			if ( ! ParseProcessStart( sLine ) )
+				return AT_RETURN_CODE::ANALYZE_ERROR;
+		}
+		else if( sLine.find( LABEL_DLL_LOAD ) != string::npos )
+		{
+			if ( ! ParseDllLoad( sLine ) )
+				return AT_RETURN_CODE::ANALYZE_ERROR;
+		}
+		else if( sLine.find( LABEL_DLL_UNLOAD ) != string::npos )
+		{
+			if ( ! ParseDllUnload( sLine ) )
+				return AT_RETURN_CODE::ANALYZE_ERROR;
+		}
+		else if( sLine.find( LABEL_MEM_LEAK ) != string::npos)
+		{
+			if ( ! ParseMemLeak( sLine ) )
+				return AT_RETURN_CODE::ANALYZE_ERROR;
+		}
+		else if( sLine.find( LABEL_PROCESS_END ) != string::npos )
+		{
+			if ( ! ParseProcessEnd( sLine ) )
+				return AT_RETURN_CODE::ANALYZE_ERROR;
+		}
+		else if( sLine.find( LABEL_ERROR_OCCURED ) != string::npos )
+		{
+			if ( ! ParseErrorOccured( sLine ) )
+				return AT_RETURN_CODE::ANALYZE_ERROR;
+		}
+		else if( sLine.find( LABEL_HANDLE_LEAK ) != string::npos )
+		{
+			if ( ! ParseHandleLeak( sLine ) )
+				return AT_RETURN_CODE::ANALYZE_ERROR;
+		}
+		else if( sLine.find( LABEL_TEST_START ) != string::npos )
+		{
+			if ( ! ParseTestStart( sLine ) )
+				return AT_RETURN_CODE::ANALYZE_ERROR;
+		}
+		else if( sLine.find( LABEL_TEST_END ) != string::npos )
+		{
+			if ( ! ParseTestEnd( sLine ) )
+				return AT_RETURN_CODE::ANALYZE_ERROR;
+		}
+		else if( sLine.find( LABEL_LOGGING_CANCELLED ) != string::npos )
+		{
+			if ( ! ParseLoggingCancelled( sLine ) )
+				return AT_RETURN_CODE::ANALYZE_ERROR;
+		}
+	}
+	while( m_In.good() );
+	// Message of failed run if process start was last line in data.
+	if ( m_eProcess_state == PROCESS_STATE::ongoing )
+	{
+		m_DataSaver.AddString( "Test run failed.\n" );
+		m_DataSaver.AddLineToLast();
+	}
+	return AT_RETURN_CODE::OK;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ParseProcessStart
+// -----------------------------------------------------------------------------
+bool CATDatParser::ParseProcessStart( string& sLine)
+{
+	LOG_FUNC_ENTRY("CATDatParser::ParseProcessStart");
+	if ( m_eProcess_state == PROCESS_STATE::ongoing )
+	{
+		m_DataSaver.AddString( "Test run failed.\n" );
+		m_DataSaver.AddLineToLast();
+	}
+	m_eProcess_state = PROCESS_STATE::ongoing;
+	m_bProcessStartFound = true;
+
+	// Clear handle leaks
+	m_vHandleLeaks.clear();
+	// Increment runs
+	m_iTotalRuns++;
+	// Clean leak count
+	m_iTotalNumberOfLeaks = 0;
+	// Clean pin pointed leaks count.
+	m_iPinPointedLeaks = 0;
+	// Clean leak number
+	m_iLeakNumber = 0;
+
+	// Clean loaded mods
+	m_vDllLoadModList.clear();
+	m_vDllLoadModListSubTest.clear();
+
+	// Skip text PROCESS_START
+	GetStringUntilNextSpace( sLine );
+	// Get process name
+	m_sCurrentProcessName = GetStringUntilNextSpace( sLine );
+	// Get Pid
+	string sPid = GetStringUntilNextSpace( sLine );
+	m_iCurrentProcessId = _httoi( sPid.c_str() );
+
+	// Header for process tart
+	m_DataSaver.AddString( "\n--------------------------------\n" );
+	m_DataSaver.AddString( "Test Run start (" );
+	m_DataSaver.AddString( m_sCurrentProcessName.c_str() );
+	m_DataSaver.AddString( "): " );
+
+	// Get start time
+	string sTime = GetStringUntilNextSpace( sLine );
+	sTime = ConvertTimeToLocalTime( sTime );
+	m_DataSaver.AddString( sTime.c_str() );
+
+	// Create data for xml
+	string sData( sTime );
+	sData.append( ";" );
+	
+	// Build mode UDEB/UREL.
+	string sBuildType = GetStringUntilNextSpace( sLine );
+
+	m_DataSaver.AddString( " Build target: " );
+	if( sBuildType.compare( "0" ) == 0 )
+	{
+		m_eBuildType = CATProject::UREL;
+	}
+	else if( sBuildType.compare( "1" ) == 0 )
+	{
+		m_eBuildType = CATProject::UDEB;
+	}
+	m_DataSaver.AddString( CATProject::GetBuildTypeString( m_eBuildType ).c_str() );
+
+	// Version.
+	string sVersion = GetStringUntilNextSpace( sLine );
+	unsigned int iVer = 0;
+	if ( hexToDec( sVersion, iVer ) && iVer != 0 )
+		m_iDataVersion = iVer;
+
+	// End line in data.
+	m_DataSaver.AddLineToLast();
+	
+	// xml
+	sData.append( CATProject::GetBuildTypeString( m_eBuildType ) );
+	sData.append( ";" );
+	sData.append( m_sCurrentProcessName );
+	m_DataSaver.SaveXML( sData, RUN );
+
+	// If projects platform defined check that it is same in data. (future feature).
+	if ( ! m_sProjectPlatform.empty() )
+	{
+		// If platform info is added to data file do check here.
+	}
+	// If projects build type defined check that it is same in data.
+	if ( m_eProjectBuildType != -1 )
+	{
+		if ( m_eBuildType != m_eProjectBuildType )
+		{
+			string sError(AT_MSG);
+			sError.append( "Error, analyzed data has build type of " );
+			sError.append( CATProject::GetBuildTypeString( m_eBuildType ) );
+			sError.append( " and project has build type " );
+			sError.append( CATProject::GetBuildTypeString( m_eProjectBuildType ) );
+			sError.append( ". Pinpointed code lines are not valid." );
+			m_DataSaver.AddString( sError.c_str(), false );
+			m_DataSaver.AddLineToLast();
+		}
+	}
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ParseProcessEnd
+// -----------------------------------------------------------------------------
+bool CATDatParser::ParseProcessEnd( string& sLine )
+{
+	LOG_FUNC_ENTRY("CATDatParser::ParseProcessEnd");
+	GetStringUntilNextSpace( sLine );
+
+	// Get process id
+	string sProcessID = GetStringUntilNextSpace( sLine );
+	unsigned long iProcessID = _httoi( sProcessID.c_str() );
+
+	// Get time
+	string sTime = GetStringUntilNextSpace( sLine );
+
+	// Convert leak time
+	sTime = ConvertTimeToLocalTime( sTime );
+
+	// Process started?
+	if( iProcessID == m_iCurrentProcessId )
+	{
+		m_iSuccesfullRuns++;
+		m_DataSaver.AddLineToLast();
+		m_DataSaver.AddString( "Test Run end (" );
+		m_DataSaver.AddString( m_sCurrentProcessName.c_str() );
+		m_DataSaver.AddString( "): " );
+		m_DataSaver.AddString( sTime.c_str() );
+		m_DataSaver.AddLineToLast();
+		m_DataSaver.AddString( "Build target: " );
+		m_DataSaver.AddString( CATProject::GetBuildTypeString( m_eBuildType ).c_str() );
+		m_DataSaver.AddLineToLast();
+
+		m_eProcess_state = PROCESS_STATE::stopped;
+		// Number of leaks
+		if ( m_iLogLevel == 1 || m_iLogLevel == 2 )
+		{
+			if ( m_iPinPointedLeaks > 0 )
+			{
+				m_DataSaver.AddInteger( m_iPinPointedLeaks );
+				m_DataSaver.AddString( " number of pinpointed memory leak(s)." );
+				m_DataSaver.AddLineToLast();
+			}
+			m_DataSaver.AddInteger( m_iLeakNumber );
+			m_DataSaver.AddString( " total number of memory leak(s)." );
+			m_DataSaver.AddLineToLast();
+		}
+		else
+		{
+			m_DataSaver.AddInteger( m_iTotalNumberOfLeaks );
+			m_DataSaver.AddString( " memory leak(s) found." );
+			m_DataSaver.AddLineToLast();
+		}
+		
+		// xml
+		char cTemp[128];
+		m_DataSaver.SaveXML( itoa( m_iTotalNumberOfLeaks, cTemp, 10 ) , MEM_LEAKS );
+
+		// Print all modules which have leaks
+		for( size_t i = 0 ; i < m_vDllLoadModList.size() ; i++ )
+		{
+			if( m_vDllLoadModList.at(i).iLeaks > 0 )
+			{
+				m_DataSaver.AddInteger( m_vDllLoadModList.at(i).iLeaks );
+				m_DataSaver.AddString( " memory leak(s) in module: " );
+				m_DataSaver.AddString( m_vDllLoadModList.at(i).sModuleName.c_str() );
+				m_DataSaver.AddLineToLast();
+
+				// xml
+				string sModuleNameAndLeaks( m_vDllLoadModList[i].sModuleName );
+				sModuleNameAndLeaks.append(";");
+				sModuleNameAndLeaks.append( itoa( m_vDllLoadModList[i].iLeaks, cTemp, 10 ) );
+				m_DataSaver.SaveXML( sModuleNameAndLeaks , MEM_LEAK_MODULE );
+			}
+		}
+		
+		if ( m_vHandleLeaks.size() > 0 )
+		{
+			// We have handle leaks
+			bool bHandLeaksFound = false;
+			int iTotalNrOfLeaks = 0;
+			// Print handle leaks
+			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) );
+				unsigned long iNrOfLeaks = _httoi( sNrOfLeaks.c_str() );
+				iTotalNrOfLeaks += iNrOfLeaks;
+				if( iNrOfLeaks )
+				{
+					if( !bHandLeaksFound )
+					{
+						m_DataSaver.SaveXML( sNrOfLeaks , HANDLE_LEAKS );
+					}
+					bHandLeaksFound = true;
+					m_DataSaver.AddInteger( iNrOfLeaks );
+					// Just print out how many leaks found.
+					// Because its always unknown.
+					m_DataSaver.AddString( " handle leak(s) found." );
+					m_DataSaver.AddLineToLast();
+
+					// xml
+					string sXMLInfo( sHandleLeakModule );
+					sXMLInfo.append( ";" ); sXMLInfo.append( sNrOfLeaks );
+					m_DataSaver.SaveXML( sXMLInfo , HANDLE_LEAK_MODULE );
+				}
+			}
+			// Update number if handle leaks
+			m_DataSaver.SaveXML( itoa( iTotalNrOfLeaks, cTemp, 10 ) , HANDLE_LEAKS );
+			if( !bHandLeaksFound )
+			{
+				//m_DataSaver.AddLineToLast();
+				m_DataSaver.AddString( TEXT_NO_HANDLE_LEAKS );
+				m_DataSaver.AddLineToLast();
+			}
+		}
+		else
+		{
+			// No handle leaks
+			m_DataSaver.AddLineToLast();
+			m_DataSaver.AddString( TEXT_NO_HANDLE_LEAKS );
+			m_DataSaver.AddLineToLast();
+		}
+
+		// Process end to xml
+		m_DataSaver.SaveXML( sTime, RUN_END );
+		// Reset current process
+		m_iCurrentProcessId = 0;
+	}
+	
+	// If no dll load or process start found
+	if ( ! m_bProcessStartFound || !m_bDllLoadFound )
+	{
+		m_DataSaver.AddLineToLast();
+		m_DataSaver.AddString( AT_ANALYZE_INSUFFICIENT_LOGGING_DATA );
+		m_DataSaver.AddLineToLast();
+	}
+	
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ParseDllLoad
+// -----------------------------------------------------------------------------
+bool CATDatParser::ParseDllLoad( string& sLine )
+{
+	LOG_FUNC_ENTRY("CATDatParser::ParseDllLoad");
+	//DLL_LOAD <DLL name> <Time stamp> <Memory start address> <Memory end address>
+	m_bDllLoadFound = true;
+	DLL_LOAD_INFO structDllInfo;
+	structDllInfo.iStartAddress = 0;
+	structDllInfo.iEndAddress = 0;
+	structDllInfo.iLeaks = 0;
+
+	// Skip "DLL_LOAD "
+	GetStringUntilNextSpace( sLine );
+
+	// Get module name
+	structDllInfo.sModuleName = GetStringUntilNextSpace( sLine );
+	ChangeToLower( structDllInfo.sModuleName );
+
+	// Create module from this if project platform emulator
+	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 = 
+		_httoi( GetStringUntilNextSpace( sLine ).c_str() );
+
+	// Get dll end memory string address from line
+	// Convert string address to real memory address
+	structDllInfo.iEndAddress = 
+		_httoi( 
+		GetStringUntilNextSpace( sLine ).c_str() );
+
+	// Is module already loaded, if not add it to list.
+	bool bFound = false;
+	for( vector<DLL_LOAD_INFO>::iterator it = m_vDllLoadModList.begin();
+		it != m_vDllLoadModList.end() ; it++ )
+	{
+		if( (*it).sModuleName.compare( structDllInfo.sModuleName ) == 0 )
+		{
+			bFound = true;
+			break;
+		}
+	}
+	if( ! bFound )
+		m_vDllLoadModList.push_back( structDllInfo );
+
+	// Sub test module list.
+	bFound = false;
+	for( vector<DLL_LOAD_INFO>::iterator it = m_vDllLoadModListSubTest.begin();
+		it != m_vDllLoadModListSubTest.end() ; it++ )
+	{
+		if( (*it).sModuleName.compare( structDllInfo.sModuleName ) == 0 )
+		{
+			bFound = true;
+			break;
+		}
+	}
+	if( ! bFound )
+		m_vDllLoadModListSubTest.push_back( structDllInfo );
+
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ParseDllUnload
+// -----------------------------------------------------------------------------
+bool CATDatParser::ParseDllUnload( string& sLine )
+{
+	LOG_FUNC_ENTRY("CATDatParser::ParseDllUnload");
+
+	// Ignore unloads on older version because no timestamps.
+	if ( m_iDataVersion < AT_DLL_TIMESTAMP_DATA_VERSION )
+	{
+		return true;
+	}
+
+	// Skip "DLL_UNLOAD "
+	GetStringUntilNextSpace( sLine );
+
+	// Get module name
+	string sModuleName = GetStringUntilNextSpace( sLine );
+	ChangeToLower( sModuleName );
+
+	// Unload time
+	unsigned long long ull;
+	string sUnload = GetStringUntilNextSpace( sLine );
+	if ( ! hexToDec( sUnload, ull ) )
+		return true;
+
+	// Set module unload time.
+	vector<DLL_LOAD_INFO>::iterator it;
+	for( it = m_vDllLoadModList.begin() ; it != m_vDllLoadModList.end() ; it++ )
+	{
+		if ( sModuleName.compare( it->sModuleName ) == 0 )
+		{
+			(*it).iUnloadTime = ull;
+			break;
+		}
+	}
+	for( it = m_vDllLoadModListSubTest.begin() ; it != m_vDllLoadModListSubTest.end() ; it++ )
+	{
+		if ( sModuleName.compare( it->sModuleName ) == 0 )
+		{
+			(*it).iUnloadTime = ull;
+			break;
+		}
+	}
+	return true;
+}
+// -----------------------------------------------------------------------------
+// CATDatParser::ParseLoggingCancelled
+// -----------------------------------------------------------------------------
+bool CATDatParser::ParseLoggingCancelled( string& sLine )
+{
+	LOG_FUNC_ENTRY("CATDatParser::ParseLoggingCancelled");
+	// Skip text "LOGGING_CANCELLED"
+	GetStringUntilNextSpace( sLine );
+
+	// Get time
+	string sTime( GetStringUntilNextSpace( sLine ) );
+	sTime = ConvertTimeToLocalTime( sTime );
+	m_DataSaver.AddString( "Logging Cancelled." );
+	m_DataSaver.AddLineToLast();
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ParseHandleLeak
+// -----------------------------------------------------------------------------
+bool CATDatParser::ParseHandleLeak( string& sLine )
+{
+	LOG_FUNC_ENTRY("CATDatParser::ParseHandleLeak");
+	// Skip text "HANDLE_LEAK"
+	GetStringUntilNextSpace( sLine );
+	m_vHandleLeaks.push_back( sLine );
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ParseTestStart
+// -----------------------------------------------------------------------------
+bool CATDatParser::ParseTestStart( string& sLine )
+{
+	LOG_FUNC_ENTRY("CATDatParser::ParseTestStart");
+	m_bSubtestOnGoing = true;
+	m_iLeakNumber = 0;
+	m_iPinPointedSubTestLeaks = 0;
+
+	// Reset subtest leaked modules list
+	for( size_t i = 0 ; i < m_vDllLoadModListSubTest.size() ; i++ )
+	{
+		m_vDllLoadModListSubTest.at(i).iLeaks = 0;
+	}
+
+	// Skip text "TEST_START"
+	GetStringUntilNextSpace( sLine );
+	// Time
+	string sTime( GetStringUntilNextSpace( sLine ) );
+	sTime = ConvertTimeToLocalTime( sTime );
+	// Name
+	string sSubTestName( GetStringUntilNextSpace( sLine ) );				
+	m_DataSaver.AddLineToLast();
+
+	// Get handle count in subtest start
+	string sSubTestStartHandleCount( GetStringUntilNextSpace( sLine ) );
+	m_iSubtestStartHandleCount = atoi( sSubTestStartHandleCount.c_str() );
+
+	// Add start to report
+	m_DataSaver.AddString( "\nSub test (" );
+	m_DataSaver.AddString( sSubTestName.c_str() );
+	m_DataSaver.AddString( ") start: " );
+	m_DataSaver.AddString( sTime.c_str() );
+
+	// m_DataSaver.AddLineToLast();
+
+	// Add start to xml
+	string sResult( sSubTestName );
+	sResult.append( ";" );
+	sResult.append( sTime );
+	sResult.append( ";" );
+	m_DataSaver.SaveXML( sResult, TEST_START );
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ParseTestEnd
+// -----------------------------------------------------------------------------
+bool CATDatParser::ParseTestEnd( string& sLine )
+{
+	LOG_FUNC_ENTRY("CATDatParser::ParseTestEnd");
+	// Skip text "TEST_END"
+	GetStringUntilNextSpace( sLine );
+
+	// Time
+	string sTime( GetStringUntilNextSpace( sLine ) );
+	sTime = ConvertTimeToLocalTime( sTime );
+
+	// Name
+	string sSubTestName( GetStringUntilNextSpace( sLine ) );
+	m_DataSaver.AddLineToLast();
+
+	// Add test end info to report
+	m_DataSaver.AddString( "Sub test (" );
+	m_DataSaver.AddString( sSubTestName.c_str() );
+	m_DataSaver.AddString( ") end: " );
+	m_DataSaver.AddString( sTime.c_str() );
+	m_DataSaver.AddLineToLast();
+
+	// Leak count to report in subtest
+	if( m_iLeakNumber > 0 )
+	{
+		if ( m_iLogLevel == 1 || m_iLogLevel == 2 )
+		{
+			m_DataSaver.AddInteger( m_iPinPointedSubTestLeaks );
+			m_DataSaver.AddString( " number of pinpointed memory leaks." );
+			m_DataSaver.AddLineToLast();
+			m_DataSaver.AddInteger( m_iLeakNumber );
+			m_DataSaver.AddString( " memory leaks found." );
+		}
+		else
+		{
+			m_DataSaver.AddInteger( m_iLeakNumber );
+			m_DataSaver.AddString( " memory leaks found." );
+		}
+	}
+	else
+	{
+		m_DataSaver.AddString( "No memory leaks found." );
+	}
+	m_DataSaver.AddLineToLast();
+
+	// Use sTime to store info to xml
+	sTime.append(";");
+	char cTemp[128];
+	// Print all modules whitch have leaks
+	for( unsigned int i = 0 ; i < m_vDllLoadModListSubTest.size() ; i++ )
+	{
+		if( m_vDllLoadModListSubTest.at(i).iLeaks > 0 )
+		{
+			// Normal report
+			m_DataSaver.AddInteger( m_vDllLoadModListSubTest[i].iLeaks );
+			m_DataSaver.AddString( " memory leaks in module: " );
+			m_DataSaver.AddString( m_vDllLoadModListSubTest.at(i).sModuleName.c_str() );
+			m_DataSaver.AddLineToLast();
+			// xml
+			string sModuleNameAndLeaks( m_vDllLoadModListSubTest.at(i).sModuleName );
+			sModuleNameAndLeaks.append(";");
+			sModuleNameAndLeaks.append( itoa( m_vDllLoadModListSubTest.at(i).iLeaks, cTemp, 10 ) );
+			m_DataSaver.SaveXML( sModuleNameAndLeaks , SUBTEST_MEM_LEAK_MODULE );
+		}
+	}
+	// Handle count
+	int iEndHandleCount = atoi( GetStringUntilNextSpace( sLine ).c_str() );
+	// Is there handle leaks in subtest?
+	if( iEndHandleCount > m_iSubtestStartHandleCount )
+	{
+		// Print normal report
+		m_DataSaver.AddInteger( iEndHandleCount - m_iSubtestStartHandleCount );
+		m_DataSaver.AddString( " handle leaks in subtest: " );
+		m_DataSaver.AddString( sSubTestName.c_str() );
+		m_DataSaver.AddString( "." );
+		m_DataSaver.AddLineToLast();
+
+		// Print handle leaks to XML
+		string sNrOfHandleLeaks( itoa( iEndHandleCount - m_iSubtestStartHandleCount, cTemp, 10 ) );
+		sNrOfHandleLeaks.append( ";" );
+		m_DataSaver.SaveXML( sNrOfHandleLeaks, SUBTEST_HANDLE_LEAKS );
+	}
+	else
+	{
+		// No handle leaks
+		m_DataSaver.AddString( TEXT_NO_HANDLE_LEAKS );
+		m_DataSaver.AddLineToLast();
+	}
+	// Save xml
+	m_DataSaver.SaveXML( sTime, TEST_END );
+	// Back to normal leaks
+	m_bSubtestOnGoing = false;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ParseErrorOccured
+// -----------------------------------------------------------------------------
+bool CATDatParser::ParseErrorOccured( string& sLine )
+{
+	LOG_FUNC_ENTRY("CATDatParser::ParseErrorOccured");
+	string sTime,sError;
+
+	// Skip text "ERROR_OCCURED:"
+	GetStringUntilNextSpace( sLine );
+
+	// Get error
+	sError = GetStringUntilNextSpace( sLine );
+	// Get and convert error time
+	sTime = GetStringUntilNextSpace( sLine );
+	sTime = ConvertTimeToLocalTime( sTime );
+
+	// Print error line
+	m_DataSaver.AddLineToLast();
+	m_DataSaver.AddString( "Error occured on: " );
+	m_DataSaver.AddString( sTime.c_str() );
+	m_DataSaver.AddString( ". " );
+	m_DataSaver.AddString( "Symbian error code: " );
+	m_DataSaver.AddString( sError.c_str() );
+	m_DataSaver.AddString( "." );
+	m_DataSaver.AddLineToLast();
+
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ParseMemLeak
+// -----------------------------------------------------------------------------
+bool CATDatParser::ParseMemLeak( string& sLine )
+{
+	LOG_FUNC_ENTRY("CATDatParser::ParseMemLeak");
+	// Increment leak count
+	if ( ! m_bSubtestOnGoing )
+		m_iTotalNumberOfLeaks++;
+
+	// Increase leak number
+	m_iLeakNumber++;
+
+	// Leak data variables
+	string sModuleName;
+	string sLeakSize;
+	string sTime;
+	unsigned long long iTime = 0;
+	string sLeakAddress;
+	
+	// Skip text "MEM_LEAK"
+	GetStringUntilNextSpace( sLine );
+	// Get leak address
+	sLeakAddress = GetStringUntilNextSpace( sLine );
+	// Get time
+	sTime = GetStringUntilNextSpace( sLine );
+	// Convert time to decimal
+	hexToDec( sTime, iTime );
+	// Get memory reserve size
+	sLeakSize = GetStringUntilNextSpace( sLine );
+	// Convert leak time
+	sTime = ConvertTimeToLocalTime( sTime );
+
+	// Loop thru call stack and put memory addresses in vector
+	CleanMemoryAddresses(); // Clean memory address vector
+	CATMemoryAddress* pMemAddr = 0;
+	vector<string> vStrings = ParseStringToVector( sLine, ' ' );
+	for( size_t i = 0; i < vStrings.size() ; i++ )
+	{
+		pMemAddr = new CATMemoryAddress( vStrings.at(i), m_iOffSet );
+		// Set address time
+		pMemAddr->SetTime( iTime );
+		// Set address module name
+		if ( pMemAddr->FindSetModuleName( &m_vDllLoadModList ) )
+		{
+			// Increment leaks in module once
+			if ( sModuleName.empty() )
+			{
+				if ( m_bSubtestOnGoing )
+					m_vDllLoadModListSubTest.at( pMemAddr->GetDllLoadInfoIndex() ).iLeaks++;
+				else
+					m_vDllLoadModList.at( pMemAddr->GetDllLoadInfoIndex() ).iLeaks++;
+				// Set leak's module where it was located.
+				sModuleName = pMemAddr->GetModuleName();
+			}
+		}
+		// Add it to vector
+		m_vMemoryAddress.push_back( pMemAddr );
+	}
+	// If logging level is 0 Skip printing / locating code lines for call stack items.
+	if ( m_iLogLevel == 0 )
+		return true;
+	if ( m_pModules && vStrings.size() > 0 )
+	{
+		// Have we successfully located code line for memory address
+		bool bSuccesfullAddressToLine = false;
+		for( size_t x = 0; x < m_vMemoryAddress.size(); x++ )
+		{
+			int iIndexInDll = m_vMemoryAddress.at( x )->GetDllLoadInfoIndex();
+			if ( iIndexInDll != -1 )
+			{
+				// Dll module name from data file
+				string sDllName = m_vDllLoadModList.at( iIndexInDll ).sModuleName;
+				// Find module from project. These are read from makefiles.
+				for ( size_t y = 0; y < m_pModules->size() ; y++ )
+				{
+					// Module name from project data (makefiles)
+					string sModuleName = m_pModules->at( y )->GetBinaryName();
+					// If we find module from project ones, use it to located code line for memory address
+					// Note! dll names can be pretty messy i.e. DLL_LOAD 10281fc6.dll{000a0000}[10281fc6] 81d57b88 81e60a90
+					if ( sDllName.find( sModuleName ) != string::npos )
+					{
+						m_pModules->at( y )->AddressToLine( m_vMemoryAddress.at( x ) );
+						if ( ! bSuccesfullAddressToLine )
+						{
+							int iPPState = m_vMemoryAddress.at( x )->GetAddressToLineState();
+							if ( iPPState == CATMemoryAddress::EXACT || iPPState == CATMemoryAddress::FUNCTION )
+							{
+								bSuccesfullAddressToLine = true;
+								if ( m_bSubtestOnGoing )
+									m_iPinPointedSubTestLeaks++;
+								else
+									m_iPinPointedLeaks++;
+							}
+						}
+					}
+				}
+			}
+		}
+		// If rom/rofs specified we use it to try get binary and function names
+		// for addresses currently out of process range.
+		if ( m_pRomSymbol )
+		{
+			for( size_t x = 0; x < m_vMemoryAddress.size(); x++ )
+			{
+				if ( m_vMemoryAddress.at(x)->GetAddressToLineState() == CATMemoryAddress::OUT_OF_PROCESS
+					|| m_vMemoryAddress.at(x)->GetAddressToLineState() == CATMemoryAddress::OUT_OF_RANGE )
+				{
+					m_pRomSymbol->AddressToLine( m_vMemoryAddress.at(x) );
+				}
+			}
+		}
+	}
+	// Print leak
+	PrintMemLeak( sTime, sLeakSize, sLeakAddress, sModuleName);
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::PrintMemLeak
+// -----------------------------------------------------------------------------
+void CATDatParser::PrintMemLeak(const string& sTime,
+							   const string& sLeakSize,
+							   const string& sLeakAddr,
+							   const string& sModuleName)
+{
+	LOG_FUNC_ENTRY("CATDatParser::PrintMemLeak");
+	// Print header data of leak
+	m_DataSaver.AddString("\nMemory leak ");
+	m_DataSaver.AddInteger( m_iLeakNumber, true);
+
+	// Leak size
+	m_DataSaver.AddString( " (" );
+	m_DataSaver.AddInteger( _httoi( sLeakSize.c_str() ), true );
+	m_DataSaver.AddString( " bytes) " );
+
+	// Leak address
+	m_DataSaver.AddString("(0x");
+	m_DataSaver.AddString( sLeakAddr.c_str(), true );
+	m_DataSaver.AddString( ") " );
+
+	// Time
+	m_DataSaver.AddString( sTime.c_str(), true );
+	m_DataSaver.AddString( " " );
+	
+	// Module name
+	m_DataSaver.AddString( sModuleName.c_str(), true );
+	m_DataSaver.SaveCarbideDataHeader();
+	
+	// Add header line
+	m_DataSaver.AddLineToLast();
+
+	// Print the call stack items
+	for( size_t i = 0 ; i < m_vMemoryAddress.size() ; i++ )
+	{
+		// On log levels 1 & 2 we only print located code lines.
+		#ifndef ADDR2LINE
+		if( 
+			( m_iLogLevel == 1 || m_iLogLevel == 2 )
+			&&
+			( m_vMemoryAddress.at(i)->GetAddressToLineState() != CATMemoryAddress::EXACT
+			&& m_vMemoryAddress.at(i)->GetAddressToLineState() != CATMemoryAddress::FUNCTION )
+			)
+		{
+			// Skips to next
+			continue;
+		}
+		#endif
+		#ifdef ADDR2LINE
+		if( ( m_iLogLevel == 1 || m_iLogLevel == 2 )
+			&& m_vMemoryAddress.at(i)->GetAddressToLineState() != CATMemoryAddress::EXACT )
+		{
+			// Skips to next
+			continue;
+		}
+		#endif
+		else if ( m_vMemoryAddress.at(i)->GetAddressToLineState() == CATMemoryAddress::OUT_OF_PROCESS )
+		{
+			// Is memory address out of modules range
+			string sTemp;
+			sTemp.append( m_vMemoryAddress.at(i)->GetAddressString() );
+			sTemp.append( " Address out of process memory.");
+			m_DataSaver.AddString( sTemp.c_str(), true );
+			m_DataSaver.AddLineToLast();
+			continue;
+		}
+		
+		// Print memory address
+		m_DataSaver.AddString( m_vMemoryAddress.at(i)->GetAddressString().c_str(), true );
+
+		// Space (only for console output)
+		m_DataSaver.AddString( " " );
+
+		m_DataSaver.AddCarbideData( 
+			NumberToHexString( m_vMemoryAddress.at(i)->GetOffSetFromModuleStart() ) );
+
+		// Module name
+		m_DataSaver.AddString( m_vMemoryAddress.at(i)->GetModuleName().c_str(), true );
+
+		// Print call stack memory address details depending on state of memory address
+		switch( m_vMemoryAddress.at(i)->GetAddressToLineState() )
+		{
+			// Address outside of known processes
+		case CATMemoryAddress::OUT_OF_PROCESS:
+			m_DataSaver.AddLineToLast();
+			break;
+			// Address located outside of known modules symbols
+		case CATMemoryAddress::OUT_OF_RANGE:
+			m_DataSaver.AddString( " " );
+			m_DataSaver.AddString( "???", true );
+			m_DataSaver.AddLineToLast();
+			break;
+		// Symbol state is currently used when using rom symbol file.
+		// From it we get module name & function name.
+		case CATMemoryAddress::SYMBOL:
+			m_DataSaver.AddString( " " );
+			m_DataSaver.AddString( m_vMemoryAddress.at(i)->GetFunctionName().c_str(), true );
+			if ( ! m_vMemoryAddress.at( i )->GetFileName().empty() )
+			{
+				m_DataSaver.AddString( " (" );
+				m_DataSaver.AddString( m_vMemoryAddress.at(i)->GetFileName().c_str(), true );
+				m_DataSaver.AddString( ")" );
+			}
+			m_DataSaver.AddLineToLast();
+			break;
+		// Lst & Map implementation
+		#ifndef ADDR2LINE
+		case CATMemoryAddress::FUNCTION:
+		case CATMemoryAddress::EXACT:
+			m_DataSaver.AddString( " " );
+			m_DataSaver.AddString( m_vMemoryAddress.at(i)->GetFunctionName().c_str(), true );
+			// Small difference displaying details depending on build urel/udeb
+			if ( m_eBuildType == CATProject::UREL )
+			{
+				// UREL
+				// Set build info to data saver
+				m_DataSaver.SetBuild( false );
+				// urel = functionname: linenumber (filename)
+				m_DataSaver.AddString( ": " );
+				if (  m_vMemoryAddress.at(i)->GetFunctionLineNumber() != -1 )
+					m_DataSaver.AddInteger( m_vMemoryAddress.at(i)->GetFunctionLineNumber(), true );
+				else if (  m_vMemoryAddress.at(i)->GetExactLineNumber() != -1 )
+					m_DataSaver.AddInteger( m_vMemoryAddress.at(i)->GetExactLineNumber(), true );
+				m_DataSaver.AddString( " (" );
+				m_DataSaver.AddString( m_vMemoryAddress.at(i)->GetFileName().c_str(), true );
+				m_DataSaver.AddString( ")" );
+				m_DataSaver.AddLineToLast();
+			}
+			else
+			{
+				// UDEB
+				// udeb = functionname: (filename:linenumber)
+				m_DataSaver.AddString( " (" );
+				m_DataSaver.AddString( m_vMemoryAddress.at(i)->GetFileName().c_str(), true );
+				m_DataSaver.AddString( ":" );
+				if(  m_vMemoryAddress.at(i)->GetExactLineNumber() != -1 )
+					m_DataSaver.AddInteger( m_vMemoryAddress.at(i)->GetExactLineNumber(), true );
+				else
+					m_DataSaver.AddString( "???", true );
+				m_DataSaver.AddString( ")" );
+				m_DataSaver.AddLineToLast();
+			}
+			break;
+		#endif
+		// addr2line implementation (new).
+		#ifdef ADDR2LINE
+		case CATMemoryAddress::FUNCTION:
+			m_DataSaver.AddString( " " );
+			m_DataSaver.AddString( m_vMemoryAddress.at(i)->GetFunctionName().c_str(), true );
+			m_DataSaver.AddString( " (" );
+			m_DataSaver.AddString( m_vMemoryAddress.at(i)->GetFileName().c_str(), true );
+			m_DataSaver.AddString( ":" );
+			if(  m_vMemoryAddress.at(i)->GetExactLineNumber() != -1 )
+				m_DataSaver.AddInteger( m_vMemoryAddress.at(i)->GetFunctionLineNumber(), true );
+			else
+				m_DataSaver.AddString( "???", true );
+			m_DataSaver.AddString( ")" );
+			m_DataSaver.AddLineToLast();
+			break;
+		case CATMemoryAddress::EXACT:
+			m_DataSaver.AddString( " " );
+			m_DataSaver.AddString( m_vMemoryAddress.at(i)->GetFunctionName().c_str(), true );
+			m_DataSaver.AddString( " (" );
+			m_DataSaver.AddString( m_vMemoryAddress.at(i)->GetFileName().c_str(), true );
+			m_DataSaver.AddString( ":" );
+			if(  m_vMemoryAddress.at(i)->GetExactLineNumber() != -1 )
+				m_DataSaver.AddInteger( m_vMemoryAddress.at(i)->GetExactLineNumber(), true );
+			else
+				m_DataSaver.AddString( "???", true );
+			m_DataSaver.AddString( ")" );
+			m_DataSaver.AddLineToLast();
+			break;
+		#endif
+		} // End switch
+		// On logging level 1 we only print one located code line
+		#ifndef ADDR2LINE
+		if ( m_iLogLevel == 1 && ( m_vMemoryAddress.at(i)->GetAddressToLineState() == CATMemoryAddress::EXACT ||
+			m_vMemoryAddress.at(i)->GetAddressToLineState() == CATMemoryAddress::FUNCTION ) )
+			break;
+		#endif
+		#ifdef ADDR2LINE
+		if ( m_iLogLevel == 1 && m_vMemoryAddress.at(i)->GetAddressToLineState() == CATMemoryAddress::EXACT )
+			break;
+		#endif
+	} // End call stack items loop
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::SetInputFile
+// -----------------------------------------------------------------------------
+void CATDatParser::SetInputFile(const string& sInputFile)
+{
+	LOG_FUNC_ENTRY("CATDatParser::SetInputFile");
+	m_sInputFile = sInputFile;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::SetOutputFile
+// -----------------------------------------------------------------------------
+void CATDatParser::SetOutputFile(const string& sOutpuFile)
+{
+	LOG_FUNC_ENTRY("CATDatParser::SetOutputFile");
+	m_sOutputFile = sOutpuFile;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::SetRomSymbolFiles
+// -----------------------------------------------------------------------------
+void CATDatParser::SetRomSymbolFiles(const vector<string>& vRomSymbolFiles)
+{
+	LOG_FUNC_ENTRY("CATDatParser::SetRomSymbolFiles");
+	m_vRomSymbolFiles = vRomSymbolFiles;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::SetLogLevel
+// -----------------------------------------------------------------------------
+void CATDatParser::SetLogLevel(int iLogLevel)
+{
+	LOG_FUNC_ENTRY("CATDatParser::SetLogLevel");
+	m_iLogLevel = iLogLevel;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::GetLogLevel
+// -----------------------------------------------------------------------------
+int CATDatParser::GetLogLevel() const
+{
+	LOG_LOW_FUNC_ENTRY("CATDatParser::GetLogLevel");
+	return m_iLogLevel;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::CleanMemoryAddresses
+// -----------------------------------------------------------------------------
+void CATDatParser::CleanMemoryAddresses()
+{
+	LOG_LOW_FUNC_ENTRY("CATDatParser::CleanMemoryAddresses");
+	// Cleanup memory addressses.
+	for( vector<CATMemoryAddress*>::iterator it = m_vMemoryAddress.begin(); it != m_vMemoryAddress.end(); it++ )
+	{
+		delete *it;
+	}
+	m_vMemoryAddress.clear();
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ConvertTimeToLocalTime
+// -----------------------------------------------------------------------------
+string CATDatParser::ConvertTimeToLocalTime( string sInputTime )
+{
+	LOG_LOW_FUNC_ENTRY("CATDatParser::ConvertTimeToLocalTime");
+	//Is process end abnormal?
+	if( sInputTime.compare( LABEL_ABNORMAL ) == 0 )
+	{
+		return string( AT_ANALYZE_ABNORMAL_EXIT );
+	}
+	else
+	// Check that input time is at least 32-bit
+	if( sInputTime.length() <= 8 )
+	{
+		sInputTime.clear();
+		return sInputTime;
+	}
+
+	string sTemp = sInputTime;
+	const char* pTemp = sTemp.c_str();
+
+	// Are all characters hex
+	for( unsigned int i = 0 ; i < sTemp.size() ; i++ )
+	{
+		if( !IsHexCharacter( (pTemp + i) ) )
+		{
+			return sInputTime;
+		}
+	}
+	
+	// Get LSB bits
+	string sLsb;
+	sLsb.append( sInputTime.substr( sInputTime.length()-8, sInputTime.length() ) );
+	unsigned int iLsbTime = (unsigned int)_httoi( sLsb.c_str() );
+
+	// Get MSB bits
+    string sMsb;
+	sMsb.append( sInputTime.substr( 0, sInputTime.length()-8 ) );
+	unsigned int iMsbTime = (unsigned int)_httoi( sMsb.c_str() );
+
+	// Get time in microsecods
+	long long sdf = iMsbTime * 0x100000000 + iLsbTime;
+
+	// Get original time (starting at year 1970 )
+	long long llOrigTime = sdf;
+
+	// Get seconds
+	sdf = ( sdf )/1000000;
+		
+	// Check that sdf contains some time value
+	if( sdf <= 0)
+	{
+		// Error in time calculation
+		// Return empty string
+		sInputTime.clear();
+		return sInputTime;
+	}
+
+	// Original time after year 1970 in seconds
+	long long llOrignTimeInSeconds = sdf;
+	
+	// Calculate new time which does not include millisecods
+	long long llDiffTime = (llOrignTimeInSeconds * 1000000);
+
+	// Calculate time difference in milliseconds
+	int llDiffTimeInMilliSecods = (int)( llOrigTime - llDiffTime )/1000;
+	
+	// Convert difference time to char
+	char cDiffInMilliSeconds[20];
+    _itoa( llDiffTimeInMilliSecods, cDiffInMilliSeconds, 10 );
+
+	// Time info structure
+	struct tm *timeinfo;
+
+	// Get local time
+	timeinfo = localtime ( (time_t*) &sdf );
+
+	// Create string and append memory leak time to it
+	string sTime;
+	sTime.append( asctime( timeinfo ) );
+
+	// Remove last char of locale time string which is \n
+	sTime.resize( (int)sTime.length()-1 );
+	
+	// Get last space index
+	int iLastSpace = (int)sTime.find_last_of(" ");
+
+	// If last space index is valid
+	if( iLastSpace <= (int)sTime.length() && iLastSpace > 0)
+	{
+		string sTempTime;
+		// Append first part of original time string
+		sTempTime.append( sTime.substr( 0, iLastSpace ) );
+		
+		// Append millisecods
+		sTempTime.append( "." );
+		sTempTime.append( cDiffInMilliSeconds );
+
+		// Append the rest of the original time string part
+		sTempTime.append( sTime.substr( iLastSpace, sTime.length()));
+
+		// Clear original and append new time string which includes millisecods
+		sTime.clear();
+		sTime.append( sTempTime );
+	}
+
+	// Return memory leak time
+	return sTime.c_str();
+}
+
+bool CATDatParser::CreateWinscwModule( const string& sBinaryName )
+{
+	LOG_FUNC_ENTRY( "CATDatParser::CreateWinscwModule" );
+	// Is module already created?
+	for( vector<CATModule2*>::iterator it = m_pModules->begin(); it != m_pModules->end(); it++ )
+	{
+		if ( _stricmp( sBinaryName.c_str(), (*it)->GetBinaryName().c_str() ) == 0 )
+			return true;
+	}
+	// No create new one and set its values.
+	CATModule2* mod = new CATModule2();
+	mod->SetTarget( RemovePathAndExt( sBinaryName, true ) );
+	mod->SetRequestedTargetExt( GetExtension( sBinaryName ) );
+	mod->SetReleasePath( string( "\\epoc32\\release" ) );
+	if ( m_eBuildType == CATProject::UDEB )
+		mod->SetFullVariantPath( string( "winscw\\udeb" ) );
+	else
+		mod->SetFullVariantPath( string( "winscw\\urel" ) );
+	mod->SetVariantPlatform( string( "winscw" ) );
+	m_pModules->push_back( mod );
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::ParseStringToVector
+// -----------------------------------------------------------------------------
+vector<string> CATDatParser::ParseStringToVector( const string& sInput, char separator )
+{
+	LOG_LOW_FUNC_ENTRY("CATDatParser::ParseStringToVector");
+	string sString(sInput);
+	// Elements vector
+	vector<string> vStrings;
+	size_t iPos = sString.find( separator );
+	// If can not find it return vector with just one element
+	if ( iPos == string::npos )
+	{
+		// Don't add empty item into vector.
+		if ( sString.size() > 0 )
+			vStrings.push_back( sString );
+		return vStrings;
+	}
+	// Loop elements
+	while( iPos != string::npos )
+	{
+		string sElement = sString.substr(0, iPos);
+		vStrings.push_back( sElement );
+		sString.erase(0, iPos +1 );
+		iPos = sString.find( separator );
+	}
+	// Add last element if any
+	if ( sString.size() > 0 )
+		vStrings.push_back( sString );
+	// Return elements
+	return vStrings;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::FindModuleUsingAddress
+// Function finds module using given address.
+// -----------------------------------------------------------------------------
+int CATDatParser::FindModuleUsingAddress( unsigned long iAddress ) const
+{
+	LOG_LOW_FUNC_ENTRY("CATDatParser::FindModuleUsingAddress");
+	int iRet = -1;
+	for( unsigned int i = 0 ; i < m_vDllLoadModList.size() ; i++ )
+	{
+		// Is address between start and end address?
+		if( iAddress > m_vDllLoadModList[i].iStartAddress && iAddress < m_vDllLoadModList[i].iEndAddress )
+		{
+			iRet = i;
+			break;
+		}	
+	}
+	return iRet;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::FindModuleUsingPID
+// Function finds module using module id.
+// -----------------------------------------------------------------------------
+/*
+int CATDatParser::FindModuleUsingPID( unsigned long iPID ) const
+{
+	LOG_FUNC_ENTRY("CATDatParser::FindModuleUsingPID");
+
+	int iRet = -1;
+
+	// Change module name characters to lowercase
+	for( unsigned int i = 0 ; i < m_vDllLoadModList.size() ; i++ )
+	{
+		if( m_vDllLoadModList[i].iPID == iPID )
+		{
+			iRet = i;
+			break;
+		}	
+	}
+	return iRet;
+}
+*/
+// -----------------------------------------------------------------------------
+// CATDatParser::FindModuleUsingName
+// Function finds module using module name.
+// -----------------------------------------------------------------------------
+int CATDatParser::FindModuleUsingName( const char* pModName )
+{
+	LOG_LOW_FUNC_ENTRY("CATDatParser::FindModuleUsingName");
+
+	// Mod name empty?
+	if( pModName == NULL || *pModName == 0 )
+		return -1;
+
+	int iRet = -1;
+	string sModName( pModName );
+	// Change module name characters to lowercase
+	ChangeToLower( sModName );
+	// Remove variant marks (dots)
+	RemoveAllAfterDotIfTwoDots( sModName);
+	for( unsigned int i = 0 ; i < m_vDllLoadModList.size() ; i++ )
+	{
+		string sTemp( m_vDllLoadModList[i].sModuleName );
+		ChangeToLower( sTemp );
+		// Remove variant marks (dots)
+		RemoveAllAfterDotIfTwoDots( sTemp );
+		if( sTemp.find( sModName ) != string::npos )
+		{
+			iRet = i;
+			break;
+		}	
+	}
+	return iRet;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::SetPrintFlag
+// -----------------------------------------------------------------------------
+void CATDatParser::SetPringFlag( bool bPrintFlag )
+{
+	LOG_FUNC_ENTRY("CATDatParser::SetPringFlag");
+	m_DataSaver.SetPrintFlag( bPrintFlag );
+}
+// -----------------------------------------------------------------------------
+// CATDatParser::SetOffSet
+// -----------------------------------------------------------------------------
+void CATDatParser::SetOffSet( int iOffSet )
+{
+	LOG_FUNC_ENTRY("CATDatParser::SetOffSet");
+	m_iOffSet = iOffSet;
+}
+
+// -----------------------------------------------------------------------------
+// CATDatParser::GetOffSet
+// -----------------------------------------------------------------------------
+int CATDatParser::GetOffSet( ) const
+{
+	LOG_LOW_FUNC_ENTRY("CATDatParser::GetOffSet");
+	return m_iOffSet;
+}
+
+// -----------------------------------------------------------------------------
+// Set project platform.
+// -----------------------------------------------------------------------------
+void CATDatParser::SetProjectPlatform( const string& sPlatform )
+{
+	LOG_FUNC_ENTRY("CATDatParser::SetProjectPlatform");
+	m_sProjectPlatform = sPlatform;
+
+	// Check that platform not empty before determing platform from it.
+	if ( sPlatform.empty() )
+		return;
+
+	// Set functions offset in mapfiles correct (depending on platform).
+	if ( _stricmp( sPlatform.c_str(), "armv5" ) == 0 )
+	{
+		m_iOffSet = FUNCTIONS_OFFSET_IN_MAP_FILE_ARMV5;
+	}
+	else if ( _stricmp( sPlatform.c_str(), "winscw" ) == 0 )
+	{
+		m_iOffSet = FUNCTIONS_OFFSET_IN_MAP_FILE_WINSCW;
+	}
+	else if ( _stricmp( sPlatform.c_str(), "gcce" ) == 0 )
+	{
+		m_iOffSet = FUNCTIONS_OFFSET_IN_GCCE;
+	}
+	else
+	{
+		LOG_STRING( AT_MSG << "Error, cannot set function's offset in map file, invalid platform: " << sPlatform );
+	}
+}
+
+// -----------------------------------------------------------------------------
+// Set projects build type. Use enumeration defined in CATProject.
+// -----------------------------------------------------------------------------
+void CATDatParser::SetProjectBuildType( int eBuildType )
+{
+	LOG_FUNC_ENTRY("CATDatParser::SetProjectBuildType");
+	m_eProjectBuildType = eBuildType;
+}
+
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/CATDataSaver.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,860 @@
+/*
+* 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 CATDataSaver.
+*
+*/
+
+
+#include "../inc/catdatasaver.h"
+
+#include <xercesc/util/OutOfMemoryException.hpp>
+
+#if defined(XERCES_NEW_IOSTREAMS)
+#include <iostream>
+#else
+#include <iostream.h>
+#endif
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::CATDataSaver
+// Constructor.
+// -----------------------------------------------------------------------------
+CATDataSaver::CATDataSaver( void )
+{
+	LOG_FUNC_ENTRY("CATDataSaver::CATDataSaver");
+	m_iLoggingLevel = DEFAULT_LOGGING_LEVEL;
+	m_bPrintImmediately = true;
+	m_bXMLInitOk = false;
+	m_bUdebBuild = true;
+
+	m_iRunNumber = 1;
+
+	m_pDomDoc = NULL;
+	m_pRootElem = NULL;
+	m_Serializer = NULL;
+	m_pCurrentLeakElem = NULL;
+	m_pRunElement = NULL;
+	m_pMemoryLeaks = NULL;
+	m_pHandleLeaks = NULL;
+	m_pCurrentSubTestElem = NULL;
+	m_pSubtestMemoryLeaks = NULL;
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::~CATDataSaver
+// Destructor.
+// -----------------------------------------------------------------------------
+CATDataSaver::~CATDataSaver(void)
+{
+	LOG_FUNC_ENTRY("CATDataSaver::~CATDataSaver");
+	if( m_bXMLInitOk )
+	{
+		if( m_Serializer )
+			delete m_Serializer;
+
+		m_pDomDoc->release();
+		xercesc::XMLPlatformUtils::Terminate();
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::SaveLinesToFile
+// Gets logging level.
+// -----------------------------------------------------------------------------
+void CATDataSaver::SaveLinesToFile( const char* pFileName, int iDataToSave )
+{
+	LOG_FUNC_ENTRY("CATDataSaver::SaveLinesToFile");
+
+	// Nothing to print?
+	if( m_vLines.empty() )
+	{
+		printf( "No output data." );
+		return;
+	}
+	if( iDataToSave != XML_DATA )
+	{
+		ofstream out( pFileName );
+
+		if( !out.good() )
+		{
+			printf( "Can not open file: %s\n", pFileName );
+			return;
+		}
+		switch( iDataToSave )
+		{
+			case TEXT_DATA:
+				for( int i = 0 ; i < (int)m_vLines.size() ; i++ )
+				{
+					out << m_vLines[i].c_str();
+				}
+			break;
+		}
+		out.close();
+	}
+	else
+	{
+		if( m_bXMLInitOk )
+		{
+			xercesc::XMLFormatTarget* myFormTarget = NULL;
+			try
+			{
+				myFormTarget = new xercesc::LocalFileFormatTarget( pFileName );
+				m_Serializer->writeNode(myFormTarget, *m_pDomDoc);
+			}
+			catch(...)
+			{
+				printf( "Can not save output file: %s.", pFileName );
+			}
+			if( myFormTarget )
+				delete myFormTarget; //lint !e118
+		}
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::PrintLinesToScreen
+// Prints all saved lines to screen.
+// -----------------------------------------------------------------------------
+void CATDataSaver::PrintLinesToScreen( void )
+{
+	LOG_FUNC_ENTRY("CATDataSaver::PrintLinesToScreen");
+	// Nothing to print?
+	if( m_vLines.empty() )
+	{
+		printf( "No output data." );
+		return;
+	}
+	for( int i = 0 ; i < (int)m_vLines.size() ; i++ )
+	{
+		printf( m_vLines[i].c_str() );	
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::AddLineToFirst
+// Adds saved line to first in database.
+// -----------------------------------------------------------------------------
+void CATDataSaver::AddLineToFirst( void )
+{
+	LOG_LOW_FUNC_ENTRY("CATDataSaver::AddLineToFirst");
+	m_sLine.append( "\n" );
+	m_vLines.insert( m_vLines.begin(), m_sLine );
+	m_sLine.clear();
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::AddLineToLast
+// Adds saved line to last in database.
+// -----------------------------------------------------------------------------
+void CATDataSaver::AddLineToLast()
+{
+	LOG_LOW_FUNC_ENTRY("CATDataSaver::AddLineToLast");
+	m_sLine.append( "\n" );
+	
+	string sTempDataLine;
+
+	m_vLines.push_back( m_sLine );
+
+	SaveXML( m_sCarbideDataLine, ITEM );
+
+	if( m_bPrintImmediately )
+	{
+		printf( m_sLine.c_str() );
+	}
+
+	m_sCarbideDataLine.clear();
+	m_sLine.clear();
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::AddString
+// Adds string to current line.
+// -----------------------------------------------------------------------------
+void CATDataSaver::AddString( const char* pData, bool bSaveCarbideData )
+{
+	LOG_LOW_FUNC_ENTRY("CATDataSaver::AddString");
+	m_sLine.append( pData );
+
+	if( bSaveCarbideData )
+	{
+		m_sCarbideDataLine.append( pData );
+		m_sCarbideDataLine.append(";");
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::AddInteger
+// Converts integer to string and adds it to current line.
+// -----------------------------------------------------------------------------
+void CATDataSaver::AddInteger( int iValue, bool bSaveCarbideData )
+{
+	LOG_LOW_FUNC_ENTRY("CATDataSaver::AddInteger");
+	char cTemp[128];
+	string sValue( itoa( iValue, cTemp, 10 ) );
+	m_sLine.append( sValue );
+
+	if( bSaveCarbideData )
+	{
+		m_sCarbideDataLine.append( sValue );
+		m_sCarbideDataLine.append(";");
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::SetLoggingLevel
+// Sets logging level.
+// -----------------------------------------------------------------------------
+void CATDataSaver::SetLoggingLevel( int iLoggingLevel )
+{
+	LOG_FUNC_ENTRY("CATDataSaver::SetLoggingLevel");
+	// Check that new logging level is valid 
+	// Acceptable values are between MIN_LOGGING_LEVEL and 
+    // MAX_LOGGING_LEVEL including them
+	if( iLoggingLevel >= MIN_LOGGING_LEVEL && iLoggingLevel <= MAX_LOGGING_LEVEL )
+	{
+		m_iLoggingLevel = iLoggingLevel;
+	}
+	else
+	{
+		// New logging level value is invalid => set default logging level
+		m_iLoggingLevel = DEFAULT_LOGGING_LEVEL;
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::GetLoggingLevel
+// Gets logging level.
+// -----------------------------------------------------------------------------
+int CATDataSaver::GetLoggingLevel( void )
+{
+	LOG_LOW_FUNC_ENTRY("CATDataSaver::GetLoggingLevel");
+	return m_iLoggingLevel;
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::SetPrintFlag
+// Sets print immediately flag.
+// -----------------------------------------------------------------------------
+void CATDataSaver::SetPrintFlag( bool bPrintImmediately )
+{
+	LOG_FUNC_ENTRY("CATDataSaver::SetPrintFlag");
+	m_bPrintImmediately = bPrintImmediately;
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::SaveCarbideDataHeader
+// Sets data header for Carbide data.
+// -----------------------------------------------------------------------------
+void CATDataSaver::SaveCarbideDataHeader( void )
+{
+	LOG_FUNC_ENTRY("CATDataSaver::SaveCarbideDataHeader");
+	SaveXML( m_sCarbideDataLine, LEAK );
+	m_sCarbideDataLine.clear();
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::InitXML
+// Initializes xerces xml parser.
+// -----------------------------------------------------------------------------
+bool CATDataSaver::InitXML( void )
+{
+	LOG_FUNC_ENTRY("CATDataSaver::InitXML");
+	try 
+	{
+		xercesc::XMLPlatformUtils::Initialize();
+	}
+	catch ( ... )//(const XMLException& toCatch) 
+	{
+		// Do your failure processing here
+		printf("XML initialization failed.\n");
+		return false;
+	}
+	// Error code.
+	int errorCode = 0;
+	// getDomIMplementation returns null if source has none.
+	xercesc::DOMImplementation* impl = xercesc::DOMImplementationRegistry::getDOMImplementation(L"Core");
+	if (impl != NULL)
+    {
+		// Create new DOMWriter.
+		m_Serializer = ((xercesc::DOMImplementationLS*)impl)->createDOMWriter();
+		// New document.
+        try
+        {
+			m_pDomDoc = impl->createDocument(
+                        0,                    // Root element namespace URI.
+                        L"results",         // Root element name
+                        0);                   // Document type object (DTD).
+
+            m_pRootElem = m_pDomDoc->getDocumentElement();
+        }
+        catch (const xercesc::OutOfMemoryException&)
+        {
+            XERCES_STD_QUALIFIER cerr << "OutOfMemoryException" << XERCES_STD_QUALIFIER endl;
+            errorCode = 5;
+        }
+        catch (const xercesc::DOMException& e)
+        {
+            XERCES_STD_QUALIFIER cerr << "DOMException code is:  " << e.code << XERCES_STD_QUALIFIER endl;
+            errorCode = 2;
+        }
+        catch (...)
+        {
+            XERCES_STD_QUALIFIER cerr << "An error occurred creating the document" << XERCES_STD_QUALIFIER endl;
+            errorCode = 3;
+        }
+    }  // (inpl != NULL)
+    else
+    {
+        XERCES_STD_QUALIFIER cerr << "Requested implementation is not supported" << XERCES_STD_QUALIFIER endl;
+        errorCode = 4;
+    }
+	if( !errorCode )
+	{
+		m_bXMLInitOk = true;
+		return true;
+	}
+	else
+	{
+		return false;
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::WCharToChar
+// Converts wchar_t* -> char*.
+// -----------------------------------------------------------------------------
+void CATDataSaver::WCharToChar( string& sInput, const WCHAR* Source )
+{
+	LOG_LOW_FUNC_ENTRY("CATDataSaver::WCharToChar");
+	if( !Source )
+		return;
+    int i = 0;
+
+    while( Source[i] != '\0' )
+    {
+		char c = (CHAR)Source[i];
+		sInput.append( &c, 1 );
+        ++i;
+    }
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::CharToWChar
+// Converts char* -> wchar_t*.
+// -----------------------------------------------------------------------------
+LPWSTR CATDataSaver::CharToWChar( const char* str )
+{
+	LOG_LOW_FUNC_ENTRY("CATDataSaver::CharToWChar");
+    LPWSTR out = NULL;
+    if( str != NULL )
+    {
+        int in_len = (int)strlen( str );
+        int out_len = MultiByteToWideChar(CP_ACP, 0, str, in_len, NULL, 0) + 2;
+        out = new WCHAR[out_len];
+
+        if (out)
+        {
+            memset(out, 0x00, sizeof(WCHAR)*out_len);
+            MultiByteToWideChar(CP_ACP, 0, str, in_len, out, in_len);
+        }
+    }
+    return out;
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::SaveXML
+// Writes data to xml tree.
+// -----------------------------------------------------------------------------
+void CATDataSaver::SaveXML( string sInput, int iElementType )
+{
+	LOG_FUNC_ENTRY("CATDataSaver::SaveXML");
+	// Variables ok?
+	if( sInput.empty() || m_pDomDoc == NULL )
+	{
+		return;
+	}
+	try
+	{
+		switch( iElementType )
+		{
+			case RESULT:
+			{
+				// Print number of runs
+				string sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				LPWSTR wTemp = CharToWChar( sTemp.c_str() );
+				m_pRootElem->setAttribute( L"runs", (const LPWSTR)wTemp );
+
+				// Print failed runs
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				if( wTemp )
+					delete[] wTemp;
+				wTemp = CharToWChar( sTemp.c_str() );
+				m_pRootElem->setAttribute( L"failed", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+			}
+			break;
+			case RUN:
+			{
+				if( m_pRootElem == NULL )
+					return;
+				xercesc::DOMElement* runElem = m_pDomDoc->createElement( L"run" );
+				m_pRootElem->appendChild( runElem );
+
+				// Reset handle leaks.
+				m_pHandleLeaks = NULL;
+
+				// Print start time
+				string sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				LPWSTR wTemp = CharToWChar( sTemp.c_str() );
+				runElem->setAttribute( L"start_time", (const LPWSTR)wTemp );
+				runElem->setAttribute( L"end_time", NULL );
+				if( wTemp )
+					delete[] wTemp;
+
+				// Print build target
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				wTemp = CharToWChar( sTemp.c_str() );
+				runElem->setAttribute( L"build_target", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+
+				// Print process name
+				wTemp = CharToWChar( sInput.c_str() );
+				runElem->setAttribute( L"process_name", (const LPWSTR)wTemp );
+
+				m_pRunElement = runElem;
+
+				char cTemp[128];
+				if( wTemp )
+					delete[] wTemp;
+				wTemp = CharToWChar( itoa( m_iRunNumber, cTemp, 10 ) );
+				runElem->setAttribute( L"id", (const LPWSTR)wTemp );
+				m_iRunNumber++;
+				if( wTemp )
+					delete[] wTemp;
+			}
+			break;
+			case LEAK:
+			{
+				m_pCurrentLeakElem = m_pDomDoc->createElement( L"leak" );
+
+
+				if( m_pCurrentLeakElem == NULL || m_pRunElement == NULL )
+					return;
+
+				// Sub test?
+				if( m_pCurrentSubTestElem )
+					m_pCurrentSubTestElem->appendChild( m_pCurrentLeakElem );
+				else
+					m_pRunElement->appendChild( m_pCurrentLeakElem );
+
+				// Print leak ID
+				string sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				LPWSTR wTemp = CharToWChar( sTemp.c_str() );
+				m_pCurrentLeakElem->setAttribute( L"id", (const LPWSTR)wTemp );
+
+				// Print leak size
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				if( wTemp )
+					delete[] wTemp;
+				wTemp = CharToWChar( sTemp.c_str() );
+				m_pCurrentLeakElem->setAttribute( L"size", (const LPWSTR)wTemp );
+
+				// Print leak address
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				if( wTemp )
+					delete[] wTemp;
+				wTemp = CharToWChar( sTemp.c_str() );
+				m_pCurrentLeakElem->setAttribute( L"memaddress", (const LPWSTR)wTemp );
+
+				// Print leak time
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				if( wTemp )
+					delete[] wTemp;
+				wTemp = CharToWChar( sTemp.c_str() );
+				m_pCurrentLeakElem->setAttribute( L"time", (const LPWSTR)wTemp );
+
+				// Print leak module
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				if( wTemp )
+					delete[] wTemp;
+				wTemp = CharToWChar( sTemp.c_str() );
+				m_pCurrentLeakElem->setAttribute( L"module", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+			}
+			break;
+			case ITEM:
+			{
+				xercesc::DOMNode* callstackNode = NULL;
+
+				xercesc::DOMElement* callstackElem = NULL;
+
+				if( m_pCurrentLeakElem  == NULL )
+					return;
+
+				// Print module name
+				if( !m_pCurrentLeakElem->hasChildNodes() )
+				{
+					callstackElem = m_pDomDoc->createElement( L"callstack" );
+					m_pCurrentLeakElem->appendChild( callstackElem );
+					callstackNode = callstackElem;
+				}
+				else
+				{
+					callstackNode = m_pCurrentLeakElem->getFirstChild();
+				}
+
+				// Add callstack item
+				xercesc::DOMElement* itemElem = m_pDomDoc->createElement( L"item" );
+				callstackNode->appendChild( itemElem );
+
+				// Print memory address name
+				string sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				LPWSTR wTemp = CharToWChar( sTemp.c_str() );
+
+				itemElem->setAttribute( L"memaddress", (const LPWSTR)wTemp );
+
+				// Print calculated memory address
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				if( wTemp )
+					delete[] wTemp;
+				wTemp = CharToWChar( sTemp.c_str() );
+
+				itemElem->setAttribute( L"calc_addr", (const LPWSTR)wTemp );
+
+				// Print module name
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				if( wTemp )
+					delete[] wTemp;
+				wTemp = CharToWChar( sTemp.c_str() );
+
+				itemElem->setAttribute( L"module", (const LPWSTR)wTemp );
+
+				// Print function name
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				if( wTemp )
+					delete[] wTemp;
+				wTemp = CharToWChar( sTemp.c_str() );
+
+				itemElem->setAttribute( L"function", (const LPWSTR)wTemp );
+
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+
+				// Print function line from urel build
+				if( !m_bUdebBuild )
+				{
+					if( wTemp )
+						delete[] wTemp;
+					wTemp = CharToWChar( sTemp.c_str() );
+					itemElem->setAttribute( L"function_line", (const LPWSTR)wTemp );
+					sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				}
+
+				// Print file name
+				if( wTemp )
+					delete[] wTemp;
+				// Erase if path found from sTemp.
+				if ( sTemp.rfind( "/" ) != string::npos )
+				{
+					sTemp.erase(0, sTemp.rfind( "/" )+1 );
+				}
+				if ( sTemp.rfind( "\\" ) != string::npos )
+				{
+					sTemp.erase(0, sTemp.rfind( "\\" )+1 );
+				}
+				wTemp = CharToWChar( sTemp.c_str() );
+
+				itemElem->setAttribute( L"file", (const LPWSTR)wTemp );
+
+				// Print line of file
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				if( wTemp )
+					delete[] wTemp;
+				wTemp = CharToWChar( sTemp.c_str() );
+
+				if( m_bUdebBuild )
+					itemElem->setAttribute( L"line", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+			}
+			break;
+			case RUN_END:
+			{
+				if( m_pRunElement == NULL )
+					return;
+				const LPWSTR wTemp = CharToWChar( sInput.c_str() );
+				m_pRunElement->setAttribute( L"end_time", wTemp );
+				if( wTemp )
+					delete[] wTemp;
+			}
+			break;
+			case ERROR_IN_RUN:
+			{
+				if( m_pRunElement == NULL )
+					return;
+				// Add error item
+				xercesc::DOMElement* errorElem = m_pDomDoc->createElement( L"error" );
+				m_pRunElement->appendChild( errorElem );
+
+				// Print error code
+				string sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				LPWSTR wTemp = CharToWChar( sTemp.c_str() );
+				errorElem->setAttribute( L"code", (const LPWSTR)wTemp );
+
+				// Print error time
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				if( wTemp )
+					delete[] wTemp;
+				wTemp = CharToWChar( sTemp.c_str() );
+				errorElem->setAttribute( L"time", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+			}
+			break;
+			case MEM_LEAKS:
+			{
+				if( m_pRunElement == NULL )
+					return;
+				xercesc::DOMElement* memoryLeaksElement = m_pDomDoc->createElement( L"mem_leaks" );
+				m_pRunElement->appendChild( memoryLeaksElement );
+				m_pMemoryLeaks = memoryLeaksElement;
+
+				// Print number of leaks
+				LPWSTR wTemp = CharToWChar( sInput.c_str() );
+				memoryLeaksElement->setAttribute( L"count", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+			}
+			break;
+			case MEM_LEAK_MODULE:
+			{
+				if( m_pMemoryLeaks == NULL )
+					return;
+				xercesc::DOMElement* moduleElement = m_pDomDoc->createElement( L"module" );
+				m_pMemoryLeaks->appendChild( moduleElement );
+
+				// Print module name
+				string sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				LPWSTR wTemp = CharToWChar( sTemp.c_str() );
+				moduleElement->setAttribute( L"name", (const LPWSTR)wTemp );
+
+				if( wTemp )
+					delete[] wTemp;
+				// Print number of memory leaks
+				wTemp = CharToWChar( sInput.c_str() );
+				moduleElement->setAttribute( L"leaks", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+			}
+			break;
+			case HANDLE_LEAKS:
+			{
+				if( m_pRunElement == NULL )
+					return;
+				if( m_pHandleLeaks )
+				{
+					// Update number of leaks
+					LPWSTR wTemp = CharToWChar( sInput.c_str() );
+					m_pHandleLeaks->setAttribute( L"count", (const LPWSTR)wTemp );
+					if( wTemp )
+						delete[] wTemp;
+				}
+				else
+				{
+					xercesc::DOMElement* handleLeaksElement = m_pDomDoc->createElement( L"handle_leaks" );
+					m_pRunElement->appendChild( handleLeaksElement );
+					m_pHandleLeaks = handleLeaksElement;
+
+					// Print number of leaks
+					LPWSTR wTemp = CharToWChar( sInput.c_str() );
+					handleLeaksElement->setAttribute( L"count", (const LPWSTR)wTemp );
+					if( wTemp )
+						delete[] wTemp;
+				}
+			}
+			break;
+			case HANDLE_LEAK_MODULE:
+			{
+				if( m_pHandleLeaks == NULL )
+					return;
+				xercesc::DOMElement* moduleElement = m_pDomDoc->createElement( L"module" );
+				m_pHandleLeaks->appendChild( moduleElement );
+
+				// Print module name
+				string sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				LPWSTR wTemp = CharToWChar( sTemp.c_str() );
+				moduleElement->setAttribute( L"name", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+
+				// Print number of memory leaks
+				wTemp = CharToWChar( sInput.c_str() );
+				moduleElement->setAttribute( L"leaks", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+			}
+			break;
+			case TEST_START:
+			{
+				m_pCurrentSubTestElem = m_pDomDoc->createElement( L"subtest" );
+
+				if( m_pCurrentSubTestElem == NULL || m_pRunElement == NULL )
+					return;
+
+				m_pRunElement->appendChild( m_pCurrentSubTestElem );
+
+				// Print sub test name
+				string sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				LPWSTR wTemp = CharToWChar( sTemp.c_str() );
+				m_pCurrentSubTestElem->setAttribute( L"name", (const LPWSTR)wTemp );
+				if( wTemp )
+				{
+					delete[] wTemp;
+					wTemp = NULL;
+				}
+
+				// Print sub test time
+				sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				wTemp = CharToWChar( sTemp.c_str() );
+				m_pCurrentSubTestElem->setAttribute( L"start_time", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+				break;
+			}
+			case TEST_END:
+			{
+				if( m_pCurrentSubTestElem == NULL )
+					return;
+				// Print end time
+				string sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				LPWSTR wTemp = CharToWChar( sTemp.c_str() );
+				m_pCurrentSubTestElem->setAttribute( L"end_time", (const LPWSTR)wTemp );
+				m_pCurrentSubTestElem = NULL;
+				if( wTemp )
+					delete[] wTemp;
+				break;
+			}
+			case SUBTEST_MEM_LEAKS:
+			{
+				if( m_pCurrentSubTestElem == NULL )
+					return;
+				xercesc::DOMElement* memoryLeaksElement = m_pDomDoc->createElement( L"mem_leaks" );
+				m_pCurrentSubTestElem->appendChild( memoryLeaksElement );
+				m_pSubtestMemoryLeaks = memoryLeaksElement;
+
+				// Print number of leaks
+				LPWSTR wTemp = CharToWChar( sInput.c_str() );
+				memoryLeaksElement->setAttribute( L"count", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+				break;
+			}
+			case SUBTEST_MEM_LEAK_MODULE:
+			{
+				if( m_pSubtestMemoryLeaks == NULL )
+					return;
+				xercesc::DOMElement* moduleElement = m_pDomDoc->createElement( L"module" );
+				m_pSubtestMemoryLeaks->appendChild( moduleElement );
+
+				// Print module name
+				string sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				LPWSTR wTemp = CharToWChar( sTemp.c_str() );
+				moduleElement->setAttribute( L"name", (const LPWSTR)wTemp );
+
+				if( wTemp )
+					delete[] wTemp;
+				// Print number of memory leaks
+				wTemp = CharToWChar( sInput.c_str() );
+				moduleElement->setAttribute( L"leaks", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+				break;
+			}
+			case SUBTEST_HANDLE_LEAKS:
+			{
+				if( m_pCurrentSubTestElem == NULL )
+					return;
+				xercesc::DOMElement* handleLeaksElement = m_pDomDoc->createElement( L"handle_leaks" );
+				m_pCurrentSubTestElem->appendChild( handleLeaksElement );
+
+				//Print number of handle leaks
+				string sTemp = GetStringUntilNextGivenChar( sInput, ';' );
+				LPWSTR wTemp = CharToWChar( sTemp.c_str() );
+				handleLeaksElement->setAttribute( L"count", (const LPWSTR)wTemp );
+				if( wTemp )
+					delete[] wTemp;
+				break;
+			}
+			default:
+			break;
+		}
+	}
+	catch( ... )
+	{
+		printf( "Error when writing data to XML file." );
+	}
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::GetStringUntilNextGivenChar
+// Function returns string from begin of given string until next given char,
+// characters until given char are removed from sInput string.
+// -----------------------------------------------------------------------------
+string CATDataSaver::GetStringUntilNextGivenChar( string& sInput, char cCharacter )
+{
+	LOG_LOW_FUNC_ENTRY("CATDataSaver::GetStringUntilNextGivenChar");
+	string sRet;
+	size_t iPos = sInput.find( cCharacter );
+	if( sInput.size() > 1 && iPos != string::npos )
+	{
+		sRet = sInput.substr( 0, iPos );
+		sInput.erase( 0, (iPos + 1) );
+	}
+	return sRet;
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::SetBuild
+// Function sets build target info.
+// -----------------------------------------------------------------------------
+void CATDataSaver::SetBuild( bool bUdebBuild )
+{
+	LOG_FUNC_ENTRY("CATDataSaver::SetBuild");
+	m_bUdebBuild = bUdebBuild;
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::AddCarbideData
+// Function adds string to Carbide data.
+// -----------------------------------------------------------------------------
+void CATDataSaver::AddCarbideData( const string& sInput )
+{
+	LOG_LOW_FUNC_ENTRY("CATDataSaver::AddCarbideData");
+	m_sCarbideDataLine.append( sInput );
+	m_sCarbideDataLine.append(";");
+}
+
+// -----------------------------------------------------------------------------
+// CATDataSaver::IntegerToString
+// Converts integer to string.
+// -----------------------------------------------------------------------------
+string CATDataSaver::IntegerToString( int iValueToConvert )
+{
+	LOG_LOW_FUNC_ENTRY("CATDataSaver::IntegerToString");
+	char cTemp[128];
+	string sValue( itoa( iValueToConvert, cTemp, 10 ) );
+	return sValue;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/CATMemoryAddress.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,307 @@
+/*
+* 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:  Class representing a memory address and its details.
+*
+*/
+
+
+#include "../inc/CATMemoryAddress.h"
+#include "../inc/CATBase.h"
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::CATMemoryAddress
+// Constructor
+// -----------------------------------------------------------------------------
+CATMemoryAddress::CATMemoryAddress(string& sAddress, unsigned long iOffSet)
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::CATMemoryAddress");
+	m_sAddress = sAddress;
+	m_sFileName = "";
+	m_sFunctionName = "";
+	m_sModuleName = "";
+	m_iAddress = CATBase::_httoi( sAddress.c_str() );
+	m_iDllLoadinfoIndex = -1;
+	m_iModuleStartAddress = 0;
+	m_iOffSetFromModuleStart = 0;
+	m_iExactLineNumber = -1;
+	m_iFunctionLineNumber = -1;
+	m_ePinPointState = OUT_OF_PROCESS;
+	m_iOffSet = iOffSet;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::~CATMemoryAddress
+// Destructor.
+// -----------------------------------------------------------------------------
+CATMemoryAddress::~CATMemoryAddress()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::~CATMemoryAddress");
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::FindSetModuleName
+// Find which binary this address belongs to.
+// Sets also the offsetfrommodulestart.
+// -----------------------------------------------------------------------------
+bool CATMemoryAddress::FindSetModuleName(vector<DLL_LOAD_INFO>* vDlls)
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::FindSetModuleName");
+	vector<DLL_LOAD_INFO>::iterator it;
+	for (  it = vDlls->begin() ;
+		it != vDlls->end(); it++ )
+	{
+		// Is modules load time defined?
+		if ( (*it).iLoadTime > 0 )
+		{
+			// Check that load time is earlier or same as allocation
+			if ( m_iTime >= (*it).iLoadTime
+				&& m_iAddress >= (*it).iStartAddress 
+				&& m_iAddress < (*it).iEndAddress )
+			{
+				// Module is loaded until process end.
+				if ( (*it).iUnloadTime == 0 )
+					break;
+				// Check is allocation done before module was unloaded.
+				else if ( (*it).iUnloadTime >= m_iTime )
+					break;
+			}
+		}
+		// Module has no time defined use only code segments.
+		else
+		{
+			if ( m_iAddress >= (*it).iStartAddress 
+				&& m_iAddress < (*it).iEndAddress )
+				break;
+		}
+	}
+
+	// Did we not find module where address is?
+	if ( it == vDlls->end() )
+		return false;
+
+	m_ePinPointState = OUT_OF_RANGE;
+	m_sModuleName = (*it).sModuleName;
+	m_iModuleStartAddress = (*it).iStartAddress;
+	m_iOffSetFromModuleStart = m_iAddress - m_iModuleStartAddress;
+	m_iOffSetFromModuleStart += m_iOffSet;
+	m_iDllLoadinfoIndex = distance( vDlls->begin(), it ) ;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::SetModuleStartAddress
+// Set start address of the binary in which address resides.
+// Note, this also sets the offset from start value.
+// -----------------------------------------------------------------------------
+void CATMemoryAddress::SetModuleStartAddress(unsigned long iAddress)
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetModuleStartAddress");
+	m_iModuleStartAddress = iAddress;
+	m_iOffSetFromModuleStart = m_iAddress - m_iModuleStartAddress;
+	m_iOffSetFromModuleStart += m_iOffSet;
+}
+
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::GetOffSetFromModuleStart
+// Note return value includes the set offset.
+// So this value is not binary start - address.
+// Instead it is.
+// memory address - binary start address + offset
+// -----------------------------------------------------------------------------
+unsigned long CATMemoryAddress::GetOffSetFromModuleStart()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetOffSetFromModuleStart");
+	return m_iOffSetFromModuleStart;
+}
+
+int CATMemoryAddress::GetDllLoadInfoIndex()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetDllLoadInfo");
+	return m_iDllLoadinfoIndex;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::SetTime
+// -----------------------------------------------------------------------------
+void CATMemoryAddress::SetTime( unsigned long long& ullTime )
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetTime");
+	m_iTime = ullTime;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::GetTIme
+// -----------------------------------------------------------------------------
+unsigned long long CATMemoryAddress::GetTime()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetTime");
+	return m_iTime;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::SetAddress
+// -----------------------------------------------------------------------------
+void CATMemoryAddress::SetAddress(string& sAddress)
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetAddress");
+	m_sAddress = sAddress;
+	m_iAddress = CATBase::_httoi( sAddress.c_str() );
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::GetAddressString
+// -----------------------------------------------------------------------------
+string CATMemoryAddress::GetAddressString()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetAddressString");
+	return m_sAddress;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::SetAddress
+// -----------------------------------------------------------------------------
+void CATMemoryAddress::SetAddress(unsigned long iAddress)
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetAddress");
+	m_iAddress = iAddress;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::GetAddress
+// -----------------------------------------------------------------------------
+unsigned long CATMemoryAddress::GetAddress()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetAddress");
+	return m_iAddress;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::SetModuleName
+// -----------------------------------------------------------------------------
+void CATMemoryAddress::SetModuleName(string& sModuleName)
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetModuleName");
+	m_sModuleName = sModuleName;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::GetModuleName
+// -----------------------------------------------------------------------------
+string CATMemoryAddress::GetModuleName()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetModuleName");
+	return m_sModuleName;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::SetAddressToLineState
+// -----------------------------------------------------------------------------
+void CATMemoryAddress::SetAddressToLineState( ADDRESS_TO_LINE_STATE eState )
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetAddressToLineState");
+	m_ePinPointState = eState;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::GetAddressToLineState
+// -----------------------------------------------------------------------------
+int CATMemoryAddress::GetAddressToLineState()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetAddressToLineState");
+	return m_ePinPointState;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::SetFileName
+// -----------------------------------------------------------------------------
+void CATMemoryAddress::SetFileName(string& sFileName)
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetFileName");
+	m_sFileName = sFileName;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::GetFileName
+// -----------------------------------------------------------------------------
+string CATMemoryAddress::GetFileName()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetFileName");
+	return m_sFileName;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::SetFunctionName
+// -----------------------------------------------------------------------------
+void CATMemoryAddress::SetFunctionName(string& sFunctionName)
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetFunctionName");
+	m_sFunctionName = sFunctionName;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::GetFunctionName
+// -----------------------------------------------------------------------------
+string CATMemoryAddress::GetFunctionName()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetFunctionName");
+	return m_sFunctionName;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::SetFunctionLineNumber
+// -----------------------------------------------------------------------------
+void CATMemoryAddress::SetFunctionLineNumber(int iFunctionLineNumber)
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetFunctionLineNumber");
+	m_iFunctionLineNumber = iFunctionLineNumber;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::GetFunctionLineNumber
+// -----------------------------------------------------------------------------
+int CATMemoryAddress::GetFunctionLineNumber()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetFunctionLineNumber");
+	return m_iFunctionLineNumber;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::SetExactLineNumber
+// -----------------------------------------------------------------------------
+void CATMemoryAddress::SetExactLineNumber(int iExactLineNumber)
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::SetExactLineNumber");
+	m_iExactLineNumber = iExactLineNumber;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::GetExactLineNumber
+// -----------------------------------------------------------------------------
+int CATMemoryAddress::GetExactLineNumber()
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetExactLineNumber");
+	return m_iExactLineNumber;
+}
+
+// -----------------------------------------------------------------------------
+// CATMemoryAddress::GetModuleStartAddress
+// -----------------------------------------------------------------------------
+unsigned long CATMemoryAddress::GetModuleStartAddress() const
+{
+	LOG_LOW_FUNC_ENTRY("CATMemoryAddress::GetModuleStartAddress");
+	return m_iModuleStartAddress;
+}
+
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/CATMmp.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,396 @@
+/*
+* 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:  Class responsible of handling mmp files.
+*
+*/
+
+
+#include "../inc/CATMmp.h"
+
+CATMmp::CATMmp()
+{
+	LOG_FUNC_ENTRY("CATMmp::CATMmp");
+}
+
+CATMmp::~CATMmp()
+{
+	LOG_FUNC_ENTRY("CATMmp::~CATMmp");
+}
+
+// -----------------------------------------------------------------------------
+// CATMmp::IsMmpEdited
+// Checks is the file edited by AT
+// -----------------------------------------------------------------------------
+bool CATMmp::IsMmpEdited( bool bBackup)
+{
+	LOG_FUNC_ENTRY("CATMmp::IsMmpEdited");
+	// Stream to read file
+	ifstream in;
+	// Temp char array to read line
+	char cTemp[MAX_LINE_LENGTH];
+	// Open file
+	if ( bBackup )
+		in.open( CreateMmpBackupPath().c_str() );
+	else
+		in.open( m_sMmpFile.c_str() );
+	// Is file open ok
+	if( ! in.good() )
+	{
+		cout << AT_MSG << "Error, can not open file "
+			<< m_sMmpFile << endl;
+		in.close();
+		return false;
+	}
+	// Search edit start line
+	bool bEdited=false;
+	const char* cFind = MMPFILECHANGES[0].c_str();
+	while( ! bEdited && in.good() )
+	{
+		// Get line
+		in.getline( cTemp, MAX_LINE_LENGTH );
+		// Compare to first line in changes
+		if ( strstr( cTemp, cFind) )
+		{
+			bEdited = true;
+			// Stop looking any further
+			break;
+		}
+	}
+	// Close file and return result
+	in.close();
+	return bEdited;
+}
+
+// -----------------------------------------------------------------------------
+// CATMmp::EditMmpFile
+// Makes AnalyzeTool changes to given mmp file
+// -----------------------------------------------------------------------------
+bool CATMmp::EditMmpFile(const string& sTargetType, const string& sId)
+{
+	LOG_FUNC_ENTRY("CATMmp::EditMmpFile");
+
+	if ( ! RemoveWriteProtections() )
+		return false;
+
+	// Stream where to add changes
+	ofstream out;
+
+	// Open mmp file for editing (append changes to the end)
+	out.open( m_sMmpFile.c_str(), ios::out | ios::app );
+
+	// File open ok?
+	if( !out.good() )
+	{
+		cout << AT_MSG << "Error, can not open file "
+			<< m_sMmpFile;
+		out.close();
+		return false;
+	}
+	
+	// Write lines to mmp file
+	if ( sTargetType.compare( "dll" ) == 0 || sTargetType.compare( "lib" ) == 0 )
+	{
+		// DLL changes
+		int size = sizeof( MMPFILECHANGES_DLL ) / sizeof( string );
+		for( int i = 0; i < size; i++ )
+		{
+			out << endl << MMPFILECHANGES_DLL[i];
+		}
+		out << endl;
+	}
+	else
+	{
+		// Other than DLL changes
+		int size = sizeof( MMPFILECHANGES ) / sizeof( string );
+		for( int i = 0; i < size; i++ )
+		{
+			// After second line of changes add also source statement
+			out << endl << MMPFILECHANGES[i];
+			if ( i == 1 )
+			{
+				out << endl
+					<< "SOURCE            "
+					<< AT_TEMP_CPP_LOWER_START
+					<< sId
+					<< AT_TEMP_CPP_LOWER_END;
+			}
+		}
+		out << endl;
+	}
+	// Close stream
+	out.close();
+
+	cout << AT_MSG << "Mmp file : " << m_sMmpFile << " edited." << endl;
+
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATMmp::BackupMmpFile
+// Backups the mmp file to path/atool_temp/filename.mmp.tmp
+// Calling this function results always to 
+// - none edited mmp
+// - none edited backup
+// - If mmp is write protected. Create writable copy from it. Backup the write
+// procted one.
+// -----------------------------------------------------------------------------
+bool CATMmp::BackupMmpFile( )
+{
+	LOG_FUNC_ENTRY("CATMmp::BackupMmpFile");
+
+	if ( ! RemoveWriteProtections() )
+		return false;
+
+	// Backup path+filename
+	string sBackup = CreateMmpBackupPath();
+
+	// Backup mmp.
+	if ( CopyFile( m_sMmpFile.c_str() , sBackup.c_str(), false ) == 0 )
+	{
+		// Log and return false if failed to copy file
+		LOG_STRING( "error copyfile " << m_sMmpFile << " to " << sBackup );
+		return false;
+	}
+
+	// If backup now edited remove changes from it.
+	if ( IsMmpEdited( true ) )
+	{
+		if ( ! RemoveMmpFileChanges( true ) )
+			return false;
+	}
+
+	return true;
+}
+// -----------------------------------------------------------------------------
+// CATMmp::RestoreMmpFile
+// Restores the mmp file from backup
+// -----------------------------------------------------------------------------
+bool CATMmp::RestoreMmpFile()
+{
+	LOG_FUNC_ENTRY("CATMmp::RestoreMmpFile");
+	
+	if ( ! RemoveWriteProtections() )
+		return false;
+
+	if ( CopyFile( CreateMmpBackupPath().c_str() , m_sMmpFile.c_str(), false ) == 0 )
+	{
+		// Log and return false if failed to copy file
+		LOG_STRING("error copyfile " << CreateMmpBackupPath() << " to " << m_sMmpFile );
+		return false;
+	}
+	else
+		cout << AT_MSG << "Mmp file : " << m_sMmpFile << " restored." << endl;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATMmp::RemoveMmpFileChanges
+// Removes AT changes from given mmp file
+// -----------------------------------------------------------------------------
+bool CATMmp::RemoveMmpFileChanges(bool bBackup)
+{
+	LOG_FUNC_ENTRY("CATMmp::RemoveMmpFileChanges");
+	
+	if ( ! RemoveWriteProtections() )
+		return false;
+
+	// File reading stream
+	ifstream in;
+	// Vector to hold file data
+	vector<string> vLines;
+	// Open file
+	if ( bBackup )
+		in.open( CreateMmpBackupPath().c_str(), ios::in );
+	else
+		in.open( m_sMmpFile.c_str(), ios::in );
+	// Check file open ok
+	if ( ! in.good() )
+	{
+		cout << AT_MSG << "Error, opening file";
+		if ( bBackup )
+			cout << CreateMmpBackupPath();
+		else
+			cout << m_sMmpFile;
+		cout << endl;
+		return false;
+	}
+	// Read file to temporary stream except AT changes
+	char cLine[MAX_LINE_LENGTH];
+	// Boolean to know read or not
+	bool bRead = true;
+	// Integer to confirm that AT changes were succefully found and
+	// not read even if they are found multiple times
+	int iSuccessfull = 0;
+	// Number of 'lines' in mmp changes
+	int iChangesSize = sizeof( MMPFILECHANGES ) / sizeof( string );
+	// First mmp changes line
+	string sFirstLine = MMPFILECHANGES[0];
+	// Last mmp changes line
+	string sLastLine = MMPFILECHANGES[iChangesSize-1];
+	while( in.good() )
+	{
+		in.getline( cLine, MAX_LINE_LENGTH );
+		// Check start of AT changes
+		if( strstr( cLine, sFirstLine.c_str() ) != 0 )
+		{
+			// Remove last linefeed
+			vector<string>::iterator it = vLines.end();
+			it--;
+			if ( it->size() == 0 ) 
+				vLines.erase( vLines.end()-1, vLines.end() );
+			// Stop reading
+			bRead = false;
+			iSuccessfull+=3;
+		}
+		// Read lines outside AT changes
+		if ( bRead )
+		{
+			// Gather all other lines except the AT edits
+			vLines.push_back( string(cLine) );
+		}
+		// Check end of AT changes
+		if( strstr( cLine, sLastLine.c_str() ) != 0 )
+		{
+			// Get empty line
+			in.getline( cLine, MAX_LINE_LENGTH );
+			// Continue reading
+			bRead = true;
+			iSuccessfull-=1;
+		}
+	}
+	// Close reading file stream
+	in.close();
+	// To check all went ok iSuccesfull%2 = 0
+	if ( iSuccessfull%2 != 0 && iSuccessfull >= 2 )
+	{
+		cout << AT_MSG << "Error, removing mmp changes from ";
+		if ( bBackup )
+			cout << CreateMmpBackupPath();
+		else
+			cout << m_sMmpFile;
+		cout << endl;
+		return false;
+	}
+	// Overwrite current mmp file
+	ofstream out;
+	// Open file (truncates old data)
+	if ( bBackup )
+		out.open( CreateMmpBackupPath().c_str(), ios::trunc );
+	else
+		out.open( m_sMmpFile.c_str(), ios::trunc );
+	// Is open ok
+	if( ! out.good() )
+	{
+		cout << AT_MSG << "Error, opening file ";
+		if ( bBackup )
+			cout << CreateMmpBackupPath();
+		else
+			cout << m_sMmpFile;
+		cout << endl;
+	}
+	// Write lines to file
+	for( vector<string>::iterator it = vLines.begin() ; it != vLines.end() ; it++ )
+	{
+		out << *it << endl;
+	}
+	// Close
+	out.close();
+	// Return true
+	return true;
+}
+// -----------------------------------------------------------------------------
+// CATMmp::VerifyAndRecover
+// Wont change mmp if it is not edited
+// Replaces mmp file using backup if it exists and it is
+// not edited otherwise removes changes from mmp file.
+// -----------------------------------------------------------------------------
+bool CATMmp::VerifyAndRecover()
+{
+	LOG_FUNC_ENTRY("CATMmp::VerifyAndRecover");
+	// Is it edited
+	if ( IsMmpEdited() )
+	{
+		string sBackup = CreateMmpBackupPath();
+		if ( FileExists( sBackup.c_str() ) )
+		{
+			// Is backup edited
+			if ( ! IsMmpEdited( true ) )
+			{
+				// Replace original with backup
+				return RestoreMmpFile();
+			}
+		}
+		// Remove changes from original
+		return RemoveMmpFileChanges();
+	}
+	// Non edited original
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATMmp::CreateMmpBackupPath
+// Creates string containing full path to backup mmp file
+// -----------------------------------------------------------------------------
+string CATMmp::CreateMmpBackupPath()
+{
+	LOG_FUNC_ENTRY("CATMmp::CreateMmpBackupPath");
+	// backup path+filename
+	string sBackup;
+	sBackup.append( GetPathOrFileName( false, m_sMmpFile ) );
+	sBackup.append( AT_TEMP_DIR );
+	sBackup.append( "\\" );
+	// Add mmp file name to it and .tmp
+	sBackup.append( GetPathOrFileName( true, m_sMmpFile ) );
+	// Add .tmp
+	sBackup.append( ".tmp" );
+	// Return it
+	return sBackup;
+}
+
+// -----------------------------------------------------------------------------
+// CATMmp::RemoveWriteProtections
+// Removes write protection of mmp file and backup if exists.
+// -----------------------------------------------------------------------------
+bool CATMmp::RemoveWriteProtections()
+{
+	LOG_LOW_FUNC_ENTRY("CATMmp::RemoveWriteProtections");
+
+	// Backup path+filename
+	string sBackup = CreateMmpBackupPath();
+
+	// Check is mmp read-only
+	if ( IsFileReadOnly( m_sMmpFile.c_str() ) )
+	{
+		if( ! SetFileWritable( m_sMmpFile.c_str() ) )
+		{
+			LOG_STRING( "error setting mmp file writable" << m_sMmpFile );
+			return false;
+		}
+	}
+
+	// Check is there a backup if is remove any write protection from it.
+	if ( FileExists( sBackup.c_str() ) )
+	{
+		if ( IsFileReadOnly( sBackup.c_str() ) )
+		{
+			if( ! SetFileWritable( sBackup.c_str() ) )
+			{
+				LOG_STRING( "error setting mmp file writable" << sBackup );
+				return false;
+			}
+		}
+	}
+	return true;
+}
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/CATModule2.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,1630 @@
+/*
+* 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:  Class representing a module in project (sbs2)
+*
+*/
+
+
+#include "../inc/CATModule2.h"
+#include "../inc/CATProject.h"
+#include "../inc/CATDatParser.h"
+#include "../inc/CATMemoryAddress.h"
+#include "../inc/catdbghelper.h"
+#include "../inc/cataddr2line.h"
+
+CATModule2::CATModule2(void)
+{
+	LOG_FUNC_ENTRY("CATModule2::CATModule2");
+	m_bAddressToLineInitialized = false;
+	m_pAddressToLine = 0;
+	m_sErrors = "";
+	m_sMakeFile = "";
+	m_eBuildSystem = CATProject::SBS_V1;
+	m_sCompileInfoText = "";
+}
+
+CATModule2::~CATModule2(void)
+{
+	LOG_FUNC_ENTRY("CATModule2::~CATModule2");
+	if ( m_pAddressToLine )
+		m_pAddressToLine->Close();
+	delete m_pAddressToLine;
+}
+
+bool CATModule2::AddressToLine( CATMemoryAddress* pMemoryAddress )
+{
+	LOG_FUNC_ENTRY("CATModule2::AddressToLine");
+	if ( _stricmp( m_sVariantPlatform.c_str(), "winscw" ) == 0 )
+	{
+		return AddressToLineWinscw( pMemoryAddress );
+	}
+	else if ( _stricmp( m_sVariantPlatform.c_str(), "armv5" ) == 0 )
+	{
+		// addr2line exe.
+		#ifdef ADDR2LINE
+		return AddressToLineAddr2lineExe( pMemoryAddress );
+		#endif
+		// lst and map files.
+		#ifndef ADDR2LINE
+		return AddressToLineArmv5( pMemoryAddress );
+		#endif
+	}
+	else if ( _stricmp( m_sVariantPlatform.c_str(), "gcce" ) == 0 )
+	{
+		return AddressToLineAddr2lineExe( pMemoryAddress );
+	}
+	return false;
+}
+
+bool CATModule2::AddressToLineWinscw( CATMemoryAddress* pMemoryAddress )
+{
+	LOG_FUNC_ENTRY("CATModule2::AddressToLineWinscw( CATMemoryAddress* pMemoryAddress )");
+	if ( m_pAddressToLine == 0 && ! m_bAddressToLineInitialized )
+	{
+		// Use debug helper to locate codelines on winscw platform.
+		m_pAddressToLine = new CATDbgHelper();
+
+		// Create full path to binary which we open using CATDbgHelper.
+		string sFullPathToBinary = GetBinaryFile();
+
+		// If opening of binary not succesfull set return value to false.
+		if ( ! m_pAddressToLine->Open( sFullPathToBinary, pMemoryAddress->GetModuleStartAddress() ) )
+		{
+			LOG_STRING("Error, m_pAddressToLine->Open()");
+			return false;
+		}
+		m_bAddressToLineInitialized = true;
+	}
+	// Check pointer before calling.
+	if ( m_pAddressToLine == 0 )
+		return false;
+	m_pAddressToLine->AddressToLine( pMemoryAddress );
+	return true;
+}
+
+bool CATModule2::AddressToLineArmv5( CATMemoryAddress* pMemoryAddress )
+{
+	LOG_FUNC_ENTRY("CATModule2::AddressToLine( CATMemoryAddress* pMemoryAddress )");
+	if ( ! m_bAddressToLineInitialized )
+		return false;
+	// Find from map file
+	int iMapIndex = GetSymbolIndexUsingAddress( pMemoryAddress->GetOffSetFromModuleStart() );
+	if ( iMapIndex == -1 )
+	{
+		pMemoryAddress->SetAddressToLineState( CATMemoryAddress::ADDRESS_TO_LINE_STATE::OUT_OF_RANGE );
+		return true;
+	}
+	// Set symbol name
+	string sSymbolName = m_vMapFileFuncList.at( iMapIndex ).sFunctionName;
+
+	// Remove (... from symbol name
+	string sSymbolNameRefined( sSymbolName );
+	size_t iPos = sSymbolNameRefined.find( "(" );
+	if ( iPos != string::npos )
+		sSymbolNameRefined.resize( iPos );
+
+	// Set symbol name as function name for memory address
+	pMemoryAddress->SetFunctionName( sSymbolNameRefined );
+
+	// Set state to symbol
+	pMemoryAddress->SetAddressToLineState( CATMemoryAddress::ADDRESS_TO_LINE_STATE::SYMBOL );
+	
+	// Offset from function start addr
+	int iOffSetFromFuncStart = pMemoryAddress->GetOffSetFromModuleStart()
+		- m_vMapFileFuncList.at( iMapIndex ).iAddress;
+
+	// Find from lst list
+	int iLstIndex = GetLineInFileIndexUsingSymbolName( sSymbolName );
+	if ( iLstIndex == -1 )
+		return true;
+
+	// Set pinpointing
+	int iFuncLineNumber = m_vLineInFile.at( iLstIndex ).iLine;
+	string sFileName = m_vLineInFile.at( iLstIndex ).sFileName;
+	string sLstFileName = m_vLineInFile.at( iLstIndex ).sLstName;
+
+	pMemoryAddress->SetFunctionLineNumber( iFuncLineNumber );
+	pMemoryAddress->SetFileName( sFileName );
+	
+	pMemoryAddress->SetAddressToLineState( CATMemoryAddress::ADDRESS_TO_LINE_STATE::FUNCTION );
+
+	// In urel mode don't get exact code line
+	if ( ! IsUDEB() )
+		return true;
+
+	// Next calculate the code line inside function
+	int iExactLineNumber = FindLeakCodeLine( sLstFileName, iFuncLineNumber, iOffSetFromFuncStart );
+	pMemoryAddress->SetExactLineNumber( iExactLineNumber );
+
+	// State is now exact
+	pMemoryAddress->SetAddressToLineState( CATMemoryAddress::ADDRESS_TO_LINE_STATE::EXACT );
+	return true;
+}
+
+bool CATModule2::AddressToLineAddr2lineExe( CATMemoryAddress* pMemoryAddress )
+{
+	LOG_FUNC_ENTRY("CATModule2::AddressToLineAddr2lineExe( CATMemoryAddress* pMemoryAddress )");
+	if ( m_pAddressToLine == 0 && ! m_bAddressToLineInitialized )
+	{
+		// Use addr2line.exe to locate codelines on armv5 and gcce platform.
+		m_pAddressToLine = new CATAddr2line();
+
+		// Create full path to binary .sym file which we open using addr2line.exe.
+		string sFullPathToBinary = GetBinaryFile();
+
+		// If opening of binary not succesfull set return value to false.
+		if ( ! m_pAddressToLine->Open( sFullPathToBinary, pMemoryAddress->GetModuleStartAddress() ) )
+		{
+			LOG_STRING("Error, m_pAddressToLine->Open()");
+			return false;
+		}
+		m_bAddressToLineInitialized = true;
+	}
+	// Check pointer before calling.
+	if ( m_pAddressToLine == 0 )
+		return false;
+
+	m_pAddressToLine->AddressToLine( pMemoryAddress );
+	return true;
+}
+
+// Find symbol of given address
+int CATModule2::GetSymbolIndexUsingAddress( unsigned long iAddress ) const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetSymbolIndexUsingAddress");
+	for( size_t i = 0; i < m_vMapFileFuncList.size(); i++ )
+	{
+		unsigned long iStart = m_vMapFileFuncList.at( i ).iAddress;
+		unsigned long iEnd = ( m_vMapFileFuncList.at( i ).iAddress
+			+ m_vMapFileFuncList.at( i ).iFuncLength );
+
+		if ( iAddress >= iStart && iAddress < iEnd )
+			return (int) i;
+	}
+	return -1;
+}
+
+// Find index of function line in file vector of given symbolname
+int CATModule2::GetLineInFileIndexUsingSymbolName( const string& sSymbolName ) const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetLineInFileIndexUsingSymbolName");
+	for( size_t i = 0; i < m_vLineInFile.size(); i++ )
+	{
+		string sLineInFileName = m_vLineInFile.at( i ).sFunction;
+		if( sLineInFileName.find( sSymbolName ) != string::npos )
+		{
+			return (int) i;
+		}
+	}
+	return -1;
+}
+
+
+// Check does modules symbol file(s) exist.
+bool CATModule2::SymbolFileExist( void )
+{
+	LOG_FUNC_ENTRY("CATModule2::SymbolFileExist");
+	string sFullPathToSym = GetSymbolFile();
+	if ( !FileExists( sFullPathToSym.c_str() ) )
+	{
+		// Add missing symbol file to error string.
+		m_sErrors.append( "Missing symbol file: " );
+		m_sErrors.append( sFullPathToSym );
+		m_sErrors.append( "\n" );
+		return false;
+	}
+	return true;
+}
+
+// Check does modules map file(s) exists.
+bool CATModule2::MapFileExist( void )
+{
+	LOG_FUNC_ENTRY("CATModule2::MapFileExist");
+	string sFullPathToMap = GetMapFile();
+	if ( !FileExists( sFullPathToMap.c_str() ) )
+	{
+		// Add missing symbol file to error string.
+		m_sErrors.append( "Missing map file: " );
+		m_sErrors.append( sFullPathToMap );
+		m_sErrors.append( "\n" );
+		return false;
+	}
+	return true;
+}
+
+//Check does modules binary file(s) exist.
+bool CATModule2::BinaryFileExist( void )
+{
+	LOG_FUNC_ENTRY("CATModule2::BinaryFileExist");
+	string sFullPathToBinary = GetBinaryFile();
+	if ( ! FileExists( sFullPathToBinary.c_str() ) )
+	{
+		// Add missing binary to error string.
+		m_sErrors.append( "Missing binary file: " );
+		m_sErrors.append( sFullPathToBinary );
+		m_sErrors.append( "\n" );
+		return false;
+	}
+	return true;
+}
+
+void CATModule2::AddSource(const string &sSourceFile, const string& sLstFile)
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::AddSource");
+	// Parse sources which are separated by spaces
+	if( sSourceFile.length() < 1  || sLstFile.length() < 1 )
+		return;
+
+	// Skip if its temporary cpp.
+	if ( sSourceFile.find( AT_TEMP_CPP_LOWER_START) != string::npos )
+		return;
+
+	// Source structure
+	SOURCE sNew;
+	sNew.sCpp =  sSourceFile;
+	sNew.sLst = sLstFile;
+
+	// Verify paths.
+	ConvertUnixPathToWin( sNew.sCpp );
+	ConvertUnixPathToWin( sNew.sLst );
+
+	// Lower case them.
+	ChangeToLower( sNew.sCpp );
+	ChangeToLower( sNew.sLst );
+
+	// Add it
+	m_vSources.push_back( sNew );
+}
+
+void CATModule2::AddSources(string& sSource)
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::AddSources");
+	// Parse sources which are separated by spaces
+	if( sSource.length() < 1 )
+		return;
+	// Source structure
+	SOURCE sNew;
+	size_t iSpot = string::npos;
+	iSpot = sSource.find( " " );
+	while( iSpot != string::npos )
+	{
+		// Pickup source
+		sNew.sCpp = sSource.substr(0, iSpot);
+		// Convert path from Unix to Win
+		ConvertUnixPathToWin( sNew.sCpp );
+		// Lowercase it
+		ChangeToLower( sNew.sCpp );
+		// If its temp skip this
+		if ( sNew.sCpp.find( AT_TEMP_CPP_LOWER_START ) == string::npos )
+		{
+			// Get corresponding lst file for source
+			sNew.sLst = GetLstNameOfSource( sNew.sCpp );
+			m_vSources.push_back( sNew );
+			// Remove it from sSource
+			sSource.erase(0,iSpot+1);
+			// Find new one
+		}
+		iSpot = sSource.find( " " );
+	}
+	// Pickup last or only one source
+	sNew.sCpp = sSource;
+	// Convert path from unix to win
+	ConvertUnixPathToWin( sNew.sCpp );
+	// Lowercase it
+	ChangeToLower( sNew.sCpp );
+	// Lst name
+	sNew.sLst = GetLstNameOfSource( sNew.sCpp );
+	if ( sNew.sCpp.find( AT_TEMP_CPP_LOWER_START ) == string::npos )
+	{
+		// Get corresponding lst file for source
+		sNew.sLst = GetLstNameOfSource( sNew.sCpp );
+		m_vSources.push_back( sNew );
+	}
+}
+bool CATModule2::CreateTempCpp(const string& sS60FileName
+									, 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 mode S60
+	if ( eLoggingMode == CATProject::LOGGING_MODE::S60
+		&& m_sS60FileName.empty() )
+	{
+		m_sS60FileName = m_sTarget;
+		m_sS60FileName.append(".");
+		m_sS60FileName.append( m_sTargetType );
+		m_sS60FileName.append(".dat");
+	}
+	return CreateTemporaryCpp( GetUniqueId(), m_sTempPath,
+		m_sS60FileName, eLoggingMode, eBuildType, iAllocCallStackSize, iFreeCallStackSize );
+}
+
+bool CATModule2::ModifyMmp()
+{
+	LOG_FUNC_ENTRY("CATModule2::ModifyMmp");
+	// Create backup
+	if ( ! m_Mmp.BackupMmpFile() )
+		return false;
+	// Hook
+	return m_Mmp.EditMmpFile( m_sTargetType, GetUniqueId() );
+}
+
+bool CATModule2::RestoreMmp()
+{
+	LOG_FUNC_ENTRY("CATModule2::RestoreMmp");
+	// Restore mmp from backup
+	return m_Mmp.RestoreMmpFile();
+}
+
+bool CATModule2::VerifyAndRecoverMmp()
+{
+	LOG_FUNC_ENTRY("CATModule2::VerifyAndRecoverMmp");
+	// Verify mmp
+	return m_Mmp.VerifyAndRecover();
+}
+
+// ----------------------------------------------------------------------------
+// Releasables Handling methos
+// ----------------------------------------------------------------------------
+bool CATModule2::CopyReleasables()
+{
+	LOG_FUNC_ENTRY("CATModule2::CopyReleasables");
+	bool bRet = true;
+	if ( ! CopyLstFilesToTemp() )
+		bRet = false;
+	if ( ! CopyMapFileToTemp() )
+		bRet = false;
+	return bRet;
+}
+
+bool CATModule2::CopyLstFilesToDir( const string& sDir )
+{
+	LOG_FUNC_ENTRY("CATModule2::CopyLstFilesToDir");
+	bool bRet = true;
+	// Copy lst files to given directory.
+	vector<SOURCE>::const_iterator source;
+	for( source = m_vSources.begin(); source != m_vSources.end() ; source++ )
+	{
+		if ( ! FileCopyToPath( source->sLst, sDir ) )
+		{
+			if ( !FileExists( source->sLst.c_str() ) )
+			{
+				m_sErrors.append( "Missing listing file: " );
+				m_sErrors.append( source->sLst );
+				m_sErrors.append( "\n" );
+			}
+			if ( !DirectoryExists( sDir.c_str() ) )
+			{
+				m_sErrors.append( "Missing folder: " );
+				m_sErrors.append( sDir );
+				m_sErrors.append( "\n" );
+			}
+			bRet = false;
+		}
+	}
+	// Return.
+	return bRet;
+}
+
+bool CATModule2::CopyLstFilesToTemp()
+{
+	LOG_FUNC_ENTRY("CATModule2::CopyLstFilesToTemp");
+	// Return boolean
+	bool bRet = true;
+	// Move all lst files except tmp cpp
+	vector<SOURCE>::iterator it = m_vSources.begin();
+	while ( it != m_vSources.end() )
+	{
+		if ( !FileCopyToPath( it->sLst, m_sTempPath ) )
+		{
+			if ( !FileExists( it->sLst.c_str() ) )
+			{
+				m_sErrors.append( "Missing listing file: " );
+				m_sErrors.append( it->sLst );
+				m_sErrors.append( "\n" );
+			}
+			if ( !DirectoryExists( m_sTempPath.c_str() ) )
+			{
+				m_sErrors.append( "Missing folder: " );
+				m_sErrors.append( m_sTempPath );
+				m_sErrors.append( "\n" );
+			}
+			bRet = false;
+		}
+		it++;
+	}
+	return bRet;
+}
+
+bool CATModule2::DeleteLstFilesFromSrc( void )
+{
+	LOG_FUNC_ENTRY("CATModule2::DeleteLstFilesFromSrc");
+	vector<SOURCE>::iterator it = m_vSources.begin();
+	bool bRet = true;
+	// Delete lst files
+	while ( it != m_vSources.end() )
+	{
+		if ( ! FileDelete( it->sLst, true ) )
+			bRet = false;
+		it++;
+	}
+	return bRet;
+}
+
+bool CATModule2::CopyMapFileToTemp()
+{
+	LOG_FUNC_ENTRY("CATModule2::CopyMapFileToTemp");
+	// Return boolean
+	bool bRet = true;
+	// Map File to copy
+	string sMapFile = GetMapFile();
+	if ( !FileCopyToPath( sMapFile, m_sTempPath ) )
+	{
+		bRet = false;
+		if ( !FileExists( sMapFile.c_str() ) )
+		{
+			// Add missing map file to error string.
+			m_sErrors.append( "Missing map file: " );
+			m_sErrors.append( sMapFile );
+			m_sErrors.append( "\n" );
+		}
+		if ( !DirectoryExists( m_sTempPath.c_str() ) )
+		{
+			// Add missing temporary folder
+			m_sErrors.append( "Missing folder: " );
+			m_sErrors.append( m_sTempPath );
+			m_sErrors.append( "\n" );
+		}
+	}
+	return bRet;
+}
+
+bool CATModule2::CleanTemporaryDir()
+{
+	LOG_FUNC_ENTRY("CATModule2::CleanTemporaryDir");
+	bool bRet = true;
+	// Verify mmp
+	if ( ! m_Mmp.VerifyAndRecover() )
+		bRet = false;
+	// Clean temporary dir
+	vector<string> vFileList = DirList( m_sTempPath, false , true );
+	vector<string>::iterator it = vFileList.begin();
+	// Size of constant table
+	int iCount = sizeof( TEMP_EXTENSION_NO_DELETE ) / sizeof( string );
+	while ( it != vFileList.end() )
+	{
+		// Get extension and compare it to list
+		bool bDelete = true;
+		string sExtension = GetExtension( *it );
+		ChangeToLower( sExtension );
+		for ( int i = 0 ; i < iCount ; i++ )
+		{
+			if( sExtension.compare( TEMP_EXTENSION_NO_DELETE[i] ) == 0 )
+			{
+				bDelete = false;
+				break;
+			}
+		}
+		if ( bDelete )
+		{
+			// Delete file
+			if ( ! FileDelete( *it, true ) )
+				bRet = false;
+		}
+		// Increment
+		it++;
+	}
+	return bRet;
+}
+
+bool CATModule2::DeleteTemporaryDir()
+{
+	LOG_FUNC_ENTRY("CATModule2::DeleteTemporaryDir");
+	bool bRet = true;
+	// Verify mmp
+	if ( ! m_Mmp.VerifyAndRecover() )
+		bRet = false;
+	// Delete temp dir
+	if ( !DirDelete( m_sTempPath, true ) )
+		bRet = false;
+	return bRet;
+}
+
+bool CATModule2::IsUDEB() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::IsUDEB");
+	// Determine from variant is this udeb
+	if ( m_sVariantType.find( "udeb" ) != string::npos )
+		return true;
+	return false;
+}
+// ----------------------------------------------------------------------------
+// Private AddressToLine related methods
+// ----------------------------------------------------------------------------
+bool CATModule2::InitializeAddressToLine()
+{
+	LOG_FUNC_ENTRY("CATModule2::InitializeAddressToLine");
+	bool bRet = true;
+	// Read in different way depending on platform
+	if ( m_sVariantPlatform.compare("armv5") == 0 )
+	{
+		// Add static library lst files to source vector,
+		// before reading them.
+		vector<string> vFiles = DirList( AT_TEMP_LST_DIR, false, true );
+		for(vector<string>::iterator it = vFiles.begin() ; it != vFiles.end() ; it ++ )
+		{
+			SOURCE source;
+			source.bStatic = true;
+			source.sLst = *it;
+			source.sCpp = *it;
+			source.sCpp = CATBase::RemovePathAndExt( source.sCpp, false );
+			source.sCpp.append( ".cpp" );
+			m_vSources.push_back( source );
+		}
+
+		if ( ! ReadListingFilesArmv5() )
+			bRet = false;
+		if ( ! ReadMapFileArmv5() )
+			bRet = false;
+
+		if ( bRet )
+			m_bAddressToLineInitialized = true;
+	}
+	return bRet;
+}
+
+
+bool CATModule2::ReadListingFilesArmv5()
+{
+	LOG_FUNC_ENTRY("CATModule2::ReadListingFilesArmv5");
+	char cTemp[MAX_LINE_LENGTH];
+	vector<SOURCE>::iterator viFileIter = m_vSources.begin();
+	int iNumberOfLstFiles = (int)m_vSources.size();
+	vector<string> vTempLines;
+	string sFileName;
+
+	// Open all .lst files
+	while( iNumberOfLstFiles > 0 )
+	{
+		// Make .lst file name
+		sFileName.clear();
+	
+		// If lst file is not from static library make path to modules temporary directory.
+		if ( viFileIter->bStatic != true )
+		{
+			// Remove path
+			if( viFileIter->sLst.find("\\") != string::npos )
+				sFileName.append(
+				viFileIter->sLst.substr( viFileIter->sLst.find_last_of( "\\" ) + 1
+				, viFileIter->sLst.size() ) );
+			else
+				sFileName.append( viFileIter->sLst );
+
+			// Add temporary dir
+			sFileName.insert( 0, m_sTempPath );
+		}
+		else
+		{
+			// Lst from static library don't change path.
+			sFileName = viFileIter->sLst;
+		}
+		// Open lst file
+		ifstream in( sFileName.c_str() );
+
+		// If file can not be opened, try to open next file
+		if( !in.good() )
+		{
+			viFileIter++;
+			iNumberOfLstFiles--;
+			continue;
+		}
+
+		string sTemp;
+		// Clear temporary lines
+		vTempLines.clear();
+		// Add all lines to temp list
+		do
+		{
+			in.getline( cTemp, MAX_LINE_LENGTH );
+			sTemp.clear();
+			sTemp.append( cTemp );
+			vTempLines.push_back( sTemp );
+		}
+		while( in.good() );
+
+		LINE_IN_FILE structLineInFile;
+		
+		bool bFindENDP = false;
+		vector<string>::iterator viLinesIter = vTempLines.begin();
+
+		// Loop throw all lines in .lst file
+		while( viLinesIter != vTempLines.end() )
+		{
+			// Find ";;;"
+			if( !bFindENDP && strstr(viLinesIter->c_str(), ";;;") != NULL )
+			{
+				bFindENDP = true;
+
+				vector<string>::iterator viLineTempIter = viLinesIter;
+
+				// Find top line of function definition
+				while( viLineTempIter->size() > 0 )
+				{
+					viLineTempIter--;
+				}
+				viLineTempIter++;
+				structLineInFile.sFunction.clear();
+				structLineInFile.sFunction.append( viLineTempIter->c_str() );
+
+				viLinesIter++;
+				// Get Line
+				sTemp.clear();
+				sTemp.append( viLinesIter->c_str() );
+				sTemp.erase(0,3);
+				size_t iSize = sTemp.find_first_of(' ');
+				if( iSize != string::npos )
+					sTemp.resize(iSize);
+				structLineInFile.iLine = atoi( sTemp.c_str() );
+
+				structLineInFile.sFileName.clear();
+				structLineInFile.sFileName.append( viFileIter->sCpp.c_str() );
+				structLineInFile.sLstName = sFileName;
+				m_vLineInFile.push_back( structLineInFile );
+			}
+			else if( strstr(viLinesIter->c_str(), "ENDP") != NULL )
+				bFindENDP = false;
+			viLinesIter++;
+		}
+		viFileIter++;
+		iNumberOfLstFiles--;
+	}
+	if( m_vLineInFile.size() > 0 )
+		return true;
+	return false;
+}
+
+bool CATModule2::ReadMapFileArmv5()
+{
+	LOG_FUNC_ENTRY("CATModule2::ReadMapFileArmv5");
+	// Map file name
+	string sMapFileName	= GetMapFile();
+	// Remove path
+	if ( sMapFileName.find("\\") != string::npos )
+		sMapFileName.erase(0, sMapFileName.find_last_of('\\')+1 );
+	// Add temp path
+	sMapFileName.insert(0, m_sTempPath );
+
+	// Open .map file
+	ifstream in( sMapFileName.c_str() );
+	
+	// File open ok?
+	if( ! in.good() )
+	{
+		in.close();
+		return false;
+	}
+	char cTemp[MAX_LINE_LENGTH];
+	bool bFirstFuncFound = false;
+	// Get all lines where is "Thumb"
+	do
+	{
+		// Load one line from .map file
+		in.getline( cTemp, MAX_LINE_LENGTH );
+		// Find _E32Startup
+		if( !bFirstFuncFound && ( strstr( cTemp, "_E32Startup" ) != NULL) )
+		{
+			bFirstFuncFound = true;
+		}
+		else if( !bFirstFuncFound && ( strstr( cTemp, "_E32Dll" ) != NULL) )
+		{
+			bFirstFuncFound = true;
+		}
+		else if( !bFirstFuncFound )
+			// Skip if _E32Startup not found
+			continue;
+
+		if( strstr( cTemp, "Thumb Code" ) != NULL || strstr( cTemp, "ARM Code" ) != NULL)
+		{
+			MAP_FUNC_INFO structMapFileLineInfo;
+			structMapFileLineInfo.sWholeLine.append( cTemp );
+
+			// Get memory string address from line
+			char* pStart = strstr( cTemp, "0x" );
+			// Check did strstr return null.
+			if( pStart == NULL )
+				continue;
+			char* pTemp = pStart;
+			char TempString[MAX_LINE_LENGTH];
+			TempString[0] = 0;
+			size_t iLength = 0;
+			while( *pTemp != ' ' )
+			{
+				TempString[iLength] = *pTemp;
+				pTemp++;
+				iLength++;
+			}
+			TempString[iLength] = 0;
+
+			structMapFileLineInfo.iAddress = CATDatParser::_httoi( TempString );
+
+			pTemp = cTemp;
+			TempString[0] = 0;
+			
+			// Get function name
+
+			// Skip spaces
+			while( *pTemp == ' ' )
+			{
+				pTemp++;
+			}
+			iLength = 0;
+			// Find end of function name
+			string sTemp( pTemp );
+
+			// Location of character ')'
+			iLength = sTemp.find_first_of(')');
+
+			// Location of character ' '
+			size_t iLength2 = sTemp.find_first_of(' ');
+			
+			// If ')' character is the last char and
+			// character ' ' is closer than ')' use location of ' '
+			if( ( iLength + 1 ) == sTemp.length() && iLength2 < iLength )
+				iLength = iLength2 - 1;
+			
+			if( iLength != string::npos )
+				sTemp.resize( (iLength + 1) );
+
+			structMapFileLineInfo.sFunctionName.append( sTemp.c_str() );
+
+			bool bARM = false;
+			// Find function length
+			pStart = strstr( cTemp, "Thumb Code" );
+			if( pStart == NULL )
+			{
+				pStart = strstr( cTemp, "ARM Code" );
+				bARM = true;
+			}
+			if( pStart != NULL )
+			{
+				if( bARM )
+					pStart += 8;
+				else
+					pStart += 10;
+				while(*pStart == ' ')
+				{
+					pStart++;
+				}
+				sTemp.clear();
+				sTemp.append( pStart );
+				size_t iSize = sTemp.find_first_of(' ');
+				if( iSize != string::npos )
+					sTemp.resize( iSize );
+			}
+
+			structMapFileLineInfo.iFuncLength = atoi( sTemp.c_str() );
+			if( bFirstFuncFound && structMapFileLineInfo.iFuncLength > 0 )
+				// Save to list
+				m_vMapFileFuncList.push_back( structMapFileLineInfo );
+		}
+	}
+	while( in.good() );
+	in.close();
+	return true;
+}
+
+int CATModule2::FindLeakCodeLine( string& sFileName, int iLine, unsigned long iFromFuncAddress ) const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::FindLeakCodeLine");
+	if ( sFileName.empty() )
+		return -1;
+	char cLineFromFile[MAX_LINE_LENGTH];
+	vector<string> vTempLines;
+	string sTemp;
+	char* pTemp = NULL;
+	char* pTempEnd = NULL;
+	int iFoundLine = -1;
+	int iRet = -1;
+	
+	// Open lst file
+	ifstream in( sFileName.c_str() );
+
+	bool bLineFound = false;
+	bool bFirstAddressInFuncFound = false;
+	unsigned long iFirstAddressInFunc = 0;
+	while( in.good() )
+	{
+		in.getline( cLineFromFile, MAX_LINE_LENGTH );
+
+		if( bLineFound )
+		{
+			vTempLines.push_back( cLineFromFile );
+			// Is first character digit
+			if( isdigit( cLineFromFile[0] ) )
+			{
+				if( !bFirstAddressInFuncFound )
+				{
+					bFirstAddressInFuncFound = true;
+					sTemp.clear();
+					sTemp.append( cLineFromFile );
+					// Get value until next space
+					sTemp.resize( sTemp.find_first_of(' ') );
+
+					iFirstAddressInFunc = CATDatParser::_httoi( sTemp.c_str() );
+
+					// Return function start line if margin 0
+					if( iFromFuncAddress == 0 )
+					{
+						iRet = iLine;
+						return iRet;
+					}
+				}
+				else
+				{
+					// Find correct line using iFromFuncAddress variable
+					sTemp.clear();
+					sTemp.append( cLineFromFile );
+					// Get value until next space
+					sTemp.resize( sTemp.find_first_of(' ') );
+
+					unsigned long iValue = CATDatParser::_httoi( sTemp.c_str() );
+
+					if( ( iValue - iFirstAddressInFunc ) >= iFromFuncAddress )
+					{
+						// If there is data in function, code line can not be found
+						if( strstr( cLineFromFile , "DCB" ) != NULL )
+						{
+							iRet = -1;
+							return iRet;
+						}
+						pTemp = strstr( cLineFromFile, ";" );
+						// Get line number
+						bool bStringNumber = true;
+						if( pTemp != NULL )
+						{
+							string sTempLine( pTemp + 1 );
+							// Are all characters numbers?
+							for( unsigned int i = 0 ; i < sTempLine .size() ; i++ )
+							{
+								if( !isdigit(sTempLine[i]) )
+								{
+									bStringNumber = false;
+									break;
+								}
+							}
+						}
+						else
+							bStringNumber = false;
+						if( bStringNumber )
+						{
+							pTemp++;
+							// Get line number
+							iRet = atoi( pTemp );
+						}
+						else
+						{
+							vector<string>::iterator sTempIter = vTempLines.end();
+
+							sTempIter--;
+
+							// Find last code line
+							while( sTempIter != vTempLines.begin() )
+							{
+								if( strstr( sTempIter->c_str() , "DCB" ) != NULL )
+								{
+									iRet = -1;
+									return iRet;
+								}
+								if( strstr( sTempIter->c_str() , ";;;" ) == NULL )
+									sTempIter--;
+								else
+									break;
+							}
+							if(sTempIter == vTempLines.begin() && strstr( sTempIter->c_str() , ";;;" ) == NULL)
+							{
+								iRet = -1;
+								return iRet;
+							}
+							sTempIter->erase( 0, 3 );
+							sTempIter->resize( sTempIter->find(' ') );
+
+							// Leak line
+							iRet = atoi( sTempIter->c_str() );
+						}
+						return iRet;
+					}
+				}
+			}
+		}
+		else // Line in file not found
+		{
+			// Find line of function
+			if( strstr( cLineFromFile, ";;;" ) != NULL )
+			{
+				pTemp = &cLineFromFile[0];
+				// Skip characters ";;;"
+				pTemp += 3;
+				pTempEnd = pTemp;
+				// Find end of line number
+				while( *pTempEnd != ' ' )
+				{
+					pTempEnd++;
+				}
+				*pTempEnd = 0;
+				iFoundLine = atoi( pTemp );
+				*pTempEnd = ' ';
+				if( iLine == iFoundLine )
+				{
+					bLineFound = true;
+				}
+			}
+		}
+	}
+	return iRet;
+}
+
+bool CATModule2::IsMakeSuccessfull()
+{
+	LOG_FUNC_ENTRY("CATModule2::IsMakeSuccessfull");
+	m_sErrors.clear();
+
+	string sSearch;
+	bool bMakeSuccess = true;
+	
+	// Lst files checked only with armv5 platform.
+	if ( IsPlatformArmv5() )
+	{
+		sSearch.append( m_sTempPath );
+		sSearch.append( "*.lst" );
+		if( !SearchFileWithExtension( sSearch.c_str(), false, m_sErrors ) )
+			bMakeSuccess = false;
+		
+		// Map
+		sSearch.clear();
+		sSearch.append( m_sTempPath );
+		sSearch.append( "*.map" );
+		if( !SearchFileWithExtension( sSearch.c_str(), false, m_sErrors ) )
+			bMakeSuccess = false;
+	}
+
+	// .tmp
+	sSearch.clear();
+	sSearch.append( m_sTempPath );
+	sSearch.append( "*.tmp" );
+	if( !SearchFileWithExtension( sSearch.c_str(), false, m_sErrors ) )
+		bMakeSuccess = false;
+
+	return bMakeSuccess;
+}
+
+bool CATModule2::CreateBuildCompleteFile()
+{
+	LOG_FUNC_ENTRY("CATModule2::CreateBuildCompleteFile");
+	// Don't create file if temp path not set cause might be anywhere
+	if ( m_sTempPath.empty() )
+		return false;
+	// Create empty file indicating this module is build
+	string sFile = m_sTempPath;
+	if( sFile.at( sFile.length() - 1 ) != '\\' )
+		sFile.append("\\");
+	sFile.append( "BuildComplete" );
+	ofstream out( sFile.c_str() );
+	out << m_sVariantPlatform << endl;
+	out << m_sVariantType << endl;
+	out.close();
+	return true;
+}
+
+bool CATModule2::ReadMakeFileFromTemp()
+{
+	LOG_FUNC_ENTRY("CATModule2::ReadMakeFileFromTemp");
+	// Set makefile to point to temporary directory.
+	string sMakeFile = m_sTempPath;
+	sMakeFile.append( RemovePathAndExt( m_Mmp.m_sMmpFile, true ) );
+	sMakeFile.append( "." );
+	sMakeFile.append( AT_LEVEL_2_MAKEFILE_EXT );
+	m_sMakeFile = sMakeFile;
+	return ReadMakeFilePrivate();
+}
+
+bool CATModule2::ReadMakeFile()
+{
+	LOG_FUNC_ENTRY("CATModule2::ReadMakeFile");
+	// Read makefile
+	if ( ReadMakeFilePrivate() )
+	{
+		// Copy makefile to temporary directory.
+		string sMakeFile = m_sTempPath;
+		sMakeFile.append( RemovePathAndExt( m_Mmp.m_sMmpFile, true ) );
+		sMakeFile.append( "." );
+		sMakeFile.append( AT_LEVEL_2_MAKEFILE_EXT );
+		FileCopyToPath( m_sMakeFile, sMakeFile );
+		return true;
+	}
+	return false;
+}
+
+bool CATModule2::ReadMakeFilePrivate()
+{
+	LOG_FUNC_ENTRY("CATModule2::ReadMakeFilePrivate");
+
+	if ( m_sMakeFile.empty() )
+		return false;
+
+	LOG_STRING( "using makefile :" << m_sMakeFile );
+
+	// Stream object to read files
+	ifstream in;
+	// Char array to read line from file
+	char cLine[MAX_LINE_LENGTH];
+	// String to use as buffer from file
+	string sLine;
+	// Open file
+	in.open( m_sMakeFile.c_str(), ios_base::in );
+	// Check that its open
+	if ( ! in.good() )
+	{
+		// Cannot open file
+		cout << AT_MSG << "Error, can not open file: " << m_sMakeFile << endl;
+		return false;
+	}
+	// Check is it wrapper makefile (starts with "%:")
+	in.getline( cLine, MAX_LINE_LENGTH );
+	if ( cLine[0] == '%' && cLine[1] == ':' )
+	{
+		LOG_STRING("Found wrapper makefile");
+		in.close();
+		// Use ".default" makefile
+		string sDefaultMakeFile = m_sMakeFile.substr( 0, m_sMakeFile.find_last_of( "." ) );
+		sDefaultMakeFile.append( ".DEFAULT" );
+		LOG_STRING( "using makefile :" << m_sMakeFile );
+		// Does default exists. If not we need to run "wrapper make"
+		if ( ! FileExists( sDefaultMakeFile.c_str() ) )
+		{
+			// Run the wrapper make to create "real" makefile
+			string sMakeFileCmd;
+			sMakeFileCmd.append("make -f \"");
+			sMakeFileCmd.append( m_sMakeFile );
+			sMakeFileCmd.append( "\"" );
+			LOG_STRING( "using makefile :" << m_sMakeFile );
+			cout << AT_MSG_SYSTEM_CALL << sMakeFileCmd << endl;
+			int iRet = (int)system( sMakeFileCmd.c_str() );
+			if ( iRet )
+			{
+				cout << MAKE_ERROR;
+				return false;
+			}
+		}
+		m_sMakeFile = sDefaultMakeFile;
+		// Open new file
+		in.open( m_sMakeFile.c_str(), ios_base::in );
+		// Check that it's open
+		if ( ! in.good() )
+		{
+			// Cannot open file
+			cout << AT_MSG << "Error, can not open makefile: " << m_sMakeFile << endl;
+			return false;
+		}
+	}
+	in.seekg( ios_base::beg );
+
+	// Number of lines to read at max for basic module information.
+	int iReadLineCount = 20;
+	// Extension from target line. to be compared with targettype.
+	string sTargetExtension;
+	// Read line at a time. Loop until we find it or eof
+	do {
+		// Read line from file to array
+		in.getline( cLine, MAX_LINE_LENGTH );
+		iReadLineCount--;
+
+		sLine.clear();
+		// Put that to string
+		sLine.append( cLine );
+		// Search target
+		if ( sLine.find( MAKEFILE_TARGET_STRING ) != string::npos )
+		{
+			// Found it. Now remove other than type from line
+			sLine.erase( 0, strlen( MAKEFILE_TARGET_STRING ) );
+			ChangeToLower( sLine );
+			sTargetExtension.clear();
+			sTargetExtension = GetExtension( sLine );
+			m_sTarget = RemovePathAndExt( sLine, true);
+			LOG_STRING("found target: " << sLine );
+		}
+		// Search targettype
+		else if ( sLine.find( MAKEFILE_TARGETTYPE_STRING ) != string::npos )
+		{
+			// Found it. Now remove other than type from line
+			sLine.erase( 0, strlen( MAKEFILE_TARGETTYPE_STRING ) );
+			ChangeToLower( sLine );
+			m_sTargetType = sLine;
+			LOG_STRING("found target type: " << m_sTargetType );
+		}
+		else if ( sLine.find( MAKEFILE_BASIC_TARGETTYPE_STRING ) != string::npos )
+		{
+			sLine.erase( 0, strlen( MAKEFILE_BASIC_TARGETTYPE_STRING ) );
+			ChangeToLower( sLine );
+			m_sRequestedTargetExt = sLine;
+			// Compare with the extension in target line if not same use target lines if its "valid".
+			if ( m_sRequestedTargetExt.compare( sTargetExtension ) != 0  && sTargetExtension.size() > 0 )
+				m_sRequestedTargetExt = sTargetExtension;
+			LOG_STRING("found requested target extension: " << m_sTargetType );		
+		}
+		// Feature variant details
+		else if ( sLine.find( MAKEFILE_FEATURE_VARIANT_NAME ) != string::npos )
+		{
+			sLine.erase( 0, strlen( MAKEFILE_FEATURE_VARIANT_NAME ) );
+			m_sFeatureVariantName = sLine;
+			LOG_STRING("found feature variant name: " << sLine );
+		}
+		else if ( sLine.find( MAKEFILE_FEATURE_VARIANT_UREL_LABEL ) != string::npos )
+		{
+			sLine.erase( 0, strlen( MAKEFILE_FEATURE_VARIANT_UREL_LABEL ) );
+			LOG_STRING("found feature variant urel label: " << sLine );
+			if ( sLine.compare("INVARIANT") != 0 )
+				m_sFeatureVariantURELLabel = sLine;
+		}
+		else if ( sLine.find( MAKEFILE_FEATURE_VARIANT_UDEB_LABEL ) != string::npos )
+		{
+			sLine.erase( 0, strlen( MAKEFILE_FEATURE_VARIANT_UDEB_LABEL ) );
+			LOG_STRING("found feature variant udeb label: " << sLine );
+			if ( sLine.compare("INVARIANT") != 0 )
+				m_sFeatureVariantUDEBLabel = sLine;
+		}
+	} while( in.good() && iReadLineCount > 0 );
+
+	// Search compile definitions
+	// CWDEFS CCDEFS ARMCCDEFS
+	do
+	{
+		in.getline( cLine, MAX_LINE_LENGTH );
+		sLine.clear();
+		sLine.append( cLine );
+		if ( sLine.substr( 0 , 6 ).compare( string("CWDEFS") ) == 0 
+			|| sLine.substr( 0 , 6 ).compare( string("CCDEFS") ) == 0 )
+		{
+			sLine.erase( 0, 8 );
+			m_sCompileDefinitions = sLine;
+			break;
+		}
+		else if( sLine.substr( 0 , 9 ).compare( string("ARMCCDEFS") ) == 0  )
+		{
+			sLine.erase( 0, 11 );
+			m_sCompileDefinitions = sLine;
+			break;
+		}
+	} while( in.good() );
+	// Move reading back to start if we could not find compile flags.
+	in.seekg( ios_base::beg );
+
+	// Search listing information (modules source files).
+	int iFindItem = 1; //1 = Source, 2 = LISTINGUDEB/UREL, 3 = lst file
+	string sCdefs;
+	string sSource;
+	string sLst;
+	do
+	{
+		in.getline( cLine, MAX_LINE_LENGTH );
+		sLine.clear();
+		sLine.append( cLine );
+
+		switch( iFindItem )
+		{
+			case 1:
+				if( sLine.find( "# Source " ) != string::npos )
+				{
+					iFindItem = 2;
+					// Remove text "# Source "
+					sLine.erase( 0, 9 );
+					sSource = sLine;
+				}
+			break;
+			case 2:
+				if( IsUDEB() )
+				{
+					if( sLine.find( "LISTINGUDEB" ) != string::npos )
+					{
+						iFindItem = 3;
+					}
+				}
+				else
+				{
+					if( sLine.find( "LISTINGUREL" ) != string::npos )
+					{
+						iFindItem = 3;
+					}
+				}
+			break;
+			case 3:
+				if( sLine.find( "perl -S ecopyfile.pl" ) != string::npos )
+				{
+					// Save lst file to list
+					sLine.erase( 0, ( sLine.find_first_of( "\\" ) ) );
+					// remove last char if '"'
+					if ( sLine.at( sLine.size()-1 ) == '"' )
+						sLine.erase( sLine.size()-1, sLine.size() );
+					sLst = sLine;
+					AddSource( sSource, sLst );
+					iFindItem = 1;
+					sSource.clear(); sLst.clear();
+					
+				}
+			break;
+		}
+	}
+	while( in.good() );
+	// close and return
+	in.close();
+	return true;
+}
+
+// ----------------------------------------------------------------------------
+// Get & Sets
+// ----------------------------------------------------------------------------
+string CATModule2::GetErrors() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetErrors");
+	return m_sErrors;
+}
+
+string CATModule2::GetS60FileName() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetS60FileName");
+	if ( m_sS60FileName.empty() )
+	{
+		string sGeneratedDatName = m_sTarget;
+		sGeneratedDatName.append(".");
+		sGeneratedDatName.append( m_sTargetType );
+		sGeneratedDatName.append(".dat");
+		return sGeneratedDatName;
+	}
+	return m_sS60FileName;
+}
+
+string CATModule2::GetLstNameOfSource(string sSource) const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetLstNameOfSource");
+	// Find . before xtension
+	size_t iSpot = sSource.find_last_of( "." );
+	// Get sub string to there
+	string sLst = sSource.substr(0, iSpot+1);
+	if ( m_sVariantPlatform.compare( "winscw" ) != 0 )
+	{
+		// Add variant platform (i.e. armv5)
+		sLst.append( m_sVariantPlatform );
+		sLst.append( "." );
+		// Add variant type (i.e. build type liek urel)
+		sLst.append( m_sVariantType );
+		sLst.append( "." );
+		// Add target binary name
+		sLst.append( m_sTarget );
+		sLst.append( "." );
+		// Add target requested binary extension
+		sLst.append( m_sRequestedTargetExt );
+		sLst.append( "." );
+		// Add lst extension
+		sLst.append( "lst" );
+	}
+	else
+	{
+		sLst.append( "WINSCW.lst" );
+	}
+	return sLst;
+}
+
+bool CATModule2::IsPlatformArmv5() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::IsPlatformArmv5");
+	if ( _stricmp( m_sVariantPlatform.c_str(), "armv5" ) == 0 )
+		return true;
+	return false;
+}
+
+string CATModule2::GetMapFile() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetMapFile");
+	// Map file with path using variables
+	string sMapFile( m_sReleasePath );
+	if ( ! sMapFile.empty() )
+		sMapFile.append( "\\" );
+	sMapFile.append( m_sFullVariantPath );
+	if ( ! m_sFullVariantPath.empty() )
+		sMapFile.append( "\\" );
+	sMapFile.append( m_sTarget );
+	sMapFile.append( "." );
+	// Possible feature variant.
+	if ( ! m_sFeatureVariantUDEBLabel.empty() || ! m_sFeatureVariantURELLabel.empty() )
+	{
+		if ( IsUDEB() )
+			sMapFile.append( m_sFeatureVariantUDEBLabel );
+		else
+			sMapFile.append( m_sFeatureVariantURELLabel );
+		sMapFile.append( "." );
+	}
+	sMapFile.append( m_sRequestedTargetExt );
+	sMapFile.append( ".map" );
+	return sMapFile;
+}
+
+string CATModule2::GetSymbolFile() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetSymbolFile");
+	// Symbol file with path using variables
+	string sSymbolFile( m_sReleasePath );
+	sSymbolFile.append( "\\" );
+	sSymbolFile.append( m_sFullVariantPath );
+	sSymbolFile.append( "\\" );
+	sSymbolFile.append( m_sTarget );
+	sSymbolFile.append( "." );
+	// Possible feature variant.
+	if ( ! m_sFeatureVariantUDEBLabel.empty() || ! m_sFeatureVariantURELLabel.empty() )
+	{
+		if ( IsUDEB() )
+			sSymbolFile.append( m_sFeatureVariantUDEBLabel );
+		else
+			sSymbolFile.append( m_sFeatureVariantURELLabel );
+		sSymbolFile.append( "." );
+	}
+	
+	if ( m_eBuildSystem == CATProject::SBS_V1 )
+	{
+		sSymbolFile.append( "sym" );
+		return sSymbolFile;
+	}
+	sSymbolFile.append( m_sRequestedTargetExt );
+	sSymbolFile.append( ".sym" );
+	return sSymbolFile;
+}
+
+string CATModule2::GetBinaryFile() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetBinaryFile");
+	// Binary file with path using variables
+	string sBinaryFile( m_sReleasePath );
+	if ( ! sBinaryFile.empty() )
+		sBinaryFile.append( "\\" );
+	sBinaryFile.append( m_sFullVariantPath );
+	if ( ! m_sFullVariantPath.empty() )
+		sBinaryFile.append( "\\" );
+	sBinaryFile.append( m_sTarget );
+	sBinaryFile.append( "." );
+	// Possible feature variant.
+	if ( ! m_sFeatureVariantUDEBLabel.empty() || ! m_sFeatureVariantURELLabel.empty() )
+	{
+		if ( IsUDEB() )
+			sBinaryFile.append( m_sFeatureVariantUDEBLabel );
+		else
+			sBinaryFile.append( m_sFeatureVariantURELLabel );
+		sBinaryFile.append( "." );
+	}
+	sBinaryFile.append( m_sRequestedTargetExt );
+	return sBinaryFile;
+}
+
+bool CATModule2::SetMmpFile(const string& sMmpFile)
+{
+	LOG_FUNC_ENTRY("CATModule2::SetMmpFile");
+	// Set mmp file
+	m_Mmp.m_sMmpFile = sMmpFile;
+	// Change to lower
+	ChangeToLower( m_Mmp.m_sMmpFile );
+	// Convert
+	ConvertUnixPathToWin( m_Mmp.m_sMmpFile );
+	// Set the temporary path.
+	m_sTempPath.clear();
+	m_sTempPath = CreateTempPath( m_Mmp.m_sMmpFile );
+	return true;
+}
+
+bool CATModule2::CreateTemporaryDirectory()
+{
+	LOG_FUNC_ENTRY("CATModule2::CreateTemporaryDirectory");
+	if ( m_sTempPath.empty() )
+	{
+		LOG_STRING("Temporary path is not set.");
+		return false;
+	}
+	// Create temp dir if not exists
+	if ( ! DirectoryExists( m_sTempPath.c_str() ) )
+	{
+		if ( !CreateDirectory( m_sTempPath.c_str(), NULL ) )
+		{
+			cout << AT_MSG << "Error, can not create directory: "
+				<< m_sTempPath << endl;
+			return false;
+		}
+		cout << AT_MSG << "Directory created: " << m_sTempPath << endl;
+	}
+	return true;
+}
+
+void CATModule2::SetMakeFile( const string& sMakeFile )
+{
+	LOG_FUNC_ENTRY("CATModule2::SetMakeFile");
+	m_sMakeFile = sMakeFile;
+}
+string CATModule2::GetMakeFile() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetMakeFile");
+	return m_sMakeFile;
+}
+string CATModule2::GetMmpFile() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetMmpFile");
+	return m_Mmp.m_sMmpFile;
+}
+string CATModule2::GetTempPath() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetTempPath");
+	return m_sTempPath;
+}
+void CATModule2::SetTarget(const string& sTarget)
+{
+	LOG_FUNC_ENTRY("CATModule2::SetTarget");
+	m_sTarget = sTarget;
+	ChangeToLower( m_sTarget );
+}
+string CATModule2::GetTarget() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetTarget");
+	return m_sTarget;
+}
+string CATModule2::GetBinaryName() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetBinaryName");
+	string sBinaryName;
+	sBinaryName.append( m_sTarget );
+	sBinaryName.append( "." );
+	sBinaryName.append( m_sRequestedTargetExt );
+	return sBinaryName;
+}
+
+void CATModule2::SetTargetType(const string& sTargetType)
+{
+	LOG_FUNC_ENTRY("CATModule2::SetTargetType");
+	m_sTargetType = sTargetType;
+	ChangeToLower( m_sTargetType );
+}
+string CATModule2::GetTargetType() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetTargetType");
+	return m_sTargetType;
+}
+void CATModule2::SetRequestedTargetExt( const string& sRequestedTargetExt )
+{
+	LOG_FUNC_ENTRY("CATModule2::SetRequestedTargetExt");
+	m_sRequestedTargetExt = sRequestedTargetExt;
+	ChangeToLower( m_sRequestedTargetExt );
+}
+
+string CATModule2::GetRequestedTargetExt() const
+{
+	LOG_LOW_FUNC_ENTRY("CATmodule2::GetRequestedTargetExt");
+	return m_sRequestedTargetExt;
+}
+
+void CATModule2::SetVariantPlatform(const string& sVariantPlatform)
+{
+	LOG_FUNC_ENTRY("CATModule2::SetVariantPlatform");
+	m_sVariantPlatform = sVariantPlatform;
+	ChangeToLower( m_sVariantPlatform );
+}
+string CATModule2::GetVariantPlatform() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetVariantPlatform");
+	return m_sVariantPlatform;
+}
+void CATModule2::SetVariantType(const string& sVariantType)
+{
+	LOG_FUNC_ENTRY("CATModule2::SetVariantType");
+	m_sVariantType = sVariantType;
+	ChangeToLower( m_sVariantType );
+}
+string CATModule2::GetVariantType() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetVariantType");
+	return m_sVariantType;
+}
+void CATModule2::SetFeatureVariant(const string& sFeatureVariant)
+{
+	LOG_FUNC_ENTRY("CATModule2::SetFeatureVariant");
+	m_sFeatureVariant = sFeatureVariant;
+	ChangeToLower( m_sFeatureVariant );
+}
+string CATModule2::GetFeatureVariant() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetFeatureVariant");
+	return m_sFeatureVariant;
+}
+void CATModule2::SetFeatureVariantName(const string& sFeatureVariantName)
+{
+	LOG_FUNC_ENTRY("CATModule2::SetFeatureVariantName");
+	m_sFeatureVariantName = sFeatureVariantName;
+	ChangeToLower( m_sFeatureVariantName );
+}
+string CATModule2::GetFeatureVariantName() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetFeatureVariantName");
+	return m_sFeatureVariantName;
+}
+void CATModule2::SetReleasePath(const string& sReleasePath)
+{
+	LOG_FUNC_ENTRY("CATModule2::SetReleasePath");
+	m_sReleasePath = sReleasePath;
+	ChangeToLower( m_sReleasePath );
+	ConvertUnixPathToWin( m_sReleasePath );
+
+}
+string CATModule2::GetReleasePath() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetReleasePath");
+	return m_sReleasePath;
+}
+void CATModule2::SetFullVariantPath(const string& sFullVariantPath)
+{
+	LOG_FUNC_ENTRY("CATModule2::SetFullVariantPath");
+	m_sFullVariantPath = sFullVariantPath;
+	ChangeToLower( m_sFullVariantPath );
+	ConvertUnixPathToWin( m_sFullVariantPath );
+}
+string CATModule2::GetFullVariantPath() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetFullVariantPath");
+	return m_sFullVariantPath;
+}
+string CATModule2::GetUniqueId() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetUniqueId");
+	return FilterString( m_sTarget );
+}
+void CATModule2::SetBuildSystem( int eBuildSystem )
+{
+	LOG_FUNC_ENTRY("CATModule2::SetBuildSystem");
+	m_eBuildSystem = eBuildSystem;
+}
+
+int CATModule2::GetBuildSystem() const
+{
+	LOG_LOW_FUNC_ENTRY("CATModule2::GetBuildSystem");
+	return m_eBuildSystem;
+}
+
+void CATModule2::SetCompileDefinitions( const string& sCompileDefinitions )
+{
+	LOG_LOW_FUNC_ENTRY( "CATModule2::SetCompileDefinitions" );
+	m_sCompileDefinitions = sCompileDefinitions;
+}
+
+string CATModule2::GetCompileDefinitions() const
+{
+	LOG_LOW_FUNC_ENTRY( "CATModule2::GetCompileDefinitions" );
+	return m_sCompileDefinitions;
+}
+
+void CATModule2::SetCompileInfoText( string sCompileInfoText )
+{
+	LOG_LOW_FUNC_ENTRY( "CATModule2::SetCompileInfoText" );
+	m_sCompileInfoText = sCompileInfoText;
+}
+string CATModule2::GetCompileInfoText() const
+{
+	LOG_LOW_FUNC_ENTRY( "CATModule2::GetCompileInfoText" );
+	return m_sCompileInfoText;
+}
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/CATParseTraceFile.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,585 @@
+/*
+* 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/CATParseTraceFile.h"
+#include "../inc/catdatasaver.h"
+#include "../inc/CATDatParser.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
+// Constructor.
+// -----------------------------------------------------------------------------
+CATParseTraceFile::CATParseTraceFile()
+{
+	LOG_FUNC_ENTRY("CATParseTraceFile::CATParseTraceFile");
+	m_DataSaver.SetPrintFlag( false );
+}
+
+// -----------------------------------------------------------------------------
+// CATParseTraceFile::StartParse
+// Main function to start trace parsing.
+// -----------------------------------------------------------------------------
+bool CATParseTraceFile::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( pOutputFileName == NULL )
+		return bRet;
+
+	if ( ! FileExists( pFileName ) )
+	{
+		cout << AT_MSG << "Error, input file \""
+			<< pFileName
+			<< "\" does not exist." << endl;
+		return bRet;
+	}
+
+	// Open data file
+	ifstream in( pFileName );
+
+	// 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).
+	char cOriginalLineFromFile[MAX_LINE_LENGTH];
+
+	vector<CProcessData> vProcessList;
+	int iProcessIDinList = -1;
+
+	bool bFileVersionSaved = false;
+	// Read lines
+	while( streamPos < streamEnd )
+	{
+		// Get one line. Don't use stream flags to determinate end of file
+		// it can be found too early because trace can contain "anything".
+		in.getline( cOriginalLineFromFile, MAX_LINE_LENGTH );
+		
+		// Refresh position
+		streamPos = in.tellg();
+
+		// Check has bad bit flag raised. (i.e. device problems reading data)
+		if( in.bad() )
+		{
+			cout << AT_MSG << "Integrity error reading the trace file, reading aborted." << endl;
+			return false;
+		}
+		//Filtered characters.
+		char cLineFromFile[MAX_LINE_LENGTH];
+		char* pFiltered = cLineFromFile;
+
+		//Loop thru all characters in original line.
+		for( size_t i = 0 ; cOriginalLineFromFile[i] != 0 ; i++ )
+		{
+			//If character in line is not in invalid character array append it
+			//to filtered line.
+			if ( strchr( cINVALID_TRACE_FILE_CHARS, cOriginalLineFromFile[i] ) == 0 )
+					*pFiltered++ =  cOriginalLineFromFile[i];
+		}
+		*pFiltered++ = 0; //Add null termination to filtered line.
+
+		if( !bFileVersionSaved && *cLineFromFile != 0 )
+		{
+			bFileVersionSaved = true;
+			m_DataSaver.AddString( AT_DATA_FILE_VERSION );
+			m_DataSaver.AddLineToLast();
+		}
+
+		// Is there main ID?
+		if( strstr( cLineFromFile, MAIN_ID ) != NULL )
+		{
+			string sRestOfLine( cLineFromFile );
+			string sTemp;
+
+			// Delete all characters before main ID
+			sRestOfLine.erase( 0, sRestOfLine.find( MAIN_ID ) );
+
+			// Get main ID
+			sTemp = GetStringUntilNextSpace( sRestOfLine );
+
+			// Is there more data in line?
+			if( sRestOfLine.empty() )
+			{
+				continue;
+			}
+
+			// Get next argument
+			sTemp = GetStringUntilNextSpace( sRestOfLine );
+			// This might be process id or error message
+			if ( sTemp.compare( ERROR_OCCURED ) == 0 )
+			{
+				// Api mismatch between s60 side and atool.exe
+				if ( sRestOfLine.find( INCORRECT_ATOOL_VERSION ) != string::npos )
+				{
+					cout << "Test run failed because version conflict between device binaries\nand the atool.exe version used to build the application." << endl;
+					size_t pS = sRestOfLine.find_first_of('[');
+					size_t pE =  sRestOfLine.find_first_of(']');
+					size_t pSL = sRestOfLine.find_last_of('[');
+					size_t pEL = sRestOfLine.find_last_of(']');
+					if ( pS != string::npos && pE != string::npos && pSL != string::npos && pEL != string::npos )
+					{
+						string deviceVer = sRestOfLine.substr( pS+1, pE-pS-1 );
+						string atoolVer = sRestOfLine.substr( pSL+1, pEL-pSL-1 );
+						cout << "\tdevice: " << deviceVer << endl 
+							<<  "\tatool.exe: " << atoolVer << endl;
+					}
+				}
+				else
+					cout << sRestOfLine << endl;
+				continue;
+			}
+			unsigned long iProcessID = _httoi( sTemp.c_str() );
+
+			iProcessIDinList = -1;
+			// Find process from list
+			for( unsigned int i = 0 ; i < vProcessList.size() ; i++ )
+			{
+				if( vProcessList[i].iProcessID == iProcessID )
+				{
+					iProcessIDinList = i;
+					break;
+				}
+			}
+			// Is Process ID found from list?
+			if( iProcessIDinList == -1 )
+			{
+				CProcessData ProcessData;
+				ProcessData.bProcessOnGoing = false;
+				ProcessData.iProcessID = iProcessID;
+				vProcessList.push_back( ProcessData );
+				iProcessIDinList = (int)vProcessList.size() - 1;
+			}
+
+			// Remove spaces from end of line
+			while( sRestOfLine[sRestOfLine.size()-1] == ' ' )
+			{
+				sRestOfLine.resize( sRestOfLine.size()-1 );
+			}
+
+			string sWholeTempLine( sRestOfLine );
+
+			// Get command
+			sTemp = GetStringUntilNextSpace( sRestOfLine );
+
+			// Use c style string for easy comparisong of command.
+			const char* pCommand = sTemp.c_str();		
+
+			// Process start.
+			if( ! _stricmp( pCommand, LABEL_PROCESS_START ) )
+			{
+				bRet = true; // Set return value true we found start.
+				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
+				vProcessList[iProcessIDinList].bProcessOnGoing = true;
+				continue;
+			}
+
+			// Check is process ongoing if not skip other tags.
+			if( vProcessList[iProcessIDinList].bProcessOnGoing == false )
+				continue;
+
+			// "Old style" allocation (< v.1.6)
+			if( ! _stricmp( pCommand, ALLOC_ID ) )
+			{
+				// Add alloc
+				vProcessList[iProcessIDinList].Alloc( sRestOfLine );
+
+				// Subtests running?
+				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
+				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
+				{
+					if( viSubTestIter->bRunning )
+					{
+						// Save alloc also to sub test
+						viSubTestIter->Alloc( sRestOfLine );
+					}
+					viSubTestIter++;
+				}
+			}
+			else if ( ! _stricmp( pCommand, ALLOCH_ID ) )
+			{
+				// Add alloc
+				vProcessList[iProcessIDinList].AllocH( sRestOfLine );
+
+				// Subtests running?
+				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
+				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
+				{
+					if( viSubTestIter->bRunning )
+					{
+						// Save alloc also to sub test
+						viSubTestIter->AllocH( sRestOfLine );
+					}
+					viSubTestIter++;
+				}
+			}
+			// Allocation fragment (call stack).
+			else if ( ! _stricmp( pCommand, ALLOCF_ID ) )
+			{
+				// Add alloc fragment
+				vProcessList[iProcessIDinList].AllocF( sRestOfLine );
+				
+				// 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
+						viSubTestIter->AllocF( sRestOfLine );
+					}
+					viSubTestIter++;
+				}
+			}
+			// Command free
+			else if( ! _stricmp( pCommand, FREE_ID ) )
+			{
+				// Send free
+				vProcessList[iProcessIDinList].Free( sRestOfLine );
+
+				// Subtests running?
+				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
+				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
+				{
+					if( viSubTestIter->bRunning )
+					{
+						// Send free to subtest
+						viSubTestIter->Free( sRestOfLine );
+					}
+					viSubTestIter++;
+				}
+			}
+			// Header free.
+			else if( ! _stricmp( pCommand, FREEH_ID ) )
+			{
+				// Send free
+				vProcessList[iProcessIDinList].FreeH( sRestOfLine );
+
+				// Subtests running?
+				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
+				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
+				{
+					if( viSubTestIter->bRunning )
+					{
+						// Send free to subtest
+						viSubTestIter->FreeH( sRestOfLine );
+					}
+					viSubTestIter++;
+				}
+			
+			}
+			else if( ! _stricmp( pCommand, FREEF_ID ) )
+			{
+				// Not used currently.
+			}
+			// Command process end
+			else if( ! _stricmp( pCommand, LABEL_PROCESS_END ) )
+			{
+				// Set process has ended.
+				vProcessList[iProcessIDinList].bProcessOnGoing = false;
+
+				// Save leaks
+				vector<string> vLeaks;
+				vector<string>::iterator viLeaks;
+				vProcessList[iProcessIDinList].GetLeakList( vLeaks );
+				for ( viLeaks = vLeaks.begin(); viLeaks != vLeaks.end(); viLeaks++ )
+				{
+					sTemp.clear();
+					sTemp.append( LABEL_MEM_LEAK );
+					sTemp.append( " " );
+					sTemp.append( *viLeaks );
+					vProcessList[iProcessIDinList].vData.push_back( sTemp );
+				}
+				vProcessList[iProcessIDinList].ClearAllocs();
+
+				vector<string>::iterator viHandleIter = vProcessList[iProcessIDinList].vHandleLeaks.begin();
+				// Print handle leaks
+				while( viHandleIter != vProcessList[iProcessIDinList].vHandleLeaks.end() )
+				{
+					sTemp.clear();
+					sTemp.append( viHandleIter->c_str() );
+					vProcessList[iProcessIDinList].vData.push_back( sTemp );
+					viHandleIter++;
+				}
+				// Clear handle leaks from list
+				vProcessList[iProcessIDinList].vHandleLeaks.clear();
+
+				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
+				// Print sub test leaks
+				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
+				{
+					// Print sub test start
+					string sLine( LABEL_TEST_START ); sLine.append( " " );
+					sLine.append( viSubTestIter->sStartTime ); sLine.append( " " );
+					sLine.append( viSubTestIter->sSubTestName ); sLine.append( " " );
+					sLine.append( viSubTestIter->sSubTestStartHandleCount );
+					vProcessList[iProcessIDinList].vData.push_back( sLine );
+					sLine.clear();
+
+					// DLL Loads.
+					for( vector<string>::iterator it = viSubTestIter->vData.begin();
+						it != viSubTestIter->vData.end(); it++ )
+					{
+						vProcessList[iProcessIDinList].vData.push_back( (*it) );
+					}
+
+					// Subtest leaks.
+					vector<string> vSubLeaks;
+					vector<string>::iterator viSubLeaks;
+					viSubTestIter->GetLeakList( vSubLeaks );
+					for ( viSubLeaks = vSubLeaks.begin(); viSubLeaks != vSubLeaks.end(); viSubLeaks++ )
+					{
+						sLine.append( LABEL_MEM_LEAK );
+						sLine.append( " " );
+						sLine.append( *viSubLeaks );
+						vProcessList[iProcessIDinList].vData.push_back( sLine );
+						sLine.clear();
+					}
+					viSubTestIter->ClearAllocs();
+
+					if( !viSubTestIter->sEndTime.empty() )
+					{
+						// Print sub test end
+						sLine.append( LABEL_TEST_END ); sLine.append( " " );
+						sLine.append( viSubTestIter->sEndTime ); sLine.append( " " );
+						sLine.append( viSubTestIter->sSubTestName ); sLine.append( " " );
+						sLine.append( viSubTestIter->sSubTestEndHandleCount );
+						vProcessList[iProcessIDinList].vData.push_back( sLine );
+					}
+					viSubTestIter++;
+				}
+
+				// Clear sub tests from list
+				vProcessList[iProcessIDinList].vSubTests.clear();
+				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
+			}
+			else if( ! _stricmp( pCommand, LABEL_HANDLE_LEAK ) )
+			{
+				// Make whole line
+				sTemp.append( " " );
+				sTemp.append( sRestOfLine );
+				vProcessList[iProcessIDinList].vHandleLeaks.push_back( sTemp );
+			}
+			else if( ! _stricmp( pCommand, LABEL_DLL_LOAD ) )
+			{
+				// Add module load to process data.
+				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
+				// Add module load to subtest data if test running.
+				for( vector<CSubTestData>::iterator it = vProcessList[iProcessIDinList].vSubTests.begin();
+					it != vProcessList[iProcessIDinList].vSubTests.end(); it++ )
+				{
+					if( it->bRunning )
+						it->vData.push_back( sWholeTempLine );
+				}
+
+			}
+			else if( ! _stricmp( pCommand, LABEL_DLL_UNLOAD ) )
+			{
+				// Add module load to process data.
+				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
+				// Add module unload to subtest data if test running.
+				for( vector<CSubTestData>::iterator it = vProcessList[iProcessIDinList].vSubTests.begin();
+					it != vProcessList[iProcessIDinList].vSubTests.end(); it++ )
+				{
+					if( it->bRunning )
+						it->vData.push_back( sWholeTempLine );
+				}
+			}
+			else if( sTemp.find( LABEL_LOGGING_CANCELLED ) != string::npos ||
+				     sTemp.find( LABEL_PROCESS_END ) != string::npos || sTemp.find( LABEL_ERROR_OCCURED ) != string::npos ||
+					 sTemp.find( LABEL_HANDLE_LEAK ) != string::npos )
+			{
+				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
+			}
+			else if( ! _stricmp( pCommand, LABEL_TEST_START ) )
+			{
+				bRet = true; // Set return value true we found start.
+				// Get sub test time
+				string sSubTestTime = GetStringUntilNextSpace( sRestOfLine );
+				// Get sub test name
+				string sSubTestName = GetStringUntilNextSpace( sRestOfLine );
+				// Get sub test start handle count
+				string sSubTestStartHandleCount = GetStringUntilNextSpace( sRestOfLine );
+
+				CSubTestData SubTestData;
+				SubTestData.bRunning = true;
+				SubTestData.sStartTime = sSubTestTime;
+				SubTestData.sSubTestName = sSubTestName;
+				SubTestData.sSubTestStartHandleCount = sSubTestStartHandleCount.c_str();
+
+				vProcessList[iProcessIDinList].vSubTests.push_back( SubTestData );
+			}
+			else if( ! _stricmp( pCommand, LABEL_TEST_END ) )
+			{
+				// Get sub test time
+				string sSubTestEnd = GetStringUntilNextSpace( sRestOfLine );
+				// Get sub test name
+				string sSubTestName = GetStringUntilNextSpace( sRestOfLine );
+				// Get sub test end handle count
+				string sSubTestEndHandleCount = GetStringUntilNextSpace( sRestOfLine );
+
+				// Find subtest
+				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
+				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
+				{
+					if( viSubTestIter->sSubTestName == sSubTestName && viSubTestIter->sEndTime.empty() )
+					{
+						viSubTestIter->sEndTime = sSubTestEnd;
+						viSubTestIter->bRunning = false;
+						viSubTestIter->sSubTestEndHandleCount = sSubTestEndHandleCount.c_str();
+					}
+					viSubTestIter++;
+				}
+			}
+		}
+	}
+
+	// Print all saved data from processes
+	for( unsigned int i = 0 ; i < vProcessList.size() ; i++ )
+	{
+		// Print saved lines
+		for( unsigned int iDataCounter = 0 ; iDataCounter < vProcessList[i].vData.size() ; iDataCounter++ )
+		{
+			m_DataSaver.AddString( vProcessList[i].vData[iDataCounter].c_str() );
+			m_DataSaver.AddLineToLast();
+		}
+
+		string sTemp;
+
+		// Save leaks
+		vector<string> vLeaks;
+		vector<string>::iterator viLeaks;
+		vProcessList[i].GetLeakList( vLeaks );
+		for ( viLeaks = vLeaks.begin(); viLeaks != vLeaks.end(); viLeaks++ )
+		{
+			sTemp.clear();
+			sTemp.append( LABEL_MEM_LEAK );
+			sTemp.append( " " );
+			sTemp.append( *viLeaks );
+			m_DataSaver.AddString( sTemp.c_str() );
+			m_DataSaver.AddLineToLast();
+		}
+
+		vector<string>::iterator viHandleIter = vProcessList[i].vHandleLeaks.begin();
+		// Print handle leaks, if there is data left, there was no process end.
+		while( viHandleIter != vProcessList[i].vHandleLeaks.end() )
+		{
+			sTemp.clear();
+			sTemp.append( viHandleIter->c_str() );
+			m_DataSaver.AddString( sTemp.c_str() );
+			m_DataSaver.AddLineToLast();
+			viHandleIter++;
+		}
+		vector<CSubTestData>::iterator viSubTestIter = vProcessList[i].vSubTests.begin();
+		// Print sub test data, if there is data left, there was no process end.
+		while( viSubTestIter != vProcessList[i].vSubTests.end() )
+		{
+			// Print sub test start
+			string sLine( LABEL_TEST_START ); sLine.append( " " );
+			sLine.append( viSubTestIter->sStartTime ); sLine.append( " " );
+			sLine.append( viSubTestIter->sSubTestName ); sLine.append( " " );
+			sLine.append( viSubTestIter->sSubTestStartHandleCount );
+			m_DataSaver.AddString( sLine.c_str() );
+			m_DataSaver.AddLineToLast();
+			sLine.clear();
+
+			// DLL Loads.
+			for( vector<string>::iterator it = viSubTestIter->vData.begin();
+				it != viSubTestIter->vData.end(); it++ )
+			{
+				m_DataSaver.AddString( (*it).c_str() );
+				m_DataSaver.AddLineToLast();
+			}
+
+			// Subtest leaks.
+			vector<string> vSubLeaks;
+			vector<string>::iterator viSubLeaks;
+			viSubTestIter->GetLeakList( vSubLeaks );
+			for ( viSubLeaks = vSubLeaks.begin(); viSubLeaks != vSubLeaks.end(); viSubLeaks++ )
+			{
+				sLine.append( LABEL_MEM_LEAK );
+				sLine.append( " " );
+				sLine.append( *viSubLeaks );
+				m_DataSaver.AddString( sLine.c_str() );
+				m_DataSaver.AddLineToLast();
+				sLine.clear();
+			}
+
+			// Print sub test end
+			sLine.append( LABEL_TEST_END ); sLine.append( " " );
+			sLine.append( viSubTestIter->sEndTime ); sLine.append( " " );
+			sLine.append( viSubTestIter->sSubTestName ); sLine.append( " " );
+			sLine.append( viSubTestIter->sSubTestEndHandleCount );
+			m_DataSaver.AddString( sLine.c_str() );
+			m_DataSaver.AddLineToLast();
+
+			viSubTestIter++;
+		}
+	}
+	// Save lines to file.
+	m_DataSaver.SaveLinesToFile( pOutputFileName, TEXT_DATA );
+	// Close file.
+	in.close();
+	return bRet;
+}
+
+// -----------------------------------------------------------------------------
+// CATParseTraceFile::GetDataSaver
+// Gets data saver object.
+// -----------------------------------------------------------------------------
+CATDataSaver* CATParseTraceFile::GetDataSaver(void)	
+{
+	LOG_LOW_FUNC_ENTRY("CATParseTraceFile::GetDataSaver");
+	return &m_DataSaver;
+}
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/CATParseXML.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,148 @@
+/*
+* 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 CATParseXML.
+*
+*/
+
+
+#include "../inc/CATParseXML.h"
+#include "../inc/catdatasaver.h"
+#include "../inc/CATBase.h"
+
+#include <xercesc/parsers/XercesDOMParser.hpp>
+
+const char cCanNotFindEpocroot[] = "Can not find EPOCROOT from devices.xml.\n";
+const char cErrorInDeviceXml[] = "Error in devices.xml!\n";
+const char cCanNotFind[] = "Can not find file: %s.\n";
+
+CATParseXML::CATParseXML(void)
+{
+	LOG_FUNC_ENTRY("CATParseXML::CATParseXML");
+	try 
+	{
+		xercesc::XMLPlatformUtils::Initialize();
+	}
+	catch ( ... )
+	{
+		//Print error
+		printf("XML initialization failed.\n");
+	}
+}
+
+CATParseXML::~CATParseXML(void)
+{
+	LOG_FUNC_ENTRY("CATParseXML::~CATParseXML");
+}
+
+// -----------------------------------------------------------------------------
+// CATParseXML::GetEpocRootPathFromXML
+// Find epocroot path in xml file
+// -----------------------------------------------------------------------------
+string CATParseXML::GetEpocRootPathFromXML(const char* pSourcePath)
+{
+	LOG_FUNC_ENTRY("CATParseXML::GetEpocRootPathFromXML");
+	string sEpocRootPath;
+	// Check that source exists
+	if ( ! CATBase::FileExists( pSourcePath ) )
+	{
+		LOG_STRING( "Source xml not found." );
+		return sEpocRootPath;
+	}
+	try 
+	{
+		xercesc::XercesDOMParser* parser = new xercesc::XercesDOMParser();
+		xercesc::DOMDocument* pDomDoc;
+
+		// Get devices.xml document
+		parser->parse( pSourcePath );
+		pDomDoc = parser->getDocument();
+
+		// Get root element
+		xercesc::DOMElement* pRootElem = pDomDoc->getDocumentElement();
+
+		if( pRootElem )
+		{
+			// Get all "device" elements
+			LPWSTR wTemp = CATDataSaver::CharToWChar( "device" );
+			xercesc::DOMNodeList* pDeviceNodeList = pRootElem->getElementsByTagName( wTemp );
+			if( wTemp )
+				delete[] wTemp;
+
+			// Find default SDK
+
+			bool bEpocRootFound = false;
+			int iLength = pDeviceNodeList->getLength();
+			for( int i = 0 ; i < iLength ; i++ )
+			{
+				xercesc::DOMNode* pDeviceNode = pDeviceNodeList->item(i);
+
+				xercesc::DOMNamedNodeMap* pAttributeList = pDeviceNode->getAttributes();
+
+				// Find attribute "default"
+
+				int iAttribListLength = pAttributeList->getLength();
+				for( int x = 0 ; x < iAttribListLength ; x++ )
+				{
+					xercesc::DOMNode* pAttribNode = pAttributeList->item(x);
+					const LPWSTR pNodeName = (const LPWSTR)pAttribNode->getNodeName();
+
+					if( wcscmp( pNodeName, L"default" ) == 0 )
+					{
+						const LPWSTR pNodeValue = (const LPWSTR)pAttribNode->getNodeValue();
+						
+						// Find node value 'yes'
+						if( wcscmp( pNodeValue, L"yes" ) == 0 )
+						{
+							// Find <epocroot> node
+							xercesc::DOMNode* pChildNode = pDeviceNode->getFirstChild();
+							if( !pChildNode )
+								break;
+							while( !bEpocRootFound )
+							{
+								if( wcscmp( pChildNode->getNodeName() , L"epocroot" ) == 0 )
+								{
+									bEpocRootFound = true;
+
+									// Node value is child text node
+									xercesc::DOMNode* pTempTextNode = pChildNode->getFirstChild();
+									const LPWSTR pPathNodeValue = (const LPWSTR)pTempTextNode->getNodeValue();
+
+									CATDataSaver::WCharToChar( sEpocRootPath, pPathNodeValue );
+
+									break;
+								}
+								pChildNode = pChildNode->getNextSibling();
+								if( !pChildNode )
+									break;
+							}
+						} // If node value yes
+					} // If node name default
+					if( bEpocRootFound )
+						break;
+				} // for x
+				if( bEpocRootFound )
+					break;
+			} // for i
+		}
+		if(parser)
+			delete parser; //lint !e118
+ 		xercesc::XMLPlatformUtils::Terminate();
+	}
+    catch (...)
+	{
+        printf("XML parsing failed.");
+    }
+	return sEpocRootPath;
+}
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/CATProject.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,2361 @@
+/*
+* 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:  Class representing a project.
+*
+*/
+
+
+#include "../inc/CATProject.h"
+#include "../inc/CATModule2.h"
+#include "../inc/CATParseTraceFile.h"
+#include "../inc/CATDatParser.h"
+
+// ----------------------------------------------------------------------------
+// CATProject::CATProject()
+// ----------------------------------------------------------------------------
+CATProject::CATProject()
+{
+	LOG_FUNC_ENTRY("CATProject::CATProject");
+
+	m_bUninstrumented = true;
+
+	// Use windows api to acquire current directory info.
+	GetCurrentDirectory( MAX_LINE_LENGTH, m_cCurrentDir );
+
+	m_eBuildSystem = SBS_V1;
+	m_eBuildType = UDEB;
+	m_eLoggingMode = XTI;
+	m_eMode = NOT_DEFINED;
+	
+	m_iLoggingLevel = 3;
+	
+	m_pAnalyzer = 0;
+
+	m_sBinaryTarget = "";
+	m_sBuildCommand = "";
+	m_sDataFile = "";
+	m_sDataFileOutput = "";
+	m_sDataFileTemp = "";
+	m_sEpocRoot = "\\";
+	m_sMakeFile = "";
+	m_sPlatform = "";
+	m_sS60FileName = "";
+	m_sTargetModule = "";
+	m_sVariant = "";
+
+	m_vRomSymbolFiles.clear();
+	m_vModules.clear();
+	m_vStaticLibraries.clear();
+	m_vTargetModules.clear();
+	m_vUnsupportedModules.clear();
+}
+
+// ----------------------------------------------------------------------------
+// CATProject::~CATProject()
+// ----------------------------------------------------------------------------
+CATProject::~CATProject()
+{
+	LOG_FUNC_ENTRY("CATProject::~CATProject");
+
+	CleanModuleVectors();
+
+	// Delete analyzer
+	if ( m_pAnalyzer )
+		delete m_pAnalyzer;
+
+	// Temporary datafile
+	if ( !m_sDataFileTemp.empty() )
+	{
+		if ( FileExists( m_sDataFileTemp.c_str() ) )
+			FileDelete( m_sDataFileTemp, false );
+	}
+}
+
+bool CATProject::SetArguments( ARGUMENTS& arguments )
+{
+	LOG_FUNC_ENTRY("CATProject::SetArguments");
+	bool bRet = true;
+
+	//Project mode.
+	if( arguments.eHookSwitch == HOOK_INTERNAL )
+	{
+		SetMode( CATProject::COMPILE );
+		SetLoggingMode( CATProject::S60 );
+	}
+	else if ( arguments.eHookSwitch == HOOK_EXTERNAL )
+	{
+		SetMode( CATProject::COMPILE );
+		SetLoggingMode( CATProject::XTI );
+	}
+	else if ( arguments.eHookSwitch == HOOK_EXTERNAL_FAST )
+	{
+		SetMode( CATProject::COMPILE );
+		SetLoggingMode( CATProject::XTI_FAST );
+	}
+	/* Extension*/
+	else if ( arguments.eHookSwitch == HOOK_EXTENSION_INTERNAL )
+	{
+		SetMode( CATProject::INSTRUMENT );
+		SetLoggingMode( CATProject::S60 );
+	}
+	else if ( arguments.eHookSwitch == HOOK_EXTENSION_EXTERNAL )
+	{
+		SetMode( CATProject::INSTRUMENT );
+		SetLoggingMode( CATProject::XTI );
+	}
+	else if ( arguments.eHookSwitch == HOOK_EXTENSION_EXTERNAL_FAST )
+	{
+		SetMode( CATProject::INSTRUMENT );
+		SetLoggingMode( CATProject::XTI_FAST );
+	}
+	else if ( arguments.eHookSwitch == HOOK_EXTENSION_UNINSTRUMENT )
+	{
+		SetMode( CATProject::UNINSTRUMENT );
+	}
+	else if ( arguments.eHookSwitch == HOOK_EXTENSION_FAILED )
+	{
+		SetMode( CATProject::UNINSTRUMENT_FAILED );
+	}
+	//Return if uninstrumenting because no other arguments are set.
+    if ( GetMode() == CATProject::UNINSTRUMENT
+		|| GetMode() == CATProject::UNINSTRUMENT_FAILED )
+	{
+		return bRet;
+	}
+
+	// No build / instrument.
+	if ( arguments.HOOK.bNoBuild )
+		SetMode( CATProject::INSTRUMENT_CONSOLE );
+
+	// Call stack sizes
+	SetAllocCallStackSize( arguments.HOOK.iAllocCallStackSize );
+	SetFreeCallStackSize( arguments.HOOK.iFreeCallStackSize );
+
+	//Build system.
+	if ( arguments.HOOK.iBuildSystem == 1 )
+		SetBuildSystem( CATProject::SBS_V1 );
+	else if ( arguments.HOOK.iBuildSystem == 2 )
+		SetBuildSystem( CATProject::SBS_V2 );
+
+	//Platform.
+	if ( !_stricmp( arguments.HOOK.sPlatform.c_str(), "armv5" ) )
+		SetPlatform( arguments.HOOK.sPlatform );
+	else if ( !_stricmp( arguments.HOOK.sPlatform.c_str(), "gcce" ) )
+		SetPlatform( arguments.HOOK.sPlatform );
+	else if ( !_stricmp( arguments.HOOK.sPlatform.c_str(), "winscw" ) )
+		SetPlatform( arguments.HOOK.sPlatform );
+	else
+	{
+		LOG_STRING( "Error, no supported platform specified (armv5/gcce/winscw).");
+		bRet = false;
+	}
+
+	//BuildType.
+	if ( !_stricmp( arguments.HOOK.sBuildType.c_str(), "urel" ) )
+		SetBuildType( CATProject::UREL );
+	else if ( !_stricmp( arguments.HOOK.sBuildType.c_str(), "udeb" ) )
+		SetBuildType( CATProject::UDEB );
+	else
+	{
+		LOG_STRING( "Error, no build type specified.");
+		bRet = false;
+	}
+
+	//Internal data file.
+	if ( arguments.HOOK.bDataFileName )
+		SetS60FileName( arguments.HOOK.sDataFileName );
+
+	//Build command.
+	if ( arguments.HOOK.sBuildCmd.empty() && ( 
+		GetMode() == CATProject::COMPILE ||
+		GetMode() == CATProject::INSTRUMENT ||
+		GetMode() == CATProject::INSTRUMENT_CONSOLE
+		))
+	{
+		cout << AT_MSG << "Error, no build command specified." << endl;
+		bRet = false;
+	}
+
+	SetBuildCommand( arguments.HOOK.sBuildCmd );
+
+	//Variant.
+	SetVariant( arguments.HOOK.sFeatureVariant );
+
+	//Target programs.
+	SetTargetModules( arguments.HOOK.vTargetPrograms );
+
+	return bRet;
+}
+
+void CATProject::CleanModuleVectors()
+{
+	LOG_FUNC_ENTRY("CATProject::CleanModuleVectors");
+	// delete modules from vector.
+	for( size_t i = 0; i < m_vModules.size()  ; i++ )
+		delete m_vModules[i];
+	m_vModules.clear();
+	
+	// Delete modules from vector (unsupported).
+	for( size_t i = 0; i < m_vUnsupportedModules.size()  ; i++ )
+		delete m_vUnsupportedModules[i];
+	m_vUnsupportedModules.clear();
+
+	// Delete modules from static library vector.
+	for( size_t i = 0; i < m_vStaticLibraries.size() ; i++ )
+		delete m_vStaticLibraries[i];
+	m_vStaticLibraries.clear();
+}
+// ----------------------------------------------------------------------------
+// CATProject::Run
+// ----------------------------------------------------------------------------
+int CATProject::Run()
+{
+	LOG_FUNC_ENTRY("CATProject::Run");
+	int iReturnCode = 0;
+	switch( m_eMode )
+	{
+	case COMPILE:
+		// Run compile
+		iReturnCode = RunCompile();
+		if ( iReturnCode == AT_RETURN_CODE::READ_MAKEFILE_ERROR
+			|| iReturnCode == AT_RETURN_CODE::KERNEL_SIDE_MODULE_ERROR
+			|| iReturnCode == AT_RETURN_CODE::INVALID_MMP_DEFINED )
+		{
+			DeleteTemporaryDirs();
+			DirDelete( AT_TEMP_DIR, true );
+		}
+		else
+		{
+			DisplayCompileSummary();
+			DisplayBuildSummary();
+		}
+		break;
+	case CLEAN:
+		iReturnCode = RunClean();
+		break;
+	case ANALYZE:
+		iReturnCode = RunAnalyze();
+		break;
+	case INSTRUMENT:
+		iReturnCode = RunInstrument();
+		break;
+	case INSTRUMENT_CONSOLE:
+		iReturnCode = RunInstrumentConsole();
+		if ( iReturnCode == AT_RETURN_CODE::READ_MAKEFILE_ERROR
+			|| iReturnCode == AT_RETURN_CODE::KERNEL_SIDE_MODULE_ERROR )
+		{
+			DeleteTemporaryDirs();
+			DirDelete( AT_TEMP_DIR, true );
+		}
+		else
+		{
+			DisplayBuildSummary();
+		}
+		break;
+	case UNINSTRUMENT:
+		iReturnCode = RunUninstrument();
+		// Show summary
+		DisplayCompileSummary();
+		DisplayBuildSummary();
+		break;
+	case UNINSTRUMENT_CONSOLE:
+		iReturnCode = RunUninstrumentConsole();
+		// Show summary
+		DisplayCompileSummary();
+		DisplayBuildSummary();
+		break;
+	case UNINSTRUMENT_FAILED:
+		iReturnCode = RunUninstrumentFailed();
+		// Display message
+		cout << AT_MSG << "Build aborted, because project contains compile error(s)."
+			<< endl;
+		break;
+	default:
+		cout << AT_MSG << "Error, mode not supported / implemented." << endl;
+		break;
+	}
+	// Error messages
+	switch( iReturnCode )
+	{
+		case AT_RETURN_CODE::MAKEFILE_ERROR:
+			cout << AT_MSG << "Error, creating/reading makefiles." << endl;
+			break;
+		case AT_RETURN_CODE::COMPILE_ERROR:
+			cout << AT_MSG << "Error, compiling project." << endl;
+			break;
+		case AT_RETURN_CODE::UNKNOWN:
+			cout << AT_MSG << "Error, unknown." << endl;
+			break;
+		case AT_RETURN_CODE::WRONG_DATA_FILE_VERSION:
+			cout << AT_MSG << "unable to analyze the data file.\n";
+			cout << AT_MSG << "wrong data file version.\n";
+			break;
+		case AT_RETURN_CODE::INVALID_DATA_FILE:
+			cout << AT_MSG << "Error, invalid datafile." << endl;
+			break;
+		case AT_RETURN_CODE::RELEASABLES_ERROR:
+			cout << AT_MSG << "Error, copying releasable(s)." << endl;
+			break;
+		case AT_RETURN_CODE::RESTORE_MODULES_ERROR:
+			cout << AT_MSG << "Error, restoring mmp file(s)." << endl;
+			break;
+		case AT_RETURN_CODE::CREATING_TEMP_CPP_ERROR:
+			cout << AT_MSG << "Error, creating temporary cpp file(s)." << endl;
+			break;
+		case AT_RETURN_CODE::CLEANING_TEMP_ERROR:
+			cout << AT_MSG << "Error, cleaning temporary dir(s)." << endl;
+			break;
+		case AT_RETURN_CODE::READ_MAKEFILE_ERROR:
+			cout << AT_MSG << "Error, reading makefile." << endl;
+			break;
+		case AT_RETURN_CODE::MODIFY_MODULES_ERROR:
+			cout << AT_MSG << "Error, modifying mmp file(s)." << endl;
+			break;
+		case AT_RETURN_CODE::INVALID_MMP_DEFINED:
+			break;
+		case AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR:
+			cout << AT_MSG << "Error, writing attributes." << endl;
+			break;
+		case AT_RETURN_CODE::READ_ATTRIBUTES_ERROR:
+			cout << AT_MSG << "Error, reading project configuration. Instrument project again." << endl;
+			break;
+		case AT_RETURN_CODE::EMPTY_DATA_FILE:
+			cout << AT_MSG << "Error, no data to be analyzed." << endl;
+			break;
+		case AT_RETURN_CODE::NO_SUPPORTED_MODULES_ERROR:
+			cout << AT_MSG << "Error, no modules found with supported target type." << endl;
+			break;
+		case AT_RETURN_CODE::KERNEL_SIDE_MODULE_ERROR:
+			cout << AT_MSG << "Error, kernel side component found component. Build/instrument aborted." << endl;
+			break;
+	}	
+	return iReturnCode;
+}
+// ----------------------------------------------------------------------------
+// CATProject::RunRecoveryAndExit()
+// Restore modules quick and exit. Used when user wants to kill/end process.
+// ----------------------------------------------------------------------------
+int CATProject::RunRecoveryAndExit()
+{
+	LOG_FUNC_ENTRY("CATProject::RunRecoveryAndExit");
+	cout << AT_MSG << "Error, user requested exit." << endl;
+	VerifyAndRecoverModules();
+	DeleteTemporaryDirs();
+	DirDelete( AT_TEMP_DIR, true );
+	cout << AT_MSG << "Exit." << endl;
+	return AT_RETURN_CODE::USER_ISSUED_EXIT;
+}
+
+// ----------------------------------------------------------------------------
+// CATProject::IsUninstrumented()
+// Reads projects configuration file if it exists. 
+// Return false in case the data contains information that project is
+// uninstrumented. Otherwise returns always true.
+// ----------------------------------------------------------------------------
+bool CATProject::IsUninstrumented()
+{
+	LOG_FUNC_ENTRY("CATProject::IsUninstrumented");
+	string sCfgFile( AT_TEMP_DIR );
+	sCfgFile.append( "\\" );
+	sCfgFile.append( AT_PROJECT_ATTRIBUTES_FILE_NAME );
+	if ( ! FileExists( sCfgFile.c_str() ) )
+		return true;
+	if( !ReadAttributes() )
+	{
+		LOG_STRING( "Error, reading project.cfg file." );
+		return false;
+	}
+	return m_bUninstrumented;
+}
+
+// ----------------------------------------------------------------------------
+// CATProject::RunCompile()
+// Helper functions to run different modes.
+// ----------------------------------------------------------------------------
+int CATProject::RunCompile()
+{
+	LOG_FUNC_ENTRY("CATProject::RunCompile");
+	// Store attributes
+	if( ! MakeTempDirIfNotExist() )
+		return AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR;
+	if ( ! WriteAttributes() )
+		return AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR;
+	// Create makefile
+	if ( ! CreateMakeFile() )
+		return AT_RETURN_CODE::MAKEFILE_ERROR;
+	// Read makefile to get project attributes
+	if ( ! ReadMakeFile() )
+		return AT_RETURN_CODE::READ_MAKEFILE_ERROR;
+	// Filter unsupported
+	FilterModules();
+	// Check that we have some "valid" modules to hook
+	if ( m_vModules.size() == 0 &&(  m_vUnsupportedModules.size() > 0 || m_vStaticLibraries.size() > 0 ) )
+		return AT_RETURN_CODE::NO_SUPPORTED_MODULES_ERROR;
+	// Check is possible target module defined in project
+	if ( ! IsTargetModuleInProject() )
+		return AT_RETURN_CODE::INVALID_MMP_DEFINED;
+	// Clean temporary dirs of modules
+	if ( ! CleanTemporaryDirs() )
+		return AT_RETURN_CODE::CLEANING_TEMP_ERROR;
+	// Create temporary cpps for modulse
+	if (! CreateTemporaryCpps() )
+		return AT_RETURN_CODE::CREATING_TEMP_CPP_ERROR;
+	// Hook modules
+	if (! ModifyModules() )
+		return AT_RETURN_CODE::MODIFY_MODULES_ERROR;
+	// Compile all
+	// Return code
+	int iRetCode = AT_RETURN_CODE::OK;
+	// Compile
+	if ( ! Compile() )
+		iRetCode = AT_RETURN_CODE::COMPILE_ERROR;
+	// Listings
+	if (! CreateListings() )
+		iRetCode = AT_RETURN_CODE::COMPILE_ERROR;
+	// Releasables
+	if (! CopyReleasables() )
+		iRetCode = AT_RETURN_CODE::RELEASABLES_ERROR;
+	// Restore "unhook" modules
+	if (! RestoreModules() )
+		iRetCode = AT_RETURN_CODE::RESTORE_MODULES_ERROR;
+	// Return error code OK
+	return iRetCode;
+}
+
+int CATProject::RunClean()
+{
+	LOG_FUNC_ENTRY("CATProject::RunClean");
+	int iRetCode = AT_RETURN_CODE::OK;
+	bool bNothingFound = true;
+	// Read attributes.
+	if (  ReadAttributes() )
+	{
+		bNothingFound = false;
+		if ( m_eBuildSystem == SBS_V1 )
+			InitSbs1MakeFileWithPathToTemp();
+		// Read makefile to get project attributes
+		if( ReadMakeFile() )
+		{
+			// Filter unsupported
+			FilterModules();
+			// Restore modules to make sure no changes left
+			if( VerifyAndRecoverModules() )
+			{
+				// Run reallyclean
+				switch ( m_eBuildSystem )
+				{
+				case SBS_V1:
+					RunReallyCleanSbs1();
+					break;
+				case SBS_V2:
+					RunReallyCleanSbs2();
+					break;
+				default:
+					break;
+				}
+				// Delete temporary dirs of modules
+				if(! DeleteTemporaryDirs() )
+				{
+					
+				}
+			}
+			else
+			{
+				
+			}
+		}
+	}
+	// Projects
+	if ( ! DirDelete( AT_TEMP_DIR, true ) )
+	{
+
+	}
+	else
+		bNothingFound = false;
+
+	if ( bNothingFound )
+		cout << AT_MSG << "Nothing found to clean." << endl;
+	else
+		cout << AT_MSG << "Cleaning done." << endl;
+	return iRetCode;
+}
+
+int CATProject::RunAnalyze()
+{
+	LOG_FUNC_ENTRY("CATProject::RunAnalyze");
+
+	// Parse data file if it is trace.
+	if ( !IsDataFile( m_sDataFile ) )
+	{
+		m_sDataFileTemp.clear();
+		m_sDataFileTemp.append( m_sDataFile );
+		m_sDataFileTemp.append( ".atool" );
+		cout << AT_MSG << "Parsing trace file..." << endl;
+		CATParseTraceFile Parser;
+		if ( ! Parser.StartParse( m_sDataFile.c_str(), m_sDataFileTemp.c_str() ) )
+		{
+			return AT_RETURN_CODE::EMPTY_DATA_FILE;
+		}
+		m_sDataFile = m_sDataFileTemp;
+	}
+
+	// Init makefile member for this run mode.
+	if ( m_eBuildSystem == SBS_V1 )
+		InitSbs1MakeFileWithPathToTemp();
+	// Read makefile to get project attributes
+    if( ! ReadMakeFile() )
+	{
+		cout << AT_MSG << "Error, cannot find project build with AnalyzeTool." << endl;
+	}
+	else
+		FilterModules();
+
+	#ifndef ADDR2LINE
+	// Initialize modules locating code lines.
+	for( size_t i = 0 ; i < m_vModules.size() ; i++ )
+	{
+		m_vModules.at(i)->InitializeAddressToLine();
+	}
+	#endif
+
+	// Create analyzer
+	m_pAnalyzer = new CATDatParser( &m_vModules );
+
+	// Pass some info from project if it "exists" to analyzer.
+	if ( m_vModules.size() > 0 )
+	{
+		// Pass platform.
+		m_pAnalyzer->SetProjectPlatform( m_sPlatform );
+		// Pass build type.
+		m_pAnalyzer->SetProjectBuildType( m_eBuildType );
+	}
+	
+	// Set file.
+	m_pAnalyzer->SetInputFile( m_sDataFile );
+
+	// Set rom symbol file.
+	m_pAnalyzer->SetRomSymbolFiles( m_vRomSymbolFiles );
+
+	// Set output file if specified
+	if ( ! m_sDataFileOutput.empty() )
+	{
+		m_pAnalyzer->SetOutputFile( m_sDataFileOutput );
+	}
+	// Set log level
+	m_pAnalyzer->SetLogLevel( m_iLoggingLevel );
+
+	// Analyze
+	return m_pAnalyzer->Analyze();
+}
+
+int CATProject::RunInstrument()
+{
+	LOG_FUNC_ENTRY("CATProject::RunInstrument");
+	// Store attributes
+	if( ! MakeTempDirIfNotExist() )
+		return AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR;
+	if ( ! WriteAttributes() )
+		return AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR;
+	if ( m_eBuildSystem == SBS_V1 )
+	{
+		// Initialize level 1 make file member.
+		if ( ! InitSbs1MakeFileWithPath() )
+			return AT_RETURN_CODE::MAKEFILE_ERROR;
+		// Copy it to temporary folder.
+		CopyMakeFileSbs1ToTemporaryFolder();
+		// Run export.
+		if( ! RunExportSbs1() )
+			return AT_RETURN_CODE::MAKEFILE_ERROR;
+		// Create level 2 makefiles.
+		if ( ! CreateMakeFileSbs1Level2() )
+			return AT_RETURN_CODE::MAKEFILE_ERROR;
+	}
+	else if ( m_eBuildSystem == SBS_V2 )
+	{
+		// Create makefile only when using SBS v.2
+		if ( ! CreateMakeFile() )
+			return AT_RETURN_CODE::MAKEFILE_ERROR;
+	}
+	else
+	{
+		return AT_RETURN_CODE::UNKNOWN;
+	}
+	// Read makefile to get project attributes
+	if ( ! ReadMakeFile() )
+		return AT_RETURN_CODE::READ_MAKEFILE_ERROR;
+	// Filter unsupported
+	FilterModules();
+	// Check that we have some "valid" modules to hook
+	if ( m_vModules.size() == 0 &&(  m_vUnsupportedModules.size() > 0 || m_vStaticLibraries.size() > 0 ) )
+		return AT_RETURN_CODE::NO_SUPPORTED_MODULES_ERROR;
+
+	// Clean temporary dirs of modules
+	if ( ! CleanTemporaryDirs() )
+		return AT_RETURN_CODE::CLEANING_TEMP_ERROR;
+	// Create temporary cpps for modulse
+	if (! CreateTemporaryCpps() )
+		return AT_RETURN_CODE::CREATING_TEMP_CPP_ERROR;
+	// Hook modules
+	if (! ModifyModules() )
+		return AT_RETURN_CODE::MODIFY_MODULES_ERROR;
+	return AT_RETURN_CODE::OK;
+}
+
+int CATProject::RunInstrumentConsole()
+{
+	LOG_FUNC_ENTRY("CATProject::RunInstrumentConsole");
+	if( ! MakeTempDirIfNotExist() )
+		return AT_RETURN_CODE::UNKNOWN;
+	// Store attributes
+	m_bUninstrumented = false;
+	if ( ! WriteAttributes() )
+		return AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR;
+	// Create makefile
+	if ( ! CreateMakeFile() )
+		return AT_RETURN_CODE::MAKEFILE_ERROR;
+	// Read makefile to get project attributes
+	if ( ! ReadMakeFile() )
+		return AT_RETURN_CODE::READ_MAKEFILE_ERROR;
+	// Filter unsupported
+	FilterModules();
+	// Check that we have some "valid" modules to hook
+	if ( m_vModules.size() == 0 &&(  m_vUnsupportedModules.size() > 0 || m_vStaticLibraries.size() > 0 ) )
+		return AT_RETURN_CODE::NO_SUPPORTED_MODULES_ERROR;
+
+	// Clean temporary dirs of modules
+	if ( ! CleanTemporaryDirs() )
+		return AT_RETURN_CODE::CLEANING_TEMP_ERROR;
+	// Create temporary cpps for modulse
+	if (! CreateTemporaryCpps() )
+		return AT_RETURN_CODE::CREATING_TEMP_CPP_ERROR;
+	// Hook modules
+	if (! ModifyModules() )
+		return AT_RETURN_CODE::MODIFY_MODULES_ERROR;	
+	return AT_RETURN_CODE::OK;
+}
+
+int CATProject::RunUninstrument()
+{
+	LOG_FUNC_ENTRY("CATProject::RunUninstrument");
+	// Read attributes.
+	if ( ! ReadAttributes() )
+		return AT_RETURN_CODE::READ_ATTRIBUTES_ERROR;
+	// Init makefile member for this run mode.
+	if ( m_eBuildSystem == SBS_V1 )
+		InitSbs1MakeFileWithPathToTemp();
+	// Read makefile to get project attributes
+	if ( ! ReadMakeFile() )
+		return AT_RETURN_CODE::READ_MAKEFILE_ERROR;
+	// Filter unsupported
+	FilterModules();
+	// Check that we have some "valid" modules to hook
+	if ( m_vModules.size() == 0 &&(  m_vUnsupportedModules.size() > 0 || m_vStaticLibraries.size() > 0 ) )
+		return AT_RETURN_CODE::NO_SUPPORTED_MODULES_ERROR;
+	// Create lst files
+    if (! CreateListings() )
+		return AT_RETURN_CODE::COMPILE_ERROR;
+	// Copy releasables of modules
+	if (! CopyReleasables() )
+		return AT_RETURN_CODE::RELEASABLES_ERROR;
+	// Restore "unhook" modules
+	if (! RestoreModules() )
+		return AT_RETURN_CODE::RESTORE_MODULES_ERROR;
+	// Return error code OK
+	return AT_RETURN_CODE::OK;
+}
+
+int CATProject::RunUninstrumentConsole()
+{
+	LOG_FUNC_ENTRY("CATProject::RunUninstrumentConsole");
+	int iErrorCode = AT_RETURN_CODE::OK;
+	// Read attributes
+	if ( ReadAttributes() )
+	{
+		// Init makefile member for this run mode.
+		if ( m_eBuildSystem == SBS_V1 )
+			InitSbs1MakeFileWithPathToTemp();
+		// Read makefile to get project attributes
+		if( ReadMakeFile() )
+		{
+			// Filter unsupported
+			FilterModules();
+			// Create lst files
+			CreateListings();
+			if (! CopyReleasables() )
+				iErrorCode = AT_RETURN_CODE::RELEASABLES_ERROR;
+		}
+		else
+			iErrorCode = AT_RETURN_CODE::READ_MAKEFILE_ERROR;
+		// Change state to uninstrumented and write status
+		m_bUninstrumented = true;
+		if ( ! WriteAttributes() )
+			iErrorCode = AT_RETURN_CODE::WRITE_ATTRIBUTES_ERROR;
+	}
+	else
+	{
+		iErrorCode = AT_RETURN_CODE::READ_ATTRIBUTES_ERROR;
+	}
+	return iErrorCode;
+}
+
+int CATProject::RunUninstrumentFailed()
+{
+	LOG_FUNC_ENTRY("CATProject::RunUninstrumentFailed");
+	// Read attributes.
+	if ( ! ReadAttributes() )
+		return AT_RETURN_CODE::READ_ATTRIBUTES_ERROR;
+	// Init makefile member for this run mode.
+	if ( m_eBuildSystem == SBS_V1 )
+		InitSbs1MakeFileWithPathToTemp();
+	// Read makefile to get project attributes
+	if( ReadMakeFile() )
+	{
+		// Filter modules
+		FilterModules();
+		// Restore modules to make sure no changes left
+		if( RestoreModules() )
+		{
+			// Delete temporary dirs of modules
+			if(! DeleteTemporaryDirs() )
+			{
+
+			}
+
+		}
+		else
+		{
+
+		}
+	}
+	else
+	{
+
+	}
+	// Projects
+	if ( ! DirDelete( AT_TEMP_DIR, true ) )
+	{
+
+	}
+	return AT_RETURN_CODE::OK;
+}
+
+// ----------------------------------------------------------------------------
+// Main Functions
+// ----------------------------------------------------------------------------
+void CATProject::DisplayCompileSummary()
+{
+	LOG_FUNC_ENTRY("CATProject::DisplayCompileSummary");
+	cout << AT_BUILD_SUMMARY_HEADER;
+	// Supported modules
+	for( size_t i = 0; i < m_vModules.size(); i++ )
+	{
+		// Successful
+		if ( m_vModules.at(i)->GetErrors().empty() )
+		{
+			// Create build complete file for Carbide xtension
+			m_vModules.at(i)->CreateBuildCompleteFile();
+			cout << AT_BUILD_SUMMARY_INSTRUMENTED_BUILD_COMPLETE
+				<< GetPathOrFileName( true, m_vModules.at(i)->GetMmpFile() )
+				<< endl
+				<< AT_BUILD_SUMMARY_TARGET
+				<< m_vModules.at(i)->GetBinaryName()
+				<< endl;
+			// Datafiles
+			// Use module data file name if project's data file not defined.
+			if ( m_eLoggingMode == CATProject::S60 
+				&& m_vModules.at(i)->GetTargetType().compare("exe") == 0 )
+			{
+				if ( m_sS60FileName.empty() )
+					cout << AT_BUILD_SUMMARY_DATA_FILE_NAME
+						<< m_vModules.at(i)->GetS60FileName()
+						<< endl;
+				else
+					cout << AT_BUILD_SUMMARY_DATA_FILE_NAME
+					<< m_sS60FileName
+					<< endl;
+			}
+		}
+		else
+		{
+			// Failed
+			cout << AT_BUILD_SUMMARY_FAILED
+				<< GetPathOrFileName( true, m_vModules.at(i)->GetMmpFile() )
+				<< endl
+				<< AT_BUILD_SUMMARY_TARGET
+				<< m_vModules.at(i)->GetBinaryName()
+				<< endl;
+			// Print errors.
+			cout << AT_BUILD_SUMMARY_ERRORS
+				<< m_vModules.at(i)->GetErrors()
+				<< endl;
+		}
+	}
+
+	// Static libraries
+	for( size_t i = 0; i < m_vStaticLibraries.size(); i++ )
+	{
+		if ( m_vStaticLibraries.at(i)->GetErrors().empty() )
+		{
+			cout << AT_BUILD_SUMMARY_NORMAL_BUILD_COMPLETE
+				<< GetPathOrFileName( true, m_vStaticLibraries.at(i)->GetMmpFile())
+				<< endl
+				<< AT_BUILD_SUMMARY_TARGET
+				<< m_vStaticLibraries.at(i)->GetBinaryName()
+				<< endl
+				<< AT_BUILD_SUMMARY_STATIC_LIBRARY
+				<< endl;
+				
+		}
+		else
+		{
+			// Failed
+			cout << AT_BUILD_SUMMARY_FAILED
+				<< GetPathOrFileName( true, m_vStaticLibraries.at(i)->GetMmpFile() )
+				<< endl
+				<< AT_BUILD_SUMMARY_TARGET
+				<< m_vStaticLibraries.at(i)->GetBinaryName()
+				<< endl;
+			// Print errors.
+			cout << AT_BUILD_SUMMARY_ERRORS
+				<< m_vStaticLibraries.at(i)->GetErrors()
+				<< endl;
+		}
+	}
+
+	// Unsupported modules
+	for( size_t i = 0; i < m_vUnsupportedModules.size(); i++ )
+	{
+		cout << AT_BUILD_SUMMARY_NORMAL_BUILD_COMPLETE
+			<< GetPathOrFileName( true, m_vUnsupportedModules.at(i)->GetMmpFile() )
+			<< endl
+			<< AT_BUILD_SUMMARY_TARGET
+			<< m_vUnsupportedModules.at(i)->GetBinaryName()
+			<< endl;
+		cout << m_vUnsupportedModules.at(i)->GetCompileInfoText() << endl;
+	}
+}
+
+void CATProject::DisplayBuildSummary( void )
+{
+	LOG_FUNC_ENTRY("CATProject::DisplayBuildSummary");
+	cout << endl;
+	// Build information
+	cout << AT_BUILD_SUMMARY_BUILD_TYPE << GetBuildTypeString() << endl;
+	// Platform
+	cout << AT_BUILD_SUMMARY_BUILD_PLATFORM << m_sPlatform << endl;
+	// Possible variant
+	if ( ! m_sVariant.empty() )
+		cout << AT_BUILD_SUMMARY_BUILD_VARIANT << m_sVariant << endl;
+	// Logging mode
+	cout << AT_BUILD_SUMMARY_LOGGING_MODE;
+	if ( m_eLoggingMode == S60 )
+		cout  << AT_BUILD_SUMMARY_S60;
+	else if ( m_eLoggingMode == XTI )
+		cout << AT_BUILD_SUMMARY_XTI;
+	else if ( m_eLoggingMode == XTI_FAST )
+		cout << AT_BUILD_SUMMARY_XTI_FAST;
+	cout << endl;
+	// Call stack sizes
+	cout << AT_BUILD_SUMMARY_ALLOC_CALL_STACK_SIZE
+		<< m_iAllocCallStackSize
+		<< endl;
+	cout << AT_BUILD_SUMMARY_FREE_CALL_STACK_SIZE
+		<< m_iFreeCallStackSize
+		<< endl;
+}
+
+bool CATProject::CreateMakeFile()
+{
+	switch ( m_eBuildSystem )
+	{
+	case SBS_V1:
+		if( ! CreateMakeFileSbs1() )
+			return false;
+		// Copy main make file.
+		if( ! CopyMakeFileSbs1ToTemporaryFolder() )
+			return false;
+		// Run Reallyclean.
+		if( ! RunReallyCleanSbs1() )
+			return false;
+		// Run export.
+		if( ! RunExportSbs1() )
+			return false;
+		// Create level 2 makefiles.
+		if( ! CreateMakeFileSbs1Level2() )
+			return false;
+		return true;
+	case SBS_V2:
+		return CreateMakeFileSbs2();
+	default:
+		return false;
+	}
+}
+
+bool CATProject::CreateMakeFileSbs1()
+{
+	LOG_FUNC_ENTRY("CATProject::CreateMakeFileSbs1");
+
+	// If variant defined check does it exist.
+	if( ! m_sVariant.empty() )
+	{
+		if ( ! CheckVariant( m_sEpocRoot, m_sVariant ) )
+		{
+			cout << INVALID_VARIANT_ERROR;
+			if ( IsDefaultVariant( m_sEpocRoot ) )
+			{
+				m_sVariant = "default";
+				cout << USING_DEFAULT_VARIANT_MESSAGE;
+				if ( ! WriteAttributes() )
+					return false;
+			}
+			else
+			{
+				cout << NO_DEFAULT_VARIANT_ERROR;
+				return false;
+			}
+		}
+	}
+
+	// Create level 1 make file.
+	string sCmd( "bldmake bldfiles " );
+	sCmd.append( m_sPlatform );
+	cout << AT_MSG_SYSTEM_CALL << sCmd << endl;
+	(void)system( sCmd.c_str() );
+	return InitSbs1MakeFileWithPath();
+}
+
+bool CATProject::CopyMakeFileSbs1ToTemporaryFolder()
+{
+	LOG_FUNC_ENTRY("CATProject::CopyMakeFileSbs1ToTemporaryFolder");
+	// Check that temporary dir exists if not create it.
+	if ( ! MakeTempDirIfNotExist() )
+		return false;
+	// Copy makefile to temporary directory
+	string sMakeFileInTemp( AT_TEMP_DIR );
+	sMakeFileInTemp.append( "\\" );
+	sMakeFileInTemp.append( AT_LEVEL_1_MAKEFILE_NAME );
+	if ( ! FileCopyToPath( m_sMakeFile, sMakeFileInTemp ) )
+		return false;
+	return true;
+
+}
+
+bool CATProject::RunReallyCleanSbs1()
+{
+	LOG_FUNC_ENTRY("CATProject::RunReallyCleanSbs1");
+	// Check that abld.bat has been made.
+	if ( ! FileExists( "abld.bat" ) )
+		return false;
+	// Run reallyclean.
+	string sCmd( "abld reallyclean ");
+	sCmd.append( m_sPlatform );
+	if ( ! m_sVariant.empty() )
+	{
+		sCmd.append( "." );
+		sCmd.append( m_sVariant );
+	}
+	sCmd.append( " " );
+	sCmd.append( GetBuildTypeString() );
+	if ( m_vTargetModules.size() > 1 )
+	{
+		RunAbldCommandToAllTargets( sCmd );
+	}
+	else
+	{
+		AddTargetModuleIfDefined( sCmd );
+		cout << AT_MSG_SYSTEM_CALL << sCmd << endl;
+		(void) system( sCmd.c_str() );
+	}
+	return true;
+}
+
+bool CATProject::RunReallyCleanSbs2()
+{
+	LOG_FUNC_ENTRY("CATProject::RunReallyCleanSbs2");
+	string sCmd("");
+	if ( m_sBuildCommand.empty() )
+	{
+		// If no build command defined (not found in project.cfg).
+		sCmd.append( RAPTOR_CMD_BASE );;
+		sCmd.append( m_sPlatform );
+		sCmd.append( "_" );
+		sCmd.append( GetBuildTypeString() );
+		if ( ! m_sVariant.empty() )
+		{
+			sCmd.append( "." );
+			sCmd.append( m_sVariant );
+		}
+		sCmd.append( RAPTOR_REALLYCLEAN_LOG );
+		AddTargetModuleIfDefined( sCmd );
+		sCmd.append( " REALLYCLEAN" );
+	}
+	else
+	{
+		// When build command set use it.
+		sCmd.append( m_sBuildCommand );
+		sCmd.append( RAPTOR_REALLYCLEAN_LOG );
+		sCmd.append( " REALLYCLEAN" );
+	}
+	cout << AT_MSG_SYSTEM_CALL << sCmd << endl;
+	int iRet = (int)system( sCmd.c_str() );
+	if ( iRet == 0 )
+		return true;
+	return false;
+}
+
+bool CATProject::RunExportSbs1()
+{
+	LOG_FUNC_ENTRY("CATProject::RunExportSbs1");
+	// Run export.
+	cout << AT_MSG_SYSTEM_CALL << "abld export" << endl;
+	(void) system( "abld export" );
+	return true;
+}
+
+bool CATProject::CreateMakeFileSbs1Level2()
+{
+	LOG_FUNC_ENTRY("CATProject::CreateMakeFileSbs1Level2");
+	// Create level 2 makefiles.
+	string sCmd( "abld makefile ");
+	sCmd.append( m_sPlatform );
+	if ( ! m_sVariant.empty() )
+	{
+		sCmd.append( "." );
+		sCmd.append( m_sVariant );
+	}
+		// Check if multiple targets defined and sbs 1.
+	if ( m_vTargetModules.size() > 1 )
+	{
+		RunAbldCommandToAllTargets( sCmd );
+	}
+	else
+	{
+		AddTargetModuleIfDefined( sCmd );
+		cout << AT_MSG_SYSTEM_CALL << sCmd << endl;
+		(void) system( sCmd.c_str() );
+	}
+	return true;
+}
+
+bool CATProject::CreateMakeFileSbs2()
+{
+	LOG_FUNC_ENTRY("CATProject::CreateMakeFileSbs2");
+	// Delete build directory if it exists before creating new makefiles.
+	if ( DirectoryExists( "atool_temp\\build" ) )
+		DirDelete( "atool_temp\\build", true );
+	// Create command to create makefiles.
+	string sCmd( m_sBuildCommand );
+	sCmd.append( " " );
+	sCmd.append( RAPTOR_MAKEFILE_SWITCH );
+	sCmd.append( " " );
+	sCmd.append( RAPTOR_NOBUILD_SWITCH );
+	cout << AT_MSG_SYSTEM_CALL << sCmd << endl;
+	int iRet = (int)system( sCmd.c_str() );
+	if ( iRet == 0 )
+		return true;
+	return false;
+}
+
+bool CATProject::ReadMakeFile()
+{
+	// Clean modules before reading.
+	CleanModuleVectors();
+	if ( m_eBuildSystem == SBS_V1 )
+	{
+		// Read level 1 makefile which contains module name and makefiles.
+		if( ! ReadMakeFileSbs1Level1() )
+			return false;
+		// Read level 2 makefiles.
+		vector<CATModule2*>::iterator it;
+		// If we are compiling or etc... we need to create temporary directories.
+		if ( m_eMode == COMPILE || m_eMode == INSTRUMENT || m_eMode == INSTRUMENT_CONSOLE )
+		{
+			// Read make makefiles from /epoc32/build... and create temporary directory.
+			bool bLevel2 = true;
+			for( it = m_vModules.begin(); it != m_vModules.end() ; it ++ )
+			{
+				if( ! (*it)->CreateTemporaryDirectory() )
+					return false;
+				if( ! (*it)->ReadMakeFile() )
+				{
+					bLevel2 = false;
+					break;
+				}
+			}
+			// If failed reading modules from level 2 makefiles.
+			if ( ! bLevel2 )
+			{
+				// Clean modules.
+				CleanModuleVectors();
+				// Try use default variant if it exists.
+				if ( CheckVariant( m_sEpocRoot, "default" ) )
+				{
+					m_sVariant = "default";
+					cout << USING_DEFAULT_VARIANT_MESSAGE;
+					if ( ! WriteAttributes() )
+						return false;
+					if ( ! InitSbs1MakeFileWithPath() )
+						return false;
+					if ( ! ReadMakeFileSbs1Level1() )
+						return false;
+					for( it = m_vModules.begin(); it != m_vModules.end() ; it ++ )
+					{
+						if( ! (*it)->CreateTemporaryDirectory() )
+							return false;
+						if( ! (*it)->ReadMakeFile() )
+							return false;
+					}
+
+				}
+			}
+		}
+		else
+		{
+			// Read make files from temporary directories.
+			for( it = m_vModules.begin(); it != m_vModules.end() ; it ++ )
+			{
+				if ( ! (*it)->ReadMakeFileFromTemp() )
+					return false;
+			}
+		}
+		return true;
+	}
+	else if ( m_eBuildSystem == SBS_V2 )
+	{
+		// Read make file.
+		if( ! ReadMakeFileSbs2() )
+			return false;
+		// Create module temporary directories if we are compiling or etc...
+		if ( m_eMode == COMPILE || m_eMode == INSTRUMENT || m_eMode == INSTRUMENT_CONSOLE )
+			{
+			for( vector<CATModule2*>::iterator it = m_vModules.begin(); it < m_vModules.end(); it++ )
+				(*it)->CreateTemporaryDirectory();
+			for( vector<CATModule2*>::iterator it = m_vStaticLibraries.begin(); it < m_vStaticLibraries.end(); it++ )
+				(*it)->CreateTemporaryDirectory();
+			}
+	}
+	return true;
+}
+
+bool CATProject::ReadMakeFileSbs1Level1()
+{
+	LOG_FUNC_ENTRY("CATProject::ReadMakeFileSbs1Level1");
+
+	bool bRet = false;
+
+	//Try to open makefile
+	ifstream in;
+	in.open( m_sMakeFile.c_str() );
+
+	//File open ok?
+	if( !in.good() )
+	{
+		printf( "Can not open file: %s\n", m_sMakeFile.c_str() );
+		in.close();
+		return bRet;
+	}
+
+	// Add also these so "compatible with sbs2".
+	// Releasables path (binaries).
+	string sReleasePath( m_sEpocRoot );
+	// add trailing '\' if root path is missing it
+	if ( sReleasePath.size() < 1 )
+		sReleasePath.append( "\\" );
+	else if ( sReleasePath.at( sReleasePath.length() -1 ) != '\\' )
+		sReleasePath.append( "\\" );
+	sReleasePath.append( "epoc32\\release" );
+	string sFullVariantPath( m_sPlatform );
+	sFullVariantPath.append( "\\" );
+	sFullVariantPath.append( GetBuildTypeString() );
+
+	char cTemp[MAX_LINE_LENGTH];
+	bool bContinueSearch = true;
+	bool bMmpInfoFound = false;
+	CATModule2* pModule = 0;
+	string sTempLineFromFile;
+	do
+	{
+		// get line from file
+		in.getline( cTemp, MAX_LINE_LENGTH );
+		sTempLineFromFile.clear();
+		sTempLineFromFile.append( cTemp );
+
+		//Search makefile string
+		if( sTempLineFromFile.find( MAKEFILE_SEARCH_STRING ) != string::npos )
+		{
+			bMmpInfoFound = true;
+			if( sTempLineFromFile.find( MMPFILE_SEARCH_STRING ) != string::npos )
+			{
+				bRet = true;
+				//Parse mmp path + mmp filename
+				sTempLineFromFile.erase( 0, sTempLineFromFile.find_first_of("\"") );
+				sTempLineFromFile.erase( 0, 1 );
+
+				string sPath = sTempLineFromFile.substr(0, sTempLineFromFile.find_first_of("\"") );
+
+				sPath = ChangeSlashToBackSlash( sPath );
+				//Remove text "bld.inf"
+				sPath.erase( (sPath.find_last_of( "\\" ) + 1) , string::npos );
+
+				string sFileName = sTempLineFromFile.substr( (sTempLineFromFile.find( MMPFILE_SEARCH_STRING ) + strlen(MMPFILE_SEARCH_STRING) + 3), string::npos );
+				sFileName = ChangeSlashToBackSlash( sFileName );
+				sFileName = sFileName.substr( 0, sFileName.find_first_of("\"") );
+
+				// Append .mmp to filename if it does not exist
+				if ( sFileName.find(".mmp") == string::npos )
+					sFileName.append(".mmp");
+
+				//Insert drive letter
+				sPath.insert(0, string( m_cCurrentDir).substr(0,2) );
+		
+				//Insert mmp file to the end
+				sPath.append( sFileName );
+
+				ChangeToLower( sPath );
+				
+				// If target programs defined find from those or do not
+				// add module to vector.
+				bool bAddToVector = true;
+				if ( m_vTargetModules.size() > 0 )
+				{
+					bAddToVector = false;
+					vector<string>::iterator it;
+					for( it = m_vTargetModules.begin() ; it != m_vTargetModules.end() ; it++ )
+					{
+						string sFind( *it );
+						sFind.insert( 0, "\\" );
+						if ( sPath.find( sFind ) != string::npos )
+						{
+							bAddToVector = true;
+							break;
+						}
+					}	
+				}
+
+				if ( bAddToVector )
+				{
+					pModule = new CATModule2();
+					pModule->SetMmpFile( sPath );
+					pModule->SetVariantType( GetBuildTypeString() );
+					pModule->SetVariantPlatform( m_sPlatform );
+					pModule->SetReleasePath( sReleasePath );
+					pModule->SetFullVariantPath( sFullVariantPath );
+					pModule->SetBuildSystem( SBS_V1 );
+					m_vModules.push_back( pModule );
+				}
+			}
+		}
+		else if( bMmpInfoFound )
+			//Do not continue search if mmp info lines are all handled
+			bContinueSearch = false;
+		if( !in.good() )
+			bContinueSearch = false;
+	}
+	while( bContinueSearch );
+
+	bContinueSearch = true;
+
+	//Search MAKEFILES for invidual modules
+	do
+	{
+		in.getline( cTemp, MAX_LINE_LENGTH );
+		sTempLineFromFile.clear();
+		sTempLineFromFile.append( cTemp );
+		// find the lines 'MAKEFILE[modulename]_FILES'
+		if( (sTempLineFromFile.find( "MAKEFILE" ) == 0) && (sTempLineFromFile.find( "_FILES" ) != string::npos) )
+		{
+			//Math the makefile line with one of our modules
+			for( size_t i = 0 ; i < m_vModules.size() ; i++ )
+			{
+				//Create name
+				string sMakeFile( "MAKEFILE" );
+				string sTempMmpFile( RemovePathAndExt( m_vModules.at(i)->GetMmpFile(), true ) );
+				ChangeToUpper( sTempMmpFile );
+				sMakeFile.append( sTempMmpFile );
+				sMakeFile.append( "_FILES" );
+				// matched
+				if( sTempLineFromFile.find( sMakeFile ) != string::npos )
+				{
+					//parse the makefile name from line
+					in.getline( cTemp, MAX_LINE_LENGTH );
+					sTempLineFromFile.clear();
+					sTempLineFromFile.append( cTemp );
+					//Remove character "\""
+					sTempLineFromFile.erase( 0, ( sTempLineFromFile.find_first_of("\"") + 1 ) );
+					// in winscw last part is '" \' and on armd '"' so remove all after last '"'
+					sTempLineFromFile.erase( sTempLineFromFile.find_last_of("\""), sTempLineFromFile.size() );
+					// Set correct makefile for module
+					m_vModules.at( i )->SetMakeFile( sTempLineFromFile );
+					// break 
+					break;
+				} // If mathed to mmp
+			} // End of mmp file loop
+		} // found lines 'MAKEFILE[modulename]_FILES'
+		if( !in.good() )
+			bContinueSearch = false;
+	}
+	while( bContinueSearch );
+	in.close();
+	return bRet;
+}
+
+bool CATProject::ReadMakeFileSbs2( void )
+{
+	LOG_FUNC_ENTRY("CATProject::ReadMakeFileSbs2(void)");
+	// File is by default named make_build.default but when building specific layer
+	// make_build_LAYERNAME.default is produced by Raptor.
+	// So find makefile(s) and read them.
+	vector<string> vMakeFiles = DirList( "atool_temp\\build\\", false, true );
+	bool bRet = true;
+	for( vector<string>::iterator it = vMakeFiles.begin(); it != vMakeFiles.end() ; it++ )
+	{
+		// Recognize multiple makefiles.
+		if ( it->find("make_build_") != string::npos && it->find(".default") != string::npos )
+		{
+			if ( ! ReadMakeFileSbs2( *it ) )
+				bRet = false;
+		}
+		// Single makefile.
+		else if ( it->find( "make_build.default" ) != string::npos )
+		{
+			if ( ! ReadMakeFileSbs2( *it ) )
+				bRet = false;
+		}
+	}
+	// We got some modules?
+	if ( m_vModules.size() == 0 )
+		bRet = false;
+	return bRet;
+}
+
+bool CATProject::ReadMakeFileSbs2( string& sMakeFile )
+{
+	LOG_FUNC_ENTRY("CATProject::ReadMakeFileSbs2(string)");
+	try {
+		// Open file
+		ifstream in;
+		in.open( sMakeFile.c_str() , ios_base::in );
+		// Check that open ok
+		if ( ! in.good() )
+		{
+			cout << AT_MSG << "Error, opening file "
+				<< RAPTOR_MAKEFILE << endl;
+			in.close();
+			return false;
+		}
+		// Source line from file
+		string sSourceLine;
+		// Module pointer
+		CATModule2* pModule = 0;
+		// Line from file
+		char cLine[MAX_LINE_LENGTH];
+		// Are we looking for module attributes
+		bool bFindAttributes = false;
+		// Until end of file
+		while( in.good() )
+		{
+			// Get new line from file
+			in.getline( cLine, MAX_LINE_LENGTH );
+			string sLine(cLine);
+			// New module
+			if ( sLine.find( RAPTOR_PROJECT_META ) == 0 )
+			{
+				// Remove project_meta from line
+				sLine.erase(0, strlen( RAPTOR_PROJECT_META ) );
+				LOG_STRING("Found module: " << sLine );
+				// Check is name empty
+				// This seems to happen when sbs2 "wraps" i.e. mifconv to a module type item
+				if ( sLine.empty() )
+				{
+					LOG_STRING("skipping empty module");
+					// Skip it
+					continue;
+				}
+				// If module add it to vector
+				if ( pModule )
+				{
+					// Add sources,
+					pModule->AddSources( sSourceLine );
+					// Build system.
+					pModule->SetBuildSystem( SBS_V1 );
+					// Push to vector.
+					m_vModules.push_back( pModule );
+				}
+				// New module
+				pModule = new CATModule2();
+				// Clear sourceline
+				sSourceLine.clear();
+				// Set modules mmp with path
+
+				if ( ! pModule->SetMmpFile( sLine ) )
+				{
+					// Fatal error setting mmp file
+					in.close();
+					return false;
+				}
+				// Find attributes on
+				bFindAttributes = true;
+				// Get new line from file
+				in.getline( cLine, MAX_LINE_LENGTH );
+			}
+			// If attribute finding on
+			if ( bFindAttributes )
+			{
+				// Pickup modules attributes
+				if ( sLine.find ( RAPTOR_SOURCE ) == 0 )
+				{
+					sLine.erase(0, strlen( RAPTOR_SOURCE ) );
+					sSourceLine = sLine;
+				}
+				else if ( sLine.find ( RAPTOR_TARGET ) == 0 )
+				{
+					sLine.erase(0, strlen( RAPTOR_TARGET ) );
+					pModule->SetTarget( sLine );
+				}
+				else if ( sLine.find ( RAPTOR_TARGETYPE ) == 0 )
+				{
+					sLine.erase(0, strlen( RAPTOR_TARGETYPE ));
+					pModule->SetTargetType( sLine );
+				}
+				else if ( sLine.find( RAPTOR_REQUESTEDTARGETEXT ) == 0 )
+				{
+					sLine.erase(0, strlen( RAPTOR_REQUESTEDTARGETEXT ) );
+					pModule->SetRequestedTargetExt( sLine );
+				}
+				else if ( sLine.find ( RAPTOR_VARIANTPLATFORM ) == 0 )
+				{
+					sLine.erase(0, strlen( RAPTOR_VARIANTPLATFORM ));
+					pModule->SetVariantPlatform( sLine );
+				}
+				else if ( sLine.find ( RAPTOR_VARIANTTYPE ) == 0 )
+				{
+					sLine.erase(0, strlen( RAPTOR_VARIANTTYPE ));
+					pModule->SetVariantType( sLine );
+				}
+				else if ( sLine.find ( RAPTOR_FEATUREVARIANT ) == 0 )
+				{
+					sLine.erase(0, strlen( RAPTOR_FEATUREVARIANT ));
+					pModule->SetFeatureVariant( sLine );
+				}
+				else if ( sLine.find ( RAPTOR_FEATUREVARIANTNAME ) == 0 )
+				{
+					sLine.erase(0, strlen( RAPTOR_FEATUREVARIANTNAME ));
+					pModule->SetFeatureVariantName( sLine );
+				}
+				else if ( sLine.find ( RAPTOR_RELEASEPATH ) == 0 )
+				{
+					sLine.erase(0, strlen( RAPTOR_RELEASEPATH ));
+					pModule->SetReleasePath( sLine );
+				}
+				else if ( sLine.find ( RAPTOR_FULLVARIANTPATH ) == 0 )
+				{
+					sLine.erase(0, strlen( RAPTOR_FULLVARIANTPATH ));
+					pModule->SetFullVariantPath( sLine );
+				}
+				else if ( sLine.find ( RAPTOR_COMPILE_DEFINITIONS ) == 0 )
+				{
+					sLine.erase(0, strlen( RAPTOR_COMPILE_DEFINITIONS ) );
+					pModule->SetCompileDefinitions( sLine );
+				}
+			}
+		} // while in.good()
+		// Add last module if n number of modules found
+		if ( pModule )
+		{
+			if ( ! pModule->GetTarget().empty() )
+			{
+				// Add sources
+				pModule->AddSources( sSourceLine );
+				// Build system.
+				pModule->SetBuildSystem( SBS_V1 );
+				// Push back to vector
+				m_vModules.push_back( pModule );
+			}
+		}
+		// Close file
+		in.close();
+		return true;
+	} // try.
+	catch(...)
+	{
+		LOG_STRING("Unexpected exception reading sbs 2 makefile");
+		return false;
+	}
+}
+bool CATProject::CreateTemporaryDirectories()
+{
+	LOG_FUNC_ENTRY("CATProject::CreateTemporaryDirectories");
+	bool bRet = true;
+	for( size_t i = 0 ; i < m_vModules.size(); i++)
+	{
+		if( ! m_vModules.at(i)->CreateTemporaryDirectory() )
+			bRet = false;
+	}
+	for( size_t i = 0 ; i < m_vStaticLibraries.size(); i++)
+	{
+		if( ! m_vStaticLibraries.at(i)->CreateTemporaryDirectory() )
+			bRet = false;
+	}
+	return bRet;
+
+}
+
+bool CATProject::CreateTemporaryCpps()
+{
+	LOG_FUNC_ENTRY("CATProject::CreateTemporaryCpps");
+	bool bRet = true;
+	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 ) )
+			bRet = false;
+	}
+	return bRet;
+}
+
+bool CATProject::FilterModules()
+{
+	LOG_FUNC_ENTRY("CATProject::FilterModules");
+	vector<CATModule2*>::iterator it;
+	// Loop thru modules.
+	it = m_vModules.begin();
+	while( it != m_vModules.end() )
+	{
+		// Get target type of module to separate string (will be modified).
+		string sTargetType = (*it)->GetTargetType();
+		// Modules compile definitions.
+		string sCompileDefinition = (*it)->GetCompileDefinitions();
+		// Check is it supported.
+		if ( !IsTargetTypeSupported( sTargetType) )
+		{
+			(*it)->SetCompileInfoText( AT_UNSUPPORTED_TARGET_TYPE );
+			// Not supported add to not supported vector.
+			m_vUnsupportedModules.push_back( *it );
+			// Erase cell.
+			it = m_vModules.erase( it );
+		}
+		// Check if its static library
+		else if ( _stricmp( sTargetType.c_str(), "lib" ) == 0 )
+		{
+			// Static librarie move to their vector.
+			m_vStaticLibraries.push_back( *it );
+			// Erase cell.
+			it = m_vModules.erase( it );
+		
+		}
+		else if ( sCompileDefinition.find( KERNEL_MODE_COMPILE_DEFINITION ) != string::npos )
+		{
+			(*it)->SetCompileInfoText( AT_UNSUPPORTED_COMPILE_DEFINITION );
+			// Not supported add to not supported vector.
+			m_vUnsupportedModules.push_back( *it );
+			// Erase cell.
+			it = m_vModules.erase( it );
+		}
+		else
+			it++;
+	}
+	return true;
+}
+
+bool CATProject::ModifyModules()
+{
+	LOG_FUNC_ENTRY("CATProject::ModifyModules");
+	bool bRet = true;
+	for( size_t i = 0; i < m_vModules.size(); i++ )
+	{
+		if (! m_vModules.at(i)->ModifyMmp() )
+			bRet = false;
+	}
+	for( size_t i = 0; i < m_vStaticLibraries.size(); i++ )
+	{
+		if (! m_vStaticLibraries.at(i)->ModifyMmp() )
+			bRet = false;
+	}
+	return bRet;
+}
+
+bool CATProject::RestoreModules()
+{
+	LOG_FUNC_ENTRY("CATProject::RestoreModules");
+	bool bRet = true;
+	for( size_t i = 0; i < m_vModules.size(); i++ )
+	{
+		if (! m_vModules.at(i)->RestoreMmp() )
+			bRet = false;
+	}
+	for( size_t i = 0; i < m_vStaticLibraries.size(); i++ )
+	{
+		if (! m_vStaticLibraries.at(i)->RestoreMmp() )
+			bRet = false;
+	}
+	return bRet;
+}
+
+bool CATProject::VerifyAndRecoverModules()
+{
+	LOG_FUNC_ENTRY("CATProject::VerifyAndRecoverModules");
+	bool bRet = true;
+	for( size_t i = 0; i < m_vModules.size(); i++ )
+	{
+		if (! m_vModules.at(i)->VerifyAndRecoverMmp() )
+			bRet = false;
+	}
+	for( size_t i = 0; i < m_vStaticLibraries.size(); i++ )
+	{
+		if (! m_vStaticLibraries.at(i)->VerifyAndRecoverMmp() )
+			bRet = false;
+	}
+	return bRet;
+}
+bool CATProject::Compile()
+{
+	switch ( m_eBuildSystem )
+	{
+	case SBS_V1:
+		return CompileSbs1();
+	case SBS_V2:
+		return CompileSbs2();
+	default:
+		return false;
+	}
+}
+
+bool CATProject::CompileSbs1()
+{
+	LOG_FUNC_ENTRY("CATProject::CompileSbs1");
+	string sCommand("");
+	if ( m_sBuildCommand.empty() )
+	{
+		sCommand = "abld build";
+		// -debug if urel
+		if ( m_eBuildType == UREL )
+			sCommand.append( " -debug" );
+
+		// No variant
+		if ( m_sVariant.empty() )
+		{
+			sCommand.append( " " );
+			sCommand.append( m_sPlatform );
+		}
+		else
+		{
+			// Add variant
+			sCommand.append( " " );
+			sCommand.append( m_sPlatform );
+			sCommand.append( "." );
+			sCommand.append( m_sVariant );
+		}
+
+		// urel vs udeb
+		sCommand.append( " " );
+		sCommand.append( GetBuildTypeString() );
+
+		// Possible target module
+		AddTargetModuleIfDefined( sCommand );
+	}
+	// Check that build command contains -debug switch if sbs v.1 used
+	else if ( ! m_sBuildCommand.empty() 
+		&& m_eBuildType == UREL 
+		&& m_eBuildSystem == SBS_V1 
+		&& m_sBuildCommand.find( "-debug" ) == string::npos )
+	{
+		// Find correct index to insert -debug switch
+		size_t iPos = m_sBuildCommand.find( "build" );
+		if ( iPos != string::npos )
+		{
+			sCommand = m_sBuildCommand;
+			sCommand.insert( iPos+5, " -debug" );
+		}
+		else
+		{
+			LOG_STRING("Overwriting given build command to add -debug switch. Original command is: " << m_sBuildCommand );
+			sCommand = "abld build -debug ";
+			// No variant
+			if ( m_sVariant.empty() )
+			{
+				sCommand.append( m_sPlatform );
+			}
+			else
+			{
+				// Add variant
+				sCommand.append( m_sPlatform );
+				sCommand.append( "." );
+				sCommand.append( m_sVariant );
+			}
+
+			// urel vs udeb
+			sCommand.append( " " );
+			sCommand.append( GetBuildTypeString() );
+			// Possible target module
+			AddTargetModuleIfDefined( sCommand );
+		}
+	}
+	else
+		sCommand = m_sBuildCommand;
+	// Run command
+	cout << AT_MSG_SYSTEM_CALL << sCommand << endl;
+	(void)system( sCommand.c_str() );
+	return true;
+}
+
+bool CATProject::CompileSbs2()
+{
+	LOG_FUNC_ENTRY("CATProject::CompileSbs2");
+	// Create command to compile with raptor
+	string sCmd( m_sBuildCommand );
+	sCmd.append( RAPTOR_BUILD_LOG );
+	cout << AT_MSG_SYSTEM_CALL << sCmd << endl;
+	int iRet = (int)system( sCmd.c_str() );
+	if ( iRet == 0 )
+		return true;
+	return false;
+}
+
+bool CATProject::CreateListings()
+{
+	// Create listings if no addr2line defined
+	#ifndef ADDR2LINE
+	if ( _stricmp( m_sPlatform.c_str(), "armv5" ) == 0 )
+	{
+		switch ( m_eBuildSystem )
+		{
+		case SBS_V1:
+			return CreateListingsSbs1();
+		case SBS_V2:
+			return CreateListingsSbs2();
+		default:
+			return false;
+		}
+	}
+	#endif
+	return true;
+}
+
+bool CATProject::CreateListingsSbs1()
+{
+	LOG_FUNC_ENTRY("CATProject::CreateListingsSbs1");
+	string sCommand( "abld listing " );
+
+	// Listing
+	if ( m_sVariant.empty() )
+	{
+		// No variant
+		sCommand.append( m_sPlatform );
+	}
+	else
+	{
+		// Use specified variant
+		sCommand.append( m_sPlatform );
+		sCommand.append( "." );
+		sCommand.append( m_sVariant );
+	}
+	// udeb vs urel
+	sCommand.append( " " );
+	sCommand.append( GetBuildTypeString() );
+
+	if ( m_vTargetModules.size() > 1 )
+	{
+		RunAbldCommandToAllTargets( sCommand );
+	}
+	else
+	{
+		AddTargetModuleIfDefined( sCommand ); 
+		cout << AT_MSG_SYSTEM_CALL << sCommand << endl;
+		(void)system( sCommand.c_str() );
+	}
+	return true;
+}
+
+bool CATProject::CreateListingsSbs2()
+{
+	LOG_FUNC_ENTRY("CATProject::CreateListingsSbs2");
+	string sCmd( m_sBuildCommand );
+	sCmd.append( RAPTOR_LISTING_LOG );
+	sCmd.append( " LISTING");
+	cout << AT_MSG_SYSTEM_CALL << sCmd << endl;
+	int iRet = (int)system( sCmd.c_str() );
+	if ( iRet == 0 )
+		return true;
+	return false;
+}
+
+bool CATProject::CopyReleasables()
+{
+	bool bRet = true;
+	LOG_FUNC_ENTRY("CATProject::CopyReleasables");
+	// Only copy releasables on armv5 platform and no addr2line defined.
+	#ifndef ADDR2LINE
+	if ( _stricmp( m_sPlatform.c_str(), "armv5" ) == 0 ) 
+	{
+		for( size_t i = 0; i < m_vModules.size(); i++ )
+		{
+			if ( ! m_vModules.at(i)->CopyReleasables() )
+				bRet = false;
+		}
+		// Static libraries lst files.
+		// First create directory for them (delete old one if exists).
+		if ( ! DirectoryExists( AT_TEMP_LST_DIR ) )
+		{
+			DirCreate( AT_TEMP_LST_DIR, true );
+		}
+		else
+		{
+			DirDelete( AT_TEMP_LST_DIR, true );
+			DirCreate( AT_TEMP_LST_DIR, true );
+		}
+		for ( size_t i = 0 ; i < m_vStaticLibraries.size(); i ++ )
+		{
+			if( ! m_vStaticLibraries.at(i)->CopyLstFilesToDir( AT_TEMP_LST_DIR ) )
+				bRet = false;
+		}
+
+		// Delete lst files from all type of modules in project.
+		// Ignoring errors because different modules might use same source/lst files.
+		for( size_t i = 0; i < m_vModules.size(); i++ )
+			m_vModules.at(i)->DeleteLstFilesFromSrc();
+		for ( size_t i = 0 ; i < m_vUnsupportedModules.size(); i ++ )
+			m_vUnsupportedModules.at(i)->DeleteLstFilesFromSrc();
+		for ( size_t i = 0 ; i < m_vStaticLibraries.size(); i ++ )
+			m_vStaticLibraries.at(i)->DeleteLstFilesFromSrc();
+		
+		return bRet;
+	}
+	#endif
+	// When addr2line defined and used we use symbol and map file(s).
+	#ifdef ADDR2LINE
+	if ( _stricmp( m_sPlatform.c_str(), "armv5" ) == 0 )
+	{
+		// Verify that module(s) symbol file(s) exist
+		for( size_t i = 0; i < m_vModules.size(); i++ )
+		{
+			// Check symbol file.
+			if ( ! m_vModules.at(i)->SymbolFileExist() )
+				bRet = false;
+			// Check map  file.
+			if ( ! m_vModules.at(i)->MapFileExist() )
+				bRet = false;
+		}
+	}
+	#endif
+	// Platform winscw.
+	else if ( _stricmp( m_sPlatform.c_str(), "winscw" ) == 0 )
+	{
+		// Verify that module(s) binaries exist
+		for( size_t i = 0; i < m_vModules.size(); i++ )
+		{
+			if ( ! m_vModules.at(i)->BinaryFileExist() )
+				bRet = false;
+		}
+		// For static libraries binary/target is same as their library.
+		for ( size_t i = 0 ; i < m_vStaticLibraries.size(); i ++ )
+			if ( ! m_vStaticLibraries.at(i)->BinaryFileExist() )
+				bRet = false;
+	}
+	// Platform gcce.
+	else if ( _stricmp( m_sPlatform.c_str(), "gcce" ) == 0 )
+	{
+		// Verify that module(s) symbol file(s) exist
+		for( size_t i = 0; i < m_vModules.size(); i++ )
+		{
+			// Check symbol file.
+			if ( ! m_vModules.at(i)->SymbolFileExist() )
+				bRet = false;
+		}
+	}
+	return bRet;
+}
+
+// ----------------------------------------------------------------------------
+// Write project's (user) attributes to a file under temp folder
+// ----------------------------------------------------------------------------
+bool CATProject::WriteAttributes() const
+{
+	LOG_FUNC_ENTRY("CATProject::WriteAttributes");
+	// File to write to
+	string sOutFile( AT_TEMP_DIR );
+	sOutFile.append( "\\" );
+	sOutFile.append( AT_PROJECT_ATTRIBUTES_FILE_NAME );
+	// Open file truncate if exists
+	ofstream out( sOutFile.c_str(), ios_base::trunc );
+	// Check file opened successfully
+	if ( ! out.good() )
+		return false;
+	// Write attributes line by line
+	out << m_bUninstrumented << endl; // Is project instrumented
+	// Sbs version
+	if ( m_eBuildSystem == CATProject::SBS_V2 )
+		out << "SBS_2" << endl; 
+	else
+		out << "SBS_1" << endl;
+	out << endl; // Reserved for possible binary data
+	out << m_sPlatform << endl;
+	out << m_sVariant << endl;
+	out << m_eLoggingMode << endl;
+	out << m_eBuildType << endl;
+	out << m_sS60FileName << endl;
+	out << m_iAllocCallStackSize << endl;
+	out << m_iFreeCallStackSize << endl;
+	for ( size_t i = 0 ; i < m_vTargetModules.size() ; i++ )
+		out << m_vTargetModules.at(i) << AT_PROJECT_ATTRIBUTES_SEPARATOR;
+	out << endl;
+	out << m_sBuildCommand << endl;
+	out.close();
+	return true;
+}
+// ----------------------------------------------------------------------------
+// Reads project's (user) attributes to a file under temp folder
+// ----------------------------------------------------------------------------
+bool CATProject::ReadAttributes()
+{
+	LOG_FUNC_ENTRY("CATProject::ReadAttributes");
+	// File to read on
+	string sInFile( AT_TEMP_DIR );
+	sInFile.append( "\\" );
+	sInFile.append( AT_PROJECT_ATTRIBUTES_FILE_NAME );
+	// Open file
+	ifstream in( sInFile.c_str() );
+	// Check file opened successfully
+	if ( ! in.good() )
+		return false;
+	// Read attributes
+	char cLine[ MAX_LINE_LENGTH ];
+	string sLine;
+	in.getline( cLine, MAX_LINE_LENGTH );
+	int iValue = atoi( cLine );
+	if ( iValue == 1 )
+		m_bUninstrumented = true;
+	else
+		m_bUninstrumented = false;
+	// Sbs version
+	in.getline( cLine, MAX_LINE_LENGTH ); string sBuildSystem = string( cLine );
+	if ( sBuildSystem.compare( "SBS_1" ) == 0 )
+		m_eBuildSystem = CATProject::SBS_V1;
+	else if ( sBuildSystem.compare( "SBS_2" ) == 0 )
+		m_eBuildSystem = CATProject::SBS_V2;
+	else {
+		LOG_STRING("Error invalid build system defined in project.cfg");
+		m_eBuildSystem = CATProject::SBS_V1;
+	}
+	in.getline( cLine, MAX_LINE_LENGTH ); // reserverd for possible binary timestamp or similar
+	in.getline( cLine, MAX_LINE_LENGTH ); m_sPlatform = string( cLine );
+	in.getline( cLine, MAX_LINE_LENGTH ); m_sVariant = string( cLine );
+	in.getline( cLine, MAX_LINE_LENGTH ); m_eLoggingMode = atoi( cLine );
+	in.getline( cLine, MAX_LINE_LENGTH ); m_eBuildType = atoi( cLine );
+	in.getline( cLine, MAX_LINE_LENGTH ); m_sS60FileName = string( cLine );
+	in.getline( cLine, MAX_LINE_LENGTH ); m_iAllocCallStackSize = atoi( cLine );
+	in.getline( cLine, MAX_LINE_LENGTH ); m_iFreeCallStackSize = atoi( cLine );
+	in.getline( cLine, MAX_LINE_LENGTH ); sLine = cLine;
+	size_t iSpot = sLine.find( AT_PROJECT_ATTRIBUTES_SEPARATOR );
+	while ( iSpot != string::npos )
+	{
+		string sTarget = sLine.substr(0, iSpot );
+		m_vTargetModules.push_back( sTarget );
+		sLine.erase(0, iSpot + AT_PROJECT_ATTRIBUTES_SEPARATOR.size() );
+		iSpot = sLine.find( AT_PROJECT_ATTRIBUTES_SEPARATOR );
+	}
+	in.getline( cLine, MAX_LINE_LENGTH ); m_sBuildCommand = cLine;
+	in.close();
+	return true;
+}
+
+// ----------------------------------------------------------------------------
+// Creates atool_temp directory to current folder if does not exist
+// ----------------------------------------------------------------------------
+bool CATProject::MakeTempDirIfNotExist()
+{
+	LOG_FUNC_ENTRY("CATProject::MakeTempDirIfNotExist");
+	if ( ! DirectoryExists( AT_TEMP_DIR ) )
+	{
+		if( !CreateDirectory( AT_TEMP_DIR , NULL ) )
+		{
+			return false;
+		}
+	}
+	return true;
+}
+// ----------------------------------------------------------------------------
+// Utilities
+// ----------------------------------------------------------------------------
+
+bool CATProject::RunAbldCommandToAllTargets( const string& sCommand )
+{
+	LOG_FUNC_ENTRY("CATProject::RunAbldCommandToAllTargets");
+
+	// Check for space at the commands end.
+	string sSystemCall( sCommand );
+	if ( *(sSystemCall.rbegin()) != ' ' )
+		sSystemCall.append( " " );
+
+	// Loop calls.
+	bool bRet = true;
+	for ( vector<string>::iterator it = m_vTargetModules.begin(); it < m_vTargetModules.end(); it++ )
+	{
+		string sCall( sSystemCall );
+		sCall.append( RemovePathAndExt( *it, true ) );
+		cout << AT_MSG_SYSTEM_CALL << sCall << endl;
+		if ( (int) system( sCall.c_str() ) != 0 )
+			bRet = false;
+	}
+	return bRet;
+}
+
+void CATProject::AddTargetModuleIfDefined( string& sCmd )
+{
+	LOG_FUNC_ENTRY("CATProject::AddTargetModuleIfDefined");
+	// Do we have target modules defined
+	if ( m_vTargetModules.size() > 0 )
+	{
+		switch( m_eBuildSystem )
+		{
+		case SBS_V1:
+			// Add first target modules name without extension to build cmd.
+			sCmd.append( " " );
+			sCmd.append( RemovePathAndExt( m_vTargetModules.at( 0 ), true ) );
+			break;
+		case SBS_V2:
+			// Add all target modules to build command using raptor switch '-p'.
+			for( size_t i = 0 ; i < m_vTargetModules.size() ; i++ )
+			{
+				LOG_STRING("Adding :" << m_vTargetModules.at( i ) );
+				sCmd.append( " -p " );
+				sCmd.append( m_vTargetModules.at( i ) );
+			}
+			break;
+		}
+	}
+}
+
+bool CATProject::IsTargetModuleInProject() const
+{
+	LOG_FUNC_ENTRY("CATProject::IsTargetModuleInProject");
+	vector<CATModule2*>::const_iterator modules;
+	vector<CATModule2*>::const_iterator staticModules;
+	vector<string>::const_iterator targets;
+	bool bRet = true;
+	// Do we have target modules defined
+	if ( m_vTargetModules.size() > 0 )
+	{
+		// Sbs version 1 support only single target module.
+		if ( m_eBuildSystem == SBS_V1 )
+		{
+			// Try to find module from project.
+			bRet = false;
+			string sTarget = m_vTargetModules.at(0);
+			for( modules = m_vModules.begin() ; modules != m_vModules.end() ; modules++ )
+			{
+				if( (*modules)->GetMmpFile().find( sTarget ) != string::npos )
+				{
+					// Found it return true.
+					bRet = true;
+					break;
+				}
+			}
+			for( staticModules = m_vStaticLibraries.begin(); staticModules != m_vStaticLibraries.end(); staticModules++ )
+			{
+				if( (*staticModules)->GetMmpFile().find( sTarget ) != string::npos )
+				{
+					bRet = true;
+					break;
+				}
+			}
+			if ( ! bRet )
+			{
+				// Not found display error message.
+				cout << AT_MSG << "Error, " << sTarget << " not defined in project." << endl;
+			}
+		}
+		// Sbs version 2 supports multiple target modules.
+		else if ( m_eBuildSystem == SBS_V2 )
+		{
+			// Check that all targets are defined in project.
+			for( targets = m_vTargetModules.begin(); targets != m_vTargetModules.end() ; targets++ )
+			{
+				// Found iterated target?
+				bool bFound = false;
+				for ( modules = m_vModules.begin() ; modules != m_vModules.end() ; modules++ )
+				{
+					if( (*modules)->GetMmpFile().find( *targets ) != string::npos )
+					{
+						// yes.
+						bFound = true;
+						break;
+					}
+				}
+				for( staticModules = m_vStaticLibraries.begin(); staticModules != m_vStaticLibraries.end(); staticModules++ )
+				{
+					if( (*staticModules)->GetMmpFile().find( *targets ) != string::npos )
+					{
+						bFound = true;
+						break;
+					}
+				}
+				if ( ! bFound )
+				{
+					// Display error when not found and set return value false.
+					bRet = false;
+					cout << AT_MSG << "Error, " << targets->c_str() << " not defined in project." << endl;
+				}
+			}
+		}
+	}
+	return bRet;
+}
+
+string CATProject::GetBuildTypeString()
+{
+	LOG_LOW_FUNC_ENTRY("CATProject::GetBuildTypeString");
+	// Return build type as lowercase string
+	switch( m_eBuildType )
+	{
+	case BUILD_TYPE::UDEB:
+		return string("udeb");
+	case BUILD_TYPE::UREL:
+		return string("urel");
+	default:
+		return "";
+	}
+}
+
+string CATProject::GetBuildTypeString( int eType )
+{
+	LOG_LOW_FUNC_ENTRY("CATProject::GetBuildTypeString( int eType )");
+	// Return build type as lowercase string
+	switch( eType )
+	{
+	case BUILD_TYPE::UDEB:
+		return string("udeb");
+	case BUILD_TYPE::UREL:
+		return string("urel");
+	default:
+		return string("unknown");
+	}
+}
+
+bool CATProject::CleanTemporaryDirs()
+{
+	LOG_FUNC_ENTRY("CATProject::CleanTemporaryDirs");
+	bool bRet = true;
+	// Modules
+	for( size_t i = 0; i < m_vModules.size(); i++ )
+	{
+		if ( ! m_vModules.at(i)->CleanTemporaryDir() )
+			bRet = false;
+	}
+	for( size_t i = 0; i < m_vStaticLibraries.size(); i++ )
+	{
+		if ( ! m_vStaticLibraries.at(i)->CleanTemporaryDir() )
+			bRet = false;
+	}
+	// Projects
+	vector<string> vFileList = DirList( AT_TEMP_DIR, false , true );
+	vector<string>::iterator it2 = vFileList.begin();
+	// Size of constant table
+	int iCount = sizeof( TEMP_EXTENSION_NO_DELETE ) / sizeof( string );
+	while ( it2 != vFileList.end() )
+	{
+		// Get extension and compare it to list
+		bool bDelete = true;
+		string sExtension = GetExtension( *it2 );
+		ChangeToLower( sExtension );
+		for ( int i = 0 ; i < iCount ; i++ )
+		{
+			if( sExtension.compare( TEMP_EXTENSION_NO_DELETE[i] ) == 0 )
+			{
+				bDelete = false;
+				break;
+			}
+		}
+		if ( bDelete )
+		{
+			// Delete file
+			if ( ! FileDelete( *it2, true ) )
+				bRet = false;
+		}
+		// Increment
+		it2++;
+	}
+	return bRet;
+}
+
+bool CATProject::DeleteTemporaryDirs()
+{
+	LOG_FUNC_ENTRY("CATProject::DeleteTemporaryDirs");
+	bool bRet = true;
+	// Modules
+	for( size_t i = 0; i < m_vModules.size(); i++ )
+	{
+		if (! m_vModules.at(i)->DeleteTemporaryDir() )
+			bRet = false;
+	}
+	for( size_t i = 0; i < m_vStaticLibraries.size(); i++ )
+	{
+		if (! m_vStaticLibraries.at(i)->DeleteTemporaryDir() )
+			bRet = false;
+	}
+	return bRet;
+}
+
+bool CATProject::InitSbs1MakeFileWithPathToTemp()
+{
+	LOG_FUNC_ENTRY("CATProject::InitSbs1MakeFileWithPathToTemp");
+	// Use temporary folder
+	m_sMakeFile.clear();
+	m_sMakeFile.append( AT_TEMP_DIR );
+	m_sMakeFile.append( "\\" );
+	m_sMakeFile.append( AT_LEVEL_1_MAKEFILE_NAME );
+	// At end check does it exist, return the result.
+	return FileExists( m_sMakeFile.c_str() );
+}
+
+bool CATProject::InitSbs1MakeFileWithPath()
+{
+	LOG_FUNC_ENTRY("CATProject::InitMakeFileWithPath");
+	if ( m_sEpocRoot.empty() )
+	{
+		LOG_STRING("Error, epocroot is not set.");
+		return false;
+	}
+	m_sMakeFile.clear();
+	m_sMakeFile.append( m_sEpocRoot );
+	if( *m_sMakeFile.rbegin() != '\\' )
+		m_sMakeFile.append( "\\" );
+	m_sMakeFile.append( "epoc32\\build\\" );
+	// Add current directory to path (first remove driveletter).
+	string sCurrentDir( m_cCurrentDir );
+	if ( sCurrentDir.length() < 3 )
+	{
+		LOG_STRING("Error, current dir invalid.");
+		return false;
+	}
+	sCurrentDir.erase(0,3);
+	m_sMakeFile.append( sCurrentDir );
+	m_sMakeFile.append( "\\" );
+	// Platform
+	string sPlatInUpper( m_sPlatform);
+	ChangeToUpper( sPlatInUpper );
+	m_sMakeFile.append( sPlatInUpper );
+	// Possible variant
+	m_sMakeFile.append( "." );
+	if ( m_sVariant.empty() )
+	{
+		m_sMakeFile.append( "MAKE" );
+	}
+	else
+	{
+		m_sMakeFile.append( m_sVariant );
+		m_sMakeFile.append( ".MAKE" );
+	}
+	// At end check does it exist, return the result.
+	return FileExists( m_sMakeFile.c_str() );
+}
+
+// ----------------------------------------------------------------------------
+// Get & Sets
+// ----------------------------------------------------------------------------
+void CATProject::SetBuildSystem( BUILD_SYSTEM eSystem )
+{
+	LOG_FUNC_ENTRY("CATProject::SetBuildSystem");
+	m_eBuildSystem = eSystem;
+}
+void CATProject::SetMode( PROJECT_MODE eMode )
+{
+	LOG_FUNC_ENTRY("CATProject::SetMode");
+	m_eMode = eMode;
+}
+int CATProject::GetMode() const
+{
+	LOG_LOW_FUNC_ENTRY("CATProject::GetMode");
+	return m_eMode;
+}
+void CATProject::SetEpocRoot( const string& sEpocRoot )
+{
+	LOG_FUNC_ENTRY("CATProject::SetEpocRoot");
+	m_sEpocRoot = sEpocRoot;
+}
+void CATProject::SetPlatform( const string& sPlatform )
+{
+	LOG_FUNC_ENTRY("CATProject::SetPlatform");
+	m_sPlatform = sPlatform;
+}
+void CATProject::SetVariant( const string& sVariant )
+{
+	LOG_FUNC_ENTRY("CATProject::SetVariant");
+	m_sVariant = sVariant;
+}
+void CATProject::SetLoggingMode( LOGGING_MODE eLoggingMode)
+{
+	LOG_FUNC_ENTRY("CATProject::SetLoggingMode");
+	m_eLoggingMode = eLoggingMode;
+}
+void CATProject::SetAllocCallStackSize( int iAllocCallStackSize )
+{
+	m_iAllocCallStackSize = iAllocCallStackSize;
+}
+void CATProject::SetFreeCallStackSize( int iFreeCallStackSize )
+{
+	m_iFreeCallStackSize = iFreeCallStackSize;
+}
+void CATProject::SetBuildType( BUILD_TYPE eType )
+{
+	LOG_FUNC_ENTRY("CATProject::SetBuildType");
+	m_eBuildType = eType;
+}
+void CATProject::SetS60FileName( const string& sFileName)
+{
+	LOG_FUNC_ENTRY("CATProject::SetS60FileName");
+	m_sS60FileName = sFileName;
+}
+void CATProject::SetRomSymbolFiles(const vector<string>& vRomSymbolFiles)
+{
+	LOG_FUNC_ENTRY("CATProject::SetRomSymbolFiles");
+	m_vRomSymbolFiles = vRomSymbolFiles;
+}
+void CATProject::SetTargetModule(const string& sTargetModule)
+{
+	LOG_FUNC_ENTRY("CATProject::SetTargetModule");
+	m_sTargetModule = sTargetModule;
+	ChangeToLower( m_sTargetModule);
+}
+void CATProject::SetBinaryTarget(const string& sBinaryTarget)
+{
+	LOG_FUNC_ENTRY("CATProject::SetBinaryTarget");
+	m_sBinaryTarget = sBinaryTarget;
+	ChangeToLower( m_sBinaryTarget );
+}
+void CATProject::SetDataFile( const string& sDataFile )
+{
+	LOG_FUNC_ENTRY("CATProject::SetDataFile");
+	m_sDataFile = sDataFile;
+}
+void CATProject::SetLogLevel( int iLogLevel )
+{
+	LOG_FUNC_ENTRY("CATProject::SetLogLevel");
+	m_iLoggingLevel = iLogLevel;
+}
+void CATProject::SetDataFileOutput( const string& sDataFileOutput )
+{
+	LOG_FUNC_ENTRY("CATProject::SetDataFileOutput");
+	m_sDataFileOutput = sDataFileOutput;
+}
+void CATProject::SetTargetModules( const vector<string>& vTargetModules )
+{
+	LOG_FUNC_ENTRY("CATProject::SetTargetModules");
+	m_vTargetModules = vTargetModules;
+}
+void CATProject::SetBuildCommand( const string& sBuildCommand )
+{
+	LOG_FUNC_ENTRY("CATProject::SetBuildCommand");
+	m_sBuildCommand = sBuildCommand;
+}
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/arguments.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,947 @@
+/*
+* 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:  Argument parsing functions.
+*/
+#include "../inc/ATCommonDefines.h"
+#include "../inc/CATBase.h"
+
+//Forward declarations.
+bool parseBaseArguments( vector<string>& vArgs, ARGUMENTS& args );
+bool parseHookArguments( vector<string>& vArgs, ARGUMENTS& args );
+bool parseOldHookArguments( vector<string>& vArgs, ARGUMENTS& args );
+bool parseAnalyzeArguments( vector<string>& vArgs, ARGUMENTS& args );
+bool parseHtiArguments( vector<string>& vArgs, ARGUMENTS& args );
+bool parseParseArguments( vector<string>& vArgs, ARGUMENTS& args );
+bool checkDataFileName( string& sFileName );
+
+// Constants for old "hooking" parameter parsing.
+#define INVALID_PARAMETER "AnalyzeTool : Error, invalid parameter: "
+const char LOG_S60[] = "s60";
+const char LOG_XTI[] = "xti";
+const char DATAFILENAME_INVALID_CHARS[] = " &^+-@$%*()|\\/[]{}<>?;:,\"'";
+
+/**
+* Check datafile name for invalid characters.
+* @return true if file name ok.
+*/
+bool checkDataFileName( string& sFileName )
+{
+	for ( size_t i = 0; i < sFileName.length(); i++ )
+	{
+		const char c = sFileName.at( i );
+		if( strchr( DATAFILENAME_INVALID_CHARS, c ) != 0 )
+			return false;
+	}
+	return true;
+}
+
+/**
+* Parse base arguments from given vector of strings.
+* Removes debug / help arguments from vector.
+*/
+bool parseBaseArguments( vector<string>& vArgs, ARGUMENTS& args )
+{
+	// Iterator used in this function.
+	vector<string>::iterator it;
+	// If no arguments set show help true.
+ 	if ( vArgs.size() == 0 )
+	{
+		args.eMainSwitch = SWITCH_UNKNOWN;
+		args.bHelp = true;
+	}
+	//Try find help and debug switches.
+	//Note: -help is main switch what shows syntax examples.
+	for(it = vArgs.begin(); it != vArgs.end(); it++ )
+	{
+		//Help switches.
+		if ( ! _stricmp( (*it).c_str(), "-?" ) )
+		{
+			args.bHelp = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "--?" ) )
+		{
+			args.bHelp = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "--help" ) )
+		{
+			args.bHelp = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "/?" ) )
+		{
+			args.bHelp = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		//Debug switches.
+		else if ( ! _stricmp( (*it).c_str(), "-show_debug" ) )
+		{
+			args.bDebugConsole = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "--show_debug" ) )
+		{
+			args.bDebugConsole = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-show_debug_all" ) )
+		{
+			args.bDebugConsole = true;
+			args.bDebugLowLevel = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "--show_debug_all" ) )
+		{
+			args.bDebugConsole = true;
+			args.bDebugLowLevel = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-show_dbgview" ) )
+		{
+			args.bDebugDbgView = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "--show_dbgview" ) )
+		{
+			args.bDebugDbgView = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-show_dbgview_all" ) )
+		{
+			args.bDebugDbgView = true;
+			args.bDebugLowLevel = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "--show_dbgview_all" ) )
+		{
+			args.bDebugDbgView = true;
+			args.bDebugLowLevel = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+		//Raptor switch.
+		else if ( ! _stricmp( (*it).c_str(), "-sbs2" ) )
+		{
+			args.bEnableSbs2 = true;
+			it = vArgs.erase( it );
+			if ( it == vArgs.end() )
+				break;
+		}
+	}
+	if ( vArgs.size() > 0 )
+	{
+		//Pick up main switch.
+		it = vArgs.begin();
+		if ( ! _stricmp( (*it).c_str(), "-a" ) )
+			args.eMainSwitch = SWITCH_ANALYZE;
+		else if ( ! _stricmp( (*it).c_str(), "-p" ) )
+			args.eMainSwitch = SWITCH_PARSE_TRACE;
+		else if ( ! _stricmp( (*it).c_str(), "-c" ) )
+			args.eMainSwitch = SWITCH_CLEAN;
+		else if ( ! _stricmp( (*it).c_str(), "-g" ) )
+			args.eMainSwitch = SWITCH_HTI_GET;
+		else if ( ! _stricmp( (*it).c_str(), "-delete" ) )
+			args.eMainSwitch = SWITCH_HTI_DELETE;
+		else if ( ! _stricmp( (*it).c_str(), "-v" ) )
+			args.eMainSwitch = SWITCH_VERSION;
+		else if ( ! _stricmp( (*it).c_str(), "-help" ) )
+			args.eMainSwitch = SWITCH_HELP;
+		else if ( ! _stricmp( (*it).c_str(), "-me" ) )
+		{
+			args.eMainSwitch = SWITCH_HOOK;
+			args.eHookSwitch = HOOK_EXTERNAL;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-e" ) )
+		{
+			args.eMainSwitch = SWITCH_HOOK;
+			args.eHookSwitch = HOOK_EXTERNAL_FAST;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-mi" ) )
+		{
+			args.eMainSwitch = SWITCH_HOOK;
+			args.eHookSwitch = HOOK_INTERNAL;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-instrument_i" ) )
+		{
+			args.eMainSwitch = SWITCH_HOOK;
+			args.eHookSwitch = HOOK_EXTENSION_INTERNAL;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-instrument_e" ) )
+		{
+			args.eMainSwitch = SWITCH_HOOK;
+			args.eHookSwitch = HOOK_EXTENSION_EXTERNAL;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-instrument_ef" ) )
+		{
+			args.eMainSwitch = SWITCH_HOOK;
+			args.eHookSwitch = HOOK_EXTENSION_EXTERNAL_FAST;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-uninstrument" ) )
+		{
+			args.eMainSwitch = SWITCH_UNHOOK;
+			args.eHookSwitch = HOOK_EXTENSION_UNINSTRUMENT;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-uninstrument_failed" ) )
+		{
+			args.eMainSwitch = SWITCH_UNHOOK;
+			args.eHookSwitch = HOOK_EXTENSION_FAILED;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-inst" ) )
+		{
+			args.eMainSwitch = SWITCH_OLD_HOOK;
+			args.eHookSwitch = HOOK_OLD_EXTENSION_INSTRUMENT;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-uninst" ) )
+		{
+			args.eMainSwitch = SWITCH_OLD_HOOK;
+			args.eHookSwitch = HOOK_OLD_EXTENSION_UNINSTRUMENT;
+		}
+		else if ( ! _stricmp( (*it).c_str(), "-uninst_failed" ) )
+		{
+			args.eMainSwitch = SWITCH_OLD_HOOK;
+			args.eHookSwitch = HOOK_OLD_EXTENSION_FAILED;
+		}
+	}
+	return true;
+}
+
+/**
+* Parse analyze related arguments from given vector of strings.
+*/
+bool parseAnalyzeArguments( vector<string>& vArgs, ARGUMENTS& args )
+{
+	bool bRet = true;
+	if ( vArgs.size() < 2 )
+	{
+		cout << AT_MSG << "Error, missing datafile." << endl;
+		return false;
+	}
+	// Iterator used in this function.
+	vector<string>::const_iterator it;
+	for(it = vArgs.begin()+1; it != vArgs.end(); it++ )
+	{
+		if ( it->find("-l") != string::npos )
+		{
+			if ( it->length() == 3 )
+			{
+				// Create char array for atoi function
+				char level[2];
+				level[0] = it->at(2);
+				level[1] = 0; // null terminate
+				// check that its digit first
+				if ( isdigit(level[0]) )
+				{
+					// pass array to atoi
+					int iLoggingLevel = atoi( level );
+					if ( iLoggingLevel >= 0 && iLoggingLevel <= 3 )
+					{
+						// log level ok
+						args.ANALYZE.iLoggingLevel = iLoggingLevel;
+						continue;
+					}
+				}
+				bRet = false;
+				cout << AT_MSG << "Invalid logging level specified (0-3)." << endl;
+				args.ANALYZE.iLoggingLevel = -1;
+			}
+		}
+		// No else here because logging level check is done to all args in list.
+		// Rom symbol file
+		if( _stricmp( it->c_str(), "-s" ) == 0 )
+		{
+			it++;
+			if ( it == vArgs.end() )
+			{
+				bRet = false;
+				cout << AT_MSG << "Missing symbol file." << endl;
+				break; // Leave for loop.
+			}
+			else
+			{
+				args.ANALYZE.bSymbolFile = true;
+				args.ANALYZE.vSymbolFiles.push_back( *it );
+				continue;
+			}
+		}
+		else 
+		{
+			// If we got datafile we must assume this is output
+			if( ! args.ANALYZE.sDataFile.empty() )
+			{
+				if ( args.ANALYZE.sOutputFile.empty() )
+					args.ANALYZE.sOutputFile = *it;
+				else
+				{
+					bRet = false;
+					cout << AT_MSG << "Invalid parameter: " << *it << endl;
+				}
+			}
+			// If this is file we assume datafile
+			else if( CATBase::FileExists( it->c_str() ) )
+			{
+				args.ANALYZE.sDataFile = *it;
+			}
+			else
+			{
+				bRet = false;
+				cout << AT_MSG << "Specified datafile does not exist." << endl;
+			}
+		}
+	}
+	if ( args.ANALYZE.sDataFile.empty() )
+		bRet = false;
+	return bRet;
+}
+
+
+/**
+* Parse hooking related arguments from given vector of strings.
+*/
+bool parseHookArguments( vector<string>& vArgs, ARGUMENTS& args )
+{
+	bool bRet = true;
+	try {
+		// Iterator used in this function.
+		vector<string>::const_iterator it;
+
+		// Check that we have some arguments except main switch.
+		if ( vArgs.size() < 2 )
+		{
+			if ( args.eHookSwitch == HOOK_EXTENSION_UNINSTRUMENT
+				|| args.eHookSwitch == HOOK_EXTENSION_FAILED
+				)
+				return bRet;
+			cout << AT_MSG << "Error, Missing build command." << endl;
+			bRet = false;
+		}
+		bool bBuildFound = false;
+		for(it = vArgs.begin()+1; it != vArgs.end(); it++ )
+		{
+			// If's to pickup atool options
+			// no build switch
+			if ( _stricmp( it->c_str(), "-nobuild" ) == 0 )
+			{
+				args.HOOK.bNoBuild = true;
+			}
+			// call stack size(s)
+			else if ( _stricmp( it->c_str(), "-acs" ) == 0 || _stricmp( it->c_str(), "-fcs" ) == 0 )
+			{
+				// Free vs Alloc
+				bool bAlloc = true;
+				if ( _stricmp( it->c_str(), "-fcs" ) == 0 )
+					bAlloc = false;
+				// Value
+				it++;
+				if ( it== vArgs.end() )
+				{
+					bRet = false;
+					cout << AT_MSG << "Error, missing call stack size parameter." << endl;
+					break;
+				}
+				else if ( ! _stricmp( it->c_str(), "sbs" ) 
+					|| ! _stricmp( it->c_str(), "abld" )
+					|| ! _stricmp( it->c_str(), "-f" ) )
+				{
+					bRet = false;
+					cout << AT_MSG << "Error, missing call stack size parameter." << endl;
+					break;
+				}
+				else
+				{
+					int i;
+					// Try to parse integer value using stream.
+					istringstream ss( *it );
+					if ( ss>>i )
+					{
+						// Value parsed ok now check bounds.
+						if ( i < AT_CALL_STACK_SIZE_MIN  )
+						{
+							bRet = false;
+							cout << AT_MSG << "Error, specified call stack size value too small." << endl;
+							break;
+						}
+						else if ( i > AT_CALL_STACK_SIZE_MAX )
+						{
+							bRet = false;
+							cout << AT_MSG << "Error, specified call stack size value too big." << endl;
+							break;
+						}
+						else
+						{
+							// Value valid.
+							if ( bAlloc )
+								args.HOOK.iAllocCallStackSize = i;
+							else
+								args.HOOK.iFreeCallStackSize = i;
+						}
+					}
+					else
+					{
+						// Error parsing value using stream.
+						bRet = false;
+						cout << AT_MSG << "Error, specified call stack size value invalid." << endl;
+						break;
+					}
+
+				}
+			}
+			// Data file name.
+			else if ( _stricmp( it->c_str(), "-f" ) == 0 )
+			{
+				it++;
+				if ( it == vArgs.end() )
+				{
+					bRet = false;
+					cout << AT_MSG << "Error, missing internal data gathering 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;
+					break;
+				}
+				else
+				{
+					if ( checkDataFileName( string( *it ) ) )
+					{
+						// Pickup filename.
+						args.HOOK.bDataFileName = true;
+						args.HOOK.sDataFileName = *it;
+					}
+					else
+					{
+						bRet = false;
+						cout << AT_MSG << "Error, specified internal data gathering file name contains invalid character(s)." << endl;
+						break;
+					}
+				}
+			}
+			// Build command parsing.
+			else if ( _stricmp( it->c_str(), "sbs" ) == 0 )
+			{
+				bBuildFound = true;
+				// Use raptor build system, pickup all rest arguments to sbs commmand.
+				bool bFoundConfig = false; // Have we found config already?
+				args.HOOK.iBuildSystem = 2;
+				vector<string>::const_iterator itC = it;
+				args.HOOK.sBuildCmd.clear();
+				for ( ; itC != vArgs.end() ; itC++ )
+				{
+					args.HOOK.sBuildCmd.append( *itC );
+					args.HOOK.sBuildCmd.append( " " );
+					args.HOOK.vBuildCmd.push_back( *itC );
+				}
+				// Remove last space
+				if ( args.HOOK.vBuildCmd.size() > 1 )
+					args.HOOK.sBuildCmd.erase( args.HOOK.sBuildCmd.size()-1 );
+
+				// Parse needed variables from sbs command.
+				vector<string>::iterator itSbs;
+				for( itSbs = args.HOOK.vBuildCmd.begin(); itSbs != args.HOOK.vBuildCmd.end() ; itSbs++ )
+				{
+					// Program(s).
+					if ( _stricmp( itSbs->c_str(), "-p" ) == 0 )
+					{
+						// Next is program.
+						itSbs++;
+						args.HOOK.vTargetPrograms.push_back( *itSbs );
+					}
+					else if ( itSbs->find( "--project=" ) != string::npos )
+					{
+						itSbs->erase(0, 10 );
+						args.HOOK.vTargetPrograms.push_back( *itSbs );
+					}
+					// platform & build type
+					else if ( _stricmp( itSbs->c_str(), "-c" ) == 0 )
+					{
+						itSbs++;
+
+						// Error message if config found more than once.
+						if ( bFoundConfig )
+						{
+							bRet = false;
+							cout << AT_MSG << "Error, AnalyzeTool does not support defining more than one configuration (platform & build type)." << endl;
+							continue;
+						}
+						bFoundConfig = true;
+
+						// Check for '_' which separates platform and type.
+						if ( itSbs->find("_") != string::npos )
+						{
+							args.HOOK.sPlatform = itSbs->substr(0, itSbs->find("_") );
+							args.HOOK.sBuildType = itSbs->substr( itSbs->find("_")+1, itSbs->size()- itSbs->find("_")+1 );
+						}
+						else
+							args.HOOK.sPlatform = *itSbs;
+					}
+					else if ( itSbs->find( "--config=" ) != string::npos )
+					{
+						// Error message if config found more than once.
+						if ( bFoundConfig )
+						{
+							bRet = false;
+							cout << AT_MSG << "Error, AnalyzeTool does not support defining more than one configuration (platform & build type)." << endl;
+							continue;
+						}
+						bFoundConfig = true;
+
+						itSbs->erase( 0, 9 );
+						// Check for '_' which separates platform and type.
+						if ( itSbs->find("_") != string::npos )
+						{
+							args.HOOK.sPlatform = itSbs->substr(0, itSbs->find("_") );
+							args.HOOK.sBuildType = itSbs->substr( itSbs->find("_")+1, itSbs->size()- itSbs->find("_")+1 );
+						}
+						else
+							args.HOOK.sPlatform = *itSbs;
+					}
+				}
+				// Check platform and build type
+				if ( args.HOOK.sPlatform.empty() )
+				{					
+					// not platform was found.
+					cout << AT_MSG << "Error, no supported platform found in sbs parameters (armv5/winscw/gcce)." << endl;
+					bRet = false;
+				}
+				else
+				{
+					// check is platform supported.
+					bool bOk = false;
+					if ( _stricmp( args.HOOK.sPlatform.c_str(), "armv5" ) == 0 )
+						bOk = true;
+					else if ( _stricmp( args.HOOK.sPlatform.c_str(), "winscw" ) == 0 )
+						bOk = true;
+					else if ( _stricmp( args.HOOK.sPlatform.c_str(), "gcce" ) == 0 )
+						bOk = true;
+					if ( ! bOk )
+					{
+						// not supported.
+						cout << AT_MSG << "Error, no supported platform found in sbs parameters (armv5/winscw/gcce)." << endl;
+						bRet = false;
+					}
+				}
+				if ( args.HOOK.sBuildType.empty() )
+				{
+					// no build type specified.
+					cout << AT_MSG << "Error, no build type specified in sbs parameters (udeb/urel)." << endl;
+					bRet = false;
+				}
+				else
+				{
+					// check is build type supported.
+					bool bOk = false;
+					if ( _stricmp( args.HOOK.sBuildType.c_str(), "urel" ) == 0 )
+						bOk = true;
+					else if ( _stricmp( args.HOOK.sBuildType.c_str(), "udeb" ) == 0 )
+						bOk = true;
+					if ( ! bOk )
+					{
+						// not supported.
+						cout << AT_MSG << "Error, no build type specified in sbs parameters (udeb/urel)." << endl;
+						bRet = false;
+					}
+				}
+			}
+			else if ( _stricmp( it->c_str(), "abld" ) == 0 )
+			{
+				bBuildFound = true;
+				// Use abld build system, pickup all rest argumenst as abld options.
+				args.HOOK.iBuildSystem = 1;
+				
+				vector<string>::const_iterator itC = it;
+				args.HOOK.sBuildCmd.clear();
+				for ( ; itC != vArgs.end() ; itC++ )
+				{
+					args.HOOK.sBuildCmd.append( *itC );
+					args.HOOK.sBuildCmd.append( " " );
+					args.HOOK.vBuildCmd.push_back( *itC );
+				}
+				
+				string sCmd( args.HOOK.sBuildCmd ); // build command to lower case here.
+				for( size_t i = 0 ; i < sCmd.size(); i++ )
+					sCmd.at(i) = tolower( sCmd.at(i) );
+				
+				sCmd.erase(0,11); // remove "abld build "
+				
+				//Is -debug switch in command?
+				if( sCmd.find( "-debug " ) != string::npos )
+				{
+					sCmd.erase( sCmd.find( "-debug " ), 7 );
+				}
+
+				// Parse needed "variables" from command.
+				bool bOk = false;
+
+				// Find platform
+				if ( sCmd.find( "armv5" ) != string::npos )
+				{
+					bOk = true;
+					args.HOOK.sPlatform = "armv5";
+					sCmd.erase( sCmd.find( "armv5" ), 5 );
+				}
+				else if ( sCmd.find( "winscw" ) != string::npos )
+				{
+					bOk = true;
+					args.HOOK.sPlatform = "winscw";
+					sCmd.erase( sCmd.find( "winscw" ), 6 );
+				}
+				else if ( sCmd.find( "gcce" ) != string::npos )
+				{
+					bOk = true;
+					args.HOOK.sPlatform = "gcce";
+					sCmd.erase( sCmd.find( "gcce" ), 4 );
+				}
+				if ( bOk )
+				{
+					// Feature variant.
+					if ( sCmd.at(0 ) == '.' )
+					{
+						sCmd.erase(0,1);
+						args.HOOK.sFeatureVariant = sCmd.substr( 0, sCmd.find_first_of(' ') );
+						sCmd.erase(0, sCmd.find_first_of(' ')+1 );
+					}
+				}
+				else
+				{
+					// not platform specified.
+					cout << AT_MSG << "Error, no supported platform found in abld parameters (armv5/winscw/gcce)." << endl;
+					bRet = false;
+				}
+				
+				// find build type
+				bOk = false;
+				if (  sCmd.find( "urel" ) != string::npos )
+				{
+					bOk = true;
+					args.HOOK.sBuildType = "urel";
+					sCmd.erase( sCmd.find( "urel" ), 4 );
+				}
+
+				else if ( sCmd.find( "udeb" ) != string::npos )
+				{
+					bOk = true;
+					args.HOOK.sBuildType = "udeb";
+					sCmd.erase( sCmd.find( "udeb" ), 4 );
+				}
+				if( !bOk )
+				{
+					// no build type specified.
+					cout << AT_MSG << "Error, no build type specified in abld parameters (udeb/urel)." << endl;
+					bRet = false;
+				}
+		
+				// Is there multiple programs (only should be used from extension).
+				if ( sCmd.find(" -p") != string::npos )
+				{
+					sCmd.erase( sCmd.find(" -p" ), sCmd.size() - sCmd.find(" -p" ) );
+					// Loop thru all parameters and pick up programs.
+					vector<string>::iterator it;
+					for( it = args.HOOK.vBuildCmd.begin(); it != args.HOOK.vBuildCmd.end(); it++ )
+					{
+						if ( _stricmp( it->c_str(), "-p" ) == 0 )
+						{
+							// Next is program.
+							it++;
+							string sProgram = *it;
+							// Make sure program name ends with ".mmp".
+							CATBase::ChangeToLower( sProgram );
+							if ( sProgram.length() >= 4 )
+							{
+                                string sEnd = sProgram.substr( sProgram.length()-4, 4 );
+								if ( sEnd.compare( ".mmp" ) != 0 )
+									sProgram.append( ".mmp" );
+							}
+							else
+								sProgram.append( ".mmp" );
+							args.HOOK.vTargetPrograms.push_back( sProgram );
+						}
+					}
+				}
+				else {
+					// find single defined program.
+					if ( sCmd.find_first_not_of(' ') != string::npos )
+					{
+						size_t iS = sCmd.find_first_not_of(' ');
+						size_t iE = sCmd.find_first_of(' ', iS );
+						string sProgram;
+						if ( iE == string::npos )
+							sProgram = sCmd.substr( iS, sCmd.size()-iS );
+						else
+							sProgram =  sCmd.substr( iS, iE-iS);
+						// Make sure program name ends with ".mmp".
+						CATBase::ChangeToLower( sProgram );
+						if ( sProgram.length() >= 4 )
+						{
+                            string sEnd = sProgram.substr( sProgram.length()-4, 4 );
+							if ( sEnd.compare( ".mmp" ) != 0 )
+								sProgram.append( ".mmp" );
+						}
+						else
+							sProgram.append( ".mmp" );
+						args.HOOK.vTargetPrograms.push_back( sProgram );
+					}
+				}
+			}
+			else
+			{
+				if ( ! bBuildFound )
+				{
+					bRet = false;
+					cout << AT_MSG << "Error, invalid parameter :" << *it << endl;
+					break;
+				}
+			}
+		}
+	}
+	catch(...)
+	{
+		bRet = false;
+		cout << AT_MSG << "Error parsing arguments." << endl;
+	}
+	return bRet;
+}
+
+
+/**
+* Parse old style hooking related arguments from given vector of strings.
+*/
+bool parseOldHookArguments( vector<string>& vArgs, ARGUMENTS& args )
+{
+	// Only supporting extension here atm.
+	// This is frozen do not change anything in this else if.
+	bool bRet = true;
+	vector<string>::iterator it = vArgs.begin()+1;
+	string sMmpFileName;
+	string sPhoneDataFileName;
+	vector<string> vMmpFileNames;
+	string sVariant;
+	bool bBuildUdeb = true;
+	bool bLogTargetS60 = false;
+	bool bLogTargetXTI = false;
+	bool bPhoneDataFileName = false;
+	bool bMmpFileName = false;
+	bool bVariant = false;
+	bool bEmulator = false;
+	bool bGcce = false;
+
+	while( it != vArgs.end() )
+	{
+		string sArgument( *it );
+		CATBase::ChangeToLower( sArgument );
+		//Mmp filename given?
+		if( sArgument.find( ".mmp" ) != string::npos )
+		{
+			if( bMmpFileName && ! args.bEnableSbs2 )
+			{
+				cout<<INVALID_PARAMETER<<*it<<"."<<endl;
+				return 0;
+			}
+			sMmpFileName = *it;
+			vMmpFileNames.push_back( *it );
+			bMmpFileName = true;
+		}
+		else
+		//Logging mode XTI?
+		if( stricmp( sArgument.c_str(), LOG_XTI ) == 0 )
+		{
+			if ( bLogTargetS60 )
+			{
+				cout<<INVALID_PARAMETER<<*it<<"."<<endl;
+				return 0;
+			}
+			bLogTargetXTI = true;
+		}
+		else
+		//Logging mode S60?
+		if( stricmp( sArgument.c_str(), LOG_S60 ) == 0 )
+		{
+			if ( bLogTargetXTI )
+			{
+				cout<<INVALID_PARAMETER<<*it<<"."<<endl;
+				return 0;
+			}
+			bLogTargetS60 = true;
+		}
+		else
+		//Variant
+		//if( sArgument.find( "-variant" ) != string::npos )
+		if( stricmp( sArgument.c_str(), "-variant") == 0 )
+		{
+			// use variant
+			bVariant = true;
+			// pickup variant name
+			it++;
+			if ( it == vArgs.end() )
+			{
+				cout << "When using -variant, variant name must be specified." << endl;
+				return 0;
+			}
+			sVariant.append( *it );
+		}
+		else
+		//Build urel?
+		if( stricmp( sArgument.c_str(), "urel" ) == 0 )
+		{
+			bBuildUdeb = false;
+		}
+		else
+		//Build udeb?
+		//if( sArgument.find( "udeb" ) != string::npos && sArgument.length() == 4)
+		if( stricmp( sArgument.c_str(), "udeb" ) == 0 )
+		{
+			bBuildUdeb = true;
+		}
+		else
+		//Build for emulator
+		if( stricmp( sArgument.c_str(), "-e" ) == 0 || stricmp( sArgument.c_str(), "-winscw") == 0 )
+		{
+			bEmulator = true;
+		}
+		else
+		if( stricmp( sArgument.c_str(), "-gcce") == 0 )
+		{
+			bGcce = true;
+		}
+		else
+		//Assume its data file name
+		if( bLogTargetS60 )
+		{
+			if ( bPhoneDataFileName )
+			{
+				cout<<INVALID_PARAMETER<<*it<<"."<<endl;
+				bRet = false;
+			}
+			// Check that datafile name is <= 50 chars long
+			if ( sArgument.size() > 50 )
+			{
+				cout << AT_MSG << "Error, specified datafile name too long (Max 50 chars)." << endl;
+				bRet = false;
+			}
+			sPhoneDataFileName = sArgument;
+			bPhoneDataFileName = true;
+		}
+		// unregognized build parameter
+		else
+		{
+			// print error and exit 
+			cout<<INVALID_PARAMETER<<*it<<"."<<endl;
+			bRet = false;
+		}
+		it++;
+	}
+	// platform
+	if ( bEmulator )
+		args.HOOK.sPlatform = "winscw";
+	else
+		args.HOOK.sPlatform = "armv5";
+	if ( bGcce )
+		args.HOOK.sPlatform = "gcce";
+	// build type
+	if ( bBuildUdeb )
+		args.HOOK.sBuildType = "udeb";
+	else
+		args.HOOK.sBuildType = "urel";
+	// Variant
+	if ( bVariant )
+		args.HOOK.sFeatureVariant = sVariant;
+	if ( ! bLogTargetS60 && ! bLogTargetXTI )
+		args.HOOK.iLoggingMode = 1;
+	if ( bLogTargetS60 )
+		args.HOOK.iLoggingMode = 2;
+	else if ( bLogTargetXTI )
+		args.HOOK.iLoggingMode = 1;
+	// If selected modules to be compiled
+	if ( vMmpFileNames.size() > 0 )
+		args.HOOK.vTargetPrograms = vMmpFileNames;
+	// S60 data file name
+	if ( ! sPhoneDataFileName.empty() )
+	{
+		args.HOOK.bDataFileName = true;
+		args.HOOK.sDataFileName = sPhoneDataFileName;
+	}
+	return bRet;
+}
+
+/**
+* Parse HTI related arguments from given vector of strings.
+*/
+bool parseHtiArguments( vector<string>& /* vArgs */, ARGUMENTS& /* args*/)
+{
+	//Implementation currently in hti.cpp, should be moved here.
+	return false;
+}
+
+/**
+* Parse trace parsing related arguments from given vector of strings.
+*/
+bool parseParseArguments( vector<string>& vArgs, ARGUMENTS& args )
+{
+	// Iterator used in this function.
+	vector<string>::const_iterator it = vArgs.begin();
+
+	if ( it == vArgs.end() )
+		return false;
+
+	it++;
+
+	if ( it == vArgs.end() )
+	{
+		cout << AT_MSG << "Error, input file not defined (raw data file)." << endl;
+		return false;
+	}
+
+	//Input.
+	args.PARSE.bDataFile = true;
+	args.PARSE.sDataFile = *it;
+	
+	it++;
+	if ( it == vArgs.end() )
+	{
+	
+		cout << AT_MSG << "Error, output file not defined (device data file)." << endl;
+		return false;
+	}
+
+	//Output.
+	args.PARSE.bOutputFile = true;
+	args.PARSE.sOutputFile = *it;
+	return true;
+}
+
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/atool.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,330 @@
+/*
+* 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:  Defines the entry point for the console application.
+*
+*/
+
+// Includes.
+#include "../inc/ATCommonDefines.h"
+#include "../inc/CATDatParser.h"
+#include "../inc/CATParseTraceFile.h"
+#include "../inc/CATProject.h"
+
+//Debug logging parameters
+//To enable debugging as argument to atool.exe use:
+//--show_debug / -show_debug : Normal logging in console.
+//--show_debug_all / -show_debug_all : Log all (low level functions also) to console.
+//--show_dbgview / -show_dbgview : Normal logging to windows debug messages.
+//--show_dbgview_all / -show_dbgview_all : Log all (low level functions also) to windows debug messages.
+
+//Return codes (errorlevel) defined in AT_RETURN_CODE structure see ATCommonDefines.h.
+
+extern bool g_bDebugConsole = false;
+extern bool g_bDebugDbgView = false;
+extern bool g_bDebugLowLevel = false;
+
+//Argument parsing.
+extern bool parseBaseArguments( vector<string>& vArgs, ARGUMENTS& args );
+extern bool parseHookArguments( vector<string>& vArgs, ARGUMENTS& args );
+extern bool parseOldHookArguments( vector<string>& vArgs, ARGUMENTS& args );
+extern bool parseAnalyzeArguments( vector<string>& vArgs, ARGUMENTS& args );
+extern bool parseHtiArguments( vector<string>& vArgs, ARGUMENTS& args );
+extern bool parseParseArguments( vector<string>& vArgs, ARGUMENTS& args );
+
+//Helps.
+extern void print_help( void );
+extern void print_syntax_examples( void );
+
+//AT Library check functions
+extern bool CheckATLibrariesArmv5( string sEpocRoot );
+extern bool CheckATLibrariesArmv5Abiv2( string sEpocRoot );
+extern bool CheckATLibrariesWinscw( string sEpocRoot );
+
+//Hti functions.
+#ifdef HTI_SUPPORT
+extern int htiGetReport( int argc, _TCHAR* argv[] );
+extern int htiDeleteFile( int argc, _TCHAR* argv[] );
+#endif
+
+//CLE version functions.
+extern int showVersionInfo( void );
+
+//Miscelllanaeous functions.
+extern bool CheckSBS2Folder( void );
+
+const char DEBUG_PARAMETER_CONSOLE[] = "-debug";
+const char DEBUG_PARAMETER_DBGVIEW[] = "-dbgview";
+const char SBS2_PARAMETER[] = "-sbs2";
+char g_cCurrentDir[MAX_LINE_LENGTH];
+
+//Global compile class objects are neededif ctrl+c is pressed mmp file must be restored.
+CATProject project_module;
+
+//Parse object.
+CATParseTraceFile Parser;
+
+/**
+* Handle process control signals.
+*/
+BOOL WINAPI HandlerRoutine( DWORD dwCtrlType )
+{
+	//Run recovery and exit for project if user presses ctrl+c
+	//or close signal is received.
+	if( dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_CLOSE_EVENT )
+	{
+		int iMode = project_module.GetMode();
+		if ( iMode == CATProject::COMPILE
+			|| iMode == CATProject::INSTRUMENT
+			|| iMode == CATProject::INSTRUMENT_CONSOLE )
+			project_module.RunRecoveryAndExit();
+	}
+	//Return false so program execution is stopped.
+	return false;
+}
+// TESTING
+int _tmain( int argc, _TCHAR* argv[] )
+{
+	#ifdef MEM_LEAK_CHECK
+	_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+	#endif
+	try {
+		//Set function to handle process control signals.
+		SetConsoleCtrlHandler( HandlerRoutine, true );
+		vector<string> vArguments;
+		for( int i = 1 ; i < argc ; i++ )
+		{
+			vArguments.push_back( argv[i] );
+		}
+		//Help variables.
+		string sEpocRoot("");
+		//Parse base arguments.
+		ARGUMENTS args;
+		parseBaseArguments( vArguments, args );
+
+		// Debugging messages.
+		if ( args.bDebugConsole == true )
+			g_bDebugConsole = true;
+		if ( args.bDebugDbgView == true )
+			g_bDebugDbgView = true;
+		if ( args.bDebugLowLevel == true )
+			g_bDebugLowLevel = true;
+
+		//According to main switch parse rest arguments.
+		switch( args.eMainSwitch )
+		{
+		case SWITCH_UNKNOWN:
+			print_help();
+			return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
+		case SWITCH_ANALYZE:
+			if ( ! parseAnalyzeArguments( vArguments, args ) )
+				return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
+			// Get epocroot
+			if( ! CATBase::GetEpocRoot( sEpocRoot ) )
+				return AT_RETURN_CODE::CANNOT_FIND_EPOCROOT;
+			project_module.SetEpocRoot( sEpocRoot );
+			// project not uninstrumented run it first.
+			if ( ! project_module.IsUninstrumented() )
+			{
+				project_module.SetMode( CATProject::UNINSTRUMENT_CONSOLE );
+				project_module.Run();
+			}
+			// Set mode.
+			project_module.SetMode( CATProject::ANALYZE );
+			project_module.SetLogLevel( args.ANALYZE.iLoggingLevel );
+			project_module.SetDataFile( args.ANALYZE.sDataFile );
+			if ( args.ANALYZE.bSymbolFile )
+				project_module.SetRomSymbolFiles( args.ANALYZE.vSymbolFiles );
+			project_module.SetDataFileOutput( args.ANALYZE.sOutputFile);
+			return project_module.Run();
+		case SWITCH_HOOK:
+			// Parse arguments related to hooking.
+			if ( ! parseHookArguments( vArguments, args ) )
+				return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
+			// Set variables for project.
+			if ( ! project_module.SetArguments( args ) )
+				return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
+			// Get epocroot
+			if( ! CATBase::GetEpocRoot( sEpocRoot ) )
+				return AT_RETURN_CODE::CANNOT_FIND_EPOCROOT;
+			project_module.SetEpocRoot( sEpocRoot );
+			// Check AnalyzeTool libraries
+			if ( _stricmp( args.HOOK.sPlatform.c_str(), "winscw") == 0 )
+			{
+				// Emulator winscw platform
+				if ( ! CheckATLibrariesWinscw(sEpocRoot) )
+					return AT_RETURN_CODE::AT_LIBS_MISSING;
+			}
+			else
+			{
+				// Armv5
+				if ( args.HOOK.iBuildSystem == 2 )
+				{
+					// Abiv2
+					if ( ! CheckATLibrariesArmv5Abiv2(sEpocRoot) )
+						return AT_RETURN_CODE::AT_LIBS_MISSING;
+				}
+				else
+				{
+					// Abiv1
+					if( ! CheckATLibrariesArmv5(sEpocRoot) )
+						return AT_RETURN_CODE::AT_LIBS_MISSING;
+				}
+			}
+			// Run hooking.
+			return project_module.Run();
+			//Uninstrument
+		case SWITCH_UNHOOK:
+			// Set variables for project.
+			if ( ! project_module.SetArguments( args ) )
+				return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
+			// Get epocroot
+			if( ! CATBase::GetEpocRoot( sEpocRoot ) )
+				return AT_RETURN_CODE::CANNOT_FIND_EPOCROOT;
+			project_module.SetEpocRoot( sEpocRoot );
+			return project_module.Run();
+			//Support for old extensions.
+		case SWITCH_OLD_HOOK:
+			// Parse old style arguments related to hooking.
+			if ( ! parseOldHookArguments( vArguments, args ) )
+				return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
+			// Set mode for project.
+			if( args.eHookSwitch == HOOK_OLD_EXTENSION_INSTRUMENT )
+				project_module.SetMode( CATProject::INSTRUMENT );
+			else if( args.eHookSwitch == HOOK_OLD_EXTENSION_UNINSTRUMENT )
+				project_module.SetMode( CATProject::UNINSTRUMENT );
+			else if( args.eHookSwitch == HOOK_OLD_EXTENSION_FAILED )
+				project_module.SetMode( CATProject::UNINSTRUMENT_FAILED );
+			else
+				return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
+
+			// Get epocroot
+			if( ! CATBase::GetEpocRoot( sEpocRoot ) )
+				return AT_RETURN_CODE::CANNOT_FIND_EPOCROOT;
+			project_module.SetEpocRoot( sEpocRoot );
+
+			// Check AnalyzeTool libraries
+			if ( _stricmp( args.HOOK.sPlatform.c_str(), "winscw") == 0 )
+			{
+				// Emulator winscw platform
+				if ( ! CheckATLibrariesWinscw(sEpocRoot) )
+					return AT_RETURN_CODE::AT_LIBS_MISSING;
+			}
+			else
+			{
+				// Armv5
+				if ( args.bEnableSbs2 == true )
+				{
+					// Abiv2
+					if ( ! CheckATLibrariesArmv5Abiv2(sEpocRoot) )
+						return AT_RETURN_CODE::AT_LIBS_MISSING;
+				}
+				else
+				{
+					// Abiv1
+					if( ! CheckATLibrariesArmv5(sEpocRoot) )
+						return AT_RETURN_CODE::AT_LIBS_MISSING;
+				}
+			}
+
+			// In uninstrument we check folder otherwise the switch for sbs version.
+			if ( project_module.GetMode() == CATProject::UNINSTRUMENT )
+			{
+					if ( CheckSBS2Folder() )
+						project_module.SetBuildSystem( CATProject::SBS_V2 );
+					else
+						project_module.SetBuildSystem( CATProject::SBS_V1 );
+			}
+			else
+			{
+				if ( args.bEnableSbs2 == true )
+					project_module.SetBuildSystem( CATProject::SBS_V2 );
+				else
+					project_module.SetBuildSystem( CATProject::SBS_V1 );
+			}
+			// platform
+			project_module.SetPlatform( args.HOOK.sPlatform );
+
+			// build type
+			if ( !_stricmp( args.HOOK.sBuildType.c_str(), "urel" ) )
+				project_module.SetBuildType( CATProject::UREL );
+			else if ( !_stricmp( args.HOOK.sBuildType.c_str(), "udeb" ) )
+				project_module.SetBuildType( CATProject::UDEB );
+
+			// Variant
+			project_module.SetVariant( args.HOOK.sFeatureVariant );
+
+			// If selected modules to be compiled
+			project_module.SetTargetModules( args.HOOK.vTargetPrograms );
+
+			// S60 data file name
+			if ( args.HOOK.bDataFileName )
+				project_module.SetS60FileName( args.HOOK.sDataFileName );
+
+			// logging mode
+			if ( args.HOOK.iLoggingMode == 2 )
+				project_module.SetLoggingMode( CATProject::S60 );
+			else
+				project_module.SetLoggingMode( CATProject::XTI );
+			// run
+			return project_module.Run();
+		case SWITCH_VERSION:
+			return showVersionInfo();
+		case SWITCH_CLEAN:
+			project_module.SetMode( CATProject::CLEAN );
+			if ( CheckSBS2Folder() )
+				project_module.SetBuildSystem( CATProject::SBS_V2 );
+			else
+				project_module.SetBuildSystem( CATProject::SBS_V1 );
+			return project_module.Run();
+		case SWITCH_PARSE_TRACE:
+			if ( ! parseParseArguments( vArguments, args ) )
+				return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
+			if (  CATBase::IsDataFile( args.PARSE.sDataFile ) )
+			{
+				cout << AT_MSG << "Error, " << args.PARSE.sDataFile << " is already parsed." << endl;
+				return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
+			}
+			if ( args.PARSE.bOutputFile )
+			{
+				//Save data with name in arguments[3]
+				Parser.StartParse( args.PARSE.sDataFile.c_str(), args.PARSE.sOutputFile.c_str() );
+			}
+			else
+			{
+				Parser.StartParse( args.PARSE.sDataFile.c_str(), NULL );
+			}
+			return AT_RETURN_CODE::OK;
+		#ifdef HTI_SUPPORT
+		case SWITCH_HTI_DELETE:
+			return htiDeleteFile( argc, argv );
+		case SWITCH_HTI_GET:
+			return htiGetReport( argc, argv );
+		#endif
+		case SWITCH_HELP:
+			print_help();
+			print_syntax_examples();
+			return AT_RETURN_CODE::OK;
+		default:
+			cout << AT_MSG << "Invalid parameters." << endl;
+			return AT_RETURN_CODE::INVALID_ARGUMENT_ERROR;
+		}
+
+	} catch(...)
+	{
+		cout << AT_MSG << "Error, unhandled exception." << endl;
+		return AT_RETURN_CODE::UNHANDLED_EXCEPTION;
+	}
+}
+
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/cataddr2line.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,388 @@
+/*
+* 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:  Main module for addr2line pinpointing.
+*
+*/
+
+#include "../inc/cataddr2line.h"
+#include "../inc/CATMemoryAddress.h"
+#include "../inc/CATBase.h"
+#include "../inc/CATDatParser.h"
+
+#define ASCII_CHAR_CARRIAGE_RETURN 0x0D
+
+CATAddr2line::CATAddr2line()
+{
+	LOG_FUNC_ENTRY("CATAddr2line::CATAddr2line");
+}
+
+bool CATAddr2line::Open( const string& sParameter, const unsigned long /* iLong */ )
+{
+	LOG_FUNC_ENTRY("CATAddr2line::Open");
+	//Debugging for addr2line task.
+	//debug.open( "addr2line-lines.txt", ios_base::trunc );
+
+	m_sMapFileName.clear();
+	// Add .map extendsion
+	m_sMapFileName.append( sParameter );
+	m_sMapFileName.append( ".map" );
+
+	ReadMapFileArmv5();
+
+	//Make symfile path+name
+	string sFullPathToSymFile(sParameter);
+	sFullPathToSymFile.erase( sFullPathToSymFile.find_last_of( "." ), string::npos );
+	sFullPathToSymFile.append( ".sym" );
+
+	// Check with extension + .sym also.
+	if ( ! CATBase::FileExists( sFullPathToSymFile.c_str() ) )
+	{
+		sFullPathToSymFile.clear();
+		sFullPathToSymFile.append( sParameter );
+		sFullPathToSymFile.append( ".sym" );
+	}
+
+	return server.Initialize( sFullPathToSymFile );
+}
+
+string CATAddr2line::GetError( void )
+{
+	LOG_FUNC_ENTRY("CATAddr2line::GetError");
+	string s;
+	return s;
+}
+
+bool CATAddr2line::Close( void )
+{
+	LOG_FUNC_ENTRY("CATAddr2line::Close");
+	//Debugging for addr2line task.
+	//debug.close();
+	return true;
+}
+
+bool CATAddr2line::AddressToLine( CATMemoryAddress* result )
+{
+	LOG_FUNC_ENTRY("CATAddr2line::AddressToLine");
+	
+	result->SetAddressToLineState( CATMemoryAddress::ADDRESS_TO_LINE_STATE::OUT_OF_RANGE);
+
+	if( !server.GetProcessCreatedState() )
+		return false;
+	//Count address
+	ULONG uStartA = result->GetModuleStartAddress();
+	ULONG uMemoryA = result->GetAddress();
+	ULONG uCountedA = uMemoryA - uStartA;
+	uCountedA += FUNCTIONS_OFFSET_IN_GCCE;
+
+	string sTemp = CATBase::NumberToHexString( uCountedA );
+    //Remove "0x"
+    size_t iCounter = sTemp.find_first_of('x');
+    if( iCounter != string::npos )
+    {
+		sTemp.erase( 0, (int)iCounter+1 );
+    }
+	// Write to pipe that is the standard input for a child process.
+	server.WriteToPipe( sTemp ); 
+ 
+	// Read from pipe that is the standard output for child process.
+    string s = server.ReadFromPipe();
+
+	//If output not empty, parse output
+	if( !s.empty() )
+	{
+		//Debugging code for addr2line task.
+		//debug.write( "##########\n", 12 );
+		//debug.write( s.c_str(), s.size() );
+		result->SetAddressToLineState( CATMemoryAddress::ADDRESS_TO_LINE_STATE::EXACT );
+
+		string s2;
+		size_t iLocation = s.find_first_of( ASCII_CHAR_CARRIAGE_RETURN );
+
+		bool bFunctionNameFoundUsingAddr2line = false;
+
+		//Function name
+		
+		if(iLocation != string::npos )
+		{
+			s2 = s.substr( 0, iLocation );
+			//All characters ascii?
+			if( CATBase::IsAscii( s2.c_str(), (int)s2.length() ) )
+			{
+				//addr2line returns $x if function name not found
+				//length must over 2 to be real function name
+				if( s2.length() > 2 )
+				{
+					bFunctionNameFoundUsingAddr2line = true;
+					result->SetFunctionName( s2 );
+					s.erase( 0, iLocation+2 );
+				}
+			}
+		}
+		//If function name not found using addr2line find it from map file
+		if( !bFunctionNameFoundUsingAddr2line )
+		{
+			string sFuncName( GetFunctionNameUsingAddress( uCountedA ) );
+			//If function name empty, print "???"
+			if( sFuncName.empty() )
+			{
+				s2 = "???";
+				result->SetFunctionName( s2 );
+				if(iLocation != string::npos )
+				{
+					s.erase( 0, iLocation+2 );
+				}
+			}
+			else
+				result->SetFunctionName( sFuncName );
+		}
+		iLocation = s.find_first_of( ':' );
+
+		//Filename and location
+
+		if(iLocation != string::npos )
+		{
+			s2 = s.substr( 0, iLocation );
+			result->SetFileName( s2 );
+			s.erase( 0, iLocation+1 );
+		}
+
+		//Exact line number
+
+		s2 = s.substr( 0, s.find_first_of( ASCII_CHAR_CARRIAGE_RETURN ) );
+		result->SetExactLineNumber( atoi( s2.c_str() ) );
+	}
+	return true;
+}
+
+bool CATAddr2line::ReadMapFileArmv5()
+{
+	LOG_FUNC_ENTRY("CATModule2::ReadMapFileArmv5");
+	// Open .map file
+	ifstream in( m_sMapFileName.c_str() );
+	// File open ok?
+	if( ! in.good() )
+	{
+		in.close();
+		return false;
+	}
+	char cTemp[MAX_LINE_LENGTH];
+	bool bFirstFuncFound = false;
+	bool bFirstLine = true;
+	// Get all lines where is "Thumb"
+	do
+	{
+		// Load one line from .map file
+		in.getline( cTemp, MAX_LINE_LENGTH );
+		if( bFirstLine )
+		{
+			bFirstLine = false;
+			if( strstr( cTemp, "ARM Linker" ) == NULL )
+				return false;
+		}
+		// Find _E32Startup
+		if( !bFirstFuncFound && ( strstr( cTemp, "_E32Startup" ) != NULL) )
+		{
+			bFirstFuncFound = true;
+		}
+		else if( !bFirstFuncFound && ( strstr( cTemp, "_E32Dll" ) != NULL) )
+		{
+			bFirstFuncFound = true;
+		}
+		else if( !bFirstFuncFound )
+			// Skip if _E32Startup not found
+			continue;
+
+		if( strstr( cTemp, "Thumb Code" ) != NULL || strstr( cTemp, "ARM Code" ) != NULL)
+		{
+			MAP_FUNC_INFO structMapFileLineInfo;
+			structMapFileLineInfo.sWholeLine.append( cTemp );
+
+			// Get memory string address from line
+			char* pStart = strstr( cTemp, "0x" );
+			// Check did strstr return null.
+			if ( pStart == NULL )
+				continue;
+			char* pTemp = pStart;
+			char TempString[MAX_LINE_LENGTH];
+			TempString[0] = 0;
+			size_t iLength = 0;
+			while( *pTemp != ' ' )
+			{
+				TempString[iLength] = *pTemp;
+				pTemp++;
+				iLength++;
+			}
+			TempString[iLength] = 0;
+
+			structMapFileLineInfo.iAddress = CATDatParser::_httoi( TempString );
+
+			pTemp = cTemp;
+			TempString[0] = 0;
+			
+			// Get function name
+
+			// Skip spaces
+			while( *pTemp == ' ' )
+			{
+				pTemp++;
+			}
+			iLength = 0;
+			// Find end of function name
+			string sTemp( pTemp );
+
+			// Location of character ')'
+			iLength = sTemp.find_first_of(')');
+
+			// Location of character ' '
+			size_t iLength2 = sTemp.find_first_of(' ');
+			
+			// If ')' character is the last char and
+			// character ' ' is closer than ')' use location of ' '
+			if( ( iLength + 1 ) == sTemp.length() && iLength2 < iLength )
+				iLength = iLength2 - 1;
+			
+			if( iLength != string::npos )
+				sTemp.resize( (iLength + 1) );
+
+			structMapFileLineInfo.sFunctionName.append( sTemp.c_str() );
+
+			bool bARM = false;
+			// Find function length
+			pStart = strstr( cTemp, "Thumb Code" );
+			if( pStart == NULL )
+			{
+				pStart = strstr( cTemp, "ARM Code" );
+				bARM = true;
+			}
+			if( pStart != NULL )
+			{
+				if( bARM )
+					pStart += 8;
+				else
+					pStart += 10;
+				while(*pStart == ' ')
+				{
+					pStart++;
+				}
+				sTemp.clear();
+				sTemp.append( pStart );
+				size_t iSize = sTemp.find_first_of(' ');
+				if( iSize != string::npos )
+					sTemp.resize( iSize );
+			}
+
+			structMapFileLineInfo.iFuncLength = atoi( sTemp.c_str() );
+			if( bFirstFuncFound && structMapFileLineInfo.iFuncLength > 0 )
+				// Save to list
+				m_vMapFileFuncList.push_back( structMapFileLineInfo );
+		}
+	}
+	while( in.good() );
+	in.close();
+	return true;
+}
+
+// Find function name of given address
+string CATAddr2line::GetFunctionNameUsingAddress( unsigned long iAddress )
+{
+	LOG_LOW_FUNC_ENTRY("CATAddr2line::GetSymbolIndexUsingAddress");
+	string sRet;
+	for( size_t i = 0; i < m_vMapFileFuncList.size(); i++ )
+	{
+		unsigned long iStart = m_vMapFileFuncList.at( i ).iAddress;
+		unsigned long iEnd = ( m_vMapFileFuncList.at( i ).iAddress
+			+ m_vMapFileFuncList.at( i ).iFuncLength );
+
+		if ( iAddress >= iStart && iAddress < iEnd )
+			return m_vMapFileFuncList.at( i ).sFunctionName;
+	}
+	return sRet;
+}
+
+//Note: New filtering functions commented out until they are taken into use.
+/**
+* Filter string out of unwanted characters.
+*/
+/*
+void CATAddr2line::FilterString( string &sString )
+{
+	LOG_LOW_FUNC_ENTRY("CATAddr2line::FilterString");
+	string sFiltered("");
+	for( size_t i = 0 ; i < sString.length() ; i++ )
+	{
+		const char p = sString.at( i );
+		if ( p != 0 && strchr( ADDR2LINEALLOWEDCHARS, p ) != 0 )
+			sFiltered.push_back( p );
+	}
+	sString = sFiltered;
+}
+*/
+/**
+* Find line feed position from string.
+*/
+/*
+size_t CATAddr2line::FindLineFeed( const string& sString )
+{
+	LOG_LOW_FUNC_ENTRY("CATAddr2line::FindLineFeed");
+	size_t iLineFeed1 = sString.find( 12 );
+	size_t iLineFeed2 = sString.find( 15 );
+	if ( iLineFeed1 < iLineFeed2 && iLineFeed1 != string::npos )
+		return iLineFeed1;
+	else if ( iLineFeed2 != string::npos )
+		return iLineFeed2;
+	else
+		return string::npos;
+}
+*/
+/**
+* Erase characters from start of the string until other char than linefeed found.
+*/
+/*
+void CATAddr2line::EraseUntilNoLineFeed( string& sString )
+{
+	LOG_LOW_FUNC_ENTRY("CATAddr2line::EraseUntilNoLineFeed");
+	for ( size_t i = 0 ; i < sString.length() ; i++ )
+	{
+		if ( sString.at( i ) != 15 && sString.at( i ) != 12 )
+			break;
+	}
+	sString.erase( 0, i );
+}
+*/
+/**
+* Split multiple line string with unexpected line feeds to vector of strings.
+*/
+/*
+vector<string> CATAddr2line::SplitToStrings( string& sMultiLineString )
+{
+	LOG_LOW_FUNC_ENTRY("CATAddr2line::SplitToStrings");
+    vector<string> vLines;
+	while ( 1 )
+	{
+		size_t iLineFeed = FindLineFeed( sMultiLineString );
+		if ( iLineFeed == string::npos )
+			break;
+		string sCell = sMultiLineString.substr(0, iLineFeed );
+		sMultiLineString.erase(0, iLineFeed );
+		EraseUntilNoLineFeed( sMultiLineString );
+		FilterString( sCell );
+		vLines.push_back( sCell );
+	}
+	// If no lines were found set single one.
+	if ( vLines.size() == 0 )
+		vLines.push_back( sMultiLineString );
+	return vLines;
+}
+*/
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/cataddr2lineserver.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,286 @@
+/*
+* 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:  Class representing a server that uses addr2line.exe.
+*
+*/
+
+#include "../inc/cataddr2lineserver.h"
+#include "../inc/CATBase.h"
+
+// ----------------------------------------------------------------------------
+// Constructor
+// ----------------------------------------------------------------------------
+CATAddr2lineServer::CATAddr2lineServer()
+{
+	LOG_FUNC_ENTRY("CATAddr2lineServer::CATAddr2lineServer");
+	m_bProcessCreated = false;
+
+	// Pipe handles.
+	m_hChildErroutRd = 0;
+	m_hChildErroutRdDup = 0;
+	m_hChildErroutWr = 0;
+	m_hChildStdinRd = 0;
+	m_hChildStdinWr = 0;
+	m_hChildStdinWrDup = 0;
+	m_hChildStdoutRd = 0;
+	m_hChildStdoutWr = 0;
+	m_hChildStdoutRdDup = 0;
+	
+	m_hSaveErrout = 0;
+	m_hSaveStdin = 0;
+	m_hSaveStdout = 0;
+
+    // Set the bInheritHandle flag so pipe handles are inherited.
+    m_saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
+    m_saAttr.bInheritHandle = TRUE;
+    m_saAttr.lpSecurityDescriptor = NULL;
+
+	// Symbol file.
+	m_sFullPathAndBinaryName = "";
+}
+// ----------------------------------------------------------------------------
+// Destructor
+// ----------------------------------------------------------------------------
+CATAddr2lineServer::~CATAddr2lineServer()
+{
+	LOG_FUNC_ENTRY("CATAddr2lineServer::~CATAddr2lineServer");
+	// Close the pipe handle so the child process stops reading.
+    CloseHandle(m_hChildStdinWrDup);
+    // Close the write end of the pipe
+    CloseHandle(m_hChildStdoutWr);
+    // Close the write end of the error pipe
+	CloseHandle(m_hChildErroutWr);
+}
+bool CATAddr2lineServer::Initialize( const string& sFullPathAndBinaryName )
+{
+    LOG_FUNC_ENTRY("CATAddr2lineServer::Initialize");
+	BOOL fSuccess;
+	m_sFullPathAndBinaryName = sFullPathAndBinaryName;
+
+    // The steps for redirecting child process's STDOUT:
+    //     1. Save current STDOUT, to be restored later.
+    //     2. Create anonymous pipe to be STDOUT for child process.
+    //     3. Set STDOUT of the parent process to be write handle to
+    //        the pipe, so it is inherited by the child process.
+    //     4. Create a noninheritable duplicate of the read handle and
+    //        close the inheritable read handle.
+ 
+    // Save the handle to the current STDOUT. 
+    m_hSaveStdout = GetStdHandle(STD_OUTPUT_HANDLE); 
+
+    // Create a pipe for the child process's STDOUT.
+    if (! CreatePipe(&m_hChildStdoutRd, &m_hChildStdoutWr, &m_saAttr, 0))
+		return PrintErrorAndExit( "Stdout pipe creation failed\n" );
+
+    // Set a write handle to the pipe to be STDOUT.
+   if (! SetStdHandle(STD_OUTPUT_HANDLE, m_hChildStdoutWr))
+		return PrintErrorAndExit( "Redirecting STDOUT failed\n" );
+
+    // Create noninheritable read handle and close the inheritable read
+    // handle.
+    fSuccess = DuplicateHandle(GetCurrentProcess(), m_hChildStdoutRd,
+        GetCurrentProcess(), &m_hChildStdoutRdDup , 0,
+        FALSE,
+        DUPLICATE_SAME_ACCESS);
+    if( !fSuccess )
+		return PrintErrorAndExit( "DuplicateHandle failed" );
+    CloseHandle(m_hChildStdoutRd);
+
+    // The steps for redirecting child process's STDIN:
+    //     1.  Save current STDIN, to be restored later.
+    //     2.  Create anonymous pipe to be STDIN for child process.
+    //     3.  Set STDIN of the parent to be the read handle to the
+    //         pipe, so it is inherited by the child process.
+    //     4.  Create a noninheritable duplicate of the write handle,
+    //         and close the inheritable write handle.
+ 
+    // Save the handle to the current STDIN.
+    m_hSaveStdin = GetStdHandle(STD_INPUT_HANDLE);
+
+    // Create a pipe for the child process's STDIN.
+    if (! CreatePipe(&m_hChildStdinRd, &m_hChildStdinWr, &m_saAttr, 0))
+		return PrintErrorAndExit( "Stdin pipe creation failed\n" );
+ 
+    // Set a read handle to the pipe to be STDIN. 
+    if (! SetStdHandle(STD_INPUT_HANDLE, m_hChildStdinRd)) 
+		return PrintErrorAndExit( "Redirecting Stdin failed\n" ); 
+ 
+    // Duplicate the write handle to the pipe so it is not inherited. 
+	
+    fSuccess = DuplicateHandle(GetCurrentProcess(), m_hChildStdinWr, 
+        GetCurrentProcess(), &m_hChildStdinWrDup, 0, 
+        FALSE,                  // not inherited 
+        DUPLICATE_SAME_ACCESS); 
+    if (! fSuccess) 
+		return PrintErrorAndExit( "DuplicateHandle failed\n" );
+
+    CloseHandle(m_hChildStdinWr);
+ 
+    // The steps for redirecting child process's ERROUT:
+    //     1. Save current STDOUT, to be restored later.
+    //     2. Create anonymous pipe to be STDOUT for child process.
+    //     3. Set STDOUT of the parent process to be write handle to
+    //        the pipe, so it is inherited by the child process.
+    //     4. Create a noninheritable duplicate of the read handle and
+    //        close the inheritable read handle.
+ 
+    // Save the handle to the current STDOUT. 
+    m_hSaveErrout = GetStdHandle( STD_ERROR_HANDLE ); 
+
+    // Create a pipe for the child process's ERROUT.
+    if (! CreatePipe(&m_hChildErroutRd, &m_hChildErroutWr, &m_saAttr, 0))
+		return PrintErrorAndExit( "Errout pipe creation failed\n" );
+
+    // Set a write handle to the pipe to be ERROUT.
+   if (! SetStdHandle(STD_ERROR_HANDLE, m_hChildErroutWr))
+		return PrintErrorAndExit( "Redirecting ERROUT failed\n" );
+
+    // Create noninheritable read handle and close the inheritable read
+    // handle.
+   
+    fSuccess = DuplicateHandle(GetCurrentProcess(), m_hChildErroutRd,
+        GetCurrentProcess(), &m_hChildErroutRdDup , 0,
+        FALSE,
+        DUPLICATE_SAME_ACCESS);
+    if( !fSuccess )
+		return PrintErrorAndExit( "DuplicateHandle failed" );
+    
+	CloseHandle(m_hChildErroutRd);
+	CloseHandle(m_hChildErroutRdDup);
+	
+	// Now create the child process. 
+    fSuccess = CreateChildProcess();
+    if (!fSuccess )
+		return PrintErrorAndExit( "Create process failed\n" );
+ 
+    // After process creation, restore the saved STDIN and STDOUT.
+	if (! SetStdHandle(STD_INPUT_HANDLE, m_hSaveStdin))
+        return PrintErrorAndExit( "Re-redirecting Stdin failed\n" );
+
+	if (! SetStdHandle(STD_OUTPUT_HANDLE, m_hSaveStdout))
+       return PrintErrorAndExit( "Re-redirecting Stdout failed\n" );
+
+	if (! SetStdHandle(STD_ERROR_HANDLE, m_hSaveErrout))
+       return PrintErrorAndExit( "Re-redirecting Stderrout failed\n" );
+
+	m_bProcessCreated = true;
+    return true;
+}
+BOOL CATAddr2lineServer::CreateChildProcess() 
+{ 
+    LOG_FUNC_ENTRY("CATAddr2lineServer::CreateChildProcess");
+    PROCESS_INFORMATION piProcInfo; 
+    STARTUPINFO siStartInfo;
+    BOOL bFuncRetn = FALSE; 
+ 
+    // Set up members of the PROCESS_INFORMATION structure.
+    ZeroMemory( &piProcInfo, sizeof(PROCESS_INFORMATION) );
+ 
+	// Set up members of the STARTUPINFO structure.
+    ZeroMemory( &siStartInfo, sizeof(STARTUPINFO) );
+    siStartInfo.cb = sizeof(STARTUPINFO); 
+ 
+	//atool.exe:s path + filename
+	char buffer[MAX_PATH];
+
+	GetModuleFileName( NULL, buffer, MAX_PATH );
+
+	string sCommand( buffer );
+
+	//Remove 'atool.exe'
+	size_t tPos = sCommand.rfind( "\\" );
+	if ( tPos != string::npos )
+		sCommand.resize( sCommand.rfind( "\\" )+1 );
+	else
+		sCommand.clear();
+
+	sCommand.append( "addr2line.exe" );
+
+	//addr2line file exists
+	if( !CATBase::FileExists( sCommand.c_str() ) )
+		return PrintErrorAndExit( "File not found addr2line.exe\n" );
+
+	//Sym file exists
+	if( !CATBase::FileExists( m_sFullPathAndBinaryName.c_str() ) )
+	{
+		string sTemp( "File not found " );
+		sTemp.append( m_sFullPathAndBinaryName );
+		sTemp.append( "\n" );
+		return PrintErrorAndExit( sTemp );
+	}
+
+	sCommand.append(" -f -C -e ");
+	sCommand.append( m_sFullPathAndBinaryName );
+
+	// Create the child process. 
+    bFuncRetn = CreateProcess(NULL,
+		(LPSTR)sCommand.c_str(), // command line
+        NULL,          // process security attributes
+        NULL,          // primary thread security attributes
+        TRUE,          // handles are inherited
+        0,             // creation flags
+        NULL,          // use parent's environment
+        NULL,          // use parent's current directory
+        &siStartInfo,  // STARTUPINFO pointer
+        &piProcInfo);  // receives PROCESS_INFORMATION
+
+    if (bFuncRetn == 0)
+    {
+       //CreateProcess failed
+       return false;
+    }
+    else
+    {
+       CloseHandle(piProcInfo.hProcess);
+       CloseHandle(piProcInfo.hThread);
+       return bFuncRetn;
+    }
+}
+VOID CATAddr2lineServer::WriteToPipe( const string& sAddress ) 
+{ 
+	LOG_LOW_FUNC_ENTRY("CATAddr2lineServer::WriteToPipe");
+    DWORD dwRead, dwWritten;
+    CHAR chBuf[2]; //This is for enter key
+
+    //Write data to a pipe. 
+    dwRead = (DWORD)sAddress.length();
+	WriteFile(m_hChildStdinWrDup, sAddress.c_str(), dwRead, &dwWritten, NULL);
+
+	chBuf[0] = 0x0A; //Enter
+	chBuf[1] = 0; //NULL
+	//Write enter key to a pipe
+	WriteFile(m_hChildStdinWrDup, chBuf, 1, &dwWritten, NULL);
+} 
+string CATAddr2lineServer::ReadFromPipe(VOID) 
+{
+	LOG_LOW_FUNC_ENTRY("CATAddr2lineServer::ReadFromPipe");
+	string s;
+	DWORD dwRead;
+    CHAR chBuf[BUFSIZE];
+    // Read output from the child process, and save data to string.
+    ReadFile( m_hChildStdoutRdDup, chBuf, BUFSIZE, &dwRead, NULL);
+	s.append( chBuf );
+    return s;
+}
+bool CATAddr2lineServer::GetProcessCreatedState( void )
+{
+	LOG_LOW_FUNC_ENTRY("CATAddr2lineServer::GetProcessCreatedState");
+	return m_bProcessCreated;
+}
+bool CATAddr2lineServer::PrintErrorAndExit( const string sInput )
+{
+	LOG_FUNC_ENTRY("CATAddr2lineServer::PrintErrorAndExit");
+	cout << AT_MSG << sInput;
+	return false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/catalloc.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -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: 
+*
+*/
+#include "../inc/ATCommonDefines.h"
+#include "../inc/catalloc.h"
+
+string CATAlloc::GetAllocString( void )
+{
+	LOG_LOW_FUNC_ENTRY("CATAlloc::GetAllocString");
+	// Create alloc string
+	string sLine("");
+	sLine.append( m_sTime ); sLine.append(" " );
+	sLine.append( m_sSize );
+
+	// Add all call stack fragments to line.
+	string sCallStack;
+	map<unsigned long, string>::iterator it;
+	for( it = m_vCallStack.begin() ; it != m_vCallStack.end() ; it++ )
+	{
+		sCallStack.append( (*it).second );
+		sCallStack.append( " " );
+	}
+	// Remove the last space
+	if ( sCallStack.size() > 0 )
+		sCallStack.erase( sCallStack.size()-1, 1 );
+	
+	if ( m_iCSCount != 0 )
+	{
+		// Check integrity (calculate number of spaces in call stack)
+		unsigned long iCount = 0;
+		size_t pos = 0;
+		while ( pos != string::npos )
+		{
+			iCount++;
+			pos = sCallStack.find_first_of( ' ', pos+1 );
+		}
+		if ( iCount != m_iCSCount )
+			cout << AT_MSG << "Error, integrity check failed in alloc." << endl;
+	}
+
+	// Add call stack to line.
+	if ( sCallStack.size() > 0 )
+	{
+		sLine.append(" " );
+		sLine.append( sCallStack );
+	}
+
+	// return alloc line.
+	return sLine;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/catallocs.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,176 @@
+/*
+* 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 "../inc/ATCommonDefines.h"
+#include "../inc/catallocs.h"
+
+void CATAllocs::Alloc( const string& sAllocString )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::Alloc");
+	string sAlloc( sAllocString );
+	CATAlloc alloc;
+	string sAddress = GetStringUntilNextSpace( sAlloc, true );
+	alloc.m_sTime = GetStringUntilNextSpace( sAlloc, true );
+	alloc.m_sSize = GetStringUntilNextSpace( sAlloc, true );
+	alloc.m_vCallStack.insert( pair<unsigned long,string>(1, sAlloc) );
+	// 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::AllocH( const string& sAllocHString )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::AllocH");
+	string sAllocH( sAllocHString );
+	// Parse alloc & create new allocation.
+	CATAlloc alloc;
+	string sAddress = GetStringUntilNextSpace( sAllocH, true );
+	alloc.m_sTime = GetStringUntilNextSpace( sAllocH, true );
+	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.
+	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 )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::AllocF");
+	string sAllocF( sAllocFString );
+	string sAddress = GetStringUntilNextSpace( sAllocF, true );
+	string sTime = GetStringUntilNextSpace( sAllocF, true );
+	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 );
+	}
+}
+
+// Free message.
+void CATAllocs::Free( const string& sFreeString )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::Free");
+	string sFree( sFreeString );
+	string sKey = GetStringUntilNextSpace( sFree );
+	// Find related allocation.
+	map<string, CATAlloc>::iterator it;
+	it = m_vAllocs.find( sKey );
+	if ( it == m_vAllocs.end() )
+	{
+		LOG_STRING( "CATAllocs: Free message which has no alloc pair: " << sKey );
+		return;
+	}
+	// Delete it.
+	m_vAllocs.erase( it );
+}
+
+// FreeH.
+void CATAllocs::FreeH( const string& sFreeH )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::FreeH");
+	// Current implementation does not use call stack of
+	// free message to anything.
+	string sFree( sFreeH );
+	string sKey = GetStringUntilNextSpace( sFree );
+	// Time stamp. (not used currently)
+	// Call stack count. (not used currently)
+	// Call stack data. (not used currently)
+
+	// Find related allocation.
+	map<string, CATAlloc>::iterator it;
+	it = m_vAllocs.find( sKey );
+	if ( it == m_vAllocs.end() )
+	{
+		LOG_STRING( "CATAllocs: FreeH message which has no alloc pair: " << sKey );
+		return;
+	}
+	// Delete it.
+	m_vAllocs.erase( it );
+}
+
+// FreeF.
+void CATAllocs::FreeF( const string& /* sFreeF */ )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::FreeF");
+	// Fragments are currently ignored.
+	// Memory address. (not used currently)
+	// Time stamp. (not used currently)
+	// Packet number. (not used currently)
+	// Call stack data. (not used currently)
+}
+
+// Get "leak" list ordered by allocation time.
+void CATAllocs::GetLeakList( vector<string>& vLeakList )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::GetLeakList");
+
+	// Create multimap where key is timestamp.
+	// Add allocations there so they will go ascending order.
+	multimap<string,string> mmap;
+	multimap<string,string>::iterator itMmap;
+	
+	map<string, CATAlloc>::iterator it;
+	for( it = m_vAllocs.begin(); it != m_vAllocs.end() ; it++ )
+	{
+		string sTime = it->second.m_sTime;
+		
+		string sLine = it->first;
+		sLine.append(" ");
+		sLine.append( it->second.GetAllocString() );
+
+		mmap.insert( pair<string,string>( sTime, sLine ) );
+	}
+	
+	// Iterate list to parameter vector.
+	vLeakList.clear();
+	for ( itMmap = mmap.begin(); itMmap != mmap.end(); itMmap++ )
+		vLeakList.push_back( itMmap->second );
+}
+
+// Clear alloc data.
+void CATAllocs::ClearAllocs( void )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::ClearAllocs");
+	m_vAllocs.clear();
+}
+
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/catdbghelper.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,314 @@
+/*
+* 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:  Windows debug api implementation for IAddressToLine interface.
+*
+*/
+
+#include "../inc/catdbghelper.h"
+#include "../inc/CATBase.h"
+#include "../inc/CATMemoryAddress.h"
+#include <dbghelp.h>
+
+/**
+* Notes on version number of api functions.
+* 5.1	Windows XP
+* 5.2	Windows Server 2003
+* 6.8	Debugging Tools for Windows 6.8
+* SymSetOptions			DbgHelp.dll 5.1 or later
+* SymSetSearchPath		DbgHelp.dll 5.1 or later
+* SymLoadModuleEx			Versions 5.2 and 6.0
+* SymLoadModule64			DbgHelp.dll 5.1 or later
+* SymFromAddr				Versions 4.0 and 5.1
+* SymGetLineFromAddr64	DbgHelp.dll 5.1 or later
+*/
+
+// Wrapper class for symbol information package.
+struct CSymbolInfo : public SYMBOL_INFO_PACKAGE
+{
+	CSymbolInfo()
+	{
+		si.SizeOfStruct = sizeof( SYMBOL_INFO );
+		si.MaxNameLen = sizeof( name );
+	}
+};
+
+// Wrapper class for line information container.
+struct CLineInfo : public IMAGEHLP_LINE64
+{
+	CLineInfo()
+	{
+		SizeOfStruct = sizeof( IMAGEHLP_LINE64 );
+	}
+};
+
+CATDbgHelper::CATDbgHelper()
+{
+	LOG_FUNC_ENTRY("CATDbgHelper::CDbgHelper");
+	// Set the some "default" base address.
+	m_BaseAddress = 0x2;
+	m_bMap = false;
+	m_pBinaryFile = NULL;
+}
+
+CATDbgHelper::~CATDbgHelper()
+{
+	LOG_FUNC_ENTRY("CATDbgHelper::~CDbgHelper");
+	// Close dbghelper only once.
+	if ( CDBGHELPER_OPEN )
+	{
+		Close();
+	}
+	if ( m_pBinaryFile )
+	{
+		delete[] m_pBinaryFile;
+		m_pBinaryFile = NULL;
+	}
+}
+
+bool CATDbgHelper::Open( const string& sParameter, const unsigned long iLong )
+{
+	LOG_FUNC_ENTRY("CATDbgHelper::Open");
+	// Verify that file exits. Version 5.1.2600.5512 of dbghelp.dll does not correctly
+	// return error code if missing image file. This can lead upto applicaton crash.
+	if ( ! CATBase::FileExists( sParameter.c_str() ) )
+	{
+		LOG_STRING( "Missing image file: " << sParameter );
+		return false;
+	}
+
+	// Is it urel try read map?
+	if ( sParameter.find( "\\urel\\" ) != string::npos )
+	{
+		string sMapFile = sParameter;
+		sMapFile.append( ".map" );
+		ReadMapFile( sMapFile );
+	}
+
+	// Set base address used
+	m_BaseAddress = iLong + AT_VIRTUAL_OFFSET_DBGHELPER;
+	// Binary file (also referred as symbol).
+	size_t length = sParameter.length();
+	if ( length == 0 )
+	{
+		LOG_STRING("DbgHelp:Invalid binary parameter.");
+		return false;
+	}
+
+	char* pChar = new char[ sParameter.length()+1 ];
+	strcpy( pChar, sParameter.c_str() );
+	// Have to be casted to PSTR before using dbg api. Even tho its typedef same.
+	// This will avoid access violations bug.
+	// Note pChar is not deleted because its the member pointer just casted its
+	// memory allocation freed in destructor.
+	if ( m_pBinaryFile )
+		delete[] m_pBinaryFile;
+
+	m_pBinaryFile = (PSTR) pChar;
+
+	// Initialize dbghelper if not done only once.
+	if ( ! CDBGHELPER_OPEN )
+	{
+		// Set symbol options
+		SymSetOptions( SYMOPT_LOAD_LINES | SYMOPT_DEBUG | SYMOPT_UNDNAME | SYMOPT_LOAD_ANYTHING );
+		if ( !SymInitialize( GetCurrentProcess(), NULL, TRUE ) )
+		{
+			LOG_STRING("DbgHelp:Error initializing dbghelper " << (int) GetLastError());
+			return false;
+		}
+		LOG_STRING("DbgHelp:dbghelper opened.");
+		CDBGHELPER_OPEN = true;
+	}
+
+	// Set symbol search path.
+	if ( !SymSetSearchPath( GetCurrentProcess(), NULL ) )
+	{
+		LOG_STRING("DbgHelp:Error setting symbol search path " << (int) GetLastError());
+		return false;
+	}
+
+	// Load module.
+	DWORD64 ret;
+	ret = SymLoadModule64( GetCurrentProcess(), NULL, m_pBinaryFile, NULL, m_BaseAddress, NULL ); // 5.1 api version.
+	if ( ret != m_BaseAddress  && ret != 0)
+	{
+		LOG_STRING("Dbghelp:Module load failed " << (int) GetLastError());
+		return false;
+	}
+	CDBGHELPER_CLIENTS++;
+	return true;
+}
+
+string CATDbgHelper::GetError( void )
+{
+	LOG_FUNC_ENTRY("CATDbgHelper::GetError");
+	return string("not implemented.");
+}
+
+bool CATDbgHelper::Close( void )
+{
+	LOG_FUNC_ENTRY("CATDbgHelper::Close");
+	if ( ! SymUnloadModule64( GetCurrentProcess(), m_BaseAddress ) )
+	{
+		LOG_STRING("Dbghelp:Module unload failed.");
+	}
+	CDBGHELPER_CLIENTS--;
+	if ( CDBGHELPER_OPEN && CDBGHELPER_CLIENTS == 0)
+	{
+		// Cleanup dbghelper.
+		if ( ! SymCleanup( GetCurrentProcess() ) )
+		{
+			LOG_STRING("dbghelper cleanup failed.");
+			return false;
+		}
+		LOG_STRING("dbghelper closed.");
+		// Set state not opened.
+		CDBGHELPER_OPEN = false;
+	}
+	return true;
+}
+
+bool CATDbgHelper::AddressToLine( CATMemoryAddress* result )
+{
+	LOG_FUNC_ENTRY("CATDbgHelper::AddressToLine");
+	
+	// Set state out of range
+	result->SetAddressToLineState( CATMemoryAddress::OUT_OF_RANGE );
+
+	// check that dbghelper has been initialized successfully.
+	if ( ! CDBGHELPER_OPEN )
+		return false;
+
+	// Check has binary been moved, if so unload and load to new base address.
+	if ( result->GetModuleStartAddress() + AT_VIRTUAL_OFFSET_DBGHELPER != m_BaseAddress )
+	{
+		// Unload.
+		if ( SymUnloadModule64( GetCurrentProcess(), m_BaseAddress ) )
+		{
+			// Set new base address.
+			m_BaseAddress = result->GetModuleStartAddress() + AT_VIRTUAL_OFFSET_DBGHELPER;
+			// (Re)load.
+			DWORD64 loading = SymLoadModule64( GetCurrentProcess(), NULL, m_pBinaryFile, NULL, m_BaseAddress, NULL );
+			if ( loading != m_BaseAddress  && loading != 0)	
+			{
+				LOG_STRING("Dbghelp:Module load failed " << (int) GetLastError());
+				return false;
+			}
+		}
+		else
+			LOG_STRING("Dbghelp:Module unload failed " << (int) GetLastError() );
+	}
+	// Address to find (offset+given address).
+	unsigned long iAddressToFind = result->GetAddress() + AT_VIRTUAL_OFFSET_DBGHELPER;
+	// Displacements of line/symbol information.
+	DWORD64 displacementSymbol;
+	DWORD displacementLine;
+	// Structure to get symbol information.
+	CSymbolInfo symbol;
+	// Structure to get line information.
+	CLineInfo line;
+	// Find Symbol for given address 
+	if( ! SymFromAddr( GetCurrentProcess(), iAddressToFind , &displacementSymbol, &symbol.si ) )
+	{
+		LOG_STRING("Failed to find symbol information for given line.");
+		return AddressToFunction( result );
+	}
+	// Find line information
+	if( ! SymGetLineFromAddr64( GetCurrentProcess(), iAddressToFind, &displacementLine, &line ) )
+	{
+		// If it fails get symbol line information
+		LOG_STRING("Dbghelp:Failed to find line information for address, trying for symbol of address.");
+		if( ! SymGetLineFromAddr64( GetCurrentProcess(), symbol.si.Address, &displacementLine, &line ) )
+		{
+			LOG_STRING("Dbghelp:Failed to find line information for symbol address.");
+			return AddressToFunction( result );
+		}
+	}
+	// Set the results.
+	result->SetFileName( string( line.FileName ) );
+	result->SetFunctionName( string( symbol.si.Name ) );
+	result->SetExactLineNumber( (int) line.LineNumber );
+	result->SetAddressToLineState( CATMemoryAddress::EXACT );
+	// Return.
+	return true;
+}
+
+bool CATDbgHelper::AddressToFunction( CATMemoryAddress* result )
+{
+	LOG_FUNC_ENTRY("CATDbgHelper::AddressToFunction");
+	bool bFound = false;
+	// If map file read use it and return.
+	if ( m_bMap )
+	{
+		ULONG uCountedA = result->GetOffSetFromModuleStart();
+		for ( vector<MAP_FUNC_INFO>::iterator it = m_vMapFileFuncList.begin() ; it != m_vMapFileFuncList.end() ; it++ )
+		{
+			// Check is this the symbol where address is.
+			unsigned long iStart = it->iAddress;
+			unsigned long iEnd = it->iAddress + it->iFuncLength;
+			if ( uCountedA >= iStart 
+				&& uCountedA < iEnd )
+			{
+				result->SetAddressToLineState( CATMemoryAddress::SYMBOL );
+				result->SetFunctionName( it->sMangledName );
+				bFound = true;
+				break;
+			}
+		}
+	}
+	return bFound;
+}
+
+void CATDbgHelper::ReadMapFile( const string sMapFileName )
+{
+	LOG_FUNC_ENTRY("CATDbgHelper::ReadMapFile");
+	try {
+		ifstream in( sMapFileName.c_str() );
+		if ( ! in.good() )
+		{
+			in.close();
+			return;
+		}
+		char cLine[MAX_LINE_LENGTH];
+		do {
+			in.getline( cLine, MAX_LINE_LENGTH );
+			// Search pattern for 'image ro' symbols is ".text"
+			string sLine( cLine );
+			if ( sLine.find( ".text" ) != string::npos )
+			{
+				MAP_FUNC_INFO symbol;
+				// Pickup symbol attributes
+				// Address
+				string sAddress = CATBase::GetStringUntilNextSpace( sLine, true );
+				symbol.iAddress = CATBase::_httoi( sAddress.c_str() );
+				// Lenght
+				string sLength = CATBase::GetStringUntilNextSpace( sLine, true );
+				symbol.iFuncLength = CATBase::_httoi( sLength.c_str() );
+				// Name
+				size_t iStart = sLine.find_first_of( '(' );
+				size_t iEnd = sLine.find_last_of( ')' );
+				if ( iStart != string::npos && iEnd != string::npos )
+				{
+					symbol.sMangledName = sLine.substr( iStart+1, iEnd-iStart-1 );
+					// Add symbol to vector
+					m_vMapFileFuncList.push_back( symbol );
+				}
+			}
+		} while ( in.good() );
+		in.close();
+		m_bMap = true;
+	} catch (...) {
+		m_bMap = false;
+		LOG_STRING("DbgHelp: Error reading map file.");
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/catfilereader.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,111 @@
+/*
+* 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:  Class for reading ascii files in AnalyzeTool.
+*
+*/
+
+#include "../inc/ATCommonDefines.h"
+#include "../inc/catfilereader.h"
+
+// -----------------------------------------------------------------------------
+// CATFileReader::CATFileReader
+// Constructor.
+// -----------------------------------------------------------------------------
+CATFileReader::CATFileReader()
+{
+	LOG_FUNC_ENTRY("CATFileReader::CATFileReader");
+	m_cDelimiter = '\r'; // default line delimeter
+}
+
+// -----------------------------------------------------------------------------
+// CATFileReader::~CATFileReader
+// Destructor.
+// -----------------------------------------------------------------------------
+CATFileReader::~CATFileReader()
+{
+	LOG_FUNC_ENTRY("CATFileReader::~CATFileReader");
+}
+
+// -----------------------------------------------------------------------------
+// CATFileReader::Open
+// Open / Read file.
+// -----------------------------------------------------------------------------
+bool CATFileReader::Open( const char* cFile )
+{
+	LOG_FUNC_ENTRY("CATFileReader::Open");
+	if ( strlen( cFile ) < 1 )
+	{
+		LOG_STRING("CATFileReader::Open empty file argument.");
+		return false;
+	}
+	try {
+		ifstream in;
+		in.open( cFile, ios::binary );
+		if ( ! in.good() )
+			return false;
+		m_stream << in.rdbuf();
+		in.close();
+	}
+	catch(...)
+	{
+		LOG_STRING("CATFileReader::Open unhandled exception.");
+		return false;
+	}
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATFileReader::Close
+// Close file.
+// -----------------------------------------------------------------------------
+bool CATFileReader::Close( void )
+{
+	LOG_FUNC_ENTRY("CATFileReader::Close");
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATFileReader::GetLine
+// Get line from file.
+// -----------------------------------------------------------------------------
+bool CATFileReader::GetLine( string& sLine )
+{
+	//LOG_FUNC_ENTRY("CATFileReader::GetLine");
+	char cLine[MAX_LINE_LENGTH];
+	if ( !m_stream.good() )
+		return false;
+	m_stream.getline( cLine, MAX_LINE_LENGTH, m_cDelimiter ); m_stream.get();
+	sLine = cLine;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATFileReader::SetDelimiter
+// Set line delimiting character.
+// -----------------------------------------------------------------------------
+void CATFileReader::SetDelimiter( char cDelimiter )
+{
+	LOG_FUNC_ENTRY("CATFileReader::SetDelimiter");
+	m_cDelimiter = cDelimiter;
+}
+
+// -----------------------------------------------------------------------------
+// CATFileReader::GetDelimiter
+// Get current line delimiting character.
+// -----------------------------------------------------------------------------
+char CATFileReader::GetDelimiter() const
+{
+	LOG_FUNC_ENTRY("CATFileReader::GetDelimiter()");
+	return m_cDelimiter;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/catromsymbol.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,656 @@
+/*
+* 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:  Reads rom symbol file and provides interface to acquire
+*               binary and function information using memory addresss.
+*
+*/
+
+#include "../inc/ATCommonDefines.h"
+#include "../inc/catromsymbol.h"
+#include "../inc/catfilereader.h"
+#include "../inc/CATBase.h"
+#include "../inc/CATMemoryAddress.h"
+
+// -----------------------------------------------------------------------------
+// RofsBinary::RofsBinary
+// Default construcor
+// -----------------------------------------------------------------------------
+RofsBinary::RofsBinary()
+{
+	LOG_LOW_FUNC_ENTRY("RofsBinary::RofsBinary");
+	m_sBinary = "";
+	vSymbols.clear();
+}
+
+// -----------------------------------------------------------------------------
+// RofsBinary::RofsBinary
+// Construcor
+// -----------------------------------------------------------------------------
+RofsBinary::RofsBinary( const string& sBinary )
+{
+	LOG_LOW_FUNC_ENTRY("RofsBinary::RofsBinary");
+	m_sBinary = sBinary;
+	vSymbols.clear();
+}
+
+// -----------------------------------------------------------------------------
+// RofsBinary::~RofsBinary
+// Destructor
+// -----------------------------------------------------------------------------
+RofsBinary::~RofsBinary()
+{
+	LOG_LOW_FUNC_ENTRY("RofsBinary::~RofsBinary");
+	for ( vector<Symbol*>::iterator it = vSymbols.begin() ; it != vSymbols.end() ; it++ )
+		delete *it;
+	vSymbols.clear();
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::CATRomSymbol
+// Constructor.
+// -----------------------------------------------------------------------------
+CATRomSymbol::CATRomSymbol()
+{
+	LOG_FUNC_ENTRY("CATRomSymbol::CATRomSymbol");
+	m_bSymbolsRead = false;
+	m_iRomEndAddress = 0;
+	m_iRomStartAddress = 0;
+	m_vRomFiles.clear();
+	m_sErrorMessage = "";
+	m_vRomCache.clear();
+	m_vRomSymbols.clear();
+	m_bShowProgressMessages = false;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::~CATRomSymbol
+// Destructor.
+// -----------------------------------------------------------------------------
+CATRomSymbol::~CATRomSymbol()
+{
+	LOG_FUNC_ENTRY("CATRomSymbol::~CATRomSymbol");
+	// Rom
+	for ( vector<Symbol*>::iterator it = m_vRomSymbols.begin() ; it != m_vRomSymbols.end() ; it++ )
+	{
+		delete *it;
+	}
+	m_vRomSymbols.clear();
+	// Rofs
+	for ( vector<RofsBinary*>::iterator it = m_vRofsBinaries.begin() ; it != m_vRofsBinaries.end() ; it++ )
+	{
+		delete *it;
+	}
+	m_vRofsBinaries.clear();
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::Open
+// This funtion should not be used anymore since
+// we support multiple rom/rofs files.
+// -----------------------------------------------------------------------------
+bool CATRomSymbol::Open( const string& /*sString*/, const unsigned long /*iLong*/)
+{
+	LOG_FUNC_ENTRY("CATRomSymbol::Open");
+	return false;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::SetSymbols
+// Set symbol file(s) to be used.
+// This also checks that files exists and identifies them as rom/rofs.
+// -----------------------------------------------------------------------------
+bool CATRomSymbol::SetSymbols( const vector<string>& vSymbols )
+{
+	LOG_FUNC_ENTRY("CATRomSymbol::SetSymbols");
+	bool ok = true;
+	// Check no same symbol defined twice.
+	for( vector<string>::const_iterator it = vSymbols.begin() ;
+		it != vSymbols.end(); it++ )
+	{
+		for( vector<string>::const_iterator it2 = vSymbols.begin() ;
+			it2 != vSymbols.end(); it2++ )
+		{
+			if ( it == it2 )
+				continue;
+			if ( _stricmp( (*it).c_str(), (*it2).c_str() ) == 0 )
+			{
+				m_sErrorMessage.append( "Same symbol file defined twice (" );
+				m_sErrorMessage.append( (*it) );
+				m_sErrorMessage.append( ")\n" );
+				return false;
+			}
+		}
+	}
+	// Loop given symbol files.
+	for( vector<string>::const_iterator it = vSymbols.begin() ;
+		it != vSymbols.end(); it++ )
+	{
+		// Symbol file exists?
+		if ( ! CATBase::FileExists( (*it).c_str() ) )
+		{
+			ok = false;
+			m_sErrorMessage.append( "Symbol file does not exists (" );
+			m_sErrorMessage.append( *it );
+			m_sErrorMessage.append( ").\n");
+			continue;
+		}
+		// Identify symbol file.
+		int type = IdentifySymbolFile( *it );
+		// Depending on type move it correct vector.
+		switch( type )
+		{
+		case SYMBOL_FILE_INVALID:
+			ok = false;
+			m_sErrorMessage.append( "Symbol file with invalid content (" );
+			m_sErrorMessage.append( *it );
+			m_sErrorMessage.append( ").\n");
+			break;
+		case SYMBOL_FILE_ROM:
+			m_vRomFiles.push_back( *it );
+			break;
+		case SYMBOL_FILE_ROFS:
+			m_vRofsFiles.push_back( *it );
+			break;
+		default:
+			ok = false;
+			LOG_STRING("IdentifySymbolFile returned unknown type.");
+			break;
+		}
+	}
+	if ( ok )
+	{
+		// Read symbols.
+		if ( m_vRomFiles.size() > 0 )
+		{
+			if ( ! ReadRomFiles() )
+				ok = false;
+			else
+				m_bSymbolsRead = true;
+		}
+		if ( m_vRofsFiles.size() > 0 )
+		{
+			if ( ! ReadRofsFiles() )
+				ok = false;
+			else
+				m_bSymbolsRead = true;
+		}
+	}
+	return ok;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::IdentifySymbolFile
+// Identify given file is it rom / rofs.
+// -----------------------------------------------------------------------------
+int CATRomSymbol::IdentifySymbolFile( const string& sFile )
+{
+	LOG_FUNC_ENTRY("CATRomSymbol::IdentifySymbolFile");
+	// Set type as invalid.
+	int iType = SYMBOL_FILE_INVALID;
+	// Line counter.
+	int iLineCount = 0;
+	// Minimun line length to identify it.
+	size_t iLineMinLength = MAX_LINE_LENGTH;
+	if ( ROFS_SYMBOL_IDENTIFY_STRING.length() > ROM_SYMBOL_IDENTIFY_STRING.length() )
+		iLineMinLength = ROFS_SYMBOL_IDENTIFY_STRING.length();
+	else
+		iLineMinLength = ROM_SYMBOL_IDENTIFY_STRING.length();
+	try {
+		ifstream in;
+		in.open( sFile.c_str(), ios::in );
+		if ( ! in.good() )
+			return SYMBOL_FILE_INVALID;
+		char cLine[MAX_LINE_LENGTH];
+		do {
+			// Dont read too many lines. (File might be contain invalid data).
+			iLineCount++;
+			if ( iLineCount > IDENTIFY_MAX_LINES_READ )
+				break;
+
+			// Get line -> string.
+			in.getline( cLine, MAX_LINE_LENGTH );
+			string sLine(cLine);
+			
+			// Check its not too short.
+			if( sLine.length() < iLineMinLength )
+				continue;
+
+			// Take substring from start of line to identify it to rofs/rom.
+			if ( ! sLine.substr( 0, ROFS_SYMBOL_IDENTIFY_STRING.length() ).compare( ROFS_SYMBOL_IDENTIFY_STRING ) )
+			{
+				iType = SYMBOL_FILE_ROFS;
+				break;
+			}
+			else if ( ! sLine.substr( 0, ROM_SYMBOL_IDENTIFY_STRING.length() ).compare( ROM_SYMBOL_IDENTIFY_STRING ) )
+			{
+				iType = SYMBOL_FILE_ROM;
+				break;
+			}
+		} while ( in.good() );
+		in.close();
+	}
+	catch(...)
+	{
+		LOG_STRING("CATRomSymbol::IdentifySymbolFile unhandled exception.");
+	}
+	return iType;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::ReadRomFiles
+// Reads rom file(s) and creates symbols to vector.
+// -----------------------------------------------------------------------------
+bool CATRomSymbol::ReadRomFiles()
+{
+	LOG_FUNC_ENTRY("CATRomSymbol::ReadRomFile");
+
+	// Clear symbols.
+	for ( vector<Symbol*>::iterator it = m_vRomSymbols.begin() ; it != m_vRomSymbols.end() ; it++ )
+	{
+		delete *it;
+	}
+	m_vRomSymbols.clear();
+	
+	// Clear cache. note cache is just pointers dont delete them.
+	m_vRomCache.clear();
+
+	// Any errors?
+	bool ok = true;
+
+	for( vector<string>::iterator it = m_vRomFiles.begin();
+		it != m_vRomFiles.end() ; it++ )
+		ok = ReadRomFile( *it );
+	
+	// If size smaller than 1 it is not good rom file(s).
+	if ( m_vRomSymbols.size() < 1  || ok != true)
+		return false;
+
+	// Rom start and end addresses.
+	m_iRomStartAddress = (*m_vRomSymbols.begin())->iStartAddress;
+	m_iRomEndAddress = (*m_vRomSymbols.rbegin())->iEndAddress;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::ReadRofsFiles
+// Read rofs files.
+// -----------------------------------------------------------------------------
+bool CATRomSymbol::ReadRofsFiles()
+{
+	LOG_FUNC_ENTRY("CATRomSymbol::ReadRofsFiles");
+	// Clear.
+	for ( vector<RofsBinary*>::iterator it = m_vRofsBinaries.begin() ; it != m_vRofsBinaries.end() ; it++ )
+	{
+		delete *it;
+	}
+	m_vRofsBinaries.clear();
+	
+	// Any errors?
+	bool ok = true;
+
+	for( vector<string>::iterator it = m_vRofsFiles.begin();
+		it != m_vRofsFiles.end() ; it++ )
+		ok = ReadRofsFile( *it );
+	
+	// If size smaller than 1 it is not good rofs file(s).
+	if ( m_vRofsBinaries.size() < 1  || ok != true)
+		return false;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::ReadRomFile
+// Read given rom file
+// -----------------------------------------------------------------------------
+bool CATRomSymbol::ReadRomFile( const string& sFile )
+{
+	LOG_FUNC_ENTRY("CATRomSymbol::ReadRomfile");
+	// Open rom file.
+	CATFileReader* reader = new CATFileReader();
+	// Show progress message if flag set.
+	if ( m_bShowProgressMessages )
+		cout << AT_MSG << "Reading rom symbol file: " << sFile << "..." << endl;
+	if ( ! reader->Open( sFile.c_str() ) )
+	{
+		reader->Close();
+		delete reader;
+		return false;
+	}
+
+	// Show progress message if flag set.
+	if ( m_bShowProgressMessages )
+		cout << AT_MSG << "Parsing rom symbol file: " << sFile << "..." << endl;
+
+	// Loop thrue lines.
+	string sLine("");
+	string sBinary("");
+	while( reader->GetLine( sLine ) )
+	{
+		// From rom we just read symbols that have lenght, no need to separate them into diff binaries.
+		try {
+			if ( sLine.size() < 2 )
+			{
+				continue;
+			}
+			else if ( sLine.at(0) == '8' )
+			{
+				// Create new item.
+				Symbol* symbol = new Symbol();
+				ParseSymbolFromLine( sLine, symbol);
+				// Ignore symbols which have same start & end address (zero length).
+				if ( symbol->iStartAddress != symbol->iEndAddress )
+					m_vRomSymbols.push_back( symbol );
+				else
+					delete symbol;
+			}
+		} catch(...)
+		{
+			// Catch all possible exception here so analyze will succeed even rom file invalid.
+			m_sErrorMessage.append( "Unhandled exception parsing rom symbol file.\n" );
+			// Close and delete reader.
+			reader->Close();
+			delete reader;
+			return false;
+		}
+	}
+	// Close and delete reader.
+	reader->Close();
+	delete reader;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::ReadRofsFile
+// Read given rofs file
+// -----------------------------------------------------------------------------
+bool CATRomSymbol::ReadRofsFile( const string& sFile )
+{
+	LOG_FUNC_ENTRY("CATRomSymbol::ReadRofsFile");
+	// open/read rofs file.
+	CATFileReader* reader = new CATFileReader();
+	// Show progress message if flag set.
+	if ( m_bShowProgressMessages )
+		cout << AT_MSG << "Reading rofs symbol file: " << sFile << "..." << endl;
+	if ( ! reader->Open( sFile.c_str() ) )
+	{
+		reader->Close();
+		delete reader;
+		return false;
+	}
+
+	// Show progress message if flag set.
+	if ( m_bShowProgressMessages )
+		cout << AT_MSG << "Parsing rofs symbol file: " << sFile << "..." << endl;
+
+	// Loop thrue lines.
+	string sLine("");
+	string sBinary("");
+	RofsBinary* rb = NULL;
+	while( reader->GetLine( sLine ) )
+	{
+		try {
+			if ( sLine.size() < 2 )
+			{
+				continue;
+			}
+			else if ( sLine.at(0) == 'F' )
+			{
+				if ( rb != NULL )
+				{
+					// Check last binary if no symbols in it dont add it.
+					if ( rb->vSymbols.size() == 0 )
+					{
+						delete rb;
+						rb = NULL;
+					}
+					else
+						m_vRofsBinaries.push_back( rb );
+				}
+				// new binary name.
+				size_t i = sLine.rfind("\\");
+				sLine.erase(0, i+1);
+				rb = new RofsBinary( sLine );
+
+			}
+			else if ( sLine.at(0) == '0' )
+			{
+				// Cannot pickup symbols if no binary defined.
+				if ( rb == NULL )
+					continue;
+				// Create new item.
+				Symbol* symbol = new Symbol();
+				ParseSymbolFromLine( sLine, symbol);
+				// Ignore symbols which have same start & end address (zero length).
+				if ( symbol->iStartAddress != symbol->iEndAddress )
+					rb->vSymbols.push_back( symbol );
+				else
+					delete symbol;
+			}
+		} catch(...)
+		{
+			// Catch all possible exception here so analyze will succeed even rofs file invalid.
+			m_sErrorMessage.append( "Unhandled exception parsing rofs symbol file.\n" );
+			// Close and delete reader.
+			reader->Close();
+			delete reader;
+			return false;
+		}
+	}
+	// Last added binary.
+	if ( rb != NULL )
+	{
+		if ( rb->vSymbols.size() == 0 )
+		{
+			delete rb;
+			rb = NULL;
+		}
+		else
+			m_vRofsBinaries.push_back( rb );
+	}
+	// Close and delete reader.
+	reader->Close();
+	delete reader;
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::ParseSymbolFromLine
+// Parses given line into given symbol.
+// -----------------------------------------------------------------------------
+void CATRomSymbol::ParseSymbolFromLine( const string& sLine, Symbol* pSymbol )
+{
+	LOG_LOW_FUNC_ENTRY("CATRomSymbol::ParseSymbolFromLine");
+	if ( pSymbol == NULL )
+		return;
+	size_t s,x;
+	string temp;
+	// address.
+	x = sLine.find( ' ' );
+	temp = sLine.substr( 0, x );
+	pSymbol->iStartAddress = CATBase::_httoi( temp.c_str() );
+	// "Erase spaces" move starting point.
+	s = x;
+	s = sLine.find_first_not_of( ' ', s );
+	// length.
+	x = sLine.find( ' ', s );
+	temp = sLine.substr(s,x-s);
+	unsigned long length = CATBase::_httoi( temp.c_str() );
+	pSymbol->iEndAddress = pSymbol->iStartAddress + length;
+	// "Erase spaces" move starting point.
+	s = x;
+	s = sLine.find_first_not_of( ' ', s);
+	// function. Function might have spaces so we find 2 spaces which indicates end of it.
+	x = sLine.find( "  ", s );
+	temp = sLine.substr( s, x-s );
+	pSymbol->sFunction = temp;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::GetError
+// Get error string if error occured in other methods.
+// -----------------------------------------------------------------------------
+string CATRomSymbol::GetError( void )
+{
+	LOG_FUNC_ENTRY("CATRomSymbol::GetError");
+	return m_sErrorMessage;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::Close
+// Close (stop using).
+// -----------------------------------------------------------------------------
+bool CATRomSymbol::Close( void )
+{
+	LOG_FUNC_ENTRY("CATRomSymbol::Close");
+	return true;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::AddressToLine
+// Try locate binary and function name for given memory address.
+// -----------------------------------------------------------------------------
+bool CATRomSymbol::AddressToLine( CATMemoryAddress* result )
+{
+	LOG_LOW_FUNC_ENTRY("CATRomSymbol::AddressToLine");
+	// Have symbols been read.
+	if ( ! m_bSymbolsRead )
+		return false;
+	// check that its lenght > 2
+	if ( result->GetAddressString().size() < 2 )
+		return false;
+	/* Check first is address in range of rom */
+	if ( result->GetAddress() < m_iRomStartAddress
+		|| result->GetAddress() > m_iRomEndAddress )
+	{
+		return AddressToLineRofs( result );		
+	}
+	return AddressToLineRom( result );
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::AddressToLineRom
+// Locate function from rom address range.
+// -----------------------------------------------------------------------------
+bool CATRomSymbol::AddressToLineRom( CATMemoryAddress* result )
+{
+	LOG_LOW_FUNC_ENTRY( "CATRomSymbol::AddressToLineRom" );
+	// Address to find in integer & string.
+	unsigned long iAddressToFind = result->GetAddress();
+	string sAddressToFind = result->GetAddressString();
+	
+	// Find symbol.
+	Symbol* pFound = NULL;
+
+	// Check from cache first.
+	vector<Symbol*>::iterator it;
+	for ( it = m_vRomCache.begin(); it != m_vRomCache.end(); it++ )
+	{
+		if ( iAddressToFind >= (*it)->iStartAddress
+			&& (*it)->iEndAddress > iAddressToFind )
+		{
+			pFound = *it;
+			break;
+		}
+	}
+	
+	if ( pFound == NULL )
+	{
+		// From all symbols.
+		bool reverse = false;
+		int offSetFromStart = iAddressToFind - m_iRomStartAddress;
+		int offSetFromEnd = m_iRomEndAddress - iAddressToFind;
+		if ( offSetFromEnd < offSetFromStart ) 
+			reverse = true;
+		
+		if ( reverse )
+		{
+			// Iterate vector in reverse.
+			vector<Symbol*>::reverse_iterator it;
+			for ( it = m_vRomSymbols.rbegin(); it != m_vRomSymbols.rend(); ++it )
+			{
+				if ( iAddressToFind >= (*it)->iStartAddress
+					&& (*it)->iEndAddress > iAddressToFind )
+				{
+					pFound = *it;
+					break;
+				}
+			}
+		}
+		else
+		{
+			// Iterate vector normal direction.
+			vector<Symbol*>::iterator it;
+			for ( it = m_vRomSymbols.begin(); it != m_vRomSymbols.end(); it++ )
+			{
+				if ( iAddressToFind >= (*it)->iStartAddress
+					&& (*it)->iEndAddress > iAddressToFind )
+				{
+					pFound = *it;
+					break;
+				}
+			}
+		}
+	}
+
+	// Set result if found.
+	if ( pFound != NULL )
+	{
+		result->SetFunctionName( pFound->sFunction );
+		result->SetAddressToLineState( CATMemoryAddress::SYMBOL );
+		// Add found symbols pointer to cache.
+		m_vRomCache.push_back( pFound );
+		return true;
+	}
+	return false;
+}
+
+// -----------------------------------------------------------------------------
+// CATRomSymbol::AddressToLineRofs
+// Locate function from rofs address range.
+// -----------------------------------------------------------------------------
+bool CATRomSymbol::AddressToLineRofs( CATMemoryAddress* result)
+{
+	LOG_LOW_FUNC_ENTRY("CATRomSymbol::AddressToLineRofs");
+	// Check that binary name is defined in memory address.
+	string sBinary = result->GetModuleName();
+	if ( sBinary.empty() )
+		return false;
+	// Try find that named module.
+	vector<RofsBinary*>::iterator rofs = m_vRofsBinaries.begin();
+	while( rofs != m_vRofsBinaries.end() )
+	{
+		if ( (*rofs)->m_sBinary.compare( sBinary ) == 0 )
+			break;
+		rofs++;
+	}
+	if ( rofs == m_vRofsBinaries.end() )
+		return false;
+
+	// Offset what we are looking from binary
+	unsigned long offSet = result->GetAddress();
+	offSet -= result->GetModuleStartAddress();
+	for( vector<Symbol*>::iterator it = (*rofs)->vSymbols.begin() ;
+		it != (*rofs)->vSymbols.end(); it++ )
+	{
+		if ( (*it)->iStartAddress <= offSet && offSet < (*it)->iEndAddress )
+		{
+			result->SetFunctionName( (*it)->sFunction );
+			result->SetAddressToLineState( CATMemoryAddress::SYMBOL );
+			return true;
+		}
+	}
+	return false;
+}
+
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/helps.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,205 @@
+/*
+* 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 help texts for CLE.
+*
+*/
+#include "../inc/ATCommonDefines.h"
+
+//Function declarations
+void print_help( void );
+void print_syntax_examples( void );
+
+/**
+* Print help info.
+*/
+void print_help( void )
+{
+	cout<< "S60 AnalyzeTool v";
+	cout<< ATOOL_VERSION;
+	cout<< " - ";
+	cout<< ATOOL_DATE;
+	cout<< "\n";
+	cout<< "Copyright (c) 2009 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";
+#ifdef HTI_SUPPORT
+	cout<< "      -g [data-file]\n";
+#endif
+	cout<< "      -a data-file [output-file] [-s symbol-file] [-l#]\n";
+	cout<< "      -p data-file output-file\n";
+#ifdef HTI_SUPPORT
+	cout<< "      -delete data-file\n";
+#endif
+	cout<< "      -c\n";
+	cout<< "      -v\n";
+	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<< " 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";
+	cout<< "                 command, which includes supported platform and build type.\n";
+	cout<< " -a              Analyze report file.\n";
+	cout<< " -c              Clear AnalyzeTool changes, temporary files and releasable(s).\n";
+	cout<< " -p              Parse trace file to data file.\n";
+#ifdef HTI_SUPPORT
+	cout<< " -g              Get analyze reports from device. Without the file name\n";
+	cout<< "                 gives a list of available files. If file name * all available\n";
+	cout<< "                 files on device are saved to current directory.\n";
+	cout<< " -delete         Delete datafile from the phone.\n";
+#endif
+	cout<< " -help           Show full help including syntax examples.\n";
+	cout<< " -v              Print version info.\n";
+	cout<< "\n";
+
+	cout<< "Optional parameters:\n";
+	cout<< " -acs size       Specifies the call stack size gathered when memory\n";
+	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<< "                 (50 chars max). Cannot contain path.\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";
+	cout<< "                 Multiple -s options can be given.\n";
+	cout<< " -nobuild        Instruments the project.\n";
+	//cout<< "  -show_debug       Print debug messages to console.\n";
+	//cout<< "  -show_debug_all	  Print debug messages to console (all).\n";
+	//cout<< "  -show_dbgview     Print debug messages to windows debug api.\n";
+	//cout<< "  -show_dbgview_all Print debug messages to windows debug api (all).\n";
+
+	/*
+	* Old style parameters, just for notes.
+	printf("Usage:\n");
+	printf("atool -m [mmp-file] [mode] [data-file] [-variant variant-name] [build] [-sbs2] [-e]\n");
+	printf("      -i [mmp-file] [mode] [data-file] [-variant variant-name] [build] [-sbs2] [-e]\n");
+#ifdef HTI_SUPPORT
+	printf("      -g [data-file]\n");
+#endif
+	printf("      -a [mmp-file | target-name] data-file [-s symbol-file]\n");
+	printf("         [output-file] [-l#]\n");
+	printf("      -p data-file [output-file]\n");
+#ifdef HTI_SUPPORT
+	printf("      -delete data-file\n");
+#endif
+	printf("      -c\n");
+	//printf("      -u\n");
+	printf("      -v\n");
+	printf("      -help\n");
+	printf("\n");
+	printf("Mandatory option to choose:\n");
+	printf("  -m           Build project for analysis.\n");
+	printf("  -i           Instrument project.\n");
+	printf("  -a           Analyze report file.\n");
+	//printf("  -u           Create listing & map files.\n");
+	printf("  -c           Clear AnalyzeTool changes and temporary files.\n");
+	printf("  -p           Parse trace file.\n");
+#ifdef HTI_SUPPORT
+	printf("  -g           Get analyze reports from phone. Without the file name\n");
+	printf("               gives a list of available files.\n");
+#endif
+#ifdef HTI_SUPPORT
+	printf("  -delete      Delete datafile from the phone.\n");
+#endif
+	printf("  -help        Show full help including syntax examples.\n");
+	printf("\n");
+
+	printf("Optional options:\n");
+	printf("  mmp-file     Specifies one of the component from bld.inf which is used.\n");
+	printf("  target-name  Specifies the target name of binary to which create\n");
+	printf("               analyze report.\n");
+	printf("  mode         Logging mode (XTI or S60), default XTI.\n");
+	printf("  data-file    Specifies the user defined data file name (50 chars max).\n");
+	printf("  build        Build target (udeb or urel), default udeb.\n");
+	printf("  output-file  Specifies the results data file name.\n");
+	printf("  -l           Logging level of analyze report(0,1,2,3), default 3.\n");
+	printf("  -variant     Specifies Symbian binary variant to be used.\n");
+	printf("  variant-name Specifies the variant name to be used.\n");
+	printf("  -s           Specifies rom symbol file be used in analyze.\n");
+	printf("  symbol-file  Full path to rom symbol file used in analyze.\n");
+	printf("  -sbs2        Use Symbian Build System v.2.\n");
+	printf("  -winscw      Build project for emulator (winscw platform).\n");
+	printf("  -v           Print version info.\n");
+	*/
+}
+
+void print_syntax_examples( void )
+{
+//Helper line showing width of 80 chars.
+//80cout<< "12345678901234567890123456789012345678901234567890123456789012345678901234567890";
+	cout<< endl;
+	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<< "      udeb build type and armv5 platform." << endl;
+
+	cout<< "atool -mi -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<< "      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 -e -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<< "      udeb build type and armv5 platform." << endl;
+	
+	cout<< "atool -e 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<< "atool -me 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<< 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<< "      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;
+
+	cout<< endl;
+	cout<< "Analyzing syntax examples:" << endl;
+	cout<< "Cmd   Description" << endl;
+	cout<< "atool -a foo.dat" << endl;
+	cout<< "      Create analyze report from foo.dat device data file." << endl;
+	cout<< "atool -a foo.trace" << endl;
+	cout<< "      Create analyze report from foo.trace raw data file." << endl;
+	cout<< "atool -a foo.dat -s my_rom.symbol -s my_rofs1.symbol" << endl;
+	cout<< "      Create analyze report from foo.dat using also rom and rofs symbol files." << endl;
+	
+	cout<< endl;
+	cout<< "Parsing syntax examples:" << endl;
+	cout<< "Cmd   Description" << endl;
+	cout<< "atool -p foo.trace foo.dat" << endl;
+	cout<< "      Parse foo.trace raw data file to foo.dat device data file." << endl;
+	}
+
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/librarychecks.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,193 @@
+/*
+* 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 functions to check AT libraries.
+*
+*/
+#include "../inc/ATCommonDefines.h"
+#include "../inc/CATBase.h"
+
+// Function declarations
+bool CheckATLibrariesArmv5( string sEpocRoot );
+bool CheckATLibrariesArmv5Abiv2( string sEpocRoot );
+bool CheckATLibrariesWinscw( string sEpocRoot );
+
+// Error msg to user if missing lib
+const char cMissingAToolLibs[] = "\nCan not find AnalyzeTool libraries from current SDK\n\nInstall libraries first\n";
+
+// List of libraries what AnalyzeTool needs when compiled applications on armv5 platform
+const string cAToolLibsArmv5[] = {
+	"epoc32\\RELEASE\\armv5\\LIB\\AToolMemoryHook.lib",
+	"epoc32\\RELEASE\\armv5\\udeb\\AtoolStaticLib.lib",
+	"epoc32\\RELEASE\\armv5\\urel\\AtoolStaticLib.lib"
+};
+
+// List of libraries what AnalyzeTool needs when compiled applications on armv5 platform (using sbs2 / ABIV2 binaries)
+const string cAToolLibsArmv5Abiv2[] = {
+	"epoc32\\RELEASE\\armv5\\LIB\\AToolMemoryHook.dso",
+	"epoc32\\RELEASE\\armv5\\udeb\\AtoolStaticLib.lib",
+	"epoc32\\RELEASE\\armv5\\urel\\AtoolStaticLib.lib"
+};
+
+// List of libraries what AnalyzeTool needs when compiled applications on winscw platform
+const string cAToolLibsWinscw[] = {
+	"epoc32\\RELEASE\\winscw\\udeb\\AToolMemoryHook.lib",
+	"epoc32\\RELEASE\\winscw\\udeb\\AtoolStaticLib.lib",
+	"epoc32\\RELEASE\\winscw\\urel\\AtoolStaticLib.lib"
+};
+
+/**
+* CheckATLibrariesArmv5
+* Checks that armv5 libraries are in sEpocRoot
+* @param sEpocRoot, epoc root where to search libs
+* @return bool true if they are found otherwise false
+*/
+bool CheckATLibrariesArmv5(string sEpocRoot )
+{
+	LOG_FUNC_ENTRY("CheckATLibrariesArmv5");
+
+	// check that epocroot is set
+	if ( sEpocRoot.length() <= 0 )
+	{
+		LOG_FUNC_EXIT("CheckATLibrariesArmv5 Error, EpocRoot not set");
+		return false;
+	}
+
+	// add trailing '\' if root path is missing it
+	if ( sEpocRoot.at( sEpocRoot.length() -1 ) != '\\' )
+		sEpocRoot.append( "\\" );
+
+	// return boolean value
+	bool bReturn = true;
+
+	int arraySize = sizeof( cAToolLibsArmv5 ) / sizeof( string );
+	for ( int i=0 ; i < arraySize ; i++ )
+	{
+		// append epocroot to file
+		string sFileToCheck = sEpocRoot;
+		sFileToCheck.append( cAToolLibsArmv5[i] );
+		// check does it exists
+		if ( ! CATBase::FileExists( sFileToCheck.c_str() ) )
+		{
+			bReturn = false;
+			cout << AT_MSG << "Missing library file: " << sFileToCheck << endl;
+			LOG_STRING("Missing library file: " << sFileToCheck);
+		}
+	}
+
+	if ( ! bReturn )
+	{
+		// print error msg to user
+		cout << cMissingAToolLibs;
+
+	}
+	return bReturn;
+}
+
+/**
+* CheckATLibrariesArmv5Abiv2
+* Checks that armv5 abiv2 libraries are in sEpocRoot
+* @param sEpocRoot, epoc root where to search libs
+* @return bool true if they are found otherwise false
+*/
+bool CheckATLibrariesArmv5Abiv2(string sEpocRoot )
+{
+	LOG_FUNC_ENTRY("CheckATLibrariesArmv5Abiv2");
+
+	// check that epocroot is set
+	if ( sEpocRoot.length() <= 0 )
+	{
+		LOG_FUNC_EXIT("CheckATLibrariesArmv5Abiv2 Error, EpocRoot not set");
+		return false;
+	}
+
+	// add trailing '\' if root path is missing it
+	if ( sEpocRoot.at( sEpocRoot.length() -1 ) != '\\' )
+		sEpocRoot.append( "\\" );
+
+	// return boolean value
+	bool bReturn = true;
+
+	int arraySize = sizeof( cAToolLibsArmv5Abiv2 ) / sizeof( string );
+	for ( int i=0 ; i < arraySize ; i++ )
+	{
+		// append epocroot to file
+		string sFileToCheck = sEpocRoot;
+		sFileToCheck.append( cAToolLibsArmv5Abiv2[i] );
+		// check does it exists
+		if ( ! CATBase::FileExists( sFileToCheck.c_str() ) )
+		{
+			bReturn = false;
+			cout << AT_MSG << "Missing library file: " << sFileToCheck << endl;
+			LOG_STRING("Missing library file: " << sFileToCheck);
+		}
+	}
+
+	if ( ! bReturn )
+	{
+		// print error msg to user
+		cout << cMissingAToolLibs;
+
+	}
+	return bReturn;
+}
+
+/**
+* CheckATLibrariesWinscw
+* Checks that winscw libraries are in sEpocRoot
+* @param sEpocRoot, epoc root where to search libs
+* @return bool true if they are found otherwise false
+*/
+bool CheckATLibrariesWinscw(string sEpocRoot )
+{
+	LOG_FUNC_ENTRY("CheckATLibrariesWinscw");
+
+	// check that epocroot is set
+	if ( sEpocRoot.length() <= 0 )
+	{
+		LOG_FUNC_EXIT("CheckATLibrariesArmv5Abiv2 Error, EpocRoot not set");
+		return false;
+	}
+
+	// add trailing '\' if root path is missing it
+	if ( sEpocRoot.at( sEpocRoot.length() -1 ) != '\\' )
+		sEpocRoot.append( "\\" );
+
+	// return boolean value
+	bool bReturn = true;
+
+	int arraySize = sizeof( cAToolLibsWinscw ) / sizeof( string );
+	for ( int i=0 ; i < arraySize ; i++ )
+	{
+		// append epocroot to file
+		string sFileToCheck = sEpocRoot;
+		sFileToCheck.append( cAToolLibsWinscw[i] );
+		// check does it exists
+		if ( ! CATBase::FileExists( sFileToCheck.c_str() ) )
+		{
+			bReturn = false;
+			cout << AT_MSG << "Missing library file: " << sFileToCheck << endl;
+			LOG_STRING("Missing library file: " << sFileToCheck);
+		}
+	}
+
+	if ( ! bReturn )
+	{
+		// print error msg to user
+		cout << cMissingAToolLibs;
+
+	}
+	return bReturn;
+}
+
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/stdafx.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,20 @@
+/*
+* 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 "../inc/stdafx.h"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/utility.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,38 @@
+/*
+* 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:  Miscellaneous utility functions.
+*
+*/
+#include "../inc/ATCommonDefines.h"
+#include "../inc/CATBase.h"
+#include "../inc/CATProject.h"
+
+//Analyze report logging level.
+#define MAX_LOG_LEVEL 3
+
+//Function declarations.
+bool CheckSBS2Folder( void );
+
+/**
+* Helper function which checks does current dir contain atool_temp\build folder which
+* is used in sbs2 support
+*/
+bool CheckSBS2Folder( void )
+{
+	LOG_FUNC_ENTRY("CheckSBS2Folder");
+	if ( CATBase::DirectoryExists( RAPTOR_MAKEFILE_DIR ) )
+		return true;
+	return false;
+}
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/commandlineengine/internal/src/version.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,156 @@
+/*
+* 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:  Show / Check atool version.
+*
+*/
+#include "../inc/ATCommonDefines.h"
+#include "../inc/CATBase.h"
+
+//Function declarations.
+int showVersionInfo( void );
+int showCoreVersionInfo( void );
+bool readCoreVersionInfo( const string& sFile, string& sVersion );
+string findAnalyzeToolHeader( void );
+
+//External GetEpocRoot function
+extern bool GetEpocRoot( string &sEpocRoot );
+
+void convertWriteTimeToLocalTime( FILETIME ftWrite, LPSTR lpszString );
+
+int showCoreVersionInfo( void )
+{
+	LOG_FUNC_ENTRY( "version.cpp::showCoreVersionInfo" );
+	// Try find header from environment where to locate version info.
+	string sHeaderFile = findAnalyzeToolHeader();
+	if ( sHeaderFile.empty() )
+		return 0;
+	string sVersion("");
+	if ( readCoreVersionInfo( sHeaderFile, sVersion ) )
+	{
+		cout << "AnalyzeTool SDK binaries version: " 
+			<< sVersion
+			<< endl;
+	}
+	return 0;
+}
+
+
+/**
+* Find analyzetool.h header file
+* @return string containing full path to file or empty string if not found.
+*/
+string findAnalyzeToolHeader( void )
+{
+	LOG_FUNC_ENTRY( "version.cpp::findAnalyzeToolHeader" );
+	string sEpocRoot;
+	if ( ! CATBase::GetEpocRoot( sEpocRoot ) )
+		return string("");
+	int iC = sizeof( AT_CORE_INCLUDE_FILE_WITH_VERSION_NUMBER ) / sizeof ( string );
+	for( int i = 0 ; i < iC ; i++ )
+	{
+		string sCheck( sEpocRoot );
+		sCheck.append( AT_CORE_INCLUDE_FILE_WITH_VERSION_NUMBER[i] );
+		if ( CATBase::FileExists( sCheck.c_str() ) )
+			return sCheck;
+	}
+	return string("");
+}
+/**
+* Read core version string.
+* @param sVersion string will contain version info if funtion returns true.
+* @return true if successful.
+*/
+bool readCoreVersionInfo( const string& sFile, string& sVersion )
+{
+	LOG_FUNC_ENTRY( "version.cpp::readCoreVersionInfo" );
+	try {
+		ifstream in;
+		in.open( sFile.c_str() );
+		if ( ! in.good() )
+			return false;
+		char cBuff[MAX_LINE_LENGTH];
+		while ( in.good() )
+		{
+			in.getline( cBuff, MAX_LINE_LENGTH );
+			string s( cBuff );
+			if ( s.find( AT_CORE_VERSION_NUMBER_TAG ) != string::npos )
+			{
+				// Find spot after first space (ignore first 3 chars).
+				size_t t =  s.find_first_of( ' ', 3 )+1;
+				sVersion = s.substr( t, s.size()-t );
+				return true;
+			}
+		}
+	}
+	catch(...)
+	{
+		LOG_STRING(AT_MSG << "Exception reading core version info.");
+	}
+	return false;
+}
+
+/**
+* Print version information of atool.exe binary.
+*/
+int showVersionInfo( void )
+{
+	LOG_FUNC_ENTRY( "version.cpp::showVersionInfo" );
+	string sTemp( "Version: " );
+	sTemp.append( ATOOL_VERSION );
+	sTemp.append( "\n" );
+	//Print atool version
+	printf( sTemp.c_str() );
+
+	//atool.exe:s path + filename
+	char buffer[MAX_PATH];
+
+	GetModuleFileName( NULL, buffer, MAX_PATH );
+
+	printf( "Path: %s\n", buffer );
+
+	WIN32_FIND_DATA FindFileData;
+	HANDLE hFind;
+	//Get file handle
+	hFind = FindFirstFile( buffer, &FindFileData );
+
+	if( hFind == INVALID_HANDLE_VALUE )
+	{
+		printf( "Can not find file:%s", buffer );
+		return 0;
+	}
+
+	convertWriteTimeToLocalTime( FindFileData.ftLastWriteTime , buffer );
+	printf( "Modified: %s\n", buffer );
+
+	// Show core version information.
+	showCoreVersionInfo();
+	return 0;
+}
+
+// Convert the last-write time to local time.
+void convertWriteTimeToLocalTime( FILETIME ftWrite, LPSTR lpszString )
+{
+	LOG_FUNC_ENTRY( "version.cpp::convertWriteTimeToLocalTime" );
+	SYSTEMTIME stUTC, stLocal;
+    // Convert the last-write time to local time.
+    FileTimeToSystemTime(&ftWrite, &stUTC);
+    SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
+
+    // Build a string showing the date and time.
+    wsprintf(lpszString, "%02d/%02d/%d %02d:%02d:%02d",
+        stLocal.wDay, stLocal.wMonth, stLocal.wYear,
+        stLocal.wHour, stLocal.wMinute, stLocal.wSecond);
+}
+
+//EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/data/atconfigurationappgui.l01	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,136 @@
+/*
+* 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: 
+*
+*/
+
+// localized strings for language: UK English (01)
+#define STR_ATConfigurationAppGuiApplication_2 ""
+#define STR_ATConfigurationAppGuiApplication_3 ""
+#define STR_ATConfigurationAppGuiApplication_4 "AnalyzeTool"
+#define STR_ATConfigurationAppGuiApplication_5 "AnalyzeTool"
+#define STR_ATConfigurationAppGuiApplication_1 ""
+
+#define STR_ATConfigurationAppGuiApplication_About_Dlg_Label "AnalyzeTool UI"
+#define STR_ATConfigurationAppGuiApplication_About_Dlg_Message "Version 1.8.0 - 1st December 2009. Developed by Platform RnD Tools. Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies)."
+#define STR_ATConfigurationAppGuiApplication_Error_1 "Could not establish connection to storage server"
+#define STR_ATConfigurationAppGuiApplication_Error_2 "Not supported for this process!"
+#define STR_ATConfigurationAppGuiApplication_Error_3 "Cannot start, process not found!"
+#define STR_ATConfigurationAppGuiApplication_Error_4 "Cannot stop, process not found!"
+#define STR_ATConfigurationAppGuiSofkteyOptions "Options"
+#define STR_ATConfigurationAppGuiSofkteyExit "Exit"
+#define STR_ATConfigurationAppGuiSofkteyBack "Back"
+
+//
+// Registration strings
+//
+
+// Caption string for app.
+#define qtn_caption_string "AnalyzeTool"
+
+// Short caption string for app.
+#define qtn_short_caption_string "AnalyzeTool"
+
+#define qtn_loc_resource_file_1 "\\resource\\apps\\atconfigurationappgui"
+
+//
+// Processes View
+//
+
+#define STR_ATConfigurationAppGuiListBoxView_1 ""
+#define STR_ATConfigurationAppGuiListBoxView_2 ""
+#define STR_ATConfigurationAppGuiListBoxView_3 ""
+#define STR_ATConfigurationAppGuiListBoxView_4 "AnalyzeTool UI"
+#define STR_ATConfigurationAppGuiListBoxView_5 "Help"
+#define STR_ATConfigurationAppGuiListBoxView_6 "About"
+#define STR_ATConfigurationAppGuiListBoxView_7 "Open"
+#define STR_ATConfigurationAppGuiListBoxView_8 "Start subtest"
+#define STR_ATConfigurationAppGuiListBoxView_9 "Stop subtest"
+#define STR_ATConfigurationAppGuiListBoxView_10 "Settings"
+#define STR_ATConfigurationAppGuiListBoxView_11 "Exit"
+#define STR_ATConfigurationAppGuiListBoxView_12 "End process"
+#define STR_ATConfigurationAppGuiListBoxView_13 "Kill"
+#define STR_ATConfigurationAppGuiListBoxView_14 "Terminate"
+#define STR_ATConfigurationAppGuiListBoxView_15 "Panic"
+#define STR_ATConfigurationAppGuiListBoxView_16 "End"
+#define STR_ATConfigurationAppGuiListboxNoProcesses "no processes"
+#define STR_ATConfigurationAppGuiListBoxSubtest "subtest running"
+#define STR_ATConfigurationAppGuiListBoxCancelLoggingMenuItem "Cancel logging"
+#define STR_ATConfigurationAppGuiListBoxLoggingCancelled "logging cancelled"
+#define STR_ATConfigurationAppGuiListBoxCancelFailureNote "Logging could not be cancelled!"
+
+//
+// Process View
+//
+
+#define STR_ATConfigurationAppGuiContainer2View_1 ""
+#define STR_ATConfigurationAppGuiContainer2View_2 ""
+#define STR_ATConfigurationAppGuiContainer2View_3 ""
+#define STR_ATConfigurationAppGuiContainer2View_4 "MemoryLeaker.exe"
+#define STR_ATConfigurationAppGuiContainer2View_6 "Curr. allocations:"
+#define STR_ATConfigurationAppGuiContainer2View_7 "curr. alloc. size:"
+#define STR_ATConfigurationAppGuiContainer2View_23 "subtest running"
+#define STR_ATConfigurationAppGuiContainer2View_25 "Process started:"
+#define STR_ATConfigurationAppGuiContainer2View_26 ""
+#define STR_ATConfigurationAppGuiContainer2View_29 "Logging mode:"
+#define STR_ATConfigurationAppGuiContainer2View_30 ""
+#define STR_ATConfigurationAppGuiContainer2View_31 "Mode:"
+#define STR_ATConfigurationAppGuiContainer2View_32 ""
+#define STR_ATConfigurationAppGuiContainer2View_33 "Logging file:"
+#define STR_ATConfigurationAppGuiContainer2View_34 ""
+#define STR_ATConfigurationAppGuiContainer2View_11 "Max. allocations:"
+#define STR_ATConfigurationAppGuiContainer2View_12 "max. alloc. size:"
+#define STR_ATConfigurationAppGuiContainer2View_15 "MemoryLeakerDll1.dll"
+#define STR_ATConfigurationAppGuiContainer2View_16 ""
+#define STR_ATConfigurationAppGuiContainer2View_19 "MemoryLeakerDll2.dll"
+#define STR_ATConfigurationAppGuiContainer2View_20 ""
+#define STR_ATConfigurationAppGuiContainer2View_17 "Exit"
+#define STR_ATConfigurationAppGuiContainer2View_5 "Stop subtest"
+#define STR_ATConfigurationAppGuiContainer2View_8 "View libraries"
+#define STR_ATConfigurationAppGuiContainer2View_9 "Set logging mode"
+#define STR_ATConfigurationAppGuiContainer2View_10 "Settings"
+#define STR_ATConfigurationAppGuiContainer2View_13 "Help"
+#define STR_ATConfigurationAppGuiContainer2View_21 "memoryleakerdll.dll"
+#define STR_ATConfigurationAppGuiContainer2View_24 "memoryleakerdll2.dll"
+#define STR_ATConfigurationAppGuiContainer2View_14 "Loaded libraries"
+#define STR_ATConfigurationAppGuiXtiOption "External"
+#define STR_ATConfigurationAppGuiS60Option "Internal"
+#define STR_ATConfigurationAppGuiNoneOption "None"
+#define STR_ATConfigurationAppGuiListboxNoInfo "no info"
+
+//
+// Settings View
+//
+
+#define STR_ATConfigurationAppGuiSettingItemListView_3 ""
+#define STR_ATConfigurationAppGuiSettingItemListView_4 ""
+#define STR_ATConfigurationAppGuiSettingItemListView_5 "Settings"
+#define STR_ATConfigurationAppGuiSettingItemListView_1 "Settings"
+#define STR_ATConfigurationAppGuiSettingItemListView_7 "Change"
+#define STR_ATConfigurationAppGuiSettingItemListView_2 ""
+#define STR_ATConfigurationAppGuiSettingItemListView_98 "Help"
+#define STR_ATConfigurationAppGuiSettingItemListView_99 "Exit"
+#define STR_ATConfigurationAppGuiSettingItemListView_12 "On"
+#define STR_ATConfigurationAppGuiSettingItemListView_13 "On"
+#define STR_ATConfigurationAppGuiSettingItemListView_14 "Off"
+#define STR_ATConfigurationAppGuiSettingItemListView_15 "Off"
+#define STR_ATConfigurationAppGuiSettingItemListView_16 "Warning tones"
+#define STR_ATConfigurationAppGuiSettingItemListView_147 "Update interval"
+#define STR_ATConfigurationAppGuiSettingItemListView_152 "2 seconds"
+#define STR_ATConfigurationAppGuiSettingItemListView_153 "Update interval"
+#define STR_ATConfigurationAppGuiSettingItemListView_154 "Off"
+#define STR_ATConfigurationAppGuiSettingItemListView_155 "90 secs."
+#define STR_ATConfigurationAppGuiSettingItemListView_156 "minute"
+#define STR_ATConfigurationAppGuiSettingItemListView_157 "minutes"
+#define STR_ATConfigurationAppGuiSettingItemListView_158 "seconds"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/data/atconfigurationappgui.loc.hrh	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,136 @@
+/*
+* 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: 
+*
+*/
+
+// localized strings for language: UK English (01)
+#define STR_ATConfigurationAppGuiApplication_2 ""
+#define STR_ATConfigurationAppGuiApplication_3 ""
+#define STR_ATConfigurationAppGuiApplication_4 "AnalyzeTool"
+#define STR_ATConfigurationAppGuiApplication_5 "AnalyzeTool"
+#define STR_ATConfigurationAppGuiApplication_1 ""
+
+#define STR_ATConfigurationAppGuiApplication_About_Dlg_Label "AnalyzeTool UI"
+#define STR_ATConfigurationAppGuiApplication_About_Dlg_Message "Version 1.8.0 - 1st December 2009. Developed by Platform RnD Tools. Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies)."
+#define STR_ATConfigurationAppGuiApplication_Error_1 "Could not establish connection to storage server"
+#define STR_ATConfigurationAppGuiApplication_Error_2 "Not supported for this process!"
+#define STR_ATConfigurationAppGuiApplication_Error_3 "Cannot start, process not found!"
+#define STR_ATConfigurationAppGuiApplication_Error_4 "Cannot stop, process not found!"
+#define STR_ATConfigurationAppGuiSofkteyOptions "Options"
+#define STR_ATConfigurationAppGuiSofkteyExit "Exit"
+#define STR_ATConfigurationAppGuiSofkteyBack "Back"
+
+//
+// Registration strings
+//
+
+// Caption string for app.
+#define qtn_caption_string "AnalyzeTool"
+
+// Short caption string for app.
+#define qtn_short_caption_string "AnalyzeTool"
+
+#define qtn_loc_resource_file_1 "\\resource\\apps\\atconfigurationappgui"
+
+//
+// Processes View
+//
+
+#define STR_ATConfigurationAppGuiListBoxView_1 ""
+#define STR_ATConfigurationAppGuiListBoxView_2 ""
+#define STR_ATConfigurationAppGuiListBoxView_3 ""
+#define STR_ATConfigurationAppGuiListBoxView_4 "AnalyzeTool UI"
+#define STR_ATConfigurationAppGuiListBoxView_5 "Help"
+#define STR_ATConfigurationAppGuiListBoxView_6 "About"
+#define STR_ATConfigurationAppGuiListBoxView_7 "Open"
+#define STR_ATConfigurationAppGuiListBoxView_8 "Start subtest"
+#define STR_ATConfigurationAppGuiListBoxView_9 "Stop subtest"
+#define STR_ATConfigurationAppGuiListBoxView_10 "Settings"
+#define STR_ATConfigurationAppGuiListBoxView_11 "Exit"
+#define STR_ATConfigurationAppGuiListBoxView_12 "End process"
+#define STR_ATConfigurationAppGuiListBoxView_13 "Kill"
+#define STR_ATConfigurationAppGuiListBoxView_14 "Terminate"
+#define STR_ATConfigurationAppGuiListBoxView_15 "Panic"
+#define STR_ATConfigurationAppGuiListBoxView_16 "End"
+#define STR_ATConfigurationAppGuiListboxNoProcesses "no processes"
+#define STR_ATConfigurationAppGuiListBoxSubtest "subtest running"
+#define STR_ATConfigurationAppGuiListBoxCancelLoggingMenuItem "Cancel logging"
+#define STR_ATConfigurationAppGuiListBoxLoggingCancelled "logging cancelled"
+#define STR_ATConfigurationAppGuiListBoxCancelFailureNote "Logging could not be cancelled!"
+
+//
+// Process View
+//
+
+#define STR_ATConfigurationAppGuiContainer2View_1 ""
+#define STR_ATConfigurationAppGuiContainer2View_2 ""
+#define STR_ATConfigurationAppGuiContainer2View_3 ""
+#define STR_ATConfigurationAppGuiContainer2View_4 "MemoryLeaker.exe"
+#define STR_ATConfigurationAppGuiContainer2View_6 "Curr. allocations:"
+#define STR_ATConfigurationAppGuiContainer2View_7 "curr. alloc. size:"
+#define STR_ATConfigurationAppGuiContainer2View_23 "subtest running"
+#define STR_ATConfigurationAppGuiContainer2View_25 "Process started:"
+#define STR_ATConfigurationAppGuiContainer2View_26 ""
+#define STR_ATConfigurationAppGuiContainer2View_29 "Logging mode:"
+#define STR_ATConfigurationAppGuiContainer2View_30 ""
+#define STR_ATConfigurationAppGuiContainer2View_31 "Mode:"
+#define STR_ATConfigurationAppGuiContainer2View_32 ""
+#define STR_ATConfigurationAppGuiContainer2View_33 "Logging file:"
+#define STR_ATConfigurationAppGuiContainer2View_34 ""
+#define STR_ATConfigurationAppGuiContainer2View_11 "Max. allocations:"
+#define STR_ATConfigurationAppGuiContainer2View_12 "max. alloc. size:"
+#define STR_ATConfigurationAppGuiContainer2View_15 "MemoryLeakerDll1.dll"
+#define STR_ATConfigurationAppGuiContainer2View_16 ""
+#define STR_ATConfigurationAppGuiContainer2View_19 "MemoryLeakerDll2.dll"
+#define STR_ATConfigurationAppGuiContainer2View_20 ""
+#define STR_ATConfigurationAppGuiContainer2View_17 "Exit"
+#define STR_ATConfigurationAppGuiContainer2View_5 "Stop subtest"
+#define STR_ATConfigurationAppGuiContainer2View_8 "View libraries"
+#define STR_ATConfigurationAppGuiContainer2View_9 "Set logging mode"
+#define STR_ATConfigurationAppGuiContainer2View_10 "Settings"
+#define STR_ATConfigurationAppGuiContainer2View_13 "Help"
+#define STR_ATConfigurationAppGuiContainer2View_21 "memoryleakerdll.dll"
+#define STR_ATConfigurationAppGuiContainer2View_24 "memoryleakerdll2.dll"
+#define STR_ATConfigurationAppGuiContainer2View_14 "Loaded libraries"
+#define STR_ATConfigurationAppGuiXtiOption "External"
+#define STR_ATConfigurationAppGuiS60Option "Internal"
+#define STR_ATConfigurationAppGuiNoneOption "None"
+#define STR_ATConfigurationAppGuiListboxNoInfo "no info"
+
+//
+// Settings View
+//
+
+#define STR_ATConfigurationAppGuiSettingItemListView_3 ""
+#define STR_ATConfigurationAppGuiSettingItemListView_4 ""
+#define STR_ATConfigurationAppGuiSettingItemListView_5 "Settings"
+#define STR_ATConfigurationAppGuiSettingItemListView_1 "Settings"
+#define STR_ATConfigurationAppGuiSettingItemListView_7 "Change"
+#define STR_ATConfigurationAppGuiSettingItemListView_2 ""
+#define STR_ATConfigurationAppGuiSettingItemListView_98 "Help"
+#define STR_ATConfigurationAppGuiSettingItemListView_99 "Exit"
+#define STR_ATConfigurationAppGuiSettingItemListView_12 "On"
+#define STR_ATConfigurationAppGuiSettingItemListView_13 "On"
+#define STR_ATConfigurationAppGuiSettingItemListView_14 "Off"
+#define STR_ATConfigurationAppGuiSettingItemListView_15 "Off"
+#define STR_ATConfigurationAppGuiSettingItemListView_16 "Warning tones"
+#define STR_ATConfigurationAppGuiSettingItemListView_147 "Update interval"
+#define STR_ATConfigurationAppGuiSettingItemListView_152 "2 seconds"
+#define STR_ATConfigurationAppGuiSettingItemListView_153 "Update interval"
+#define STR_ATConfigurationAppGuiSettingItemListView_154 "Off"
+#define STR_ATConfigurationAppGuiSettingItemListView_155 "90 secs."
+#define STR_ATConfigurationAppGuiSettingItemListView_156 "minute"
+#define STR_ATConfigurationAppGuiSettingItemListView_157 "minutes"
+#define STR_ATConfigurationAppGuiSettingItemListView_158 "seconds"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/data/atconfigurationappgui.rss	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,134 @@
+/*
+* 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: 
+*
+*/
+
+NAME ATCO
+
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.hrh>
+#include <eikon.rh>
+#include <appinfo.rh>
+#include <avkonicons.hrh>
+#include <data_caging_paths_strings.hrh>
+#include "atconfigurationappgui.hrh"
+#include "atconfigurationappgui.loc.hrh"
+
+RESOURCE RSS_SIGNATURE
+	{
+	}
+RESOURCE TBUF
+	{
+	buf = "AnalyzeTool";
+	}
+RESOURCE EIK_APP_INFO r_application_atconfiguration_app_gui_app_ui
+	{
+	cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+	status_pane = r_application_status_pane;
+	}
+RESOURCE STATUS_PANE_APP_MODEL r_application_status_pane
+	{
+	}
+RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info
+	{
+	short_caption = "AnalyzeTool";
+	caption_and_icon = CAPTION_AND_ICON_INFO
+		{
+		caption = "AnalyzeTool";
+
+        	number_of_icons = 1;
+
+		// Note for ROM-based apps it is recommended to add the drive letter
+		//icon_file = ""z:"APP_BITMAP_DIR"\\atconfigurationappgui_aif.mif";
+        	icon_file = APP_BITMAP_DIR"\\atconfigurationappgui_aif.mif";
+		};
+	}
+RESOURCE TBUF r_application_akn_view_reference1
+	{
+	}
+RESOURCE DIALOG r_about_heading_pane
+    {
+    flags=EEikDialogFlagNoDrag |EEikDialogFlagCbaButtons |EEikDialogFlagWait;
+    buttons = R_AVKON_SOFTKEYS_OK_EMPTY; //R_AVKON_SOFTKEYS_BACK;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                headinglayout = R_AVKON_LIST_HEADING_PANE_POPUPS;
+                label = STR_ATConfigurationAppGuiApplication_About_Dlg_Label;
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknMessageQueryContentId;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = STR_ATConfigurationAppGuiApplication_About_Dlg_Message;
+                };
+            }
+        };
+    }
+
+RESOURCE TBUF r_cant_connect_server
+    {
+    buf = STR_ATConfigurationAppGuiApplication_Error_1;
+    }
+
+RESOURCE TBUF r_cant_start_subtest_notsupported
+    {
+    buf = STR_ATConfigurationAppGuiApplication_Error_2;
+    }
+
+RESOURCE TBUF r_cant_start_subtest_processid
+    {
+    buf = STR_ATConfigurationAppGuiApplication_Error_3;
+    }
+
+RESOURCE TBUF r_cant_stop_subtest_processid
+    {
+    buf = STR_ATConfigurationAppGuiApplication_Error_4;
+    }
+
+RESOURCE CBA r_atconfiguration_app_gui_softkeys_options_exit__contextmenu
+  {
+  flags = 0;
+  buttons =
+    {
+    CBA_BUTTON {id=EAknSoftkeyOptions; txt=STR_ATConfigurationAppGuiSofkteyOptions;},
+    CBA_BUTTON {id=EAknSoftkeyExit; txt=STR_ATConfigurationAppGuiSofkteyExit;},
+    CBA_BUTTON {id=EAknSoftkeyContextOptions; txt=text_softkey_option;}
+    };
+  }
+
+RESOURCE CBA r_atconfiguration_app_gui_softkeys_options_back__contextmenu
+  {
+  flags = 0;
+  buttons =
+    {
+    CBA_BUTTON {id=EAknSoftkeyOptions; txt=STR_ATConfigurationAppGuiSofkteyOptions;},
+    CBA_BUTTON {id=EAknSoftkeyBack; txt=STR_ATConfigurationAppGuiSofkteyBack;},
+    CBA_BUTTON {id=EAknSoftkeyContextOptions; txt=text_softkey_option;}
+    };
+  }
+
+#include "atconfigurationappguilistbox.rssi"
+#include "atconfigurationappguiprocesscontainer.rssi"
+#include "atconfigurationappguisettingitemlist.rssi"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/data/atconfigurationappgui_reg.rss	Thu Feb 11 15:51:35 2010 +0200
@@ -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: 
+*
+*/
+
+
+#include <eikon.rh>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <appinfo.rh>
+#include "atconfigurationappgui.loc.hrh"
+#include <atconfigurationappgui.rsg>
+#include <data_caging_paths_strings.hrh>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x20012432
+
+RESOURCE APP_REGISTRATION_INFO
+        {
+        app_file="atconfigurationappgui";
+        localisable_resource_file =  APP_RESOURCE_DIR"\\atconfigurationappgui";
+        localisable_resource_id = R_LOCALISABLE_APP_INFO;
+        group_name = "RnD Tools";
+        }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/data/atconfigurationappguilistbox.rssi	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,150 @@
+/*
+* 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 "atconfigurationappguilistbox.hrh"
+#include "atconfigurationappgui.loc.hrh"
+
+RESOURCE AVKON_VIEW r_atconfiguration_app_gui_list_box_atconfiguration_app_gui_list_box_view
+	{
+	cba = r_atconfiguration_app_gui_softkeys_options_exit__contextmenu; //R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+	menubar = r_atconfiguration_app_gui_list_box_options_menu;
+	toolbar = 0;
+	}
+RESOURCE MENU_BAR r_atconfiguration_app_gui_list_box_options_menu
+	{titles =
+			{
+			MENU_TITLE
+			    {
+			    menu_pane = r_atconfiguration_app_gui_list_box_menu_pane1_menu_pane;
+			    }
+			};
+
+	}
+RESOURCE STATUS_PANE_APP_MODEL r_atconfiguration_app_gui_list_box_status_pane
+	{
+	panes =
+		{
+		SPANE_PANE
+		    {
+		    id = EEikStatusPaneUidTitle;
+		    type = EAknCtTitlePane;
+		    resource = r_atconfiguration_app_gui_list_box_title_resource;
+		    }
+		};
+	}
+RESOURCE TITLE_PANE r_atconfiguration_app_gui_list_box_title_resource
+	{
+	txt = STR_ATConfigurationAppGuiListBoxView_4;
+	}
+RESOURCE LISTBOX r_atconfiguration_app_gui_list_box_list_box
+	{
+	flags = EAknListBoxSelectionList;
+	}
+RESOURCE MENU_PANE r_atconfiguration_app_gui_list_box_menu_pane1_menu_pane
+	{
+	items =
+		{
+		MENU_ITEM
+		    {
+		    command = EATConfigurationAppGuiListBoxViewDetailsMenuItemCommand;
+		    txt = STR_ATConfigurationAppGuiListBoxView_7;
+		    },
+		MENU_ITEM
+		    {
+		    command = EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand;
+		    txt = STR_ATConfigurationAppGuiListBoxView_8;
+		    },
+		MENU_ITEM
+		    {
+		    command = EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand;
+		    txt = STR_ATConfigurationAppGuiListBoxView_9;
+		    },
+        MENU_ITEM
+            {
+            command = EATConfigurationAppGuiListBoxViewEnd_processMenuItemCommand;
+            txt = STR_ATConfigurationAppGuiListBoxView_12;
+            cascade = r_atconfiguration_app_gui_endtask_options_menupane;
+            },
+        MENU_ITEM
+            {
+            command = EATConfigurationAppGuiListBoxViewCancel_loggingMenuItemCommand;
+            txt = STR_ATConfigurationAppGuiListBoxCancelLoggingMenuItem;
+            },
+		MENU_ITEM
+		    {
+		    command = EATConfigurationAppGuiListBoxViewLog_settingMenuItemCommand;
+		    txt = STR_ATConfigurationAppGuiListBoxView_10;
+		    },
+		MENU_ITEM
+		    {
+		    command = EATConfigurationAppGuiListBoxViewVersionMenuItemCommand;
+		    txt = STR_ATConfigurationAppGuiListBoxView_6;
+		    },
+		MENU_ITEM
+		    {
+		    command = EATConfigurationAppGuiListBoxViewHelpMenuItemCommand;
+		    txt = STR_ATConfigurationAppGuiListBoxView_5;
+		    },
+		MENU_ITEM
+		    {
+		    command = EAknCmdExit;
+		    txt = STR_ATConfigurationAppGuiListBoxView_11;
+		    }
+		};
+	}
+
+RESOURCE MENU_PANE r_atconfiguration_app_gui_endtask_options_menupane
+    {
+    items =
+        {
+            MENU_ITEM 
+                {
+                command = EATConfigurationAppGuiListBoxViewEndTaskMenuItemCommand;
+                txt = STR_ATConfigurationAppGuiListBoxView_16;
+                },
+            MENU_ITEM 
+                {
+                command = EATConfigurationAppGuiListBoxViewKillProcessMenuItemCommand;
+                txt = STR_ATConfigurationAppGuiListBoxView_13;
+                },
+            MENU_ITEM 
+                {
+                command = EATConfigurationAppGuiListBoxViewTerminateProcessMenuItemCommand;
+                txt = STR_ATConfigurationAppGuiListBoxView_14;
+                },
+            MENU_ITEM 
+                {
+                command = EATConfigurationAppGuiListBoxViewPanicProcessMenuItemCommand;
+                txt = STR_ATConfigurationAppGuiListBoxView_15;
+                }
+        };
+    }
+
+RESOURCE TBUF r_atconfiguration_app_gui_listbox_subtest
+    {
+    buf = STR_ATConfigurationAppGuiListBoxSubtest;
+    }
+
+RESOURCE TBUF r_atconfiguration_app_gui_listbox_logging_cancelled
+    {
+    buf = STR_ATConfigurationAppGuiListBoxLoggingCancelled;
+    }
+
+RESOURCE TBUF r_atconfiguration_app_gui_listbox_cancel_failure_note
+    {
+    buf = STR_ATConfigurationAppGuiListBoxCancelFailureNote;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/data/atconfigurationappguiprocesscontainer.rssi	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,321 @@
+/*
+* 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 "atconfigurationappguiprocesscontainer.hrh"
+#include "atconfigurationappguilistbox.hrh"
+#include "atconfigurationappgui.hrh"
+#include "atconfigurationappgui.loc.hrh"
+
+RESOURCE AVKON_VIEW r_atconfiguration_app_gui_processcontainer_view
+	{
+	cba = r_atconfiguration_app_gui_softkeys_options_back__contextmenu; //R_AVKON_SOFTKEYS_OPTIONS_BACK;
+	menubar = r_atconfiguration_process_options_menu;
+	toolbar = 0;
+	}
+RESOURCE MENU_BAR r_atconfiguration_process_options_menu
+	{titles =
+			{
+			MENU_TITLE
+				{
+				menu_pane = r_atconfiguration_app_gui_process_menu_pane;
+				}
+			};
+
+	}
+RESOURCE STATUS_PANE_APP_MODEL r_atconfiguration_process_status_pane
+	{
+	panes =
+		{
+		SPANE_PANE
+			{
+			id = EEikStatusPaneUidTitle;
+			type = EAknCtTitlePane;
+			resource = r_atconfiguration_app_gui_title_resource;
+			},
+		SPANE_PANE
+			{
+			id = EEikStatusPaneUidNavi;
+			type = EAknCtNaviPane;
+			resource = r_atconfiguration_app_gui_navi_process_resource;
+			}
+		};
+	}
+RESOURCE TITLE_PANE r_atconfiguration_app_gui_title_resource
+	{
+	txt = STR_ATConfigurationAppGuiContainer2View_4;
+	}
+RESOURCE NAVI_DECORATOR r_atconfiguration_app_gui_navi_process_resource
+	{
+	type = ENaviDecoratorLabel;
+	control = NAVI_LABEL
+		{
+		txt = STR_ATConfigurationAppGuiContainer2View_23;
+		};
+	}
+RESOURCE TBUF r_atconfiguration_app_gui_navi_text1
+	{
+	buf = STR_ATConfigurationAppGuiContainer2View_23;
+	}
+RESOURCE LISTBOX r_atconfiguration_app_gui_list_box
+	{
+	flags = EAknListBoxViewerFlags; //EAknListBoxSelectionList;
+	}
+RESOURCE ARRAY r_atconfiguration_app_gui_process_listbox_item1
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_6;
+			},
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_7;
+			}
+		};
+	}
+RESOURCE ARRAY r_atconfiguration_app_gui_process_listbox_item2
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_11;
+			},
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_12;
+			}
+		};
+	}
+RESOURCE ARRAY r_atconfiguration_app_gui_process_listbox_item3
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_25;
+			},
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_26;
+			}
+		};
+	}
+RESOURCE ARRAY r_atconfiguration_app_gui_process_listbox_item4
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_29;
+			},
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_30;
+			}
+		};
+	}
+
+RESOURCE ARRAY r_atconfiguration_app_gui_process_listbox_item5
+    {
+    items =
+        {
+        LBUF
+            {
+            txt = STR_ATConfigurationAppGuiContainer2View_31;
+            },
+        LBUF
+            {
+            txt = STR_ATConfigurationAppGuiContainer2View_32;
+            }
+        };
+    }
+
+RESOURCE ARRAY r_atconfiguration_app_gui_process_listbox_item6
+    {
+    items =
+        {
+        LBUF
+            {
+            txt = STR_ATConfigurationAppGuiContainer2View_33;
+            },
+        LBUF
+            {
+            txt = STR_ATConfigurationAppGuiContainer2View_34;
+            }
+        };
+    }
+
+RESOURCE ARRAY r_atconfiguration_app_gui_listbox_item4
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_19;
+			},
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_20;
+			}
+		};
+	}
+RESOURCE ARRAY r_atconfiguration_app_gui_listbox_item3
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_15;
+			},
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_16;
+			}
+		};
+	}
+RESOURCE MENU_PANE r_atconfiguration_app_gui_process_menu_pane
+	{
+	items =
+		{
+        MENU_ITEM
+            {
+            command = EATConfigurationAppGuiProcessViewStart_subtestMenuItemCommand;
+            txt = STR_ATConfigurationAppGuiListBoxView_8;
+            },
+        MENU_ITEM
+            {
+            command = EATConfigurationAppGuiProcessViewStop_subtestMenuItemCommand;
+            txt = STR_ATConfigurationAppGuiListBoxView_9;
+            },
+		MENU_ITEM
+			{
+			command = EATConfigurationAppGuiProcessView_librariesMenuItemCommand;
+			txt = STR_ATConfigurationAppGuiContainer2View_8;
+			},
+		MENU_ITEM
+			{
+			command = EATConfigurationAppGuiProcessViewSet_logging_modeMenuItemCommand;
+			txt = STR_ATConfigurationAppGuiContainer2View_9;
+			cascade=r_atconfiguration_app_gui_radiobutton_menupane;
+			},
+		MENU_ITEM
+			{
+			command = EATConfigurationAppGuiProcessViewSettingsMenuItemCommand;
+			txt = STR_ATConfigurationAppGuiContainer2View_10;
+			},
+		MENU_ITEM
+			{
+			command = EATConfigurationAppGuiProcessViewHelpMenuItemCommand;
+			txt = STR_ATConfigurationAppGuiContainer2View_13;
+			},
+		MENU_ITEM
+			{
+			command = EATConfigurationAppGuiProcessViewExitMenuItemCommand;
+			txt = STR_ATConfigurationAppGuiContainer2View_17;
+			}
+		};
+	}
+RESOURCE AVKON_LIST_QUERY r_atconfiguration_app_gui_list_query1
+	{
+	flags = EGeneralQueryFlags;
+	softkeys = R_AVKON_SOFTKEYS_OK_EMPTY; //R_AVKON_SOFTKEYS_OK_CANCEL;
+	items =
+		{
+		AVKON_LIST_QUERY_DLG_LINE
+			{
+			control = AVKON_LIST_QUERY_CONTROL
+				{
+				listtype = EAknCtSinglePopupMenuListBox;
+				heading = STR_ATConfigurationAppGuiContainer2View_14;
+				listbox = AVKON_LIST_QUERY_LIST
+					{
+					};
+				};
+			}
+		};
+	}
+RESOURCE ARRAY r_atconfiguration_app_gui_listbox_item7
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_21;
+			}
+		};
+	}
+RESOURCE ARRAY r_atconfiguration_app_gui_listbox_item8
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiContainer2View_24;
+			}
+		};
+	}
+
+RESOURCE MENU_PANE r_atconfiguration_app_gui_radiobutton_menupane
+    {
+    items =
+        {
+            MENU_ITEM 
+                {
+                command = EATConfigurationAppGuiProcessViewEXTILogOption;
+                txt = STR_ATConfigurationAppGuiXtiOption;
+                flags = EEikMenuItemRadioStart | EEikMenuItemSymbolOn;
+                },
+            MENU_ITEM 
+                {
+                command = EATConfigurationAppGuiProcessViewES60LogOption;
+                txt = STR_ATConfigurationAppGuiS60Option;
+                },
+            MENU_ITEM 
+                {
+                command = EATConfigurationAppGuiProcessViewENoneLogOption;
+                txt = STR_ATConfigurationAppGuiNoneOption;
+                flags = EEikMenuItemRadioEnd;
+                }
+        };
+    }
+
+RESOURCE TBUF r_atconfiguration_app_gui_lbx_no_processes
+    {
+    buf = STR_ATConfigurationAppGuiListboxNoProcesses;
+    }
+
+RESOURCE TBUF r_atconfiguration_app_gui_lbx_no_info
+    {
+    buf = STR_ATConfigurationAppGuiListboxNoInfo;
+    }
+
+RESOURCE TBUF r_atconfiguration_app_xti_logging
+    {
+    buf = STR_ATConfigurationAppGuiXtiOption;
+    }
+
+RESOURCE TBUF r_atconfiguration_app_file_logging
+    {
+    buf = STR_ATConfigurationAppGuiS60Option;
+    }
+
+RESOURCE TBUF r_atconfiguration_app_none_logging
+    {
+    buf = STR_ATConfigurationAppGuiNoneOption;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/data/atconfigurationappguisettingitemlist.rssi	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,225 @@
+/*
+* 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 "atconfigurationappguisettingitemlist.hrh"
+#include "atconfigurationappgui.loc.hrh"
+
+RESOURCE AVKON_VIEW r_atconfiguration_app_gui_setting_item_list_view
+	{
+	cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;
+	menubar = r_atconfiguration_app_gui_settings_options_menu;
+	toolbar = 0;
+	}
+RESOURCE MENU_BAR r_atconfiguration_app_gui_settings_options_menu
+	{
+	titles =
+		{
+		MENU_TITLE
+			{
+			menu_pane = r_atconfiguration_app_gui_settings_menu_pane;
+			}
+		};
+	}
+RESOURCE MENU_PANE r_atconfiguration_app_gui_settings_menu_pane
+	{
+	items =
+		{
+		MENU_ITEM
+			{
+			command = EATConfigurationAppGuiSettingItemListViewMenuItem1Command;
+			txt = STR_ATConfigurationAppGuiSettingItemListView_7;
+			},
+		MENU_ITEM
+			{
+			command = EATConfigurationAppGuiSettingItemListViewHelpMenuItemCommand;
+			txt = STR_ATConfigurationAppGuiSettingItemListView_98;
+			},
+		MENU_ITEM
+			{
+			command = EATConfigurationAppGuiSettingItemListViewExitMenuItemCommand;
+			txt = STR_ATConfigurationAppGuiSettingItemListView_99;
+			}
+		};
+	}
+RESOURCE STATUS_PANE_APP_MODEL r_atconfiguration_app_gui_settings_status_pane
+	{
+	panes =
+		{
+		SPANE_PANE
+			{
+			id = EEikStatusPaneUidTitle;
+			type = EAknCtTitlePane;
+			resource = r_atconfiguration_app_gui_title_resource;
+			}
+		};
+	}
+RESOURCE TITLE_PANE r_atconfiguration_app_gui_settings_title_resource
+	{
+	txt = STR_ATConfigurationAppGuiSettingItemListView_5;
+	}
+RESOURCE AVKON_SETTING_ITEM_LIST r_atconfiguration_app_gui_setting_item_list
+	{
+	flags = EAknSettingItemNumberedStyle;
+	items =
+		{
+		AVKON_SETTING_ITEM
+			{
+			name = STR_ATConfigurationAppGuiSettingItemListView_16;
+			identifier = EATConfigurationAppGuiSettingItemListViewBinarySetting1;
+			setting_page_resource = r_atconfiguration_app_gui_binary_setting1_setting_page_resource;
+			associated_resource = r_atconfiguration_app_gui_binary_setting1;
+			},
+		AVKON_SETTING_ITEM
+			{
+			name = STR_ATConfigurationAppGuiSettingItemListView_147;
+			identifier = EATConfigurationAppGuiSettingItemListViewEnumeratedTextPopup1;
+			//setting_page_resource = r_atconfiguration_app_gui_enumerated_text_popup1_setting_page_resource;
+			//associated_resource = r_atconfiguration_app_gui_enumerated_text_popup1;
+			setting_page_resource = r_text_setting_page;
+			}
+		};
+	}
+RESOURCE AVKON_SETTING_PAGE r_text_setting_page
+    {
+    number = 1;
+    label = STR_ATConfigurationAppGuiSettingItemListView_147;
+    type = EEikCtEdwin;
+    editor_resource_id = r_settinglist_edwin;
+    }
+
+RESOURCE EDWIN r_settinglist_edwin
+    {
+    maxlength = 30;
+    }
+
+
+RESOURCE AVKON_SETTING_PAGE r_atconfiguration_app_gui_binary_setting1_setting_page_resource
+	{
+	label = STR_ATConfigurationAppGuiSettingItemListView_16;
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_atconfiguration_app_gui_binary_setting1_editor_resource_id;
+	}
+RESOURCE POPUP_SETTING_LIST r_atconfiguration_app_gui_binary_setting1_editor_resource_id
+	{
+	}
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_atconfiguration_app_gui_binary_setting1
+	{
+	setting_texts_resource = r_atconfiguration_app_gui_binary_setting1_setting_texts_resource;
+	popped_up_texts_resource = r_atconfiguration_app_gui_binary_setting1_popped_up_texts_resource;
+	}
+RESOURCE ARRAY r_atconfiguration_app_gui_binary_setting1_setting_texts_resource
+	{
+	items =
+		{
+		AVKON_ENUMERATED_TEXT
+			{
+			text = STR_ATConfigurationAppGuiSettingItemListView_12;
+			value = 1;
+			},
+		AVKON_ENUMERATED_TEXT
+			{
+			text = STR_ATConfigurationAppGuiSettingItemListView_14;
+			}
+		};
+	}
+RESOURCE ARRAY r_atconfiguration_app_gui_binary_setting1_popped_up_texts_resource
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiSettingItemListView_13;
+			},
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiSettingItemListView_15;
+			}
+		};
+	}
+RESOURCE AVKON_SETTING_PAGE r_atconfiguration_app_gui_enumerated_text_popup1_setting_page_resource
+	{
+	label = STR_ATConfigurationAppGuiSettingItemListView_147;
+	type = EAknCtPopupSettingList;
+	editor_resource_id = r_atconfiguration_app_gui_enumerated_text_popup1_editor_resource_id;
+	}
+RESOURCE POPUP_SETTING_LIST r_atconfiguration_app_gui_enumerated_text_popup1_editor_resource_id
+	{
+	}
+RESOURCE AVKON_POPUP_SETTING_TEXTS r_atconfiguration_app_gui_enumerated_text_popup1
+	{
+	setting_texts_resource = r_atconfiguration_app_gui_enumerated_text_popup1_setting_texts_resource;
+	popped_up_texts_resource = r_atconfiguration_app_gui_enumerated_text_popup1_popped_up_texts_resource;
+	}
+RESOURCE ARRAY r_atconfiguration_app_gui_enumerated_text_popup1_setting_texts_resource
+	{
+	items =
+		{
+		AVKON_ENUMERATED_TEXT
+			{
+			text = STR_ATConfigurationAppGuiSettingItemListView_152;
+			}
+		};
+	}
+RESOURCE ARRAY r_atconfiguration_app_gui_enumerated_text_popup1_popped_up_texts_resource
+	{
+	items =
+		{
+		LBUF
+			{
+			txt = STR_ATConfigurationAppGuiSettingItemListView_153;
+			}
+		};
+	}
+
+RESOURCE AVKON_SETTING_PAGE r_atconfiguration_app_gui_slider_setting_page
+    {
+    number = 2;
+    label = STR_ATConfigurationAppGuiSettingItemListView_153;
+    type = EAknCtSlider;
+    editor_resource_id = r_atconfiguration_app_gui_settinglist_slider;
+    }
+
+RESOURCE SLIDER r_atconfiguration_app_gui_settinglist_slider
+    {
+    layout = EAknSettingsItemSliderLayout;
+    minvalue = 0;
+    maxvalue = 90;
+    step = 5;
+    valuetype = EAknSliderValueDecimal;
+    minlabel = STR_ATConfigurationAppGuiSettingItemListView_154;
+    maxlabel = STR_ATConfigurationAppGuiSettingItemListView_155;
+    }
+
+RESOURCE TBUF r_atconfiguration_app_gui_setting_item_minute
+    {
+    buf = STR_ATConfigurationAppGuiSettingItemListView_156;
+    }
+
+RESOURCE TBUF r_atconfiguration_app_gui_setting_item_minutes
+    {
+    buf = STR_ATConfigurationAppGuiSettingItemListView_157;
+    }
+
+RESOURCE TBUF r_atconfiguration_app_gui_setting_item_off
+    {
+    buf = STR_ATConfigurationAppGuiSettingItemListView_154;
+    }
+
+RESOURCE TBUF r_atconfiguration_app_gui_setting_item_seconds
+    {
+    buf = STR_ATConfigurationAppGuiSettingItemListView_158;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/group/atconfigurationappgui.mmp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,70 @@
+/*
+* 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 Configuration UI.
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET			atconfigurationappgui.exe
+UID			    0x100039CE 0x20012432
+VENDORID        0
+TARGETTYPE      exe
+CAPABILITY      ALL -TCB
+EPOCSTACKSIZE   0x5000
+
+SMPSAFE
+
+APP_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc ../data ../../inc
+SOURCEPATH		../data
+
+START RESOURCE	atconfigurationappgui.rss
+HEADER
+TARGETPATH APP_RESOURCE_DIR
+END //RESOURCE
+
+START RESOURCE	atconfigurationappgui_reg.rss
+DEPENDS			atconfigurationappgui.rsg
+TARGETPATH		/private/10003a3f/apps
+END //RESOURCE
+
+LIBRARY			euser.lib apparc.lib cone.lib eikcore.lib avkon.lib apgrfx.lib
+LIBRARY			commonengine.lib efsrv.lib estor.lib eikcoctl.lib eikdlg.lib 
+LIBRARY			eikctl.lib bafl.lib fbscli.lib aknnotify.lib aknicon.lib
+LIBRARY			etext.lib gdi.lib egul.lib insock.lib charconv.lib 
+LIBRARY			ecom.lib InetProtUtil.lib http.lib esock.lib atoolstorageserverclnt.lib
+LIBRARY         flogger.lib
+
+LANG 			SC
+SOURCEPATH		../src
+
+#ifdef ENABLE_ABIV2_MODE
+DEBUGGABLE
+#endif
+
+SOURCE atconfigurationappguilistbox.cpp 
+SOURCE atconfigurationappguilistboxview.cpp 
+SOURCE atconfigurationappguiappui.cpp 
+SOURCE atconfigurationappguiapplication.cpp 
+SOURCE atconfigurationappguidocument.cpp
+SOURCE atconfigurationappguiprocessview.cpp
+SOURCE atconfigurationappguiprocesscontainer.cpp
+SOURCE atconfigurationappguisettingitemlist.cpp
+SOURCE atconfigurationappguisettingitemlistsettings.cpp
+SOURCE atconfigurationappguisettingitemlistview.cpp
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/group/atool_aif_icons.mk	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,78 @@
+#
+# 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: 
+#
+
+
+ifeq (WINS,$(findstring WINS, $(PLATFORM)))
+ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\Z
+else
+ZDIR=$(EPOCROOT)epoc32\data\z
+endif
+
+
+# ----------------------------------------------------------------------------
+# Configure these
+# ----------------------------------------------------------------------------
+
+TARGETDIR=$(ZDIR)\resource\apps
+ICONTARGETFILENAME=$(TARGETDIR)\atconfigurationappgui_aif.mif
+
+ICONDIR=..\icons
+
+do_nothing :
+	@rem do_nothing
+
+MAKMAKE : do_nothing
+
+BLD : do_nothing
+
+CLEAN : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+# ----------------------------------------------------------------------------
+# Configure these.
+#
+# NOTE 1: DO NOT DEFINE MASK FILE NAMES! They are included automatically by
+# MifConv if the mask detph is defined.
+#
+# NOTE 2: Usually, source paths should not be included in the bitmap
+# definitions. MifConv searches for the icons in all icon directories in a
+# predefined order, which is currently \s60\icons, \s60\bitmaps2.
+# The directory \s60\icons is included in the search only if the feature flag
+# __SCALABLE_ICONS is defined.
+# ----------------------------------------------------------------------------
+# NOTE: if you have JUSTINTIME enabled for your S60 3rd FP1 or newer SDK
+# and this command crashes, consider adding "/X" to the command line.
+# See <http://forum.nokia.com/document/Forum_Nokia_Technical_Library_v1_35/contents/FNTL/Build_process_fails_at_mif_file_creation_in_S60_3rd_Ed_FP1_SDK.htm>
+# ----------------------------------------------------------------------------
+
+RESOURCE : $(ICONTARGETFILENAME)
+
+$(ICONTARGETFILENAME) : $(ICONDIR)\qgn_menu_atconfigurationappgui.svg
+	mifconv $(ICONTARGETFILENAME) \
+		/c32,8 $(ICONDIR)\qgn_menu_atconfigurationappgui.svg
+		
+FREEZE : do_nothing
+
+SAVESPACE : do_nothing
+
+RELEASABLES :
+	@echo $(ICONTARGETFILENAME)
+
+FINAL : do_nothing
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/group/bld.inf	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,38 @@
+/*
+* 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 atconfigurationappgui
+*
+*/
+
+
+PRJ_PLATFORMS
+ARMV5 WINSCW
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+atconfigurationappgui.mmp
+
+#if !defined(__SERIES60_30__) && !defined(__SERIES60_31__) && !defined(__SERIES60_32__)
+	PRJ_EXTENSIONS
+	START EXTENSION s60/mifconv
+	OPTION TARGETFILE atconfigurationappgui_aif.mif
+	OPTION SOURCEDIR ../icons
+	OPTION SOURCES -c8,8 qgn_menu_atconfigurationappgui
+	END
+#else
+	gnumakefile atool_aif_icons.mk
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/icons/qgn_menu_atconfigurationappgui.svg	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 11.0, SVG Export Plug-In  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"    "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [
+	<!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
+	<!ENTITY ns_svg "http://www.w3.org/2000/svg">
+	<!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
+	<!ENTITY st0 "fill:#464646;">
+	<!ENTITY st1 "fill:url(#XMLID_1_);">
+	<!ENTITY st2 "fill:url(#XMLID_2_);">
+	<!ENTITY st3 "fill:url(#XMLID_3_);">
+	<!ENTITY st4 "fill:url(#XMLID_4_);">
+	<!ENTITY st5 "fill:url(#XMLID_5_);">
+	<!ENTITY st6 "opacity:0.75;">
+	<!ENTITY st7 "opacity:0.6;">
+	<!ENTITY st8 "fill:#FFFFFF;">
+	<!ENTITY st9 "fill:none;">
+	<!ENTITY st10 "fill:#6A6A6A;">
+]>
+<svg  xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
+	 width="44" height="44" viewBox="0 -0.00049 44 44" xml:space="preserve">
+	<defs>
+	</defs>
+	<g>
+		<rect id="_x34_4x44_1_" style="&st9;" width="44" height="43.99951"/> 
+		
+			<linearGradient id="XMLID_1_" gradientUnits="userSpaceOnUse" x1="-254.23682" y1="413.55127" x2="-243.03081" y2="373.37363" gradientTransform="matrix(1 0 0 -1 275 413.49902)">
+			<stop  offset="0" style="stop-color:#5E5F5F"/>
+			<stop  offset="0.0454" style="stop-color:#7B7C7C"/>
+			<stop  offset="0.13559" style="stop-color:#BFBFC0"/>
+			<stop  offset="0.16058" style="stop-color:#C8C8C9"/>
+			<stop  offset="0.20213" style="stop-color:#E2E2E2"/>
+			<stop  offset="0.24011" style="stop-color:#FFFFFF"/>
+			<stop  offset="0.28249" style="stop-color:#FFFFFF"/>
+			<stop  offset="0.34463" style="stop-color:#E9E9E9"/>
+			<stop  offset="0.639" style="stop-color:#919191"/>
+			<stop  offset="0.813" style="stop-color:#4A4A4A"/>
+			<stop  offset="0.9373" style="stop-color:#1E1E1E"/>
+			<stop  offset="1" style="stop-color:#0D0D0D"/>
+			<a:midPointStop  offset="0" style="stop-color:#5E5F5F"/>
+			<a:midPointStop  offset="0.53191" style="stop-color:#5E5F5F"/>
+			<a:midPointStop  offset="0.13559" style="stop-color:#BFBFC0"/>
+			<a:midPointStop  offset="0.5946" style="stop-color:#BFBFC0"/>
+			<a:midPointStop  offset="0.24011" style="stop-color:#FFFFFF"/>
+			<a:midPointStop  offset="0.5" style="stop-color:#FFFFFF"/>
+			<a:midPointStop  offset="0.28249" style="stop-color:#FFFFFF"/>
+			<a:midPointStop  offset="0.5" style="stop-color:#FFFFFF"/>
+			<a:midPointStop  offset="0.34463" style="stop-color:#E9E9E9"/>
+			<a:midPointStop  offset="0.5" style="stop-color:#E9E9E9"/>
+			<a:midPointStop  offset="0.639" style="stop-color:#919191"/>
+			<a:midPointStop  offset="0.5" style="stop-color:#919191"/>
+			<a:midPointStop  offset="0.813" style="stop-color:#4A4A4A"/>
+			<a:midPointStop  offset="0.5" style="stop-color:#4A4A4A"/>
+			<a:midPointStop  offset="0.9373" style="stop-color:#1E1E1E"/>
+			<a:midPointStop  offset="0.5" style="stop-color:#1E1E1E"/>
+			<a:midPointStop  offset="1" style="stop-color:#0D0D0D"/>
+		</linearGradient>
+		<path style="&st1;" d="M36.92383,5.26221C30.43164,3.99072,9.646,2.61426,8.85352,2.61426
+			c-0.79492,0-3.70898,0.61914-4.18652,1.08203C4.52441,3.83447,4.50928,3.83447,4.521,3.79932l0.021,0.02197
+			C6.0376,3.64063,31.68945,5.6333,35.78027,6.854c0.88086,0.73877,0.97852,3.28027,1.05566,4.36279
+			c0.2041,2.78223-0.20605,25.70459-0.38281,27.51514c-0.1709,1.74902-0.06934,2.18555-0.86816,3.38477
+			c-0.27148,0.40137-0.49414,0.63379-0.95801,0.77832c0.01074-0.00488,0.16113-0.01465,0.16797-0.0166
+			c0.94629-0.19141,4.46973-2.37891,4.78711-3.38965c0.70215-2.53906,1.25098-26.24707,0.92676-29.78955
+			C40.5332,5.6333,37.9502,5.4624,36.92383,5.26221z"/>
+		<path style="&st8;" d="M35.58301,42.1167c0.7998-1.19629,0.69922-1.63281,0.87012-3.38477
+			c0.17676-1.80762,0.63867-24.15723,0.49316-26.74756c-0.14648-2.59131-0.16406-4.43457-1.10645-5.08154
+			C34.20801,5.90625,6.39111,3.73486,4.54102,3.82129C2.69141,3.90771,2.4541,35.03369,3.56787,35.41455
+			c0.74512,1.11523,28.79736,7.42969,30.72803,7.48242C34.91797,42.94873,35.29883,42.54639,35.58301,42.1167z"/>
+		<g>
+			<path style="&st0;" d="M35.38867,12.4917c-0.06738-2.55469,0.0332-3.5127-0.82324-4.15332
+				C33.82813,7.58398,8.46094,5.00146,6.4375,5.26318C6.28711,5.28125,5.59863,5.59814,5.51514,5.63574
+				c1.2124-0.51807,27.74268,2.24072,28.48193,2.99512c0.91699,0.66309,0.75488,1.5957,0.82324,4.15137
+				c0.09766,4.25342-0.01563,22.89893-0.17188,24.5874c-0.125,3.0498-1.04199,3.67676-1.94727,3.78516
+				c0.10449-0.00684,0.20605-0.01563,0.29004-0.03125c1.12598-0.25195,2.10645-1.10938,2.22266-4.04297
+				C35.37305,35.39014,35.48633,16.74463,35.38867,12.4917z"/>
+		</g>
+		<linearGradient id="XMLID_2_" gradientUnits="userSpaceOnUse" x1="9.65381" y1="7.875" x2="35.431" y2="43.66636">
+			<stop  offset="0" style="stop-color:#FFFFFF"/>
+			<stop  offset="0.12323" style="stop-color:#F5F5F5"/>
+			<stop  offset="0.32904" style="stop-color:#DCDCDC"/>
+			<stop  offset="0.59205" style="stop-color:#B2B2B2"/>
+			<stop  offset="0.89897" style="stop-color:#797979"/>
+			<stop  offset="1" style="stop-color:#646464"/>
+			<a:midPointStop  offset="0" style="stop-color:#FFFFFF"/>
+			<a:midPointStop  offset="0.5946" style="stop-color:#FFFFFF"/>
+			<a:midPointStop  offset="1" style="stop-color:#646464"/>
+		</linearGradient>
+		<path style="&st2;" d="M34.64648,37.41064c0.16699-1.6416,0.29785-20.63672,0.19531-24.77783
+			c-0.07129-2.48877,0.09668-3.39746-0.86523-4.04297C33.2041,7.85498,6.9834,5.13428,5.71436,5.63867
+			C4.44238,6.14307,4.32178,9.37842,4.30469,19.20752c-0.0083,4.91602-0.06104,8.4541-0.02246,10.89355
+			c0.03857,2.43848,0.1665,3.77637,0.52051,4.29395c0.90088,1.25586,24.94922,6.75977,27.26953,6.71484
+			c0.18164,0.00488,0.46582,0.00391,0.71582-0.01172C33.73633,40.99268,34.5166,40.3833,34.64648,37.41064z"/>
+		<path style="&st10;" d="M34.65332,36.63135L4.2876,30.38232c0.00732,0.3125,0.01465,0.60645,0.02441,0.88086l30.1665,6.20801
+			L34.65332,36.63135z"/>
+		<path style="&st10;" d="M4.33887,26.53564l30.50293,5.66602c0.00391-0.28223,0.00977-0.57129,0.01367-0.87109l-30.5127-5.66699
+			C4.34131,25.9585,4.34033,26.25635,4.33887,26.53564z"/>
+		<path style="&st10;" d="M4.29541,22.05518l30.5415,4.94727c0.00293-0.28906,0.00488-0.57813,0.00488-0.86914L4.29834,21.18604
+			C4.29736,21.48438,4.29639,21.76904,4.29541,22.05518z"/>
+		<path style="&st10;" d="M34.87598,19.83203L4.32471,15.16455c-0.00293,0.28369-0.00537,0.56592-0.00781,0.86719l30.55615,4.66895
+			C34.87402,20.40869,34.875,20.11816,34.87598,19.83203z"/>
+		<path style="&st10;" d="M34.86133,13.73486L4.51367,9.25732C4.49219,9.52588,4.47314,9.8125,4.45557,10.11621l30.41455,4.48975
+			C34.86621,14.29297,34.86328,14.00244,34.86133,13.73486z"/>
+		<path style="&st10;" d="M7.20703,5.58984v29.81592c0.15918,0.05078,0.32568,0.10156,0.49805,0.1543V5.60889
+			C7.53125,5.60156,7.36084,5.59473,7.20703,5.58984z"/>
+		<path style="&st10;" d="M11.73145,5.87451V36.6958c0.16553,0.04297,0.32959,0.08887,0.49854,0.13086V5.91553
+			C12.06348,5.90137,11.89502,5.8877,11.73145,5.87451z"/>
+		<path style="&st10;" d="M16.48438,6.29541v31.60352c0.16602,0.04004,0.33203,0.08008,0.49854,0.11914V6.34326
+			C16.81641,6.32715,16.65039,6.31152,16.48438,6.29541z"/>
+		<path style="&st10;" d="M21.29932,6.78271v32.24609c0.16748,0.03809,0.33252,0.07617,0.49902,0.11328V6.8374
+			C21.63086,6.81885,21.4668,6.80127,21.29932,6.78271z"/>
+		<path style="&st10;" d="M26.01758,7.31689h-0.08984v32.72656c0.1709,0.03516,0.33398,0.06738,0.49902,0.10254V7.3667
+			C26.29199,7.34961,26.15625,7.33398,26.01758,7.31689z"/>
+		<path style="&st10;" d="M30.4541,7.89258v33.02197c0.17578,0.0293,0.34473,0.05566,0.49609,0.07813V7.96582
+			C30.78906,7.94141,30.62598,7.91797,30.4541,7.89258z"/>
+		<polygon style="&st6;" points="4.44287,28.65674 11.83984,22.29639 23.79395,23.24365 35.05762,13.54443 35.05762,18.50635 
+			24.83008,26.35693 12.38086,24.64111 4.51807,32.32373 "/>
+		<linearGradient id="XMLID_3_" gradientUnits="userSpaceOnUse" x1="7.729" y1="27.25049" x2="30.62796" y2="19.08257">
+			<stop  offset="0.00444" style="stop-color:#2BCD00"/>
+			<stop  offset="0.11142" style="stop-color:#31CA00"/>
+			<stop  offset="0.25605" style="stop-color:#42C200"/>
+			<stop  offset="0.42218" style="stop-color:#5FB500"/>
+			<stop  offset="0.60444" style="stop-color:#86A300"/>
+			<stop  offset="0.79974" style="stop-color:#B98B00"/>
+			<stop  offset="1" style="stop-color:#F56F00"/>
+			<a:midPointStop  offset="0.00444" style="stop-color:#2BCD00"/>
+			<a:midPointStop  offset="0.64286" style="stop-color:#2BCD00"/>
+			<a:midPointStop  offset="1" style="stop-color:#F56F00"/>
+		</linearGradient>
+		<polygon style="&st3;" points="4.25732,28.1001 11.65479,21.73926 23.60742,22.68652 34.87109,12.98682 34.87109,17.94873 
+			24.64355,25.79834 12.19531,24.08447 4.33252,31.76514 "/>
+		<g>
+			<g>
+				<polygon points="12.77197,22.94287 11.81494,23.10889 11.81494,8.8501 12.77197,8.97754 "/>
+				<path d="M19.4502,14.4375c0,0.42725-0.26758,0.77344-0.60107,0.7749l-6.4126,0.02637
+					c-0.33252,0.00146-0.60205-0.41064-0.60205-0.92139V9.81982c0-0.51025,0.26953-0.88867,0.60205-0.84424l6.4126,0.84912
+					c0.3335,0.04443,0.60107,0.42578,0.60107,0.85205V14.4375z"/>
+				
+					<radialGradient id="XMLID_4_" cx="14.23877" cy="10.93506" r="5.57665" fx="14.23877" fy="10.93506" gradientUnits="userSpaceOnUse">
+					<stop  offset="0" style="stop-color:#FFFFFF"/>
+					<stop  offset="0.08496" style="stop-color:#FFFFF5"/>
+					<stop  offset="0.22686" style="stop-color:#FEFEDC"/>
+					<stop  offset="0.40831" style="stop-color:#FDFDB2"/>
+					<stop  offset="0.62222" style="stop-color:#FBFB78"/>
+					<stop  offset="0.86064" style="stop-color:#F8F82E"/>
+					<stop  offset="1" style="stop-color:#F7F700"/>
+					<stop  offset="1" style="stop-color:#9D9A9A"/>
+					<a:midPointStop  offset="0" style="stop-color:#FFFFFF"/>
+					<a:midPointStop  offset="0.5946" style="stop-color:#FFFFFF"/>
+					<a:midPointStop  offset="1" style="stop-color:#F7F700"/>
+					<a:midPointStop  offset="0.5" style="stop-color:#F7F700"/>
+					<a:midPointStop  offset="1" style="stop-color:#9D9A9A"/>
+				</radialGradient>
+				<path style="&st4;" d="M18.77637,13.98438c0,0.34668-0.21729,0.625-0.48438,0.62207l-5.16553-0.05713
+					c-0.26807-0.00293-0.48486-0.32959-0.48486-0.72998v-3.53564c0-0.40088,0.2168-0.7002,0.48486-0.66797l5.16553,0.62158
+					c0.26709,0.03223,0.48438,0.33984,0.48438,0.68701V13.98438z"/>
+			</g>
+		</g>
+		<g>
+			<g>
+				<polygon points="25.17871,24.24854 24.22168,24.41455 24.22168,10.15576 25.17871,10.2832 "/>
+				<path d="M31.85742,15.74316c0,0.42725-0.26758,0.77344-0.60156,0.7749l-6.41211,0.02637
+					c-0.33301,0.00146-0.60254-0.41064-0.60254-0.92139v-4.49756c0-0.51025,0.26953-0.88867,0.60254-0.84424l6.41211,0.84912
+					c0.33398,0.04443,0.60156,0.42578,0.60156,0.85205V15.74316z"/>
+				
+					<radialGradient id="XMLID_5_" cx="26.64551" cy="12.24072" r="5.57665" fx="26.64551" fy="12.24072" gradientUnits="userSpaceOnUse">
+					<stop  offset="0" style="stop-color:#FFFFFF"/>
+					<stop  offset="0.08496" style="stop-color:#FFFFF5"/>
+					<stop  offset="0.22686" style="stop-color:#FEFEDC"/>
+					<stop  offset="0.40831" style="stop-color:#FDFDB2"/>
+					<stop  offset="0.62222" style="stop-color:#FBFB78"/>
+					<stop  offset="0.86064" style="stop-color:#F8F82E"/>
+					<stop  offset="1" style="stop-color:#F7F700"/>
+					<stop  offset="1" style="stop-color:#9D9A9A"/>
+					<a:midPointStop  offset="0" style="stop-color:#FFFFFF"/>
+					<a:midPointStop  offset="0.5946" style="stop-color:#FFFFFF"/>
+					<a:midPointStop  offset="1" style="stop-color:#F7F700"/>
+					<a:midPointStop  offset="0.5" style="stop-color:#F7F700"/>
+					<a:midPointStop  offset="1" style="stop-color:#9D9A9A"/>
+				</radialGradient>
+				<path style="&st5;" d="M31.18359,15.29004c0,0.34668-0.21777,0.625-0.48438,0.62207l-5.16602-0.05713
+					c-0.26758-0.00293-0.48438-0.32959-0.48438-0.72998v-3.53564c0-0.40088,0.2168-0.7002,0.48438-0.66797l5.16602,0.62158
+					c0.2666,0.03223,0.48438,0.33984,0.48438,0.68701V15.29004z"/>
+			</g>
+		</g>
+	</g>
+</svg>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappgui.hrh	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,23 @@
+/*
+* 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:
+*
+*/
+
+enum TATConfigurationAppGuiViewUids
+    {
+    EATConfigurationAppGuiListBoxViewId = 1,
+    EATConfigurationAppGuiProcessViewId,
+    EATConfigurationAppGuiSettingItemListViewId
+    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappgui.pan	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,34 @@
+/*
+* 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 ATCONFIGURATIONAPPGUI_PAN_H
+#define ATCONFIGURATIONAPPGUI_PAN_H
+
+/** ATConfigurationAppGui application panic codes */
+enum TATConfigurationAppGuiPanics
+    {
+    EATConfigurationAppGuiUi = 1
+    // add further panics here
+    };
+
+inline void Panic(TATConfigurationAppGuiPanics aReason)
+    {
+    _LIT(applicationName,"ATConfigurationAppGui");
+    User::Panic(applicationName, aReason);
+    }
+
+#endif // ATCONFIGURATIONAPPGUI_PAN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguiapplication.h	Thu Feb 11 15:51:35 2010 +0200
@@ -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: 
+*
+*/
+
+#ifndef ATCONFIGURATIONAPPGUIAPPLICATION_H
+#define ATCONFIGURATIONAPPGUIAPPLICATION_H
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+const TUid KUidATConfigurationAppGuiApplication = { 0x20012432/*0xEBE42C45*/ };
+
+/**
+ *
+ * @class CATConfigurationAppGuiApplication ATConfigurationAppGuiApplication.h
+ * @brief A CAknApplication-derived class is required by the S60 application 
+ *          framework. It is subclassed to create the application's document 
+ *          object.
+ */
+class CATConfigurationAppGuiApplication : public CAknApplication
+    {
+public:
+    /**
+    * From CEikApplication.
+    */
+    //CDictionaryStore* OpenIniFileLC( RFs& aFs ) const;
+private:
+    /**
+    * From CApaApplication.
+    */
+    TUid AppDllUid() const;
+    /**
+    * From CEikApplication.
+    */
+    CApaDocument* CreateDocumentL();
+    };
+            
+#endif // ATCONFIGURATIONAPPGUIAPPLICATION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguiappui.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,233 @@
+/*
+* 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 ATCONFIGURATIONAPPGUIAPPUI_H
+#define ATCONFIGURATIONAPPGUIAPPUI_H
+
+// INCLUDES
+#include <aknviewappui.h>
+#include <analyzetool/atstorageserverclnt.h>
+#include <analyzetool/atcommon.h>
+#include <analyzetool/analyzetool.h>
+
+// FORWARD DECLARATIONS
+class CApaApplication;
+class CATConfigurationAppGuiListBoxView;
+class CATConfigurationAppGuiProcessView;
+//class CATConfigurationAppGuiSettingItemListView;
+
+// CONSTANTS
+const TUint32 KATHundred = 100;
+const TUint32 KATThousand = 1000;
+const TUint32 KATMillion = 1000000;
+_LIT( KATB, "B" );
+_LIT( KATKB, "KB" );
+_LIT( KATMB, "MB" );
+
+/**
+ * @class CATConfigurationAppGuiAppUi ATConfigurationAppGuiAppUi.h
+ * @brief The AppUi class handles application-wide aspects of the user interface, including
+ *        view management and the default menu, control pane, and status pane.
+ */
+class CATConfigurationAppGuiAppUi : public CAknViewAppUi
+    {
+public: 
+    /**
+    * C++ default constructor.
+    */
+    CATConfigurationAppGuiAppUi();
+    
+    /**
+    * Destructor.
+    */
+    virtual ~CATConfigurationAppGuiAppUi();
+    
+    /**
+    * ConstructL.
+    */
+    void ConstructL();
+
+public:
+    /**
+    * From CCoeAppUi.
+    */
+    TKeyResponse HandleKeyEventL(
+                const TKeyEvent& aKeyEvent,
+                TEventCode aType );
+
+    /**
+    * from CEikAppUi.
+    */
+    void HandleCommandL( TInt aCommand );
+    
+    /**
+    * From CEikAppUi.
+    */
+    void HandleResourceChangeL( TInt aType );
+
+    /**
+    * From CAknAppUi.
+    */
+    void HandleViewDeactivation( 
+            const TVwsViewId& aViewIdToBeDeactivated, 
+            const TVwsViewId& aNewlyActivatedViewId );
+    
+    /**
+    * Returns handle to the storage server
+    * @return RATStorageServer handle to the storage server
+    */  
+    inline RATStorageServer StorageServer()
+        {
+        return iStorageServer;    
+        }
+    
+    /**
+    * Sets current process's process ID.
+    * @param aProcessId current process's process ID
+    */
+    inline void SetCurrentProcessId( TUint aProcessId )
+        {
+        iCurrentProcessId = aProcessId;
+        }
+    
+    /**
+    * Gets current process ID.
+    * @return TUint process ID
+    */
+    inline TUint GetCurrentProcessId()
+        {
+        return iCurrentProcessId;    
+        }
+    
+    /**
+    * Sets member variable's process start time.
+    * @param aProcessStartTime current process's start time
+    */
+    inline void SetCurrentProcessStartTime( TInt64 aProcessStartTime )
+        {
+        iCurrentProcessStartTime = aProcessStartTime;
+        }
+    
+    /**
+    * Get current opened process's start time.
+    * @return TInt64 start time presented in microseconds
+    */
+    inline TInt64 GetCurrentProcessStartTime()
+        {
+        return iCurrentProcessStartTime;    
+        }
+
+    /**
+    * Starts a subtest for a process.
+    * @param aProcessId ID of the process
+    */
+    void SetProcessSubTestStartL( TUint aProcessId );
+    
+    /**
+    * Stops a subtest for a process.
+    * @param aProcessId ID of the process
+    */
+    
+    void SetProcessSubTestStopL( TUint aProcessId );
+    
+    /**
+    * Checks if subtest is running for a process.
+    * @param aProcessId ID of the process
+    * @return The index of the first matching aProcessId 
+    * within the array. KErrNotFound, if no matching 
+    * aProcessId can be found.
+    */
+    TInt IsSubTestRunning( TUint aProcessId );
+
+    /**
+    * Loads application settings.
+    * @return TInt KErrNone if loading succeeds.
+    */
+    TInt LoadSettingsL();
+    
+    /**
+    * Shows error note.
+    * @param aResourceId resource id of the text which
+    * is to be shown to the user.
+    */    
+    void ShowErrorNoteL( TInt aResourceId );
+
+    /**        
+    * From CEikAppUi.
+    */      
+    void HandleForegroundEventL( TBool aForeground );
+    
+
+    /**        
+    * Starts periodic timer with an interval.
+    */      
+    void StartTimerL();
+
+    /**        
+    * Periodic timer's callback function.
+    * @param ptr TAny pointer.
+    * @return TInt KErrNone.
+    */      
+    static TInt CallBackFunctionL( TAny* ptr )
+        {
+        ( static_cast<CATConfigurationAppGuiAppUi*>( ptr ) )->TimerNotifyL( ETrue );
+        return KErrNone;
+        };
+
+    /**        
+    * Periodic timer's notify function.
+    * @param aPeriod ETrue if certain time interval is reached, EFalse otherwise.
+    */        
+    void TimerNotifyL( TBool aPeriod );
+ 
+    /**        
+    * Stops all the subtests currently running.
+    */   
+    void StopAllSubtestsL();
+
+private:
+    /**
+    * Constructs needed components in the AppUi.
+    */
+    void InitializeContainersL();
+    
+private:
+    // Processes view pointer
+    CATConfigurationAppGuiListBoxView* iATConfigurationAppGuiListBoxView;
+    // Process view pointer
+    CATConfigurationAppGuiProcessView* iATConfigurationAppGuiProcessView;
+    // Settings view pointer
+    //CATConfigurationAppGuiSettingItemListView* iATConfigurationAppGuiSettingItemListView; 
+    // Handle to the RATStorageServer
+    RATStorageServer iStorageServer;
+    // Current process ID
+    TUint iCurrentProcessId;
+    // Current process's start time
+    TInt64 iCurrentProcessStartTime;
+    // Warning tones setting
+    TInt iWarningTones;
+    // Update interval setting
+    TInt iUpdateInterval;
+    // array containing all the processes which subtest is running
+    RArray<TUint> iSubTestProcesses;
+    // Periodic timer to handle timer events
+    CPeriodic*  iPeriodicTimer;
+    // Deactivated view's Id
+    TVwsViewId  iDeactivatedId;
+    };
+
+#endif // ATCONFIGURATIONAPPGUIAPPUI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguidocument.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,62 @@
+/*
+* 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 ATCONFIGURATIONAPPGUIDOCUMENT_H
+#define ATCONFIGURATIONAPPGUIDOCUMENT_H
+
+// INCLUDES
+#include <akndoc.h>
+
+// FORWARD DECLARATIONS
+class CEikAppUi;
+
+/**
+* @class CATConfigurationAppGuiDocument ATConfigurationAppGuiDocument.h
+* @brief A CAknDocument-derived class is required by the S60 application 
+*           framework. It is responsible for creating the AppUi object. 
+*/
+class CATConfigurationAppGuiDocument : public CAknDocument
+    {
+public: 
+    /**
+    * Creates new document object.
+    * @param aApp Reference to the CEikApplication
+    * @return CATConfigurationAppGuiDocument* pointer to the
+    * newly created document class.
+    */
+    static CATConfigurationAppGuiDocument* NewL( CEikApplication& aApp );
+
+private: 
+    /**
+    * C++ default constructor.
+    * @param aApp Reference to the CEikApplication
+    */
+    CATConfigurationAppGuiDocument( CEikApplication& aApp );
+    
+    /**
+    * ConstructL.
+    */
+    void ConstructL();
+    
+public: 
+
+    /**
+    * From CEikDocument.
+    */
+    CEikAppUi* CreateAppUiL();
+    };
+#endif // ATCONFIGURATIONAPPGUIDOCUMENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguilistbox.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,236 @@
+/*
+* 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 ATCONFIGURATIONAPPGUILISTBOX_H
+#define ATCONFIGURATIONAPPGUILISTBOX_H
+
+// INCLUDES
+#include <coecntrl.h>        
+#include <analyzetool/atstorageserverclnt.h>
+
+#include "atconfigurationappguilistboxview.h"
+
+// FORWARD DECLARATIONS
+class MEikCommandObserver;        
+class CAknDoubleStyleListBox;
+class CEikTextListBox;
+
+/**
+ * Container class for ATConfigurationAppGuiListBox
+ * 
+ * @class CATConfigurationAppGuiListBox ATConfigurationAppGuiListBox.h
+ */
+class CATConfigurationAppGuiListBox : public CCoeControl, public MEikListBoxObserver
+    {
+public:
+    /**
+    * C++ default constructor.
+    */
+    CATConfigurationAppGuiListBox();
+
+    /**
+    * Two-phased constructor that can leave.
+    * @return A new instance of this class
+    */
+    static CATConfigurationAppGuiListBox* NewL( 
+        const TRect& aRect, 
+        CATConfigurationAppGuiListBoxView* aParent, 
+        MEikCommandObserver* aCommandObserver );
+
+    /**
+    * Two-phased constructor that can leave and leaves a pointer
+    * on the cleanup stack.
+    * @return A new instance of this class
+    */
+    static CATConfigurationAppGuiListBox* NewLC( 
+        const TRect& aRect, 
+        CATConfigurationAppGuiListBoxView* aParent, 
+        MEikCommandObserver* aCommandObserver );
+ 
+    /**
+    *  Symbian 2nd phase constructor.
+    */
+    void ConstructL( 
+        const TRect& aRect, 
+        CATConfigurationAppGuiListBoxView* aParent, 
+        MEikCommandObserver* aCommandObserver );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CATConfigurationAppGuiListBox();
+
+public:
+
+    /**
+    * From CCoeControl.
+    */
+    TInt CountComponentControls() const;
+    
+    /**
+    * From CCoeControl.
+    */
+    CCoeControl* ComponentControl( TInt aIndex ) const;
+    
+    /**
+    * From CCoeControl.
+    */
+    TKeyResponse OfferKeyEventL( 
+            const TKeyEvent& aKeyEvent, 
+            TEventCode aType );
+    
+    /**
+    * From CCoeControl.
+    */
+    void HandleResourceChange( TInt aType );
+    
+    /**
+    * Updates view's components.
+    */
+    void UpdateViewL();
+
+    /**
+    * From CCoeControl.
+    */
+    void HandlePointerEventL( const TPointerEvent& aPointerEvent );
+
+    /**
+    * From MEikListBoxObserver.
+    */    
+    void HandleListBoxEventL( CEikListBox* aListBox, TListBoxEvent aEventType );
+    
+protected:
+    /**
+    * From CCoeControl.
+    */
+    void SizeChanged();
+
+private:
+    /**
+    * From CCoeControl.
+    */
+    void Draw( const TRect& aRect ) const;
+
+private:
+    /**
+    * Initializes all the controls in the class.
+    */
+    void InitializeControlsL();
+    
+    /**
+    * Layouts controls according to the screen size.
+    */
+    void LayoutControls();
+    
+    // Active control
+    CCoeControl* iFocusControl;
+    // Command observer
+    MEikCommandObserver* iCommandObserver;
+public:
+    /**
+    * Adds an item to the listbox.
+    * @param aListBox pointer to the listbox
+    * @param aString a text about to be shown in the listbox.
+    */
+    static void AddListBoxItemL( 
+            CEikTextListBox* aListBox,
+            const TDesC& aString );
+ 
+    /**
+    * Returns selected listbox items.
+    * @param aListBox pointer to the listbox
+    * @return RArray< TInt >* array of selected items
+    */
+    static RArray< TInt >* GetSelectedListBoxItemsLC( CEikTextListBox* aListBox );
+ 
+    /**
+    * Deletes selected listbox items.
+    * @param aListBox pointer to the listbox
+    */
+    static void DeleteSelectedListBoxItemsL( CEikTextListBox* aListBox );
+
+    /**
+    * Returns this controls listbox.
+    */
+    CAknDoubleStyleListBox* ListBox();
+ 
+    /**
+    * Creates listbox item from the given text.
+    * @param aBuffer text to be appended to the listbox
+    * @param aMainText a text for the first line of the item
+    * @param aSecondaryText a text for the second line of the item
+    */
+    static void CreateListBoxItemL( TDes& aBuffer, 
+            const TDesC& aMainText,
+            const TDesC& aSecondaryText );
+ 
+    /**
+    * Starts adding listbox items from the resource.
+    * @param aResourceId resource id of the text
+    */
+    void AddListBoxResourceArrayItemL( TInt aResourceId );
+ 
+    /**
+    * Setups listbox icons.
+    */
+    void SetupListBoxIconsL();
+    
+    /**
+    * Handles listbox command.
+    * @param aCommand command id
+    */
+    TBool HandleMarkableListCommandL( TInt aCommand );
+ 
+    /**
+    * Gets current highlighted listbox index.
+    * @return TInt listbox index
+    */
+    TInt GetCurrentItemIndex();
+ 
+    /**
+    * Updates processes in the view.
+    */
+    void UpdateProcessesL();
+    
+private: 
+    // Listbox
+    CAknDoubleStyleListBox* iListBox;
+    
+    // Array of processes under testing
+    RArray<TATProcessInfo> iProcesses;
+    CATConfigurationAppGuiListBoxView* iParent;
+public:
+    /**
+    * @enum TControls
+    * Defines controls.
+    */
+    enum TControls
+        {
+        EListBox,       /**< Listbox control. */
+        ELastControl    /**< Last control in the view. */
+        };
+    /**
+    * @enum TListBoxImages
+    * Defines listbox icons.
+    */
+    enum TListBoxImages
+        {
+        EListBoxFirstUserImageIndex /**< First icon in listbox. */
+        };
+    };
+                
+#endif // ATCONFIGURATIONAPPGUILISTBOX_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguilistbox.hrh	Thu Feb 11 15:51:35 2010 +0200
@@ -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: 
+*
+*/
+
+enum TATConfigurationAppGuiListBoxViewCommands
+    {
+    EATConfigurationAppGuiListBoxViewDetailsMenuItemCommand = 0x6000,
+    EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand,
+    EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand,
+    EATConfigurationAppGuiListBoxViewEnd_processMenuItemCommand,
+    EATConfigurationAppGuiListBoxViewEndTaskMenuItemCommand,
+    EATConfigurationAppGuiListBoxViewKillProcessMenuItemCommand,
+    EATConfigurationAppGuiListBoxViewTerminateProcessMenuItemCommand,
+    EATConfigurationAppGuiListBoxViewPanicProcessMenuItemCommand,
+    EATConfigurationAppGuiListBoxViewCancel_loggingMenuItemCommand,
+    EATConfigurationAppGuiListBoxViewLog_settingMenuItemCommand,
+    EATConfigurationAppGuiListBoxViewVersionMenuItemCommand,
+    EATConfigurationAppGuiListBoxViewHelpMenuItemCommand,
+    EATConfigurationAppGuiListBoxViewExitMenuItemCommand
+    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguilistboxview.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,144 @@
+/*
+* 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 ATCONFIGURATIONAPPGUILISTBOXVIEW_H
+#define ATCONFIGURATIONAPPGUILISTBOXVIEW_H
+
+// INCLUDES
+#include <aknview.h>
+
+// FORWARD DECLARATIONS
+class CATConfigurationAppGuiListBox;
+
+/**
+ * Avkon view class for ATConfigurationAppGuiListBoxView. It is register with the view server
+ * by the AppUi. It owns the container control.
+ * @class CATConfigurationAppGuiListBoxView ATConfigurationAppGuiListBoxView.h
+ */
+class CATConfigurationAppGuiListBoxView : public CAknView
+    {
+public:
+    /**
+    * C++ default constructor.
+    */
+    CATConfigurationAppGuiListBoxView();
+    
+    /**
+    * Two-phased constructor that can leave.
+    * @return A new instance of this class
+    */
+    static CATConfigurationAppGuiListBoxView* NewL();
+    
+    /**
+    * Two-phased constructor that can leave and leaves a pointer
+    * on the cleanup stack.
+    * @return A new instance of this class
+    */
+    static CATConfigurationAppGuiListBoxView* NewLC();
+    
+    /**
+    *  Symbian 2nd phase constructor.
+    */
+    void ConstructL();
+    
+    /**
+    * Destructor.
+    */
+    virtual ~CATConfigurationAppGuiListBoxView();
+                        
+    /**
+    * From CAknView.
+    */
+    TUid Id() const;
+    
+    /**
+    * From CAknView.
+    */
+    void HandleCommandL( TInt aCommand );
+    
+    /**
+    * Creates control for this view.
+    * @return CATConfigurationAppGuiListBox* pointer to the control
+    */
+    CATConfigurationAppGuiListBox* CreateContainerL();
+    
+    /**
+    * From CAknView.
+    */
+    void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+    
+    /**
+    * Launches view's menu.
+    */
+    //void LaunchMenuL();
+ 
+    /**
+    * Updates view.
+    */
+    void UpdateViewL();
+
+    /**
+    * Ends a process with a certain method.
+    * @param aCommand command id
+    */
+    void EndProcessL( TInt aCommand );
+    
+protected:
+    
+    /**
+    * From CAknView.
+    */
+    void DoActivateL(
+        const TVwsViewId& aPrevViewId,
+        TUid aCustomMessageId,
+        const TDesC8& aCustomMessage );
+    
+    /**
+    * From CAknView.
+    */
+    void DoDeactivate();
+    
+    /**
+    * Setups status pane according to the screen size.
+    */
+    void HandleStatusPaneSizeChange();
+    
+    /**
+    * Handles About -menu item execution.
+    * @param aCommand command id
+    * @return TBool not used
+    */
+    TBool HandleVersionMenuItemSelectedL( TInt aCommand );
+    
+private:
+    
+    /**
+    * Setups status pane.
+    */
+    void SetupStatusPaneL();
+    
+    /**
+    * Clears status pane and frees resources from it.
+    */
+    void CleanupStatusPane();
+    
+    // Pointer to the control class
+    CATConfigurationAppGuiListBox* iATConfigurationAppGuiListBox;
+    
+    };
+
+#endif // ATCONFIGURATIONAPPGUILISTBOXVIEW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguiprocesscontainer.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,229 @@
+/*
+* 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 ATCONFIGURATIONAPPGUIPROCESSCONTAINER_H
+#define ATCONFIGURATIONAPPGUIPROCESSCONTAINER_H
+
+//INCLUDES
+#include <coecntrl.h>
+
+#include "atconfigurationappguiprocessview.h"
+
+// FORWARD DECLARATIONS
+class MEikCommandObserver;		
+class CAknDoubleStyleListBox;
+class CEikTextListBox;
+
+/**
+ * Container class for CATConfigurationAppGuiProcessContainer
+ * 
+ * @class	CATConfigurationAppGuiProcessContainer
+ */
+class CATConfigurationAppGuiProcessContainer : public CCoeControl
+	{
+public:
+    /**
+    * C++ default constructor.
+    */
+	CATConfigurationAppGuiProcessContainer();
+	
+    /**
+    * Two-phased constructor that can leave.
+    * @return A new instance of this class
+    */
+	static CATConfigurationAppGuiProcessContainer* NewL( 
+		const TRect& aRect, 
+		CATConfigurationAppGuiProcessView* aParent, 
+		MEikCommandObserver* aCommandObserver, TUint aProcessId, TInt64 aProcessStartTime );
+	
+    /**
+    * Two-phased constructor that can leave and leaves a pointer
+    * on the cleanup stack.
+    * @return A new instance of this class
+    */
+	static CATConfigurationAppGuiProcessContainer* NewLC( 
+		const TRect& aRect, 
+		CATConfigurationAppGuiProcessView* aParent, 
+		MEikCommandObserver* aCommandObserver, TUint aProcessId, TInt64 aProcessStartTime );
+	
+    /**
+    *  Symbian 2nd phase constructor.
+    */
+	void ConstructL( 
+		const TRect& aRect, 
+		CATConfigurationAppGuiProcessView* aParent, 
+		MEikCommandObserver* aCommandObserver, TUint aProcessId, TInt64 aProcessStartTime );
+	
+    /**
+    * Destructor.
+    */
+	virtual ~CATConfigurationAppGuiProcessContainer();
+	
+    /**
+    * Updates view components.
+    */
+	void UpdateViewL();
+
+public:
+
+    /**
+    * From CCoeControl.
+    */
+	TInt CountComponentControls() const;
+
+    /**
+    * From CCoeControl.
+    */
+	CCoeControl* ComponentControl( TInt aIndex ) const;
+	
+    /**
+    * From CCoeControl.
+    */
+	TKeyResponse OfferKeyEventL( 
+			const TKeyEvent& aKeyEvent, 
+			TEventCode aType );
+	
+    /**
+    * From CCoeControl.
+    */
+	void HandleResourceChange( TInt aType );
+	
+protected:
+
+    /**
+    * From CCoeControl.
+    */
+	void SizeChanged();
+
+private:
+
+    /**
+    * From CCoeControl.
+    */
+	void Draw( const TRect& aRect ) const;
+
+private:
+    
+    /**
+    * Initializes all the controls in the class.
+    */
+	void InitializeControlsL();
+    /**
+    * Layouts controls according to the screen size.
+    */
+	void LayoutControls();
+	
+    // Active control
+	CCoeControl* iFocusControl;
+    // Command observer
+	MEikCommandObserver* iCommandObserver;
+	CATConfigurationAppGuiProcessView* iParent;
+
+public: 
+    
+    /**
+    * Adds an item to the listbox.
+    * @param aListBox pointer to the listbox
+    * @param aString a text about to be shown in the listbox.
+    */
+	static void AddListBoxItemL( 
+			CEikTextListBox* aListBox,
+			const TDesC& aString );
+	
+    /**
+    * Returns selected listbox items.
+    * @param aListBox pointer to the listbox
+    * @return RArray< TInt >* array of selected items
+    */
+	static RArray< TInt >* GetSelectedListBoxItemsLC( CEikTextListBox* aListBox );
+	
+    /**
+    * Deletes selected listbox items.
+    * @param aListBox pointer to the listbox
+    */
+	static void DeleteSelectedListBoxItemsL( CEikTextListBox* aListBox );
+	
+    /**
+    * Returns this controls listbox.
+    */
+	CAknDoubleStyleListBox* ListBox();
+	
+    /**
+    * Creates listbox item from the given text.
+    * @param aBuffer text to be appended to the listbox
+    * @param aMainText a text for the first line of the item
+    * @param aSecondaryText a text for the second line of the item
+    */
+	static void CreateListBoxItemL( TDes& aBuffer, 
+			const TDesC& aMainText,
+			const TDesC& aSecondaryText );
+	
+    /**
+    * Starts adding listbox items from the resource.
+    * @param aResourceId resource id of the text
+    */
+	void AddListBoxResourceArrayItemL( TInt aResourceId );
+	
+    /**
+    * Setups listbox icons.
+    */
+	void SetupListBoxIconsL();
+	
+    /**
+    * Handles listbox command.
+    * @param aCommand command id
+    */
+	TBool HandleMarkableListCommandL( TInt aCommand );
+	
+    /**
+    * Gets current highlighted listbox index.
+    * @return TInt listbox index
+    */
+	TInt GetCurrentItemIndex();
+	
+private: 
+    
+    // Listbox
+	CAknDoubleStyleListBox* iListBox;
+	// Id of the opened process
+	TUint iProcessId;
+	// Starting time of the opened process
+	TInt64 iProcessStartTime;
+
+protected: 
+	
+public: 
+    /**
+    * @enum TControls
+    * Defines controls.
+    */
+	enum TControls
+		{
+		EListBox,     /**< Listbox control. */
+		ELastControl  /**< Last control in the view. */
+		};
+    /**
+    * @enum TListBoxImages
+    * Defines listbox icons.
+    */
+	enum TListBoxImages
+		{
+		EListBoxFirstUserImageIndex   /**< First icon in listbox. */
+		};
+	};
+				
+#endif // ATCONFIGURATIONAPPGUIPROCESSCONTAINER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguiprocesscontainer.hrh	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,30 @@
+/*
+* 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:
+*
+*/
+
+enum TATConfigurationAppGuiProcessViewCommands
+	{
+	EATConfigurationAppGuiProcessViewStart_subtestMenuItemCommand = 0x6000,
+	EATConfigurationAppGuiProcessViewStop_subtestMenuItemCommand,
+	EATConfigurationAppGuiProcessView_librariesMenuItemCommand,
+	EATConfigurationAppGuiProcessViewSet_logging_modeMenuItemCommand,
+	EATConfigurationAppGuiProcessViewSettingsMenuItemCommand,
+	EATConfigurationAppGuiProcessViewHelpMenuItemCommand,
+	EATConfigurationAppGuiProcessViewExitMenuItemCommand,
+	EATConfigurationAppGuiProcessViewEXTILogOption,
+	EATConfigurationAppGuiProcessViewES60LogOption,
+	EATConfigurationAppGuiProcessViewENoneLogOption
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguiprocessview.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,180 @@
+/*
+* 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 ATCONFIGURATIONAPPGUIPROCESSVIEW_H
+#define ATCONFIGURATIONAPPGUIPROCESSVIEW_H
+
+// INCLUDES
+#include <aknview.h>
+#include <analyzetool/atstorageserverclnt.h>
+#include <analyzetool/atcommon.h>
+
+// FORWARD DECLARATIONS
+class CAknNavigationDecorator;
+class CATConfigurationAppGuiProcessContainer;
+
+/**
+ * Avkon view class for CATConfigurationAppGuiProcessView. It is register with the view server
+ * by the AppUi. It owns the container control.
+ * @class	CATConfigurationAppGuiProcessView
+ */
+class CATConfigurationAppGuiProcessView : public CAknView
+	{
+public:
+    /**
+    * C++ default constructor.
+    */
+	CATConfigurationAppGuiProcessView();
+	
+    /**
+    * Two-phased constructor that can leave.
+    * @return A new instance of this class
+    */
+	static CATConfigurationAppGuiProcessView* NewL();
+	
+    /**
+    * Two-phased constructor that can leave and leaves a pointer
+    * on the cleanup stack.
+    * @return A new instance of this class
+    */
+	static CATConfigurationAppGuiProcessView* NewLC();
+	
+    /**
+    *  Symbian 2nd phase constructor.
+    */
+	void ConstructL();
+	
+    /**
+    * Destructor.
+    */
+	virtual ~CATConfigurationAppGuiProcessView();
+						
+    /**
+    * From CAknView.
+    */
+	TUid Id() const;
+	
+    /**
+    * From CAknView.
+    */
+	void HandleCommandL( TInt aCommand );
+	
+    /**
+    * From CAknView.
+    */
+	void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+    /**
+    * Creates control for this view.
+    * @return CATConfigurationAppGuiListBox* pointer to the control
+    */
+	CATConfigurationAppGuiProcessContainer* CreateContainerL();
+	
+    /**
+    * Creates an item for list query dialog.
+    * @param aBuffer buffer holding the text
+    * @param aMainText listbox text
+    */
+	void CreateListQuery1ItemL( 
+			TDes& aBuffer,
+			const TDesC& aMainText );
+	
+    /**
+    * Creates list item from resource.
+    * @param aBuffer buffer holding the text
+    * @param aResourceId resource id
+    */
+	void CreateListQuery1ResourceArrayItemL( 
+			TDes& aBuffer, 
+			TInt aResourceId );
+
+    /**
+    * Initializes components in the list query.
+    * @return CDesCArray* array of list items
+    */
+	CDesCArray* InitializeListQuery1LC();
+
+    /**
+    * Initializes icons in the list query.
+    * @return CArrayPtr< CGulIcon >* icon array
+    */
+	CArrayPtr< CGulIcon >* SetupListQuery1IconsLC();
+
+    /**
+    * Executes list query including DLLs in a particular process.
+    * @param aOverrideText heading for the list query
+    * @param aOverrideItemArray array holding DLLs
+    * @param aOverrideIconArray array holding icons
+    */
+	TInt RunListQueryL(
+			const TDesC* aOverrideText = NULL, 
+			CDesCArray* aOverrideItemArray = NULL,
+			CArrayPtr< CGulIcon >* aOverrideIconArray = NULL );
+	
+protected:
+    /**
+    * From CAknView.
+    */
+	void DoActivateL(
+		const TVwsViewId& aPrevViewId,
+		TUid aCustomMessageId,
+		const TDesC8& aCustomMessage );
+	
+    /**
+    * From CAknView.
+    */
+	void DoDeactivate();
+	
+    /**
+    * Setups status pane according to the screen size.
+    */
+	void HandleStatusPaneSizeChange();
+private:
+    /**
+    * Setups status pane.
+    */
+	void SetupStatusPaneL();
+	
+    /**
+    * Clears status pane and frees resources from it.
+    */
+	void CleanupStatusPaneL();
+
+	// Current navi decorator
+	CAknNavigationDecorator* iNaviDecorator_;
+	// Control for this view
+	CATConfigurationAppGuiProcessContainer* iProcessContainer;
+	// Logging option for this process
+	TInt   iLogOption;
+	// Process Id of current process
+	TUint  iProcessId;
+	// Starting time of current process
+	TInt64 iProcessStartTime;
+	// Loaded libraries for this process
+	RArray< TBuf8<KMaxLibraryName> > iLibraries;
+	
+    /**
+    * @enum TListQuery1Images
+    * Defines icons for list query.
+    */
+	enum TListQuery1Images
+		{
+		EListQuery1FirstUserImageIndex    /**< First icon in listbox. */
+		};
+	};
+
+#endif // ATCONFIGURATIONAPPGUIPROCESSVIEW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguisettingitemlist.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,101 @@
+/*
+* 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 ATCONFIGURATIONAPPGUISETTINGITEMLIST_H
+#define ATCONFIGURATIONAPPGUISETTINGITEMLIST_H
+
+// INCLUDES
+#include <aknsettingitemlist.h>
+
+// FORWARD DECLARATIONS
+class MEikCommandObserver;
+class CATConfigurationAppGuiSettingItemListSettings;
+
+/**
+ * @class	CATConfigurationAppGuiSettingItemList 
+ */
+class CATConfigurationAppGuiSettingItemList : public CAknSettingItemList
+	{
+public: // constructors and destructor
+    /**
+    * C++ default constructor.
+    * @param aSettings setting list
+    * @param aCommandObserver command observer
+    */
+	CATConfigurationAppGuiSettingItemList( 
+	        CATConfigurationAppGuiSettingItemListSettings& aSettings, 
+			MEikCommandObserver* aCommandObserver );
+	
+    /**
+    * Destructor.
+    */
+	virtual ~CATConfigurationAppGuiSettingItemList();
+
+public:
+
+    /**
+    * From CCoeControl.
+    */
+	void HandleResourceChange( TInt aType );
+
+    /**
+    * From CAknSettingItemList.
+    */
+	CAknSettingItem* CreateSettingItemL( TInt id );
+	
+    /**
+    * From CAknSettingItemList.
+    */
+	void EditItemL( TInt aIndex, TBool aCalledFromMenu );
+	
+    /**
+    * From CCoeControl.
+    */
+	TKeyResponse OfferKeyEventL( 
+			const TKeyEvent& aKeyEvent, 
+			TEventCode aType );
+
+public:
+    /**
+    * Handles changing a setting value from the menu.
+    */
+	void ChangeSelectedItemL();
+
+    /**
+    * Loads stored setting values.
+    */
+	void LoadSettingValuesL();
+	
+    /**
+    * Stores settings.
+    */
+	void SaveSettingValuesL();
+		
+private:
+    /**
+    * From CAknSettingItemList.
+    */
+	void SizeChanged();
+
+private:
+	// Current settings values
+    CATConfigurationAppGuiSettingItemListSettings& iSettings;
+    // Command observer
+	MEikCommandObserver* iCommandObserver;
+	
+	};
+#endif // ATCONFIGURATIONAPPGUISETTINGITEMLIST_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguisettingitemlist.hrh	Thu Feb 11 15:51:35 2010 +0200
@@ -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:
+*
+*/
+
+enum TATConfigurationAppGuiSettingItemListViewCommands
+	{
+	EATConfigurationAppGuiSettingItemListViewMenuItem1Command = 0x6000,
+	EATConfigurationAppGuiSettingItemListViewHelpMenuItemCommand,
+	EATConfigurationAppGuiSettingItemListViewExitMenuItemCommand
+	};
+enum TATConfigurationAppGuiSettingItemListViewItems
+	{
+	EATConfigurationAppGuiSettingItemListViewBinarySetting1 = 1,
+	EATConfigurationAppGuiSettingItemListViewEnumeratedTextPopup1
+	};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguisettingitemlistsettings.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,98 @@
+/*
+* 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 ATCONFIGURATIONAPPGUISETTINGITEMLISTSETTINGS_H
+#define ATCONFIGURATIONAPPGUISETTINGITEMLISTSETTINGS_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+/**
+ * @class	CATConfigurationAppGuiSettingItemListSettings
+ */
+class CATConfigurationAppGuiSettingItemListSettings: public CBase
+	{
+public:
+
+    /**
+    * Two-phased constructor that can leave.
+    * @return A new instance of this class
+    */
+	static CATConfigurationAppGuiSettingItemListSettings* NewL();
+	
+    /**
+    *  Symbian 2nd phase constructor.
+    */
+	void ConstructL();
+		
+private:
+    
+    /**
+    * C++ default constructor.
+    */
+	CATConfigurationAppGuiSettingItemListSettings();
+public:
+    
+    /**
+    * Returns value of binary setting 1.
+    * @return TBool& reference to selected binary setting
+    */
+	TBool& BinarySetting1();
+	
+    /**
+    * Sets binary 1 setting value
+    * @param aValue binary value to be set
+    */
+	void SetBinarySetting1( const TBool& aValue );
+	
+    /**
+    * Returns enumerated text value from first popup setting.
+    * @return TDes& reference to selected text
+    */
+	TDes& EnumeratedTextPopup1();
+	
+    /**
+    * Returns the value of application's update interval.
+    * @return TInt update interval
+    */
+	TInt UpdateInterval();
+	
+    /**
+    * Sets value of the update interval
+    * @param aUpdate update interval value to be set
+    */
+	void SetUpdateIntervalL( TInt aUpdate );
+	
+    /**
+    * Sets value of the enumerated text value for
+    * first popup settting.
+    * @param aValue text value to be set
+    */
+	void SetEnumeratedTextPopup1L( const TDesC& aValue );
+	
+protected:
+    // First binary setting value
+	TBool iBinarySetting1;
+	// Value of the update interval
+	TInt iUpdateInterval;
+	// Temporary buffer holding setting text shown
+	// to the user
+	TBuf<50> iTemp;
+	
+	};
+#endif // ATCONFIGURATIONAPPGUISETTINGITEMLISTSETTINGS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/inc/atconfigurationappguisettingitemlistview.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,123 @@
+/*
+* 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 ATCONFIGURATIONAPPGUISETTINGITEMLISTVIEW_H
+#define ATCONFIGURATIONAPPGUISETTINGITEMLISTVIEW_H
+
+// INCLUDES
+#include <aknview.h>
+#include "atconfigurationappguisettingitemlistsettings.h"
+
+// FORWARD DECLARATIONS
+class CATConfigurationAppGuiSettingItemList;
+
+/**
+ * Avkon view class for CATConfigurationAppGuiSettingItemListView. It is register with the view server
+ * by the AppUi. It owns the container control.
+ * @class	CATConfigurationAppGuiSettingItemListView
+ */						
+			
+class CATConfigurationAppGuiSettingItemListView : public CAknView
+	{
+public:
+    /**
+    * C++ default constructor.
+    */
+	CATConfigurationAppGuiSettingItemListView();
+	
+    /**
+    * Two-phased constructor that can leave.
+    * @return A new instance of this class
+    */
+	static CATConfigurationAppGuiSettingItemListView* NewL();
+	
+    /**
+    * Two-phased constructor that can leave and leaves a pointer
+    * on the cleanup stack.
+    * @return A new instance of this class
+    */
+	static CATConfigurationAppGuiSettingItemListView* NewLC();  
+	
+    /**
+    *  Symbian 2nd phase constructor.
+    */
+	void ConstructL();
+	
+    /**
+    * Destructor.
+    */
+	virtual ~CATConfigurationAppGuiSettingItemListView();
+						
+    /**
+    * From CAknView.
+    */
+	TUid Id() const;
+	
+    /**
+    * From CAknView.
+    */
+	void HandleCommandL( TInt aCommand );
+	
+protected:
+    
+    /**
+    * From CAknView.
+    */
+	void DoActivateL(
+		const TVwsViewId& aPrevViewId,
+		TUid aCustomMessageId,
+		const TDesC8& aCustomMessage );
+	
+    /**
+    * From CAknView.
+    */
+	void DoDeactivate();
+	
+    /**
+    * Setups status pane according to the screen size.
+    */
+	void HandleStatusPaneSizeChange();
+	
+    /**
+    * Handles changing of a selected setting item.
+    * @param aCommand command id
+    * @return TBool ETrue if setting change successful
+    */
+	TBool HandleChangeSelectedSettingItemL( TInt aCommand );
+	
+private:
+    
+    /**
+    * Setups status pane.
+    */
+	void SetupStatusPaneL();
+	
+    /**
+    * Clears status pane and frees resources from it.
+    */
+	void CleanupStatusPane();
+	
+	// Setting item list
+	CATConfigurationAppGuiSettingItemList* iATConfigUISettingItemList;
+	// Values of the settings
+	CATConfigurationAppGuiSettingItemListSettings* iSettings;
+	// Id of the view which was previously active
+	TUid   iLastViewId;
+	
+	};
+
+#endif // ATCONFIGURATIONAPPGUISETTINGITEMLISTVIEW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/sis/atconfigurationappgui.pkg	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,54 @@
+;
+; 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:
+;
+; ATConfigurationAppGui.pkg
+; This is an auto-generated PKG file by Carbide.
+; This file uses variables specific to Carbide builds that will not work
+; on command-line builds. If you want to use this generated PKG file from the
+; command-line tools you will need to modify the variables with the appropriate
+; values: $(EPOCROOT), $(PLATFORM), $(TARGET)
+; Also, the resource file entries should be changed to match the language
+; used in the build. For example, if building for LANGUAGE_01, change the file
+; extensions .rsc to .r01.
+;
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"ATConfigurationAppGui"},(0x20012432),1,8,0
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+;Supports S60 release 5.0
+[0x1028315F], 0, 0, 0, {"Series60ProductID"}
+
+;Files to install
+;You should change the source paths to match that of your environment
+;<source> <destination>
+"\epoc32\release\armv5\urel\atconfigurationappgui.exe"		-"!:\sys\bin\atconfigurationappgui.exe"
+"\epoc32\data\z\resource\apps\atconfigurationappgui.rsc"		-"!:\resource\apps\atconfigurationappgui.rsc"
+"\epoc32\data\z\private\10003a3f\apps\atconfigurationappgui_reg.rsc"	-"!:\private\10003a3f\import\apps\atconfigurationappgui_reg.rcs"
+"\epoc32\data\z\resource\apps\atconfigurationappgui_aif.mif" -"!:\resource\apps\atconfigurationappgui_aif.mif"
+;"\epoc32\data\z\resource\apps\atconfigurationappgui.mbm" -"!:\resource\apps\atconfigurationappgui.mbm"
+; Add any installation notes if applicable
+;"atconfigurationappgui.txt"					  -"!:\private\0x20012432\atconfigurationappgui.txt"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/sis/backup_registration.xml	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+  <system_backup/>
+  <restore requires_reboot = "no"/>
+</backup_registration>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/src/atconfigurationappguiapplication.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -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 "atconfigurationappguiapplication.h"
+#include "atconfigurationappguidocument.h"
+#include "atlog.h"
+#include <eikstart.h>
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiApplication::AppDllUid()
+// Returns UID for this application (KUidATConfigurationAppGuiApplication)
+// -----------------------------------------------------------------------------
+//
+TUid CATConfigurationAppGuiApplication::AppDllUid() const
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiApplication::AppDllUid()" );
+    
+    return KUidATConfigurationAppGuiApplication;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiApplication::CreateDocumentL()
+// Returns Pointer to the created document object (CATConfigurationAppGuiDocument)
+// -----------------------------------------------------------------------------
+//
+CApaDocument* CATConfigurationAppGuiApplication::CreateDocumentL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiApplication::CreateDocumentL()" );
+    
+    return CATConfigurationAppGuiDocument::NewL( *this );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiApplication::NewApplication()
+// Returns The application (CATConfigurationAppGuiApplication)
+// -----------------------------------------------------------------------------
+//
+LOCAL_C CApaApplication* NewApplication()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiApplication::NewApplication()" );
+    
+    return new CATConfigurationAppGuiApplication;
+    }
+
+// -----------------------------------------------------------------------------
+// GLDEF_C TInt E32Main()
+// This standard export is the entry point for all Series 60 applications.
+// Returns error code
+// -----------------------------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiApplication::E32Main()" );
+    
+    return EikStart::RunApplication( NewApplication );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiApplication::OpenIniFileLC()
+// To support .ini files for storing application settings
+// -----------------------------------------------------------------------------
+//
+/*CDictionaryStore* CATConfigurationAppGuiApplication::OpenIniFileLC( RFs& aFs ) const
+    {
+    return CEikApplication::OpenIniFileLC( aFs );
+    }*/
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/src/atconfigurationappguiappui.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,554 @@
+/*
+* 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 <eikmenub.h>
+#include <akncontext.h>
+#include <akntitle.h>
+#include <atconfigurationappgui.rsg>
+#include <stringloader.h>
+#include <aknnotewrappers.h>
+#include <s32stor.h> // CDictionaryStore
+
+#include "atconfigurationappguiappui.h"
+#include "atconfigurationappgui.hrh"
+#include "atconfigurationappguilistboxview.h"
+#include "atconfigurationappguiprocessview.h"
+#include "atconfigurationappguisettingitemlistview.h"
+#include "atconfigurationappguiapplication.h"
+#include "atlog.h"
+
+#include <aknmessagequerydialog.h>
+
+// CONSTANTS
+const TInt KATDefaultUpdatingInterval = 2000000;
+_LIT8( KSubTestId, "ATConfigUiSubTest" );
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::CATConfigurationAppGuiAppUi()
+// Construct the CATConfigurationAppGuiAppUi instance
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiAppUi::CATConfigurationAppGuiAppUi()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiAppUi::CATConfigurationAppGuiAppUi()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::ConstructL()
+// Completes the second phase of Symbian object construction.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::ConstructL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiAppUi::ConstructL()" );
+    
+    BaseConstructL( EAknEnableSkin  | 
+                     EAknEnableMSK ); 
+    InitializeContainersL();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::~CATConfigurationAppGuiAppUi()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiAppUi::~CATConfigurationAppGuiAppUi()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiAppUi::~CATConfigurationAppGuiAppUi()" );
+    
+    if ( iPeriodicTimer )
+        {
+        if ( iPeriodicTimer->IsActive() )
+            {
+            iPeriodicTimer->Cancel();
+            }  
+        delete iPeriodicTimer;  
+        }
+ 
+    iSubTestProcesses.Close();
+    iStorageServer.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::InitializeContainersL()
+// Initializes all the controls.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::InitializeContainersL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiAppUi::InitializeContainersL()" );
+    
+    iPeriodicTimer = CPeriodic::New( CActive::EPriorityLow );
+        
+    iATConfigurationAppGuiListBoxView = CATConfigurationAppGuiListBoxView::NewL();
+    AddViewL( iATConfigurationAppGuiListBoxView );
+    iATConfigurationAppGuiProcessView = CATConfigurationAppGuiProcessView::NewL();
+    AddViewL( iATConfigurationAppGuiProcessView );
+    //iATConfigurationAppGuiSettingItemListView = CATConfigurationAppGuiSettingItemListView::NewL();
+    //AddViewL( iATConfigurationAppGuiSettingItemListView );
+    
+    SetDefaultViewL( *iATConfigurationAppGuiListBoxView );
+
+    TInt error = iStorageServer.Connect();
+        if ( error != KErrNone )
+            {
+            HBufC* noteText;
+            noteText = StringLoader::LoadLC( R_CANT_CONNECT_SERVER );
+            CAknErrorNote* note = new (ELeave) CAknErrorNote( ETrue );
+            note->ExecuteLD( *noteText );
+            CleanupStack::PopAndDestroy( noteText );
+            }
+    // Load application settings
+    //LoadSettingsL();
+    // Start updating the view
+    if ( iPeriodicTimer )
+        {
+        StartTimerL();    
+        }    
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::HandleCommandL()
+// Handle a command for this appui.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::HandleCommandL( TInt aCommand )
+    {
+    LOGSTR2( "ATCU CATConfigurationAppGuiAppUi::HandleCommandL(%i)", 
+			aCommand );
+    
+    TBool commandHandled = EFalse;
+    switch ( aCommand )
+        { // Code to dispatch to the AppUi's menu and CBA commands is generated here
+        default:
+            break;
+        }
+
+    if ( !commandHandled ) 
+        {
+        if ( aCommand == EAknSoftkeyExit || aCommand == EEikCmdExit )
+            {
+            // Stop all subtests before closing handles
+            StopAllSubtestsL();
+            Exit();
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::HandleResourceChangeL()
+// Override of the HandleResourceChangeL virtual function.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::HandleResourceChangeL( TInt aType )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiAppUi::HandleResourceChangeL()" );
+    
+    CAknViewAppUi::HandleResourceChangeL( aType );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::HandleKeyEventL()
+// Override of the HandleKeyEventL virtual function.
+// -----------------------------------------------------------------------------
+//
+TKeyResponse CATConfigurationAppGuiAppUi::HandleKeyEventL(
+        const TKeyEvent& /*aKeyEvent*/,
+        TEventCode /*aType*/ )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiAppUi::HandleKeyEventL()" );
+    
+    // The inherited HandleKeyEventL is private and cannot be called
+    return EKeyWasNotConsumed;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::HandleViewDeactivation()
+// Override of the HandleViewDeactivation virtual function.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::HandleViewDeactivation( 
+        const TVwsViewId& aViewIdToBeDeactivated, 
+        const TVwsViewId& aNewlyActivatedViewId )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiAppUi::HandleViewDeactivation()" );
+    
+    CAknViewAppUi::HandleViewDeactivation( 
+            aViewIdToBeDeactivated, 
+            aNewlyActivatedViewId );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::SetProcessSubTestStartL()
+// Starts subtest for a process.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::SetProcessSubTestStartL( TUint aProcessId )
+    {
+    LOGSTR2( "ATCU CATConfigurationAppGuiAppUi::SetProcessSubTestStartL(%i)", 
+    		aProcessId );
+    
+    // Load the kernel side device driver
+    TInt loadErr = User::LoadLogicalDevice( KAnalyzeToolLddName );
+    TBool driverLoaded( EFalse );
+            
+    if ( loadErr == KErrNone || loadErr == KErrAlreadyExists )
+        {
+        driverLoaded = ETrue;
+        }
+        
+    RAnalyzeTool analyzeTool;    
+    TInt driverOpen = analyzeTool.Open();
+    TInt handleCount( KErrNone );
+    
+    if ( driverOpen == KErrNone )
+        {       
+        TATProcessHandlesBuf params;
+        params().iProcessId = aProcessId;
+        
+        analyzeTool.GetCurrentHandleCount( params );
+        handleCount = params().iCurrentHandleCount;
+        LOGSTR2( "CATConfigurationAppGuiAppUi::SetProcessSubTestStartL - %i current handle(s)",
+                params().iCurrentHandleCount );       
+        }
+    
+    TInt startErr = iStorageServer.StartSubTest( aProcessId, KSubTestId, handleCount );
+    if ( KErrNone == startErr )
+        {
+        iSubTestProcesses.Append( aProcessId );    
+        }
+    else if ( KErrNotSupported == startErr )
+        {
+        ShowErrorNoteL( R_CANT_START_SUBTEST_NOTSUPPORTED );
+        }
+    else // Could not start for a process
+        {
+        ShowErrorNoteL( R_CANT_START_SUBTEST_PROCESSID );  
+        }
+    
+    // The count of device driver users
+    TClientCountBuf count;
+    
+    // Check the flag
+    if ( driverOpen == KErrNone )
+        {
+        analyzeTool.ClientCount( count );
+        analyzeTool.Close();
+        }  
+    // Check the flag
+    if ( driverLoaded )
+        {
+        // Check if there is another user for device driver
+        if ( count().iClientCount <= 1 )
+            {
+            // There was no other users -> unload the device driver
+            User::FreeLogicalDevice( KAnalyzeToolLddName );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::SetProcessSubTestStopL()
+// Stops subtest for a process.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::SetProcessSubTestStopL( TUint aProcessId )
+    {
+    LOGSTR2( "ATCU CATConfigurationAppGuiAppUi::SetProcessSubTestStopL(%i)", 
+    		aProcessId );
+    
+    // Load the kernel side device driver
+    TInt loadErr = User::LoadLogicalDevice( KAnalyzeToolLddName );
+    TBool driverLoaded( EFalse );
+            
+    if ( loadErr == KErrNone || loadErr == KErrAlreadyExists )
+        {
+        driverLoaded = ETrue;
+        }
+        
+    RAnalyzeTool analyzeTool;
+    
+    TInt driverOpen = analyzeTool.Open();
+    TInt handleCount( KErrNone );
+    
+    if ( driverOpen == KErrNone )
+        {  
+        TATProcessHandlesBuf params;
+        params().iProcessId = aProcessId;
+        
+        analyzeTool.GetCurrentHandleCount( params );
+        handleCount = params().iCurrentHandleCount;
+        LOGSTR2( "CATConfigurationAppGuiAppUi::SetProcessSubTestStopL - %i current handle(s)",
+                params().iCurrentHandleCount );      
+        }
+        
+    TInt stopErr = iStorageServer.StopSubTest( aProcessId, KSubTestId, handleCount );
+    if ( KErrNone == stopErr )
+        {
+        TInt index = iSubTestProcesses.Find( aProcessId );
+        if ( index > KErrNotFound )
+            {
+            iSubTestProcesses.Remove( index );
+            if ( iSubTestProcesses.Count() == KErrNone )
+                iSubTestProcesses.Reset();
+            }             
+        }
+    else
+        {
+        ShowErrorNoteL( R_CANT_STOP_SUBTEST_PROCESSID );     
+        }
+    
+    // The count of device driver users
+    TClientCountBuf count;
+    
+    // Check the flag
+    if ( driverOpen == KErrNone )
+        {
+        analyzeTool.ClientCount( count );
+        analyzeTool.Close();
+        }  
+    // Check the flag
+    if ( driverLoaded )
+        {
+        // Check if there is another user for device driver
+        if ( count().iClientCount <= 1 )
+            {
+            // There was no other users -> unload the device driver
+            User::FreeLogicalDevice( KAnalyzeToolLddName );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::IsSubTestRunning()
+// Returns ETrue if subtest is running for a process.
+// -----------------------------------------------------------------------------
+//
+TInt CATConfigurationAppGuiAppUi::IsSubTestRunning( TUint aProcessId )
+    {
+    LOGSTR2( "ATCU CATConfigurationAppGuiAppUi::IsSubTestRunning(%i)", 
+    		aProcessId );
+    
+    return iSubTestProcesses.Find( aProcessId );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::LoadSettingsL()
+// Loads application settings.
+// -----------------------------------------------------------------------------
+//
+TInt CATConfigurationAppGuiAppUi::LoadSettingsL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiAppUi::LoadSettingsL()" );
+    
+    /*CDictionaryStore* iniFile = Application()->OpenIniFileLC( CCoeEnv::Static()->FsSession() );
+ 
+    if ( iniFile->IsPresentL( KUidATConfigurationAppGuiApplication ) )
+        {
+        RDictionaryReadStream readStream;
+        readStream.OpenLC( *iniFile, KUidATConfigurationAppGuiApplication );
+        // Load warning tones value
+        iWarningTones = static_cast<TInt>( readStream.ReadInt32L() );
+        // Load update interval value
+        iUpdateInterval = static_cast<TInt>( readStream.ReadInt32L() );
+        // Initialize other settings
+ 
+        CleanupStack::PopAndDestroy( &readStream );
+        }
+    else
+        {
+        // ini doesn't exist, so use default values
+        iWarningTones = 0;
+        iUpdateInterval = 0;
+        }
+ 
+    CleanupStack::PopAndDestroy(iniFile);*/      
+        
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::ShowErrorNoteL()
+// Shows error note.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::ShowErrorNoteL( TInt aResourceId )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiAppUi::ShowErrorNoteL()" );
+    
+    CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote();
+    HBufC* errorText = StringLoader::LoadLC( aResourceId );
+    errorNote->SetTextL( errorText->Des() );
+    errorNote->ExecuteLD();
+    CleanupStack::PopAndDestroy( errorText );      
+    }
+
+//-----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::HandleForegroundEventL
+// Handles fore ground events
+//-----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::HandleForegroundEventL( TBool aForeground )
+    {  
+    LOGSTR2( "ATCU CATConfigurationAppGuiAppUi::HandleForegroundEventL(%i)", 
+    		aForeground );
+    
+    if ( aForeground )
+        {
+        // Start timer when processes view gains foreground
+        if ( iDeactivatedId.iViewUid == TUid::Uid( EATConfigurationAppGuiListBoxViewId ) )
+            {
+            StartTimerL();    
+            }
+        }
+    else
+        {
+        // Cancel timer when not in foreground
+        TVwsViewId viewId;
+        GetActiveViewId( viewId );
+        // Save deactivated view's Id
+        iDeactivatedId = viewId;
+        TimerNotifyL( EFalse );        
+        }
+    }
+
+//-----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::StartTimerL
+// Starts timer with a specific time interval
+//-----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::StartTimerL()
+    {   
+    LOGSTR1( "ATCU CATConfigurationAppGuiAppUi::StartTimerL()" );
+    
+    if ( iPeriodicTimer->IsActive() )
+        {
+        iPeriodicTimer->Cancel();
+        }
+    iPeriodicTimer->Start( KATDefaultUpdatingInterval, 
+            KATDefaultUpdatingInterval, TCallBack( CallBackFunctionL, this ) );  
+    }
+    
+//-----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::TimerNotifyL
+// Periodic timer's callback function
+//-----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::TimerNotifyL( TBool aPeriod )
+    {
+    LOGSTR2( "ATCU CATConfigurationAppGuiAppUi::TimerNotifyL(%i)", 
+    		aPeriod );
+    
+    if ( iPeriodicTimer->IsActive() )
+        {
+        iPeriodicTimer->Cancel();
+        }   
+    if ( aPeriod )
+        {
+        if ( iATConfigurationAppGuiListBoxView )
+            {
+            iATConfigurationAppGuiListBoxView->UpdateViewL();
+            }
+        StartTimerL();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiAppUi::StopAllSubtestsL()
+// Stops all subtests which are running
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiAppUi::StopAllSubtestsL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiAppUi::StopAllSubtestsL()" );
+    
+    TInt index( KErrNone );
+    RArray<TATProcessInfo> processes;
+    TInt err( iStorageServer.GetProcessesL( processes ) );
+    LOGSTR2( "iStorageServer.GetProcessesL(%i)", err ); 
+    
+    // Load the kernel side device driver
+    TInt loadErr( User::LoadLogicalDevice( KAnalyzeToolLddName ) );
+    TBool driverLoaded( EFalse );
+    LOGSTR2( "ATCU CATConfigurationAppGuiAppUi::StopAllSubtestsL() loadErr(%i)", 
+    		loadErr );
+            
+    if ( loadErr == KErrNone || loadErr == KErrAlreadyExists )
+        {
+        driverLoaded = ETrue;
+        }
+    
+    RAnalyzeTool analyzeTool;    
+    TInt driverOpen( analyzeTool.Open() );
+    
+    while ( index < processes.Count() )
+        {
+        TUint processId = processes[ index ].iProcessId;
+        TInt handleCount( KErrNone );
+        
+        if ( driverOpen == KErrNone )
+            {  
+            TATProcessHandlesBuf params;
+            params().iProcessId = processId;
+            // Get process handle count
+            analyzeTool.GetCurrentHandleCount( params );
+            handleCount = params().iCurrentHandleCount;
+            LOGSTR2( "ATCU CATConfigurationAppGuiAppUi::StopAllSubtestsL() handleCount( %i )",
+            		handleCount );      
+            }        
+        
+        err = iStorageServer.StopSubTest( processId, KSubTestId, handleCount );
+        LOGSTR2( "ATCU > iStorageServer.StopSubTest( %i )", err ); 
+        
+        TInt find( iSubTestProcesses.Find( processId ) );
+        if ( find > KErrNotFound )
+            {
+            iSubTestProcesses.Remove( find );
+            if ( iSubTestProcesses.Count() == KErrNone )
+                {
+                iSubTestProcesses.Reset();
+                }  
+            } 
+        index++;
+        }
+    
+    // Close processes array
+    processes.Close();
+
+    // The count of device driver users
+    TClientCountBuf count;
+    
+    // Check the flag
+    if ( driverOpen == KErrNone )
+        {
+        analyzeTool.ClientCount( count );
+        analyzeTool.Close();
+        }  
+    // Check the flag
+    if ( driverLoaded )
+        {
+        // Check if there is another user for device driver
+        if ( count().iClientCount <= 1 )
+            {
+            // There was no other users -> unload the device driver
+            err = User::FreeLogicalDevice( KAnalyzeToolLddName );
+            LOGSTR2( "ATCU > FreeLogicalDevice( %i )", err ); 
+            }
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/src/atconfigurationappguidocument.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -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: 
+*
+*/
+
+#include "atconfigurationappguidocument.h"
+#include "atconfigurationappguiappui.h"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiDocument::CATConfigurationAppGuiDocument()
+// Constructs the document class for the application.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiDocument::CATConfigurationAppGuiDocument( CEikApplication& anApplication )
+    : CAknDocument( anApplication )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiDocument::CATConfigurationAppGuiDocument()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiDocument::ConstructL()
+// Completes the second phase of Symbian object construction.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiDocument::ConstructL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiDocument::CATConfigurationAppGuiDocument()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiDocument::NewL()
+// Creates an instance of CATConfigurationAppGuiDocument, constructs it, and
+// returns it.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiDocument* CATConfigurationAppGuiDocument::NewL( 
+	CEikApplication& aApp )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiDocument::NewL()" );
+    
+    CATConfigurationAppGuiDocument* self = 
+		new ( ELeave ) CATConfigurationAppGuiDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiDocument::CreateAppUiL()
+// Creates the application UI object for this document.
+// -----------------------------------------------------------------------------
+//
+CEikAppUi* CATConfigurationAppGuiDocument::CreateAppUiL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiDocument::CreateAppUiL()" );
+    
+    return new ( ELeave ) CATConfigurationAppGuiAppUi;
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/src/atconfigurationappguilistbox.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,666 @@
+/*
+* 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 <barsread.h>
+#include <stringloader.h>
+#include <aknlists.h>
+#include <eikenv.h>
+#include <akniconarray.h>
+#include <eikclbd.h>
+#include <aknviewappui.h>
+#include <eikappui.h>
+#include <atconfigurationappgui.rsg>
+#include <aknnotewrappers.h>
+
+#include "atconfigurationappguilistbox.h"
+#include "atconfigurationappguilistboxview.h"
+#include "atconfigurationappgui.hrh"
+#include "atconfigurationappguilistbox.hrh"
+#include "atconfigurationappguiappui.h"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::CATConfigurationAppGuiListBox()
+// First phase of Symbian two-phase construction.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiListBox::CATConfigurationAppGuiListBox()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::CATConfigurationAppGuiListBox()" );
+    
+    iListBox = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::~CATConfigurationAppGuiListBox()
+// Destroy child controls.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiListBox::~CATConfigurationAppGuiListBox()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::~CATConfigurationAppGuiListBox()" );
+    
+    if ( iListBox )
+        {
+        delete iListBox;
+        iListBox = NULL;
+        }
+    iProcesses.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::NewL()
+// Construct the control (first phase).
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiListBox* CATConfigurationAppGuiListBox::NewL( 
+    const TRect& aRect, CATConfigurationAppGuiListBoxView* aParent, 
+    MEikCommandObserver* aCommandObserver )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::NewL()" );
+    
+    CATConfigurationAppGuiListBox* self = CATConfigurationAppGuiListBox::NewLC( 
+            aRect, 
+            aParent, 
+            aCommandObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::NewLC()
+// Construct the control (first phase).
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiListBox* CATConfigurationAppGuiListBox::NewLC( 
+    const TRect& aRect, CATConfigurationAppGuiListBoxView* aParent, 
+    MEikCommandObserver* aCommandObserver )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::NewLC()" );
+    
+    CATConfigurationAppGuiListBox* self = new ( ELeave ) CATConfigurationAppGuiListBox();
+    CleanupStack::PushL( self );
+    self->ConstructL( aRect, aParent, aCommandObserver );
+    return self;
+    }
+             
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::ConstructL()
+// Construct the control (second phase).
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::ConstructL( 
+    const TRect& aRect, CATConfigurationAppGuiListBoxView* aParent, 
+    MEikCommandObserver* aCommandObserver )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::ConstructL()" );
+    
+    //if ( aParent == NULL )
+        //{
+        CreateWindowL();
+        //}
+    /*else
+        {
+        SetContainerWindowL( *aParent );
+        }*/
+    iFocusControl = NULL;
+    iCommandObserver = aCommandObserver;
+    iParent = aParent;
+    InitializeControlsL();
+    SetRect( aRect );
+    ActivateL();
+    }
+    
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::CountComponentControls()
+// Returns the number of controls in the container.
+// -----------------------------------------------------------------------------
+//
+TInt CATConfigurationAppGuiListBox::CountComponentControls() const
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::CountComponentControls()" );
+    
+    return ( int ) ELastControl;
+    }
+                
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::ComponentControl()
+// Get the control with the given index.
+// -----------------------------------------------------------------------------
+//
+CCoeControl* CATConfigurationAppGuiListBox::ComponentControl( 
+	TInt aIndex ) const
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::ComponentControl()" );
+    
+    switch ( aIndex )
+        {
+    case EListBox:
+        return iListBox;
+        }
+    return NULL;
+    }
+                
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::SizeChanged()
+// Handle resizing of the container.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::SizeChanged()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::SizeChanged()" );
+    
+    CCoeControl::SizeChanged();
+    LayoutControls();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::LayoutControls()
+// Layout components.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::LayoutControls()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::LayoutControls()" );
+    
+    iListBox->SetExtent( TPoint( 0, 0 ), iListBox->MinimumSize() );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::HandleListBoxEventL()
+// Handle listbox events.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::HandleListBoxEventL( 
+	CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::HandleListBoxEventL()" );
+    
+    switch ( aEventType )
+        {
+        case EEventEnterKeyPressed:
+        case EEventItemDoubleClicked:
+            {
+            iParent->HandleCommandL( 
+            		EATConfigurationAppGuiListBoxViewDetailsMenuItemCommand );
+            }
+            break;
+        default:
+            break;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::OfferKeyEventL()
+// Handle key events.
+// -----------------------------------------------------------------------------
+//
+TKeyResponse CATConfigurationAppGuiListBox::OfferKeyEventL( 
+    const TKeyEvent& aKeyEvent, TEventCode aType )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::OfferKeyEventL()" );
+    
+    if ( aKeyEvent.iCode == EKeyLeftArrow 
+        || aKeyEvent.iCode == EKeyRightArrow )
+        {
+        // Listbox takes all events even if it doesn't use them
+        return EKeyWasNotConsumed;
+        }
+    
+    if ( iFocusControl != NULL
+        && iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
+        {       
+        return EKeyWasConsumed;
+        }
+        
+    return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::HandlePointerEventL
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::HandlePointerEventL(
+                        const TPointerEvent& aPointerEvent)
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::HandlePointerEventL()" );
+    
+    if ( !AknLayoutUtils::PenEnabled() )
+        {
+        return;
+        }
+        
+    CCoeControl::HandlePointerEventL( aPointerEvent );
+    }
+  
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::InitializeControlsL()
+// Initialize each control upon creation.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::InitializeControlsL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::InitializeControlsL()" );
+    
+    iListBox = new ( ELeave ) CAknDoubleStyleListBox;
+    iListBox->SetContainerWindowL( *this );
+        {
+        TResourceReader reader;
+        iEikonEnv->CreateResourceReaderLC( reader, R_ATCONFIGURATION_APP_GUI_LIST_BOX_LIST_BOX );
+        iListBox->ConstructFromResourceL( reader );
+        CleanupStack::PopAndDestroy(); // Reader internal state
+        }
+    // The listbox owns the items in the list and will free them
+    iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+    iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
+
+    iListBox->CreateScrollBarFrameL( ETrue );
+    iListBox->ScrollBarFrame()->
+         SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EOn );
+    iListBox->SetListBoxObserver(this);
+    
+    HBufC* noProcesses = StringLoader::LoadLC( R_ATCONFIGURATION_APP_GUI_LBX_NO_PROCESSES );
+    iListBox->View()->SetListEmptyTextL( noProcesses->Des() );
+    CleanupStack::PopAndDestroy( noProcesses );
+    
+    // Setup the icon array so graphics-style boxes work
+    SetupListBoxIconsL();    
+    
+    // Update processes array
+    UpdateProcessesL();
+    CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )iEikonEnv->AppUi();
+    
+    for ( TInt count = 0 ; count < iProcesses.Count() ; count++ )
+        {
+        // This is intended to be large enough, but if you get 
+        // a USER 11 panic, consider reducing string sizes.
+        TATProcessInfo processInfo = iProcesses[ count ];
+        TUint processId = processInfo.iProcessId;
+        TBuf<KMaxProcessName> processName;
+        processName.Copy( processInfo.iProcessName );
+        TATLogOption loggingMode;//lint !e644
+        appUi->StorageServer().GetLoggingModeL( processId, loggingMode );
+        TBuf<512> listString;
+        if ( EATLoggingOff != loggingMode )
+            {
+            // Check is if this process's subtest is running
+            TInt subTest = appUi->IsSubTestRunning( processId );
+            if ( subTest > KErrNotFound )
+                {
+                HBufC* running = StringLoader::LoadLC( R_ATCONFIGURATION_APP_GUI_LISTBOX_SUBTEST );
+                CreateListBoxItemL( listString, processName, running->Des() );
+                CleanupStack::PopAndDestroy( running );
+                }
+            else
+                {
+                CreateListBoxItemL( listString, processName, KNullDesC );
+                // TEST START
+                /*if ( count == KErrNone )
+                    CreateListBoxItemL( listString, processName, KNullDesC );
+                else if ( count == 1 )
+                    CreateListBoxItemL( listString, processName, _L("logging cancelled") );
+                else if ( count == 2 )
+                    CreateListBoxItemL( listString, processName, _L("subtest running") );
+                */
+                //TEST END
+                }                
+            }
+        else
+            {
+            HBufC* cancelled = StringLoader::LoadLC( R_ATCONFIGURATION_APP_GUI_LISTBOX_LOGGING_CANCELLED );
+            CreateListBoxItemL( listString, processName, cancelled->Des() );
+            CleanupStack::PopAndDestroy( cancelled );
+            }
+
+        AddListBoxItemL( iListBox, listString );
+        }
+    iListBox->SetFocus( ETrue );
+    iFocusControl = iListBox;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::HandleResourceChange()
+// Handle global resource changes.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::HandleResourceChange( TInt aType )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::HandleResourceChange()" );
+    
+    CCoeControl::HandleResourceChange( aType );
+    SetRect( iAvkonViewAppUi->View( TUid::Uid( 
+    		EATConfigurationAppGuiListBoxViewId ) )->ClientRect() );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::Draw()
+// Draw container contents.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::Draw( const TRect& aRect ) const
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::Draw()" );
+    
+    CWindowGc& gc = SystemGc();
+    gc.Clear( aRect );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::AddListBoxItemL()
+// Add a list box item to a list.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::AddListBoxItemL( 
+    CEikTextListBox* aListBox, const TDesC& aString )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::AddListBoxItemL()" );
+    
+    CTextListBoxModel* model = aListBox->Model();
+    CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
+    itemArray->AppendL( aString );
+    aListBox->HandleItemAdditionL();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::GetSelectedListBoxItemsLC()
+// Get the array of selected item indices.
+// -----------------------------------------------------------------------------
+//
+RArray< TInt >* CATConfigurationAppGuiListBox::GetSelectedListBoxItemsLC( 
+	CEikTextListBox* aListBox )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::GetSelectedListBoxItemsLC()" );
+    
+    CAknFilteredTextListBoxModel* model = 
+        static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() );
+    if ( model->NumberOfItems() == 0 )
+        return NULL;
+        
+    // Get currently selected indices
+    const CListBoxView::CSelectionIndexArray* selectionIndexes =
+        aListBox->SelectionIndexes();
+    TInt selectedIndexesCount = selectionIndexes->Count();
+    if ( selectedIndexesCount == 0 )
+        return NULL;
+        
+    // Copy the indices and sort numerically
+    RArray<TInt>* orderedSelectedIndices = 
+        new (ELeave) RArray< TInt >( selectedIndexesCount );
+    
+    // Push the allocated array
+    CleanupStack::PushL( orderedSelectedIndices );
+    
+    // Dispose the array resource
+    CleanupClosePushL( *orderedSelectedIndices );
+    
+    // See if the search field is enabled
+    CAknListBoxFilterItems* filter = model->Filter();
+    if ( filter != NULL )
+        {
+        // When filtering enabled, translate indices back to underlying model
+        for ( TInt idx = 0; idx < selectedIndexesCount; idx++ )
+            {
+            TInt filteredItem = ( *selectionIndexes ) [ idx ];
+            TInt actualItem = filter->FilteredItemIndex ( filteredItem );
+            orderedSelectedIndices->InsertInOrder( actualItem );
+            }
+        }
+    else
+        {
+        // The selection indices refer directly to the model
+        for ( TInt idx = 0; idx < selectedIndexesCount; idx++ )
+            orderedSelectedIndices->InsertInOrder( ( *selectionIndexes ) [ idx ] );
+        }    
+        
+    return orderedSelectedIndices;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::DeleteSelectedListBoxItemsL()
+// Delete the selected item or items from the list box.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::DeleteSelectedListBoxItemsL( 
+	CEikTextListBox* aListBox )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::DeleteSelectedListBoxItemsL()" );
+    
+    CAknFilteredTextListBoxModel* model = 
+        static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() );
+    if ( model->NumberOfItems() == 0 )
+        return;
+    
+    RArray< TInt >* orderedSelectedIndices = GetSelectedListBoxItemsLC( aListBox );
+    if ( !orderedSelectedIndices )
+        return;
+        
+    // Delete selected items from bottom up so indices don't change on us
+    CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
+    TInt currentItem = 0;
+    
+    for ( TInt idx = orderedSelectedIndices->Count(); idx-- > 0; ) 
+        {
+        currentItem = ( *orderedSelectedIndices )[ idx ];
+        itemArray->Delete ( currentItem );
+        }
+    
+    // Dispose the array resources
+    CleanupStack::PopAndDestroy();
+    
+    // Dispose the array pointer
+    CleanupStack::PopAndDestroy( orderedSelectedIndices );
+    
+    // Refresh listbox's cursor now that items are deleted
+    AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(
+        aListBox, currentItem, ETrue );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::ListBox()
+// Get the listbox.
+// -----------------------------------------------------------------------------
+//
+CAknDoubleStyleListBox* CATConfigurationAppGuiListBox::ListBox()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::ListBox()" );
+    
+    return iListBox;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::CreateListBoxItemL()
+// Create a list box item with the given column values.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::CreateListBoxItemL( TDes& aBuffer, 
+        const TDesC& aMainText,
+        const TDesC& aSecondaryText )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::CreateListBoxItemL()" );
+    
+    _LIT ( KStringHeader, "\t%S\t%S" );
+    
+    aBuffer.Format( KStringHeader(), &aMainText, &aSecondaryText );
+    } 
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::AddListBoxResourceArrayItemL()
+// Add an item to the list by reading the text items from the array resource.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::AddListBoxResourceArrayItemL( 
+	TInt aResourceId )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::AddListBoxResourceArrayItemL()" );
+    
+    CDesCArray* array = iCoeEnv->ReadDesCArrayResourceL( aResourceId );
+    CleanupStack::PushL( array );
+    // This is intended to be large enough, but if you get 
+    // a USER 11 panic, consider reducing string sizes.
+    TBuf<512> listString; 
+    CreateListBoxItemL( listString, ( *array ) [ 0 ], ( *array ) [ 1 ] );
+    AddListBoxItemL( iListBox, listString );
+    CleanupStack::PopAndDestroy( array );
+    } 
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::SetupListBoxIconsL()
+// Set up the list's icon array.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::SetupListBoxIconsL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::SetupListBoxIconsL()" );
+    
+    CArrayPtr< CGulIcon >* icons = NULL;
+    
+    if ( icons != NULL )
+        {
+        iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::HandleMarkableListCommandL()
+// Handle commands relating to markable lists.
+// -----------------------------------------------------------------------------
+//
+TBool CATConfigurationAppGuiListBox::HandleMarkableListCommandL( 
+	TInt /*aCommand*/ )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::HandleMarkableListCommandL()" );
+    
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::GetCurrentItemIndex()
+// Returns current listbox index.
+// -----------------------------------------------------------------------------
+//
+TInt CATConfigurationAppGuiListBox::GetCurrentItemIndex()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::GetCurrentItemIndex()" );
+    
+    return iListBox->CurrentItemIndex();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::UpdateProcessesL()
+// Updates processes array.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::UpdateProcessesL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::UpdateProcessesL()" );
+    
+    // Update processes array from the storage server
+    CATConfigurationAppGuiAppUi* appUi = 
+		( CATConfigurationAppGuiAppUi* )iEikonEnv->AppUi();
+    appUi->StorageServer().GetProcessesL( iProcesses );
+    // TEST
+    /*TATProcessInfo pr1;
+    pr1.iProcessId = 1;
+    TBuf8<KMaxProcessName> pr1Name;
+    pr1Name.Copy( _L("MemoryLeaker.exe") );
+    pr1.iProcessName.Copy( pr1Name );
+    pr1.iStartTime = 1234556789;
+    iProcesses.Append( pr1 );
+
+    TATProcessInfo pr2;
+    pr2.iProcessId = 2;
+    TBuf8<KMaxProcessName> pr2Name;
+    pr2Name.Copy( _L("ConsoleApp.exe") );
+    pr2.iProcessName.Copy( pr2Name );
+    pr2.iStartTime = 2234556789;
+    iProcesses.Append( pr2 );
+    
+    TATProcessInfo pr3;
+    pr3.iProcessId = 3;
+    TBuf8<KMaxProcessName> pr3Name;
+    pr3Name.Copy( _L("MediaPlayer.exe") );
+    pr3.iProcessName.Copy( pr3Name );
+    pr3.iStartTime = 3234556789;
+    iProcesses.Append( pr3 );*/
+    // TEST END
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBox::UpdateViewL()
+// Updates views controls.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBox::UpdateViewL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBox::UpdateViewL()" );
+    
+    CTextListBoxModel* model = iListBox->Model();
+    CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
+    itemArray->Reset();
+    
+    // Update processes array
+    UpdateProcessesL();
+    for ( TInt count = 0 ; count < iProcesses.Count() ; count++ )
+        {
+        // This is intended to be large enough, but if you get 
+        // a USER 11 panic, consider reducing string sizes.
+        TATProcessInfo processInfo = iProcesses[ count ];
+        TUint processId = processInfo.iProcessId;
+        TBuf<KMaxProcessName> processName;
+        processName.Copy( processInfo.iProcessName );
+        TBuf<512> listString;
+        // Check is if this process's subtest is running
+        CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )iEikonEnv->AppUi();
+        
+        TATLogOption loggingMode;//lint !e644
+        appUi->StorageServer().GetLoggingModeL( processId, loggingMode );
+        if ( EATLoggingOff != loggingMode )
+            {
+            // Check is if this process's subtest is running
+            TInt subTest = appUi->IsSubTestRunning( processId );
+            if ( subTest > KErrNotFound )
+                {
+                HBufC* running = StringLoader::LoadLC( R_ATCONFIGURATION_APP_GUI_LISTBOX_SUBTEST );
+                CreateListBoxItemL( listString, processName, running->Des() );
+                CleanupStack::PopAndDestroy( running );
+                }
+            else
+                {
+                CreateListBoxItemL( listString, processName, KNullDesC );
+                // TEST START
+                /*if ( count == KErrNone )
+                    CreateListBoxItemL( listString, processName, KNullDesC );
+                else if ( count == 1 )
+                    CreateListBoxItemL( listString, processName, _L("logging cancelled") );
+                else if ( count == 2 )
+                    CreateListBoxItemL( listString, processName, _L("subtest running") );
+                */
+                //TEST END
+                }                
+            }
+        else
+            {
+            HBufC* cancelled = StringLoader::LoadLC( R_ATCONFIGURATION_APP_GUI_LISTBOX_LOGGING_CANCELLED );
+            CreateListBoxItemL( listString, processName, cancelled->Des() );
+            CleanupStack::PopAndDestroy( cancelled );
+            }            
+        AddListBoxItemL( iListBox, listString );
+        }    
+    iListBox->DrawNow();
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/src/atconfigurationappguilistboxview.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,575 @@
+/*
+* 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 <aknviewappui.h>
+#include <eikmenub.h>
+#include <avkon.hrh>
+#include <barsread.h>
+#include <stringloader.h>
+#include <aknlists.h>
+#include <eikenv.h>
+#include <akniconarray.h>
+#include <eikclbd.h>
+#include <akncontext.h>
+#include <akntitle.h>
+#include <eikbtgpc.h>
+#include <atconfigurationappgui.rsg>
+#include <aknmessagequerydialog.h>
+#include <aknnotewrappers.h>
+#include <apgtask.h>
+
+#include "atconfigurationappgui.hrh"
+#include "atconfigurationappguilistboxview.h"
+#include "atconfigurationappguilistbox.hrh"
+#include "atconfigurationappguilistbox.h"
+#include "atconfigurationappguiappui.h"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::CATConfigurationAppGuiListBoxView()
+// First phase of Symbian two-phase construction.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiListBoxView::CATConfigurationAppGuiListBoxView()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::CATConfigurationAppGuiListBoxView()" );
+    
+    iATConfigurationAppGuiListBox = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::~CATConfigurationAppGuiListBoxView()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiListBoxView::~CATConfigurationAppGuiListBoxView()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::~CATConfigurationAppGuiListBoxView()" );
+    
+    delete iATConfigurationAppGuiListBox;
+    iATConfigurationAppGuiListBox = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::NewL()
+// Symbian two-phase constructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiListBoxView* CATConfigurationAppGuiListBoxView::NewL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::NewL()" );
+    
+    CATConfigurationAppGuiListBoxView* self = CATConfigurationAppGuiListBoxView::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::NewLC()
+// Symbian two-phase constructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiListBoxView* CATConfigurationAppGuiListBoxView::NewLC()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::NewLC()" );
+    
+    CATConfigurationAppGuiListBoxView* self = new ( ELeave ) CATConfigurationAppGuiListBoxView();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::ConstructL()
+// Second-phase constructor for view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBoxView::ConstructL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::ConstructL()" );
+    
+    BaseConstructL( R_ATCONFIGURATION_APP_GUI_LIST_BOX_ATCONFIGURATION_APP_GUI_LIST_BOX_VIEW );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::Id()
+// Returns The UID for this view.
+// -----------------------------------------------------------------------------
+//
+TUid CATConfigurationAppGuiListBoxView::Id() const
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::Id()" );
+    
+    return TUid::Uid( EATConfigurationAppGuiListBoxViewId );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::HandleCommandL()
+// Handle a command for this view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBoxView::HandleCommandL( TInt aCommand )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::HandleCommandL()" );
+    
+    TBool commandHandled = EFalse;
+    switch ( aCommand )
+        { // Code to dispatch to the AknView's menu and CBA commands is generated here
+        case EATConfigurationAppGuiListBoxViewVersionMenuItemCommand:
+            commandHandled = HandleVersionMenuItemSelectedL( aCommand );
+            break;
+        case EATConfigurationAppGuiListBoxViewDetailsMenuItemCommand:
+            {
+            // Listbox items are in the same order as in storage server
+            // thus using current index
+            if ( iATConfigurationAppGuiListBox )
+                {
+                TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
+                RArray<TATProcessInfo> processes;
+                CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
+                appUi->StorageServer().GetProcessesL( processes );
+                if ( current >= KErrNone && current < processes.Count() )
+                    {
+                    TUint processId = processes[ current ].iProcessId;
+                    TInt64 processStartTime = processes[ current ].iStartTime;
+                    appUi->SetCurrentProcessId( processId );
+                    appUi->SetCurrentProcessStartTime( processStartTime );
+                    AppUi()->ActivateLocalViewL( TUid::Uid( EATConfigurationAppGuiProcessViewId ) );
+                    }
+                // Closes the array and frees all memory allocated to the array.
+                processes.Close();
+                }
+            break;
+            }
+        /*case EATConfigurationAppGuiListBoxViewEnd_processMenuItemCommand:
+            {
+            EndProcessL( EATConfigurationAppGuiListBoxViewEndTaskMenuItemCommand );
+            break;
+            }*/
+        case EATConfigurationAppGuiListBoxViewEndTaskMenuItemCommand:
+            {
+            EndProcessL( EATConfigurationAppGuiListBoxViewEndTaskMenuItemCommand );
+            break;
+            }
+        case EATConfigurationAppGuiListBoxViewKillProcessMenuItemCommand:
+            {
+            EndProcessL( EATConfigurationAppGuiListBoxViewKillProcessMenuItemCommand );
+            break;
+            }
+        case EATConfigurationAppGuiListBoxViewTerminateProcessMenuItemCommand:
+            {
+            EndProcessL( EATConfigurationAppGuiListBoxViewTerminateProcessMenuItemCommand );
+            break;
+            }
+        case EATConfigurationAppGuiListBoxViewPanicProcessMenuItemCommand:
+            {
+            EndProcessL( EATConfigurationAppGuiListBoxViewPanicProcessMenuItemCommand );
+            break;
+            }
+        case EATConfigurationAppGuiListBoxViewCancel_loggingMenuItemCommand:
+            {
+            // Listbox items are in the same order as in storage server
+            // thus using current index
+            if ( iATConfigurationAppGuiListBox )
+                {
+                TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
+                RArray<TATProcessInfo> processes;
+                CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
+                appUi->StorageServer().GetProcessesL( processes );
+                if ( current >= KErrNone && current < processes.Count() )
+                    {
+                    TUint processId = processes[ current ].iProcessId;
+                    // Stop subtesting for this process
+                    //if ( appUi->IsSubTestRunning( processId ) )
+                        //appUi->SetProcessSubTestStopL( processId );
+                    
+                    TInt cancelErr = appUi->StorageServer().CancelLogging( processId );
+                    if ( cancelErr != KErrNone )
+                        {
+                        // Logging could not be cancelled
+                        appUi->ShowErrorNoteL( R_ATCONFIGURATION_APP_GUI_LISTBOX_CANCEL_FAILURE_NOTE );
+                        }
+                    else
+                        {
+                        iATConfigurationAppGuiListBox->UpdateViewL();
+                        }
+                    }
+				// Closes the array and frees all memory allocated to the array.
+                processes.Close();
+                }
+            break;
+            }
+        case EATConfigurationAppGuiListBoxViewLog_settingMenuItemCommand:
+            {
+            AppUi()->ActivateLocalViewL( TUid::Uid( EATConfigurationAppGuiSettingItemListViewId ),
+                    TUid::Uid( EATConfigurationAppGuiListBoxViewId ), KNullDesC8 );
+            break;
+            }
+        case EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand:
+            {
+            if ( iATConfigurationAppGuiListBox )
+                {
+                TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
+                RArray<TATProcessInfo> processes;
+                CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
+                appUi->StorageServer().GetProcessesL( processes );
+                if ( current >= KErrNone && current < processes.Count() )
+                    {
+                    TUint processId = processes[ current ].iProcessId;
+                    appUi->SetProcessSubTestStartL( processId );
+                    iATConfigurationAppGuiListBox->UpdateViewL();
+                    }
+				// Closes the array and frees all memory allocated to the array.
+                processes.Close();
+                }
+            break;
+            }
+        case EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand:
+            {
+            if ( iATConfigurationAppGuiListBox )
+                {
+                TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
+                RArray<TATProcessInfo> processes;
+                CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
+                appUi->StorageServer().GetProcessesL( processes );
+                if ( current >= KErrNone && current < processes.Count() )
+                    {
+                    TUint processId = processes[ current ].iProcessId;
+                    appUi->SetProcessSubTestStopL( processId );
+                    iATConfigurationAppGuiListBox->UpdateViewL();
+                    }
+				// Closes the array and frees all memory allocated to the array.
+                processes.Close();
+                }
+            break;
+            }
+        default:
+            break;
+        }
+     
+    if ( !commandHandled ) 
+        {
+    
+        if ( aCommand == EAknSoftkeyExit || aCommand == EAknSoftkeyExit )
+            {
+            AppUi()->HandleCommandL( EEikCmdExit );
+            }
+    
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::DoActivateL()
+// Handles user actions during activation of the view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBoxView::DoActivateL( 
+        const TVwsViewId& /*aPrevViewId*/,
+        TUid /*aCustomMessageId*/,
+        const TDesC8& /*aCustomMessage*/ )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::DoActivateL()" );
+    
+    SetupStatusPaneL();
+    
+    if ( iATConfigurationAppGuiListBox == NULL )
+        {
+        iATConfigurationAppGuiListBox = CreateContainerL();
+        iATConfigurationAppGuiListBox->SetMopParent( this );
+        AppUi()->AddToStackL( *this, iATConfigurationAppGuiListBox );
+        // For supporting MSK context menu
+        MenuBar()->SetContextMenuTitleResourceId( R_ATCONFIGURATION_APP_GUI_LIST_BOX_OPTIONS_MENU );
+        // Start update timer
+        ( (CATConfigurationAppGuiAppUi*)AppUi() )->StartTimerL();
+        } 
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::DoDeactivate()
+// Handles user actions during deactivation of the view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBoxView::DoDeactivate()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::DoDeactivate()" );
+    
+    CleanupStatusPane();
+    
+    if ( iATConfigurationAppGuiListBox != NULL )
+        {
+        // Cancel timer events
+        TRAP_IGNORE( ( (CATConfigurationAppGuiAppUi*)AppUi() )->TimerNotifyL( EFalse ) );
+        AppUi()->RemoveFromViewStack( *this, iATConfigurationAppGuiListBox );
+        delete iATConfigurationAppGuiListBox;
+        iATConfigurationAppGuiListBox = NULL;
+        }
+    CleanupStatusPane();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::DynInitMenuPaneL()
+// Handles dynamical menu item dimming.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBoxView::DynInitMenuPaneL( TInt aResourceId, 
+	CEikMenuPane* aMenuPane )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::DynInitMenuPaneL()" );
+    
+    if ( R_ATCONFIGURATION_APP_GUI_LIST_BOX_MENU_PANE1_MENU_PANE == aResourceId )
+        {
+        if( iATConfigurationAppGuiListBox->GetCurrentItemIndex() < 0 ) 
+            {
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewDetailsMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewEnd_processMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewLog_settingMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewHelpMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewCancel_loggingMenuItemCommand, ETrue );
+            } 
+        else 
+            {
+            TInt subTest( KErrNotFound );
+            TATLogOption loggingMode = EATUseDefault;//lint !e644
+            if ( iATConfigurationAppGuiListBox )
+                {
+                TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
+                RArray<TATProcessInfo> processes;
+                CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
+                appUi->StorageServer().GetProcessesL( processes );
+                if ( current >= KErrNone && current < processes.Count() )
+                    {
+                    TUint processId = processes[ current ].iProcessId;
+                    subTest = appUi->IsSubTestRunning( processId );
+                    // Get logging mode
+                    appUi->StorageServer().GetLoggingModeL( processId, loggingMode );
+                    }
+				// Closes the array and frees all memory allocated to the array.
+                processes.Close();
+                }
+            if ( subTest > KErrNotFound )
+                {
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand, ETrue );
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand, EFalse );
+                }
+            else
+                {
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand, EFalse );
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand, ETrue );
+                }
+            
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewDetailsMenuItemCommand, EFalse );
+            
+            if ( loggingMode == EATLoggingOff )
+                {
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewCancel_loggingMenuItemCommand, ETrue );
+                // Logging cancelled -> hide necessary items
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewDetailsMenuItemCommand, ETrue );
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStart_subtestMenuItemCommand, ETrue );
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewStop_subtestMenuItemCommand, ETrue );
+                }
+            else
+                {
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewCancel_loggingMenuItemCommand, EFalse );
+                }
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewLog_settingMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiListBoxViewHelpMenuItemCommand, ETrue );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::HandleStatusPaneSizeChange()
+// Handle status pane size change for this view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBoxView::HandleStatusPaneSizeChange()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::HandleStatusPaneSizeChange()" );
+    
+    CAknView::HandleStatusPaneSizeChange();
+    
+    // This may fail, but we're not able to propagate exceptions here
+    TInt result;
+    TRAP( result, SetupStatusPaneL() ); 
+    }  
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::SetupStatusPaneL()
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBoxView::SetupStatusPaneL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::SetupStatusPaneL()" );
+    
+    // Reset the context pane
+    TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
+    CEikStatusPaneBase::TPaneCapabilities subPaneContext = 
+        StatusPane()->PaneCapabilities( contextPaneUid );
+    if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
+        {
+        CAknContextPane* context = static_cast< CAknContextPane* > ( 
+            StatusPane()->ControlL( contextPaneUid ) );
+        context->SetPictureToDefaultL();
+        }
+    
+    // Setup the title pane
+    TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
+    CEikStatusPaneBase::TPaneCapabilities subPaneTitle = 
+        StatusPane()->PaneCapabilities( titlePaneUid );
+    if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
+        {
+        CAknTitlePane* title = static_cast< CAknTitlePane* >( 
+            StatusPane()->ControlL( titlePaneUid ) );
+        TResourceReader reader;
+        iEikonEnv->CreateResourceReaderLC( reader, R_ATCONFIGURATION_APP_GUI_LIST_BOX_TITLE_RESOURCE );
+        title->SetFromResourceL( reader );
+        CleanupStack::PopAndDestroy(); // reader internal state
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::CleanupStatusPane()
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBoxView::CleanupStatusPane()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::CleanupStatusPane()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::CreateContainerL()
+// Creates the top-level container for the view.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiListBox* CATConfigurationAppGuiListBoxView::CreateContainerL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::CreateContainerL()" );
+    
+    return CATConfigurationAppGuiListBox::NewL( ClientRect(), this, this );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::HandleVersionMenuItemSelectedL()
+// Shows About dialog of the application.
+// -----------------------------------------------------------------------------
+//
+TBool CATConfigurationAppGuiListBoxView::HandleVersionMenuItemSelectedL( 
+	TInt /*aCommand*/ )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::HandleVersionMenuItemSelectedL()" );
+    CAknMessageQueryDialog* dlg = new (ELeave) CAknMessageQueryDialog;
+    dlg->ExecuteLD( R_ABOUT_HEADING_PANE );
+    
+    return ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::UpdateViewL()
+// Updates view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBoxView::UpdateViewL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiListBoxView::UpdateViewL()" );
+    
+    if ( iATConfigurationAppGuiListBox )
+        {
+        iATConfigurationAppGuiListBox->UpdateViewL();
+        } 
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiListBoxView::EndProcessL()
+// Ends process with a specific method.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiListBoxView::EndProcessL( TInt aCommand )
+    {
+    LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL" );  
+                    
+    TInt current = iATConfigurationAppGuiListBox->GetCurrentItemIndex();
+    RArray<TATProcessInfo> processes;
+    CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
+    appUi->StorageServer().GetProcessesL( processes );
+     if ( current >= KErrNone && current < processes.Count() )
+         {
+         RProcess endProcess;
+         TUint processId = processes[ current ].iProcessId;
+         TBuf<KMaxProcessName> processName;
+         processName.Copy( processes[ current ].iProcessName );
+         TInt find = processName.Find( _L( "." ) );
+         if ( find > KErrNotFound )
+             processName.Delete( find, processName.Length() - find );
+         
+         TInt openErr = endProcess.Open( TProcessId( processId ) );
+         if ( openErr ==KErrNone )
+             {
+             if ( aCommand == EATConfigurationAppGuiListBoxViewEndTaskMenuItemCommand )
+                 {
+                 LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL - end task" );
+                 endProcess.Close();
+
+                 TApaTaskList apList = TApaTaskList( iEikonEnv->WsSession() );
+                 TApaTask apTask = apList.FindApp( processName );
+                 if ( apTask.Exists() )
+                     {
+                     LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL - task exists -> end" );
+                     apTask.EndTask();
+                     }
+                 else
+                     {
+                     _LIT( KAppNotExist, "Could not end this process!" );
+                     CAknErrorNote* note = new ( ELeave ) CAknErrorNote();
+                     note->SetTextL( KAppNotExist() );
+                     note->ExecuteLD();
+                     }
+                 }
+             else if ( aCommand == EATConfigurationAppGuiListBoxViewKillProcessMenuItemCommand )
+                 {
+                 LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL - kill process" );
+                 endProcess.Kill( KErrNone );
+                 endProcess.Close();
+                 }
+             else if ( aCommand == EATConfigurationAppGuiListBoxViewTerminateProcessMenuItemCommand )
+                 {
+                 LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL - terminate process" );
+                 endProcess.Terminate( KErrNone );
+                 endProcess.Close();
+                 }
+             else if ( aCommand == EATConfigurationAppGuiListBoxViewPanicProcessMenuItemCommand )
+                 {
+                 LOGSTR1( "CATConfigurationAppGuiListBoxView::EndProcessL - panic process" );
+                 _LIT( KPanicTxt, "Panic");
+                 endProcess.Panic( KPanicTxt, KErrNone );
+                 endProcess.Close();
+                 }
+             }
+         else
+             {
+             CAknErrorNote* errorNote = new ( ELeave ) CAknErrorNote();
+             _LIT( KErrTxt, "Could not open the process!");
+             errorNote->SetTextL( KErrTxt );
+             errorNote->ExecuteLD();
+             }
+         }   
+	// Closes the array and frees all memory allocated to the array.
+    processes.Close();
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/src/atconfigurationappguiprocesscontainer.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,715 @@
+/*
+* 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
+#include <barsread.h>
+#include <stringloader.h>
+#include <aknlists.h>
+#include <eikenv.h>
+#include <akniconarray.h>
+#include <eikclbd.h>
+#include <aknviewappui.h>
+#include <eikappui.h>
+#include <utf.h>
+#include <atconfigurationappgui.rsg>
+#include <analyzetool/atstorageserverclnt.h>
+
+#include "atconfigurationappguiprocesscontainer.h"
+#include "atconfigurationappguiprocessview.h"
+#include "atconfigurationappgui.hrh"
+#include "atconfigurationappguiprocesscontainer.hrh"
+#include "atconfigurationappguiappui.h"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::CATConfigurationAppGuiProcessContainer()
+// First phase of Symbian two-phase construction.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiProcessContainer::CATConfigurationAppGuiProcessContainer()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::CATConfigurationAppGuiProcessContainer()" );
+    
+    iListBox = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::~CATConfigurationAppGuiProcessContainer()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiProcessContainer::~CATConfigurationAppGuiProcessContainer()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::~CATConfigurationAppGuiProcessContainer()" );
+    
+    delete iListBox;
+    iListBox = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::NewL()
+// Construct the control (first phase).
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiProcessContainer* CATConfigurationAppGuiProcessContainer::NewL( 
+    const TRect& aRect, CATConfigurationAppGuiProcessView* aParent, 
+    MEikCommandObserver* aCommandObserver, TUint aProcessId, 
+    TInt64 aProcessStartTime )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::NewL()" );
+    
+    CATConfigurationAppGuiProcessContainer* self = 
+		CATConfigurationAppGuiProcessContainer::NewLC( 
+            aRect, 
+            aParent, 
+            aCommandObserver, aProcessId, aProcessStartTime );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::NewLC()
+// Construct the control (first phase).
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiProcessContainer* CATConfigurationAppGuiProcessContainer::NewLC( 
+    const TRect& aRect, CATConfigurationAppGuiProcessView* aParent, 
+    MEikCommandObserver* aCommandObserver, TUint aProcessId, 
+    TInt64 aProcessStartTime )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::NewLC()" );
+    
+    CATConfigurationAppGuiProcessContainer* self = 
+		new ( ELeave ) CATConfigurationAppGuiProcessContainer();
+    CleanupStack::PushL( self );
+    self->ConstructL( aRect, 
+				      aParent, 
+				      aCommandObserver, 
+				      aProcessId, aProcessStartTime );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::ConstructL()
+// Construct the control (second phase).
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::ConstructL( 
+    const TRect& aRect, CATConfigurationAppGuiProcessView* aParent, 
+    MEikCommandObserver* aCommandObserver, TUint aProcessId, 
+    TInt64 aProcessStartTime )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::ConstructL()" );
+    
+    //if ( aParent == NULL )
+        //{
+    CreateWindowL();
+        //}
+    /*else
+        {
+        SetContainerWindowL( *aParent );
+        }*/
+    iFocusControl = NULL;
+    iParent = aParent;
+    iCommandObserver = aCommandObserver;
+    iProcessId = aProcessId;
+    iProcessStartTime = aProcessStartTime;
+    InitializeControlsL();
+    SetRect( aRect );
+    ActivateL();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::CountComponentControls()
+// Returns the number of controls in the container.
+// -----------------------------------------------------------------------------
+//
+TInt CATConfigurationAppGuiProcessContainer::CountComponentControls() const
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::CountComponentControls()" );
+    return ( int ) ELastControl;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::ComponentControl()
+// Get the control with the given index.
+// -----------------------------------------------------------------------------
+//
+CCoeControl* CATConfigurationAppGuiProcessContainer::ComponentControl( 
+	TInt aIndex ) const
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::ComponentControl()" );
+    
+    switch ( aIndex )
+        {
+    case EListBox:
+        return iListBox;
+        }
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::SizeChanged()
+// Handle resizing of the container.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::SizeChanged()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::SizeChanged()" );
+    
+    CCoeControl::SizeChanged();
+    LayoutControls();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::LayoutControls()
+// Layout components.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::LayoutControls()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::LayoutControls()" );
+    
+    iListBox->SetExtent( TPoint( 0, 0 ), iListBox->MinimumSize() );
+    }
+    
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::OfferKeyEventL()
+// Handle key events.
+// -----------------------------------------------------------------------------
+//
+TKeyResponse CATConfigurationAppGuiProcessContainer::OfferKeyEventL( 
+        const TKeyEvent& aKeyEvent, 
+        TEventCode aType )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::OfferKeyEventL()" );
+    
+    if ( aKeyEvent.iCode == EKeyLeftArrow 
+        || aKeyEvent.iCode == EKeyRightArrow )
+        {
+        // Listbox takes all events even if it doesn't use them
+        return EKeyWasNotConsumed;
+        }
+        
+    if ( iFocusControl != NULL
+        && iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
+        {
+        return EKeyWasConsumed;
+        }
+    return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::InitializeControlsL()
+// Initialize each control upon creation.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::InitializeControlsL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::InitializeControlsL()" );
+    
+    iListBox = new ( ELeave ) CAknDoubleStyleListBox;
+    iListBox->SetContainerWindowL( *this );
+        {
+        TResourceReader reader;
+        iEikonEnv->CreateResourceReaderLC( reader, R_ATCONFIGURATION_APP_GUI_LIST_BOX );
+        iListBox->ConstructFromResourceL( reader );
+        CleanupStack::PopAndDestroy(); // Reader internal state
+        }
+    // The listbox owns the items in the list and will free them
+    iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
+
+    iListBox->CreateScrollBarFrameL( ETrue );
+    iListBox->ScrollBarFrame()->
+         SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EOn );
+
+    // Enable marquee
+    iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
+        
+    HBufC* noInfo = StringLoader::LoadLC( R_ATCONFIGURATION_APP_GUI_LBX_NO_INFO );
+    iListBox->View()->SetListEmptyTextL( noInfo->Des() );
+    CleanupStack::PopAndDestroy( noInfo );
+
+    // Setup the icon array so graphics-style boxes work
+    SetupListBoxIconsL();
+
+    // Add list items
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM1 );
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM2 );
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM3 );
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM4 );
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM5 );
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM6 );
+
+    iListBox->SetFocus( ETrue );
+    iFocusControl = iListBox;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::HandleResourceChange()
+// Handle global resource changes.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::HandleResourceChange( TInt aType )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::HandleResourceChange()" );
+    
+    CCoeControl::HandleResourceChange( aType );
+    SetRect( iAvkonViewAppUi->View( TUid::Uid( EATConfigurationAppGuiProcessViewId ) )->ClientRect() );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::Draw()
+// Draw container contents.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::Draw( const TRect& aRect ) const
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::Draw()" );
+    
+    CWindowGc& gc = SystemGc();
+    gc.Clear( aRect );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::AddListBoxItemL()
+// Add a list box item to a list.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::AddListBoxItemL( 
+    CEikTextListBox* aListBox, const TDesC& aString )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::AddListBoxItemL()" );
+    
+    CTextListBoxModel* model = aListBox->Model();
+    CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
+    itemArray->AppendL( aString );
+    aListBox->HandleItemAdditionL();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::GetSelectedListBoxItemsLC()
+// Get the array of selected item indices.
+// -----------------------------------------------------------------------------
+//
+RArray< TInt >* CATConfigurationAppGuiProcessContainer::GetSelectedListBoxItemsLC( 
+	CEikTextListBox* aListBox )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::GetSelectedListBoxItemsLC()" );
+    
+    CAknFilteredTextListBoxModel* model = 
+        static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() );
+    if ( model->NumberOfItems() == 0 )
+        return NULL;
+        
+    // Get currently selected indices
+    const CListBoxView::CSelectionIndexArray* selectionIndexes =
+        aListBox->SelectionIndexes();
+    TInt selectedIndexesCount = selectionIndexes->Count();
+    if ( selectedIndexesCount == 0 )
+        return NULL;
+        
+    // Copy the indices and sort numerically
+    RArray<TInt>* orderedSelectedIndices = 
+        new (ELeave) RArray< TInt >( selectedIndexesCount );
+
+    // Push the allocated array
+    CleanupStack::PushL( orderedSelectedIndices );
+
+    // Dispose the array resource
+    CleanupClosePushL( *orderedSelectedIndices );
+
+    // See if the search field is enabled
+    CAknListBoxFilterItems* filter = model->Filter();
+    if ( filter != NULL )
+        {
+        // When filtering enabled, translate indices back to underlying model
+        for ( TInt idx = 0; idx < selectedIndexesCount; idx++ )
+            {
+            TInt filteredItem = ( *selectionIndexes ) [ idx ];
+            TInt actualItem = filter->FilteredItemIndex ( filteredItem );
+            orderedSelectedIndices->InsertInOrder( actualItem );
+            }
+        }
+    else
+        {
+        // The selection indices refer directly to the model
+        for ( TInt idx = 0; idx < selectedIndexesCount; idx++ )
+            orderedSelectedIndices->InsertInOrder( ( *selectionIndexes ) [ idx ] );
+        }
+        
+    return orderedSelectedIndices;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::DeleteSelectedListBoxItemsL()
+// Delete the selected item or items from the list box.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::DeleteSelectedListBoxItemsL( 
+	CEikTextListBox* aListBox )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::DeleteSelectedListBoxItemsL()" );
+    
+    CAknFilteredTextListBoxModel* model = 
+        static_cast< CAknFilteredTextListBoxModel *> ( aListBox->Model() );
+    if ( model->NumberOfItems() == 0 )
+        return;
+
+    RArray< TInt >* orderedSelectedIndices = GetSelectedListBoxItemsLC( aListBox );
+    if ( !orderedSelectedIndices )
+        return;
+        
+    // Delete selected items from bottom up so indices don't change on us
+    CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
+    TInt currentItem = 0;
+
+    for ( TInt idx = orderedSelectedIndices->Count(); idx-- > 0; ) 
+        {
+        currentItem = ( *orderedSelectedIndices )[ idx ];
+        itemArray->Delete ( currentItem );
+        }
+
+    // Dispose the array resources
+    CleanupStack::PopAndDestroy();
+
+    // Dispose the array pointer
+    CleanupStack::PopAndDestroy( orderedSelectedIndices );
+
+    // Refresh listbox's cursor now that items are deleted
+    AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(
+        aListBox, currentItem, ETrue );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::ListBox()
+// Get the listbox.
+// -----------------------------------------------------------------------------
+//
+CAknDoubleStyleListBox* CATConfigurationAppGuiProcessContainer::ListBox()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::ListBox()" );
+    
+    return iListBox;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::CreateListBoxItemL()
+// Create a list box item with the given column values.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::CreateListBoxItemL( TDes& aBuffer, 
+    const TDesC& aMainText, const TDesC& aSecondaryText )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::CreateListBoxItemL()" );
+    
+    _LIT ( KStringHeader, "\t%S\t%S" );
+
+    aBuffer.Format( KStringHeader(), &aMainText, &aSecondaryText );
+    } 
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::AddListBoxResourceArrayItemL()
+// Add an item to the list by reading the text items from the array resource.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::AddListBoxResourceArrayItemL( 
+	TInt aResourceId )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::AddListBoxResourceArrayItemL()" );
+    
+    CDesCArray* array = iCoeEnv->ReadDesCArrayResourceL( aResourceId );
+    CleanupStack::PushL( array );
+    _LIT( KSpace, " " );
+    TBuf<KATHundred> main;
+    TBuf<KMaxFileName + 1> secondary;
+    // Get handle to appUi
+    CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )iEikonEnv->AppUi();
+
+    switch ( aResourceId )
+        {
+        case R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM1:
+            {
+            TUint32 number( KErrNone );
+            TUint32 size( KErrNone );
+            TInt currErr = appUi->StorageServer().GetCurrentAllocsL( iProcessId, number, size );
+            if ( currErr == KErrNone )
+                {
+                main.Copy( KSpace );
+                main.AppendNum( number );
+                if ( size >= KATThousand && size < KATMillion ) // kiloByte range
+                    {
+                    TReal value( size );
+                    value = value / KATThousand;
+                    secondary.Format( _L(" %.1f"), value );
+                    secondary.Append( KSpace );
+                    secondary.Append( KATKB );  
+                    }
+                else if ( size >= KATMillion ) // megaByte range
+                    {
+                    TReal value( size );
+                    value = value / KATMillion;
+                    secondary.Format( _L(" %.1f"), value );
+                    secondary.Append( KSpace );
+                    secondary.Append( KATMB );
+                    }
+                else
+                    {
+                    secondary.Copy( KSpace );
+                    secondary.AppendNum( size );
+                    secondary.Append( KSpace );
+                    secondary.Append( KATB );
+                    }
+                }
+            else
+                {
+                main.Copy( KSpace );
+                main.Append( _L("unavailable") );
+                secondary.Copy( KSpace );
+                secondary.Append( _L("unavailable") );
+                }
+            break;
+            }
+        case R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM2:
+            {
+            TUint32 number( KErrNone );
+            TUint32 size( KErrNone );
+            TInt maxErr = appUi->StorageServer().GetMaxAllocsL( iProcessId, number, size );
+            if ( maxErr == KErrNone )
+                {
+                main.Copy( KSpace );
+                main.AppendNum( number );
+                if ( size >= KATThousand && size < KATMillion ) // kiloByte range
+                    {
+                    TReal value( size );
+                    value = value / KATThousand;
+                    secondary.Format( _L(" %.1f"), value );
+                    secondary.Append( KSpace );
+                    secondary.Append( KATKB );  
+                    }
+                else if ( size >= KATMillion ) // megaByte range
+                    {
+                    TReal value( size );
+                    value = value / KATMillion;
+                    secondary.Format( _L(" %.1f"), value );
+                    secondary.Append( KSpace );
+                    secondary.Append( KATMB );
+                    }
+                else
+                    {
+                    secondary.Copy( KSpace );
+                    secondary.AppendNum( size );
+                    secondary.Append( KSpace );
+                    secondary.Append( KATB );
+                    }                   
+                }
+            else
+                {
+                main.Copy( KSpace );
+                main.Append( _L("unavailable") );
+                secondary.Copy( KSpace );
+                secondary.Append( _L("unavailable") );
+                }
+            break;
+            }
+        case R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM3:
+            {
+            secondary.Copy( KSpace );
+            TTime time( iProcessStartTime );
+            TBuf<50> dateString;
+            _LIT( KDateString3,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B" );
+            time.FormatL( dateString, KDateString3 );
+            secondary.Append( dateString );
+            break;
+            }
+        case R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM4:
+            {
+            secondary.Copy( KSpace );
+            TATLogOption loggingMode;
+            TInt loggingErr = appUi->StorageServer().GetLoggingModeL( iProcessId, loggingMode );
+            if ( KErrNone == loggingErr )
+                {
+                if ( EATUseDefault == loggingMode )
+                    {
+                    HBufC* defaultLogging = StringLoader::LoadLC( R_ATCONFIGURATION_APP_XTI_LOGGING );
+                    secondary.Append( defaultLogging->Des() );
+                    CleanupStack::PopAndDestroy( defaultLogging );
+                    }
+                else if ( EATLogToFile == loggingMode )
+                    {
+                    HBufC* fileLogging = StringLoader::LoadLC( R_ATCONFIGURATION_APP_FILE_LOGGING );
+                    secondary.Append( fileLogging->Des() );
+                    CleanupStack::PopAndDestroy( fileLogging );
+                    }
+                else if ( EATLogToXti == loggingMode )
+                    {
+                    HBufC* xtiLogging = StringLoader::LoadLC( R_ATCONFIGURATION_APP_XTI_LOGGING );
+                    secondary.Append( xtiLogging->Des() );
+                    CleanupStack::PopAndDestroy( xtiLogging );
+                    }
+                else if( EATLoggingOff == loggingMode )
+                    {
+                    HBufC* noneLogging = StringLoader::LoadLC( R_ATCONFIGURATION_APP_NONE_LOGGING );
+                    secondary.Append( noneLogging->Des() );
+                    CleanupStack::PopAndDestroy( noneLogging );
+                    }
+                }
+            else
+                {
+                secondary.Append( _L("unavailable") );
+                }
+            break;
+            }
+        case R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM5:
+            {
+            secondary.Copy( KSpace );
+            TUint32 isUdeb;
+            TInt udebErr = appUi->StorageServer().GetUdebL( iProcessId, isUdeb );
+            if ( KErrNone == udebErr )
+                {
+                if ( isUdeb > KErrNone )
+                    {
+                    _LIT( KUdeb, "UDEB" );
+                    secondary.Append( KUdeb() );
+                    }
+                else
+                    {
+                    _LIT( KUrel, "UREL" );
+                    secondary.Append( KUrel() );   
+                    }
+                }
+            else
+                {
+                secondary.Append( _L("unavailable") );
+                }
+            break;
+            }
+        case R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM6:
+            {
+            secondary.Copy( KSpace );
+            TBuf8<KMaxFileName> fileName;
+            TInt fileErr = appUi->StorageServer().GetLoggingFileL( iProcessId, fileName );
+            if ( KErrNone == fileErr )
+                {
+                if ( fileName.Length() > KErrNone )
+                    {
+                    TBuf<KMaxFileName> unicodeFile;
+                    CnvUtfConverter::ConvertToUnicodeFromUtf8( unicodeFile, fileName );
+                    secondary.Append( unicodeFile );
+                    }
+                else
+                    {               
+                    _LIT( KNone, "None" );
+                    secondary.Append( KNone() );
+                    }
+                }
+            else
+                {
+                _LIT( KUnavail, "unavailable" );
+                secondary.Append( KUnavail() );
+                }
+            break;
+            }
+        default:
+            {
+            break;
+            }
+        }
+    HBufC* mainText = HBufC::NewLC( ( *array ) [ 0 ].Length() + main.Length() );
+    HBufC* secondaryText = HBufC::NewLC(( *array ) [ 1 ].Length() + secondary.Length() );
+    mainText->Des().Copy( ( *array ) [ 0 ] );
+    mainText->Des().Append( main );
+    secondaryText->Des().Copy( ( *array ) [ 1 ] );
+    secondaryText->Des().Append( secondary );
+    // This is intended to be large enough, but if you get 
+    // a USER 11 panic, consider reducing string sizes.
+    TBuf<512> listString; 
+    CreateListBoxItemL( listString, mainText->Des(), secondaryText->Des() );
+    AddListBoxItemL( iListBox, listString );
+    CleanupStack::PopAndDestroy( secondaryText );
+    CleanupStack::PopAndDestroy( mainText );
+    CleanupStack::PopAndDestroy( array );
+    } 
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::SetupListBoxIconsL()
+// Set up the list's icon array.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::SetupListBoxIconsL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::SetupListBoxIconsL()" );
+    
+    CArrayPtr< CGulIcon >* icons = NULL;
+
+    if ( icons != NULL )
+        {
+        iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::HandleMarkableListCommandL()
+// Handle commands relating to markable lists.
+// -----------------------------------------------------------------------------
+//
+TBool CATConfigurationAppGuiProcessContainer::HandleMarkableListCommandL( 
+	TInt /*aCommand*/ )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::HandleMarkableListCommandL()" );
+    
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::GetCurrentItemIndex()
+// Returns current listbox index.
+// -----------------------------------------------------------------------------
+//
+TInt CATConfigurationAppGuiProcessContainer::GetCurrentItemIndex()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::GetCurrentItemIndex()" );
+    
+    return iListBox->CurrentItemIndex();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessContainer::UpdateViewL()
+// Update view's controls.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessContainer::UpdateViewL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessContainer::UpdateViewL()" );
+    
+    CTextListBoxModel* model = iListBox->Model();
+    CDesCArray* itemArray = static_cast< CDesCArray* > ( model->ItemTextArray() );
+    itemArray->Reset();
+    
+    // add list items
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM1 );
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM2 );
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM3 );
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM4 );
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM5 );
+    AddListBoxResourceArrayItemL( R_ATCONFIGURATION_APP_GUI_PROCESS_LISTBOX_ITEM6 );
+    
+    iListBox->DrawNow();
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/src/atconfigurationappguiprocessview.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,601 @@
+/*
+* 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 <aknviewappui.h>
+#include <eikmenub.h>
+#include <avkon.hrh>
+#include <barsread.h>
+#include <stringloader.h>
+#include <aknlists.h>
+#include <eikenv.h>
+#include <akniconarray.h>
+#include <eikclbd.h>
+#include <akncontext.h>
+#include <akntitle.h>
+#include <aknnavide.h>
+#include <aknnavi.h>
+#include <eikbtgpc.h>
+#include <aknlistquerydialog.h>
+#include <atconfigurationappgui.rsg>
+
+#include "atconfigurationappgui.hrh"
+#include "atconfigurationappguiprocessview.h"
+#include "atconfigurationappguiprocesscontainer.hrh"
+#include "atconfigurationappguilistbox.hrh"
+#include "atconfigurationappguiprocesscontainer.h"
+#include "atconfigurationappguiappui.h"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::CATConfigurationAppGuiProcessView()
+// First phase of Symbian two-phase construction.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiProcessView::CATConfigurationAppGuiProcessView() :
+    iLogOption( EATUseDefault )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::CATConfigurationAppGuiProcessView()" );
+    
+    iNaviDecorator_ = NULL;
+    iProcessContainer = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::~CATConfigurationAppGuiProcessView()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiProcessView::~CATConfigurationAppGuiProcessView()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::~CATConfigurationAppGuiProcessView()" );
+    
+    if ( iNaviDecorator_ != NULL )
+        {
+        delete iNaviDecorator_;
+        iNaviDecorator_ = NULL;
+        }
+    delete iProcessContainer;
+    iProcessContainer = NULL;
+    
+    // Closes the array and frees all memory allocated to the array.
+    iLibraries.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::NewL()
+// Symbian two-phase constructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiProcessView* CATConfigurationAppGuiProcessView::NewL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::NewL()" );
+    
+    CATConfigurationAppGuiProcessView* self = CATConfigurationAppGuiProcessView::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::NewLC()
+// Symbian two-phase constructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiProcessView* CATConfigurationAppGuiProcessView::NewLC()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::NewLC()" );
+    
+    CATConfigurationAppGuiProcessView* self = new ( ELeave ) CATConfigurationAppGuiProcessView();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::ConstructL()
+// Second-phase constructor for view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessView::ConstructL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::ConstructL()" );
+    
+    BaseConstructL( R_ATCONFIGURATION_APP_GUI_PROCESSCONTAINER_VIEW );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::Id()
+// Returns the UID for this view.
+// -----------------------------------------------------------------------------
+//
+TUid CATConfigurationAppGuiProcessView::Id() const
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::Id()" );
+    
+    return TUid::Uid( EATConfigurationAppGuiProcessViewId );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::HandleCommandL()
+// Handle a command for this view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessView::HandleCommandL( TInt aCommand )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::HandleCommandL()" );
+    
+    // [[[ begin generated region: do not modify [Generated Code]
+    TBool commandHandled = EFalse;
+    switch ( aCommand )
+        { // Code to dispatch to the AknView's menu and CBA commands is generated here
+        case EATConfigurationAppGuiProcessView_librariesMenuItemCommand:
+        	RunListQueryL();
+            commandHandled = ETrue;
+            break;
+        case EAknSoftkeyBack:
+            {
+            AppUi()->ActivateLocalViewL( TUid::Uid( EATConfigurationAppGuiListBoxViewId ) );
+            commandHandled = ETrue;
+            break;
+            }
+        case EATConfigurationAppGuiProcessViewSettingsMenuItemCommand:
+            {
+            AppUi()->ActivateLocalViewL( TUid::Uid( EATConfigurationAppGuiSettingItemListViewId ),
+                    TUid::Uid( EATConfigurationAppGuiProcessViewId ), KNullDesC8 );
+            commandHandled = ETrue;
+            break;
+            }
+        case EATConfigurationAppGuiProcessViewEXTILogOption:
+            {
+            iLogOption = EATLogToXti;
+            commandHandled = ETrue;
+            break;
+            }
+        case EATConfigurationAppGuiProcessViewES60LogOption:
+            {
+            iLogOption = EATLogToFile;
+            commandHandled = ETrue;
+            break;
+            }
+        case EATConfigurationAppGuiProcessViewENoneLogOption:
+            {
+            iLogOption = EATLoggingOff;
+            commandHandled = ETrue;
+            break;
+            }
+        case EATConfigurationAppGuiProcessViewStart_subtestMenuItemCommand:
+            {
+            CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )iEikonEnv->AppUi();
+            appUi->SetProcessSubTestStartL( iProcessId );
+            SetupStatusPaneL();
+            if ( iProcessContainer )
+                {
+                iProcessContainer->UpdateViewL();
+                }
+            break;
+            }
+        case EATConfigurationAppGuiProcessViewStop_subtestMenuItemCommand:
+            {
+            CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )iEikonEnv->AppUi();
+            appUi->SetProcessSubTestStopL( iProcessId );
+            SetupStatusPaneL();
+            if ( iProcessContainer )
+                {
+                iProcessContainer->UpdateViewL();
+                }
+            break;
+            }
+        default:
+            break;
+        }
+        
+    if ( !commandHandled ) 
+        {
+
+        if ( aCommand == EAknSoftkeyBack || 
+             aCommand == EATConfigurationAppGuiProcessViewExitMenuItemCommand )
+            {
+            AppUi()->HandleCommandL( EEikCmdExit );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::DynInitMenuPaneL()
+// Handles dynamically dimming the menu items.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessView::DynInitMenuPaneL( TInt aResourceId, 
+	CEikMenuPane* aMenuPane )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::DynInitMenuPaneL()" );
+    
+    if ( aResourceId == R_ATCONFIGURATION_APP_GUI_PROCESS_MENU_PANE )
+        {
+        if( iProcessContainer->GetCurrentItemIndex() < 0 ) 
+            {
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessViewStart_subtestMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessViewStop_subtestMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessView_librariesMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessViewSet_logging_modeMenuItemCommand, ETrue );
+            } 
+        else {
+            CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )iEikonEnv->AppUi();
+            TInt subTest = appUi->IsSubTestRunning( iProcessId );
+            if ( subTest > KErrNotFound )
+                {
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessViewStart_subtestMenuItemCommand, ETrue );
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessViewStop_subtestMenuItemCommand, EFalse );
+                }
+            else
+                {
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessViewStart_subtestMenuItemCommand, EFalse );
+                aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessViewStop_subtestMenuItemCommand, ETrue );
+                }
+
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessView_librariesMenuItemCommand, EFalse );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessViewSet_logging_modeMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessViewHelpMenuItemCommand, ETrue );
+            aMenuPane->SetItemDimmed( EATConfigurationAppGuiProcessViewSettingsMenuItemCommand, ETrue );
+            }
+        }
+        
+    if ( aResourceId == R_ATCONFIGURATION_APP_GUI_RADIOBUTTON_MENUPANE )
+        {
+        if ( iLogOption == EATUseDefault )
+            aMenuPane->SetItemButtonState( EATConfigurationAppGuiProcessViewEXTILogOption, 
+                                           EEikMenuItemSymbolOn );
+        else if ( iLogOption == EATLogToFile )
+            aMenuPane->SetItemButtonState( EATConfigurationAppGuiProcessViewES60LogOption, 
+                                           EEikMenuItemSymbolOn );
+        else if ( iLogOption == EATLogToXti )
+            aMenuPane->SetItemButtonState( EATConfigurationAppGuiProcessViewEXTILogOption, 
+                                           EEikMenuItemSymbolOn );
+        else if ( iLogOption == EATLoggingOff )
+            aMenuPane->SetItemButtonState( EATConfigurationAppGuiProcessViewENoneLogOption, 
+                                           EEikMenuItemSymbolOn );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::DoActivateL()
+// Handles user actions during activation of the view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessView::DoActivateL( 
+    const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/,
+    const TDesC8& /*aCustomMessage*/ )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::DoActivateL()" );
+    
+    CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )AppUi();
+    iProcessId = appUi->GetCurrentProcessId();
+    iProcessStartTime = appUi->GetCurrentProcessStartTime();
+
+    SetupStatusPaneL();
+
+    if ( iProcessContainer == NULL )
+        {
+        iProcessContainer = CreateContainerL();
+        iProcessContainer->SetMopParent( this );
+        AppUi()->AddToStackL( *this, iProcessContainer );
+        // For supporting MSK context menu
+        MenuBar()->SetContextMenuTitleResourceId( R_ATCONFIGURATION_PROCESS_OPTIONS_MENU );
+        } 
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::DoDeactivate()
+// Handles user actions during deactivation of the view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessView::DoDeactivate()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::DoDeactivate()" );
+    
+    TRAP_IGNORE( CleanupStatusPaneL() );
+
+    if ( iProcessContainer != NULL )
+        {
+        AppUi()->RemoveFromViewStack( *this, iProcessContainer );
+        delete iProcessContainer;
+        iProcessContainer = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::HandleStatusPaneSizeChange()
+// Handle status pane size change for this view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessView::HandleStatusPaneSizeChange()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::HandleStatusPaneSizeChange()" );
+    
+    CAknView::HandleStatusPaneSizeChange();
+
+    // This may fail, but we're not able to propagate exceptions here
+    TInt result;
+    TRAP( result, SetupStatusPaneL() ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::SetupStatusPaneL()
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessView::SetupStatusPaneL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::SetupStatusPaneL()" );
+    
+    // Reset the context pane
+    TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
+    CEikStatusPaneBase::TPaneCapabilities subPaneContext = 
+        StatusPane()->PaneCapabilities( contextPaneUid );
+    if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
+        {
+        CAknContextPane* context = static_cast< CAknContextPane* > ( 
+            StatusPane()->ControlL( contextPaneUid ) );
+        context->SetPictureToDefaultL();
+        }
+
+    // Setup the title pane
+    TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
+    CEikStatusPaneBase::TPaneCapabilities subPaneTitle = 
+        StatusPane()->PaneCapabilities( titlePaneUid );
+    if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
+        {
+        CAknTitlePane* title = static_cast< CAknTitlePane* >( 
+            StatusPane()->ControlL( titlePaneUid ) );
+        //TResourceReader reader;
+        //iEikonEnv->CreateResourceReaderLC( reader, R_ATCONFIGURATION_APP_GUI_TITLE_RESOURCE );
+        //title->SetFromResourceL( reader );
+        //CleanupStack::PopAndDestroy(); // reader internal state
+        
+        // Get process's name
+        RArray<TATProcessInfo> processes;
+        CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )iEikonEnv->AppUi();
+        appUi->StorageServer().GetProcessesL( processes );
+
+        for ( TInt find = 0 ; find < processes.Count() ; find++ )
+            {
+            TATProcessInfo processInfo = processes[ find ];
+            if ( processInfo.iProcessId == iProcessId )
+                {
+                HBufC* name = HBufC::NewLC( processInfo.iProcessName.Length() );
+                name->Des().Copy( processInfo.iProcessName );
+                title->SetTextL( name->Des(), ETrue );
+                CleanupStack::PopAndDestroy( name );
+                break;
+                }
+            }
+		// Closes the array and frees all memory allocated to the array.
+        processes.Close();
+        }
+        
+    // Set the navi pane content
+    TUid naviPaneUid = TUid::Uid( EEikStatusPaneUidNavi );
+    CEikStatusPaneBase::TPaneCapabilities subPaneNavi = 
+        StatusPane()->PaneCapabilities( naviPaneUid );
+    if ( subPaneNavi.IsPresent() && subPaneNavi.IsAppOwned() )
+        {
+        CAknNavigationControlContainer* naviPane = 
+            static_cast< CAknNavigationControlContainer* >( 
+                StatusPane()->ControlL( naviPaneUid ) );
+        if ( iNaviDecorator_ != NULL )
+            {
+            delete iNaviDecorator_;
+            iNaviDecorator_ = NULL;
+            }
+        // Check if subtest is running
+        CATConfigurationAppGuiAppUi* appUi = ( CATConfigurationAppGuiAppUi* )iEikonEnv->AppUi();
+        TInt subTest = appUi->IsSubTestRunning( iProcessId );
+        if ( subTest > KErrNotFound )
+            {
+            HBufC* labelText = StringLoader::LoadLC( R_ATCONFIGURATION_APP_GUI_NAVI_TEXT1 );
+            iNaviDecorator_ = naviPane->CreateNavigationLabelL( labelText->Des() );  
+            CleanupStack::PopAndDestroy( labelText );
+            }
+        else
+            {
+            iNaviDecorator_ = naviPane->CreateNavigationLabelL( KNullDesC ); 
+            }
+        naviPane->PushL( *iNaviDecorator_ );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::CleanupStatusPaneL()
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessView::CleanupStatusPaneL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::CleanupStatusPaneL()" );
+    
+    // Reset the navi pane 
+    TUid naviPaneUid = TUid::Uid( EEikStatusPaneUidNavi );
+    CEikStatusPaneBase::TPaneCapabilities subPaneNavi = 
+        StatusPane()->PaneCapabilities( naviPaneUid );
+    if ( subPaneNavi.IsPresent() && subPaneNavi.IsAppOwned() )
+        {
+        CAknNavigationControlContainer* naviPane = 
+            static_cast< CAknNavigationControlContainer* >( 
+                StatusPane()->ControlL( naviPaneUid ) );
+        if ( iNaviDecorator_ != NULL )
+            {
+            naviPane->Pop( iNaviDecorator_ );
+            delete iNaviDecorator_;
+            iNaviDecorator_ = NULL;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::CreateContainerL()
+// Creates the top-level container for the view.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiProcessContainer* CATConfigurationAppGuiProcessView::CreateContainerL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::CreateContainerL()" );
+    
+    return CATConfigurationAppGuiProcessContainer::NewL( 
+    		ClientRect(), this, this, iProcessId, iProcessStartTime );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::CreateListQuery1ItemL()
+// Create a list box item with the given column values.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessView::CreateListQuery1ItemL( 
+    TDes& aBuffer, const TDesC& aMainText )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::CreateListQuery1ItemL()" );
+    
+    _LIT ( KStringHeader, "%S" );
+
+    aBuffer.Format( KStringHeader(), &aMainText );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::CreateListQuery1ResourceArrayItemL()
+// Add an item to the list by reading the text items from resource.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiProcessView::CreateListQuery1ResourceArrayItemL( 
+        TDes& aBuffer, 
+        TInt aResourceId )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::CreateListQuery1ResourceArrayItemL()" );
+    
+    CDesCArray* array = CCoeEnv::Static()->ReadDesCArrayResourceL( aResourceId );
+    CleanupStack::PushL( array );
+    CreateListQuery1ItemL( aBuffer, ( *array ) [ 0 ] );
+    CleanupStack::PopAndDestroy( array );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::InitializeListQuery1LC()
+// Initialize contents of the popup item list.
+// -----------------------------------------------------------------------------
+//
+CDesCArray* CATConfigurationAppGuiProcessView::InitializeListQuery1LC()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::InitializeListQuery1LC()" );
+    
+    ( ( CATConfigurationAppGuiAppUi* )AppUi() )->StorageServer().GetLoadedDllsL( iProcessId, iLibraries );
+    const int KNumItems = iLibraries.Count();
+    CDesCArray* itemArray = new ( ELeave ) CDesCArrayFlat( KNumItems ? KNumItems : 1 );
+    CleanupStack::PushL( itemArray );
+    // This is intended to be large enough, but if you get 
+    // a USER 11 panic, consider reducing string sizes.
+
+    for ( TInt count = 0 ; count < KNumItems ; count++ )
+        {
+        TBuf<512> des;
+        TBuf<KMaxLibraryName> library;
+        library.Copy( iLibraries[ count ] );
+        CreateListQuery1ItemL( des, library );
+        itemArray->AppendL( des );
+        }
+    
+    // Empties the array, so that it is ready to be reused.
+    iLibraries.Reset();
+    return itemArray;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::SetupListQuery1IconsLC()
+// Set up the list query's icon array.
+// -----------------------------------------------------------------------------
+//
+CArrayPtr< CGulIcon >* CATConfigurationAppGuiProcessView::SetupListQuery1IconsLC()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::SetupListQuery1IconsLC()" );
+    
+    CArrayPtr< CGulIcon >* icons = NULL;
+    return icons;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiProcessView::RunListQueryL()
+// Show the popup list query dialog for listQuery.
+// -----------------------------------------------------------------------------
+//
+TInt CATConfigurationAppGuiProcessView::RunListQueryL( 
+    const TDesC* aOverrideText, CDesCArray* aOverrideItemArray,
+    CArrayPtr< CGulIcon >* aOverrideIconArray )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiProcessView::RunListQueryL()" );
+    
+    TInt index = 0;
+    CAknListQueryDialog* queryDialog = NULL;
+    queryDialog = new ( ELeave ) CAknListQueryDialog( &index );
+    CleanupStack::PushL( queryDialog );
+
+    queryDialog->PrepareLC( R_ATCONFIGURATION_APP_GUI_LIST_QUERY1 );
+    if ( aOverrideText != NULL )
+        {
+        queryDialog->SetHeaderTextL( *aOverrideText );
+        }
+        
+    // Initialize list items
+    CDesCArray* itemArray = NULL;
+
+    if ( aOverrideItemArray != NULL ) 
+        {
+        CleanupStack::PushL( aOverrideItemArray );
+        itemArray = aOverrideItemArray;
+        }
+    else
+        {
+        itemArray = InitializeListQuery1LC();
+        }
+        
+    queryDialog->SetItemTextArray( itemArray );
+    queryDialog->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::Pop( itemArray );
+
+    // Initialize list icons
+    CArrayPtr< CGulIcon >* iconArray = NULL;
+
+    if ( aOverrideIconArray != NULL )
+        {
+        CleanupStack::PushL( aOverrideIconArray );
+        iconArray = aOverrideIconArray;
+        }
+    else
+        {
+        iconArray = SetupListQuery1IconsLC();
+        }
+        
+    if ( iconArray != NULL ) 
+        {
+        queryDialog->SetIconArrayL( iconArray ); // Passes ownership
+        CleanupStack::Pop( iconArray );
+        }
+    // Enable text scrolling
+    queryDialog->ListControl()->Listbox()->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
+    // Run dialog
+    TInt result = queryDialog->RunLD();
+
+    // Clean up
+    CleanupStack::Pop( queryDialog );
+
+    return result == 0 ? -1 : index;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/src/atconfigurationappguisettingitemlist.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,225 @@
+/*
+* 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 <avkon.hrh>
+#include <avkon.rsg>
+#include <eikmenup.h>
+#include <aknappui.h>
+#include <eikcmobs.h>
+#include <barsread.h>
+#include <stringloader.h>
+#include <aknpopupfieldtext.h>
+#include <eikenv.h>
+#include <eikappui.h>
+#include <aknviewappui.h>
+#include <aknslidersettingpage.h> 
+#include <atconfigurationappgui.rsg>
+
+#include "atconfigurationappguisettingitemlist.h"
+#include "atconfigurationappguisettingitemlistsettings.h"
+#include "atconfigurationappgui.hrh"
+#include "atconfigurationappguisettingitemlist.hrh"
+#include "atconfigurationappguisettingitemlistview.h"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemList::CATConfigurationAppGuiSettingItemList()
+// Construct the CATConfigurationAppGuiSettingItemList instance.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiSettingItemList::CATConfigurationAppGuiSettingItemList( 
+        CATConfigurationAppGuiSettingItemListSettings& aSettings, 
+        MEikCommandObserver* aCommandObserver )
+    : iSettings( aSettings ), iCommandObserver( aCommandObserver )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemList::CATConfigurationAppGuiSettingItemList()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemList::~CATConfigurationAppGuiSettingItemList()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiSettingItemList::~CATConfigurationAppGuiSettingItemList()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemList::~CATConfigurationAppGuiSettingItemList()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemList::SizeChanged()
+// Handle system notification that the container's size has changed.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemList::SizeChanged()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemList::SizeChanged()" );
+    
+    if ( ListBox() ) 
+        {
+        ListBox()->SetRect( Rect() );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemList::CreateSettingItemL()
+// Create one setting item at a time, identified by id.
+// -----------------------------------------------------------------------------
+//
+CAknSettingItem* CATConfigurationAppGuiSettingItemList::CreateSettingItemL( 
+	TInt aId )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemList::CreateSettingItemL()" );
+    
+    switch ( aId )
+        {
+        case EATConfigurationAppGuiSettingItemListViewBinarySetting1:
+            {
+            CAknBinaryPopupSettingItem* item = new ( ELeave ) 
+                CAknBinaryPopupSettingItem( 
+                    aId,
+                    iSettings.BinarySetting1() );
+            return item;
+            }
+        case EATConfigurationAppGuiSettingItemListViewEnumeratedTextPopup1:
+            {
+            //CAknEnumeratedTextPopupSettingItem* item = new ( ELeave ) 
+            //CAknEnumeratedTextPopupSettingItem( aId, iSettings.EnumeratedTextPopup1() );
+            CAknTextSettingItem* item = new (ELeave) CAknTextSettingItem( aId, iSettings.EnumeratedTextPopup1() );
+            return item;
+            }
+        }
+        
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemList::EditItemL()
+// Edit the setting item identified by the given id.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemList::EditItemL ( TInt aIndex, 
+	TBool aCalledFromMenu )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemList::EditItemL()" );
+    
+    CAknSettingItem* item = ( *SettingItemArray() )[aIndex];
+
+    if ( ListBox()->CurrentItemIndex() == 1 )// Update interval
+        {
+        TInt setting( iSettings.UpdateInterval() );
+        CAknSliderSettingPage* settPage = new (ELeave) CAknSliderSettingPage
+                  ( R_ATCONFIGURATION_APP_GUI_SLIDER_SETTING_PAGE, setting );
+        CleanupStack::PushL( settPage );
+        
+        TBool accepted = settPage ->ExecuteLD
+            ( CAknSettingPage::EUpdateWhenChanged );
+        
+        if ( accepted )
+            {
+            iSettings.SetUpdateIntervalL( setting );    
+            }
+        CleanupStack::Pop( settPage );
+        item->LoadL();
+        item->UpdateListBoxTextL();
+        }
+    else
+        {
+        switch ( item->Identifier() )
+            {
+            }
+        
+        CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
+
+        switch ( item->Identifier() )
+            {
+            }
+
+        item->StoreL();
+        SaveSettingValuesL();  
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemList::ChangeSelectedItemL()
+// Handle the "Change" option on the Options menu.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemList::ChangeSelectedItemL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemList::ChangeSelectedItemL()" );
+    
+    if ( ListBox()->CurrentItemIndex() >= 0 )
+        {
+        EditItemL( ListBox()->CurrentItemIndex(), ETrue );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemList::LoadSettingValuesL()
+// Load the initial contents of the setting items.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemList::LoadSettingValuesL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemList::LoadSettingValuesL()" );
+    // Load values into iSettings
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemList::SaveSettingValuesL()
+// Save the contents of the setting items.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemList::SaveSettingValuesL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemList::SaveSettingValuesL()" );
+    // Store values from iSettings
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemList::HandleResourceChange()
+// Handle global resource changes.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemList::HandleResourceChange( TInt aType )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemList::HandleResourceChange()" );
+    CAknSettingItemList::HandleResourceChange( aType );
+    SetRect( iAvkonViewAppUi->View( TUid::Uid( EATConfigurationAppGuiSettingItemListViewId ) )->ClientRect() );
+    }
+                
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemList::OfferKeyEventL()
+// Handle key event.
+// -----------------------------------------------------------------------------
+//
+TKeyResponse CATConfigurationAppGuiSettingItemList::OfferKeyEventL( 
+    const TKeyEvent& aKeyEvent, TEventCode aType )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemList::OfferKeyEventL()" );
+    
+    if ( aKeyEvent.iCode == EKeyLeftArrow 
+        || aKeyEvent.iCode == EKeyRightArrow )
+        {
+        // Allow the tab control to get the arrow keys
+        return EKeyWasNotConsumed;
+        }
+
+    return CAknSettingItemList::OfferKeyEventL( aKeyEvent, aType );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/src/atconfigurationappguisettingitemlistsettings.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,161 @@
+/*
+* 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 <e32base.h>
+#include <stringloader.h>
+#include <barsread.h>
+#include <atconfigurationappgui.rsg>
+#include "atconfigurationappguisettingitemlistsettings.h"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListSettings::CATConfigurationAppGuiSettingItemListSettings()
+// C/C++ constructor for settings data.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiSettingItemListSettings::CATConfigurationAppGuiSettingItemListSettings() :
+    iUpdateInterval( 0 )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListSettings::CATConfigurationAppGuiSettingItemListSettings()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListSettings::NewL()
+// Two-phase constructor for settings data.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiSettingItemListSettings* CATConfigurationAppGuiSettingItemListSettings::NewL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListSettings::NewL()" );
+    
+    CATConfigurationAppGuiSettingItemListSettings* data = new( ELeave ) CATConfigurationAppGuiSettingItemListSettings;
+    CleanupStack::PushL( data );
+    data->ConstructL();
+    CleanupStack::Pop( data );
+    return data;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListSettings::ConstructL()
+// Second phase for initializing settings data.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemListSettings::ConstructL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListSettings::ConstructL()" );
+    
+    SetBinarySetting1( 1 );
+    SetEnumeratedTextPopup1L( KNullDesC );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListSettings::BinarySetting1()
+// -----------------------------------------------------------------------------
+//
+TBool& CATConfigurationAppGuiSettingItemListSettings::BinarySetting1()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListSettings::BinarySetting1()" );
+    
+    return iBinarySetting1;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListSettings::SetBinarySetting1()
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemListSettings::SetBinarySetting1( 
+	const TBool& aValue )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListSettings::SetBinarySetting1()" );
+    
+    iBinarySetting1 = aValue;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListSettings::EnumeratedTextPopup1()
+// -----------------------------------------------------------------------------
+//
+TDes& CATConfigurationAppGuiSettingItemListSettings::EnumeratedTextPopup1()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListSettings::EnumeratedTextPopup1()" );
+    
+    return iTemp;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListSettings::UpdateInterval()
+// -----------------------------------------------------------------------------
+//
+TInt CATConfigurationAppGuiSettingItemListSettings::UpdateInterval()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListSettings::UpdateInterval()" );
+    
+    return iUpdateInterval;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListSettings::SetUpdateIntervalL()
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemListSettings::SetUpdateIntervalL( 
+	TInt aUpdateInterval )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListSettings::SetUpdateIntervalL()" );
+    
+    iUpdateInterval = aUpdateInterval;
+    // Update also the text setting shown to the 
+    // user
+    SetEnumeratedTextPopup1L( KNullDesC );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListSettings::SetEnumeratedTextPopup1L()
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemListSettings::SetEnumeratedTextPopup1L( 
+	const TDesC& /*aValue*/ )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListSettings::SetEnumeratedTextPopup1L()" );
+    
+    _LIT( KATSpace, " " );
+    iTemp.Zero();
+    if ( iUpdateInterval > 1 )
+        {
+        iTemp.AppendNum( iUpdateInterval );
+        HBufC* minutes = StringLoader::LoadLC( R_ATCONFIGURATION_APP_GUI_SETTING_ITEM_SECONDS );
+        iTemp.Append( KATSpace );
+        iTemp.Append( minutes->Des() );
+        CleanupStack::PopAndDestroy( minutes );
+        }
+    else if ( iUpdateInterval == KErrNone )
+        {
+        HBufC* offText = StringLoader::LoadLC( R_ATCONFIGURATION_APP_GUI_SETTING_ITEM_OFF );
+        iTemp.Append( offText->Des() );
+        CleanupStack::PopAndDestroy( offText );
+        }
+    /*else
+        {
+            iTemp.AppendNum( iUpdateInterval );
+        HBufC* minute = StringLoader::LoadLC( R_ATCONFIGURATION_APP_GUI_SETTING_ITEM_MINUTE );
+        iTemp.Append( KATSpace );
+        iTemp.Append( minute->Des() );
+        CleanupStack::PopAndDestroy( minute );
+        }*/
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/configurationappgui/src/atconfigurationappguisettingitemlistview.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,268 @@
+/*
+* 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 <aknviewappui.h>
+#include <eikmenub.h>
+#include <avkon.hrh>
+#include <akncontext.h>
+#include <akntitle.h>
+#include <stringloader.h>
+#include <barsread.h>
+#include <eikbtgpc.h>
+#include <atconfigurationappgui.rsg>
+
+#include "atconfigurationappgui.hrh"
+#include "atconfigurationappguisettingitemlistview.h"
+#include "atconfigurationappguisettingitemlist.hrh"
+#include "atconfigurationappguisettingitemlist.h"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::CATConfigurationAppGuiSettingItemListView()
+// First phase of Symbian two-phase construction.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiSettingItemListView::CATConfigurationAppGuiSettingItemListView() :
+iLastViewId( TUid::Uid( EATConfigurationAppGuiListBoxViewId ) )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::CATConfigurationAppGuiSettingItemListView()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::~CATConfigurationAppGuiSettingItemListView()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiSettingItemListView::~CATConfigurationAppGuiSettingItemListView()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::~CATConfigurationAppGuiSettingItemListView()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::NewL()
+// Symbian two-phase constructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiSettingItemListView* CATConfigurationAppGuiSettingItemListView::NewL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::NewL()" );
+    
+    CATConfigurationAppGuiSettingItemListView* self = CATConfigurationAppGuiSettingItemListView::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::NewLC()
+// Symbian two-phase constructor.
+// -----------------------------------------------------------------------------
+//
+CATConfigurationAppGuiSettingItemListView* CATConfigurationAppGuiSettingItemListView::NewLC()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::NewLC()" );
+    
+    CATConfigurationAppGuiSettingItemListView* self = new ( ELeave ) CATConfigurationAppGuiSettingItemListView();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::ConstructL()
+// Second-phase constructor for view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemListView::ConstructL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::ConstructL()" );
+    
+    BaseConstructL( R_ATCONFIGURATION_APP_GUI_SETTING_ITEM_LIST_VIEW );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::Id()
+// Returns the UID for this view.
+// -----------------------------------------------------------------------------
+//
+TUid CATConfigurationAppGuiSettingItemListView::Id() const
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::Id()" );
+    
+    return TUid::Uid( EATConfigurationAppGuiSettingItemListViewId );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::HandleCommandL()
+// Handle a command for this view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemListView::HandleCommandL( TInt aCommand )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::HandleCommandL()" );
+    
+    TBool commandHandled = EFalse;
+    switch ( aCommand )
+        { // Code to dispatch to the AknView's menu and CBA commands is generated here
+        case EATConfigurationAppGuiSettingItemListViewMenuItem1Command:
+            commandHandled = HandleChangeSelectedSettingItemL( aCommand );
+            break;
+        case EAknSoftkeyBack:
+            {
+            AppUi()->ActivateLocalViewL( iLastViewId );
+            commandHandled = ETrue;
+            break;    
+            }
+        default:
+            break;
+        }
+
+        
+    if ( !commandHandled ) 
+        {
+
+        if ( aCommand == EAknSoftkeyBack )
+            {
+            AppUi()->HandleCommandL( EEikCmdExit );
+            }
+
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::DoActivateL()
+// Handles user actions during activation of the view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemListView::DoActivateL( 
+        const TVwsViewId& /*aPrevViewId*/,
+        TUid aCustomMessageId,
+        const TDesC8& /*aCustomMessage*/ )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::DoActivateL()" );
+    
+    SetupStatusPaneL();
+    iLastViewId = aCustomMessageId;
+
+    if ( iATConfigUISettingItemList == NULL )
+        {
+        iSettings = CATConfigurationAppGuiSettingItemListSettings::NewL();
+        iATConfigUISettingItemList = new ( ELeave ) CATConfigurationAppGuiSettingItemList( *iSettings, this );
+        iATConfigUISettingItemList->SetMopParent( this );
+        iATConfigUISettingItemList->ConstructFromResourceL( R_ATCONFIGURATION_APP_GUI_SETTING_ITEM_LIST );
+        iATConfigUISettingItemList->ActivateL();
+        iATConfigUISettingItemList->LoadSettingValuesL();
+        iATConfigUISettingItemList->LoadSettingsL();
+        AppUi()->AddToStackL( *this, iATConfigUISettingItemList );
+        } 
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::DoDeactivate()
+// Handles user actions during deactivation of the view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemListView::DoDeactivate()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::DoDeactivate()" );
+    
+    CleanupStatusPane();
+
+    if ( iATConfigUISettingItemList != NULL )
+        {
+        AppUi()->RemoveFromStack( iATConfigUISettingItemList );
+        delete iATConfigUISettingItemList;
+        iATConfigUISettingItemList = NULL;
+        delete iSettings;
+        iSettings = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::HandleStatusPaneSizeChange()
+// Handle status pane size change for this view.
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemListView::HandleStatusPaneSizeChange()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::HandleStatusPaneSizeChange()" );
+    
+    CAknView::HandleStatusPaneSizeChange();
+
+    // This may fail, but we're not able to propagate exceptions here
+    TInt result;
+    TRAP( result, SetupStatusPaneL() ); 
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::SetupStatusPaneL()
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemListView::SetupStatusPaneL()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::SetupStatusPaneL()" );
+    
+    // Reset the context pane
+    TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
+    CEikStatusPaneBase::TPaneCapabilities subPaneContext = 
+        StatusPane()->PaneCapabilities( contextPaneUid );
+    if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
+        {
+        CAknContextPane* context = static_cast< CAknContextPane* > ( 
+            StatusPane()->ControlL( contextPaneUid ) );
+        context->SetPictureToDefaultL();
+        }
+
+    // Setup the title pane
+    TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
+    CEikStatusPaneBase::TPaneCapabilities subPaneTitle = 
+        StatusPane()->PaneCapabilities( titlePaneUid );
+    if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
+        {
+        CAknTitlePane* title = static_cast< CAknTitlePane* >( 
+            StatusPane()->ControlL( titlePaneUid ) );
+        TResourceReader reader;
+        iEikonEnv->CreateResourceReaderLC( reader, R_ATCONFIGURATION_APP_GUI_SETTINGS_TITLE_RESOURCE );
+        title->SetFromResourceL( reader );
+        CleanupStack::PopAndDestroy(); // Reader internal state
+        }
+                
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::CleanupStatusPane()
+// -----------------------------------------------------------------------------
+//
+void CATConfigurationAppGuiSettingItemListView::CleanupStatusPane()
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::CleanupStatusPane()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CATConfigurationAppGuiSettingItemListView::HandleChangeSelectedSettingItemL()
+// Handle the selected event.
+// -----------------------------------------------------------------------------
+//
+TBool CATConfigurationAppGuiSettingItemListView::HandleChangeSelectedSettingItemL( 
+	TInt /*aCommand*/ )
+    {
+    LOGSTR1( "ATCU CATConfigurationAppGuiSettingItemListView::HandleChangeSelectedSettingItemL()" );
+    
+    iATConfigUISettingItemList->ChangeSelectedItemL();
+    return ETrue;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/consoleui/group/atconsoleui.mmp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* 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 Console UI.
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET          atool.exe
+TARGETTYPE      exe
+SECUREID		0x20012433
+CAPABILITY      PowerMgmt
+
+SMPSAFE
+
+MW_LAYER_SYSTEMINCLUDE
+OS_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+
+SOURCEPATH      ../src
+
+SOURCE          atconsoleui.cpp
+SOURCE          atconsoleviews.cpp
+
+LIBRARY         euser.lib charconv.lib ws32.lib apgrfx.lib 
+LIBRARY			atoolstorageserverclnt.lib
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/consoleui/group/bld.inf	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,32 @@
+/*
+* 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
+
+PRJ_TESTEXPORTS
+
+PRJ_MMPFILES
+atconsoleui.mmp
+
+PRJ_TESTMMPFILES
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/consoleui/inc/atconsoleui.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,302 @@
+/*
+* 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 ATCONSOLE_UI_H
+#define ATCONSOLE_UI_H
+
+//  INCLUDE
+#include <e32std.h>
+#include <e32base.h>
+
+#include <analyzetool/atstorageserverclnt.h>
+#include <analyzetool/analyzetool.h>
+
+// CONSTANTS
+const TInt KMaxLineLength = 80;            // Max. line length
+const TInt KScrollPeriod = 300000;		   // scrolling period
+const TUint32 KATHundred = 100;
+const TUint32 KATThousand = 1000;
+const TUint32 KATMillion = 1000000;
+_LIT( KATB, "B" );
+_LIT( KATKB, "KB" );
+_LIT( KATMB, "MB" );
+
+// MACROS
+
+// FORWARD DECLARATIONS
+class CView;
+class CConsoleMain;
+class CConsoleReader;
+
+// CLASS DECLARATION
+
+/**
+ * @class CScrollerTimer atconsoleui.h
+ * @brief The CSrollerTimer is used for updating the application
+ * user interface.
+ */
+class CScrollerTimer
+        :public CActive
+    {       
+    public:  // Constructors and destructor
+
+        /**
+        * NewL is first phase of two-phased constructor.
+        */
+        static CScrollerTimer* NewL( CConsoleMain* aMain );
+
+        /**
+        * Destructor of CModule.
+        */
+        ~CScrollerTimer();
+
+    public: // New functions
+
+		/** 
+        * StartL
+        */
+		void StartL();
+
+		/** 
+        * RunL
+        */
+		void RunL();
+
+		/** 
+        * DoCancel
+        */
+		void DoCancel();
+
+		/** 
+        * RunError
+        */
+		TInt RunError ( TInt aError );
+
+    private:
+
+        /** 
+        * C++ default constructor.
+        */
+        CScrollerTimer();
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL( CConsoleMain* aMain );
+
+    protected:  // Data
+        // None
+
+    private:    // Data
+        CConsoleMain*     iMain;            // Pointer to main console
+		RTimer            iTimer;
+    };
+
+/**
+ * @class CConsoleMain atconsoleui.h
+ * @brief The CConsoleMain is main class for constructing the console
+ * application.
+ */
+class CConsoleMain: public CBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * NewL is first phase of two-phased constructor.
+        */
+        static CConsoleMain* NewL();
+
+        /**
+        * Start
+        */
+        TInt StartL();
+
+        /**
+        * Returns the array of processes under testing
+        */
+        RArray<TATProcessInfo> Processes();
+
+        /**
+        * Returns handle to the storage server
+        * @return RATStorageServer handle to the storage server
+        */  
+        inline RATStorageServer StorageServer()
+            {
+            return iStorageServer;    
+            }
+
+        /**
+        * Starts a subtest for a process.
+        * @param aProcessId ID of the process
+        */
+        void SetProcessSubTestStart( TUint aProcessId );
+        
+        /**
+        * Stops a subtest for a process.
+        * @param aProcessId ID of the process
+        */
+        
+        void SetProcessSubTestStop( TUint aProcessId );
+        
+        /**
+        * Checks if subtest is running for a process.
+        * @param aProcessId ID of the process
+        * @return The index of the first matching aProcessId 
+        * within the array. KErrNotFound, if no matching 
+        * aProcessId can be found.
+        */
+        TInt IsSubTestRunning( TUint aProcessId );
+        
+        /**        
+        * Stops all the subtests currently running.
+        */   
+        void StopAllSubtestsL();
+        
+        /**
+        * Destructor of CConsoleMain.
+        */
+        ~CConsoleMain();
+        
+        /**
+        * Updates processes.
+        */       
+        void UpdateProcessesL();
+
+
+    public: // New functions
+
+        /**
+        * Close instance.
+        */
+        void Close( TInt aHandle );
+
+        /**
+        * Return pointer to console
+        */
+        CConsoleBase* GetConsole();
+
+        /**
+        * Called from timer to perform scrolling
+        */
+        void TimerUpdate();
+                
+        /**
+        * Process keystokes.
+        */
+        void KeyPressedL();
+
+    private:
+
+        /** 
+        * C++ default constructor.
+        */
+        CConsoleMain();
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+        
+    protected:  // Data
+        // None
+
+    private:    // Data
+        CConsoleBase*       iConsole;       // Pointer to console
+
+        CView*              iMainView;      // Root menu
+        CView*              iCurrentView;   // Current menu
+
+        CScrollerTimer*     iScroller;
+        
+        CConsoleReader*     iReader;        // Console reader                   
+        // Handle to the RATStorageServer
+        RATStorageServer iStorageServer;
+        // Array of processes under testing
+        RArray<TATProcessInfo> iProcesses;
+        // array containing all the processes which subtest is running
+        RArray<TUint> iSubTestProcesses;
+        TBool             iStorageServerOpen;
+    };
+    
+/**
+ * @class CConsoleReader atconsoleui.h
+ * @brief The CConsoleReader is reading keystrokes from console.
+ */
+class CConsoleReader
+    :public CActive
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * NewL is first phase of two-phased constructor.
+        */
+        static CConsoleReader* NewL( CConsoleMain* aMain, 
+                                     CConsoleBase* aConsole );
+
+        /**
+        * Start
+        */
+        void StartL();
+
+        /**
+        * Destructor of CConsoleReader.
+        */
+        ~CConsoleReader();
+
+    public: // Functions from base classes
+
+        /**
+        * RunL derived from CActive handles the completed requests.
+        */
+        void RunL();
+
+        /**
+        * DoCancel derived from CActive handles the Cancel
+        */
+        void DoCancel();
+        /**
+        * RunError derived from CActive handles errors from active object
+        */        
+        virtual TInt RunError(TInt aError);
+
+    private:
+
+        /** 
+        * C++ default constructor.
+        */
+        CConsoleReader( CConsoleMain* aMain, 
+                        CConsoleBase* iConsole );
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL();
+
+    public:   //Data
+        // None
+    
+    protected:  // Data
+        // None
+
+    private:    // Data
+        CConsoleBase*   iConsole;   // Pointer to console
+        CConsoleMain*   iMain;      // Pointer to the CConsoleMain
+    };
+
+#endif // ATCONSOLEUI_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/consoleui/inc/atconsoleviews.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,316 @@
+/*
+* 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 ATCONSOLE_VIEWS_H
+#define ATCONSOLE_VIEWS_H
+
+
+//  INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+
+// CONSTANTS
+const TInt KViewOverhead = 4;
+
+// Numeric key ascii code values for ATConsoleUI's menu
+const TInt KMyKeyDownAsciiCode = 56; // Ascii code for number '8'
+const TInt KMyKeyLeftAsciiCode = 52; // Ascii code for number '4'
+const TInt KMyKeyRightAsciiCode = 54; // Ascii code for number '6'
+const TInt KMyKeyUpAsciiCode = 50;  // Ascii code for number '2'
+
+// FORWARD DECLARATIONS
+class CView;
+class CConsoleMain;
+
+// CLASS DECLARATION
+
+/**
+ * @class CView atconsoleviews.h
+ * @brief The CView is used for making views needed in the console
+ * application.
+ */
+class CView
+        :public CBase
+    {
+    public:  // Enumerations
+        enum TUpdateType
+            {
+            EViewPrint,
+            EViewRefresh,
+            };
+
+    public:  // Constructors and destructor
+        // None
+
+        /**
+        * NewL is first phase of two-phased constructor.
+        */
+        static CView* NewL( CConsoleMain* aConsole,
+                            CView* aParent,
+                            const TDesC& aName, TInt64 aProcessId );
+
+       /**
+        * Destructor of CConsoleMain.
+        */
+        virtual ~CView();
+
+    public: // New functions
+    
+        /** 
+        * Return menu name
+        */
+        virtual const TDesC& Name() const;
+
+        /** 
+        * Return item texts.
+        */
+        virtual TInt ItemTexts( RArray<TDesC>& aArray );
+
+        /** 
+        * Prints the view
+        */
+        virtual void PrintViewL( TUpdateType  aType );
+
+        /** 
+        * Process keypresses on this menu
+        */
+        virtual CView* SelectL( TKeyCode aSelection, TBool& aContinue );
+
+        /** 
+        * Set parent menu
+        */
+        virtual void SetParent ( CView* aMenu );
+
+        /** 
+        * Print line
+        */
+        virtual void Print( const TDesC& aPrint );
+
+        /** 
+        * Add item to menu
+        */
+        virtual void AddItemL ( CView* aItem );
+
+        /** 
+        * Resets the item list
+        */
+        virtual void ResetItems();
+
+        /** 
+        * Update display from timer
+        */
+		virtual void TimerUpdate();
+		
+		/**
+		* Append text before original text.
+		*/
+		virtual void AppendBefore(  TInt aLineNum, TDes& aLine );
+		
+		/**
+		* Get menu type.
+		*/
+		inline TInt Type(){ return iType; };
+		
+		/**
+		* Map KeyCode 
+		*/
+		void MapKeyCode( TKeyCode &aSelection );
+
+    protected:  // Functions from base classes
+        // None    
+
+        /** 
+        * C++ default constructor.
+        */
+        CView();
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL( CConsoleMain* aConsole,
+                         CView* aParent,
+                         const TDesC& aName, TInt64 aProcessId );
+
+    protected:  // Data    
+    
+        CConsoleBase*           iConsole;      // Pointer to console
+        CConsoleMain*           iMain;         // Pointer to main console
+        CView*                  iParent;       // Pointer to parent menu
+        TName                   iViewName;         // Menu name
+        TInt64                  iProcessId;    // Process id of the menu
+
+        RPointerArray<CView>    iItems;        // Menu items
+
+        TInt                    iPositionOnScreen;  // Position on display
+        TInt                    iFirstItem;        // First displayed item
+        TInt                    iLastItem;         // Last displayed item
+        TInt                    iItemCount;    // Last Item
+        TSize                   iSize;         // Display size
+        TInt                    iScreenSize;   // "Work area" size
+		TInt                    iDirection;    // Scrolling direction
+		TInt                    iStart;        // Scrolling position
+		TInt                    iPrevPos;      // Previous position in scrolling
+        // Menu type (which updates must cause console update) 
+        TInt                    iType;
+		TUpdateType             iUpdateType;
+		// Determines if libraries are to be shown
+		TBool   iShowLibraries;
+		// Determines if set logging mode query is to be shown
+		TBool iSetLoggingMode;
+    };
+
+/**
+ * @class CProcessInfoView atconsoleviews.h
+ * @brief The CProcessInfoView is used for showing information about
+ * some process and starting/stopping subtests.
+ */
+class CProcessInfoView 
+    :public CView
+  
+    {
+
+    private: // Enumerations
+        enum TProcessInfoView
+            {
+            EStartSubtestTxtItem,
+            EStopSubtestTxtItem,
+            EViewLibrariesTxtItem,
+            EEndProcessTxtItem,
+            EKillProcessTxtItem,
+            ECancelLoggingTxtItem
+            };
+
+        enum TProcessEnds
+            {
+            ETryToEnd,
+            ETryToKill
+            };
+            
+    public:  // Constructors and destructor
+
+        /**
+        * NewL is first phase of two-phased constructor.
+        */
+        static CProcessInfoView* NewL( CConsoleMain* aConsole,
+                                      CView* aParent,
+                                      const TDesC& aName, TInt64 aProcessId );
+
+       /**
+        * Destructor
+        */
+        ~CProcessInfoView();
+
+    public: // Functions from base classes
+
+        /** 
+        * Return item texts.
+        */
+        virtual TInt ItemTexts( RArray<TDesC>& aArray );
+        
+        /** 
+        * Process keypresses on this menu
+        */
+        virtual CView* SelectL( TKeyCode aSelectLion, 
+                                TBool& aContinue );
+ 
+        /** 
+        * Prints the view
+        */
+        virtual void PrintViewL( TUpdateType  aType );
+        
+        /** 
+        * Prints libraries
+        */
+        void ViewLibrariesL();
+ 
+        /** 
+        * Prints logging modes
+        */
+        void SetLoggingModeL();
+        
+        /**
+        * Ends a process with a certain method.
+        * @param aCommand command id
+        */
+        void EndProcessL( TInt aCommand );
+        
+    protected:  // New functions
+        // None
+
+    protected:  // Functions from base classes
+        // None
+       
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL( CConsoleMain* aConsole, 
+                         CView* aParent,
+                         const TDesC& aName, TInt64 aProcessId );
+
+    private:    // Data
+        // Current opened process's info
+        TATProcessInfo iCurrentProcessInfo;
+        
+    };
+
+// CONSTANTS
+_LIT( KExitTxt,     "Exit" );
+
+/**
+ * @class CMainView atconsoleviews.h
+ * @brief The CMainView is used for showing all the processes
+ * currently under testing.
+ */
+class CMainView 
+    :public CView
+  
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * NewL is first phase of two-phased constructor.
+        */
+        static CMainView* NewL( CConsoleMain* aConsole, 
+                                CView* aParent, 
+                                const TDesC& aName );
+
+    public: // Functions from base classes    
+
+        /** 
+        * Return item texts.
+        */
+        virtual TInt ItemTexts( RArray<TDesC>& aArray );
+
+        /** 
+        * Process keypresses on this menu
+        */
+        virtual CView* SelectL( TKeyCode aSelectLion, TBool& aContinue );
+
+    protected:  // Functions from base classes
+
+        /**
+        * By default Symbian OS constructor is private.
+        */
+        void ConstructL( CConsoleMain* aConsole, 
+                         CView* aParent,
+                         const TDesC& aName );
+
+    };
+ 
+#endif // ATCONSOLE_VIEWS_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/consoleui/src/atconsoleui.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,728 @@
+/*
+* 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 FILES
+#include <e32base.h>
+#include <e32cons.h>
+#include <e32svr.h>
+#include <f32file.h>
+
+#include "atconsoleui.h"
+#include "atconsoleviews.h"
+
+
+// CONSTANTS
+_LIT( KNameTxt, "AT CONSOLE UI" );
+
+// FORWARD DECLARATIONS
+LOCAL_C void MainL();
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::NewL()
+// Construct the console main class.
+// -----------------------------------------------------------------------------
+//
+CConsoleMain* CConsoleMain::NewL( )
+    {
+    CConsoleMain* self = new ( ELeave ) CConsoleMain();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::ConstructL()
+// Second level constructor.
+// -----------------------------------------------------------------------------
+//
+void CConsoleMain::ConstructL( )
+    {
+    // Construct the console
+    iConsole = Console::NewL( KNameTxt,
+                             TSize( KConsFullScreen, KConsFullScreen ) );
+    
+    iStorageServerOpen = EFalse;
+
+    iConsole->Printf(_L("\nAnalyzeTool console starting\n"));
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::CConsoleMain()
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+CConsoleMain::CConsoleMain()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::~CConsoleMain()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CConsoleMain::~CConsoleMain()
+    {
+    // Close storage server
+    iStorageServer.Close();
+    
+    delete iReader;
+    iReader = NULL;
+    
+    delete iScroller;
+    iScroller = NULL;
+    
+    delete iConsole;
+    iConsole = NULL;
+
+    delete iMainView;
+    iMainView = NULL;
+    
+    iSubTestProcesses.Close();
+    
+    iProcesses.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::StartL()
+// Construct menu objects and start the menu handling.
+// -----------------------------------------------------------------------------
+//
+TInt CConsoleMain::StartL()
+    {
+    // Construct keystroke reader
+    iReader = CConsoleReader::NewL( this, iConsole );
+    // Construct the main menu
+    iMainView = CMainView::NewL( this, NULL, _L( "Processes view" ) );
+    // Connect to the storage server
+    TInt error = iStorageServer.Connect();
+    if( error != KErrNone )
+        {
+        // Notify if error occurs
+        }
+    else
+        {
+        iStorageServerOpen = ETrue;
+        iStorageServer.GetProcessesL( iProcesses );
+        }
+    
+    // TEST
+    /*TATProcessInfo pr1;
+    pr1.iProcessId = 1;
+    TBuf8<KMaxProcessName> pr1Name;
+    pr1Name.Copy( _L("MemoryLeaker.exe") );
+    pr1.iProcessName.Copy( pr1Name );
+    pr1.iStartTime = 1234556789;
+    iProcesses.Append( pr1 );
+
+    TATProcessInfo pr2;
+    pr2.iProcessId = 2;
+    TBuf8<KMaxProcessName> pr2Name;
+    pr2Name.Copy( _L("ConsoleApplication.exe") );
+    pr2.iProcessName.Copy( pr2Name );
+    pr2.iStartTime = 12345567559;
+    iProcesses.Append( pr2 );
+    
+    TATProcessInfo pr3;
+    pr3.iProcessId = 3;
+    TBuf8<KMaxProcessName> pr3Name;
+    pr3Name.Copy( _L("Player.exe") );
+    pr3.iProcessName.Copy( pr3Name );
+    pr3.iStartTime = 1234577789;
+    iProcesses.Append( pr3 );*/
+    // TEST END
+    
+    if ( iProcesses.Count() > KErrNone )
+        {
+        CView* processMenu  = NULL;
+        for ( TInt count = 0 ; count < iProcesses.Count() ; count++ )
+            {
+            TBuf<KMaxProcessName> processName;
+            processName.Copy( iProcesses[ count ].iProcessName );
+            TInt64 processId = iProcesses[ count ].iProcessId;
+            // Create and add menu
+            processMenu   = CProcessInfoView::NewL( this, iMainView, processName, processId );
+            iMainView->AddItemL( processMenu );  
+            }           
+        }
+           
+    iScroller = CScrollerTimer::NewL ( this );
+    iScroller->StartL();
+    // Print the main menu
+    iCurrentView = iMainView;
+    iCurrentView->PrintViewL( CView::EViewPrint );
+    // Start to process keyboard events
+    iReader->StartL();
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::Processes()
+// Returns processes.
+// -----------------------------------------------------------------------------
+//
+RArray<TATProcessInfo> CConsoleMain::Processes()
+    {
+    return iProcesses;
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::KeyPressedL()
+// Process keyboard events. Print new menu.
+// -----------------------------------------------------------------------------
+//
+void CConsoleMain::KeyPressedL()
+    {
+    TBool cont = ETrue;
+    // Read the key
+    TKeyCode key = iConsole->KeyCode();
+    CView* tmp = iCurrentView;
+    // Update the screen
+    TimerUpdate();
+    
+    // Let the menu handle the key press
+    TRAPD( err, 
+        iCurrentView = iCurrentView->SelectL( key, cont );
+        );
+    
+    if( err != KErrNone )
+        {
+        User::InfoPrint( 
+            _L( "Processing keystroke failed" ) );  
+        }
+            
+    if ( iCurrentView == NULL )
+        {
+            iCurrentView = tmp;
+        }
+
+   // If "not-exit" key pressed, continue
+    if ( cont )
+        {
+        // Either only update old menu or new menu.
+        if ( tmp == iCurrentView )
+            {
+            TRAP( err, iCurrentView->PrintViewL( CView::EViewRefresh ); );
+            }
+        else
+            {
+            TRAP( err, iCurrentView->PrintViewL( CView::EViewPrint ); )
+            }
+        if( err != KErrNone )
+            {
+            User::InfoPrint( 
+                _L( "Printing view failed" ) );  
+            }
+        // Enable keystrokes
+        iReader->StartL();
+        }
+    else
+        {
+        // Stop all subtests before closing handles
+        StopAllSubtestsL();
+        // "Exit", stop scheduler and exit
+        CActiveScheduler::Stop();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::StopAllSubtestsL()
+// Stops all subtests which are running
+// -----------------------------------------------------------------------------
+//
+void CConsoleMain::StopAllSubtestsL()
+    {
+    TInt index( KErrNone );
+    RArray<TATProcessInfo> processes;
+    iStorageServer.GetProcessesL( processes );
+    while ( index < processes.Count() )
+        {
+        TUint processId = processes[ index ].iProcessId;
+        _LIT8( KSubTestId, "ATConsoleUiSubTest" );
+        TInt stopErr = iStorageServer.StopSubTest( processId, KSubTestId );
+        TInt find = iSubTestProcesses.Find( processId );
+        
+        if ( find > KErrNotFound )
+            {
+            iSubTestProcesses.Remove( find );
+            if ( iSubTestProcesses.Count() == KErrNone )
+                {
+                iSubTestProcesses.Reset();
+                }  
+            }
+        
+        index++;
+        }
+    processes.Close();
+    }
+    
+// -----------------------------------------------------------------------------
+// CConsoleMain::Close()
+// Close instance.
+// -----------------------------------------------------------------------------
+//
+void CConsoleMain::Close( TInt aHandle )
+    {
+    if( aHandle < 0 )
+        {
+        return;
+        } 
+    }
+           
+// -----------------------------------------------------------------------------
+// CConsoleMain::GetConsole()
+// Returns the console.
+// -----------------------------------------------------------------------------
+//
+CConsoleBase* CConsoleMain::GetConsole()
+    {
+    return iConsole;
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::TimerUpdate()
+// Updates current menu from timer.
+// -----------------------------------------------------------------------------
+//
+void CConsoleMain::TimerUpdate()
+    {
+    // Update processes
+    if ( iCurrentView->Name().Compare( _L( "Processes view" ) ) == KErrNone )
+        {
+        UpdateProcessesL();
+        iCurrentView->ResetItems();
+        if ( iProcesses.Count() > KErrNone )
+            {
+            CView* processMenu  = NULL;
+            for ( TInt count = 0 ; count < iProcesses.Count() ; count++ )
+                {
+                TBuf<KMaxProcessName> processName;
+                processName.Copy( iProcesses[ count ].iProcessName );
+                TInt64 processId = iProcesses[ count ].iProcessId;
+                // Create and add menu
+                processMenu   = CProcessInfoView::NewL( this, iMainView, processName, processId );
+                iMainView->AddItemL( processMenu );  
+                }           
+             }                      
+        }
+    iCurrentView->TimerUpdate();
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::UpdateProcessesL()
+// Updates processes.
+// -----------------------------------------------------------------------------
+//
+void CConsoleMain::UpdateProcessesL()
+    {
+    if ( iStorageServerOpen )
+        {
+        iStorageServer.GetProcessesL( iProcesses );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::SetProcessSubTestStart()
+// Starts subtest for a process.
+// -----------------------------------------------------------------------------
+//
+void CConsoleMain::SetProcessSubTestStart( TUint aProcessId )
+    {
+    // load the kernel side device driver
+    TInt loadErr = User::LoadLogicalDevice( KAnalyzeToolLddName );
+    TBool driverLoaded( EFalse );
+            
+    if ( loadErr == KErrNone || loadErr == KErrAlreadyExists )
+        {
+        driverLoaded = ETrue;
+        }
+        
+    RAnalyzeTool analyzeTool;
+    
+    TInt driverOpen = analyzeTool.Open();
+    TInt handleCount( KErrNone );
+    
+    if ( driverOpen == KErrNone )
+        {       
+        TATProcessHandlesBuf params;
+        params().iProcessId = aProcessId;
+        
+        analyzeTool.GetCurrentHandleCount( params );
+        handleCount = params().iCurrentHandleCount;
+        }
+        
+    _LIT8( KSubTestId, "ATConsoleUiSubTest" );
+    TInt startErr = iStorageServer.StartSubTest( aProcessId, KSubTestId, handleCount );
+    if ( KErrNone == startErr )
+        {
+        iSubTestProcesses.Append( aProcessId );
+        }
+
+    // The count of device driver users
+    TClientCountBuf count;
+    
+    // Check the flag
+    if ( driverOpen == KErrNone )
+        {
+        analyzeTool.ClientCount( count );
+        analyzeTool.Close();
+        }  
+    // Check the flag
+    if ( driverLoaded )
+        {
+        // Check if there is another user for device driver
+        if ( count().iClientCount <= 1 )
+            {
+            // There was no other users -> unload the device driver
+            User::FreeLogicalDevice( KAnalyzeToolLddName );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::SetProcessSubTestStop()
+// Stops subtest for a process.
+// -----------------------------------------------------------------------------
+//
+void CConsoleMain::SetProcessSubTestStop( TUint aProcessId )
+    {
+    // Load the kernel side device driver
+    TInt loadErr = User::LoadLogicalDevice( KAnalyzeToolLddName );
+    TBool driverLoaded( EFalse );
+            
+    if ( loadErr == KErrNone || loadErr == KErrAlreadyExists )
+        {
+        driverLoaded = ETrue;
+        }
+        
+    RAnalyzeTool analyzeTool;
+    
+    TInt driverOpen = analyzeTool.Open();
+    TInt handleCount( KErrNone );
+    
+    if ( driverOpen == KErrNone )
+        {  
+        TATProcessHandlesBuf params;
+        params().iProcessId = aProcessId;
+        
+        analyzeTool.GetCurrentHandleCount( params );
+        handleCount = params().iCurrentHandleCount;
+        }
+        
+    _LIT8( KSubTestId, "ATConsoleUiSubTest" );
+    TInt stopErr = iStorageServer.StopSubTest( aProcessId, KSubTestId, handleCount );
+    if ( KErrNone == stopErr )
+        {
+        TInt index = iSubTestProcesses.Find( aProcessId );
+        if ( index > KErrNotFound )
+            {
+            iSubTestProcesses.Remove( index );
+            if ( iSubTestProcesses.Count() == KErrNone )
+                iSubTestProcesses.Reset();
+            }             
+        }
+
+    // The count of device driver users
+    TClientCountBuf count;
+    
+    // Check the flag
+    if ( driverOpen == KErrNone )
+        {
+        analyzeTool.ClientCount( count );
+        analyzeTool.Close();
+        }
+    
+    // Check the flag
+    if ( driverLoaded )
+        {
+        // Check if there is another user for device driver
+        if ( count().iClientCount <= 1 )
+            {
+            // There was no other users -> unload the device driver
+            User::FreeLogicalDevice( KAnalyzeToolLddName );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleMain::IsSubTestRunning()
+// Returns ETrue if subtest is running for a process.
+// -----------------------------------------------------------------------------
+//
+TInt CConsoleMain::IsSubTestRunning( TUint aProcessId )
+    {
+    return iSubTestProcesses.Find( aProcessId );
+    }
+
+// -----------------------------------------------------------------------------
+// CScrollerTimer::NewL()
+// Construct a new CScrollerTimer object.
+// -----------------------------------------------------------------------------
+//
+CScrollerTimer* CScrollerTimer::NewL( CConsoleMain* aMain )
+    {
+    CScrollerTimer* self = new ( ELeave ) CScrollerTimer();
+    CleanupStack::PushL( self );
+    self->ConstructL( aMain );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CScrollerTimer::ConstructL()
+// Second level constructor.
+// -----------------------------------------------------------------------------
+//
+void CScrollerTimer::ConstructL( CConsoleMain* aMain )
+    {
+    // Store module information
+    iMain = aMain;
+    iTimer.CreateLocal();
+
+    CActiveScheduler::Add ( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CScrollerTimer::CScrollerTimer()
+// Constructor.
+// -----------------------------------------------------------------------------
+//
+CScrollerTimer::CScrollerTimer() : CActive (CActive::EPriorityStandard)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CScrollerTimer::~CScrollerTimer()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CScrollerTimer::~CScrollerTimer( )
+    {
+    Cancel();
+    iTimer.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CScrollerTimer::StartL()
+// Start timer.
+// -----------------------------------------------------------------------------
+//
+void CScrollerTimer::StartL( )
+    {
+    SetActive();
+    iTimer.After ( iStatus, KScrollPeriod );
+    }
+
+// -----------------------------------------------------------------------------
+// CScrollerTimer::RunL()
+// RunL.
+// -----------------------------------------------------------------------------
+//
+void CScrollerTimer::RunL( )
+    {
+    iMain->TimerUpdate();
+
+    // Restart request
+    SetActive();
+    iTimer.After ( iStatus, KScrollPeriod );
+    }
+
+// -----------------------------------------------------------------------------
+// CScrollerTimer::DoCancel()
+// Cancels timer.
+// -----------------------------------------------------------------------------
+//
+void CScrollerTimer::DoCancel( )
+    {
+    iTimer.Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CScrollerTimer::RunError()
+// Returns error.
+// -----------------------------------------------------------------------------
+//
+TInt CScrollerTimer::RunError( TInt aError)
+    {
+    return aError;
+    }    
+
+// -----------------------------------------------------------------------------
+// CConsoleReader::NewL()
+// First phase constructor.
+// -----------------------------------------------------------------------------
+//
+CConsoleReader* CConsoleReader::NewL( CConsoleMain* aMain, 
+                                      CConsoleBase* aConsole )
+    {
+    CConsoleReader* self = 
+        new ( ELeave ) CConsoleReader( aMain, aConsole );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleReader::ConstructL()
+// Second phase constructor.
+// -----------------------------------------------------------------------------
+//
+void CConsoleReader::ConstructL( )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleReader::CConsoleReader()
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+CConsoleReader::CConsoleReader( CConsoleMain* aMain, 
+                                CConsoleBase* aConsole ): 
+    CActive( EPriorityStandard )
+    {
+    iMain = aMain;
+    iConsole = aConsole;
+    
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleReader::~CConsoleReader()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CConsoleReader::~CConsoleReader( )
+    {
+    Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleReader::StartL()
+// Starts console reader.
+// -----------------------------------------------------------------------------
+//
+void CConsoleReader::StartL( )
+    {
+    // Start to process keyboard events
+    SetActive();
+    iConsole->Read(iStatus);
+    }
+  
+// -----------------------------------------------------------------------------
+// CConsoleReader::RunError()
+// Returns error.
+// -----------------------------------------------------------------------------
+//
+TInt CConsoleReader::RunError( TInt aError )
+    {
+    return aError;
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleReader::RunL()
+// Handles key pressings.
+// -----------------------------------------------------------------------------
+//
+void CConsoleReader::RunL()
+    {
+    iMain->KeyPressedL(); 
+    }
+
+// -----------------------------------------------------------------------------
+// CConsoleReader::DoCancel()
+// Cancel request.
+// -----------------------------------------------------------------------------
+//
+void CConsoleReader::DoCancel()
+    {
+    iConsole->ReadCancel();
+    }
+
+// -----------------------------------------------------------------------------
+// MainL()
+// The main function that can leave.
+// Create the CMainConsole object and create, initialise and 
+// start active scheduler.
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void MainL()
+    {
+    // Construct and install active scheduler
+    CActiveScheduler* scheduler=new ( ELeave ) CActiveScheduler;
+    CleanupStack::PushL( scheduler );
+    CActiveScheduler::Install( scheduler );
+
+    // Construct the console
+    CConsoleMain* mainConsole = CConsoleMain::NewL();
+    CleanupStack::PushL( mainConsole );
+
+    // Start the console
+    mainConsole->StartL();
+
+    // Start handling requests
+    CActiveScheduler::Start();
+    // Execution continues from here after CActiveScheduler::Stop()
+
+    // Clean-up
+    CleanupStack::PopAndDestroy( mainConsole );
+    CleanupStack::PopAndDestroy( scheduler );
+    }
+
+// -----------------------------------------------------------------------------
+// E32Main()
+// The main function. Execution starts from here.
+// Create clean-up stack and trap the MainL function which does the
+// real work.
+// -----------------------------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+    {
+    __UHEAP_MARK;
+
+    // Get clean-up stack
+    CTrapCleanup* cleanup=CTrapCleanup::New();
+
+    // Call the main function
+    TRAPD( error, MainL() );
+
+    // Clean-up
+    delete cleanup; 
+    cleanup = NULL;
+
+    __UHEAP_MARKEND;
+
+    return error;
+    }
+
+#if defined(__WINS__)
+// -----------------------------------------------------------------------------
+// WinsMain()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt WinsMain()
+    {
+    E32Main();
+    return KErrNone;
+    }
+
+#endif // __WINS__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/consoleui/src/atconsoleviews.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,1247 @@
+/*
+* 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 FILES
+#include <e32base.h>
+#include <e32cons.h>
+#include <e32svr.h>
+#include <utf.h>
+#include <apgtask.h>
+#include "atconsoleui.h"
+#include "atconsoleviews.h"
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C void LimitedAppend( TDes& aOriginal, const TDesC& aAppend);
+
+// FORWARD DECLARATIONS
+
+// ==================== LOCAL FUNCTIONS =======================================
+// -----------------------------------------------------------------------------
+// LimitedAppend()
+// Appends texts.
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void LimitedAppend( TDes& aOriginal, const TDesC& aAppend )
+    {
+
+    TInt spaceLeft = aOriginal.MaxLength() - aOriginal.Length();
+    
+    if ( spaceLeft > aAppend.Length() )
+        {
+        aOriginal.Append ( aAppend );
+        }
+    else
+        {       
+        aOriginal.Append ( aAppend.Left ( spaceLeft ) );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CView::NewL()
+// First phase constructor.
+// -----------------------------------------------------------------------------
+//
+CView* CView::NewL( CConsoleMain* aConsole,
+                    CView* aParent,
+                    const TDesC& aName,
+                    TInt64 aProcessId
+                  )
+    {
+
+    CView* self = new ( ELeave ) CView();
+    CleanupStack::PushL( self );
+    self->ConstructL( aConsole, aParent, aName, aProcessId );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CView::ConstructL()
+// Second phase constructor.
+// -----------------------------------------------------------------------------
+//
+void CView::ConstructL( CConsoleMain* aConsole,
+                        CView* aParent,
+                        const TDesC& aName, TInt64 aProcessId
+                      )
+    {
+    // Store the parameters
+    iMain = aConsole;
+    iConsole = aConsole->GetConsole();
+    iParent = aParent;
+    iViewName = aName;
+    iProcessId = aProcessId;
+
+    // Get display size
+    const TInt KOverHead = 5;
+    iSize = iConsole->ScreenSize();
+    iScreenSize = iSize.iHeight - KOverHead;   // Size available for menus
+    }
+
+// -----------------------------------------------------------------------------
+// CView::CView()
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+CView::CView()
+    {
+    iDirection = 1;
+    iPrevPos  = -1;     // Invalid starting value
+    }
+
+// -----------------------------------------------------------------------------
+// CView::~CView()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CView::~CView()
+    {    
+    iItems.ResetAndDestroy();
+    }
+
+// -----------------------------------------------------------------------------
+// CView::TimerUpdate()
+// Handles screen updates.
+// -----------------------------------------------------------------------------
+//
+void CView::TimerUpdate()
+    {   
+    RArray<TDesC> texts;
+    if( ItemTexts( texts ) != KErrNone )
+        {
+        texts.Close();
+        return;
+        }
+    TInt count = texts.Count();
+    // If list is empty, do not scroll.
+    if ( count < 1 )
+        {
+        texts.Close();
+        return;
+        }
+    else if( iFirstItem + iPositionOnScreen > count )
+        {
+        iFirstItem = iPositionOnScreen = 0;
+        }
+
+    // If menu selection is updated, then restart scrolling
+    if (iPrevPos != iFirstItem + iPositionOnScreen)
+        {
+        iPrevPos = iFirstItem + iPositionOnScreen;
+        iStart = 0;
+        iDirection = 1;
+        }
+
+    // If menu item have not been changed after last timer, then
+    // start scrolling  
+    const TDesC& name = texts[ iFirstItem + iPositionOnScreen ]; 
+    if ( name.Length() > iSize.iWidth)
+        {
+        TInt y = iConsole->WhereY();
+        TInt x = iConsole->WhereX();
+        TBuf<80> iTmp;
+
+        iStart = iStart + iDirection;
+
+        // "Right end"
+        if ( iStart + iSize.iWidth > name.Length() + KViewOverhead )
+            {
+            iStart--;
+            iDirection = -1;
+            }
+        
+        // "Left end"
+        if ( iStart == -1 )
+            {
+            iStart++;
+            iDirection = 1;
+            }
+        
+        if( iStart > name.Length() )
+            {
+            iStart = 0;
+            }
+
+        iTmp=_L(" *");
+        LimitedAppend( iTmp, name.Mid ( iStart ) );
+            
+        iConsole->SetPos( 0, iPositionOnScreen + 1 );
+        iConsole->Printf ( iTmp.Left( iSize.iWidth -2 )  );
+
+        iConsole->SetPos(x,y);
+        }
+    texts.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CView::AppendBefore()
+// Appends cursor to the line.
+// -----------------------------------------------------------------------------
+//
+void CView::AppendBefore( TInt aLineNum, TDes& aLine )
+    {    
+    if( ( aLine.MaxLength() - aLine.Length() ) < 2 )
+        {
+        return;
+        }        
+    
+    // If printing active line, print the marker
+    if ( aLineNum == iPositionOnScreen + iFirstItem )
+        {
+        aLine.Append( _L(" *") );
+        }
+    else
+        {
+        aLine.Append( _L("  ") );
+        }        
+    }
+
+// -----------------------------------------------------------------------------
+// CView::PrintViewL()
+// Prints view.
+// -----------------------------------------------------------------------------
+//
+void CView::PrintViewL( TUpdateType aType )
+    {
+    iUpdateType = aType;
+    TBuf<KMaxLineLength> line;
+
+    // Clear display
+    iConsole->ClearScreen();
+
+    // Print menu title
+    Print( Name() );
+    
+    RArray<TDesC> texts;
+    if( ItemTexts( texts ) != KErrNone )
+        {
+		texts.Close();
+        return;
+        }
+    
+    TInt oldItemCount = iItemCount;
+     
+    iItemCount = texts.Count();
+
+    // If first time in menu, update start and end positions
+    if( ( iFirstItem == iLastItem ) ||        // First time here..
+        ( iLastItem >= iItemCount ) ||
+        ( oldItemCount != iItemCount ) )      // Menu size changed
+        {
+        iLastItem = iItemCount - 1;
+        iPositionOnScreen = 0;
+
+        // If "overflow", then adjust the end
+        if (iLastItem > iScreenSize )
+            {
+            iLastItem = iScreenSize;
+            }
+        }
+    
+    // Print items
+    for ( TInt i = iFirstItem; i <= iLastItem; i++ )
+        {
+        line.Zero();
+        
+        // Append text before line
+        AppendBefore( i, line );
+        TBuf<2*KMaxName> temp;
+        if ( i < iItems.Count() )
+            {
+            temp.Copy( iItems[ i ]->Name() );
+            TATLogOption loggingMode;
+            iMain->StorageServer().GetLoggingModeL( iMain->Processes()[ i ].iProcessId, loggingMode );
+            if ( EATLoggingOff != loggingMode )
+                {
+                if ( iMain->IsSubTestRunning( iMain->Processes()[ i ].iProcessId ) > KErrNotFound )
+                    {
+                    temp.Append( _L(": ") );
+                    temp.Append( _L("subtest running") );
+                    }                   
+                }
+            else
+                {
+                temp.Append( _L(": ") );
+                temp.Append( _L("logging cancelled") );
+                }
+            // TEST START
+            /*if ( i == iFirstItem )
+                {
+                temp.Append( _L(": ") );
+                temp.Append( _L("subtest running") );
+                }
+            else if ( i == iFirstItem + 1 )
+                {
+                temp.Append( _L(": ") );
+                temp.Append( _L("logging cancelled") );
+                }
+            else if ( i == iFirstItem + 2 )
+                {
+                temp.Append( _L(": ") );
+                temp.Append( _L("subtest running") );
+                }*/
+            // TEST END
+            LimitedAppend ( line, temp /*texts[i]*/ );
+            }
+        else
+            LimitedAppend ( line, KExitTxt );
+
+        // Print the line
+        Print(line);
+        }
+    texts.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CView::SelectL()
+// Handles line selections.
+// -----------------------------------------------------------------------------
+//
+CView* CView::SelectL( TKeyCode aSelection, TBool& aContinue )
+    {
+    MapKeyCode( aSelection );
+    
+    switch ( ( TInt )aSelection )
+        {
+        // Exit
+        case EKeyEscape:
+            aContinue = EFalse;
+            return this;
+        // SelectL item
+        case EKeyEnter:
+        case EKeyRightArrow:
+            {
+            // Print items
+            for ( TInt i = iFirstItem; i <= iLastItem; i++ )
+                {
+                if ( i < iItems.Count() )
+                    {
+                    TATLogOption loggingMode;
+                    TInt processCount ( iMain->Processes().Count() );
+                    if ( i <  processCount )
+                        {
+                        iMain->StorageServer().GetLoggingModeL( iMain->Processes()[ i ].iProcessId, loggingMode );
+                        if ( EATLoggingOff != loggingMode )
+                            {
+                            return iItems[ iPositionOnScreen ];
+                            }
+                        else
+                            {
+                            return this;
+                            }
+                        }
+                    }
+                }                    
+            //return iItems[ iPositionOnScreen ];
+            } 
+        // Going back
+        case EKeyLeftArrow:
+            {
+            TBool tmp = iShowLibraries | iSetLoggingMode;
+            iShowLibraries = EFalse;
+            iSetLoggingMode = EFalse;
+            if ( tmp )
+                return this;
+            else
+                return iParent;
+            }
+        // Go down
+        case EKeyDownArrow:
+            {
+            if ( iFirstItem + iPositionOnScreen == iItemCount - 1 )
+                {
+                // If end of the list, go to beginning
+                iLastItem = iLastItem - iFirstItem;
+                iFirstItem = 0;
+                iPositionOnScreen = 0;
+                }
+            else 
+                {
+                if ( iPositionOnScreen == iScreenSize )
+                    {
+                    // If in end of screen, update items
+                    if ( iLastItem != ( iItemCount - 1 ) )
+                        {
+                        // If not end of the list, then update first and last
+                        // but do not update position in screen.
+                        iLastItem++;
+                        iFirstItem++;
+                        }
+                    }
+                else
+                    {
+                    // Going down "in-screen", no need to update items
+                    iPositionOnScreen++;
+                    }
+                }
+            break;
+            }   
+        // Go Up
+        case EKeyUpArrow:
+            {
+            if ( iFirstItem + iPositionOnScreen == 0 )
+                {
+                // If in the beginning of the list
+    
+                if ( iItemCount <= iScreenSize ) 
+                    {
+                    // Wrap around when the list is not full
+                        iPositionOnScreen = iItemCount-1;
+                    }
+                else
+                    {
+                    // Wrap around when there are more items than
+                    // can be shown at once.            
+                    iPositionOnScreen = iScreenSize;
+                    iLastItem = iItemCount-1;
+                    iFirstItem = iItemCount - iPositionOnScreen - 1;
+                    }
+                }
+            else if ( iPositionOnScreen == 0 )
+                {
+                // If not at the beginning of the list, then update first and
+                // last  but do not update position in screen.
+                if ( iFirstItem != 0 )
+                    {
+                    iLastItem--;
+                    iFirstItem--;
+                    }
+                }
+            else
+                {
+                // Going up "in-screen", no need to update items
+                iPositionOnScreen--;
+                }
+            
+            break;
+            }                
+
+        // Additional keys
+        case EKeyHome:
+        case '3':
+            iPositionOnScreen = 0;
+            iFirstItem = 0;
+            iLastItem = iScreenSize;
+    
+            if ( iLastItem > iItemCount-1 )
+                {
+                iLastItem = iItemCount-1;
+                }
+            break;
+        case EKeyEnd:
+        case '9':
+            iPositionOnScreen = iScreenSize;
+            iLastItem = iItemCount-1;
+            iFirstItem = iLastItem - iScreenSize;
+    
+            if ( iFirstItem < 0 )
+                {
+                iFirstItem = 0;
+                iPositionOnScreen = iLastItem-1;
+                }
+            break;
+        case EKeyPageUp:
+        case '1':
+    
+            iFirstItem = iFirstItem - iScreenSize - 1;
+            iLastItem = iLastItem - iScreenSize - 1;
+    
+            if ( iFirstItem < 0 )
+                {
+                iFirstItem = 0;
+                iPositionOnScreen = 0;
+                iLastItem = iScreenSize;
+                if ( iLastItem > iItemCount-1 )
+                    {
+                    iLastItem = iItemCount-1;
+                    }
+                }
+            break;
+        case EKeyPageDown:
+        case '7':
+            iFirstItem = iFirstItem + iScreenSize + 1;
+            iLastItem = iLastItem + iScreenSize + 1;
+    
+            // Going too far
+            if ( iLastItem > iItemCount - 1 )
+                {
+                iLastItem = iItemCount-1;
+                iFirstItem = iLastItem - iScreenSize;
+                iPositionOnScreen = iScreenSize;
+                }
+    
+            // Ok, list is smaller than screen
+            if ( iFirstItem < 0 )
+                {
+                iFirstItem = 0;
+                iLastItem = iItemCount-1;
+                iPositionOnScreen = iLastItem;
+                }
+            break;
+        default:  // Bypass the keypress
+            break;
+        }
+
+    // Continue normally and keep in the same menu
+    aContinue = ETrue;
+    return this;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CView::ItemTexts()
+// Formats menu texts
+// -----------------------------------------------------------------------------
+//
+TInt CView::ItemTexts( RArray<TDesC>& aArray )
+    {
+    
+    TInt count = iItems.Count();
+    for( TInt i=0; i<count; i++ )
+        {
+        TBuf<50> temp;
+        temp.Copy( iItems[i]->Name() );
+        if( aArray.Append( iItems[i]->Name() ) != KErrNone )
+            {
+            return KErrNoMemory;
+            }
+        }
+
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CView::SetParent()
+// Sets menu parent menu
+// -----------------------------------------------------------------------------
+//
+void CView::SetParent ( CView* aMenu )
+    {
+
+    iParent = aMenu;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CView::Print()
+// Prints line to the screen.
+// -----------------------------------------------------------------------------
+//
+void CView::Print( const TDesC& aPrint )
+    {    
+    iConsole->Printf ( aPrint.Left( iSize.iWidth - KViewOverhead ) );   
+    iConsole->Printf(_L("\n"));
+    }
+
+// -----------------------------------------------------------------------------
+// CView::AddItemL()
+// Adds item to the list.
+// -----------------------------------------------------------------------------
+//
+void CView::AddItemL( CView* aMenu )
+    {
+
+    User::LeaveIfError ( iItems.Append( aMenu ) );
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CView::ResetItems()
+// Resets the item list.
+// -----------------------------------------------------------------------------
+//
+void CView::ResetItems()
+    {
+    iItems.ResetAndDestroy();
+    }
+// -----------------------------------------------------------------------------
+// CView::Name()
+// Returns the name of view.
+// -----------------------------------------------------------------------------
+//
+const TDesC& CView::Name( ) const
+    {
+
+    return iViewName;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CView::MapKeyCode()
+// Maps numeric keycodes to proper TKeyCode values.
+// -----------------------------------------------------------------------------
+//
+void CView::MapKeyCode(TKeyCode &aSelection)
+    {
+    
+    TInt asciiCode = (TInt) aSelection;
+    
+    // Handling numeric keys 2,4,6 and 8
+    
+    if(asciiCode == KMyKeyUpAsciiCode)
+        {
+        aSelection = EKeyUpArrow;
+        }
+        
+    if(asciiCode == KMyKeyLeftAsciiCode)
+        {
+        aSelection = EKeyLeftArrow;
+        }
+
+    if(asciiCode == KMyKeyRightAsciiCode)
+        {
+        aSelection = EKeyEnter;
+        }
+
+    if(asciiCode == KMyKeyDownAsciiCode)
+        {
+        aSelection = EKeyDownArrow;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CMainView::NewL()
+// First phase constructor.
+// -----------------------------------------------------------------------------
+//
+CMainView* CMainView::NewL( CConsoleMain* aConsole,
+                            CView* aParent,
+                            const TDesC& aName )
+    {
+
+    CMainView* self = new ( ELeave ) CMainView();
+    CleanupStack::PushL( self );
+    self->ConstructL( aConsole, aParent, aName );
+    CleanupStack::Pop( self );
+    return self;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CMainView::ItemTexts()
+// Format menu texts.
+// -----------------------------------------------------------------------------
+//
+TInt CMainView::ItemTexts( RArray<TDesC>& aArray )
+    {
+    
+    CView::ItemTexts( aArray );
+    // Add Exit to last one in menu
+    if( aArray.Append( KExitTxt ) != KErrNone )
+        {
+        return KErrNoMemory;
+        }
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CMainView::ConstructL()
+// Second phase constructor.
+// -----------------------------------------------------------------------------
+//
+void CMainView::ConstructL( CConsoleMain* aConsole, 
+                            CView* aParent,
+                            const TDesC& aName
+                          )
+    {
+
+    CView::ConstructL( aConsole, aParent, aName, NULL );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CMainView::SelectL()
+// Process keypresses in menu.
+// -----------------------------------------------------------------------------
+//
+CView* CMainView::SelectL( TKeyCode aSelection, TBool& aContinue )
+    {
+
+    MapKeyCode( aSelection );
+    
+    // If SelectLion == "exit" and right or enter
+    if ( aSelection == EKeyEnter || aSelection == EKeyRightArrow )
+        {
+        if ( iPositionOnScreen == iItemCount - 1 )
+            {
+            // Exit
+            aContinue = EFalse;
+            return this;
+            }
+        }
+
+    // Normal menu handling
+    CView* tmp = CView::SelectL( aSelection, aContinue );
+    return tmp;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CProcessInfoView::NewL()
+// First phase constructor.
+// -----------------------------------------------------------------------------
+//
+CProcessInfoView* CProcessInfoView::NewL( CConsoleMain* aConsole,
+                                        CView* aParent,
+                                        const TDesC& aName, TInt64 aProcessId )
+    {    
+
+        CProcessInfoView* self = new ( ELeave ) CProcessInfoView();
+    CleanupStack::PushL( self );
+    self->ConstructL( aConsole, aParent, aName, aProcessId );
+    CleanupStack::Pop( self );
+    return self;
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CProcessInfoView::~CProcessInfoView()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CProcessInfoView::~CProcessInfoView()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CProcessInfoView::ConstructL()
+// First phase constructor.
+// -----------------------------------------------------------------------------
+//
+void CProcessInfoView::ConstructL( CConsoleMain* aConsole,
+                                  CView* aParent,
+                                  const TDesC& aName, TInt64 aProcessId
+                                 )
+    {
+    CView::ConstructL( aConsole, aParent, aName, aProcessId );
+    }
+
+// -----------------------------------------------------------------------------
+// CProcessInfoView::ItemTexts()
+// Formats menu item texts.
+// -----------------------------------------------------------------------------
+//
+TInt CProcessInfoView::ItemTexts( RArray<TDesC>& /*aArray*/ )
+    {      
+    return KErrNone; 
+    }
+
+// -----------------------------------------------------------------------------
+// CProcessInfoView::PrintViewL()
+// Prints process info view.
+// -----------------------------------------------------------------------------
+//
+void CProcessInfoView::PrintViewL( TUpdateType /*aType*/ )
+    {
+    if ( !iShowLibraries && !iSetLoggingMode )
+        {
+        // Get module names
+        RArray<TATProcessInfo> processes;
+        // Clear display
+        iConsole->ClearScreen();
+        // Print menu title
+        TBuf<2*KMaxName> title;
+        title.Copy( Name() );
+        TInt subTest = iMain->IsSubTestRunning( iProcessId );
+        if ( subTest > KErrNotFound )
+            {
+            // Append subtest running text
+            title.Append( _L(": ") );
+            title.Append( _L( "subtest running" ) );
+            }
+        
+        Print( title /*Name()*/ );
+        // Update positions
+        RArray<TDesC> texts;
+        if( ItemTexts( texts ) != KErrNone )
+            {
+            return;
+            }
+        
+        TInt oldItemCount = iItemCount;
+        iItemCount = texts.Count();
+
+        // If first time in menu, update start and end positions
+        if( ( iFirstItem == iLastItem ) ||        // First time here..
+            ( iLastItem >= iItemCount ) ||
+            ( oldItemCount != iItemCount ) )      // Menu size changed
+            {
+            iLastItem = iItemCount - 1;
+            iPositionOnScreen = 0;
+
+            // If "overflow", then adjust the end
+            if ( iLastItem > iScreenSize )
+                {
+                iLastItem = iScreenSize;
+                }
+            }
+        // Update pos screen
+        if ( iPositionOnScreen > ( TInt )ECancelLoggingTxtItem - 1 )
+            iPositionOnScreen = 0;
+        else if ( iPositionOnScreen < ( TInt )EStartSubtestTxtItem )
+            iPositionOnScreen = ( TInt )ECancelLoggingTxtItem - 1;
+        
+        // Get processes
+        processes = iMain->Processes();
+        // Get current opened process
+        for ( TInt num = 0 ; num < processes.Count() ; num++ )
+            {
+            TATProcessInfo tmpProcessInfo;
+            tmpProcessInfo = processes[ num ];
+            if ( tmpProcessInfo.iProcessId == iProcessId )
+                {
+                iCurrentProcessInfo = tmpProcessInfo;
+                break;
+                }    
+            }
+
+        TBuf<KMaxLineLength> line;
+        // Get curr. and max. allocations
+        TUint32 number( KErrNone );
+        TUint32 size( KErrNone );
+        TUint32 maxNumber( KErrNone );
+        TUint32 maxSize( KErrNone );
+        TInt currErr = iMain->StorageServer().GetCurrentAllocsL( iProcessId, number, size );
+        TInt maxErr = iMain->StorageServer().GetMaxAllocsL( iProcessId, maxNumber, maxSize );
+        // Get logging mode
+        TATLogOption loggingMode;
+        TInt loggingErr = iMain->StorageServer().GetLoggingModeL( iProcessId, loggingMode );
+        
+        // Print curr. allocations
+        line = _L("    ");
+        LimitedAppend ( line, _L( "Curr. allocations: " ) );
+        // Append curr. allocs
+        if ( currErr == KErrNone )
+            line.AppendNum( number );
+        
+        Print( line );
+        line = _L("        ");
+        if ( currErr == KErrNone )
+            {
+            if ( size >= KATThousand && size < KATMillion ) // kiloByte range
+                {
+                TReal value( size );
+                value = value / KATThousand;
+                line.Format( _L("     %.1f"), value );
+                line.Append( _L(" ") );
+                line.Append( KATKB );  
+                }
+            else if ( size >= KATMillion ) // megaByte range
+                {
+                TReal value( size );
+                value = value / KATMillion;
+                line.Format( _L("     %.1f"), value );
+                line.Append( _L(" ") );
+                line.Append( KATMB );
+                }
+            else
+                {
+                line.Copy( _L("     ") );
+                line.AppendNum( size );
+                line.Append( _L(" ") );
+                line.Append( KATB );
+                }
+            }
+        else
+            {
+            LimitedAppend ( line, _L( "unavailable" ) );
+            }       
+        Print( line );
+        
+        // Print max. allocations
+        line = _L("    ");
+        LimitedAppend ( line, _L( "Max. allocations: " ) );
+        // Append curr. allocs
+        if ( maxErr == KErrNone )
+            line.AppendNum( maxNumber );
+        
+        Print( line );
+        line = _L("        ");
+        if ( maxErr == KErrNone )
+            {
+            if ( size >= KATThousand && size < KATMillion ) // kiloByte range
+                {
+                TReal value( maxSize );
+                value = value / KATThousand;
+                line.Format( _L("     %.1f"), value );
+                line.Append( _L(" ") );
+                line.Append( KATKB );  
+                }
+            else if ( size >= KATMillion ) // megaByte range
+                {
+                TReal value( maxSize );
+                value = value / KATMillion;
+                line.Format( _L("     %.1f"), value );
+                line.Append( _L(" ") );
+                line.Append( KATMB );
+                }
+            else
+                {
+                line.Copy( _L("     ") );
+                line.AppendNum( maxSize );
+                line.Append( _L(" ") );
+                line.Append( KATB );
+                }
+            }
+        else
+            {
+            LimitedAppend ( line, _L( "unavailable") );
+            }
+        Print( line ); 
+        
+        // Print starting time
+        line = _L("    ");
+        LimitedAppend ( line, _L( "Process started:") );
+        Print( line );
+        line = _L("     ");
+        TTime time( iCurrentProcessInfo.iStartTime );
+        TBuf<50> dateString;
+        _LIT( KDateString3,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%J%:1%T%:2%S%:3%+B" );
+        time.FormatL( dateString, KDateString3 );
+        LimitedAppend ( line, dateString );
+        Print( line );
+        
+        // Print logging mode
+        line = _L("    ");
+        LimitedAppend ( line, _L( "Logging mode:") );
+        Print( line );
+        line = _L("     ");
+        if ( KErrNone == loggingErr )
+            {
+            if ( EATUseDefault == loggingMode )
+                {
+                LimitedAppend ( line, _L( "External" ) );
+                }
+            else if ( EATLogToFile == loggingMode )
+                {
+                LimitedAppend ( line, _L( "Internal" ) );
+                }
+            else if ( EATLogToXti == loggingMode )
+                {
+                LimitedAppend ( line, _L( "External" ) );
+                }
+            else if( EATLoggingOff == loggingMode )
+                {
+                LimitedAppend ( line, _L( "None" ) );
+                }
+            }
+        else
+            {
+            LimitedAppend ( line, _L( "unavailable" ) );
+            }
+        Print(line);
+        
+        // Print mode information (UDEB/UREL)
+        line = _L("    ");
+        LimitedAppend ( line, _L( "Mode:") );
+        Print( line );
+        line = _L("     ");
+        TUint32 isUdeb;
+        TInt udebErr = iMain->StorageServer().GetUdebL( iProcessId, isUdeb );
+        if ( KErrNone == udebErr )
+            {
+            if ( isUdeb > KErrNone )
+                {
+                LimitedAppend ( line, _L( "UDEB" ) );
+                }
+            else
+                {
+                LimitedAppend ( line, _L( "UREL" ) );
+                }
+            }
+        else
+            {
+            LimitedAppend ( line, _L( "unavailable" ) );
+            }
+        Print( line );
+
+        // Print logging file information
+        line = _L("    ");
+        LimitedAppend ( line, _L( "Logging file:") );
+        Print( line );
+        line = _L("     ");  
+        TBuf8<KMaxFileName> fileName;
+        TInt fileErr = iMain->StorageServer().GetLoggingFileL( iProcessId, fileName );
+        if ( KErrNone == fileErr )
+            {
+            if ( fileName.Length() > KErrNone )
+                {
+                TBuf<KMaxFileName> unicodeFile;
+                CnvUtfConverter::ConvertToUnicodeFromUtf8( unicodeFile, fileName );
+                LimitedAppend ( line, unicodeFile );
+                }
+            else
+                {               
+                LimitedAppend ( line, _L( "None" ) );
+                }
+            }
+        else
+            {
+            LimitedAppend ( line, _L( "unavailable" ) );
+            }        
+        Print( line );
+        
+        line = _L("\n");
+        Print( line );
+        
+        // Print process info menu
+        TInt cursor( KErrNone );
+        while ( cursor <= ( TInt )ECancelLoggingTxtItem - 1 ) // -1, dyninitmenupane
+            {
+            line.Zero();
+            if ( cursor == 0 && iMain->IsSubTestRunning( iProcessId ) == KErrNotFound )
+                {
+                AppendBefore( cursor, line );
+                LimitedAppend ( line, _L( "Start subtest") );
+                // Print the line
+                Print( line );
+                }
+            else if ( cursor == 0 && iMain->IsSubTestRunning( iProcessId ) > KErrNotFound )
+                {
+                AppendBefore( cursor, line );
+                LimitedAppend ( line, _L( "Stop subtest") );
+                // Print the line
+                Print( line );
+                } 
+            else if ( cursor == 1 )
+                {
+                AppendBefore( cursor, line );
+                LimitedAppend ( line, _L( "View libraries") );
+                // Print the line
+                Print( line );
+                }
+            else if ( cursor == 2 )
+                {
+                AppendBefore( cursor, line );
+                LimitedAppend ( line, _L( "End process") );
+                // Print the line
+                Print( line );
+                }
+            else if ( cursor == 3 )
+                {
+                AppendBefore( cursor, line );
+                LimitedAppend ( line, _L( "Kill process") );
+                // Print the line
+                Print( line );
+                }
+            else if ( cursor == 4 )
+                {
+                AppendBefore( cursor, line );
+                LimitedAppend ( line, _L( "Cancel logging") );
+                // Print the line
+                Print( line );
+                }
+            cursor++;
+            }
+        texts.Close();
+        }
+    else if ( iShowLibraries && !iSetLoggingMode )
+        {
+        ViewLibrariesL();
+        }
+    else if ( !iShowLibraries && iSetLoggingMode )
+        {
+        SetLoggingModeL();
+        }
+
+    }
+
+// -----------------------------------------------------------------------------
+// CProcessInfoView::SelectL()
+// Process keypresses in menu.
+// -----------------------------------------------------------------------------
+//
+CView* CProcessInfoView::SelectL( TKeyCode aSelection, TBool& aContinue )
+    {
+    MapKeyCode( aSelection );
+    
+    if( ( aSelection == EKeyRightArrow ||
+            aSelection == EKeyEnter ) )
+        {
+        if ( !iSetLoggingMode )
+            {
+            if( iPositionOnScreen == EStartSubtestTxtItem )
+                {
+                if ( iMain->IsSubTestRunning( iProcessId ) == KErrNotFound )
+                    iMain->SetProcessSubTestStart( iProcessId );
+                else
+                    iMain->SetProcessSubTestStop( iProcessId );
+                return NULL;
+                }
+            else if( iPositionOnScreen == EViewLibrariesTxtItem - 1 )
+                {
+                iShowLibraries = ETrue;
+                return NULL;
+                }
+            else if( iPositionOnScreen == EEndProcessTxtItem - 1 )
+                {
+                EndProcessL( ETryToEnd );
+                // Trying to end process -> go processes view
+                return iParent;
+                }
+            else if( iPositionOnScreen == EKillProcessTxtItem - 1 )
+                {
+                EndProcessL( ETryToKill );
+                // Trying to kill process -> go processes view
+                return iParent;
+                }
+            else if( iPositionOnScreen == ECancelLoggingTxtItem - 1 )
+                {
+                iMain->StorageServer().CancelLogging( iProcessId );
+                return iParent;
+                }
+            else
+                {
+                return this;
+                }               
+            }
+        else if ( iSetLoggingMode )
+            {
+            return NULL;
+            }
+        }
+
+    return CView::SelectL( aSelection, aContinue );
+    }
+
+// -----------------------------------------------------------------------------
+// CProcessInfoView::ViewLibrariesL()
+// Prints libraries loaded by current process.
+// -----------------------------------------------------------------------------
+//
+void CProcessInfoView::ViewLibrariesL()
+    { 
+    // Clear display
+    iConsole->ClearScreen();
+    // Print menu title
+    Print( _L( "Loaded libraries:") );
+
+    TBuf<KMaxLineLength> line;  
+    // Loaded libraries for this process
+    RArray< TBuf8<KMaxLibraryName> > libraries;
+    iMain->StorageServer().GetLoadedDllsL( iCurrentProcessInfo.iProcessId, libraries );
+    TInt lCount = libraries.Count();
+    for ( TInt count = 0 ; count < lCount ; count++ )
+        {
+        TBuf<KMaxLibraryName> library;
+        library.Copy( libraries[ count ] );
+        line = _L("    ");
+        LimitedAppend ( line, library );
+        Print(line);
+        }
+    libraries.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CProcessInfoView::SetLoggingModeL()
+// Prints logging modes which user wants to select to current process.
+// -----------------------------------------------------------------------------
+//
+void CProcessInfoView::SetLoggingModeL()
+    { 
+    // Clear display
+    iConsole->ClearScreen();
+    // Print menu title
+    Print( _L( "Logging mode:") );
+
+    // Update pos screen
+    if ( iPositionOnScreen > 2 )
+        iPositionOnScreen = 0;
+    else if ( iPositionOnScreen < 0 )
+        iPositionOnScreen = 2;
+    
+    TBuf<KMaxLineLength> line;  
+
+    // Print logging modes
+    TInt cursor( KErrNone );
+    while ( cursor <= 2 ) // Three items
+        {
+        line.Zero();
+        if ( cursor == 0 )
+            {
+            AppendBefore( cursor, line );
+            LimitedAppend ( line, _L( "External") );
+            // Print the line
+            Print( line );
+            }
+        else if ( cursor == 1 )
+            {
+            AppendBefore( cursor, line );
+            LimitedAppend ( line, _L( "Internal") );
+            // Print the line
+            Print( line );
+            } 
+        else if ( cursor == 2 )
+            {
+            AppendBefore( cursor, line );
+            LimitedAppend ( line, _L( "None") );
+            // Print the line
+            Print( line );
+            }
+        cursor++;
+        }  
+    }
+
+// -----------------------------------------------------------------------------
+// CProcessInfoView::EndProcessL()
+// Ends process with a specific method.
+// -----------------------------------------------------------------------------
+//
+void CProcessInfoView::EndProcessL( TInt aCommand )
+    {
+     RProcess endProcess;
+     TUint processId = iProcessId;
+     TBuf<KMaxProcessName> processName;
+     processName.Copy( Name() );
+     TInt find = processName.Find( _L( "." ) );
+     if ( find > KErrNotFound )
+         processName.Delete( find, processName.Length() - find );
+     
+     TInt openErr = endProcess.Open( TProcessId( processId ) );
+     if ( openErr ==KErrNone )
+         {
+         if ( aCommand == ETryToEnd )
+             {
+             endProcess.Close();
+             RWsSession wsSession;
+             TInt wsErr = wsSession.Connect();
+             if ( KErrNone == wsErr )
+                 {
+                 TApaTaskList apList = TApaTaskList( wsSession );
+                 TApaTask apTask = apList.FindApp( processName );
+                 if ( apTask.Exists() )
+                     {
+                     apTask.EndTask();
+                     }
+                 wsSession.Close();
+                 }
+
+             }
+         else if ( aCommand == ETryToKill )
+             {               
+             endProcess.Kill( KErrNone );
+             endProcess.Close();
+             }
+         }
+    }
+
+// End of file
Binary file memana/analyzetoolclient/doc/S60_Analyze_Tool_Users_Guide.pdf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/bwins/atoolmemoryhooku.def	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,13 @@
+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@@HV?$TBuf@$0BAA@@@KKKK@Z @ 4 NONAME ; class RAllocator & CustomUser::InstallAllocator(int, class TBuf<256>, 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@@V?$TBuf@$0BAA@@@KK1KK@Z @ 8 NONAME ; int CustomUser::SetupThreadHeap(int, struct SStdEpocThreadCreateInfo &, class TBuf<256>, unsigned long, unsigned long, class TBuf<256>, unsigned long, unsigned long)
+	?StartSubTest@AnalyzeToolInterface@@SAXABVTDesC8@@@Z @ 9 NONAME ; void AnalyzeToolInterface::StartSubTest(class TDesC8 const &)
+	?StopSubTest@AnalyzeToolInterface@@SAXABVTDesC8@@@Z @ 10 NONAME ; void AnalyzeToolInterface::StopSubTest(class TDesC8 const &)
+	?__DbgMarkEnd@CustomUser@@SAKHH@Z @ 11 NONAME ; unsigned long CustomUser::__DbgMarkEnd(int, int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/eabi/atoolmemoryhooku.def	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,19 @@
+EXPORTS
+	_ZN10CustomUser11SetCriticalEN4User9TCriticalE @ 1 NONAME
+	_ZN10CustomUser12__DbgMarkEndEii @ 2 NONAME
+	_ZN10CustomUser15SetupThreadHeapEiR24SStdEpocThreadCreateInfo4TBufILi256EEmmS3_mm @ 3 NONAME
+	_ZN10CustomUser16InstallAllocatorEi4TBufILi256EEmmmm @ 4 NONAME
+	_ZN10CustomUser18SetProcessCriticalEN4User9TCriticalE @ 5 NONAME
+	_ZN10CustomUser4ExitEi @ 6 NONAME
+	_ZN10CustomUser5PanicERK7TDesC16i @ 7 NONAME
+	_ZN20AnalyzeToolInterface11StopSubTestERK6TDesC8 @ 8 NONAME
+	_ZN20AnalyzeToolInterface12StartSubTestERK6TDesC8 @ 9 NONAME
+	_ZTI20CLibraryEventHandler @ 10 NONAME ; #<TI>#
+	_ZTI21RAnalyzeToolAllocator @ 11 NONAME ; #<TI>#
+	_ZTI25RAnalyzeToolMainAllocator @ 12 NONAME ; #<TI>#
+	_ZTI27RAnalyzeToolMemoryAllocator @ 13 NONAME ; #<TI>#
+	_ZTV20CLibraryEventHandler @ 14 NONAME ; #<VT>#
+	_ZTV21RAnalyzeToolAllocator @ 15 NONAME ; #<VT>#
+	_ZTV25RAnalyzeToolMainAllocator @ 16 NONAME ; #<VT>#
+	_ZTV27RAnalyzeToolMemoryAllocator @ 17 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/group/atoolmemoryhook.mmp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,62 @@
+/*
+* 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 AToolMemoryHook.
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET        atoolmemoryhook.dll
+TARGETTYPE    dll
+UID           0x1000008d 0x2001242F
+CAPABILITY    ALL -TCB
+
+SMPSAFE
+
+SOURCEPATH    ../src
+
+SOURCE        analyzetooleventhandler.cpp
+SOURCE        codeblock.cpp
+SOURCE        threadstack.cpp
+SOURCE        customuser.cpp
+SOURCE        analyzetoolmemoryallocator.cpp
+SOURCE        analyzetoolmainallocator.cpp
+SOURCE        analyzetoolallocator.cpp
+SOURCE        analyzetoolfastlog.cpp
+
+SOURCEPATH    ../../storageserver/server/src
+SOURCE        atdriveinfo.cpp
+
+USERINCLUDE   ../inc
+USERINCLUDE   ../../inc
+USERINCLUDE   ../../storageserver/inc
+USERINCLUDE   ../../storageserver/server/inc
+
+#ifdef WINSCW
+APP_LAYER_SYSTEMINCLUDE
+#endif
+
+OS_LAYER_SYSTEMINCLUDE
+
+LIBRARY       efsrv.lib 
+LIBRARY       euser.lib
+LIBRARY       atoolstorageserverclnt.lib
+LIBRARY       flogger.lib
+LIBRARY       charconv.lib 
+LIBRARY       platformenv.lib 
+#ifdef WINSCW
+LIBRARY		  cone.lib
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/group/bld.inf	Thu Feb 11 15:51:35 2010 +0200
@@ -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
+ARMV5 WINSCW
+
+PRJ_MMPFILES
+atoolmemoryhook.mmp
+
+PRJ_TESTMMPFILES
+../tsrc/group/analyzetoolmemoryhooktest.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolallocator.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,247 @@
+/*
+* 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 RAnalyzeToolAllocator.
+*
+*/
+
+
+#ifndef ANALYZETOOLALLOCATOR_H
+#define ANALYZETOOLALLOCATOR_H
+
+// INCLUDES
+#include <u32std.h>
+#include "codeblock.h"
+#include "threadstack.h"
+#include "analyzetoolmemoryallocator.h"
+#include <analyzetool/atstorageserverclnt.h>
+#include <analyzetool/analyzetool.h>
+#include <analyzetool/atcommon.h>
+
+// CLASS DECLARATION
+
+/**
+*  Class which overloads the RAlloctor functions and provides access to 
+*  the overloaded functions  
+*/
+class RAnalyzeToolAllocator : public RAnalyzeToolMemoryAllocator
+    {
+
+    public:
+
+        /**
+        * 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 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 );
+        /**
+        * Destructor.
+        */                     
+        ~RAnalyzeToolAllocator();
+
+        /**
+        * Allocates a cell of specified size from the heap.
+        * @param aSize The size of the cell to be allocated from the heap. 
+        * @return TAny* A pointer to the allocated cell.
+        */
+        TAny* Alloc( TInt aSize );
+
+        /**
+        * Frees the specified cell and returns it to the heap.
+        * @param aPtr A pointer to a cell to be freed.
+        */
+        void Free( TAny* aPtr );
+
+        /**
+        * Increases or decreases the size of an existing cell.
+        * @param aPtr A pointer to the cell to be reallocated.
+        * @param aSize The new size of the cell. This may be bigger 
+        *              or smaller than the size of the original cell.
+        * @param aMode Flags controlling the reallocation.
+        * @return TAny* A pointer to the reallocated cell. This may be the 
+        *               same as the original pointer supplied through aCell.
+        */
+        //lint --e{1735} suppress "Virtual function has default parameter"
+        TAny* ReAlloc( TAny* aPtr, TInt aSize, TInt aMode = 0 );
+        
+        /**
+        * Gets the length of the available space in the specified 
+        * allocated cell.
+        * @param aCell A pointer to the allocated cell.
+        * @return TInt The length of the available space in the allocated cell.
+        */
+        TInt AllocLen( const TAny* aCell ) const;
+
+    #ifndef __KERNEL_MODE__
+
+        /**
+        * Opens this heap for shared access. Opening the heap increases 
+        * the heap's access count by one.
+        */
+        TInt Open();
+        
+        /**
+        * Closes this shared heap. Closing the heap decreases the heap's 
+        * access count by one.
+        */
+        void Close();
+
+        /**
+        * The function frees excess committed space from the top of the heap.
+        * The size of the heap is never reduced below the minimum size 
+        * specified during creation of the heap.
+        * @return TInt The space reclaimed. If no space can be reclaimed, 
+                       then this value is zero.
+        */
+        TInt Compress();
+
+        /**
+        * Frees all allocated cells on this heap. 
+        */
+        void Reset();
+
+        /**
+        * Gets the number of cells allocated on this heap, and 
+        * the total space allocated to them.
+        * @param aTotalAllocSize On return, contains the total 
+        *                        space allocated to the cells.
+        * @return TInt The number of cells allocated on this heap.
+        */
+        TInt AllocSize( TInt& aTotalAllocSize ) const;
+        
+        /**
+        * Gets the total free space currently available on the heap and the 
+        * space available in the largest free block. The space available 
+        * represents the total space which can be allocated. Note that 
+        * compressing the heap may reduce the total free space available 
+        * and the space available in the largest free block.
+        * @param aBiggestBlock On return, contains the space available 
+        *                      in the largest free block on the heap.
+ 
+        * @return TInt The total free space currently available on the heap.
+
+        */
+        TInt Available( TInt& aBiggestBlock ) const;
+        
+    #endif
+
+        /**
+        * Invocates specified debug funtionality.
+        * @param aFunc The debug function
+        * @param a1 Debug function specific paramenter.
+        * @param a2 Debug function specific paramenter.
+        * @return TInt Returns KErrNone, if successful otherwise one 
+        *              of the other system-wide error codes.
+        */
+        //lint --e{1735} suppress "Virtual function has default parameter"
+        TInt DebugFunction( TInt aFunc, TAny* a1 = NULL, TAny* a2 = NULL );
+
+    protected:
+
+        /**
+        * Extension function
+        * @param aExtensionId The extension id
+        * @param a0 Extension specific paramenter.
+        * @param a1 Extension specific paramenter.
+        * @return TInt Returns KErrNone, if successful otherwise one 
+        *              of the other system-wide error codes. 
+        */
+        TInt Extension_( TUint aExtensionId, TAny*& a0, TAny* a1 );
+
+    public: // from RAnalyzeToolMemoryAllocator
+        
+        /**
+        * Installs the RTraceAllocator allocator
+        */
+        void Uninstall();
+        
+        /**
+        * Shares the heap
+        */
+        void ShareHeap();
+
+    private:
+    
+        /**
+        * Find the current thread which is using the heap
+        * @param aStackStart A reference where the stack start is stored
+        * @return TBool ETrue if a thread can be found, EFalse otherwise
+        */
+        TBool FindCurrentThreadStack( TUint32& aStackStart );
+
+    private: 
+    
+        /* Handle to the storage server*/
+        RATStorageServer& iStorageServer;
+
+        /* A reference to codeblocks of the observed process */            
+        RArray<TCodeblock>& iCodeblocks;
+
+        /* The mutex for serializing access to the shared resources */
+        RMutex& iMutex;
+
+        /* The process id */
+        TUint iProcessId;
+
+        /* Array for storing the callstack */
+        TFixedArray<TUint32, KATMaxCallstackLength> iCallStack;
+
+        /* Array for storing the reallocation callstack */
+        TFixedArray <TUint32, KATMaxCallstackLength> iReCallStack;
+
+        /* Array for storing the reallocation callstack */	
+        TFixedArray<TUint32, KATMaxFreeCallstackLength> iFreeCallStack;
+                
+        /* Array of threads using this heap */
+        RArray<TThreadStack> iThreadArray;
+
+        RAnalyzeTool& iAnalyzeTool;
+
+        /* A flag for indicating that the RATStorageServer is open */
+        TBool iStorageServerOpen;
+
+        /* Log option */
+        TUint32 iLogOption;
+        
+        /* Max items on stored call stack when memory allocated */
+        TUint32 iAllocMaxCallStack;
+        
+        /* Max items on stored call stack when memory freed */
+        TUint32 iFreeMaxCallStack;
+        
+    };
+
+#endif // ANALYZETOOLALLOCATOR_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetooleventhandler.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,122 @@
+/*
+* 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 CLibraryEventHandler.
+*
+*/
+
+
+#ifndef ANALYZETOOLEVENTHANDLER_H
+#define ANALYZETOOLEVENTHANDLER_H
+
+// INCLUDES
+#include <e32cmn.h>
+#include "Codeblock.h"
+#include <analyzetool/atstorageserverclnt.h>
+#include <analyzetool/analyzeTool.h>
+
+// FORWARD DECLARATIONS
+class MAnalyzeToolEventhandlerNotifier;
+
+// CLASS DECLARATION
+
+/**
+*  Class for receiving library load/unlaod events from the kernel   
+*/
+class CLibraryEventHandler : public CActive
+    {
+    
+    public: 
+
+        /**
+        * C++ default constructor.
+        * @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
+        * @param aNotifier A reference to notifier object which is used to 
+        * 					inform killed threads
+        * @param aLogOption Current used log option on allocator.
+        */
+        CLibraryEventHandler( RAnalyzeTool& aAnalyzeTool, 
+                RArray<TCodeblock>& aCodeblocks, 
+                RATStorageServer& aStorageServer, 
+                TUint aProcessId,
+                RMutex& aMutex,
+                MAnalyzeToolEventhandlerNotifier& aNotifier,
+                TUint32 aLogOption );
+
+        /**
+        * Destructor.
+        */
+        ~CLibraryEventHandler();
+
+        /* Start receiving events from the kernel */
+        void Start();
+        
+        /**
+        * Returns eventhandler's state.
+        * @return TBool ETrue if eventhandler is started, EFalse otherwise
+        */
+        TBool IsStarted();
+
+    protected: // Functions from base classes
+        
+        /**
+        * Process active object's task
+        */
+        void RunL();
+
+        /**
+        * Cancels active object's task
+        */
+        void DoCancel();
+ 
+    private: // Member variables
+
+        /* Handle to the analyze tool device driver*/
+        RAnalyzeTool& iAnalyzeTool; 
+
+        /* A reference to codeblocks of the observed process */
+        RArray<TCodeblock>& iCodeblocks;
+
+        /* Handle to the storage server*/
+        RATStorageServer& iStorageServer;
+
+        /* The observered process id */ 
+        TUint iProcessId;
+
+        /* The library info */
+        TLibraryEventInfo iLibraryInfo;
+
+        /* The mutex for serializing access to the shared resources */
+        RMutex& iMutex;
+        
+        /* Inform if handler is started */
+        TBool iStarted;
+        
+        /* A reference to event handler notifier */
+        MAnalyzeToolEventhandlerNotifier& iNotifier;
+
+        /* Current used log option */
+        TUint32 iLogOption;
+    };
+
+#endif // ANALYZETOOLEVENTHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetooleventhandlernotifier.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,45 @@
+/*
+* 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 MAnalyzeToolEventhandlerNotifier
+*
+*/
+
+
+#ifndef ANALYZETOOLEVENTHANDLERNOTIFIER_H
+#define ANALYZETOOLEVENTHANDLERNOTIFIER_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// CLASS DECLARATION
+
+/**
+*  MAnalyzeToolEventhandlerNotifier class
+*  An interface class for informing killed thread.
+*/
+class MAnalyzeToolEventhandlerNotifier
+    {
+    public: // New functions
+           
+        /**
+        * Inform when thread killed.
+        * @param aThreadId - Killed thread Id.
+        */
+        virtual void RemoveKilledThread( const TUint aThreadId ) = 0;
+
+    };
+
+#endif // ANALYZETOOLEVENTHANDLERNOTIFIER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolfastlog.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,96 @@
+/*
+* 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 __ANALYZETOOLFASTLOG_H__
+#define __ANALYZETOOLFASTLOG_H__
+
+// INCLUDES
+#include    <e32base.h>
+#include    <analyzetool/atcommon.h>
+#include    <analyzetool/analyzetooltraceconstants.h>
+
+// Function prototypes.
+
+/**
+ * TBD
+ * @param aProcessName The name of the new process started. The length of this
+ *   descriptor must not be greater than KMaxProcessName.
+ * @param aProcessId The ID of the process started.
+ * @param aIsDebug Determines whether a binary is UDEB or UREL
+ * @return KErrNone.
+*/
+GLREF_C TInt ATFastLogProcessStarted( const TDesC8& aProcessName,
+                                 TUint aProcessId,
+                                 TUint32 aIsDebug );
+
+/**
+ * TBD 
+ * @param aProcessId The ID number of the process ended.
+ * @param aHandleLeaks An array of handle leaks.
+ * @return KErrNone, if successful; otherwise one of the other
+ *   system-wide error codes.
+ */
+GLREF_C TInt ATFastLogProcessEnded( TUint aProcessId, 
+                                TUint aHandleLeakCount );
+
+/**
+ * TBD
+ * @param aProcessId The ID number of the process ended.
+ * @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.
+*/
+GLREF_C TInt ATFastLogDllLoaded( TUint aProcessId, const TDesC8& aDllName, TUint32 aStartAddress,
+                                TUint32 aEndAddress );
+
+/**
+ * TBD
+ * @param aProcessId The ID number of the process ended.
+ * @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.
+*/
+GLREF_C TInt ATFastLogDllUnloaded( TUint aProcessId, const TDesC8& aDllName, TUint32 aStartAddress,
+                                       TUint32 aEndAddress );
+
+/**
+ * TBD
+ * @param aProcessId The ID number of the process ended.
+ * @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.
+*/
+GLREF_C TInt ATFastLogMemoryAllocated( TUint aProcessId, TUint32 aMemAddress,
+                                  TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
+                                  TInt aSize );
+        
+/**
+ * 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.
+ * @return KErrNone.
+*/
+GLREF_C TInt ATFastLogMemoryFreed( TUint aProcessId, TUint32 aMemAddress, 
+                              TFixedArray<TUint32, KATMaxCallstackLength>& aFreeCallstack );
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolmainallocator.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,329 @@
+/*
+* 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 RAnalyzeToolMainAllocator.
+*
+*/
+
+
+#ifndef ANALYZETOOLMAINALLOCATOR_H
+#define ANALYZETOOLMAINALLOCATOR_H
+
+// 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"
+
+// FORWARD DECLARATIONS
+class CLibraryEventHandler;
+
+// CLASS DECLARATION
+
+/**
+*  Class which overloads the RAlloctor functions and provides access to 
+*  the overloaded functions  
+*/
+class RAnalyzeToolMainAllocator : public RAnalyzeToolMemoryAllocator, 
+								  public MAnalyzeToolEventhandlerNotifier
+    {
+
+    public:
+
+        /**
+        * 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 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
+        */
+        RAnalyzeToolMainAllocator( TBool aNotFirst,
+                const TFileName aFileName,
+                TUint32 aLogOption, TUint32 aIsDebug,
+                TUint32 aAllocCallStackSize,
+                TUint32 aFreeCallStackSize );
+
+        /**
+        * Destructor.
+        */
+        ~RAnalyzeToolMainAllocator();
+
+        /**
+        * Allocates a cell of specified size from the heap.
+        * @param aSize The size of the cell to be allocated from the heap. 
+        * @return TAny* A pointer to the allocated cell.
+        */
+        TAny* Alloc( TInt aSize );
+
+        /**
+        * Frees the specified cell and returns it to the heap.
+        * @param aPtr A pointer to a cell to be freed.
+        */
+        void Free( TAny* aPtr );
+
+        /**
+        * Increases or decreases the size of an existing cell.
+        * @param aPtr A pointer to the cell to be reallocated.
+        * @param aSize The new size of the cell. This may be bigger 
+        *              or smaller than the size of the original cell.
+        * @param aMode Flags controlling the reallocation.
+        * @return TAny* A pointer to the reallocated cell. This may be the 
+        *               same as the original pointer supplied through aCell.
+        */
+        TAny* ReAlloc( TAny* aPtr, TInt aSize, TInt aMode = 0 );
+        
+        /**
+        * Gets the length of the available space in the specified 
+        * allocated cell.
+        * @param aCell A pointer to the allocated cell.
+        * @return TInt The length of the available space in the allocated cell.
+        */
+        TInt AllocLen(const TAny* aCell) const;
+
+    #ifndef __KERNEL_MODE__
+
+        /**	
+        * Opens this heap for shared access. Opening the heap increases 
+        * the heap's access count by one.
+        */
+        TInt Open();
+        
+        /**
+        * Closes this shared heap. Closing the heap decreases the heap's 
+        * access count by one.
+        */  	
+        void Close();
+
+        /**
+        * The function frees excess committed space from the top of the heap.
+        * The size of the heap is never reduced below the minimum size 
+        * specified during creation of the heap.
+        * @return TInt The space reclaimed. If no space can be reclaimed, 
+                       then this value is zero.
+        */
+        TInt Compress();
+
+        /**
+        * Frees all allocated cells on this heap. 
+        */
+        void Reset();
+
+        /**
+        * Gets the number of cells allocated on this heap, and 
+        * the total space allocated to them.
+        * @param aTotalAllocSize On return, contains the total 
+        *						 space allocated to the cells.
+        * @return TInt The number of cells allocated on this heap.
+        */
+        TInt AllocSize( TInt& aTotalAllocSize ) const;
+        
+        /**
+        * Gets the total free space currently available on the heap and the 
+        * space available in the largest free block. The space available 
+        * represents the total space which can be allocated. Note that 
+        * compressing the heap may reduce the total free space available 
+        * and the space available in the largest free block.
+        * @param aBiggestBlock On return, contains the space available 
+        *                      in the largest free block on the heap.
+ 
+        * @return TInt The total free space currently available on the heap.
+
+        */
+        TInt Available( TInt& aBiggestBlock ) const;
+
+	#endif
+        
+        /**
+        * Invocates specified debug funtionality.
+        * @param aFunc The debug function
+        * @param a1 Debug function specific paramenter.
+        * @param a2 Debug function specific paramenter.
+        * @return TInt Returns KErrNone, if successful otherwise one 
+        *              of the other system-wide error codes.
+        */
+        TInt DebugFunction( TInt aFunc, TAny* a1 = NULL, TAny* a2 = NULL );
+        
+        // From MAnalyzeToolEventhandlerNotifier
+        
+        /**
+		* Remove killed thread from threads array.
+		* @param aThreadId - Thread Id
+		*/
+		void RemoveKilledThread( const TUint aThreadId );
+		
+    protected:
+
+        /**
+        * Extension function
+        * @param aExtensionId The extension id
+        * @param a0 Extension specific paramenter.
+        * @param a1 Extension specific paramenter.
+        * @return TInt Returns KErrNone, if successful otherwise one 
+        *              of the other system-wide error codes. 
+        */
+        TInt Extension_( TUint aExtensionId, TAny*& a0, TAny* a1 );
+
+    public: // from RAnalyzeToolMemoryAllocator
+        
+        /**
+        * Installs the RTraceAllocator allocator
+        */
+        void Uninstall();
+        
+        /**
+        * Shares the heap
+        */
+        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
+        */
+        inline RArray<TCodeblock>& Codeblocks();
+        
+        /**
+        * Acquires the mutex used to access shared objects
+        * @return RMutex& A reference to open mutex
+        */
+        inline RMutex& Mutex();
+        
+        /**
+        * Acquires the current process id
+        * @return TInt The process id
+        */
+        inline TInt ProcessId();
+
+        /**
+		* Acquires the logical channel handle
+		* @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 
+        * @return TUint32 iLogOption
+        */        
+        inline TUint32 LogOption();
+        
+        /**
+        * Acquires the max size of call stack when memory allocated
+        * @return TUint32 iAllocMaxCallStack
+        */        
+        inline TUint32 AllocMaxCallStack();
+        
+        /**
+         * Acquires the max size of call stack when memory freed
+         * @return TUint32 iFreeMaxCallStack
+         */
+        inline TUint32 FreeMaxCallStack();
+
+    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 aIsDebug Determines whether a binary is UDEB or UREL
+        */
+        void LogProcessInformation( const TFileName aFileName, TUint32 aLogOption,
+                                                                TUint32 aIsDebug );
+
+        /**
+        * Find the current thread which is using the heap
+        * @param aStackStart A reference where the stack start is stored
+        * @return TBool ETrue if a thread can be found, EFalse otherwise
+        */
+        TBool FindCurrentThreadStack( TUint32& aStackStart );
+        
+        /**
+        * Installs the eventhandler, if possible
+        */
+        void InstallEventHandler();
+
+    private: // member variables
+            
+        /* Handle to the RATStorageServer */
+        RATStorageServer iStorageServer;
+
+        /* Handle to the RAnalyzeTool */		
+        RAnalyzeTool iAnalyzeTool;           
+        
+        /* A flag for indicating that the RAnalyzeTool is open */
+        TBool iAnalyzeToolOpen;
+
+        /* A flag for indicating that the device driver is loaded */
+        TBool iDeviceDriverLoaded;
+        
+        /* The codeblocks of the process */
+        RArray<TCodeblock> iCodeblocks;
+
+        /* The handler for kerner events */
+        CLibraryEventHandler* iEventHandler;
+
+        /* The mutex for serializing access to the shared resources */
+        mutable RMutex iMutex;	
+        	
+        /* Array for storing the callstack */	
+        TFixedArray <TUint32, KATMaxCallstackLength> iCallStack;
+
+        /* Array for storing the reallocation callstack */	
+        TFixedArray <TUint32, KATMaxCallstackLength> iReCallStack;
+
+        /* Array for storing the reallocation callstack */	
+        TFixedArray<TUint32, KATMaxFreeCallstackLength> iFreeCallStack;
+                
+        /* Array of threads using this heap */
+        RArray<TThreadStack> iThreadArray;
+
+        /* A flag for indicating that the RATStorageServer is open */
+        TBool iStorageServerOpen;
+        
+        /* Log option */
+        TUint32 iLogOption;
+
+        /* The process id */
+        TUint iProcessId;	
+        
+        /* Max items on stored call stack when memory allocated */
+        TUint32 iAllocMaxCallStack;
+        
+        /* Max items on stored call stack when memory freed */
+        TUint32 iFreeMaxCallStack;
+        
+    };
+
+// INLINES
+#include "analyzetoolmainallocator.inl"
+
+#endif // ANALYZETOOLMAINALLOCATOR_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolmainallocator.inl	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,109 @@
+/*
+* 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:  Definition for the inline functions of RAnalyzeToolMainAllocator.
+*
+*/
+
+
+#include "analyzetoolmemoryallocator.h"
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::StorageServer()
+// Acquires reference to open RATStorageServer
+// -----------------------------------------------------------------------------
+//
+inline RATStorageServer& RAnalyzeToolMainAllocator::StorageServer()
+    {
+    return iStorageServer;
+    }
+  
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Codeblocks()
+// Acquires reference to process used codeblocks
+// -----------------------------------------------------------------------------
+//  
+inline RArray<TCodeblock>& RAnalyzeToolMainAllocator::Codeblocks()
+    {
+    return iCodeblocks;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Mutex()
+// Acquires reference to mutex which is used to share resources
+// -----------------------------------------------------------------------------
+//  
+inline RMutex& RAnalyzeToolMainAllocator::Mutex()
+    {
+    return iMutex;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::ProcessId()
+// Acquires the process id
+// -----------------------------------------------------------------------------
+//
+inline TInt RAnalyzeToolMainAllocator::ProcessId()
+    {
+    return iProcessId;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::AnalyzeTool()
+// Acquires the logical channel handle
+// -----------------------------------------------------------------------------
+//
+inline RAnalyzeTool& RAnalyzeToolMainAllocator::AnalyzeTool()
+    {
+    return iAnalyzeTool;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::StorageServerOpen()
+// Acquires the iStorageServerOpen variable
+// -----------------------------------------------------------------------------
+//
+inline TBool RAnalyzeToolMainAllocator::StorageServerOpen()
+    {
+    return iStorageServerOpen;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::LogOption()
+// Acquires the iLogOption variable
+// -----------------------------------------------------------------------------
+//
+inline TUint32 RAnalyzeToolMainAllocator::LogOption()
+    {
+    return iLogOption;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::AllocMaxCallStack()
+// Acquires the iAllocMaxCallStack variable
+// -----------------------------------------------------------------------------
+//
+inline TUint32 RAnalyzeToolMainAllocator::AllocMaxCallStack()
+    {
+    return iAllocMaxCallStack;
+    }
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::FreeMaxCallStack()
+// Acquires the iFreeMaxCallStack variable
+// -----------------------------------------------------------------------------
+//
+inline TUint32 RAnalyzeToolMainAllocator::FreeMaxCallStack()
+    {
+    return iFreeMaxCallStack;
+    }
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolmemoryallocator.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,94 @@
+/*
+* 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 RAnalyzeToolMemoryAllocator.
+*
+*/
+
+
+#ifndef ANALYZETOOLMEMORYALLOCATOR_H
+#define ANALYZETOOLMEMORYALLOCATOR_H
+
+// INCLUDES
+#include <u32std.h>
+#include "threadstack.h"
+#include "../../symbian_version.hrh"
+
+// CONSTANTS
+#if ( SYMBIAN_VERSION_SUPPORT >= SYMBIAN_3 )
+    #ifndef __WINS__
+    const TInt KDummyHandle = -1000;
+    #endif
+#endif
+
+// CLASS DECLARATION
+
+/**
+*  Abstract class for basic RAnalyzeToolMemoryAllocator funtions
+*/
+class RAnalyzeToolMemoryAllocator : public RAllocator
+    {
+    public:
+    
+        /**
+        * C++ default constructor.
+        * @param aNotFirst Is this first thread using this heap
+        */   
+        RAnalyzeToolMemoryAllocator( TBool aNotFirst );
+        
+        /**
+        * Destructor.
+        */  
+        //lint -e{1510} suppress "base class 'RAllocator' has no destructor"    
+        virtual ~RAnalyzeToolMemoryAllocator();
+        
+        /**
+        * Uninstall the RAnalyzeToolMemoryAllocator
+        */
+        virtual void Uninstall() = 0;
+        
+        /**
+        * Shares the heap for another thread
+        */
+        virtual void ShareHeap() = 0;
+
+    protected:
+
+        /**
+         * Switch original allocator in use.
+         * Switches original allocator in use if not already.
+         */
+        void SwitchOriginalAllocator();
+        
+        /**
+         * Checks is the given address in loaded code memory area.
+         */
+        inline bool IsAddressLoadedCode( TUint32& aAddress );
+        
+        /* The original thread RAllocator */
+        RAllocator* iAllocator;
+        
+        /* Is this the first thread using this heap */
+        TBool iNotFirst;   
+
+        /* Memorymodel */
+        TUint32 iMemoryModel;
+        
+    };
+
+// INLINES
+#include "analyzetoolmemoryallocator.inl"
+
+#endif // ANALYZETOOLMEMORYALLOCATOR_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolmemoryallocator.inl	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,54 @@
+/*
+* 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:  Definition for the inline functions of RAnalyzeToolMemoryAllocator.
+*
+*/
+
+
+
+#include <analyzetool/atcommon.h>
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMemoryAllocator::IsAddressLoadedCode()
+// Checks is the given address in loaded code memory area.
+// -----------------------------------------------------------------------------
+//
+inline bool RAnalyzeToolMemoryAllocator::IsAddressLoadedCode( TUint32& aAddress )
+    {
+    // Debug log strings in this function are not used because
+    // this is called so many times.
+    /*
+     * TMemModelAttributes models.
+     * EMemModelTypeDirect      // direct memory model on hardware
+     * EMemModelTypeMoving=1    // moving memory model on hardware
+     * EMemModelTypeMultiple=2  // multiple memory model on hardware
+     * EMemModelTypeEmul=3      // emulation using single host process
+     * Flexible ?
+     */
+    switch( iMemoryModel )
+        {
+        case EMemModelTypeMultiple:
+            // Use low & high limits which define rofs loading->rom area
+            // in multiple memory model.
+            if ( aAddress < KATMultipleMemoryModelLowLimit 
+              || aAddress > KATMultipleMemoryModelHighLimit )
+                return false;
+            return true;
+        default:
+            return true;
+        }
+    }
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/analyzetoolpanics.pan	Thu Feb 11 15:51:35 2010 +0200
@@ -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:  Panic codes and definition of a panic function for the Memory Hook
+*
+*/
+
+
+#ifndef ANALYZETOOLPANICS_PAN_H
+#define ANALYZETOOLPANICS_PAN_H
+
+_LIT( KAnalyzeToolName, "AnalyzeTool" );
+
+/** AnalyzeTool application panic codes */
+enum TAnalyzeToolPanics
+    {
+    ENoMemory = 1,
+    EFailedToCreateHeap,
+    ECantOpenHandle,
+    ECantLoadDevice,
+    ECantAppendToTheArray,
+    ECantFindRightThread,
+    ECantConnectStorageServer,
+    ECantShareStorageServer,
+    ECantCreateMutex,
+    ECantLoadDeviceDriver,
+    ECantConnectDeviceDriver
+    // add further panics here
+    };
+
+inline void AssertPanic(TAnalyzeToolPanics aReason)
+    {
+    User::Panic( KAnalyzeToolName, aReason );
+    }
+
+#endif // ANALYZETOOLPANICS_PAN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/codeblock.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,92 @@
+/*
+* 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 TCodeblock.
+*
+*/
+
+
+#ifndef CODEBLOCK_H
+#define CODEBLOCK_H
+
+// INCLUDES
+#include <u32std.h>
+
+/**
+*  Stores information of process loaded code segments
+*/
+class TCodeblock
+    {
+    
+    public: // Constructors
+        
+        /**
+        * C++ default constructor.
+        * @param aRunAddress Start address of the memory block. 
+        * @param aSize The size of the memory block.
+        * @param aName The name of the library
+        */
+        TCodeblock( TLinAddr aRunAddress, TUint32 aSize, TBuf8<KMaxLibraryName>& aName );
+
+    public: // New functions
+
+        /**
+        * Checks if the given address is in this memory block area
+        * @param aAddress A address to be checked. 
+        * @return TBool Returns ETrue if the given address is in this
+        *               memory block area, EFalse otherwise
+        */
+        TBool CheckAddress( TUint32 aAddress );
+
+        /**
+        * Matches if the given parameters represents this memory block 
+        * @param aName The name of the library
+        * @return TBool Returns ETrue if the given parameters represents
+        *               this memory block, EFalse otherwise
+        */
+        TBool Match( TBuf8<KMaxLibraryName>& aName );
+
+        /**
+        * Returs specific segment's end address 
+        * @return TUint end address of the code segment
+        */
+        TUint32 EndAddress();
+
+        /**
+        * Returs specific segment's start address
+        * @return TUint start address of the code segment
+        */
+        TUint32 StartAddress();
+
+        /**
+        * Gets specific code segment's name
+        * @param aName Name of the code segment
+        */
+        void Name( TDes8& aName );
+        
+    private: // Member variables
+
+        /* Start address of the memory block */
+        TLinAddr iStartAddress;
+
+        /* End address of the memory block */
+        TLinAddr iEndAddress;
+
+        /* End address of the memory block */
+        TBuf8<KMaxLibraryName> iName;
+    };
+
+#endif // CODEBLOCK_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/customuser.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,185 @@
+/*
+* 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>
+
+// CLASS DECLARATION
+
+/**
+*  Class which overloads the User functions and provides access to 
+*  the overloaded functions  
+*/
+class CustomUser
+    {
+    
+    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
+        * @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 TFileName aVersion,
+                             TUint32 aAllocCallStackSize,
+                             TUint32 aFreeCallStackSize );
+                             
+        /**
+        * 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 );
+        
+        /**
+		* Overloaded version of User::DbgMarkEnd()
+		* Marks the end of heap cell checking at the current nested level 
+		* for the current thread's default heap, or the kernel heap.
+		* @param aKernel ETrue, if checking is being done for the kernel heap; 
+		* 	EFalse, if checking is being done for the current thread's default heap.
+		* @param aCount The number of allocated heap cells expected.
+		*/ 
+        IMPORT_C static TUint32 CustomUser::__DbgMarkEnd( TBool aKernel, TInt aCount );
+        
+    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 TFileName aVersion, TDes& aToolVersion ); 
+        
+		/**
+		* Function for showing incorrect version information (file or XTI).
+		* @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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/inc/threadstack.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,70 @@
+/*
+* 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 TThreadStack.
+*
+*/
+
+
+#ifndef THREADSTACK_H
+#define THREADSTACK_H
+
+// INCLUDES
+#include <u32std.h>
+
+// CLASS DECLARATION
+
+/**
+*  Stores thread id and the start of the thread's callstack
+*/
+class TThreadStack
+    {
+    public:
+    
+        /**
+        * C++ default constructor.
+        * @param aId The thread id
+        * @param aStackStart The start of thread's stack
+        */
+        TThreadStack( TThreadId aId, TUint32 aStackStart );
+        
+        /**
+        * Checks if this is the current thread and if this is the current
+        * thread assings value to the given parameter
+        * @param aStackStart& A reference to stack start
+        * @return TBool The start of thread's stack
+        */
+        TBool ThreadStackStart( TUint32& aStackStart );
+       
+        /**
+        * Checks if this the the current thread
+        * @param aThreadId A thread id
+        * @return TBool ETrue it this is the current thread, EFalse otherwise
+        */ 
+        TBool Match( const TUint aThreadId = 0 );
+        
+    private: // Member variables
+    
+        /* The id of the thread */
+        TThreadId iId;
+        
+        /* The start addess of this thread */
+        TUint32 iStackStart;
+    };
+
+
+#endif // THREADSTACK_H
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/sis/analyzetoolmemoryhook.pkg	Thu Feb 11 15:51:35 2010 +0200
@@ -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:
+;
+
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"AnalyzeToolMemoryHook"},(0xEDF5A8B1),1,8,0
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+; 1 File to install
+"\epoc32\release\armv5\urel\atoolmemoryhook.dll"-"!:\sys\bin\atoolmemoryhook.dll"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/src/analyzetoolallocator.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,1008 @@
+/*
+* 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 RAnalyzeToolAllocator.
+*
+*/
+
+
+#include "analyzetoolallocator.h"
+#include "analyzetoolmemoryallocator.h"
+#include "atlog.h"
+#include "analyzetoolpanics.pan"
+#include "analyzetoolfastlog.h"
+#include <e32svr.h>
+
+// CONSTANTS
+
+// Length of the callstack address
+const TUint32 KAddressLength = 4;
+
+// Thread count
+const TInt KThreadCount = 1;
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::RAnalyzeToolAllocator()
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+RAnalyzeToolAllocator::RAnalyzeToolAllocator( TBool aNotFirst, 
+                                              RATStorageServer& aStorageServer, 
+                                              RArray<TCodeblock>& aCodeblocks, 
+                                              RMutex& aMutex,
+                                              TUint aProcessId,
+                                              RAnalyzeTool& aAnalyzeTool,
+                                              TBool aStorageServerOpen,
+                                              TUint32 aLogOption,
+                                              TUint32 aAllocCallStackSize,
+                                              TUint32 aFreeCallStackSize ) :
+    RAnalyzeToolMemoryAllocator( aNotFirst ),
+    iStorageServer( aStorageServer ), 
+    iCodeblocks( aCodeblocks ), 
+    iMutex( aMutex ),
+    iProcessId( aProcessId ),
+    iThreadArray( KATMaxCallstackLength ),
+    iAnalyzeTool( aAnalyzeTool ),
+    iStorageServerOpen( aStorageServerOpen ),
+    iLogOption( aLogOption ),
+    iAllocMaxCallStack( aAllocCallStackSize ),
+    iFreeMaxCallStack( aFreeCallStackSize )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::RAnalyzeToolAllocator()" );
+    
+    // Append thread to array of the users of this allocator
+    TThreadParamsBuf params;
+    params().iThreadId = RThread().Id().operator TUint();
+    TInt error = iAnalyzeTool.ThreadStack( params );
+    if ( KErrNone == error )
+        {
+        LOGSTR2( "ATMH Thread stack address: %x", params().iStackAddress );
+        LOGSTR2( "ATMH Thread stack size:    %x", params().iStackSize );
+        error = iThreadArray.Append( TThreadStack( RThread().Id(), 
+                             params().iStackAddress + params().iStackSize ) );
+        }
+    
+    __ASSERT_ALWAYS( KErrNone == error, AssertPanic( ECantAppendToTheArray ) ); 
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::~RAnalyzeToolAllocator()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+RAnalyzeToolAllocator::~RAnalyzeToolAllocator()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::~RAnalyzeToolAllocator()" );
+    
+    // Close the thread array 
+    iThreadArray.Close();
+    }
+    
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::Uninstall()
+// Uninstalls the current allocator
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolAllocator::Uninstall()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::Uninstall()" );
+
+    // Switch back to the original allocator
+    SwitchOriginalAllocator();
+    
+    // Check if this is shared allocator between threads
+    if ( iThreadArray.Count() > KThreadCount )
+        {
+        // Close the shared allocator
+        Close();
+        return;
+        }
+
+#if ( SYMBIAN_VERSION_SUPPORT >= SYMBIAN_3 )
+    #ifndef __WINS__ 
+    // Remove dummy Tls handle
+    UserSvr::DllFreeTls( KDummyHandle );
+    #endif
+#endif
+    
+    // Since this is the last thread using this allocator it can be deleted
+    delete this;
+    }
+
+#ifdef __WINS__
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::Alloc() WINS version
+// Allocates a cell of specified size from the heap.
+// -----------------------------------------------------------------------------
+//
+UEXPORT_C TAny* RAnalyzeToolAllocator::Alloc( TInt aSize )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::Alloc()" );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // 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 xti.
+    if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+        {
+        // 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 == EATLogToXtiFast )
+            {
+            // Using fast xti.
+            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;
+                    }
+                }
+            }
+        }
+    // Release the mutex
+    iMutex.Signal();
+    
+    return p;
+    }
+#else
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::Alloc() ARMV5 version
+// Allocates a cell of specified size from the heap.
+// -----------------------------------------------------------------------------
+//
+TAny* RAnalyzeToolAllocator::Alloc( TInt aSize )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::Alloc()" );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // 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 xti.
+    if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+        {
+        // 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
+            {
+            for ( TInt j = 0; j < blocksCount; j++ )
+                {
+                if ( iCodeblocks[j].CheckAddress( (TUint32) *( (TUint32*) i ) ) )
+                    {
+                    // To avoid recursive call to ReAlloc specifying granularity
+                    // Add address to the callstack
+                    iCallStack[arrayCounter] = ( (TUint32) *( (TUint32*) i ) );
+                    arrayCounter++;
+                    break;
+                    }
+                }
+            if ( arrayCounter == KATMaxCallstackLength ||
+                 arrayCounter == iAllocMaxCallStack )
+                {
+                LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
+                break;
+                }
+            }
+        // Log the memory allocation information
+        if ( iLogOption == EATLogToXtiFast )
+            {
+            // Fast xti.
+            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;
+                    }
+                }
+            }
+        }
+ 
+    // Release the mutex
+    iMutex.Signal(); 
+    
+    // Return the allocatated memory
+    return p;
+    }
+#endif // __WINS__
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::Free()
+// Frees the allocated memory
+// -----------------------------------------------------------------------------
+//
+TAny RAnalyzeToolAllocator::Free( TAny* aPtr )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::Free()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Don't collect or log data if storage server not open or logging mode not fast xti.
+    if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+        {
+        // Reset the callstack
+        iFreeCallStack.Reset();
+        
+        // Check if XTI logging mode because free call stack is not used in other log options.
+        if ( (iLogOption == EATUseDefault || iLogOption == EATLogToXti || iLogOption == EATLogToXtiFast )
+                && 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 == EATLogToXtiFast )
+            {
+            // Using fast xti.
+            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 );
+                }
+            }
+        }
+    
+    // Free the memory using original allocator
+    iAllocator->Free( aPtr ); 
+    
+    LOGSTR2( "ATMH RAnalyzeToolAllocator::Free() - aPtr: %x", (TUint32)aPtr );
+    
+    // Release the mutex
+    iMutex.Signal();
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::Open()
+// Opens this heap for shared access. Opening the heap increases 
+// the heap's access count by one.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolAllocator::Open()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::Open()");
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Share the memory using original allocator
+    TInt error = iAllocator->Open();
+    
+    // If everything is OK add thread to the array which use this allocator
+    if ( KErrNone == error )
+        {
+        TThreadParamsBuf params;
+        params().iThreadId = RThread().Id().operator TUint();
+        error = iAnalyzeTool.ThreadStack( params );
+
+        __ASSERT_ALWAYS( KErrNone == error, AssertPanic( ECantAppendToTheArray ) );
+
+        if ( KErrNone == error )
+            {
+            LOGSTR2( "ATMH Thread stack address: %x", params().iStackAddress );
+            LOGSTR2( "ATMH Thread stack size:    %x", params().iStackSize );
+            iThreadArray.Append( TThreadStack( RThread().Id(), 
+                    params().iStackAddress + params().iStackSize ) );
+            }
+        }
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Return the error code
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::Close()
+// Closes this shared heap. Closing the heap decreases the heap's 
+// access count by one.
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolAllocator::Close()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::Close()" );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Close the memory using original allocator
+    iAllocator->Close();
+    
+    TInt count = iThreadArray.Count();
+    
+    // Iterate through array of threads to remove current thread
+    for ( TInt i = 0; i < count; i++ )
+        {
+        // Check if this is current thread
+        if ( iThreadArray[ i ].Match() )
+            {
+            // Remove the thread
+            iThreadArray.Remove( i );
+            break;
+            }
+        }
+    
+    // Release the mutex
+    iMutex.Signal();
+    }
+
+#ifdef __WINS__
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::ReAlloc()
+// Increases or decreases the size of an existing cell.
+// -----------------------------------------------------------------------------
+//
+TAny* RAnalyzeToolAllocator::ReAlloc( TAny* aPtr, TInt aSize, TInt aMode )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::ReAlloc()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // Realloc the memory using original allocator
+    TAny* ptr = iAllocator->ReAlloc( aPtr, aSize, aMode );
+    
+    // NULL addresses are not in a process under test
+    if ( ptr && !( aMode & ENeverMove ) )
+        {
+        LOGSTR3( "ATMH RAnalyzeToolAllocator::ReAlloc() - aPtr: %x, ptr: %x", 
+                (TUint32)aPtr, (TUint32)ptr );
+        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 xti.
+        if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+            {
+            // 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 XTI logging mode(s) we also log call stack in free.
+                if ( ( iLogOption == EATUseDefault || iLogOption == EATLogToXti || iLogOption == EATLogToXtiFast )
+                        && 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 == EATLogToXtiFast )
+                    {
+                    ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack );
+                    }
+                else
+                    {
+                    iStorageServer.LogMemoryFreed( (TUint32) aPtr, iFreeCallStack );
+                    }
+                }
+            
+            // Log the memory allocation information
+            if ( iLogOption == EATLogToXtiFast )
+                {
+                // Using fast xti.
+                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;
+                        }
+                    }
+                }
+            }
+        }
+    
+    // Release the mutex
+    iMutex.Signal();
+
+    // Return pointer to the reallocated cell
+    return ptr; 
+    }
+
+#else
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::ReAlloc()
+// Increases or decreases the size of an existing cell.
+// -----------------------------------------------------------------------------
+//
+TAny* RAnalyzeToolAllocator::ReAlloc( TAny* aPtr, TInt aSize, TInt aMode )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::ReAlloc()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // Realloc the memory using original allocator
+    TAny* ptr = iAllocator->ReAlloc( aPtr, aSize, aMode );
+
+    // NULL addresses are not in a process under test
+    if ( ptr && !( aMode & ENeverMove ) )
+        {
+        LOGSTR3( "ATMH RAnalyzeToolAllocator::ReAlloc() - aPtr: %x, ptr: %x", 
+                (TUint32)aPtr, (TUint32)ptr );
+        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 xti.
+        if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+            {
+            // 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() );
+            TInt error( KErrNone );
+            TUint arrayCounter = 0;
+            
+            for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+                {
+                for ( TInt j = 0; j < blocksCount; j++ )
+                    {
+                    if ( iCodeblocks[j].CheckAddress( (TUint32) *( (TUint32*) i ) ) )
+                        {
+                        // To avoid recursive call to ReAlloc specifying granularity
+                        // Add address to the callstack
+                        iReCallStack[arrayCounter] = ( (TUint32) *( (TUint32*) i ) );
+                        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 XTI logging mode(s) we also log call stack with free.
+                if ( ( iLogOption == EATUseDefault || iLogOption == EATLogToXti || iLogOption == EATLogToXtiFast )
+                        && 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 == EATLogToXtiFast )
+                    {
+                    ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack );
+                    }
+                else
+                    {
+                    iStorageServer.LogMemoryFreed( (TUint32) aPtr, iFreeCallStack );
+                    }
+                }
+        
+            // Log the memory allocation information
+            if ( iLogOption == EATLogToXtiFast )
+                {
+                // Using fast xti.
+                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;
+                        }
+                    }
+                }
+            }
+        }
+
+    // Release the mutex
+    iMutex.Signal();
+
+    // Return pointer to the reallocated cell
+    return ptr; 
+    }
+
+#endif // __WINS__
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::Compress()
+// The function frees excess committed space from the top of the heap.
+// The size of the heap is never reduced below the minimum size 
+// specified during creation of the heap.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolAllocator::Compress()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::Compress()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // Compress the memory using original allocator
+    TInt compress = iAllocator->Compress();
+
+    // Release the mutex
+    iMutex.Signal();
+
+    // Return the space reclaimed
+    return compress;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::Reset()
+// Frees all allocated cells on this heap. 
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolAllocator::Reset()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::Reset()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // Reset the memory using original allocator
+    iAllocator->Reset();
+
+    // Release the mutex
+    iMutex.Signal();
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::AllocSize()
+// Gets the number of cells allocated on this heap, and 
+// the total space allocated to them.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolAllocator::AllocSize( TInt& aTotalAllocSize ) const
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::AllocSize()" );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Acquire the memory information using original allocator
+    TInt size = iAllocator->AllocSize( aTotalAllocSize );
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Return the number of cells allocated on this heap.
+    return size;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::Available()
+// Gets the total free space currently available on the heap and the 
+// space available in the largest free block. The space available 
+// represents the total space which can be allocated. Note that 
+// compressing the heap may reduce the total free space available 
+// and the space available in the largest free block.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolAllocator::Available( TInt& aBiggestBlock ) const
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::Available()" );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Acquire the memory information using original allocator
+    TInt available = iAllocator->Available( aBiggestBlock );
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Return the total free space currently available on the heap
+    return available;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::AllocLen()
+// Gets the length of the available space in the specified 
+// allocated cell.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolAllocator::AllocLen( const TAny* aCell ) const
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::AllocLen()" ); 
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Acquire the memory information using original allocator
+    TInt len = iAllocator->AllocLen( aCell );
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Return the length of the available space in the allocated cell.
+    return len;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::DebugFunction()
+// Invocates specified debug funtionality.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolAllocator::DebugFunction( TInt aFunc, TAny* a1, TAny* a2 )
+    {
+    LOGSTR2( "ATMH RAnalyzeToolAllocator::DebugFunction() %i", aFunc );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Invocate debug funtion using original allocator
+    TInt debug = iAllocator->DebugFunction( aFunc, a1, a2 );
+    
+    switch( aFunc )
+		{  
+		case EMarkEnd:
+			{
+			// Disables the __UHEAP_MARKEND macro
+			LOGSTR1( "ATMH __UHEAP_MARKEND macro called" );
+			if ( debug > 0 )
+				{
+				LOGSTR2( "ATMH __UHEAP_MARKEND detects leaks: %d", debug );
+				// Because there is leaks the alloc panic will occur but
+				// lets return a zero to pretend that everything is OK
+				debug = 0;
+				}
+			}
+		break;
+		
+		default:
+			{
+			}
+		break;
+		}
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Return information of the debug function success
+    return debug;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::Extension_()
+// Extension function
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolAllocator::Extension_( TUint aExtensionId, TAny*& a0, 
+    TAny* a1 ) 
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::Extension_()" );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Invocate extension funtion using original allocator
+    TInt ext = RAllocator::Extension_( aExtensionId, a0, a1 );
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Return information of the extension function success
+    return ext;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::ShareHeap()
+// Share heap with other thread
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolAllocator::ShareHeap()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolAllocator::ShareHeap()" );
+    
+    // Call the overwrited Open function
+    Open();
+    }
+    
+// -----------------------------------------------------------------------------
+// RAnalyzeToolAllocator::FindCurrentThreadStack()
+// Find the current thread which is using the heap
+// -----------------------------------------------------------------------------
+//
+TBool RAnalyzeToolAllocator::FindCurrentThreadStack( TUint32& aStackStart )
+    {
+    LOGSTR2( "ATMH RAnalyzeToolAllocator::FindCurrentThreadStack(), count( %i )", 
+            iThreadArray.Count() );
+    
+    // Flag for indicating that right thread has been found
+    TBool found( EFalse );
+    // If threre is only one thread it must be the right thread
+    if ( iThreadArray.Count() == KThreadCount )
+        {
+        if ( !iThreadArray[ 0 ].ThreadStackStart( aStackStart ) )
+            {
+            // This MUST BE the right thread
+            //__ASSERT_ALWAYS( EFalse, AssertPanic( ECantFindRightThread ) );
+            }
+        else if ( iThreadArray[ 0 ].ThreadStackStart( aStackStart ) )
+            {
+            found = ETrue;
+            }
+        }
+    else
+        {
+        // Iterate through array to find right thread
+        TInt count( iThreadArray.Count() );
+        
+        for ( TInt i = 0; i < count; i++ )
+            {
+            // Check if this is the right thread
+            if ( iThreadArray[ i ].ThreadStackStart( aStackStart ) )
+                {
+                // Right thread found. Mark the flag
+                found = ETrue;
+                break;
+                }
+            }
+        // If right thread was not found the panic must be raised
+        if ( !found )
+            {
+            //__ASSERT_ALWAYS( EFalse, AssertPanic( ECantFindRightThread ) );
+            }
+        }
+    return found;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/src/analyzetooleventhandler.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,230 @@
+/*
+* 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 CLibraryEventHandler.
+*
+*/
+
+
+// INCLUDE FILES
+#include "atlog.h"
+#include "analyzetooleventhandler.h"
+#include "analyzetooleventhandlernotifier.h"
+#include "analyzetoolmemoryallocator.h"
+#include "analyzetoolfastlog.h"
+
+// -----------------------------------------------------------------------------
+// CLibraryEventHandler::~CLibraryEventHandler()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CLibraryEventHandler::~CLibraryEventHandler()
+    {
+    LOGSTR1( "ATMH CLibraryEventHandler::~CLibraryEventHandler()" );
+    Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CLibraryEventHandler::RunL()
+// Process active object's task
+// -----------------------------------------------------------------------------
+//
+void CLibraryEventHandler::RunL()
+    {
+    LOGSTR1( "ATMH CLibraryEventHandler::RunL()" );
+
+    if ( KErrNone != iStatus.Int() )
+        {
+        LOGSTR2( "ATMH RunL error: %i",  iStatus.Int() );
+        return;
+        }
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // Check that this is observed process 
+    if ( iLibraryInfo.iEventType == TLibraryEventInfo::ELibraryAdded )
+        {
+        LOGSTR1( "ATMH CLibraryEventHandler::RunL() - TLibraryEventInfo::ELibraryAdded" );
+        if ( iLibraryInfo.iProcessId == iProcessId )
+            {
+            TInt error( KErrNone );
+
+            // Log library load event.
+            if ( iLogOption == EATLogToXtiFast )
+                {
+                LOGSTR1( "ATMH CLibraryEventHandler::RunL() - ATFastLog.LogDllLoaded() " );
+                ATFastLogDllLoaded( iProcessId,
+                        iLibraryInfo.iLibraryName, 
+                        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 );
+                }
+            if ( KErrNone == error )
+                {
+                iCodeblocks.Append( TCodeblock( iLibraryInfo.iRunAddress, 
+                        iLibraryInfo.iSize, 
+                        iLibraryInfo.iLibraryName ) );
+                }
+            }
+        }
+    else if ( iLibraryInfo.iEventType == TLibraryEventInfo::ELibraryRemoved )
+        {
+        LOGSTR1( "ATMH CLibraryEventHandler::RunL() - TLibraryEventInfo::ELibraryRemoved " );
+        TInt count = iCodeblocks.Count();
+        LOGSTR2( "ATMH count of code blocks: %i",  count );
+        for ( TInt i = 0; i < count; i++ )
+            {
+            if ( iCodeblocks[ i ].Match( iLibraryInfo.iLibraryName ) )
+                {
+                TBuf8<KMaxLibraryName> libraryName;
+                libraryName.Copy( iLibraryInfo.iLibraryName );
+                
+                // Log library unloaded event
+                if ( iLogOption == EATLogToXtiFast )
+                    {
+                    LOGSTR1( "ATMH CLibraryEventHandler::RunL() - ATFastLogDllUnloaded() " );
+                    ATFastLogDllUnloaded( iProcessId,
+                            libraryName,
+                            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
+                    }
+                iCodeblocks.Remove( i );
+                break;
+                }
+            }
+        }
+    else if ( iLibraryInfo.iEventType == TLibraryEventInfo::EKillThread )
+		{
+		LOGSTR1( "ATMH CLibraryEventHandler::RunL() - TLibraryEventInfo::EKillThread" );
+	  
+		iNotifier.RemoveKilledThread( iLibraryInfo.iThreadId );
+    	}
+    
+    Start();
+    
+    // Release the mutex
+    iMutex.Signal();
+    }
+
+// -----------------------------------------------------------------------------
+// CLibraryEventHandler::DoCancel()
+// Cancels active object's task
+// -----------------------------------------------------------------------------
+//
+void CLibraryEventHandler::DoCancel()
+    {
+    LOGSTR1( "ATMH CLibraryEventHandler::DoCancel()" );
+    // Cancel the subscription of the library events
+    if ( IsActive() )
+        {
+        iStarted = EFalse;
+        
+        iAnalyzeTool.CancelLibraryEvent();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CLibraryEventHandler::Start()
+// Creates CActiveScheduler and variables for the child thread
+// -----------------------------------------------------------------------------
+//
+void CLibraryEventHandler::Start()
+    {
+    LOGSTR1( "ATMH CLibraryEventHandler::Start()" );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+
+    if ( !IsAdded() )
+        {
+        CActiveScheduler::Add( this );
+        }
+
+    // Cancel current subscribetion
+    if ( IsActive() )
+        {
+        iStarted = EFalse;
+        Cancel();
+        }
+
+    iStatus = KErrNone;
+    iAnalyzeTool.LibraryEvent( iStatus, iLibraryInfo );
+    SetActive();
+    
+    iStarted = ETrue;
+    // Release the mutex
+    iMutex.Signal();
+    }
+
+// -----------------------------------------------------------------------------
+// CLibraryEventHandler::CLibraryEventHandler()
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CLibraryEventHandler::CLibraryEventHandler( RAnalyzeTool& aAnalyzeTool, 
+	RArray<TCodeblock>& aCodeblocks, RATStorageServer& aStorageServer, 
+	TUint aProcessId, RMutex& aMutex, 
+	MAnalyzeToolEventhandlerNotifier& aNotifier,
+	TUint32 aLogOption ) 
+ :	CActive( EPriorityNormal ),
+    iAnalyzeTool( aAnalyzeTool ),
+    iCodeblocks( aCodeblocks ),
+    iStorageServer( aStorageServer ),
+    iProcessId( aProcessId ),
+    iMutex( aMutex ),
+    iStarted( EFalse ),
+    iNotifier( aNotifier ),
+    iLogOption( aLogOption )
+    {
+    LOGSTR1( "ATMH CLibraryEventHandler::CLibraryEventHandler()" );
+    }
+
+// -----------------------------------------------------------------------------
+// CLibraryEventHandler::IsStarted()
+// Returns eventhandler's state.
+// -----------------------------------------------------------------------------
+//
+TBool CLibraryEventHandler::IsStarted()
+    {
+    LOGSTR2( "ATMH CLibraryEventHandler::IsStarted(%i)", iStarted );
+    
+    return iStarted;
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/src/analyzetoolfastlog.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,298 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <e32debug.h> // RDebug
+#include <analyzetool/analyzetooltraceconstants.h>
+#include "analyzetoolfastlog.h"
+#include "atlog.h"
+
+// Local time function.
+TInt64 CurrentTime()
+    {
+    LOGSTR1( "ATFL CurrentTime()" );
+    TTime time;
+    time.UniversalTime();
+    return time.Int64() - KMicroSecondsAt1970;
+    }
+
+TInt ATFastLogProcessStarted( const TDesC8& aProcessName,
+                                 TUint aProcessId,
+                                 TUint32 aIsDebug )
+    {
+    LOGSTR1( "ATFL ATFastLogProcessStarted()" );
+    // Convert process name to 16-bit descriptor.
+    TBuf<KMaxProcessName> processName;
+    processName.Copy( aProcessName );
+    // Buffer to trace.
+    TBuf<KProcessStartBufLength> buffer;
+    // Format process name and id.
+    buffer.Format( KProcessStart16, &processName, aProcessId );
+    // Timestamp.
+    buffer.AppendNum( CurrentTime(), EHex ) ;
+    // Append udeb/urel information to the process start.
+    buffer.Append( KSpaceXti );  
+    buffer.AppendNum( aIsDebug, EHex );
+    // Append version number.
+    buffer.Append( KSpaceXti );  
+    buffer.AppendNum( KATTraceVersion, EHex );
+    // Log to XTI.
+    RDebug::Print( KXtiMessage, aProcessId ,&buffer );
+    return KErrNone;
+    }
+
+TInt ATFastLogProcessEnded( TUint aProcessId, 
+                            TUint aHandleLeakCount )
+    {
+    LOGSTR1( "ATFL ATFastLogProcessEnded()" );
+    // Handle leaks.
+    if ( aHandleLeakCount > 0 )
+        {
+        // Buffer to trace.
+        TBuf<KHandleLeakBufLength> buffer2;
+        buffer2.Format( KHandleLeak16, &KUnknownModule16, aHandleLeakCount );
+        // Trace it.
+        RDebug::Print( KXtiMessage, aProcessId, &buffer2 );
+        }
+    // Process end trace.
+    TBuf<KProcessEndBufLength> buffer;
+    buffer.Format( KProcessEnd16, aProcessId );
+    buffer.AppendNum( CurrentTime(), EHex);
+    buffer.Append( KNewLineXti );
+    RDebug::Print( KXtiMessage, aProcessId, &buffer );
+    return KErrNone;
+    }
+
+TInt ATFastLogDllLoaded( TUint aProcessId, 
+                                        const TDesC8& aDllName,
+                                        TUint32 aStartAddress,
+                                        TUint32 aEndAddress )
+    {
+    LOGSTR1( "ATFL ATFastLogDllLoaded()" );
+    // Timestamp.
+    TInt64 time = CurrentTime();
+    // Convert dll name to 16-bit descriptor.
+    TBuf<KMaxLibraryName> dll;
+    dll.Copy( aDllName );
+    // Buffer to trace.
+    TBuf<KDllLoadBufLength> buffer;
+    buffer.Format( KDllLoad16, &dll, time, aStartAddress, aEndAddress );
+    RDebug::Print( KXtiMessage, aProcessId, &buffer );
+    return KErrNone;
+    }
+
+TInt ATFastLogDllUnloaded( TUint aProcessId, const TDesC8& aDllName, TUint32 aStartAddress,
+                                       TUint32 aEndAddress )
+    {
+    LOGSTR1( "ATFL ATFastLogDllUnloaded()" );
+    // Timestamp.
+    TInt64 time = CurrentTime();
+    // Convert dll name to 16-bit descriptor.
+    TBuf<KMaxLibraryName> dll;
+    dll.Copy( aDllName );
+    // Buffer to trace.
+    TBuf<KDllLoadBufLength> buffer;
+    buffer.Format( KDllUnload16, &dll, time, aStartAddress, aEndAddress );
+    RDebug::Print( KXtiMessage, aProcessId, &buffer );   
+    return KErrNone;
+    }
+
+TInt ATFastLogMemoryAllocated( TUint aProcessId, TUint32 aMemAddress,
+                                  TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
+                                  TInt aSize )
+    {
+    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 );
+    
+    // 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( KSpaceXti );
+    ptr.AppendNum( time, EHex );
+    
+    // Append the size of the allocation in the 32-bit (max 8 characters) hexadecimal
+    // text format.
+    ptr.Append( KSpaceXti );
+    ptr.AppendNum( aSize, EHex );
+    
+    // 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 );
+    
+    // Append address count.
+    ptr.Append( KSpaceXti );
+    ptr.AppendNum( addrCount, EHex );
+            
+    // Calculate last item length
+    TInt lastItemLength( KXtiMessage().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 ( ptr.Length() <= 0 )
+            {               
+            // Create alloc fragment message header
+            ptr.Append( KMemoryAllocFragment );
+            ptr.AppendNum( aMemAddress, EHex );
+            ptr.Append( KSpaceXti );
+            ptr.AppendNum( time, EHex );
+            ptr.Append( KSpaceXti );        
+            ptr.AppendNum( packetNumber, EHex );
+            // Increase packet number
+            packetNumber++;
+            }
+      
+        // Append call stack address.
+        ptr.AppendFormat( KHexaNumberXti, aCallstack.At( addrPos ) );
+        
+        // Move the call stack position.
+        addrPos++;
+        
+        // Check if buffer max length exceed
+        if ( lastItemLength + ptr.Length() >= KMemAllocBufLength )
+            {
+            ptr.Append( KNewLineXti );
+            // Log through XTI channel 
+            RDebug::Print( KXtiMessage, aProcessId, &buffer );
+            // Empty XTI buffer
+            ptr.Delete( 0, ptr.MaxLength() );
+            }
+        }
+    // Send last message if exists.
+    if ( ptr.Length() > 0 )
+        {
+        ptr.Append( KNewLineXti );
+        RDebug::Print( KXtiMessage, aProcessId, &buffer);
+        }
+    return KErrNone;
+    }
+
+
+TInt ATFastLogMemoryFreed( TUint aProcessId, TUint32 aMemAddress, 
+                              TFixedArray<TUint32, KATMaxCallstackLength>& aFreeCallstack )
+    {
+    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 );
+    
+    // Append timestamp;
+    ptr.Append( KSpaceXti );
+    ptr.AppendNum( time, EHex);
+    
+    // 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 );
+    
+    // Append address count.
+    ptr.Append( KSpaceXti );
+    ptr.AppendNum( addrCount, EHex );
+            
+    // Calculate last item length
+    TInt lastItemLength( KXtiMessage().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 ( ptr.Length() <= 0 )
+            {               
+            // Create alloc fragment message header
+            ptr.Append( KMemoryFreedFragment );
+            ptr.AppendNum( aMemAddress, EHex );
+            ptr.Append( KSpaceXti );
+            ptr.AppendNum( packetNumber, EHex );
+            // Increase packet number
+            packetNumber++;
+            }
+      
+        // Append call stack address.
+        ptr.AppendFormat( KHexaNumberXti, aFreeCallstack.At( addrPos ) );
+        
+        // Move the call stack position.
+        addrPos++;
+        
+        // Check if buffer max length exceed
+        if ( lastItemLength + ptr.Length() >= KMemFreedBufLength )
+            {
+            ptr.Append( KNewLineXti );
+            // Log through XTI channel 
+            RDebug::Print( KXtiMessage, aProcessId, &buffer );
+            // Empty XTI buffer
+            ptr.Delete( 0, ptr.MaxLength() );
+            }
+        }
+    // Send last message if exists.
+    if ( ptr.Length() > 0 )
+        {
+        ptr.Append( KNewLineXti );
+        RDebug::Print( KXtiMessage, aProcessId, &buffer);
+        }
+    return KErrNone;   
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/src/analyzetoolmainallocator.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,1461 @@
+/*
+* 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 RAnalyzeToolMainAllocator.
+*
+*/
+
+
+#include "analyzetoolmainallocator.h"
+#include "atlog.h"
+#include "analyzetooleventhandler.h"
+#include "analyzetoolmemoryallocator.h"
+#include "analyzetoolpanics.pan"
+#include "analyzetoolfastlog.h"
+#ifdef __WINSCW__
+#include <coemain.h>
+#endif
+#include <e32svr.h>
+
+
+// CONSTANTS
+
+// 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;
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::RAnalyzeToolMainAllocator()
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+RAnalyzeToolMainAllocator::RAnalyzeToolMainAllocator( TBool aNotFirst, 
+    const TFileName aFileName, TUint32 aLogOption, TUint32 aIsDebug,
+    TUint32 aAllocCallStackSize, TUint32 aFreeCallStackSize ) :
+    RAnalyzeToolMemoryAllocator( aNotFirst ),
+    iAnalyzeToolOpen( EFalse ),
+    iDeviceDriverLoaded( EFalse ),
+    iCodeblocks( KATMaxCallstackLength ),
+    iThreadArray( KATMaxCallstackLength ),
+    iLogOption( aLogOption ),
+    iProcessId( RProcess().Id().operator TUint() ),
+    iAllocMaxCallStack( aAllocCallStackSize ),
+    iFreeMaxCallStack( aFreeCallStackSize )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::RAnalyzeToolMainAllocator()" );
+
+    // Basic error variable used in method.
+    TInt error( KErrNone );
+    
+    // Connect to the storage server if logging mode not fast xti.
+    if ( iLogOption != EATLogToXtiFast )
+        {
+        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();
+
+    __ASSERT_ALWAYS( KErrNone == error, AssertPanic( ECantCreateMutex ) );
+
+    LOGSTR2( "ATMH Creating mutex error %i", error );
+
+    // Load the kernel side device driver
+    error = User::LoadLogicalDevice( KAnalyzeToolLddName );
+
+    if ( error != KErrNone && error != KErrAlreadyExists )
+        {
+        __ASSERT_ALWAYS( EFalse, AssertPanic( ECantLoadDeviceDriver ) );
+        }
+    else
+        {
+        iDeviceDriverLoaded = ETrue;
+        }
+
+    LOGSTR2( "ATMH Loading device driver error %i", error );
+
+    // Open handle to the kernel sidedevice driver
+    error = iAnalyzeTool.Open();
+
+    __ASSERT_ALWAYS( KErrNone == error, AssertPanic( ECantConnectDeviceDriver ) );
+
+    if ( KErrNone == error )
+        {
+        iAnalyzeToolOpen = ETrue;
+        }
+
+    LOGSTR2( "ATMH Opening RAnalyzeTool handle %i error", error );
+
+    // Set memory model by asking kernel side device driver
+    if ( iAnalyzeToolOpen )
+        {
+        TATMemoryModelBuf model;
+        if ( KErrNone == iAnalyzeTool.GetMemoryModel( model ) )
+            {
+            iMemoryModel = model().iMemoryModel;
+            LOGSTR2( "ATMH AnalyzeTool MemoryModel: %i", iMemoryModel );
+            }
+        else
+            LOGSTR2( "ATMH AnalyzeTool GetMemoryModel error: %i", error );
+        }
+    
+    // Retrieve the initial process information
+    LogProcessInformation( aFileName, aLogOption, aIsDebug );
+
+    // Create handler for receiving kernel events
+    iEventHandler = new CLibraryEventHandler( iAnalyzeTool,
+                                              iCodeblocks,
+                                              iStorageServer,
+                                              iProcessId,
+                                              iMutex, 
+                                              *this,
+                                              aLogOption);
+
+    __ASSERT_ALWAYS( iEventHandler != NULL, AssertPanic( ENoMemory ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::~RAnalyzeToolMainAllocator()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+RAnalyzeToolMainAllocator::~RAnalyzeToolMainAllocator()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::~RAnalyzeToolMainAllocator()" );
+
+    TUint handleLeakCount( 0 );
+    if ( iAnalyzeToolOpen && iThreadArray.Count() > 0 )
+        {
+        TProcessHandleInfoBuf params;
+        params().iProcessId = iProcessId;
+        TInt error( iAnalyzeTool.GetProcessHandleInfo( params ) );
+        handleLeakCount = params().iThreadHandleCount;
+        }
+
+    // Close handle for process memory blocks
+    iCodeblocks.Close();
+
+    // Delete the eventhandler
+    delete iEventHandler;
+
+    // The count of device driver users
+    TClientCountBuf count;
+
+    // Check the flag
+    if ( iAnalyzeToolOpen )
+        {
+        TInt error  = iAnalyzeTool.ClientCount( count );
+        LOGSTR2( "ATMH closing analyze tool handle error: %i", error );
+        iAnalyzeTool.Close();
+        }
+
+    // Check the flag
+    if ( iDeviceDriverLoaded )
+        {
+        LOGSTR2( "ATMH device driver client count: %i", count().iClientCount );
+
+        // Check if there is another user for device driver
+        if ( count().iClientCount <= 1 )
+            {
+            // There was no other users -> unload the device driver
+            TInt error = User::FreeLogicalDevice( KAnalyzeToolLddName );
+            LOGSTR2( "ATMH Unloading ldd error: %i", error );
+            }
+        }
+    
+    // Close the thread array
+    iThreadArray.Close();
+
+    if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+        {
+        if ( iLogOption == EATLogToXtiFast )
+            {
+            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();
+            }
+        }
+
+    // Close handle for process handle leaks
+    
+    #ifdef __WINSCW__
+    // Restore system's exit check
+    if ( CCoeEnv::Static() )
+        CCoeEnv::Static()->DisableExitChecks( EFalse );
+    #endif
+    
+    // Close the mutex
+    iMutex.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::ShareHeap()
+// Share heap with other thread
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolMainAllocator::ShareHeap()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::ShareHeap()" );
+
+    // Call the overwrited Open function
+    Open();
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Uninstall()
+// Uninstalls the current allocator
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolMainAllocator::Uninstall()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Uninstall()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    TMainThreadParamsBuf params;
+    params().iProcessId = iProcessId;
+    iAnalyzeTool.MainThreadAlloctor( params );
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Check if this is shared allocator between threads
+    if ( iThreadArray.Count() > KThreadCount && !params().iAlone )
+        {
+        // Close the shared allocator
+        Close();
+        LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Uninstall() - Close called" );
+        return;
+        }
+
+#if ( SYMBIAN_VERSION_SUPPORT >= SYMBIAN_3 )
+    #ifndef __WINS__ 
+    // Remove dummy Tls handle
+    UserSvr::DllFreeTls( KDummyHandle );
+    #endif
+#endif
+    
+    // Since this is the last thread using this allocator it can be deleted
+    delete this;
+    }
+
+#ifdef __WINS__
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Alloc() WINS version
+// Allocates a cell of specified size from the heap.
+// -----------------------------------------------------------------------------
+//
+UEXPORT_C TAny* RAnalyzeToolMainAllocator::Alloc( TInt aSize )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // Alloc memory from the original allocator
+    TAny* p = iAllocator->Alloc( aSize );
+
+    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 xti.
+    if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+        {
+        TInt error( KErrNone );
+        
+        // Check if eventhandler is active already
+        if ( !iEventHandler->IsActive() )
+            {
+            // 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 );
+            
+            TUint32 _sp;
+            __asm
+                {
+                mov [_sp], esp
+                }
+            
+            // 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
+                        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 == EATLogToXtiFast )
+            {
+            // Using fast xti.
+            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 )
+                            {
+                            iStorageServerOpen = EFalse;
+                            LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc() - close iStorageServer"  );
+                            iStorageServer.Close();
+                            }
+                        break;
+                        }
+                    default:
+                        {
+                        LOGSTR2( "ATMH LogMemoryAllocated error %i", error );
+                        break;
+                        }
+                    }
+                }
+            }
+        }
+    // Release the mutex
+    iMutex.Signal();
+
+    return p;
+    }
+#else
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Alloc() ARMV5 version
+// Allocates a cell of specified size from the heap.
+// -----------------------------------------------------------------------------
+//
+TAny* RAnalyzeToolMainAllocator::Alloc( TInt aSize )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc()"  );
+
+    // acquire the mutex
+    iMutex.Wait();
+
+    // Alloc memory from the original allocator
+    TAny* p = iAllocator->Alloc( aSize );
+
+    LOGSTR3( "ATMH RAnalyzeToolMainAllocator::Alloc() - aSize: %i, address: %x", 
+            aSize,  (TUint32) p );
+
+    TInt error( KErrNone );
+    
+    if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+        {
+        // 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 );
+            
+            TInt blocksCount( iCodeblocks.Count() );
+            
+            TUint arrayCounter = 0;
+            
+            for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+                {
+                for ( TInt j = 0; j < blocksCount; j++ )
+                    {
+                    if ( iCodeblocks[j].CheckAddress( (TUint32) *( (TUint32*) i ) ) )
+                        {
+                        // To avoid recursive call to ReAlloc specifying granularity
+                        // Add address to the callstack
+                        iCallStack[arrayCounter] = ( (TUint32) *( (TUint32*) i ) );
+                        arrayCounter++;
+                        break;
+                        }
+                    }
+                if ( arrayCounter == KATMaxCallstackLength ||
+                     arrayCounter == iAllocMaxCallStack )
+                    {
+                    LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter );
+                    break;
+                    }
+                }
+            }
+        // Log the memory allocation information
+        if ( iLogOption == EATLogToXtiFast )
+            {
+            // Using fast xti.
+            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 )
+                            {
+                            iStorageServerOpen = EFalse;
+                            LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc() - close iStorageServer"  );
+                            iStorageServer.Close();
+                            }
+                        break;
+                        }
+                    default:
+                        {
+                        LOGSTR2( "ATMH LogMemoryAllocated error %i", error );
+                        break;
+                        }
+                    }
+                }
+            }
+        }
+    
+    // Release the mutex
+    iMutex.Signal();
+
+    // Return the allocatated memory
+    return p;
+    }
+#endif // __WINS__
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Free()
+// Frees the allocated memory
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolMainAllocator::Free( TAny* aPtr )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Free()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+        {
+        // Reset the callstack
+        iFreeCallStack.Reset();
+        
+        // Check if XTI logging mode
+        // Also if we don't want any call stack to be stored skip the next part
+        if ( (iLogOption == EATUseDefault || iLogOption == EATLogToXti || iLogOption == EATLogToXtiFast )
+                && 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 the memory free information.
+        if ( iLogOption == EATLogToXtiFast )
+            {
+            // Using fast xti.
+            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 );
+                }
+            }
+        }
+    
+    // Free the memory using original allocator
+    iAllocator->Free( aPtr );
+
+    LOGSTR2( "ATMH RAnalyzeToolMainAllocator::Free() - aPtr: %x", (TUint32)aPtr );
+
+    // Release the mutex
+    iMutex.Signal();
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Open()
+// Opens this heap for shared access. Opening the heap increases
+// the heap's access count by one.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolMainAllocator::Open()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Open() " );
+
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // Share the memory using original allocator
+    TInt error = iAllocator->Open();
+
+    // If everything is OK add thread to the array which use this allocator
+    if ( KErrNone == error )
+        {
+        TThreadParamsBuf params;
+        params().iThreadId = RThread().Id().operator TUint();
+        error = iAnalyzeTool.ThreadStack( params );
+
+        __ASSERT_ALWAYS( KErrNone == error, AssertPanic( ECantAppendToTheArray ) );
+
+        if ( KErrNone == error )
+            {
+            LOGSTR2( "ATMH Thread stack address: %x", params().iStackAddress );
+            LOGSTR2( "ATMH Thread stack size:    %x", params().iStackSize );
+            iThreadArray.Append( TThreadStack( RThread().Id(),
+                    params().iStackAddress + params().iStackSize ) );
+            }
+        }
+
+    // Release the mutex
+    iMutex.Signal();
+
+    // Return the error code
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Close()
+// Closes this shared heap. Closing the heap decreases the heap's
+// access count by one.
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolMainAllocator::Close()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Close()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // Close the memory using original allocator
+    iAllocator->Close();
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Close() - allocator closed" );
+    TInt count = iThreadArray.Count();
+
+    // Iterate through array of threads to remove current thread
+    for ( TInt i = 0; i < count; i++ )
+        {
+        // Check if this is current thread
+        if ( iThreadArray[ i ].Match() )
+            {
+            // Remove the thread
+            iThreadArray.Remove( i );
+            LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Close() - thread removed" );
+            break;
+            }
+        }
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Close() - about to mutex signal" );
+    // Release the mutex
+    iMutex.Signal();
+    }
+
+#ifdef __WINS__
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::ReAlloc()
+// Increases or decreases the size of an existing cell.
+// -----------------------------------------------------------------------------
+//
+TAny* RAnalyzeToolMainAllocator::ReAlloc( TAny* aPtr, TInt aSize, TInt aMode )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::ReAlloc()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // Realloc the memory using original allocator
+    TAny* ptr = iAllocator->ReAlloc( aPtr, aSize, aMode );
+    
+    // NULL addresses are not in a process under test
+    if ( ptr && !( aMode & ENeverMove ) )
+        {
+        LOGSTR3( "ATMH RAnalyzeToolMainAllocator::ReAlloc() - aPtr: %x, ptr: %x", 
+                (TUint32)aPtr, (TUint32)ptr );
+        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 xti.
+        if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+            {
+            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 );
+    
+                // Get current sp
+                TUint32 _sp( 0 );
+                __asm
+                    {
+                    mov [_sp], esp
+                    }
+                
+                // Get codeblocks count
+                TInt blocksCount( iCodeblocks.Count() );
+                
+                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();
+                
+                // Check that logging mode is xti/xti fast so we use free call stack 
+                // and call stack size bigger than zero
+                if ( ( iLogOption == EATUseDefault || iLogOption == EATLogToXti || iLogOption == EATLogToXtiFast ) && 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 == EATLogToXtiFast )
+                    {
+                    ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack );
+                    }
+                else
+                    {
+                    iStorageServer.LogMemoryFreed( (TUint32) aPtr, iFreeCallStack );
+                    }
+                }
+            // Log the memory allocation information
+            if ( iLogOption == EATLogToXtiFast )
+                {
+                // Using fast xti.
+                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 )
+                                {
+                                iStorageServerOpen = EFalse;
+                                LOGSTR1( "ATMH RAnalyzeToolMainAllocator::ReAlloc() - close iStorageServer"  );
+                                iStorageServer.Close();
+                                }
+                            break;
+                            }
+                        default:
+                            {
+                            LOGSTR2( "ATMH LogMemoryAllocated error %i", error );
+                            break;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    
+    // Release the mutex
+    iMutex.Signal();
+
+    // Return pointer to the reallocated cell
+    return ptr;
+    }
+
+#else
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::ReAlloc()
+// Increases or decreases the size of an existing cell.
+// -----------------------------------------------------------------------------
+//
+TAny* RAnalyzeToolMainAllocator::ReAlloc( TAny* aPtr, TInt aSize, TInt aMode )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::ReAlloc()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // 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
+    if ( ptr && !( aMode & ENeverMove ) )
+        {
+        LOGSTR3( "ATMH RAnalyzeToolMainAllocator::ReAlloc() - aPtr: %x, ptr: %x", 
+                (TUint32)aPtr, (TUint32)ptr );
+        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 xti.
+        if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+            {
+            // 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 codeblocks count
+                TInt blocksCount( iCodeblocks.Count() );
+                
+                for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348
+                    {
+                    for ( TInt j = 0; j < blocksCount; j++ )
+                        {
+                        if ( iCodeblocks[j].CheckAddress( (TUint32) *( (TUint32*) i ) ) )
+                            {
+                            // To avoid recursive call to ReAlloc specifying granularity
+                            // Add address to the callstack
+                            iReCallStack[arrayCounter] = ( (TUint32) *( (TUint32*) i ) );
+                            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();
+                
+                // Check that logging mode is xti/xti fast so we use free call stack 
+                // and call stack size bigger than zero
+                if ( (iLogOption == EATUseDefault || iLogOption == EATLogToXti || iLogOption == EATLogToXtiFast )
+                        && 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 == EATLogToXtiFast )
+                    {
+                    ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack );
+                    }
+                else
+                    {
+                    iStorageServer.LogMemoryFreed( (TUint32) aPtr, iFreeCallStack );
+                    }
+                }
+            
+            // Log the memory allocation information
+            if ( iLogOption == EATLogToXtiFast )
+                {
+                // Using fast xti.
+                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 )
+                                {
+                                iStorageServerOpen = EFalse;
+                                LOGSTR1( "ATMH RAnalyzeToolMainAllocator::ReAlloc() - close iStorageServer"  );
+                                iStorageServer.Close();
+                                }
+                            break;
+                            }
+                        default:
+                            {
+                            LOGSTR2( "ATMH LogMemoryAllocated error %i", error );
+                            break;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+    // Release the mutex
+    iMutex.Signal();
+
+    // Return pointer to the reallocated cell
+    return ptr;
+    }
+
+#endif // __WINS__
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Compress()
+// The function frees excess committed space from the top of the heap.
+// The size of the heap is never reduced below the minimum size
+// specified during creation of the heap.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolMainAllocator::Compress()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Compress()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // Compress the memory using original allocator
+    TInt compress = iAllocator->Compress();
+
+    // Release the mutex
+    iMutex.Signal();
+
+    // Return the space reclaimed
+    return compress;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Reset()
+// Frees all allocated cells on this heap.
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolMainAllocator::Reset()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Reset()" );
+
+    // Acquire the mutex
+    iMutex.Wait();
+
+    // Reset the memory using original allocator
+    iAllocator->Reset();
+
+    // Release the mutex
+    iMutex.Signal();
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::AllocSize()
+// Gets the number of cells allocated on this heap, and
+// the total space allocated to them.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolMainAllocator::AllocSize( TInt& aTotalAllocSize ) const
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::AllocSize()" );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Acquire the memory information using original allocator
+    TInt size = iAllocator->AllocSize( aTotalAllocSize );
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Return the number of cells allocated on this heap.
+    return size;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Available()
+// Gets the total free space currently available on the heap and the
+// space available in the largest free block. The space available
+// represents the total space which can be allocated. Note that
+// compressing the heap may reduce the total free space available
+// and the space available in the largest free block.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolMainAllocator::Available( TInt& aBiggestBlock ) const
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Available()" );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Acquire the memory information using original allocator
+    TInt available = iAllocator->Available( aBiggestBlock );
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Return the total free space currently available on the heap
+    return available;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::AllocLen()
+// Gets the length of the available space in the specified
+// allocated cell.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolMainAllocator::AllocLen( const TAny* aCell ) const
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::AllocLen()" );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Acquire the memory information using original allocator
+    TInt len = iAllocator->AllocLen( aCell );
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Return the length of the available space in the allocated cell.
+    return len;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::DebugFunction()
+// Invocates specified debug funtionality.
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolMainAllocator::DebugFunction( TInt aFunc, TAny* a1, TAny* a2 )
+    {
+    LOGSTR2( "ATMH RAnalyzeToolMainAllocator::DebugFunction() %i", aFunc );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Invocate debug funtion using original allocator
+    TInt debug = iAllocator->DebugFunction( aFunc, a1, a2 );
+    
+    switch( aFunc )
+        {  
+        case EMarkEnd:
+            {
+            // Disables the __UHEAP_MARKEND macro
+            LOGSTR1( "ATMH __UHEAP_MARKEND macro called" );
+            if ( debug > 0 )
+                {
+                LOGSTR2( "ATMH __UHEAP_MARKEND detects leaks: %d", debug );
+                // Because there is leaks the alloc panic will occur but
+                // lets return a zero to pretend that everything is OK
+                debug = 0;
+                }
+            }
+        break;
+        
+        default:
+            {
+            }
+        break;
+        }
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Return information of the debug function success
+    return debug;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::RemoveKilledThread()
+// Remove killed thread from threads array.
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolMainAllocator::RemoveKilledThread( const TUint aThreadId  )
+    {
+    LOGSTR2( "ATMH RAnalyzeToolMainAllocator::RemoveKilledThread(%i)", 
+            aThreadId );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Iterate through array of threads to remove current thread
+    TInt count( iThreadArray.Count() );
+    LOGSTR2( "ATMH > iThreadArray.Count() %i", count );
+    
+    for ( TInt i = 0; i < count; i++ )
+        {
+        // Check if this is current thread
+        if ( iThreadArray[ i ].Match( aThreadId ) )
+            {
+            // Remove the thread
+            iThreadArray.Remove( i );
+            LOGSTR1( "ATMH > thread removed" );
+            break;
+            }
+        }
+
+    // Release the mutex
+    iMutex.Signal();
+    }
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::Extension_()
+// Extension function
+// -----------------------------------------------------------------------------
+//
+TInt RAnalyzeToolMainAllocator::Extension_( TUint aExtensionId, TAny*& a0,
+    TAny* a1)
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Extension_()" );
+    
+    // Acquire the mutex
+    iMutex.Wait();
+    
+    // Invocate extension funtion using original allocator
+    TInt ext = RAllocator::Extension_( aExtensionId, a0, a1 );
+    
+    // Release the mutex
+    iMutex.Signal();
+    
+    // Return information of the extension function success
+    return ext;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::LogProcessInformation()
+// Retrieve and log the process initial information
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolMainAllocator::LogProcessInformation( const TFileName aFileName,
+    TUint32 aLogOption, TUint32 aIsDebug )
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation()" );
+    
+    // Create local variable and retrieve the process information
+    TProcessIdentityParamsBuf params;
+    params().iProcessId = iProcessId;
+    params().iThreadId = RThread().Id().operator TUint();
+    TInt error = iAnalyzeTool.GetProcessInfo( params );
+    
+    LOGSTR2( "ATMH GetProcessInfo %i error", error );
+    
+    if ( KErrNone == error )
+        {
+        LOGSTR2( "ATMH Process %i", iProcessId );
+
+        // Store stack start address
+        LOGSTR2( "ATMH Thread stack address: %x", params().iStackAddress );
+        LOGSTR2( "ATMH Thread stack size:    %x", params().iStackSize );
+
+        // 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 == EATLogToXtiFast )
+            {
+            if ( iLogOption == EATLogToXtiFast )
+                {
+                // Using fast xti.
+                LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation() - ATFastLogProcessStarted() #1" );
+                ATFastLogProcessStarted( params().iProcessName, iProcessId, aIsDebug );                
+                }
+            else
+                {
+                // Using storage server.
+                LOGSTR1( "ATMH RAnalyzeToolMainAllocator::LogProcessInformation() - iStorageServerOpen #1" );
+                error = iStorageServer.LogProcessStarted(
+                        aFileName,
+                        params().iProcessName,
+                        iProcessId, 
+                        aLogOption, 
+                        aIsDebug );
+                }
+            }
+
+        LOGSTR2( "ATMH LogProcessStarted error %i", error );
+
+        // Iterate through process codesegments
+        for( TInt i = 0; i < params().iCodesegCount; i++ )
+            {
+            // Create local variable and retrieve codesegment info
+            TCodesegInfoBuf codeinfo;
+            codeinfo().iProcessId = iProcessId;
+            codeinfo().iIndex = i;
+            error = iAnalyzeTool.GetCodesegInfo( codeinfo );
+
+            LOGSTR2( "ATMH GetCodesegInfo error %i", error );
+            if ( KErrNone == error )
+                {
+                // Don't log AnalyzeTool libraries
+                if ( 0 != codeinfo().iFullName.CompareC( KMemoryHook ) &&
+                     0 != codeinfo().iFullName.CompareC( KStorageServer ) )
+                    {
+                    // Log the loaded codesegment(s)
+                    if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+                        {
+                        if ( iLogOption == EATLogToXtiFast )
+                            {
+                            // Using fast xti.
+                            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 );
+                            }
+                        }
+
+                    LOGSTR2( "ATMH LogDllLoaded error %i", error );
+
+                    // Check that everything is OK
+                    if ( KErrNone == error )
+                        {
+                        // Append the codesegment to the array
+                        error = iCodeblocks.Append(
+                                        TCodeblock( codeinfo().iRunAddress,
+                                        codeinfo().iSize,
+                                        codeinfo().iFullName ) );
+                        LOGSTR2( "ATMH Append error %i", error );
+                        }
+                    }
+                }
+            }
+
+        // Iterate through process dynamic codesegments
+        for ( TInt i = 0; i < params().iDynamicCount; i++ )
+            {
+            // Create local variable and retrieve codesegment info
+            TLibraryInfoBuf info;
+            info().iProcessId = iProcessId;
+            info().iIndex = i;
+            error = iAnalyzeTool.GetLibraryInfo( info );
+            LOGSTR2( "ATMH GetLibraryInfo error %i", error );
+            if ( KErrNone == error )
+                {
+                // Log the loaded dynamic codesegment(s)
+                if ( iStorageServerOpen || iLogOption == EATLogToXtiFast )
+                    {
+                    if ( iLogOption == EATLogToXtiFast )
+                        {
+                        // Using fast xti.
+                        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 );
+                        }
+                    }
+
+
+                LOGSTR2( "ATMH LogDllLoaded error %i", error );
+
+                if ( KErrNone == error )
+                    {
+                    // Append the codesegment to the array
+                    error = iCodeblocks.Append(
+                            TCodeblock( info().iRunAddress, 
+                                        info().iSize, info().iLibraryName ) );
+                    LOGSTR2( "ATMH Append error %i", error );
+                    }
+                }
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::FindCurrentThreadStack()
+// Find the current thread which is using the heap
+// -----------------------------------------------------------------------------
+//
+TBool RAnalyzeToolMainAllocator::FindCurrentThreadStack( TUint32& aStackStart )
+    {
+    LOGSTR2( "ATMH RAnalyzeToolMainAllocator::FindCurrentThreadStack(), count( %i )",
+            iThreadArray.Count() );
+    
+    // Flag for indicating that right thread has been found
+    TBool found( EFalse );
+    // If threre is only one thread it must be the right thread
+    if ( iThreadArray.Count() == KThreadCount )
+        {
+        if ( !iThreadArray[ 0 ].ThreadStackStart( aStackStart ) )
+            {
+            // This MUST BE the right thread
+            //__ASSERT_ALWAYS( EFalse, AssertPanic( ECantFindRightThread ) );
+            }
+        else if ( iThreadArray[ 0 ].ThreadStackStart( aStackStart ) )
+            {
+            found = ETrue;
+            }
+        }
+    else
+        {
+        // Iterate through array to find right thread
+        TInt count = iThreadArray.Count();
+
+        for ( TInt i = 0; i < count; i++ )
+            {
+            // Check if this is the right thread
+            if ( iThreadArray[ i ].ThreadStackStart( aStackStart ) )
+                {
+                // Right thread found. Mark the flag
+                found = ETrue;
+                break;
+                }
+            }
+        // If right thread was not found the panic must be raised
+        if ( !found )
+            {
+            //__ASSERT_ALWAYS( EFalse, AssertPanic( ECantFindRightThread ) );
+            }
+        }
+    return found;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMainAllocator::InstallEventHandler()
+// Installs the eventhandler, if possible
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolMainAllocator::InstallEventHandler()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMainAllocator::InstallEventHandler()" );
+    
+    // Active eventhalder is not active, trying to start it
+    if ( NULL != CActiveScheduler::Current() )
+        {
+        iEventHandler->Start();
+        }
+    
+    #ifdef __WINSCW__
+    // Disable system's exit checks
+    if ( CCoeEnv::Static() )
+        {
+        CCoeEnv::Static()->DisableExitChecks( ETrue );
+        }
+    #endif
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/src/analyzetoolmemoryallocator.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,71 @@
+/*
+* 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 RAnalyzeToolMemoryAllocator.
+*
+*/
+
+
+#include "analyzetoolmemoryallocator.h"
+#include "analyzetoolpanics.pan"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMemoryAllocator::RAnalyzeToolMemoryAllocator()
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+RAnalyzeToolMemoryAllocator::RAnalyzeToolMemoryAllocator( TBool aNotFirst ) :
+    RAllocator(),
+    iNotFirst( aNotFirst )/*,
+    iStorageServerOpen( EFalse )*/
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMemoryAllocator::RAnalyzeToolMemoryAllocator()" );
+    
+    // Acquire the original allocator
+    iAllocator = &User::Allocator(); 
+    
+    // Set memory model zero
+    iMemoryModel = 0;
+    }
+
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMemoryAllocator::~RAnalyzeToolMemoryAllocator()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+RAnalyzeToolMemoryAllocator::~RAnalyzeToolMemoryAllocator()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMemoryAllocator::~RAnalyzeToolMemoryAllocator()" );
+    
+    // Call switching orinigal allocator back.
+    // Just in case, if uninstall was not called.
+    SwitchOriginalAllocator();
+    }
+    
+// -----------------------------------------------------------------------------
+// RAnalyzeToolMemoryAllocator::SwitchOriginalAllocator()
+// Switches original allocator in use if not already.
+// -----------------------------------------------------------------------------
+//
+void RAnalyzeToolMemoryAllocator::SwitchOriginalAllocator()
+    {
+    LOGSTR1( "ATMH RAnalyzeToolMemoryAllocator::SwitchOriginalAllocator()" );
+    
+    if ( iAllocator != &User::Allocator() )
+        {
+        User::SwitchAllocator( iAllocator );
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/src/codeblock.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,92 @@
+/*
+* 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 TCodeblock.
+*
+*/
+
+
+#include "codeblock.h"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// TCodeblock::TCodeblock
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+TCodeblock::TCodeblock( TLinAddr aRunAddress, 
+                        TUint32 aSize, 
+                        TBuf8<KMaxLibraryName>& aName ) :
+                        iStartAddress( aRunAddress ),
+                        iEndAddress( aRunAddress + aSize )
+    {
+    LOGSTR3( "ATMH TCodeblock::TCodeblock() %x - %x", iStartAddress, iEndAddress );
+    iName.Copy( aName );
+    }
+
+// -----------------------------------------------------------------------------
+// TCodeblock::CheckAddress
+// Checks if the given address is in this memory block area
+// -----------------------------------------------------------------------------
+//
+TBool TCodeblock::CheckAddress( TUint32 aAddress )
+    {
+    if ( iStartAddress <= aAddress && aAddress <= iEndAddress )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// TCodeblock::Match
+// Matches if the given parameters represents this memory block 
+// -----------------------------------------------------------------------------
+//
+TBool TCodeblock::Match( TBuf8<KMaxLibraryName>& aName )
+    {
+    LOGSTR1( "ATMH TCodeblock::Match()" );
+    return ( 0 == iName.CompareF( aName ) ) ? ETrue : EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// TCodeblock::EndAddress
+// Returns specific segment's end address
+// -----------------------------------------------------------------------------
+//
+TUint32 TCodeblock::EndAddress()
+    {
+    return iEndAddress;
+    }
+
+// -----------------------------------------------------------------------------
+// TCodeblock::StartAddress
+// Returns specific segment's start address
+// -----------------------------------------------------------------------------
+//
+TUint32 TCodeblock::StartAddress()
+    {
+    return iStartAddress;
+    }
+
+// -----------------------------------------------------------------------------
+// TCodeblock::Name
+// Gets specific segment's name
+// -----------------------------------------------------------------------------
+//
+void TCodeblock::Name( TDes8& aName )
+    {
+    aName.Copy( iName );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/src/customuser.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,490 @@
+/*
+* 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 CustomUser.
+*
+*/
+
+#include <f32file.h>
+#include <utf.h>
+#include "customuser.h"
+#include "analyzetoolmainallocator.h"
+#include "analyzetoolallocator.h"
+#include "atlog.h"
+#include "analyzetoolmemoryallocator.h"
+#include "analyzetoolpanics.pan"
+#include "atstorageservercommon.h"
+#include "atdriveinfo.h"
+
+// CONSTANTS
+// When needed, update the version number directly inside _LIT macro.
+// Constant for the atool API(staticlib) version.
+_LIT( KAtoolApiVersion, "1.7.4" );
+
+// Version number buffer length
+const TInt KAtoolVersionNumberLength = 10;
+
+// Wrong version error code
+const TInt KAtoolVersionError = -1999;
+
+// Version number separator
+_LIT( KVersionSeparator, ";" );
+
+// Incorrect version error strings 
+_LIT8( KDataFileVersion, "DATA_FILE_VERSION 10\r\n" );
+_LIT( KIncorrectText, "ERROR_OCCURED INCORRECT_ATOOL_VERSION [API v.%S][ATOOL v.%S]" );
+_LIT( KIncorrectTextXti, "PCSS " );
+
+// -----------------------------------------------------------------------------
+// CustomUser::Panic()
+// Overloaded User::Panic() function
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CustomUser::Panic( const TDesC& aCategory, TInt aReason )
+    {
+    LOGSTR3( "ATMH CustomUser::Panic() %S %i", &aCategory, aReason );
+    
+    // Uninstall thread's RAllocator
+    ( (RAnalyzeToolMemoryAllocator&) User::Allocator() ).Uninstall();
+       
+    // Call the "real" User::Panic()
+    User::Panic( aCategory, aReason );
+    }
+
+// -----------------------------------------------------------------------------
+// CustomUser::Exit()
+// Overloaded User::Exit() function
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CustomUser::Exit( TInt aReason )
+    {
+    LOGSTR3( "ATMH CustomUser::Exit() %i %i", aReason, RThread().Id().Id() );
+    
+    if ( aReason != KAtoolVersionError )
+    	{
+    	// Uninstall thread's RAllocator
+    	( (RAnalyzeToolMemoryAllocator&) User::Allocator() ).Uninstall();
+    	LOGSTR1( "ATMH CustomUser::Exit() - about to User::Exit" );
+    	}
+    
+    // Call the "real" User::Exit()
+    User::Exit( aReason );
+    }
+
+// -----------------------------------------------------------------------------
+// CustomUser::SetCritical()
+// Overloaded User::SetCritical() function which returns
+// KErrNone, if successful; KErrArgument, if EAllThreadsCritical is 
+// passed - this is a state associated with a process, and you use 
+// User::SetProcessCritical() to set it.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CustomUser::SetCritical( User::TCritical aCritical )
+    {
+    LOGSTR1( "ATMH CustomUser::SetCritical()" );
+    // Check the given User::TCritical type
+    if ( aCritical == User::EAllThreadsCritical )
+        {
+        return KErrArgument;
+        }
+    else
+        {
+        return KErrNone;
+        }
+    }
+  
+// -----------------------------------------------------------------------------
+// CustomUser::SetProcessCritical()
+// Overloaded User::SetProcessCritical() function
+// 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.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CustomUser::SetProcessCritical( User::TCritical aCritical )
+    {
+    LOGSTR1( "ATMH CustomUser::SetProcessCritical()" );
+     // Check the given User::TCritical type 
+    if ( aCritical == User::EProcessCritical || 
+         User::EProcessPermanent == aCritical )
+        {
+        return KErrArgument;
+        }
+    else
+        {
+        return KErrNone;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CustomUser::SetupThreadHeap()
+// Overloaded UserHeap::SetupThreadHeap function
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CustomUser::SetupThreadHeap( TBool aNotFirst, 
+    SStdEpocThreadCreateInfo& aInfo, const TFileName aFileName,
+    TUint32 aLogOption, TUint32 aIsDebug, const TFileName aVersion,
+    TUint32 aAllocCallStackSize, TUint32 aFreeCallStackSize )
+    {
+    LOGSTR1( "ATMH CustomUser::SetupThreadHeap()" );
+    LOGSTR2( "ATMH > Thread id(%d)", RThread().Id().operator TUint() );
+    
+    TInt ret( KErrNone );    
+    // Check version number
+    TBuf<KAtoolVersionNumberLength> atoolVer;
+    if ( CheckVersion( aVersion, atoolVer ) != KErrNone )
+    	{
+    	LOGSTR1( "ATMH > Wrong API version > Inform user and Exit." );
+    	ReportIncorrectVersion( aLogOption, aFileName, atoolVer );
+    	return KAtoolVersionError;
+    	}
+    
+    // Check is this shared heap
+    if ( aInfo.iAllocator == NULL )
+        {
+        LOGSTR1( "ATMH creating a new heap" );
+        // RAllocator is NULL so heap is not shared, creating a new heap
+        ret = UserHeap::SetupThreadHeap( aNotFirst, aInfo );
+        __ASSERT_ALWAYS( KErrNone == ret, AssertPanic( EFailedToCreateHeap ) );
+        
+#if ( SYMBIAN_VERSION_SUPPORT >= SYMBIAN_3 )
+    #ifndef __WINS__
+        // Set dummy Tls value
+        TAny* dummyPtr( NULL );
+        TInt setErr( UserSvr::DllSetTls( KDummyHandle, dummyPtr ) );
+        LOGSTR2( "ATMH > Set Tls err(%i)", setErr );
+    #endif
+#endif
+        // Install the RAllocator
+        aInfo.iAllocator = &InstallAllocator( aNotFirst, aFileName, aLogOption, aIsDebug,
+                aAllocCallStackSize, aFreeCallStackSize );
+        }
+    else
+        {
+        LOGSTR1( "ATMH sharing the heap" );
+        // The heap is shared. Acquire pointer to the original heap
+        RAnalyzeToolMemoryAllocator* allocator = 
+			(RAnalyzeToolMemoryAllocator*) aInfo.iAllocator;
+        // Share the heap
+        allocator->ShareHeap();
+        // Switch thread heap 
+        User::SwitchAllocator( allocator );
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CustomUser::InstallAllocator
+// Installs the RAllocator
+// -----------------------------------------------------------------------------
+//
+//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 )
+    {
+    LOGSTR1( "ATMH CustomUser::InstallAllocator()" );
+    
+    // Open handle to the device driver
+    RAnalyzeTool analyzetool;
+    TInt error = analyzetool.Open();
+    
+    // Check if the device driver has already loaded
+    if ( KErrNone == error )
+        {
+        LOGSTR1( "ATMH CustomUser::InstallAllocator() - analyzetool.Open() returned KErrNone" );
+        // The device driver has already loaded
+        // Get pointer to the main thread allocator
+        TMainThreadParamsBuf params;
+        params().iProcessId = RProcess().Id().operator TUint();
+        error = analyzetool.MainThreadAlloctor( params );
+
+        __ASSERT_ALWAYS( KErrNone == error, AssertPanic( ECantOpenHandle ) );
+        
+        // Close handle to the device driver
+        analyzetool.Close();
+        
+        // Is this the first thread of the program
+        if ( params().iAlone )
+            {
+            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 );
+            
+            __ASSERT_ALWAYS( allocator != NULL, AssertPanic( ENoMemory ) );
+            
+            // Change threads allocator
+            User::SwitchAllocator( allocator );
+            
+            // Return reference to the RAllocator
+            return *allocator;
+            }
+        // This is not the first thread. A new thread with a new heap created
+        else
+            {
+            LOGSTR1( "ATMH CustomUser::InstallAllocator() - create a new allocator for the new thread" );
+            // 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() );
+
+            __ASSERT_ALWAYS( allocator != NULL, AssertPanic( ENoMemory ) );
+            
+            // Change threads allocator
+            User::SwitchAllocator( allocator );
+            
+            // Return reference to the RAllocator
+            return *allocator;
+            }
+        }
+    // The device driver does not exists so this must be the first thread
+    else
+        {
+        LOGSTR1( "ATMH CustomUser::InstallAllocator() - analyzetool.Open() returned error, creating DD" );
+        RAnalyzeToolMainAllocator* allocator = 
+			new RAnalyzeToolMainAllocator( aNotFirst, aFileName, aLogOption, aIsDebug,
+			        aAllocCallStackSize, aFreeCallStackSize );
+        
+        __ASSERT_ALWAYS( allocator != NULL, AssertPanic( ENoMemory ) );
+        
+        // Change threads allocator
+        User::SwitchAllocator( allocator );
+
+        // Return reference to the RAllocator
+        return *allocator;
+        }
+    } 
+    
+// -----------------------------------------------------------------------------
+// AnalyzeToolInterface::StartSubTest
+// Function for starting a subtest with a given name
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void AnalyzeToolInterface::StartSubTest( const TDesC8& aSubtestId )
+    {
+    LOGSTR1( "ATMH AnalyzeToolInterface::StartSubTest()" );
+    // Open handle to the device driver
+    RAnalyzeTool analyzetool;
+    TInt error = analyzetool.Open();
+    if ( KErrNone == error )
+        {
+        LOGSTR1( "ATMH AnalyzeToolInterface::StartSubTest() - DD opened" );
+        // The device driver has already loaded
+        // Get pointer to the main thread allocator
+        TMainThreadParamsBuf params;
+        params().iProcessId = RProcess().Id().operator TUint();
+        error = analyzetool.MainThreadAlloctor( params );
+
+        __ASSERT_ALWAYS( KErrNone == error, AssertPanic( ECantOpenHandle ) );
+        
+        // Close handle to the device driver
+        analyzetool.Close();
+
+        if ( ( ( RAnalyzeToolMainAllocator* )params().iAllocator )->StorageServerOpen() )
+            {
+                LOGSTR1( "ATMH AnalyzeToolInterface::StartSubTest() - SS open -> try to start subtest" );
+            // Start subtest
+            ( ( RAnalyzeToolMainAllocator* )params().iAllocator )->
+                        StorageServer().StartSubTest( aSubtestId );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// AnalyzeToolInterface::StopSubTest
+// Function for stopping a subtest with a given name
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void AnalyzeToolInterface::StopSubTest( const TDesC8& aSubtestId )
+    {
+    LOGSTR1( "ATMH AnalyzeToolInterface::StopSubTest()" );
+    // Open handle to the device driver
+    RAnalyzeTool analyzetool;
+    TInt error = analyzetool.Open();
+    if ( KErrNone == error )
+        {
+        LOGSTR1( "ATMH AnalyzeToolInterface::StopSubTest() - DD opened" );
+        // The device driver has already loaded
+        // Get pointer to the main thread allocator
+        TMainThreadParamsBuf params;
+        params().iProcessId = RProcess().Id().operator TUint();
+        error = analyzetool.MainThreadAlloctor( params );
+
+        __ASSERT_ALWAYS( KErrNone == error, AssertPanic( ECantOpenHandle ) );
+        
+        // Close handle to the device driver
+        analyzetool.Close();
+
+        if ( ( ( RAnalyzeToolMainAllocator* )params().iAllocator )->StorageServerOpen() )
+            {
+                LOGSTR1( "ATMH AnalyzeToolInterface::StopSubTest() - SS open -> try to stop subtest" );
+            // Start subtest
+            ( ( RAnalyzeToolMainAllocator* )params().iAllocator )->
+                        StorageServer().StopSubTest( aSubtestId );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CustomUser::__DbgMarkEnd
+// Marks the end of heap cell checking at the current nested level 
+// for the current thread's default heap, or the kernel heap.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TUint32 CustomUser::__DbgMarkEnd( TBool /*aKernel*/, TInt /*aCount*/ )
+    {
+    LOGSTR1( "ATMH CustomUser::__DbgMarkEnd()");
+    // Return just zero to override system's memory leak check
+    return 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CustomUser::CheckVersion
+// Check atool version
+// -----------------------------------------------------------------------------
+//
+TInt CustomUser::CheckVersion( const TFileName aVersion, TDes& aToolVersion )
+    { 
+    LOGSTR2( "ATMH CustomUser::CheckVersion(), aVersion( %S )", &aVersion );
+    
+    TFileName version;
+    version.Copy( aVersion );
+    TBuf<KAtoolVersionNumberLength> apiVer;
+    	
+    // Find separator place
+    TInt findplace( version.Find( KVersionSeparator() ) );
+    // Parse API version first [x.x.x;x.x.x]
+    if ( findplace >= 0 && findplace <= apiVer.MaxLength() )
+		{
+		apiVer.Copy( version.Mid( 0, findplace ) ); 
+		version.Delete( 0, findplace + KVersionSeparator().Length() );
+		}
+ 
+    if ( version.Length() <= aToolVersion.MaxLength() )
+    	{
+    	aToolVersion.Copy( version );
+    	if ( aToolVersion.Compare( KAtoolApiVersion ) == KErrNone &&
+    		 apiVer.Length() == 0 )
+    		{
+    		// Support 1.5.0 version (Version info: [1.5.0])
+    		apiVer.Copy( version );
+    		}
+    	}
+    
+    LOGSTR3( "ATMH > API version( %S ), ATOOL version( %S )", 
+    		&apiVer, &aToolVersion );
+        
+    // Check version numbers 
+    if ( apiVer.Compare( KAtoolApiVersion ) == KErrNone )
+    	{
+    	return KErrNone;
+    	}
+    return KErrCancel;    
+    }
+
+// -----------------------------------------------------------------------------
+// CustomUser::ReportIncorrectVersion
+// Function for showing incorrect version information
+// -----------------------------------------------------------------------------
+//
+void CustomUser::ReportIncorrectVersion( const TUint32 aLogOption,
+	const TFileName aFileName, const TDes& aToolVersion )
+	{
+	LOGSTR2( "ATMH CustomUser::ReportIncorrectVersion(), aFileName( %S )", 
+			&aFileName );
+	
+	switch ( aLogOption )
+		{
+		case EATLogToFile:
+			{
+			LOGSTR1( "ATMH ReportIncorrectVersion > EATLogToFile" );			
+			
+			// A handle to a file server session.
+			RFs fs;
+			// Creates and opens a file, 
+			// and performs all operations on a single open file.
+			RFile file;	
+			// Create full path buffer
+			TBuf<KMaxFileName> logFileBuf;
+			// Connects a client to the file server.
+			TInt err( fs.Connect() );
+			
+			if ( !err )
+				{				
+                err = TATDriveInfo::CreatePath( logFileBuf, aFileName, fs );
+			    
+				// Replace file if exists
+				if ( err && err != KErrAlreadyExists )
+					{
+					LOGSTR2( "ATMH > TATDriveInfo::CreatePath() err( %i )", err );
+					return;
+					}
+				
+				// Replace file if exists (drive C)
+				err = file.Replace( fs, logFileBuf, EFileWrite );
+										
+				// Write to file
+				if ( !err )
+					{
+					err = file.Write( KDataFileVersion );
+					// Error msg buffer
+					TBuf8<KMaxFileName> msg;				     
+					// Write the error code to the buffer  
+					logFileBuf.Format( KIncorrectText, &KAtoolApiVersion, &aToolVersion );	
+					CnvUtfConverter::ConvertFromUnicodeToUtf8( msg, logFileBuf );
+					err = file.Write( msg );
+					}
+				// Closes the file.
+				file.Close();
+				}
+			
+			LOGSTR2( "ATMH > File err( %i )", err );			
+			// Closes the handle.
+			fs.Close();
+			}
+			break;
+			
+		case EATUseDefault:
+		case EATLogToXti:
+			{
+			LOGSTR1( "ATMH > ReportIncorrectVersion > EATLogToXti" );
+			// Error msg buffer
+			TBuf<KMaxFileName> msg;	
+			msg.Copy( KIncorrectTextXti );
+			msg.Append( KIncorrectText );
+			TBuf<KMaxFileName> xtiMsg;	
+			// Write the error code to the buffer  
+			xtiMsg.Format( msg, &KAtoolApiVersion, &aToolVersion );
+			RDebug::Print( xtiMsg );
+			}
+			break;
+		
+		default:
+			{
+			LOGSTR1( "ATMH > ReportIncorrectVersion > default" );
+			}
+			break;
+		}	
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/dynamicmemoryhook/src/threadstack.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,76 @@
+/*
+* 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 TThreadStack.
+*
+*/
+
+
+#include "threadstack.h"
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// TThreadStack::TThreadStack()
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+TThreadStack::TThreadStack( TThreadId aId, TUint32 aStackStart ) :
+    iId( aId ),
+    iStackStart( aStackStart )
+    {
+    LOGSTR2( "ATMH TThreadStack::TThreadStack() aStackStart: %i", aStackStart );
+    }
+
+// -----------------------------------------------------------------------------
+// TThreadStack::ThreadStackStart()
+// Checks if this is the current thread and if this is the current
+// thread assings value to the given parameter
+// -----------------------------------------------------------------------------
+//
+TBool TThreadStack::ThreadStackStart( TUint32& aStackStart )
+    {
+    LOGSTR1( "ATMH TThreadStack::ThreadStackStart");
+    
+    if ( RThread().Id() == iId )
+        {
+        aStackStart = iStackStart;
+        return ETrue;
+        }
+    else
+        {
+        aStackStart = 0;
+        return EFalse;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TThreadStack::Match()
+// Checks if this is the the current thread.
+// -----------------------------------------------------------------------------
+//
+TBool TThreadStack::Match( const TUint aThreadId )
+    {
+    LOGSTR2( "ATMH TThreadStack::Match( %d )", aThreadId );
+    
+    if ( aThreadId != 0 )
+    	{
+    	LOGSTR2( "ATMH > iId.operator TUint() = %d", iId.operator TUint() );
+    	return ( aThreadId == iId.operator TUint() ) ? ETrue : EFalse;
+    	}
+    else
+    	{
+    	return ( RThread().Id() == iId ) ? ETrue : EFalse;
+    	}
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/group/ReleaseNotes_AnalyzeTool.txt	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,328 @@
+===============================================================================
+
+RELEASE NOTES - AnalyzeTool v1.8.0
+RELEASED 1st December 2009
+
+===============================================================================
+
+Product Description:
+====================
+
+AnalyzeTool is a test software tool that is used for testing Symbian software
+for memory leaks and pinpointing the leaking problems from the source code.
+
+
+Main Features:
+==============
+- Pinpoints memoryleaks from target hardware and emulator to source code lines
+- Discovers resource leaks from process
+- Command line interface and Carbide.c++ Extension
+
+===============================================================================
+
+What's New in 1.8.0
+===================
+
+-New:[AT-45] - Memory usage shown as graph.
+
+===============================================================================
+
+Installation Notes:
+===================
+PDK Tools Overlay installer should be used to install AnalyzeTool to the used
+environment. After that AnalyzeTool should be build to all used platforms and
+both build types (udeb/urel) in that environment.
+ 
+AnalyzeTool is found from sf\pdt\dynaanactrlandcptr\memana\analyzetoolclient
+folder. Building should be done in group folder.
+
+Note: Before building check symbian_version.hrh file that it defines correct
+version for your environment.
+
+===============================================================================
+
+System Requirements:
+====================
+- Windows XP
+- Trace connection for real time data gathering to PC
+
+Additional Requirements:
+- Carbide.c++ v2.x
+
+===============================================================================
+
+Compatibility Issues:
+=====================
+- Not compatible with versions older than 1.5.0 of AnalyzeTool
+- Kernel code analysis not supported
+
+===============================================================================
+
+Known Issues:
+=============
+- 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 in the data file. Solution is to 
+use external / monitored external data gathering mode. No fix is planned yeat. 
+
+- 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. No fix is planned yeat. 
+
+- AnalyzeTool hooked QT applications becomes too slow to run. Improved in release 1.7.4 where you 
+can use small size call stack(s) and new logging mode (external -e). 
+
+- Stif test case with AnalyzeTool can inform wrong memory leak alert. No fix is planned yeat. 
+
+- AnalyzeTool overwrites functions TInt User::ProcessCritical(TCritical aCritical) and TInt 
+User::SetProcessCritical(TCritical aCritical), but this works only when the function is called from 
+hooked exe application. So if setting critical is done from DLL (even if it's hooked with 
+AnalyzeTool) the overwriting does not work and the process stays set critical during the testing. No 
+fix is planned yeat. 
+
+- If hooked application is closed by calling User::Exit() from DLL instead of .exe application 
+AnalyzeTool reports "abnormal process end" and can't report proper memory leaks. No fix is planned 
+yeat. 
+
+===============================================================================
+Version History:
+================
+
+Version in 1.7.4 - 4th November 2009
+---------------------------------
+-New: [AT-560] - Third data gathering mode which is simple and fast.
+-New: [AT-592] - Support for specifying call stack size(s).
+-New: [AT-627] - Button to open preferences.
+-New: [AT-551] - New error dialogs in Carbide extension.
+-New: [AT-583] - Extension version number shown in AnalyzeTool view.
+-Fix: [AT-568] - Inform user in build phase that kernel mode is not supported/hooked.
+-Fix: [AT-623] - Version conflict not shown to user.
+-Fix: [AT-632] - Selecting leak from sub test does not give call stack info.
+-Fix: [AT-630] - Console UI leaks memory.
+
+Version in 1.7.3 - 1st October 2009
+---------------------------------
+-New: [AT-570] - Support reading debug data from ROFS files.
+-New: [AT-495] - Timestamps in DLL load/unload messages.
+-New: [AT-540] - Support for DLL timestamps in CLI.
+-New: [AT-544] - Use all found emulator binaries in analyze.
+-New: [AT-527] - Timestamp in free trace message.
+-Fix: [AT-463] - Memory card drive letter hard coded.
+
+Version in 1.7.2 - 3th September 2009
+---------------------------------
+-Fix: [AT-569] - False memory leak reported when test had handle leak(s)
+-Fix: [AT-535] - Hooked application panics on exit at certain environment
+
+Version in 1.7.1 - 19th August 2009
+---------------------------------
+-Fix: [AT-542] - Decrease extension memory usage when creating results.
+-Fix: [AT-548] - Write protected mmp files will not prevent building project.
+-Fix: [AT-553] - Device data file input should not accept path.
+-Fix: [AT-554] - User build accidentally slow debug version of AnalyzeTool
+-Fix: [AT-528] - Mutex access violation error in certain environment.
+-Fix: [AT-562] - Two tests in one log file may fail to pinpoint.
+-Fix: [AT-563] - Analysis takes allocations before process start tag.
+-Fix: [AT-526] - Memory check related macro panics when application is hooked.
+-Fix: [AT-541] - Opening help on hooked application causes panic.
+-Fix: [AT-555] - AnalyzeTool skips some reallocations.
+-New: [AT-558] - Supporting new environment.
+
+Version in 1.7.0 - 25th June 2009
+---------------------------------
+-Fix: [AT-521] - AnalyzeTool results can be incorrect if new line is non-standard
+-Fix: [AT-414] - Logging level 2 does not work in raptor and build type urel correctly
+-Fix: [AT-508] - Show error if illegal parameters
+-Fix: [AT-464] - Verbose output renders AnalyzeTool unusable slow
+-Fix: [AT-517] - Improve parsing speed of addresses
+-New: [AT-320] - Create support to use xml project definition when building using raptor.
+-New: [AT-389] - User can easily check version of AnalyzeTool in SDK
+-New: [AT-134] - Carbide.c++ AnalyzeTool building of a QT project
+-New: [AT-236] - Refresh button which makes results again
+-New: [AT-136] - Carbide extension to visualize results for emulator/simulator memory leaks automatically
+
+Version in 1.6.0 - 20th April 2009
+---------------------------------
+-New: [AT-475] - Number of max callstack items increased to 40
+-New: [AT-453] - On the fly call stack filtering improved
+-New: [AT-481] - "PROCESS_END x ABNORMAL" are now printed also when internal data gathering mode is used
+-Fix: [AT-491] - Error info improved with new command line parameters
+
+Version in 1.5.2 - 2nd April 2009
+---------------------------------
+-New: [AT-455] - A lot of changes to atool.exe parameters
+-New: [AT-257] - addr2line.exe in now used to pinpoint code lines
+-New: [AT-337] - Supports for pinpointing codelines from GCCE binaries
+-New: [AT-113] - Pinpoint memory leaks to code lines also in urel builds
+-Fix: [AT-461] - Pinpointing works also to dlls in emulator environment.
+-Fix: [AT-470] - Logging levels 1&2 (atool -a l1 or atool -a l2) shows now only pinpointed lines
+-Fix: [AT-483] - Commandline crash fixed when project build to winscw platform
+-Fix: [AT-328] - User is now warned when build type differs between data and project
+-Fix: [AT-419] - Clear AnalyzeTool changes (atool -c) runs reallyclean also
+-Fix: [AT-446] - Error message is display when user analysis invalid data
+-Fix: [AT-413] - Building errors fixed
+
+Version 1.5.1 - 19th March 2009
+-------------------------------
+-Fix: [AT-422] - Abnormal process ends not anymore showed for non-AnalyzeTool processes
+-Fix: [AT-433] - Summary info fixed when executing atool.exe with -uninst parameter
+-Fix: [AT-415] - New mmp specified error message added to sbs2 builds
+-Fix: [AT-449] - Thread killing now handled correctly
+-Fix: [AT-452] - All library events are now handled by DAnalyzeToolEventHandler
+-New: [AT-443] - Atool version is checked when hooked application is started
+-New: [AT-343] - System components info in callstack is read from rom symbols file
+-New: [AT-451] - Added support for pinpointing codelines from static libraries in ARMV5 platform
+
+Version 1.5.0 - 19th February 2008
+----------------------------------
+-Fix: [AT-317] - Multible processes can log to same datafile
+-Fix: [AT-350] - Running atool -c in directory where only empty atool_temp directory exists will not delete atool_temp directory
+-Fix: [AT-330] - In analyze report pinpointed memoryleak count is always zero when using raptor, in logging levels 1 & 2
+-Fix: [AT-333] - Use of raptor build variables leads to incorrect listing file name with certain types
+-Fix: [AT-357] - AnalyzeTool can share existing TraceViewer connection
+-Fix: [AT-361] - Unnecessary "Can not analyze" dialog is no longer displayed after the project is built with AnalyzeTool.
+-Fix: [AT-363] - Needed files for AnalyzeTool hooking are also checked for winscw
+-Fix: [AT-376] - Analyze Tool Pre- and Post-Build Errors are added to Problems View
+-Fix: [AT-272] - AnalyzeTool debug logging improved
+-Fix: [AT-374] - Start tracing icon changed
+-Fix: [AT-332] - Only supported mmp target types are now hooked
+-Fix: [AT-372] - If SDK prefs not ok in Carbide, atool gives error: missing libraries from SDK
+-Fix: [AT-378] - Crash when trying to navigate to source location
+-Fix: [AT-388] - Hooked application no longer panics if there is old version of atool in SDK (now application does not start if versions do not match)
+-Fix: [AT-390] - Emulator pinpoints to wrong cpp file
+-Fix: [AT-393] - Progress monitor is shown while starting the TraceViewer connection
+-Fix: [AT-417] - AnalyzeTool configUI memory leaks fixed
+-Fix: [AT-316] - New 'How to use examples' added to command line help
+-Fix: [AT-410] - Command line tool, "atool.exe", is bundled into the Carbide extension
+-Fix: [AT-325] - unnecessary copying of trace file removed from Carbide
+-Fix: [AT-358] - Disable unnecessary AnalyzeTool buttons when trace is started.
+-New: [AT-296] - AnalyzeTool supports hooking and unhooking of project in command line
+-New: [AT-254] - AnalyzeTool to work also in emulator
+-New: [AT-323] - AnalyzeTool Carbide extension can be used without Traceviewer Extension
+
+Version 1.4.1 - 19th December 2008
+----------------------------------
+-Fix: [AT-310] - AnalyzeTool consoleapplication does not show all process information
+
+Version 1.4.0 - 12th December 2008
+----------------------------------
+-New: [AT-263] - Atool supports Symbian build system version 2 (SBS v.2)
+-Fix: [AT-271] - "atool -c" gives badly formed error texts
+-Fix: [AT-294] - Atool.exe to check if there is process start and dll_load in datafile
+
+Version 1.3.3 - 27th November 2008
+----------------------------------
+-Fix: [AT-237] - Support analysing datafiles without /epoc32/build content or from sub folder where build was made
+-Fix: [AT-285] - Temporary file left to output directory in atool.exe analyze
+-Fix: [AT-292] - S60_UPGRADABLE_APP_REG_RSC macro not always available
+-Fix: [AT-283] - AnalyzeTool.iby works also on PP environment
+
+Version 1.3.2 - 13th November 2008
+----------------------------------
+-Fix: [AT-224] - Multiple modules use same source files (objects listing files)
+-Fix: [AT-220] - Atool.exe to show what is trying to copy or move
+-Fix: [AT-238] - Logging level filtering summary
+-New: [AT-233] - Results include processes udeb/urel info.
+
+Version 1.3.1 - 30th October 2008
+---------------------------------
+-Fix: [AT-228] - Atool tries to delete same temp directory multiple times
+-Fix: [AT-247] - run abld reallyclean instead of abld clean
+-Fix: [AT-215] - AnalyzeTool panics on certain environment
+
+Version 1.3.0 - 23rd October 2008
+---------------------------------
+-Fix: [AT-156] - Multiple subtests within test run show only one subtest
+-Fix: [AT-179] - Atool misinterprets data filename which contains "-l" in string as logging argument
+-Fix: [AT-181] - Logging levels 1 and 3 produce same results when using UREL target
+-Fix: [AT-204] - Memoryhook prints PROCESS_END when child threads are killed
+-Fix: [AT-206] - Atool reports runs from irrelevant PROCESS_ENDS
+-Fix: [AT-210] - Logging level 2 incorrect call stack data
+-Fix: [AT-222] - No error message data file can not be opened
+-Fix: [AT-225] - NPE when using the Analyze View in Carbide 2.0.
+-Fix: [AT-227] - AnalyzeTool uses default variant if no variant parameter is used and default level1 makefiles content is invalid
+-Doc: [AT-175] - AnalyzeTool user guide to have advanced section which explains in detail how tool works
+-New: [AT-66]  - Merge call stack info from main exe and dlls.
+-New: [AT-118] - Show urel/udeb info from main process
+-New: [AT-145] - Analyze is made to given module target name
+-New: [AT-162] - bldmake bldfiles to call only for needed components
+-New: [AT-163] - a single process start - end, should not be a test run
+-New: [AT-183] - atool continues even if bldmake bldfiles fails
+-New: [AT-189] - Carbide.c++ Extension shows ABNORMAL text when system exception happens in the phone
+-New: [AT-190] - Carbide.c++ Extension could filter memory leaks which does not contain any call stack
+-New: [AT-191] - MemoryHook reports PROCESS_END with ABNORMAL tag
+-New: [AT-192] - atool -c to undo mmp change
+-New: [AT-196] - logging datafile shown in Configuration UI
+-New: [AT-202] - Modules with read only mmp files can be hooked
+-New: [AT-209] - Print logging filename if not given
+-New: [AT-211] - AnalyzeTool supports new environments
+-New: [AT-214] - atool could check "build" parameter before assuming debug build
+
+Version 1.2.1 - 2nd October 2008
+--------------------------------
+-Fix: [AT-165] - Process end is not get when process is killed
+-Fix: [AT-176] - Should not hook STATIC libraries
+-Fix: [AT-177] - atool.exe makes changes before creating backup from mmp file
+-Fix: [AT-188] - Atool can not pinpoint codelines from variant modules.
+-New: [AT-142] - Subtests supports handle leak detection
+-New: [AT-159] - AnalyzeTool no longer hooks kernel side components
+-New: [AT-123] - Configuration UI could be used to kill processes in device
+
+Version 1.2.0 - 18th September 2008
+-----------------------------------
+-Fix: [AT-56] - Error when project is build in Carbide.
+-Fix: [AT-73] - White space not ignored when reading target from MMP-file
+-Fix: [AT-87] - XML report file is incorrect when executing multiple test runs with subtest
+-Fix: [AT-93] - Error note "AnalyzeTool can not find all .cpp files" even when project consists of only .c files.
+-Fix: [AT-101] - UI fixes
+-Fix: [AT-102] - MMP selection dialog during build
+-Fix: [AT-109] - Does not follow build order
+-Fix: [AT-110] - Jump to code line does not work
+-Fix: [AT-119] - Updating AnalyzeTool, installed on ROM, with a SIS-file fails.
+-Fix: [AT-143] - Save button menu in previous (wrong) place
+-Fix: [AT-157] - "Number of memory allocations: " can be wrong with multiple test runs
+-Fix: [AT-160] - Carbide.c++ start trace dialog does not contain cancel option
+-New: [AT-74] - Get module info from makefile
+-New: [AT-90] - Check for missing files before building
+-New: [AT-98] - Use makefile templates
+-New: [AT-116] - Improved AnalyzeTool Carbide.c++ Extension to use Carbide builder
+-New: [AT-117] - Improve results showing
+-New: [AT-121] - Urel build selection in Carbide
+-New: [AT-144] - Environment changes zips to include also binaries for various environments
+-New: [AT-149] - Check that AnalyzeTool works with mmp files without .mmp extension
+-New: [AT-53] - AnalyzeTool supports also building and analysing urel binaries
+
+Version 1.1.2 - 21th August 2008
+--------------------------------
+-Fix: [AT-50] - Atool result not always displayed.
+-Fix: [AT-97] - Launching Carbide generates error message to error log
+-Fix: [AT-99] - 'Module not build with AnalyzeTool' is still displayed after AnalyzeTool build.
+
+Version 1.1.1 - 7th August 2008
+-------------------------------
+-Fix: [AT-72] - Command line tool can not handle project where two MMP-files are in same directory
+
+Version 1.1.0 - 10th July 2008
+------------------------------
+-Fix: [AT-70] - Redundant handle leak information
+-New: [AT-59] - Trace data can be saved to a file.
+-New: [AT-68] - Cancel logging from ConfigUI feature.
+
+===============================================================================
+
+/*
+* 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:
+*
+*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/group/atool_stub_sis.mk	Thu Feb 11 15:51:35 2010 +0200
@@ -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:  Stub sis makefile for Configuration UI.
+#
+
+TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install
+
+SISNAME=analyzeTool_stub
+PKGNAME=analyzeTool_stub
+
+$(TARGETDIR) :
+	@perl -S emkdir.pl "$(TARGETDIR)"
+
+do_nothing :
+	rem do_nothing
+
+SISFILE=$(TARGETDIR)\$(SISNAME).sis
+
+$(SISFILE) : ..\sis\$(PKGNAME).pkg
+	makesis -s $? $@ 
+
+#
+# The targets invoked by bld...
+#
+
+MAKMAKE : do_nothing
+
+RESOURCE : do_nothing
+
+SAVESPACE : do_nothing
+
+BLD : do_nothing
+
+FREEZE : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+FINAL : $(TARGETDIR) $(SISFILE)
+
+CLEAN : 
+	-erase $(SISFILE)
+
+RELEASABLES : 
+	@echo $(SISFILE)
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/group/bld.inf	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,48 @@
+/*
+* 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 "../staticlib/group/bld.inf"
+#include "../storageserver/group/bld.inf"
+#include "../kerneleventhandler/group/bld.inf"
+#include "../dynamicmemoryhook/group/bld.inf"
+#ifdef __S60_
+	#include "../configurationappgui/group/bld.inf"
+#endif
+#include "../consoleui/group/bld.inf"
+
+PRJ_MMPFILES
+#if !defined(__SERIES60_30__) && !defined(__SERIES60_31__) && !defined(__SERIES60_32__)
+	PRJ_EXTENSIONS
+	#ifdef MARM
+		START EXTENSION app-services/buildstubsis
+		OPTION SRCDIR ../sis
+		OPTION SISNAME analyzeTool_stub
+		END
+	#endif
+#else
+	#ifdef MARM
+		gnumakefile atool_stub_sis.mk
+	#endif
+#endif
+
+PRJ_EXPORTS
+#if !defined(__SERIES60_30__) && !defined(__SERIES60_31__) && !defined(__SERIES60_32__)
+	#if defined CORE_IBY_EXPORT_PATH
+		../rom/analyzetool.iby CORE_IBY_EXPORT_PATH(tools,analyzetool.iby)
+		../rom/analyzetool_rom.iby CORE_IBY_EXPORT_PATH(tools/rom,analyzetool_rom.iby)
+	#endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/inc/atlog.h	Thu Feb 11 15:51:35 2010 +0200
@@ -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:  Definitions of logging macros for Analyze Tool S60 modules.
+*
+*/
+
+#ifndef __ATLOG_H__
+#define __ATLOG_H__
+
+#ifdef _DEBUG
+//To enable/disable logging uncomment/comment the next line
+// #define LOGGING_ENABLED  //Enable logging
+//Uncomment next to enable logging only LOGSTR1 lines
+// #define LOGGING_ENABLED_FAST //Logging only function names
+
+//Disable next to use file logging
+ #define USE_RDEBUG
+#endif
+
+//Do not alter the code below this
+
+#ifdef __KERNEL_MODE__
+
+ #ifdef LOGGING_ENABLED
+  #include <kernel.h> 
+  #define LOGSTR1( AAA ) 			{ Kern::Printf( AAA ); }
+  #define LOGSTR2( AAA, BBB ) 			{ Kern::Printf( AAA, BBB ); }
+ #else
+  #define LOGSTR1( AAA )
+  #define LOGSTR2( AAA, BBB )
+ #endif
+
+#else // #ifdef __KERNEL_MODE__
+
+ #ifdef LOGGING_ENABLED
+
+//  INCLUDES
+  #include <flogger.h>
+  #ifdef USE_RDEBUG
+   #include <e32svr.h>
+  #endif
+
+// CONSTANTS
+  _LIT( KAtLoggingFolder, "atlog" );
+  _LIT( KAtLoggingFile  , "LOG.TXT" );
+  #define ONE_SPACE_MARGIN	_S(" ")
+
+// ---------------------------------------------------------------------------------
+// Internal MACROS. Do not call these directly, use the External MACROS instead
+// ---------------------------------------------------------------------------------
+
+  #ifdef LOGGING_ENABLED_FAST
+
+   #ifdef USE_RDEBUG
+    #define INTERNAL_LOGSTR1( AAA )				{ _LIT( logdes, AAA ); RDebug::Print( logdes() ); }
+   #else  // RFileLogger is used
+    #define INTERNAL_LOGSTR1( AAA )				{ _LIT( logdes, AAA ); RFileLogger::Write( KAtLoggingFolder(), KAtLoggingFile(), EFileLoggingModeAppend, logdes() ); }
+   #endif // USE_RDEBUG
+   #define INTERNAL_LOGSTR2( AAA, BBB )
+   #define INTERNAL_LOGSTR3( AAA, BBB, CCC )
+   #define INTERNAL_LOGMEM
+   #define INTERNAL_LOG( AAA )
+
+  #else
+  
+   #ifdef USE_RDEBUG
+    #define INTERNAL_LOGDESC8( AAA )				{ TBuf<100> tmp; if( sizeof( AAA ) < 100 ) tmp.Copy( AAA ); RDebug::Print( tmp );}
+    #define INTERNAL_LOGSTR1( AAA )				{ _LIT( logdes, AAA ); RDebug::Print( logdes() ); }
+    #define INTERNAL_LOGSTR2( AAA, BBB )			{ _LIT( logdes, AAA ); RDebug::Print( TRefByValue<const TDesC>( logdes()), BBB ); }
+    #define INTERNAL_LOGSTR3( AAA, BBB, CCC )	{ _LIT( logdes, AAA ); RDebug::Print( TRefByValue<const TDesC>(logdes()), BBB, CCC ); }
+    #define INTERNAL_LOGMEM						{ _LIT( logdes, "Heap size: %i" );  TBuf<50> buf; TInt a; User::AllocSize( a ); buf.Format( logdes, a ); RDebug::Print( buf ); }
+    #define INTERNAL_LOG( AAA )					AAA
+   #else  // RFileLogger is used
+    #define INTERNAL_LOGSTR1( AAA )				{ _LIT( logdes, AAA ); RFileLogger::Write( KAtLoggingFolder(), KAtLoggingFile(), EFileLoggingModeAppend, logdes() ); }
+    #define INTERNAL_LOGSTR2( AAA, BBB ) 		{ _LIT( logdes, AAA ); RFileLogger::WriteFormat( KAtLoggingFolder(), KAtLoggingFile(), EFileLoggingModeAppend, TRefByValue<const TDesC>( logdes()), BBB ); }
+    #define INTERNAL_LOGSTR3( AAA, BBB, CCC) 	{ _LIT( logdes, AAA ); RFileLogger::WriteFormat( KAtLoggingFolder(), KAtLoggingFile(), EFileLoggingModeAppend, TRefByValue<const TDesC>(logdes()), BBB, CCC ); }
+    #define INTERNAL_LOGMEM 					{ _LIT( logdes, "Heap size: %i" ); TMemoryInfoV1Buf info; UserHal::MemoryInfo(info); TInt freeMemory = info().iFreeRamInBytes; TBuf<50> buf; buf.Format( logdes, freeMemory ); RFileLogger::WriteFormat( KAtLoggingFolder(), KAtLoggingFile(), EFileLoggingModeAppend, buf ); }
+    #define INTERNAL_LOG( AAA )					AAA
+   #endif // USE_RDEBUG
+
+  #endif
+
+ #else
+
+  #define INTERNAL_LOGSTR1( AAA )
+  #define INTERNAL_LOGSTR2( AAA, BBB )
+  #define INTERNAL_LOGSTR3( AAA, BBB, CCC )
+  #define INTERNAL_LOGMEM
+  #define INTERNAL_LOG( AAA )
+
+ #endif
+
+// ---------------------------------------------------------------------------------
+// External MACROS. Use these in code
+// ---------------------------------------------------------------------------------
+// Logging of string
+// i.e.: LOGSTR1( "Whoo-haa!" );
+ #define LOGSTR1( AAA ) { INTERNAL_LOGSTR1( AAA ); }
+
+// Logging of string + integer value
+// i.e.: LOGSTR2( "CHttpd status %i:", iStatus );
+ #define LOGSTR2( AAA, BBB ) { INTERNAL_LOGSTR2( AAA, BBB ); }
+
+// Logging of descriptor + 2 integers
+// i.e.: LOGSTR3( "Jippii %i %i", val1, val2 );
+ #define LOGSTR3( AAA, BBB, CCC ) { INTERNAL_LOGSTR3( AAA, BBB, CCC ); }
+
+// Log heap size
+ #define LOGMEM         { INTERNAL_LOGMEM }
+
+// Logging variable operations  
+ #define LOG( AAA )     INTERNAL_LOG( AAA )
+
+#endif // #ifdef __KERNEL_MODE__
+
+#endif // __ATLOG_H__
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/kerneleventhandler/group/atoolkerneleventhandler.mmp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,51 @@
+/*
+* 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 AToolKernelEventHandler
+*
+*/
+
+#include <platform_paths.hrh>
+#include <kernel/kern_ext.mmh>
+#include "../../symbian_version.hrh"
+
+TARGET	     	atoolkerneleventhandler.ldd
+TARGETTYPE   	ldd
+CAPABILITY		ALL
+
+SMPSAFE
+
+USERINCLUDE   	../inc
+USERINCLUDE   	../../inc
+
+OS_LAYER_KERNEL_SYSTEMINCLUDE
+
+SOURCEPATH    ../src
+
+SOURCE        analyzetoolchannel.cpp
+SOURCE        analyzetooldevice.cpp
+SOURCE        analyzetooleventhandler.cpp
+
+LIBRARY       flogger.lib
+#ifdef WINSCW
+LIBRARY       emulator.lib
+	start wins
+	win32_headers
+	end
+#endif // WINSCW
+
+#if ( SYMBIAN_VERSION_SUPPORT >= SYMBIAN_3 )
+MACRO	MCL_ROBJECTIX
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/kerneleventhandler/group/bld.inf	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,35 @@
+/*
+* 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
+../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
+
+PRJ_TESTMMPFILES
+../tsrc/group/analyzetooldevicedrivertest.mmp
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/kerneleventhandler/inc/analyzetool.h	Thu Feb 11 15:51:35 2010 +0200
@@ -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.8.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/memana/analyzetoolclient/kerneleventhandler/inc/analyzetool.inl	Thu Feb 11 15:51:35 2010 +0200
@@ -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/memana/analyzetoolclient/kerneleventhandler/inc/analyzetoolchannel.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,212 @@
+/*
+* 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 DAnalyzeToolChannel
+*
+*/
+
+
+#ifndef __ANALYZETOOLCHANNEL_H__
+#define __ANALYZETOOLCHANNEL_H__
+
+// INCLUDES
+#include <analyzetool/analyzetool.h>
+#include <kernel/kernel.h>
+#ifdef __WINSCW__
+#include <memmodel/emul/win32/memmodel.h>
+#endif // __WINSCW__
+
+// FORWARD DECLARATIONS
+class DAnalyzeToolEventHandler;
+
+// CLASS DECLARATION
+
+/**
+* The implementation of the abstract base class for a logical channel.
+*/
+class DAnalyzeToolChannel : public DLogicalChannel
+	{
+	public:
+		
+        /**
+        * C++ default constructor.
+        */
+		DAnalyzeToolChannel();
+		
+        /**
+        * Destructor.
+        */
+		~DAnalyzeToolChannel();
+		
+	protected: // from DLogicalChannel
+		
+        /**
+        * Creates the logical channel.
+        * @param aUnit A unit of the device.
+        * @param anInfo A pointer to an explicit 8-bit descriptor containing 
+        			    extra information for the physical device
+        * @param aVer The required version of the logical device
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		virtual TInt DoCreate( TInt aUnit, 
+							   const TDesC8* anInfo, 
+							   const TVersion &aVer );
+    
+        /**
+        * Handles a client request.
+        * @param aFunction The requested function.
+        * @param a1 A 32-bit value passed to the kernel-side. Its meaning 
+        			  depends on the device driver requirements
+        * @param a2 A 32-bit value passed to the kernel-side. Its meaning
+        			  depends on the device driver requirements
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		virtual TInt DoControl( TInt aFunction, TAny* a1, TAny* a2, TThreadMessage& aMessage );	
+		
+		/**
+		* Processes a message for this logical channel.
+		* This function is called in the context of a DFC thread.
+		* @param aMsg  The message to process.
+		*/
+		virtual void HandleMsg( TMessageBase* aMsg );
+		
+        /**
+        * Handles a client asynchronous request.
+        * @param aFunction The requested function.
+        * @param aStatus Pointer to client TRequestStatus.
+        * @param a1 A 32-bit value passed to the kernel-side. Its meaning 
+        			  depends on the device driver requirements
+        * @param a2 A 32-bit value passed to the kernel-side. Its meaning
+        			  depends on the device driver requirements
+        * @param aMessage Reference to received thread message.
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		virtual TInt DoRequest( TInt aFunction, 
+								TRequestStatus* aStatus, 
+								TAny* a1, 
+								TAny* a2, 
+								TThreadMessage& aMessage );
+		
+        /**
+        * Cancels outstanding asynchronous request.
+        */
+		virtual void DoCancel();
+
+	private:
+		
+        /**
+        * Acquires current process information
+        * @param aProcessInfo Pointer to the TProcessIdentityParams object.
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		TInt GetProcessInfo( TAny* aProcessInfo, TThreadMessage& aMessage );
+		
+        /**
+        * Acquires codeseg information.
+        * @param aCodesegInfo Pointer to the TCodesegInfo object.
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		TInt GetCodesegInfo( TAny* aCodesegInfo, TThreadMessage& aMessage );
+		
+        /**
+        * Acquires library information.
+        * @param aLibraryInfo Pointer to the TLibraryInfo object.
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		TInt GetLibraryInfo( TAny* aLibraryInfo, TThreadMessage& aMessage );
+	
+        /**
+        * Acquires information about process main thread RAllocator.
+        * @param aMainThreadParams Pointer to the TMainThreadParams object.
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		TInt MainThreadAllocator( TAny* aMainThreadParams, 
+								  TThreadMessage& aMessage );
+		
+		/**
+		* 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
+		*/
+		TInt ThreadStack( TAny* aThreadStack, 
+						  TThreadMessage& aMessage );
+
+        /**
+        * 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
+        */
+		TInt GetProcessHandleInfo( TAny* aProcessHandleInfo, 
+								   TThreadMessage& aMessage );
+
+        /**
+        * 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
+        */
+        TInt GetCurrentHandleCount( TAny* aProcessHandles, 
+									TThreadMessage& aMessage );
+        
+        /**
+		* Acquires the count of current device driver users.
+		* @param aClientCount A reference to TInt variable
+		* @return TInt Returns KErrNone, if successful
+        *               otherwise one of the other system-wide error codes
+		*/			
+        TInt ClientCount( TAny* aClientCount, 
+						  TThreadMessage& aMessage );
+		
+        /**
+         * Acquires memory model system uses.
+         * @return TInt Returns KErrNone, if successful
+         *              otherwise one of the other system-wide error codes
+         */
+        TInt GetMemoryModel( TAny* aMemoryModel,
+                            TThreadMessage& aMessage );
+        
+        #ifdef __WINSCW__
+        /**
+		* Gets module dependencies
+		* @param aModule Module handle
+		*/
+        void GetModuleDependencies( HMODULE aModule );
+        #endif // __WINSCW__
+        
+	private: //Member variables
+		
+		/* Handler which receives kernel events */
+		DAnalyzeToolEventHandler* iEventHandler;
+		
+		#ifdef __WINSCW__
+		/* Code segment array */
+		RArray<TCodesegInfo> iCodeSeg;
+		#endif // __WINSCW__
+		
+		/* A DFC queue for communication */
+		TDynamicDfcQue* iOwnDfcQ;
+
+	};
+
+#endif // #ifndef __ANALYZETOOLCHANNEL_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/kerneleventhandler/inc/analyzetooldevice.h	Thu Feb 11 15:51:35 2010 +0200
@@ -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:  Declaration of the class DAnalyzeToolDevice.
+*
+*/
+
+
+#ifndef __ANALYZETOOLEVICE_H__
+#define __ANALYZETOOLEVICE_H__
+
+// INCLUDES
+#include <analyzetool/analyzetool.h>
+#include <kernel/kernel.h>
+
+// CLASS DECLARATION
+
+/**
+* The implementation of the abstract base class for an LDD factory object.
+*/
+
+class DAnalyzeToolDevice : public DLogicalDevice
+	{
+	public:
+	
+        /**
+        * C++ default constructor.
+        */
+		DAnalyzeToolDevice();
+		
+	public: // from DLogicalDevice
+	
+        /**
+        * Second stage constructor.
+        @return KErrNone or standard error code.
+        */
+		virtual TInt Install();
+	
+        /**
+        * Gets the driver's capabilities.
+        @param aDes A user-side descriptor into which capabilities 
+        			information is to be written.
+        */
+		virtual void GetCaps( TDes8& aDes ) const;
+		
+        /**
+        * Called by the kernel's device driver framework to 
+        * create a Logical Channel.
+        @param aChannel Set to point to the created Logical Channel
+        @return KErrNone or standard error code.
+        */
+		virtual TInt Create( DLogicalChannelBase*& aChannel );
+	};
+
+
+#endif // __ANALYZETOOLEVICE_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/kerneleventhandler/inc/analyzetooleventhandler.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,167 @@
+/*
+* 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 DAnalyzeToolEventHandler.
+*
+*/
+
+
+#ifndef __ANALYZETOOLEVENTHANDLER_H__
+#define __ANALYZETOOLEVENTHANDLER_H__
+
+// INCLUDES
+#include <analyzetool/analyzetool.h>
+#include "atlog.h"
+#include <kernel/kernel.h>
+
+// CLASS DECLARATION
+
+/**
+* Callback class for kernel events
+*/
+
+class DAnalyzeToolEventHandler : public DKernelEventHandler
+	{
+	public:
+	
+        /**
+        * C++ default constructor.
+        */
+		inline DAnalyzeToolEventHandler( TDfcQue* aDfcQ );
+		
+        /**
+        * Destructor.
+        */ 
+		~DAnalyzeToolEventHandler();
+		
+        /**
+        * Second stage constructor.
+        * @param aDevice A pointer to device where the event handler belongs.
+        * @param aProcessId Owner process id.
+        * @return TInt Returns KErrNone, if successful
+        			   otherwise one of the other system-wide error codes
+        */
+		TInt Create( DLogicalDevice* aDevice, const TUint aProcessId );
+		
+        /**
+        * 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
+        */
+		void InformLibraryEvent( TRequestStatus* aStatus, 
+								 TAny* aLibraryInfo,
+								 TThreadMessage& aMessage );
+        
+        /**
+        * Cancels subscribetion of the library event.
+        */
+		void CancelInformLibraryEvent();
+
+        /**
+        * Static function for DFC events.
+        * @param aPtr Pointer to DAnalyzeToolEventHandler object. 
+        */
+	    static void EventDfc( TAny* aPtr );
+		
+	private:
+	
+        /**
+        * Pointer to  callback function called when an event occurs.
+        * @param aEvent Designates what event is dispatched.
+        * @param a1 Event-specific paramenter.
+        * @param a2 Event-specific paramenter.
+        * @param aThis A pointer to the event handler
+        * @return TUint Bitmask returned by callback function.
+        */
+		static TUint EventHandler( TKernelEvent aEvent, 
+								   TAny* a1, 
+								   TAny* a2, 
+								   TAny* aThis );
+	
+	private:
+	
+        /**
+        * Handles the EEventAddLibrary and EEventRemoveLibrary events
+        * @param aLib* A pointer to added/removed library.
+        * @param aThread* A pointer to thread where the libary is.
+        * @param aInfo* A reference class to be written to the client
+        */	
+		void HandleLibraryEvent( DLibrary* aLib, 
+								 DThread* aThread, 
+								 TLibraryEventInfo& aInfo );
+		
+		/**
+		* Handles the EEventKillThread events
+		* @param aThread* A pointer to the thread being terminated. 
+		* @param aInfo* A reference class
+		*/	
+		void HandleKillThreadEvent( DThread* aThread, 
+									TLibraryEventInfo& aInfo );
+		
+		/**
+		* Informs client about the occured event
+		*/	
+	    void DoEventComplete();
+					
+	private:
+	
+		/* Mutex for serializing access to event handler */
+		DMutex* iHandlerMutex;
+		
+		/* Mutex fof serializing access to event handler variables */
+		DMutex* iDataMutex;		
+		
+		/* If the client is a RAM-loaded LDD (or PDD), it is possible for the DLL to
+		be unloaded while the handler is still in use.  This would result in an
+		exception.  To avoid this, the handler must open a reference to the
+		DLogicalDevice (or DPhysicalDevice) and close it in its d'tor. */
+		DLogicalDevice* iDevice;    
+				
+		/* Owner process ID */
+		TUint iProcessId;
+		
+		/* Event array */
+		RArray<TLibraryEventInfo> iEventArray;
+				
+		/* Pointer to client's TRequestStatus */ 
+		TRequestStatus* iClientRequestStatus;
+		
+		/* Pointer to client's thread */ 
+		DThread* iClientThread;
+
+		/* Pointer to client's TLibraryEventInfo */ 
+		TAny* iClientInfo;
+		
+		/* DFC for informing events to the client */ 
+		TDfc iEventDfc;
+	};
+	
+// ----------------------------------------------------------------------------
+// DAnalyzeToolEventHandler::DAnalyzeToolEventHandler()
+// C++ default constructor.
+// ----------------------------------------------------------------------------
+//
+inline DAnalyzeToolEventHandler::DAnalyzeToolEventHandler( TDfcQue* aDfcQ ) :	
+	DKernelEventHandler( EventHandler, this ),
+	iEventDfc( EventDfc, this, 1 )
+	{
+	LOGSTR1( "ATDD DAnalyzeToolEventHandler::DAnalyzeToolEventHandler()" );
+	iEventDfc.SetDfcQ( aDfcQ );
+	}
+
+#endif // __ANALYZETOOLEVENTHANDLER_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/kerneleventhandler/inc/analyzetooltraceconstants.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,171 @@
+/*
+* 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 = EATLogToXti;
+
+// 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 XTI
+_LIT( KXtiMessage, "PCSS %x %S" );
+_LIT( KMemoryAllocHeader, "ALLOCH " );
+_LIT( KMemoryAllocFragment, "ALLOCF " );
+_LIT( KMemoryFreedHeader, "FREEH " );
+_LIT( KMemoryFreedFragment, "FREEF " );
+_LIT( KSpaceXti, " " );
+_LIT( KNewLineXti, "\r\n" );
+_LIT( KHexaNumberXti, " %x" );
+_LIT( KProcessEndXti, "PROCESS_END %x " );
+_LIT( KProcessEndAbnormalXti, "PROCESS_END %x ABNORMAL " );
+_LIT( KErrorOccuredXti, "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__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/kerneleventhandler/inc/atcommon.h	Thu Feb 11 15:51:35 2010 +0200
@@ -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 XTI channel. */
+    EATLogToXti,
+    
+    /** Logging to XTI channel bypassing storage server. */
+    EATLogToXtiFast,
+    
+    /** Logging switched off. */
+    EATLoggingOff
+    };
+
+/**
+*  Class which supports interfacing with AnalyzeTool exported
+*  functions.
+*/
+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/memana/analyzetoolclient/kerneleventhandler/sis/analyzetooldevicedriver.pkg	Thu Feb 11 15:51:35 2010 +0200
@@ -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:
+;
+
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"AnalyzeToolDeviceDriver"},(0xEDF5A8A1),1,8,0
+
+;Localised Vendor name
+%{"Vendor-EN"}
+
+;Unique Vendor name
+:"Vendor"
+
+;Supports Series 60 v 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+; 1 File to install
+"\epoc32\release\armv5\urel\atoolkerneleventhandler.ldd"-"!:\sys\bin\atoolkerneleventhandler.ldd"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/kerneleventhandler/src/analyzetoolchannel.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,1019 @@
+/*
+* 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 DAnalyzeToolChannel.
+*
+*/
+
+
+// INCLUDE FILES
+#include "analyzetoolchannel.h"
+#include "analyzetooldevice.h"
+#include "analyzetooleventhandler.h"
+
+#include <kernel/kern_priv.h>
+#ifdef __WINSCW__
+#include <emulator.h>
+#endif // __WINSCW__
+
+#include "atlog.h"
+
+// ================= MEMBER FUNCTIONS =========================================
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::DoCreate()
+// Creates the logical channel.
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::DoCreate( TInt /*aUnit*/, 
+    const TDesC8* /*aInfo*/, const TVersion &aVer )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::DoCreate()" );
+
+    // Check client version.
+    if ( !Kern::QueryVersionSupported( KAnalyzeToolLddVersion(), aVer ) )
+        {
+        return KErrNotSupported;
+        }
+     
+    TInt error = Kern::DynamicDfcQCreate( iOwnDfcQ, 
+                                          KAnalyzeToolThreadPriority, 
+                                          KAnalyzeToolThreadName );
+
+    if ( KErrNone != error )
+        {
+        return error;
+        }
+
+    SetDfcQ( iOwnDfcQ );
+    
+    iMsgQ.Receive();
+   
+    // Create the event handler
+    iEventHandler = new DAnalyzeToolEventHandler( iOwnDfcQ );
+
+    // Check that everything is OK
+    if ( !iEventHandler )
+        {
+        return KErrNoMemory;
+        }
+    
+    // 2nd stage constructor for event handler
+    return iEventHandler->Create( iDevice, Kern::CurrentProcess().iId );
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::DAnalyzeToolChannel()
+// Constructor.
+// -----------------------------------------------------------------------------
+//
+DAnalyzeToolChannel::DAnalyzeToolChannel()
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::DAnalyzeToolChannel()" );
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::~DAnalyzeToolChannel()
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+DAnalyzeToolChannel::~DAnalyzeToolChannel()
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::~DAnalyzeToolChannel()" );
+    
+    if ( iEventHandler )
+        {
+        // Cancel all processing that we may be doing
+        DoCancel();
+        
+        // Client code should use Close() instead the operator delete 
+        // to destroy the event handler. 
+        TInt error( iEventHandler->Close() );
+        if ( KErrNone != error )
+            {
+            LOGSTR2( "ATDD iEventHandler->Close(%d)", error );
+            }
+        }
+    #ifdef __WINSCW__
+        iCodeSeg.Close();
+    #endif // __WINSCW__
+    
+    // Destroy the queqe
+    if ( iOwnDfcQ )
+        {
+        iOwnDfcQ->Destroy();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::DoControl()
+// Handles a client request.
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::DoControl( TInt aFunction, 
+                                     TAny* a1, 
+                                     TAny* /*a2*/, 
+                                     TThreadMessage& aMessage )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::Request()" );
+    
+    TInt ret( KErrNone );
+
+    // Check the requested function
+    switch (aFunction)
+        {
+        case RAnalyzeTool::EGetProcessInfo:
+            ret = GetProcessInfo( a1, aMessage );
+            break;
+            
+        case RAnalyzeTool::EGetCodesegInfo:
+            ret = GetCodesegInfo( a1, aMessage );
+            break;
+
+        case RAnalyzeTool::EGetLibraryInfo:
+            ret = GetLibraryInfo( a1, aMessage );
+            break;
+            
+        case RAnalyzeTool::ECancelLibraryEvent:
+            iEventHandler->CancelInformLibraryEvent();
+            break;
+            
+        case RAnalyzeTool::ECurrentClientCount:
+            ret = ClientCount( a1, aMessage );
+            break;
+
+        case RAnalyzeTool::EMainThreadAlloctor:
+            ret = MainThreadAllocator( a1, aMessage );
+            break;
+        
+        case RAnalyzeTool::EThreadStack:
+             ret = ThreadStack( a1, aMessage );
+             break;
+             
+        case RAnalyzeTool::EGetProcessHandle:
+            ret = GetProcessHandleInfo( a1, aMessage );
+            break;
+        
+        case RAnalyzeTool::EGetCurrentHandles:
+            ret = GetCurrentHandleCount( a1, aMessage );
+            break;
+        case RAnalyzeTool::EGetMemoryModel:
+            ret = GetMemoryModel( a1, aMessage );
+            break;
+            
+        // Unsupported function. Panic
+        default:
+            Kern::PanicCurrentThread( KClientPanic, EPanicUnsupportedRequest );
+            break;
+        }
+        
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::DoRequest()
+// Handles a client asynchronous request.
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::DoRequest( TInt aFunction, 
+                                     TRequestStatus* aStatus, 
+                                     TAny* a1, 
+                                     TAny* /*a2*/,
+                                     TThreadMessage& aMessage )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::DoRequest()" );
+    
+    // Check the requested function
+    switch (aFunction)
+        {
+        case RAnalyzeTool::ELibraryEvent:
+            iEventHandler->InformLibraryEvent( aStatus, a1, aMessage );
+            break;
+            
+        // Unsupported function. Panic
+        default:
+            aMessage.PanicClient( KClientPanic, EPanicUnsupportedRequest );
+            break;
+        }
+        
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::DoCancel()
+// Cancels outstanding asynchronous request.
+// -----------------------------------------------------------------------------
+//
+void DAnalyzeToolChannel::DoCancel()
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::DoCancel()" );
+    
+    iEventHandler->CancelInformLibraryEvent();
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::HandleMsg()
+// Processes a message for this logical channel.
+// -----------------------------------------------------------------------------
+//
+void DAnalyzeToolChannel::HandleMsg(TMessageBase* aMsg)
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::HandleMsg()" );
+
+    TThreadMessage& message = *(TThreadMessage*)aMsg;
+
+    // Get message type
+    TInt id = message.iValue;
+
+    // Decode the message type and dispatch it to the relevent handler function...
+    if ( id == (TInt) ECloseMsg )
+        {
+        // Channel Close
+        DoCancel();
+        message.Complete( KErrNone, EFalse );
+        }
+    else if ( id == KMaxTInt )
+        {
+        // DoCancel
+        DoCancel();
+        message.Complete( KErrNone, ETrue );
+        }
+    else if ( id < 0 )
+        {
+        // DoRequest
+        TRequestStatus* status = (TRequestStatus*) message.Ptr0();
+        TInt error = DoRequest( ~id, status, message.Ptr1(), message.Ptr2(), message );
+        if ( KErrNone != error )
+            {
+            Kern::RequestComplete( message.Client(), status, error);
+            }
+        message.Complete(KErrNone, ETrue );
+        }
+    else
+        {
+        // DoControl
+        TInt ret = DoControl( id, message.Ptr0(), message.Ptr1(), message );
+        message.Complete( ret, ETrue );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::GetProcessInfo()
+// Acquires current process information
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::GetProcessInfo( TAny* aProcessInfo, 
+                                          TThreadMessage& aMessage )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::GetProcessInfo()" );
+
+    // Variable for reading parameters from user side
+    TProcessIdentityParamsBuf params;
+    
+    // Reads a descriptor from a thread's process.
+    TInt error = Kern::ThreadDesRead( aMessage.Client(), aProcessInfo, params, 0 );  
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesRead error %d", error );
+        return error;
+        } 
+
+    // Gets the current process
+    Kern::Containers()[ EProcess ]->Wait();
+    DProcess& process = *Kern::ProcessFromId( params().iProcessId );  
+    Kern::Containers()[ EProcess ]->Signal();
+    
+    if ( NULL == &process )
+        {        
+        return KErrNotFound;
+        }
+    
+    // Temporary variable for collecting information from the process
+    TProcessIdentityParamsBuf info;
+    
+    // Collect needed information from the process
+    process.AppendName( info().iProcessName );//lint !e64 !e1514
+    
+    // Gets the current thread
+    Kern::Containers()[ EThread ]->Wait(); 
+    DThread& thread = *Kern::ThreadFromId( params().iThreadId );
+    Kern::Containers()[ EThread ]->Signal();
+   
+    if ( NULL == &thread )
+        {
+        return KErrNotFound;
+        }     
+    
+    // Stack address of the main thread
+    info().iStackAddress = thread.iUserStackRunAddress;
+    info().iStackSize    = thread.iUserStackSize;  
+    
+    // Enters thread critical section and acquires code segment mutex.
+    Kern::AccessCode();
+        
+    // Collect needed information from the process
+    info().iDynamicCount = process.iDynamicCode.Count();
+
+    // Temporary queue for acquiring the count of codesegments
+    SDblQue queue;
+
+    // Acquire the count of codesegments
+    TInt codesegCount = process.TraverseCodeSegs( &queue, 
+                                                  NULL, 
+                                                  DCodeSeg::EMarkDebug, 
+                                                  DProcess::ETraverseFlagAdd );
+    
+    #ifndef __WINSCW__
+        info().iCodesegCount = codesegCount;    
+    #else
+    // Reset codesegment array
+    iCodeSeg.Reset();
+    
+    if ( codesegCount > 0 )
+        {
+        SDblQueLink* link = queue.iA.iNext;
+        TCodesegInfo codeinfo;
+        // Iterate through codesegments
+        for ( TInt i = 0; i < codesegCount; ++i, link = link->iNext )
+            {
+            DWin32CodeSeg* codeseg = 
+                (DWin32CodeSeg*)_LOFF( link, DCodeSeg, iTempLink );
+
+            // Aqcuire codeseg information
+            codeinfo.iFileEntryPoint = codeseg->iFileEntryPoint;
+            codeinfo.iSize = codeseg->iSize;
+            codeinfo.iFullName.Copy( codeseg->iRootName );
+            codeinfo.iRunAddress = codeseg->iRunAddress;
+            iCodeSeg.Append( codeinfo );
+            }
+        }
+    
+    // Add dependency codesegments
+    DWin32CodeSeg* pcodeSeg = (DWin32CodeSeg*)process.iCodeSeg;
+    
+    // Get dependency codesegments
+    GetModuleDependencies( pcodeSeg->iModuleHandle );
+    
+    // Set codesegment count
+    info().iCodesegCount = iCodeSeg.Count();
+    #endif
+    
+    // Removes all code segments from a queue and clear specified mark(s)
+    DCodeSeg::EmptyQueue( queue, DCodeSeg::EMarkDebug );
+
+    // Exits thread critical section and releases code segment mutex.
+    Kern::EndAccessCode();
+
+    // Writes a descriptor to a thread's process.
+    error = Kern::ThreadDesWrite( aMessage.Client(), aProcessInfo, info, 0 );  
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesWrite error %d", error );
+        return error;
+        } 
+   
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::GetCodesegInfo()
+// Acquires codeseg information.
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::GetCodesegInfo( TAny* aCodesegInfo, 
+                                          TThreadMessage& aMessage )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::GetCodesegInfo()" );
+
+    // Temporary variable for collecting information from the codeseg
+    TCodesegInfoBuf params;
+
+    TInt error( KErrArgument );
+    
+    // Reads a descriptor from a thread's process.
+    error = Kern::ThreadDesRead( aMessage.Client(), aCodesegInfo, params, 0 );  
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesRead error %d", error );
+        return error;
+        } 
+
+    if ( params().iIndex < 0 )
+        {
+        return KErrArgument;
+        }
+    
+    // Gets the current process
+    Kern::Containers()[ EProcess ]->Wait();
+    DProcess& process = *Kern::ProcessFromId( params().iProcessId );
+    Kern::Containers()[ EProcess ]->Signal();
+    
+    if ( NULL == &process )
+        {
+        return KErrNotFound;
+        }
+    
+    // Temporary variable for collecting information 
+    TCodesegInfoBuf output;
+
+    // Enters thread critical section and acquires code segment mutex.
+    Kern::AccessCode();
+
+    #ifndef __WINSCW__
+    // Temporary queue for acquiring the codesegments
+    SDblQue queue;
+    
+    // Acquire the codesegments
+    TInt actcount = process.TraverseCodeSegs( &queue, 
+                                              NULL, 
+                                              DCodeSeg::EMarkDebug, 
+                                              DProcess::ETraverseFlagAdd );
+    if ( actcount >= params().iIndex )
+        {
+        LOGSTR1( "ATDD DAnalyzeToolChannel::GetCodesegInfo() - actcount >= params.iIndex" );
+        SDblQueLink* link = queue.iA.iNext;
+        
+        // Iterate through codesegments
+        for (TInt i = 0; i < actcount; ++i, link = link->iNext)
+            {
+            DCodeSeg* codeseg = _LOFF( link, DCodeSeg, iTempLink );
+
+            // Is the codesegments which information client wants
+            if ( i == params().iIndex )
+                {
+                // Aqcuire codeseg information
+                output().iFileEntryPoint = codeseg->iFileEntryPoint;
+                output().iSize = codeseg->iSize;
+                output().iFullName.Copy( codeseg->iRootName );
+                output().iRunAddress = codeseg->iRunAddress;
+                error = codeseg->GetMemoryInfo( output().iMemoryInfo, &process );
+                
+                if ( KErrNone == error )
+                    {
+                    // Writes a descriptor to a thread's process.
+                    error = Kern::ThreadDesWrite( aMessage.Client(), 
+                                                  aCodesegInfo, 
+                                                  output, 
+                                                  0 );   
+                    if ( KErrNone != error )
+                        {
+                        LOGSTR2( "ATDD ThreadDesWrite error %d", error );
+                        } 
+                    }
+                break;
+                }
+            }
+        }
+    // Removes all code segments from a queue and clear specified mark(s).
+    DCodeSeg::EmptyQueue( queue, DCodeSeg::EMarkDebug );
+    
+    // Exits thread critical section and releases code segment mutex.
+    Kern::EndAccessCode();
+    
+    return error;
+    #else // WINSCW
+    
+    if ( iCodeSeg.Count() > params().iIndex )
+        {
+        // Aqcuire codeseg information
+        output().iSize = iCodeSeg[params().iIndex].iSize;
+        output().iFullName.Copy( iCodeSeg[params().iIndex].iFullName );
+        output().iRunAddress = iCodeSeg[params().iIndex].iRunAddress;
+        
+        // Writes a descriptor to a thread's process.
+        error = Kern::ThreadDesWrite( aMessage.Client(), aCodesegInfo, output, 0 ); 
+        
+        if ( KErrNone != error )
+            {
+            LOGSTR2( "ATDD ThreadDesWrite error %d", error );
+            }
+        }
+    
+    // Exits thread critical section and releases code segment mutex.
+    Kern::EndAccessCode();
+    
+    return error;
+    #endif
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::GetLibraryInfo()
+// Acquires library information.
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::GetLibraryInfo( TAny* aLibraryInfo, 
+                                          TThreadMessage& aMessage )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::GetLibraryInfo()" );
+
+    // Temporary variable for reading informationfrom the user side
+    TLibraryInfoBuf params;
+
+    // Reads a descriptor from a thread's process.
+    TInt error = Kern::ThreadDesRead( aMessage.Client(), aLibraryInfo, params, 0 );  
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesRead error %d", error );
+        return error;
+        } 
+
+    if ( params().iIndex < 0 )
+        {
+        return KErrArgument;
+        }
+   
+    // Gets the current process
+    Kern::Containers()[ EProcess ]->Wait();
+    DProcess& process = *Kern::ProcessFromId( params().iProcessId );
+    Kern::Containers()[ EProcess ]->Signal();
+    
+    if ( NULL == &process )
+        {
+        return KErrNotFound;
+        }
+    
+    // Temporary variable for collecting information from the library
+    TLibraryInfoBuf output;
+        
+    // Enters thread critical section and acquires code segment mutex.
+    Kern::AccessCode();
+
+    // Iterate to find the right library
+    if ( params().iIndex < process.iDynamicCode.Count() )
+        {
+        // Acquire entry to the codeseg
+        SCodeSegEntry entry = process.iDynamicCode[ params().iIndex ];
+        
+        // Acquire library information
+        entry.iLib->AppendName( output().iLibraryName );//lint !e64 !e1514
+        output().iRunAddress = entry.iSeg->iRunAddress;
+        output().iSize = entry.iSeg->iSize;
+        
+        // Writes a descriptor to a thread's process.
+        error = Kern::ThreadDesWrite( aMessage.Client(), aLibraryInfo, output, 0 ); 
+        
+        if ( KErrNone != error )
+            {
+            LOGSTR2( "ATDD ThreadDesWrite error %d", error );
+            } 
+        
+        // Exits thread critical section and releases code segment mutex.
+        Kern::EndAccessCode();
+        
+        return error;
+        }
+    else
+        {
+        // Exits thread critical section and releases code segment mutex.
+        Kern::EndAccessCode();
+        
+        return KErrArgument;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::MainThreadAllocator()
+// Acquires information about process main thread RAllocator
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::MainThreadAllocator( TAny* aMainThreadParams, 
+                                               TThreadMessage& aMessage )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::MainThreadAllocator()" );
+
+    // Temporary variable for reading client side parameters
+    TMainThreadParamsBuf params;
+
+    // Reads a descriptor from a thread's process.
+    TInt error = Kern::ThreadDesRead( aMessage.Client(), 
+                                      aMainThreadParams, 
+                                      params, 
+                                      0 );  
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesRead error %d", error );
+        return error;
+        } 
+    
+    // Gets the current process
+    Kern::Containers()[ EProcess ]->Wait();
+    DProcess& process = *Kern::ProcessFromId( params().iProcessId );
+    Kern::Containers()[ EProcess ]->Signal();
+    
+    if ( NULL == &process )
+        {
+        return KErrNotFound;
+        }
+
+    // Gets the current process
+    Kern::AccessCode();
+
+    // Temporary variable for collecting information from the RAllocator
+    TMainThreadParamsBuf output;
+
+    // Aqcuire a reference to the main thread RAllocator
+    output().iAllocator = process.FirstThread()->iAllocator;
+
+    // Is this only thread in the process
+    output().iAlone = process.iThreadQ.First()->Alone();
+
+    // Exits thread critical section and releases code segment mutex.
+    Kern::EndAccessCode();
+
+    // Writes a descriptor to a thread's process.
+    error = Kern::ThreadDesWrite( aMessage.Client(), 
+                                  aMainThreadParams, 
+                                  output, 
+                                  0 ); 
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesWrite error %d", error );
+        } 
+
+    return error;
+    }    
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::ThreadStack()
+// Acquires main thread stack address
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::ThreadStack( TAny* aThreadStack, 
+                                       TThreadMessage& aMessage )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::ThreadStack()" );
+
+    // Temporary variable for reading client side parameters
+    TThreadParamsBuf params;
+
+    // Reads a descriptor from a thread's process.
+    TInt error = Kern::ThreadDesRead( aMessage.Client(), 
+                                      aThreadStack, 
+                                      params, 
+                                      0 );  
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesRead error %d", error );
+        return error;
+        } 
+    
+    // Gets the current process
+    Kern::Containers()[ EThread ]->Wait();
+    DThread& thread = *Kern::ThreadFromId( params().iThreadId );
+    Kern::Containers()[ EThread ]->Signal();
+    
+    if ( NULL == &thread )
+        {
+        return KErrNotFound;
+        }
+    
+    // Gets the current process
+    Kern::AccessCode();
+
+    // Temporary variable for collecting information from the RAllocator
+    TThreadParamsBuf output;
+
+    // Stack address of the main thread
+    output().iStackAddress = thread.iUserStackRunAddress;
+    output().iStackSize    = thread.iUserStackSize;
+
+    // Exits thread critical section and releases code segment mutex.
+    Kern::EndAccessCode();
+
+    // Writes a descriptor to a thread's process.
+    error = Kern::ThreadDesWrite( aMessage.Client(), 
+                                  aThreadStack, 
+                                  output, 
+                                  0 ); 
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesWrite error %d", error );
+        } 
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::GetProcessHandleInfo()
+// Acquires information about process global handles
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::GetProcessHandleInfo( TAny* aProcessHandleInfo,
+                                                TThreadMessage& aMessage )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::GetProcessHandleInfo()" );
+
+    // Temporary variable for collecting information from the codeseg
+    TProcessHandleInfoBuf params;
+
+    // Reads a descriptor from a thread's process.
+    TInt error = Kern::ThreadDesRead( aMessage.Client(), 
+                                      aProcessHandleInfo, 
+                                      params, 
+                                      0 );  
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesRead error %d", error );
+        return error;
+        } 
+
+    // Gets the current process
+    Kern::Containers()[ EProcess ]->Wait();
+    DProcess& process = *Kern::ProcessFromId( params().iProcessId );
+    Kern::Containers()[ EProcess ]->Signal();
+    
+    if ( NULL == &process )
+        {
+        return KErrNotFound;
+        }
+    
+    // Variable holding wanted information
+    TProcessHandleInfoBuf output;
+
+    // Enters thread critical section and acquires code segment mutex.
+    Kern::AccessCode();
+
+    // Get the process thread queue.
+    SDblQue queue = process.iThreadQ;
+    error = KErrNotFound;
+        
+    // Tests whether this doubly linked list is empty.
+    if ( !queue.IsEmpty() )
+        {
+        // Gets a pointer to the first item in this doubly linked list.
+        SDblQueLink* link = queue.First();
+        DThread* thread = _LOFF( link, DThread, iProcessLink );
+
+        if ( thread )
+            {
+            
+#ifdef MCL_ROBJECTIX
+            TInt threadHandles( thread->iHandles.ActiveCount() );
+#else
+            TInt threadHandles( thread->iHandles->ActiveCount() );
+#endif
+            
+            // Aqcuire thread information
+            //thread->AppendName( output.iThreadName );
+            output().iUserStackRunAddress = thread->iUserStackRunAddress;
+            output().iUserStackSize = thread->iUserStackSize;
+            output().iThreadHandleCount = threadHandles;
+            
+#ifdef MCL_ROBJECTIX
+            RObjectIx objectIx = process.iHandles;
+            output().iProcessHandleCount = objectIx.ActiveCount();
+#else
+            DObjectIx* objectIx = process.iHandles;
+            output().iProcessHandleCount = objectIx->ActiveCount();
+#endif
+                        
+            // Writes a descriptor to a thread's process.
+            error = Kern::ThreadDesWrite( aMessage.Client(), 
+                                          aProcessHandleInfo, 
+                                          output, 
+                                          0 ); 
+            
+            if ( KErrNone != error )
+                {
+                LOGSTR2( "ATDD ThreadDesWrite error %d", error );
+                } 
+            }
+        }
+
+    // Exits thread critical section and releases code segment mutex.
+    Kern::EndAccessCode();
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::GetCurrentHandleCount()
+// Acquires a process's current handle count
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::GetCurrentHandleCount( TAny* aProcessHandles,
+                                                 TThreadMessage& aMessage )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::GetCurrentHandleCount()" );
+
+    // Temporary variable for collecting information from the codeseg
+    TATProcessHandlesBuf params;
+    
+    // Reads a descriptor from a thread's process.
+    TInt error = Kern::ThreadDesRead( aMessage.Client(), 
+                                      aProcessHandles, 
+                                      params, 
+                                      0 );
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesRead error %d", error );
+        return error;
+        } 
+    
+    // Gets the current process
+    Kern::Containers()[ EProcess ]->Wait();
+    DProcess* process = Kern::ProcessFromId( params().iProcessId );
+    Kern::Containers()[ EProcess ]->Signal();
+    
+    if ( NULL == process )
+        {
+        return KErrNotFound;
+        }
+
+    // Variable holding wanted information
+    TATProcessHandlesBuf output;
+    
+    // Enters thread critical section and acquires code segment mutex.
+    Kern::AccessCode();
+    
+    SDblQue queue = process->iThreadQ;
+    SDblQueLink* link = queue.First();
+    TInt threadHandles( 0 );
+    
+    // Iterate through current processes's threads
+    while ( link != queue.Last() )
+        {
+        DThread* thread = _LOFF( link, DThread, iProcessLink );
+        
+#ifdef MCL_ROBJECTIX
+        threadHandles += thread->iHandles.ActiveCount();
+#else
+        threadHandles += thread->iHandles->ActiveCount();
+#endif
+        
+        link = link->iNext;
+        }
+
+    if ( link == queue.Last() )
+        {
+        DThread* thread = _LOFF( link, DThread, iProcessLink );
+
+#ifdef MCL_ROBJECTIX
+        threadHandles += thread->iHandles.ActiveCount();
+#else
+        threadHandles += thread->iHandles->ActiveCount();
+#endif
+        }
+    
+    output().iCurrentHandleCount = threadHandles;
+    
+    // Writes a descriptor to a thread's process.
+    error = Kern::ThreadDesWrite( aMessage.Client(), 
+                                  aProcessHandles, 
+                                  output, 
+                                  0 ); 
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesWrite error %d", error );
+        } 
+    
+    // Exits thread critical section and releases code segment mutex.
+    Kern::EndAccessCode();
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::ClientCount()
+// Acquires the count of current device driver users.
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::ClientCount( TAny* aClientCount,
+                                       TThreadMessage& aMessage )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::ClientCount()" );
+    
+    // Enters thread critical section and acquires code segment mutex.
+    Kern::AccessCode();
+    
+    // Variable holding wanted information
+    TClientCountBuf output;
+    
+    // Get the number of DLogicalChannelBase objects currently in existence which
+    // have been created from this LDD.
+    output().iClientCount = DLogicalChannelBase::iDevice->iOpenChannels;
+    LOGSTR2( "ATDD > iOpenChannels count: %d", output().iClientCount ); 
+    
+    // Writes a descriptor to a thread's process.
+    TInt error = Kern::ThreadDesWrite( aMessage.Client(), 
+                                       aClientCount, 
+                                       output, 
+                                       0 ); 
+    
+    if ( KErrNone != error )
+        {
+        LOGSTR2( "ATDD ThreadDesWrite error %d", error );
+        } 
+    
+    // Exits thread critical section and releases code segment mutex.
+    Kern::EndAccessCode();
+    
+    return error;
+    }
+
+#ifdef __WINSCW__
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::GetModuleDependencies()
+// Get module dependencies
+// -----------------------------------------------------------------------------
+//
+void DAnalyzeToolChannel::GetModuleDependencies( HMODULE aModule )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::GetModuleDependencies()" );
+
+    Emulator::TModule etm( aModule );
+    TUint32 dllSize( 0 );
+    // Temporary variable for collecting information from the codeseg
+    TCodesegInfo info;
+    TBool found( EFalse );
+    
+    const IMAGE_IMPORT_DESCRIPTOR* imports = etm.Imports();
+    while( imports->Characteristics != 0 )
+        {
+        // Reset flag
+        found = EFalse;
+        
+        // Get dll name
+        const TUint8* nameAddr = ( const TUint8* )( imports->Name + ( TInt )etm.iBase );
+        TPtrC8 namePtr( nameAddr );     
+        
+        // Get dll run address
+        Emulator::TModule imp_etm( ( PCSTR )etm.Translate( imports->Name ) );        
+        const TUint8* runAddr = ( const TUint8* )imp_etm.iBase;
+        
+        // Get dll size
+        const IMAGE_NT_HEADERS32* ntHeader = imp_etm.NtHeader();
+        dllSize = ntHeader->OptionalHeader.SizeOfImage;       
+        
+        // Check if DLL already exists in codesegment list
+        for( TInt i = 0; i < iCodeSeg.Count(); i++ )
+            {
+            if ( iCodeSeg[i].iFullName.Compare( namePtr ) == KErrNone )
+                {
+                found = ETrue;
+                break;
+                }
+            }
+        
+        if ( !found )
+            {
+            info.iSize = dllSize;
+            info.iFullName.Copy( namePtr );
+            info.iRunAddress = (TUint32) runAddr;  
+            // Append codesegment to array
+            iCodeSeg.Append( info );
+            }
+        imports++;
+        }
+    }
+  
+#endif // __WINSCW__
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolChannel::GetMemoryModel()
+// Acquires memory model system uses.
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolChannel::GetMemoryModel(TAny* aMemoryModel,
+                                        TThreadMessage& aMessage)
+    {
+    LOGSTR1( "ATDD DAnalyzeToolChannel::GetMemoryModel()" );
+   
+    // Model buffer.
+    TATMemoryModelBuf model;
+    // Get current model.
+    model().iMemoryModel = (TUint32) Kern::HalFunction( EHalGroupKernel, EKernelHalMemModelInfo, NULL, NULL );
+    model().iMemoryModel &= EMemModelTypeMask; // Mask out other stuff.
+    // Write it to client side.
+    TInt error = Kern::ThreadDesWrite( aMessage.Client(),
+                                        aMemoryModel,
+                                        model,
+                                        0);
+    if ( error != KErrNone )
+        {
+        LOGSTR2( "ATDD ThreadDesWrite error %d", error );
+        }
+    return error;
+    }
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/kerneleventhandler/src/analyzetooldevice.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,93 @@
+/*
+* 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 DAnalyzeToolDevice.
+*
+*/
+
+
+// INCLUDE FILES
+#include "analyzetooldevice.h"
+#include "analyzetoolchannel.h"
+#include "atlog.h"
+
+// ================= MEMBER FUNCTIONS =========================================
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolDevice::DAnalyzeToolDevice()
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+DAnalyzeToolDevice::DAnalyzeToolDevice()
+    {
+    LOGSTR1( "ATDD DAnalyzeToolDevice::DAnalyzeToolDevice()" );
+    // Set version number
+    iVersion = KAnalyzeToolLddVersion();
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolDevice::Install()
+// Second stage constructor.
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolDevice::Install()
+    {
+    LOGSTR1( "ATDD DAnalyzeToolDevice::Install()" );
+    // Set device name
+    return SetName( &KAnalyzeToolLddName );
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolDevice::GetCaps()
+// Gets the driver's capabilities.
+// -----------------------------------------------------------------------------
+//
+void DAnalyzeToolDevice::GetCaps( TDes8& /*aDes*/ ) const
+    {
+    LOGSTR1( "ATDD DAnalyzeToolDevice::GetCaps()" );
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolDevice::Create()
+// Creates the logical channel.
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolDevice::Create( DLogicalChannelBase*& aChannel )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolDevice::Create()" );
+
+    // create new channel
+    aChannel = new DAnalyzeToolChannel;
+
+    // check that everything is OK
+    return ( aChannel != NULL ) ? KErrNone : KErrNoMemory;
+    }
+
+// -----------------------------------------------------------------------------
+// DECLARE_STANDARD_LDD
+// Defines the entry point for a standard logical device driver (LDD),
+// and declares the ordinal 1 export function for creating 
+// the LDD factory object
+// -----------------------------------------------------------------------------
+//
+DECLARE_STANDARD_LDD()
+    {
+    LOGSTR1( "ATDD DECLARE_STANDARD_LDD()" );
+    return new DAnalyzeToolDevice;
+    }
+    
+// ================= OTHER EXPORTED FUNCTIONS =================================
+
+// None
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/kerneleventhandler/src/analyzetooleventhandler.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,427 @@
+/*
+* 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 DAnalyzeToolEventHandler.
+*
+*/
+
+
+// INCLUDE FILES
+#include "analyzetooleventhandler.h"
+#include <kernel/kern_priv.h>
+
+// CONSTANTS
+
+// The handler mutex literal
+_LIT( KHandlerMutexName, "AnalyzeToolHandlerMutex" );
+
+// The handle data mutex literal
+_LIT( KDataMutexName, "AnalyzeToolDataMutex" );
+
+
+// ================= MEMBER FUNCTIONS =========================================
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolEventHandler::Create()
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+TInt DAnalyzeToolEventHandler::Create( DLogicalDevice* aDevice,
+    const TUint aProcessId )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolEventHandler::Create()" );
+    TInt ret( KErrNone );
+    
+    // Store owner process ID
+    iProcessId = aProcessId;
+    LOGSTR2( "ATDD DAnalyzeToolEventHandler::Create > iProcessId %d", 
+            iProcessId );
+    
+    // Open the device
+    ret = aDevice->Open();
+    if ( ret != KErrNone )
+        return ret;
+    iDevice = aDevice;
+
+    // Create mutex for the handler
+    ret = Kern::MutexCreate( iHandlerMutex, KHandlerMutexName, KMutexOrdDebug );
+    if ( ret != KErrNone )
+        return ret;
+    // Create mutex for the data
+    ret = Kern::MutexCreate( iDataMutex, KDataMutexName, KMutexOrdDebug-1 );
+    if ( ret != KErrNone )
+        return ret;
+
+    // Add handler to the handler queue
+    return Add();
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolEventHandler::~DAnalyzeToolEventHandler()
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+DAnalyzeToolEventHandler::~DAnalyzeToolEventHandler()
+    {
+    LOGSTR1( "ATDD DAnalyzeToolEventHandler::~DAnalyzeToolEventHandler()" );
+    
+    CancelInformLibraryEvent();
+    
+    // Close the data mutex
+    if ( iDataMutex )
+        {
+        iDataMutex->Close( NULL );
+        }
+
+    // Close the handler mutex
+    if ( iHandlerMutex )
+        {
+        iHandlerMutex->Close( NULL );
+        }
+
+    // Close the device mutex
+    if ( iDevice )
+        {
+        iDevice->Close( NULL );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolEventHandler::EventHandler()
+// Function for receiving kernel events
+// -----------------------------------------------------------------------------
+//
+TUint DAnalyzeToolEventHandler::EventHandler( TKernelEvent aEvent, 
+    TAny* a1, TAny* a2, TAny* aThis )
+    {
+    
+    // Clarify the event type
+    switch ( aEvent)
+        {
+        case EEventRemoveLibrary:
+            {
+            LOGSTR1( "ATDD DAnalyzeToolEventHandler::EventHandler() - EEventRemoveLibrary" );
+            // Cast the pointer to the handler
+            DAnalyzeToolEventHandler* handler = 
+            ( ( DAnalyzeToolEventHandler* ) aThis );
+            // Create variable for library information
+            TLibraryEventInfo info;
+            // Set as library remove event
+            info.iEventType = TLibraryEventInfo::ELibraryRemoved;
+            // Handle the event
+            handler->HandleLibraryEvent( ( DLibrary* ) a1, ( DThread* ) a2, info );
+            break;
+            }
+        case EEventAddLibrary:
+            {
+            LOGSTR1( "ATDD DAnalyzeToolEventHandler::EventHandler() - EEventAddLibrary" );
+            // Cast the pointer to the handler
+            DAnalyzeToolEventHandler* handler = 
+            ( ( DAnalyzeToolEventHandler* ) aThis );
+            // Create variable for library information
+            TLibraryEventInfo info;
+            // Set as library remove event
+            info.iEventType = TLibraryEventInfo::ELibraryAdded;
+            // Handle the event
+            handler->HandleLibraryEvent( ( DLibrary* ) a1, ( DThread* ) a2, info );
+            break;
+            }
+        case EEventHwExc:
+            {
+            LOGSTR1( "ATDD DAnalyzeToolEventHandler::EventHandler() - EEventHwExc" );
+            break;
+            }
+        case EEventSwExc:
+            {
+            LOGSTR1( "ATDD DAnalyzeToolEventHandler::EventHandler() - EEventSwExc" );
+            break;
+            }
+        case EEventRemoveThread:
+            {
+            LOGSTR1( "ATDD DAnalyzeToolEventHandler::EventHandler() - EEventRemoveThread" );
+            break;
+            }
+        case EEventKillThread:
+            {
+            LOGSTR1( "ATDD DAnalyzeToolEventHandler::EventHandler() - EEventKillThread" );
+            
+            // Cast the pointer to the handler
+            DAnalyzeToolEventHandler* handler = 
+                ( ( DAnalyzeToolEventHandler* ) aThis );
+            
+            // Create variable for library information
+            TLibraryEventInfo info;
+            
+            // Set as kill thread event
+            info.iEventType = TLibraryEventInfo::EKillThread;
+            // Handle the event
+            handler->HandleKillThreadEvent( ( DThread* ) a1, info );
+            break;
+            }
+        default:
+            {
+            }
+            break;
+        }  
+    return ERunNext;
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolEventHandler::HandleLibraryEvent()
+// Handles the EEventAddLibrary and EEventRemoveLibrary events.
+// -----------------------------------------------------------------------------
+//
+void DAnalyzeToolEventHandler::HandleLibraryEvent( DLibrary* aLib, 
+    DThread* aThread, TLibraryEventInfo& aInfo )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolEventHandler::HandleLibraryEvent()" );
+    
+    // Aqcuire the handler mutex
+    Kern::MutexWait( *iHandlerMutex );
+
+    // Aqcuire the data mutex
+    Kern::MutexWait( *iDataMutex );
+    
+    TBool addInfo( EFalse );
+    
+    // Check the library event type
+    if ( aInfo.iEventType == TLibraryEventInfo::ELibraryAdded )
+        {
+        if ( aThread != NULL )
+            {
+            if ( iProcessId == aThread->iOwningProcess->iId )
+                {
+                LOGSTR1( "ATDD > Process id match" );
+                aInfo.iProcessId = aThread->iOwningProcess->iId;
+                addInfo = ETrue;
+                }
+            }
+        }
+    else if ( aInfo.iEventType == TLibraryEventInfo::ELibraryRemoved )
+        {
+        if ( aThread != NULL )
+            {
+            aInfo.iProcessId = aThread->iOwningProcess->iId;
+            }
+        else
+            {
+            aInfo.iProcessId = 0;
+            }
+        addInfo = ETrue;
+        }
+    
+    if ( addInfo )
+        {
+        // Store lib info
+        aLib->AppendName( aInfo.iLibraryName );//lint !e64 !e1514
+        aInfo.iSize = aLib->iCodeSeg->iSize;
+        aInfo.iRunAddress = aLib->iCodeSeg->iRunAddress;
+        // Store library event info to the array
+        iEventArray.Append( aInfo );
+        LOGSTR2( "ATDD > iEventArray.Count() = %d", iEventArray.Count() );
+        
+        // if client has subscribed the event it is queued
+        if ( iClientThread != NULL )
+            {
+            iEventDfc.Enque();
+            }
+        }
+     
+    // Release the data mutex
+    Kern::MutexSignal( *iDataMutex );
+
+    // Release the handler mutex
+    Kern::MutexSignal( *iHandlerMutex );
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolEventHandler::InformLibraryEvent()
+// Subscribes library event.
+// -----------------------------------------------------------------------------
+//
+void DAnalyzeToolEventHandler::InformLibraryEvent( TRequestStatus* aStatus, 
+                                                   TAny* aLibraryInfo,
+                                                   TThreadMessage& aMessage )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolEventHandler::InformLibraryEvent()" );
+
+    // Aqcuire the data mutex
+    Kern::MutexWait( *iDataMutex );  
+    
+    // Check if request from client which is already pending
+    DThread* current = aMessage.Client();
+    
+    LOGSTR2( "ATDD > Current Thread ID = %d", current->iId );
+ 
+    // Ensure that client doesn't subscribe service when there is a pending
+    // subscription
+    if ( NULL != iClientThread )
+        {
+        aMessage.PanicClient( KClientPanic, EPanicRequestPending );
+        }
+    else
+        {
+        // Store the client variable pointers
+        iClientThread         = current;
+        iClientRequestStatus  = aStatus;
+        iClientInfo           = aLibraryInfo;
+        }
+    
+    // Release the data mutex
+    Kern::MutexSignal( *iDataMutex );
+    
+    // Queue the event since now the client has subscribed it
+    iEventDfc.Enque();
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolEventHandler::CancelInformLibraryEvent
+// Cancels subscription of the library event.
+// -----------------------------------------------------------------------------
+//
+void DAnalyzeToolEventHandler::CancelInformLibraryEvent()
+    {
+    LOGSTR1( "ATDD DAnalyzeToolEventHandler::CancelInformLibraryEvent()" );
+    
+    iEventDfc.Cancel();
+    
+    // Aqcuire the data mutex
+    Kern::MutexWait( *iDataMutex );
+
+    if ( NULL != iClientThread && iEventArray.Count() > 0 )
+        {
+        // Signal the request as complete
+        Kern::RequestComplete( iClientThread, 
+                               iClientRequestStatus, 
+                               KErrCancel );
+        
+        iClientThread         = NULL;
+        iClientRequestStatus  = NULL;
+        iClientInfo           = NULL;
+
+        // Reset the event array
+        iEventArray.Reset();
+        }
+   
+    // Release the data mutex
+    Kern::MutexSignal( *iDataMutex );
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolEventHandler::HandleKillThreadEvent()
+// Handles the EEventKillThread events.
+// -----------------------------------------------------------------------------
+//
+void DAnalyzeToolEventHandler::HandleKillThreadEvent( DThread* aThread, 
+                                                      TLibraryEventInfo& aInfo )
+    {
+    LOGSTR1( "ATDD DAnalyzeToolEventHandler::HandleKillThreadEvent()" );
+    
+    // Aqcuire the handler mutex
+    Kern::MutexWait( *iHandlerMutex );
+
+    // Aqcuire the data mutex
+    Kern::MutexWait( *iDataMutex );
+    
+    aInfo.iProcessId = aThread->iOwningProcess->iId;
+    TBool alone( aThread->iOwningProcess->iThreadQ.First()->Alone() );
+    LOGSTR2( "ATDD > Is alone = %d", alone );
+    
+    // Check if this our process and is the only thread item.
+    if ( aInfo.iProcessId == iProcessId && !alone )
+        {
+        if ( aThread )
+            {
+            // Set current Thread id
+            LOGSTR2( "ATDD > Thread ID = %d", aThread->iId );
+            aInfo.iThreadId = aThread->iId;
+            // Append event to array (beginning of the array)
+            iEventArray.Insert( aInfo, 0 );
+            
+            // if client has subscribed the event it is queued
+            if ( iClientThread != NULL )
+                {
+                iEventDfc.Enque();
+                }
+            }
+        }
+    
+    // Release the data mutex
+    Kern::MutexSignal( *iDataMutex );
+
+    // Release the handler mutex
+    Kern::MutexSignal( *iHandlerMutex );
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolEventHandler::DoEventComplete()
+// Informs client about the occured event.
+// -----------------------------------------------------------------------------
+//
+void DAnalyzeToolEventHandler::DoEventComplete()
+    {
+    LOGSTR1( "ATDD DAnalyzeToolEventHandler::DoEventComplete()" );
+    
+    // Aqcuire the handler mutex
+    Kern::MutexWait( *iHandlerMutex );
+
+    // Aqcuire the data mutex
+    Kern::MutexWait( *iDataMutex );
+    
+    if ( NULL != iClientThread && iEventArray.Count() > 0 )
+        {
+        TInt ret = Kern::ThreadRawWrite( iClientThread, 
+                                         iClientInfo, 
+                                         &iEventArray[0],
+                                         sizeof( iEventArray[0] ) );
+        
+        LOGSTR2( "ATDD > ThreadRawWrite err = %d", ret );
+        
+        // Signal the request as complete
+        Kern::RequestComplete( iClientThread, 
+                               iClientRequestStatus, 
+                               ret );
+        
+        // Remove first item to array
+        iEventArray.Remove( 0 );
+        
+        // Compresses the array down to a minimum
+        iEventArray.Compress();
+        
+        // Ensure that pointers are set to NULL
+        iClientThread         = NULL;
+        iClientRequestStatus  = NULL;
+        iClientInfo           = NULL;
+        
+        LOGSTR2( "ATDD > iEventArray = %d", iEventArray.Count() );
+        }
+    
+    // Release the data mutex
+    Kern::MutexSignal( *iDataMutex );
+
+    // Release the handler mutex
+    Kern::MutexSignal( *iHandlerMutex );
+    }
+
+// -----------------------------------------------------------------------------
+// DAnalyzeToolEventHandler::EventDfc()
+// Static function for DFC events.
+// -----------------------------------------------------------------------------
+//
+void DAnalyzeToolEventHandler::EventDfc(TAny* aPtr)
+    {
+    LOGSTR1( "ATDD DAnalyzeToolEventHandler::EventDfc()" ); 
+    ( (DAnalyzeToolEventHandler*) aPtr )->DoEventComplete();
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/rom/analyzetool.iby	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2008 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 __ANALYZETOOL_IBY__
+#define __ANALYZETOOL_IBY__
+
+S60_APP_EXE(atool)
+
+#ifdef __S60_
+S60_APP_EXE(atconfigurationappgui)
+S60_APP_AIF_ICONS(atconfigurationappgui)
+S60_APP_RESOURCE(atconfigurationappgui)
+#ifdef S60_UPGRADABLE_APP_REG_RSC
+S60_UPGRADABLE_APP_REG_RSC(atconfigurationappgui)
+#else
+S60_APP_AIF_RSC(atconfigurationappgui)
+#endif
+#endif
+
+// Memory hook
+file=ABI_DIR\BUILD_DIR\atoolmemoryhook.dll           SHARED_LIB_DIR\atoolmemoryhook.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
+
+// Stub
+data=ZSYSTEM\Install\analyzetool_stub.sis                   \system\install\analyzetool_stub.sis
+
+#endif // __ANALYZETOOL_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/rom/analyzetool_rom.iby	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2008 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 __ANALYZETOOL_ROM_IBY__
+#define __ANALYZETOOL_ROM_IBY__
+
+
+// Kernel event handler
+device[VARID]=ABI_DIR\BUILD_DIR\atoolkerneleventhandler.ldd    SHARED_LIB_DIR\atoolkerneleventhandler.ldd
+
+
+#endif // __ANALYZETOOL_ROM_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/sis/AnalyzeTool.pkg	Thu Feb 11 15:51:35 2010 +0200
@@ -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:
+;
+
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"AnalyzeTool"},(0x20012432),1,8,0,TYPE=SA, RU
+
+;Localised Vendor name
+%{"Nokia Corporation"}
+
+;Unique Vendor name
+:"Nokia Corporation"
+
+;Supports Series 60 v 3.1
+[0x102032BE], 0, 0, 0, {"Series60ProductID"}
+
+;Supports S60 release 5.0
+[0x1028315F], 0, 0, 0, {"Series60ProductID"}
+
+"\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\atconfigurationappgui.exe"	        	-"!:\sys\bin\atconfigurationappgui.exe"
+"\epoc32\data\z\resource\apps\atconfigurationappgui.rsc"	        -"!:\resource\apps\atconfigurationappgui.rsc"
+"\epoc32\data\z\private\10003a3f\apps\atconfigurationappgui_reg.rsc"-"!:\private\10003a3f\import\apps\atconfigurationappgui_reg.rsc"
+"\epoc32\data\z\resource\apps\atconfigurationappgui_aif.mif"        -"!:\resource\apps\atconfigurationappgui_aif.mif"
+
+; Install console application
+"\epoc32\release\armv5\urel\atool.exe"-"!:\sys\bin\atool.exe"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/sis/AnalyzeTool_udeb.pkg	Thu Feb 11 15:51:35 2010 +0200
@@ -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:
+;
+
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"AnalyzeTool"},(0x20012432),1,8,0,TYPE=SA, RU
+
+;Localised Vendor name
+%{"Nokia Corporation"}
+
+;Unique Vendor name
+:"Nokia Corporation"
+
+;Supports Series 60 v 3.1
+[0x102032BE], 0, 0, 0, {"Series60ProductID"}
+
+;Supports S60 release 5.0
+[0x1028315F], 0, 0, 0, {"Series60ProductID"}
+
+"\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\udeb\atconfigurationappgui.exe"		        -"!:\sys\bin\atconfigurationappgui.exe"
+"\epoc32\data\z\resource\apps\atconfigurationappgui.rsc"		    -"!:\resource\apps\atconfigurationappgui.rsc"
+"\epoc32\data\z\private\10003a3f\apps\atconfigurationappgui_reg.rsc"-"!:\private\10003a3f\import\apps\atconfigurationappgui_reg.rsc"
+"\epoc32\data\z\resource\apps\atconfigurationappgui_aif.mif"        -"!:\resource\apps\atconfigurationappgui_aif.mif"
+
+; Install console application
+"\epoc32\release\armv5\udeb\atool.exe"-"!:\sys\bin\atool.exe"
\ No newline at end of file
Binary file memana/analyzetoolclient/sis/AnalyzeTool_udeb_s60-mcl.sis has changed
Binary file memana/analyzetoolclient/sis/AnalyzeTool_urel_s60-mcl.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/sis/analyzeTool_stub.pkg	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,41 @@
+;
+; 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:
+;
+
+;Languages
+&EN
+
+;Header
+#{"AnalyzeTool"}, (0x20012432), 1,7,3
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; 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\atconfigurationappgui.exe"
+""-"z:\resource\apps\atconfigurationappgui.rsc"
+""-"z:\private\10003a3f\import\apps\atconfigurationappgui_reg.rsc"
+""-"z:\resource\apps\atconfigurationappgui_aif.mif"
+;""-"z:\resource\apps\atconfigurationappgui.mbm"
+
+""-"z:\sys\bin\atool.exe"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/staticlib/group/atoolstaticlib.mmp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,34 @@
+/*
+* 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 AToolStaticLib.
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET        atoolstaticlib.lib
+TARGETTYPE    lib
+UID           0x1000008d 0x20018421//0x02DF7F96
+CAPABILITY    ALL -TCB
+
+SMPSAFE
+
+USERINCLUDE   ../../inc
+SOURCEPATH    ../src
+SOURCE        atoolstaticlib.cpp
+
+OS_LAYER_SYSTEMINCLUDE
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/staticlib/group/bld.inf	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,27 @@
+/*
+* 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
+../../dynamicmemoryhook/inc/customuser.h OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/customuser.h)
+
+PRJ_MMPFILES
+atoolstaticlib.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/staticlib/src/atoolstaticlib.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,130 @@
+/*
+* 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 file contains declarations of extern methods and definitions
+*                of overloaded User methods.
+*
+*/
+
+
+
+#include <analyzetool/customuser.h>
+#include "atlog.h"
+
+// -----------------------------------------------------------------------------
+// LogFileName()
+// Extern function for acquiring the log filename
+// -----------------------------------------------------------------------------
+// 
+GLREF_C const TFileName LogFileName();
+
+// -----------------------------------------------------------------------------
+// LogOption()
+// Extern function for acquiring logging option
+// -----------------------------------------------------------------------------
+// 
+GLREF_C TUint32 LogOption();
+
+// -----------------------------------------------------------------------------
+// IsDebug()
+// Extern function for acquiring UDEB/UREL information
+// -----------------------------------------------------------------------------
+// 
+GLREF_C TUint32 IsDebug();
+
+// -----------------------------------------------------------------------------
+// AtoolVersion()
+// Extern function for acquiring the version number
+// -----------------------------------------------------------------------------
+// 
+GLREF_C const TFileName AtoolVersion();
+
+// -----------------------------------------------------------------------------
+// AllocCallStackSize()
+// Extern function for acquiring max allocation call stack size
+// -----------------------------------------------------------------------------
+// 
+GLREF_C TUint32 AllocCallStackSize();
+
+// -----------------------------------------------------------------------------
+// FreeCallStackSize()
+// Extern function for acquiring max free call stack size
+// -----------------------------------------------------------------------------
+// 
+GLREF_C TUint32 FreeCallStackSize();
+
+// -----------------------------------------------------------------------------
+// User::Exit()
+// Overloaded User::Exit() function
+// -----------------------------------------------------------------------------
+// 
+void User::Exit( TInt aReason )
+    {   
+    LOGSTR2( "ATMH User::Exit %i", aReason ); 
+    CustomUser::Exit( aReason );
+    }
+
+// -----------------------------------------------------------------------------
+// User::Panic()
+// Overloaded User::Panic() function
+// -----------------------------------------------------------------------------
+//
+void User::Panic( const TDesC& aCategory, TInt aReason )
+    {
+    LOGSTR3( "ATMH User::Panic() %S %i", &aCategory, aReason );
+    CustomUser::Panic( aCategory, aReason );
+    }
+ 
+// -----------------------------------------------------------------------------
+// User::SetCritical()
+// Overloaded User::SetCritical() function which returns
+// KErrNone, if successful; KErrArgument, if EAllThreadsCritical is 
+// passed - this is a state associated with a process, and you use 
+// User::SetProcessCritical() to set it.
+// -----------------------------------------------------------------------------
+// 
+TInt User::SetCritical( TCritical aCritical )
+    {
+    LOGSTR2( "ATMH User::SetCritical() %i", aCritical );
+    return CustomUser::SetCritical( aCritical );
+    }
+
+// -----------------------------------------------------------------------------
+// User::SetProcessCritical()
+// Overloaded User::SetProcessCritical() function
+// 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.
+// -----------------------------------------------------------------------------
+// 
+TInt User::SetProcessCritical( TCritical aCritical )
+    {
+    LOGSTR2( "ATMH User::SetProcessCritical() %i", aCritical );
+    return CustomUser::SetProcessCritical( aCritical );
+    }
+    
+// -----------------------------------------------------------------------------
+// UserHeap::SetupThreadHeap()
+// Overloaded UserHeap::SetupThreadHeap function
+// -----------------------------------------------------------------------------
+//  
+TInt UserHeap::SetupThreadHeap( TBool aNotFirst, 
+                                SStdEpocThreadCreateInfo& aInfo )
+    {
+    LOGSTR1( "ATMH UserHeap::SetupThreadHeap()" );
+    
+    return CustomUser::SetupThreadHeap( aNotFirst, aInfo, LogFileName(), 
+    		LogOption(), IsDebug(), AtoolVersion(), AllocCallStackSize(), FreeCallStackSize() );
+    }
+  
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/client/bwins/atoolstorageserverclntu.def	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,26 @@
+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
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/client/eabi/atoolstorageserverclntu.def	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,27 @@
+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
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/client/group/atoolstorageserverclnt.mmp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,41 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/client/inc/atstorageserverclnt.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,380 @@
+/*
+* 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, KATMaxCallstackLength>& 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 S60
+        * 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 );
+        
+        /**
+        * Sets the logging mode of the given process.
+        * @param aProcessId The ID of the process whose logging mode should be set.
+        * @param aLoggingMode An enumeration telling the logging mode.
+        * @return KErrNone, if successful; KErrNotFound, if the requested process was
+        *   not found; otherwise one of the other system wide error codes.
+        */
+        IMPORT_C TInt SetLoggingMode( TUint aProcessId, TATLogOption aLoggingMode );
+        
+        /**
+        * 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 EATLogToXti; 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 EATLogToXti; 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
+        *   EATLogToXti; 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
+        *   EATLogToXti; 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.
+        */
+        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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/client/src/atstorageserverclnt.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,930 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/group/bld.inf	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,31 @@
+/*
+* 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
+../tsrc/group/storageservertest.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/inc/atstorageservercommon.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,76 @@
+/*
+* 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\\" );
+#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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/group/atoolstorageserver.mmp	Thu Feb 11 15:51:35 2010 +0200
@@ -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:  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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/inc/atdllinfo.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,96 @@
+/*
+* 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
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/inc/atdriveinfo.h	Thu Feb 11 15:51:35 2010 +0200
@@ -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:  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
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/inc/atdynprocessinfo.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,102 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/inc/atmemoryentry.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,98 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/inc/atstorageserver.h	Thu Feb 11 15:51:35 2010 +0200
@@ -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 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 aDllName The name of the DLL to be added.
+        * @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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/inc/atstorageserversession.h	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,587 @@
+/*
+* 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 XTI 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 LogProcessStartXtiL( 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 XTI 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 LogDllLoadXtiL( 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 XTI 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 LogDllUnloadXtiL( 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 XTI 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 LogMemoryAllocXtiL( 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.
+		* @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 XTI 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 LogMemoryFreedXtiL( 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 XTI channel. Then, the method
+        * logs information on process ending into XTI 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 LogProcessEndXtiL( 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 CheckMemoryAddressXti( 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 EATLogToXti; 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 EATLogToXti; 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
+        *   EATLogToXti; 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
+        *   EATLogToXti; 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 XTI channel.
+        * @param aError The error code to be logged.
+        */
+        void HandleErrorXti( 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 XTI 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 EATLogToXti;
+        */
+        TInt LogThroughXti( 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 XTI channel(If logging mode is EATLogToXti) 
+		* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/src/atdllinfo.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,102 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/src/atdriveinfo.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,170 @@
+/*
+* 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 );
+			aPath.Append( KATDataFilePath );       
+						
+			// 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/src/atdynprocessinfo.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,94 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/src/atmemoryentry.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,84 @@
+/*
+* 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;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/src/atstorageserver.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,452 @@
+/*
+* 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/server/src/atstorageserversession.cpp	Thu Feb 11 15:51:35 2010 +0200
@@ -0,0 +1,3397 @@
+/*
+* 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 EATLogToXti:
+                    {
+                    iError = LogProcessStartXtiL( 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 EATLogToXti:
+                    {
+                    iError = LogDllLoadXtiL( 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 EATLogToXti:
+                    {
+                    iError = LogDllUnloadXtiL( 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 EATLogToXti:
+                    {
+                    iError = LogMemoryAllocXtiL( 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 EATLogToXti:
+                    {
+                    iError = LogMemoryFreedXtiL( 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 EATLogToXti:
+                    {
+                    iError = LogProcessEndXtiL( 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 EATLogToXti:
+                    {
+                    iError = CheckMemoryAddressXti( 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 == EATLogToXti && iError == KErrNoMemory )
+            {
+            HandleErrorXti( 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::LogProcessStartXtiL()
+// -----------------------------------------------------------------------------
+//    
+TInt CATStorageServerSession::LogProcessStartXtiL( const RMessage2& aMessage )
+    {
+    LOGSTR1( "STSE TInt CATStorageServerSession::LogProcessStartXtiL()" );
+    
+    // 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 XTI  
+    
+    // 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 XTI
+    TBuf<KProcessStartBufLength> xtiBuf;
+    xtiBuf.Copy( loggingBuf );
+    RDebug::Print( KXtiMessage, processId ,&xtiBuf );
+    
+    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::LogDllLoadXtiL()
+// -----------------------------------------------------------------------------
+//    
+TInt CATStorageServerSession::LogDllLoadXtiL( const RMessage2& aMessage )
+    {
+    LOGSTR1( "STSE TInt CATStorageServerSession::LogDllLoadXtiL()" );
+    
+    // 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> xtiBuf;
+    xtiBuf.Copy( loggingBuf );
+    RDebug::Print( KXtiMessage, iProcessId ,&xtiBuf );
+    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::LogDllUnloadXtiL()
+// -----------------------------------------------------------------------------
+//    
+TInt CATStorageServerSession::LogDllUnloadXtiL( const RMessage2& aMessage )
+    {
+    LOGSTR1( "STSE TInt CATStorageServerSession::LogDllUnloadXtiL()" );
+    
+    // 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> xtiBuf;
+    xtiBuf.Copy( loggingBuf );
+    RDebug::Print( KXtiMessage, iProcessId ,&xtiBuf );
+    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::LogMemoryAllocXtiL()
+// -----------------------------------------------------------------------------
+//    
+TInt CATStorageServerSession::LogMemoryAllocXtiL( const RMessage2& aMessage )
+    {
+    LOGSTR1( "STSE TInt CATStorageServerSession::LogMemoryAllocXtiL()" );
+    
+    // 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::LogMemoryAllocXtiL() 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* xtiBuf = HBufC::NewL( KMemAllocBufLength );
+    TPtr xtiPtr( xtiBuf->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
+    xtiPtr.Append( KMemoryAllocHeader );
+    
+    // Append the start address of this allocation in the 32-bit (max 8 characters)
+    // hexadecimal text format.
+    xtiPtr.AppendNum( memAddress, EHex );
+    
+    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
+    // format
+    xtiPtr.Append( KSpaceXti );
+    xtiPtr.AppendNum( timeFrom1970, EHex );
+    
+    // Append the size of the allocation in the 32-bit (max 8 characters) hexadecimal
+    // text format.
+    xtiPtr.Append( KSpaceXti );
+    xtiPtr.AppendNum( size, EHex );
+    
+    // Append call stack address count
+    xtiPtr.Append( KSpaceXti );
+    xtiPtr.AppendNum( addrCount, EHex );
+    
+    // Calculate last item length
+    TInt lastItemLength( KXtiMessage().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 ( xtiPtr.Length() <= 0 )
+            {                
+            // Create alloc fragment message header
+            xtiPtr.Append( KMemoryAllocFragment );
+            xtiPtr.AppendNum( memAddress, EHex );
+            xtiPtr.Append( KSpaceXti );
+            xtiPtr.AppendNum( timeFrom1970, EHex );
+            xtiPtr.Append( KSpaceXti );        
+            xtiPtr.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
+        xtiPtr.AppendFormat( KHexaNumberXti, callStackAddr );
+        
+        // Move the pos variable one word onwards.
+        pos += KWordSize;
+        
+        // Check if buffer max length exceed
+        if ( lastItemLength + xtiPtr.Length() >= KMemAllocBufLength )
+            {
+            xtiPtr.Append( KNewLineXti );
+            // Log through XTI channel 
+            RDebug::Print( KXtiMessage, iProcessId, xtiBuf );
+            // Empty XTI buffer
+            xtiPtr.Delete( 0, xtiPtr.MaxLength() );
+            }
+        }
+    
+    // Send the last message if exists
+    if ( xtiPtr.Length() > 0 )
+        {
+        xtiPtr.Append( KNewLineXti );
+        
+        // Log through XTI channel 
+        RDebug::Print( KXtiMessage, iProcessId, xtiBuf );
+        }
+    
+    delete xtiBuf;
+    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::LogMemoryFreedXtiL()
+// -----------------------------------------------------------------------------
+//    
+TInt CATStorageServerSession::LogMemoryFreedXtiL( const RMessage2& aMessage )
+    {
+    LOGSTR1( "STSE TInt CATStorageServerSession::LogMemoryFreedXtiL()" );
+    
+    // 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::LogMemoryFreedXti() 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* xtiBuf = HBufC::NewL( KMemFreedBufLength );
+    TPtr xtiPtr( xtiBuf->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
+    xtiPtr.Append( KMemoryFreedHeader );
+    
+    // Append the start address of this allocation in the 32-bit (max 8 characters)
+    // hexadecimal text format.
+    xtiPtr.AppendNum( memAddress, EHex );    
+    
+	// Append the current time in the 64-bit (max 16 characters) hexadecimal text
+	// format
+	xtiPtr.Append( KSpaceXti );
+	xtiPtr.AppendNum( timeFrom1970, EHex );
+			
+    // Append call stack address count
+    xtiPtr.Append( KSpaceXti );
+    xtiPtr.AppendNum( addrCount, EHex );
+    
+    // Packet number
+    TUint packetNumber( 1 );
+    
+    // Calculate last item length
+    TInt lastItemLength( KXtiMessage().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 ( xtiPtr.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
+            xtiPtr.Append( KMemoryFreedFragment );
+            xtiPtr.AppendNum( memAddress, EHex );
+            xtiPtr.Append( KSpaceXti );    
+			xtiPtr.AppendNum( timeFrom1970, EHex );
+			xtiPtr.Append( KSpaceXti );	
+            xtiPtr.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
+        xtiPtr.AppendFormat( KHexaNumberXti, callStackAddr );
+        
+        // Move the pos variable one word onwards.
+        pos += KWordSize;
+        
+        // Check if buffer max length exceed
+        if ( lastItemLength + xtiPtr.Length() >= KMemFreedBufLength )
+            {
+            xtiPtr.Append( KNewLineXti );
+            // Log through XTI channel 
+            RDebug::Print( KXtiMessage, iProcessId, xtiBuf );
+            // Empty XTI buffer
+            xtiPtr.Delete( 0, xtiPtr.MaxLength() );
+            }
+        }
+    
+    // Send the last message if exists
+    if ( xtiPtr.Length() > 0 )
+        {
+        xtiPtr.Append( KNewLineXti );
+        
+        // Log through XTI channel 
+        RDebug::Print( KXtiMessage, iProcessId, xtiBuf );
+        }
+        
+    delete xtiBuf;
+    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::LogProcessEndXtiL()
+// -----------------------------------------------------------------------------
+//    
+TInt CATStorageServerSession::LogProcessEndXtiL( const RMessage2& aMessage )
+    {
+    LOGSTR1( "STSE TInt CATStorageServerSession::LogProcessEndXtiL()" );
+    
+    // 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::LogProcessEndXtiL() 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> xtiBuf;
+        
+        // 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 );
+        
+        xtiBuf.Copy( loggingBuf );
+    
+        // Log through XTI channel 
+        RDebug::Print( KXtiMessage, iProcessId , &xtiBuf );
+        }
+
+    //////////////////////////////////////////////
+    // Log process end
+    //////////////////////////////////////////////
+    
+    // Make a buffer that will be logged
+    TBuf<KProcessEndBufLength> processEndBuf;    
+    processEndBuf.AppendFormat( KProcessEndXti, 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( KNewLineXti );
+    
+    // Log through XTI channel
+    RDebug::Print( KXtiMessage, 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::CheckMemoryAddressXti()
+// Checks if some memory address can be found
+// -----------------------------------------------------------------------------
+//
+TInt CATStorageServerSession::CheckMemoryAddressXti( const RMessage2& aMessage )
+    {
+    LOGSTR1( "STSE TInt CATStorageServerSession::CheckMemoryAddressXti()" );
+    
+    // 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 XTI
+    // and copy the contents
+    TBuf<KATMaxSubtestIdLength> subTestNameXTI;
+    subTestNameXTI.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 XTI
+    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( KSpaceXti );
+    
+    // Append the sub test ID
+    loggingBuf.Append( subTestNameXTI );
+
+    // Append a space
+    loggingBuf.Append( KSpaceXti );
+    
+    // Append current handle leak count
+    loggingBuf.AppendNum( handleCount );
+    
+    // Append a new line
+    loggingBuf.Append( KNewLineXti );
+    
+    // Log the string through XTI
+    iError = sessionObject->LogThroughXti( 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> xtiBuf;
+	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 );
+		xtiBuf.Copy( dllBuf );
+		
+		// Log the string through XTI
+		iError = sessionObject->LogThroughXti( xtiBuf );
+		if ( iError != KErrNone )
+			{
+			LOGSTR2( "STSE > LogThroughXti() 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 XTI,
+    // and copy the contents
+    TBuf<KATMaxSubtestIdLength> subTestNameXTI;
+    subTestNameXTI.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 XTI
+    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( KSpaceXti );
+    
+    // Append the sub test ID
+    loggingBuf.Append( subTestNameXTI );
+
+    // Append a space
+    loggingBuf.Append( KSpaceXti );
+    
+    // Append current handle leak count
+    loggingBuf.AppendNum( handleCount );
+    
+    // Append a new line
+    loggingBuf.Append( KNewLineXti );
+    
+    // Log the string through XTI
+    iError = sessionObject->LogThroughXti( 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 XTI
+    // and copy the contents
+    TBuf<KATMaxSubtestIdLength> subTestNameXTI;
+    subTestNameXTI.Copy( subTestName );
+
+    // Make a buffer for logging thru XTI
+    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( KSpaceXti );
+    
+    // Append the sub test ID
+    loggingBuf.Append( subTestNameXTI );
+    
+    // Append a new line
+    loggingBuf.Append( KNewLineXti );
+    
+    // Log the string through XTI
+    iError = LogThroughXti( 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> xtiBuf;
+	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 );
+		xtiBuf.Copy( dllBuf );
+		
+		// Log the string through XTI
+		iError = LogThroughXti( xtiBuf );
+		if ( iError != KErrNone )
+			{
+			LOGSTR2( "STSE > LogThroughXti() 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 XTI,
+    // and copy the contents
+    TBuf<KATMaxSubtestIdLength> subTestNameXTI;
+    subTestNameXTI.Copy( subTestName );
+
+    // Make a buffer for logging thru XTI
+    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( KSpaceXti );
+    
+    // Append the sub test ID
+    loggingBuf.Append( subTestNameXTI );
+    
+    // Append a new line
+    loggingBuf.Append( KNewLineXti );
+    
+    // Log the string through XTI
+    iError = LogThroughXti( 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 XTI 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 == EATLogToXti )
+        {
+        // Make a buffer for logging to XTI
+        TBuf<KCancelBufLength> xtiBuf;
+        xtiBuf.Copy( loggingBuf );
+        
+        // Write the buffer into the XTI channel
+        RDebug::Print( KXtiMessage, processId ,&xtiBuf );
+        }
+    
+    // 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::HandleErrorXti()
+// Internally used for handling error situations.
+// -----------------------------------------------------------------------------
+//    
+void CATStorageServerSession::HandleErrorXti( TInt aError )
+    {
+    LOGSTR1( "STSE void CATStorageServerSession::HandleErrorXti()" );
+    
+     // Get the current universal time
+    TInt64 timeFrom1970( GetTime() );
+        
+    // Make a buffer that will be logged
+    TBuf<KErrOccuredBufLength> xtiBuf;
+     
+    // Write the error code to the buffer  
+    xtiBuf.Format( KErrorOccuredXti, aError );
+       
+    // Append the current time in the 64-bit (max 16 characters) hexadecimal text
+    // format
+    xtiBuf.AppendNum( timeFrom1970, EHex );
+    
+    // Append a new line
+    xtiBuf.Append( KNewLineXti );
+                 
+    RDebug::Print( KXtiMessage, iProcessId , &xtiBuf );
+    }
+
+// -----------------------------------------------------------------------------
+// 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 XTI 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::LogThroughXti()
+// -----------------------------------------------------------------------------
+//
+TInt CATStorageServerSession::LogThroughXti( const TDesC& aLogString ) const
+    {
+    LOGSTR1( "STSE TInt CATStorageServerSession::LogThroughXti()" );
+
+    // Return KErrNotSupported, if a logging session is not currently ongoing, or
+    // the logging mode is not EATLogToXti
+    if ( !iLoggingOngoing || iLogOption != EATLogToXti)
+        {
+        return KErrNotSupported;
+        }
+        
+    RDebug::Print( KXtiMessage, 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 EATLogToXti:
+            {            
+            // Make a buffer that will be logged
+            TBuf<KEndAbnormalBufLength> xtiBuf;
+            
+            // Write the process id to the buffer  
+            xtiBuf.Format( KProcessEndAbnormalXti, iProcessId );
+            
+            // Append the current time in the 64-bit (max 16 characters) hexadecimal text
+            // format         
+            xtiBuf.AppendNum( timeFrom1970, EHex );
+                
+            // Append a new line
+            xtiBuf.Append( KNewLineXti );
+            
+            // Write the buffer into the XTI channel
+            RDebug::Print( KXtiMessage, iProcessId, &xtiBuf );
+            }
+        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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/sis/atstorageserver.pkg	Thu Feb 11 15:51:35 2010 +0200
@@ -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:
+;
+;
+; An installation file for AnalyzeTool StorageServer
+;
+
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"ATStorageServer"},(0xA22E6C80),1,8,0
+
+;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"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/storageserver/sis/atstorageserver_udeb.pkg	Thu Feb 11 15:51:35 2010 +0200
@@ -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:
+;
+;
+; An installation file for AnalyzeTool StorageServer
+;
+
+;Language - standard language definitions
+&EN
+
+; standard SIS file header
+#{"ATStorageServer"},(0xA22E6C80),1,8,0
+
+;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"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/memana/analyzetoolclient/symbian_version.hrh	Thu Feb 11 15:51:35 2010 +0200
@@ -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: Symbian version configuration file 
+*
+*/
+
+#ifndef __SYMBIAN_VERSION_HRH
+#define __SYMBIAN_VERSION_HRH
+
+// S60 and Symbian version number enumeration definitions
+
+#define S60_30                                              30
+#define S60_31                                              31
+#define S60_32                                              32
+#define S60_50                                              50
+#define S60_51                                              91
+#define S60_52                                              92
+#define SYMBIAN_1                                           50
+#define SYMBIAN_2                                           91
+#define SYMBIAN_3                                           92
+#define SYMBIAN_4                                           101
+//When creating new enumerations please check the code if there's >= and <= used correctly
+
+/**
+ * Defines the S60 or Symbian version used by this component. This flag can be
+ * used to variate the source code based on the SDK in use. The value of the
+ * flag should be always changed to reflect the current build environment.
+ */
+#define SYMBIAN_VERSION_SUPPORT                              SYMBIAN_3
+
+
+#endif  // __SYMBIAN_VERSION_HRH