# HG changeset patch # User Matti Laitinen # Date 1276592064 -10800 # Node ID 6a82cd05fb1eebe13308d0724e58d58d76cbba4b # Parent 3ff3fecb12fefbd6c2fc62e746ac69b8629ac769 Remove PI Profiler and AnalyzeTool since those are nowadays integrated to RnD tools packages diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/install/addr2line.exe Binary file memana/analyzetoolclient/commandlineengine/install/addr2line.exe has changed diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/install/atool.exe Binary file memana/analyzetoolclient/commandlineengine/install/atool.exe has changed diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/install/binutils-2.19.1-src.zip Binary file memana/analyzetoolclient/commandlineengine/install/binutils-2.19.1-src.zip has changed diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/install/xerces-c_2_7.dll Binary file memana/analyzetoolclient/commandlineengine/install/xerces-c_2_7.dll has changed diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/group/atool.vcproj --- a/memana/analyzetoolclient/commandlineengine/internal/group/atool.vcproj Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,375 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/ATCommonDefines.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/ATCommonDefines.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,563 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Common 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 vBuildCmd; //Build command split in vector. - string sPlatform; //Platform. - string sBuildType; //Build type (udeb/urel). - string sFeatureVariant; - vector 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 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/CATBase.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/CATBase.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,384 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Definitions for 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 list of files in folder - */ - static vector 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/CATDatParser.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/CATDatParser.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,282 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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* 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& 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 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 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* 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 m_vHandleLeaks; - - // Module related - vector m_vDllLoadModList; - vector 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 m_vMemoryAddress; - -}; -#endif -//EOF diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/CATDataSaver.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/CATDataSaver.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,187 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Declarations for the class CATDataSaver. -* -*/ - - -#ifndef __CATDATASAVER_H__ -#define __CATDATASAVER_H__ - -#include -#include -#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 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/CATMemoryAddress.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/CATMemoryAddress.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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* 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/CATMmp.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/CATMmp.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/CATModule2.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/CATModule2.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,547 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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 m_vSources; - // Listing data. - vector m_vLineInFile; - // Modules map data (symbols). - vector 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/CATParseTraceFile.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/CATParseTraceFile.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,73 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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 vData; - string sSubTestName; - string sStartTime; - string sEndTime; - string sSubTestStartHandleCount; - string sSubTestEndHandleCount; -}; - -class CProcessData : public CATAllocs -{ -public: - bool bProcessOnGoing; - int iProcessID; - vector vData; - vector vHandleLeaks; - vector vSubTests; -}; - -#endif diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/CATParseXML.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/CATParseXML.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/CATProject.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/CATProject.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,626 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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& 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& 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 m_vModules; - // Static libraries. - vector m_vStaticLibraries; - // Unsupported project modules. - vector 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 m_vTargetModules; - // Binary target (used in analyse). - string m_sBinaryTarget; - // User given datafile to analyse. - string m_sDataFile; - // - vector 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/cataddr2line.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/cataddr2line.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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 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 SplitToStrings( string& sMultiLineString ); - - //Debugging for addr2line task. - //ofstream debug; -}; - -#endif diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/cataddr2lineserver.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/cataddr2lineserver.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/catalloc.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/catalloc.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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 m_vCallStack; - - // Get alloc string after address ( time, size, call stack). - string GetAllocString( void ); -}; -#endif -//EOF diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/catallocs.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/catallocs.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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& vLeakList); - - /** - * Clear leaks. - */ - void ClearAllocs( void ); -#ifndef MODULE_TEST -private: -#endif - // Allocation storage. - map m_vAllocs; -}; -#endif -//EOF diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/catdbghelper.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/catdbghelper.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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 m_vMapFileFuncList; - // Binary in file system. - PSTR m_pBinaryFile; -}; \ No newline at end of file diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/catfilereader.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/catfilereader.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/catromsymbol.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/catromsymbol.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,146 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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 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& 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 m_vRomFiles; - // Cached rom symbols. - vector m_vRomCache; - // All rom symbols. - vector m_vRomSymbols; - // Rom start address. - unsigned long m_iRomStartAddress; - // Rom end address. - unsigned long m_iRomEndAddress; - - // Rofs symbol file(s) - vector m_vRofsFiles; - // Rofs binaries - vector m_vRofsBinaries; - - // Error message. - string m_sErrorMessage; -}; -#endif \ No newline at end of file diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/iaddresstoline.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/iaddresstoline.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/inc/stdafx.h --- a/memana/analyzetoolclient/commandlineengine/internal/inc/stdafx.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* -* 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 -#include -#endif - -#include -#include //ifstream,ofstream -#include -#include //string -#include //string -#include //stringstream -#include // cout -#include // map -#include \ No newline at end of file diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/lib/xerces-c_2.lib Binary file memana/analyzetoolclient/commandlineengine/internal/lib/xerces-c_2.lib has changed diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/src/CATBase.cpp --- a/memana/analyzetoolclient/commandlineengine/internal/src/CATBase.cpp Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1245 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Definitions for the class 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 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 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 "; - 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 diff -r 3ff3fecb12fe -r 6a82cd05fb1e memana/analyzetoolclient/commandlineengine/internal/src/CATDatParser.cpp --- a/memana/analyzetoolclient/commandlineengine/internal/src/CATDatParser.cpp Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1575 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: 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* 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