# HG changeset patch # User hgs # Date 1283774447 -10800 # Node ID 98307c651589a408e8bad23c2b7104d26814b8c5 # Parent 0ff24a8f6ca29ed379b0410731a49d250104fe25 201035 diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/analyzetoolcleaner/bwins/atoolcleaneru.def --- a/analyzetool/analyzetoolcleaner/bwins/atoolcleaneru.def Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - ?GetCallBackAddress@@YAPAV?$TFixedArray@K$09@@XZ @ 1 NONAME ; class TFixedArray * GetCallBackAddress(void) - diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/analyzetoolcleaner/eabi/atoolcleaneru.def --- a/analyzetool/analyzetoolcleaner/eabi/atoolcleaneru.def Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - _Z18GetCallBackAddressv @ 1 NONAME - diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/analyzetoolcleaner/group/analyzetoolcleaner.mmp --- a/analyzetool/analyzetoolcleaner/group/analyzetoolcleaner.mmp Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: The .mmp file for atoolcleaner. -* -*/ - -#include - -TARGET atoolcleaner.dll -TARGETTYPE dll -UID 0x1000008d 0x2002DC71 -CAPABILITY ALL -TCB -EPOCALLOWDLLDATA - -SMPSAFE - -SOURCEPATH ../src -SOURCE analyzetoolcleaner.cpp - -USERINCLUDE ../inc -USERINCLUDE ../../inc - -OS_LAYER_SYSTEMINCLUDE - -LIBRARY euser.lib -LIBRARY flogger.lib - -// End of File diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/analyzetoolcleaner/group/bld.inf --- a/analyzetool/analyzetoolcleaner/group/bld.inf Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -PRJ_PLATFORMS -ARMV5 WINSCW - -PRJ_EXPORTS -../inc/analyzetoolcleaner.h OS_LAYER_PLATFORM_EXPORT_PATH(analyzetool/analyzetoolcleaner.h) - -PRJ_MMPFILES -analyzetoolcleaner.mmp diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/analyzetoolcleaner/inc/analyzetoolcleaner.h --- a/analyzetool/analyzetoolcleaner/inc/analyzetoolcleaner.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Definitions for the class TAnalyzeToolCleanerBase. -* -*/ - -#ifndef __ANALYZETOOLCLEANER_H__ -#define __ANALYZETOOLCLEANER_H__ - -// INCLUDES -#include - -// CONSTANTS -#define ATCLEANERTABLESIZE 10 -#define ATCLEANERTABLE TFixedArray -_LIT( KATCleanerDllName, "atoolcleaner.dll" ); - -// CLASS DECLARATION - -/** -* Cleaner base class -*/ -class TAnalyzeToolCleanerBase - { -public: - /** - * Cleanup function which uninstall allocator - */ - virtual void Cleanup() = 0; - }; - -// CLASS DECLARATION - -/** -* Cleaner class -*/ -class THookCleaner - { -public: - /** - * C++ default constructor. - */ - THookCleaner(); - - /** - * Destructor. - */ - ~THookCleaner(); - - ATCLEANERTABLE iTable; - }; -#endif // __ANALYZETOOLCLEANER_H__ diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/analyzetoolcleaner/src/analyzetoolcleaner.cpp --- a/analyzetool/analyzetoolcleaner/src/analyzetoolcleaner.cpp Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: THookCleaner implementation -* -*/ - -// INCLUDES -#include "analyzetoolcleaner.h" -#include -#include "atlog.h" - -// Global cleaner object -static THookCleaner cleaner; - -// ordinal 1 -EXPORT_C ATCLEANERTABLE* GetCallBackAddress() - { - LOGSTR1( "ATC GetCallBackAddress()" ); - - return &( cleaner.iTable ); - } - -// ----------------------------------------------------------------------------- -// THookCleaner::THookCleaner() -// C++ default constructor can NOT contain any code, that -// might leave. -// ----------------------------------------------------------------------------- -// -THookCleaner::THookCleaner() - { - LOGSTR1( "ATC THookCleaner::THookCleaner()" ); - - iTable.Reset(); - } - -// ----------------------------------------------------------------------------- -// THookCleaner::~THookCleaner() -// Destructor. -// ----------------------------------------------------------------------------- -// -THookCleaner::~THookCleaner() - { - LOGSTR1( "ATC THookCleaner::~THookCleaner()" ); - - for ( TUint i = 0; i < ATCLEANERTABLESIZE; i++ ) - { - if ( iTable.At( i ) ) - { - TAnalyzeToolCleanerBase* obj = - ( TAnalyzeToolCleanerBase* ) iTable.At( i ); - obj->Cleanup(); - } - } - } - -// End of File diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/group/atool.vcproj --- a/analyzetool/commandlineengine/group/atool.vcproj Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,375 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/group/bld.inf --- a/analyzetool/commandlineengine/group/bld.inf Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +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: -* -*/ - - -PRJ_EXPORTS -../install/atool.exe +/tools/ -../install/addr2line.exe +/tools/ -../install/xerces-c_2_7.dll +/tools/ diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/ATCommonDefines.h --- a/analyzetool/commandlineengine/inc/ATCommonDefines.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,598 +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; - -/** -* Atool return code. -*/ -struct AT_RETURN_CODE { - /** - * Enumeration containing all return codes used by atool. - * When error happens this value set as the exit code. - * Note! Values can be only added not modified/deleted. - */ - 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. */ - }; -}; - -// 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.9.1" // NOTE! This version number is written also to temporary cpp file. -#define ATOOL_DATE "29th April 2010" - -// 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.5;1.9.1" - -// Datafile version -#define AT_DATA_FILE_VERSION "DATA_FILE_VERSION 11" - -// Latest dbghelp.dll version -const int DBGHELP_VERSION_MAJ = 6; -const int DBGHELP_VERSION_MIN = 3; -const int DBGHELP_VERSION_BUILD = 0; -const int DBGHELP_VERSION_REVIS = 0; -const char DBGHELP_DLL_NAME[] = "dbghelp.dll"; - - -// 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_FILE = "monitored internal"; -const string AT_BUILD_SUMMARY_TRACE = "monitored external"; -const string AT_BUILD_SUMMARY_TRACE_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; /** name of the code segment/binary */ - unsigned long iStartAddress; /** start address of code segment (in memory) */ - unsigned long iEndAddress; /** end address of code segment (in memory) */ - int iLeaks; /** leak count in this code segment */ - unsigned long iPID; /** process id which loaded this code segment */ - int iSubTestStartOpenHandles; /** open handle count when sub test started */ - int iSubTestEndOpenHandles; /** open handle count when sub test ended */ - // Load/Unload times, note these are micro seconds from 1970 so size is huge. - unsigned long long iLoadTime; /** code segment load time */ - unsigned long long iUnloadTime; /** code segment unload time */ - /** - * Default constructor to set default values - */ - 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; /** line number */ - string sFileName; /** filename */ - string sFunction; /** function / symbol */ - string sMangledName; /** function / symbol name in mangled / coded form */ - string sLstName; /** listing filename */ -}; - -/** -* Struct for saving symbol information from map file -*/ -struct MAP_FUNC_INFO -{ - int iAddress; /** memory address (start of symbol) */ - int iFuncLength; /** symbol length */ - string sMangledName;/** symbol name in mangled / coded form */ - string sWholeLine; /** whole symbol line from map file */ - string sFunctionName; /** symbol clear name */ -}; - -/** -* 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, /** symbol name but mangled / coded form */ - 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; /** calculated address from code segment start */ - 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, /** not defined */ - SWITCH_ANALYZE = 1, /** analyze */ - SWITCH_HOOK = 2, /** compile/instrument */ - SWITCH_UNHOOK = 3, /** uninstrument */ - SWITCH_PARSE_TRACE = 5, /** parse raw data */ - SWITCH_CLEAN = 6, /** clean AT changes */ - SWITCH_VERSION = 9, /** display version infromation */ - SWITCH_HELP = 10, /** show help with syntax examples */ - SWITCH_DBGHELP_VERSION = 11 -}; - -/** -* Enumeration used when hooking project. -*/ -enum HOOK_SWITCH -{ - HOOK_UNKNOWN = 0, /** not defined */ - HOOK_INTERNAL, /** monitored internal data gathering */ - HOOK_EXTERNAL, /** monitored external data gathering */ - HOOK_EXTERNAL_FAST, /** external data gathering */ - HOOK_EXTENSION_INTERNAL, /** Extension call, monitored internal data gathering */ - HOOK_EXTENSION_EXTERNAL, /** Extension call, monitored external data gathering */ - HOOK_EXTENSION_EXTERNAL_FAST, /** Extension call, external data gathering */ - HOOK_EXTENSION_UNINSTRUMENT, /** Extension call, uninstrument (post-build)*/ - HOOK_EXTENSION_FAILED, /** Extension call, build failed, cleanup */ - HOOK_OLD_EXTENSION_INSTRUMENT, /** Old extension call, instrument project */ - HOOK_OLD_EXTENSION_UNINSTRUMENT, /** Old extension call, uninstrument project */ - HOOK_OLD_EXTENSION_FAILED /** Old extension call, cleanup */ -}; - -/** -* Represents hooking parameters, these are set -* by the user arguments from command line. -*/ -struct ARGUMENTS_HOOK -{ - bool bNoBuild; /** Only intrument project? (no build) */ - bool bDataFileName; /** Is internal data gathering filename defined */ - bool bAbldTest; /** Is build only for test modules (abld test build.. */ - string sDataFileName; /** Internal data gathering filename */ - int iBuildSystem; /** 1 = sbs, 2 = raptor */ - int iLoggingMode; /** Just for old parameter parsing. 1=trace, 2=file, 0=? */ - int iAllocCallStackSize; /** Call stack size when memory allocated */ - int iFreeCallStackSize; /** Call stack size when memory freed */ - string sBuildCmd; /** Original build command / user defined or given */ - vector vBuildCmd; /** Build command split in vector */ - string sPlatform; /** Build platform */ - string sBuildType; /** Build type (udeb/urel) */ - string sFeatureVariant; /** Build variant defined */ - vector vTargetPrograms; /** User defined single or multiple modules from project? */ - /** - * Default constructor to set default values. - */ - ARGUMENTS_HOOK() - { - bNoBuild = false; - bAbldTest = 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(); - }; -}; - -/** -* Represents analyze parameters, these are set -* by the user arguments from command line. -*/ -struct ARGUMENTS_ANALYZE -{ - string sDataFile; /** Data file to be analyzed */ - string sOutputFile; /** Output file */ - bool bSymbolFile; /** Is rom/rofs symbol file(s) defined? */ - vector vSymbolFiles; /** Collection of symbol files */ - int iLoggingLevel; /** Logging level of report */ - /** - * Default constructor to set default values. - */ - ARGUMENTS_ANALYZE() - { - sDataFile = ""; - sOutputFile = ""; - bSymbolFile = false; - iLoggingLevel = 3; - }; -}; - -/** -* Represents raw trace parsing parameters, these are set -* by the user arguments from command line. -*/ -struct ARGUMENTS_PARSE -{ - bool bDataFile; /** Is raw data file defined */ - string sDataFile; /** Raw data file (input) */ - bool bOutputFile; /** Is output file defined */ - string sOutputFile; /** Output (AT specific data file)*/ - /** - * Default constructor to set default values. - */ - ARGUMENTS_PARSE() - { - bDataFile = false; - sDataFile = ""; - bOutputFile = false; - sOutputFile = ""; - }; -}; - - -/** -* Represents main parameters, these are set -* by the user arguments from command line. -*/ -struct ARGUMENTS -{ - // Base arguments. - MAIN_SWITCH eMainSwitch; /** mandatory/main parameter */ - HOOK_SWITCH eHookSwitch; /** if compile/instrument its "mode" */ - bool bHelp; /** show help? */ - bool bDebugConsole; /** enable debug logging to console? */ - bool bDebugDbgView; /** enable debug logging to win api? */ - bool bDebugLowLevel; /** enable debug logging for also low level functions? */ - bool bEnableSbs2; /** use raptor as build system? */ - ARGUMENTS_HOOK HOOK; /** hooking/instrument/compiling attributes */ - ARGUMENTS_ANALYZE ANALYZE; /** analyze related attributes */ - ARGUMENTS_PARSE PARSE; /** parsing related attributes */ - /** - * Default constructor to set default values. - */ - 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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/CATBase.h --- a/analyzetool/commandlineengine/inc/CATBase.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,418 +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: Defines CATBase "utility" class. -* -*/ - -#ifndef __CATBASE_H__ -#define __CATBASE_H__ - -#include "../inc/ATCommonDefines.h" - -/** -* This class implements lot of utility type of functions used all around atool project. -* All functions are static so they can be used without inheritance of this class. But still -* this is a base class of almost all others. -*/ -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 signed decimal. - * @param sHex - * @param iDec - * @return true if successful - */ - static bool hexToDec( string& sHex, int& iDec ); - - /** - * Convert hex value in string to unsigned decimal - * @param sHex - * @param iDec - * @return true if successful - */ - static bool hexToDec( string& sHex, unsigned int& iDec ); - - /** - * Convert hex value in string to unsigned long. - * @param sHex - * @param ulDec - * @return true if successful - */ - static bool hexToDec( string& sHex, unsigned long& ulDec ); - - /** - * Convert hex value in string to unsigned long long. - * @param sHex - * @param ullDec - * @return true if successful - */ - 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); - - /** - * Parse string to vector of strings using - * separator. (Tokenizer with delimeter). - * @param sInput string to split - * @char separator - * return vector - */ - static vector ParseStringToVector( const string& sInput, char separator ); - - /** - * Remove spaces and tabulatures from beginning and - * end of given string. - * @param sInput String to trim. - */ - static void TrimString( string& sInput ); - - /** - * Searches files with given extension from path. - * @param pPathAndExt path with extension - * @return string filename - */ - 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 pPrint 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 pPathAndExt path with extension definition - * @param bPrintErrors do print errors? - * @param sErrorLog errors - * @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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/CATDatParser.h --- a/analyzetool/commandlineengine/inc/CATDatParser.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,283 +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: Defines CATDatParser class and its used enumerations. -* -*/ - - -#ifndef __CATDatParser_H__ -#define __CATDatParser_H__ - -// Includes. -#include "ATCommonDefines.h" -#include "CATBase.h" -#include "CATDataSaver.h" - -// Forward declarations. -class CATModule2; -class CATMemoryAddress; -class CATRomSymbol; - -/** -* Provides the analyze feature for AnalyzeTool specific data file. -* Is used by CATProject. Uses CATModule2 and/or CATRomSymbol to locate symbols or -* codelines of memory addressses. Uses CATDataSaver to create report. -*/ -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 ); - -#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 - - 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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/CATDataSaver.h --- a/analyzetool/commandlineengine/inc/CATDataSaver.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,214 +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: Defines CATDataSaver class and element type enumeration. -* -*/ - - -#ifndef __CATDATASAVER_H__ -#define __CATDATASAVER_H__ - -#include -#include -#include "ATCommonDefines.h" - -/** -* Represents element types -*/ -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 - -/** -* TProvides features for creating the analyze report in -* basic text or XML formats. Uses xerces library for XML output. -*/ -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. - * @param pData string to add - * @param bSaveCarbideData add string to xml? - */ - void AddString( const char* pData, bool bSaveCarbideData = false ); - - /** - * Converts integer to string and adds it to current line. - * @param iValue integer value to add - * @param bSaveCarbideData add string to xml? - */ - 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. - * @param bPrintImmediately - */ - 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. - * @param sInput data - * @param iElementType element to write - */ - void SaveXML( string sInput, int iElementType ); - - /** - * Converts char* -> wchar_t*. - * @param str - * @return LPWSTR - */ - static LPWSTR CharToWChar( const char* str ); - - /** - * Converts wchar_t* -> char*. - * @param sInput - * @param Source - */ - static void WCharToChar( string& sInput, const WCHAR* Source ); - - /** - * Set is build type debug? - * @param bUdebBuild true if build type debug - */ - void SetBuild( bool bUdebBuild ); - - /** - * Add xml data for extension - * @param sInput data - */ - void AddCarbideData( const string& sInput ); - - /** - * Convert given integer to string - * @param iValueToConvert - * @return string - */ - static string IntegerToString( int iValueToConvert ); - -#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; - - /** - * Utility to get sub string from string using char as separator - * @param sInput - * @param cCharacter - * @return string - */ - string GetStringUntilNextGivenChar( string& sInput, char cCharacter ); - -}; - -#endif diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/CATMemoryAddress.h --- a/analyzetool/commandlineengine/inc/CATMemoryAddress.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,202 +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: Defines the CATMemoryAddress class. -* -*/ - - -#ifndef __CATMEMORYADDRESS_H__ -#define __CATMEMORYADDRESS_H__ - -#include "../inc/ATCommonDefines.h" - -/** -* Represents a single memory address / call stack item. -* State tells the "success" of locating the symbol / code line. -* Contains some utility functions used in this feature. -*/ -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; - /** - * Set time - * @param ullTime - */ - void SetTime( unsigned long long& ullTime ); - /** - * Get time - * @return unsigned long long - */ - unsigned long long GetTime(); - /** - * Set address - * @param sAddess - */ - void SetAddress( string& sAddress ); - /** - * Get address string - * @return string - */ - string GetAddressString(); - /** - * Set address - * @param iAddress - */ - void SetAddress( unsigned long iAddress ); - /** - * Get Address - * @return unsigned long - */ - unsigned long GetAddress(); - /** - * Set module name - * @param sModuleName - */ - void SetModuleName( string& sModuleName ); - /** - * Get module name - * @return string - */ - string GetModuleName(); - /** - * Set state of locating code line - * @param eState - */ - void SetAddressToLineState( ADDRESS_TO_LINE_STATE eState ); - /** - * Get current state of locating code line - * @return int - */ - int GetAddressToLineState(); - /** - * Set filename - * @param sFileName - */ - void SetFileName(string& sFileName); - /** - * Get filename - * @return string - */ - string GetFileName(); - /** - * Set function name - * @param sFunctionName - */ - void SetFunctionName(string& sFunctionName); - /** - * Get function name - * @return string - */ - string GetFunctionName(); - /** - * Set function line number - * @param iFunctionLineNumber - */ - void SetFunctionLineNumber(int iFunctionLineNumber); - /** - * Get function line number - * @return int - */ - int GetFunctionLineNumber(); - /** - * Set exact line number - * @param iExactLineNumber - */ - void SetExactLineNumber(int iExactLineNumber); - /** - * Get exact line number - * @return int - */ - int GetExactLineNumber(); - /** - * Set module start address - * @param iAddress - */ - 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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/CATMmp.h --- a/analyzetool/commandlineengine/inc/CATMmp.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +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(); - - string m_sMmpFile; /** The mmp file with path */ - - /** - * 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(); - -}; -#endif \ No newline at end of file diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/CATModule2.h --- a/analyzetool/commandlineengine/inc/CATModule2.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,545 +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). -* -*/ - - -#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/component (single binary) in project. -* CATProject contains a collection of these. -*/ -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; - // File 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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/CATParseTraceFile.h --- a/analyzetool/commandlineengine/inc/CATParseTraceFile.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +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, CProcessData and -* CSubTestData. -* -*/ - - -#ifndef __CATPARSETRACEFILE_H__ -#define __CATPARSETRACEFILE_H__ - -#include "../inc/ATCommonDefines.h" -#include "../inc/CATDataSaver.h" -#include "../inc/CATBase.h" -#include "../inc/catallocs.h" - -/** -* Parses raw trace data to AnalyzeTool specific data file. -*/ -class CATParseTraceFile : public CATBase -{ -public: - /** - * Constructor - */ - 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 ); - - /** - * Get data saver - * @return CATDataSaver* - */ - CATDataSaver* GetDataSaver(void); - -#ifndef MODULE_TEST -private: -#endif - CATDataSaver m_DataSaver; /** Data saver */ -}; - -/** -* Represents data of a single subtest. -*/ -class CSubTestData : public CATAllocs -{ -public: - // Members - - bool bRunning; /** Is sub test running */ - vector vData; /** data */ - string sSubTestName; /** test name */ - string sStartTime; /** start time */ - string sEndTime; /** end time */ - string sSubTestStartHandleCount; /** handle count at start */ - string sSubTestEndHandleCount; /** handle count at end */ -}; - -/** -* Represents data of a single run. -*/ -class CProcessData : public CATAllocs -{ -public: - // Members - - bool bProcessOnGoing; /** is process on going */ - int iProcessID; /** process id (pid)*/ - vector vData; /** data */ - vector vHandleLeaks; /** handle leak(s) */ - vector vSubTests; /** process sub test(s) */ -}; - -#endif diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/CATParseXML.h --- a/analyzetool/commandlineengine/inc/CATParseXML.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +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. -*/ -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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/CATProject.h --- a/analyzetool/commandlineengine/inc/CATProject.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,629 +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 MMPTESTFILE_SEARCH_STRING "PRJ_TESTMMPFILES 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, - FILE = 1, - TRACE = 2, - TRACE_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; - // Is build just for test modules - bool m_bAbldTest; - // 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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/cataddr2line.h --- a/analyzetool/commandlineengine/inc/cataddr2line.h Fri Aug 27 11:37:29 2010 +0300 +++ /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: 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 :/\\_.-"; - -/** -* Implements addresstoline interface using one of the GNU binutils tool called addr2line. -* This is used on gcce platform. In release build type also map files are used. -*/ -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. - //These were part of task which would filter unwanted characters, etc.. from results. - - /** - * 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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/cataddr2lineserver.h --- a/analyzetool/commandlineengine/inc/cataddr2lineserver.h Fri Aug 27 11:37:29 2010 +0300 +++ /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: Defines CATAddr2lineServer class. -* -*/ - -#ifndef __CATADDR2LINESERVER_H__ -#define __CATADDR2LINESERVER_H__ - -// Includes. -#include "ATCommonDefines.h" - -#define BUFSIZE 4096 - -/** -* This class "runs" the addr2line binary as a server for CATAddr2Line. -* It redirects the pipes from the tool. -*/ -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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/catalloc.h --- a/analyzetool/commandlineengine/inc/catalloc.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +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: Defines CATAlloc class. -* -*/ - - -#ifndef __CATALLOC_H__ -#define __CATALLOC_H__ - -#include "../inc/ATCommonDefines.h" - -/** -* Class representing single memory allocation. -*/ -class CATAlloc -{ -public: - /** - * Constructor. - */ - CATAlloc() : m_iCSCount(0) {} - - /** - * Destructor. - */ - ~CATAlloc(){} - - /** - * Get alloc string after address, it contains: - * time, size, call stack.. - * @return string allocation string - */ - string GetAllocString(); - - // Members - - string m_sTime; /** Allocation time */ - - string m_sSize; /** Allocation size */ - - unsigned long m_iCSCount; /** Call stack address count */ - - map m_vCallStack; /** Call stack where packet number is key */ - -}; -#endif -//EOF diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/catallocs.h --- a/analyzetool/commandlineengine/inc/catallocs.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +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: Defines CATAllocs "collection" class. -*/ - -#ifndef __CATALLOCS_H__ -#define __CATALLOCS_H__ - -#include "../inc/ATCommonDefines.h" -#include "../inc/CATBase.h" -#include "../inc/catalloc.h" - -/** -* Class representing a collection of memory allocations. -* It is used to acquire the data of memory leaks by giving all -* data on single allocations and frees. -*/ -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(); -#ifndef MODULE_TEST -private: -#endif - map m_vAllocs; /** Collection of allocation(s) */ -}; -#endif -//EOF diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/catdbghelper.h --- a/analyzetool/commandlineengine/inc/catdbghelper.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +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: Defines the CATDbgHelper class. -* -*/ - - -#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; - -/** -* Provides feature to locate code lines using Windows Debug Api. This is done -* by using dbghelper library. Implements the IAddressToLine interface. -*/ -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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/catfilereader.h --- a/analyzetool/commandlineengine/inc/catfilereader.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +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: Defines CATFileReader class. -* -*/ - - -#ifndef __CATFILEREADER_H__ -#define __CATFILEREADER_H__ - -#include "ATCommonDefines.h" - -/** -* Provides a feature to read a file as single block into memory and parse it -* from there line by line (iterating). This can fail or be very slow if file -* size is bigger than available physical memory for process. -* But is faster when file fits in free physical memory. -*/ -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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/catromsymbol.h --- a/analyzetool/commandlineengine/inc/catromsymbol.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,196 +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: Defines CATRomSymbol, RofsBinary classes and Symbol -* structure. -* -*/ - - -#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; - -/** -* Represents a single symbol in a binary. -*/ -struct Symbol -{ - unsigned long iStartAddress; /** Start address */ - unsigned long iEndAddress; /** End address */ - string sFunction; /** Function/Symbol name */ - /** - * Default constructor for structure to set default values - */ - Symbol() { iStartAddress=0; iEndAddress=0; sFunction = ""; } - /** - * Empty destructor - */ - ~Symbol() {} -}; - - -/** -* Represents a single binary in ROM/ROFS which -* contains a collection of Symbols. -*/ -class RofsBinary { -public: - /** - * Constructor - */ - RofsBinary(); - /** - * Constructor - * @param sbinary - */ - RofsBinary( const string& sbinary ); - /** - * Destructor - */ - ~RofsBinary(); - - // Members - - string m_sBinary; /** Binary / code segment */ - vector vSymbols; /** Collection of symbols */ -}; - -/** -* Implements IAddressToLine interface to acquire symbol information -* using memory addresses from rom/rofs symbol files. -*/ -class CATRomSymbol : public IAddressToLine -{ -public: - /** - * Constructor. - */ - CATRomSymbol(); - /** - * Destructor. - */ - virtual ~CATRomSymbol(); - bool m_bShowProgressMessages; /** "Flag" will we show progress when reading files */ - /** - * Empty functions does nothing returns false always. - * @param sString - * @param iLong - * @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. - * @param vSymbols - * @return bool - */ - 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. - * @param result memory address object. - * @return true if successful. - */ - bool AddressToLine( CATMemoryAddress* result ); -#ifndef MODULE_TEST -private: -#endif - /** - * Represents the symbol files type - * (content is different / format ) - */ - enum SYMBOL_FILE_TYPE { - SYMBOL_FILE_INVALID = 0, /** not valid */ - SYMBOL_FILE_ROM, /** rom type */ - SYMBOL_FILE_ROFS /** rofs type */ - }; - /** - * Identify symbol file - * @param sFile - * @return int - */ - int IdentifySymbolFile( const string& sFile ); - /** - * Locate symbol and binary name for given address if found in rom. - * @param result - * @return bool - */ - bool AddressToLineRom( CATMemoryAddress* result ); - /** - * Locate symbol and binary name for given address if found in rofs. - * @param result - * @return bool - */ - bool AddressToLineRofs( CATMemoryAddress* result ); - /** - * Reads rom files. - * @return bool - */ - bool ReadRomFiles(); - /** - * Read specified rom file - * @param sFile - * @return bool - */ - bool ReadRomFile( const string& sFile ); - /** - * Read rofs files - * @return bool - */ - bool ReadRofsFiles(); - /** - * Read specified rofs file - * @param sFile - * @return bool - */ - bool ReadRofsFile( const string& sFile ); - /** - * Parse symbol from a line in rom/rofs file. - * @param sLine - * @param pSymbol - */ - void ParseSymbolFromLine( const string& sLine, Symbol* pSymbol ); -#ifndef MODULE_TEST -private: -#endif - - // Members - - bool m_bFilesIdentified; /** Have we identified symbol file(s) */ - bool m_bSymbolsRead; /** Have we read symbol file(s) */ - vector m_vRomFiles; /** Rom symbol file(s) */ - vector m_vRomCache; /** Cached rom symbols */ - vector m_vRomSymbols; /** All rom symbols */ - unsigned long m_iRomStartAddress; /** Rom start address */ - unsigned long m_iRomEndAddress; /** Rom end address */ - vector m_vRofsFiles; /** Rofs symbol file(s) */ - vector m_vRofsBinaries; /** Rofs binaries */ - string m_sErrorMessage; /** Error message */ -}; -#endif \ No newline at end of file diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/iaddresstoline.h --- a/analyzetool/commandlineengine/inc/iaddresstoline.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +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; - -/** -* Codeline locating interface. Thru this interface CATModule2 locates code lines -* using different implementations depending on platform. -*/ -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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/inc/stdafx.h --- a/analyzetool/commandlineengine/inc/stdafx.h Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +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: 1 % -* -*/ - - -#pragma once - -// MemoryLeak checking function. -// Note! Do not comming in svn with this flag enabled. -//#define MEM_LEAK_CHECK - -// 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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/install/addr2line.exe Binary file analyzetool/commandlineengine/install/addr2line.exe has changed diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/install/atool.exe Binary file analyzetool/commandlineengine/install/atool.exe has changed diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/install/binutils-2.19.1-src.zip Binary file analyzetool/commandlineengine/install/binutils-2.19.1-src.zip has changed diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/install/xerces-c_2_7.dll Binary file analyzetool/commandlineengine/install/xerces-c_2_7.dll has changed diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/lib/xerces-c_2.lib Binary file analyzetool/commandlineengine/lib/xerces-c_2.lib has changed diff -r 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/src/CATBase.cpp --- a/analyzetool/commandlineengine/src/CATBase.cpp Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1299 +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; - } - // Headers - out << "#include "; - // Is debug - out << "\nconst TInt ATTempDebug(" << iIsDebug << ");"; - // Log option - out << "\nconst TInt ATTempLogOption(" << iLogOption << ");"; - // Alloc call stack - out << "\nconst TInt ATTempAllocCallStackSize(" << iAllocCallStackSize << ");"; - // Free call stack - out << "\nconst TInt ATTempFreeCallStackSize(" << iFreeCallStackSize << ");"; - // Log file name - out << "\n_LIT( ATTempLogFileName, \"" << sS60FileName << "\" );"; - // Version number - out << "\n_LIT( ATTempVersion, \"" << ATOOL_COMPATIBILITY_STRING << "\" );"; - // Variable functions use enumeration values that are defined in memoryhook (customuser.h) - // We use constants here so that we don't need to include the header file, wich - // might cause problems. -/* Enumeration copied to comment for notes - enum TATOptions - { - ELogFileName = 1, - EVersion = 2 , - ELogOption = 3, - EDebug = 4, - EAllocCallStackSize = 5, - EFreeCallStackSize = 6 - }; -*/ - out << "\nTInt GetInt( const TUint8 aType )"; - out << "\n{"; - out << "\nswitch( aType )"; - out << "\n{"; - out << "\ncase 4: return ATTempDebug; "; - out << "\ncase 3: return ATTempLogOption;"; - out << "\ncase 5: return ATTempAllocCallStackSize;"; - out << "\ncase 6: return ATTempFreeCallStackSize;"; - out << "\ndefault: return KErrArgument;"; - out << "\n}"; - out << "\n}"; - out << "\nTPtrC GetString( const TUint8 aType )"; - out << "\n{"; - out << "\nswitch( aType )"; - out << "\n{"; - out << "\ncase 1: return ATTempLogFileName();"; - out << "\ncase 2: return ATTempVersion();"; - out << "\ndefault: return KNullDesC();"; - out << "\n}"; - out << "\n}"; - - /** Todo: Old way of separate functions, these here for backup support and to ease testing. */ - /** Unnessesary in the future, so can be removed then (1.8.2). */ - - out << "\n_LIT( KFileName, \""; - out << sS60FileName; - out << "\" );\n"; - - // Hardcoded version number for support. - out << "\n/* The AnalyzeTool version number used. */"; - out << "\n_LIT( KAtoolVersion, \"1.7.5;1.9.1\" );\n"; - - out << "\nconst TFileName LogFileName()"; - out << "\n {"; - out << "\n return TFileName( KFileName() );"; - out << "\n }"; - - out << "\nTUint32 AllocCallStackSize()"; - out << "\n {"; - out << "\n return TUint32( "; - out << iAllocCallStackSize; - out << " );\n"; - out << "\n }"; - - out << "\nTUint32 FreeCallStackSize()"; - out << "\n {"; - out << "\n return TUint32( "; - out << iFreeCallStackSize; - out << " );\n"; - out << "\n }"; - - out << "\nconst TFileName AtoolVersion()"; - out << "\n {"; - out << "\n return TFileName( KAtoolVersion() );"; - out << "\n }"; - - out << "\nTUint32 LogOption()"; - out << "\n {"; - out << "\n return TUint32( "; - out << iLogOption; - out << " );"; - out << "\n }"; - - out << "\nTUint32 IsDebug()"; - out << "\n {"; - out << "\n return TUint32( "; - out << iIsDebug; - out << " );"; - out << "\n }"; - - // End of file and close - 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::ParseStringToVector -// ----------------------------------------------------------------------------- -vector CATBase::ParseStringToVector( const string& sInput, char separator ) -{ - LOG_LOW_FUNC_ENTRY("CATBase::ParseStringToVector"); - string sString(sInput); - // Elements vector - vector vStrings; - size_t iPos = sString.find( separator ); - // If can not find it return vector with just one element - if ( iPos == string::npos ) - { - // Don't add empty item into vector. - if ( sString.size() > 0 ) - vStrings.push_back( sString ); - return vStrings; - } - // Loop elements - while( iPos != string::npos ) - { - string sElement = sString.substr(0, iPos); - vStrings.push_back( sElement ); - sString.erase(0, iPos +1 ); - iPos = sString.find( separator ); - } - // Add last element if any - if ( sString.size() > 0 ) - vStrings.push_back( sString ); - // Return elements - return vStrings; -} - -// ----------------------------------------------------------------------------- -// 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; -} - -/** -* Used to create array of integer & hex value pairs. -*/ -struct CHexMap -{ - char chr; - int value; -}; - -// ----------------------------------------------------------------------------- -// CATBase::_httoi -// ----------------------------------------------------------------------------- -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 0ff24a8f6ca2 -r 98307c651589 analyzetool/commandlineengine/src/CATDatParser.cpp --- a/analyzetool/commandlineengine/src/CATDatParser.cpp Fri Aug 27 11:37:29 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1542 +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 = 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 == 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 == ongoing ) - { - m_DataSaver.AddString( "Test run failed.\n" ); - m_DataSaver.AddLineToLast(); - } - m_eProcess_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 = 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