sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: #include sl@0: #include "analyse.h" sl@0: #include "nonxip.h" sl@0: sl@0: sl@0: extern NonXIP gNonXIP; sl@0: sl@0: const char* COMMON_SECT="Common"; sl@0: const char* PROFILE_SECT="Profile"; sl@0: const char* PARTITION_SECT="Partition"; sl@0: const char* FORMAT_SECT="Format"; sl@0: const char* NON_XIP_SECT="NonXIP"; sl@0: sl@0: std::string Analyse::iRomFile; sl@0: std::string Analyse::iThread; sl@0: std::string Analyse::iDll; sl@0: std::string Analyse::iFunction; sl@0: std::vector Analyse::iTraces; sl@0: sl@0: int Analyse::ProcessCfgFile(const char* aCfgFileName) sl@0: { sl@0: char buf[1024]; sl@0: char path[MAX_PATH]; sl@0: if (aCfgFileName[0] != '\\' || aCfgFileName[1] != ':') sl@0: { sl@0: char ** file_name = 0; sl@0: if (!GetFullPathNameA(aCfgFileName, sizeof path, path, file_name)) sl@0: return ENoCfgFile; sl@0: aCfgFileName = path; sl@0: } sl@0: sl@0: if (GetFileAttributesA(aCfgFileName) == 0xffffffff) // no ini file sl@0: return ENoCfgFile; sl@0: int rc = GetPrivateProfileStringA(COMMON_SECT, "TraceFile", "", buf, sizeof buf, aCfgFileName); sl@0: if (rc) sl@0: { sl@0: iTraces.push_back(buf); sl@0: sTraces.push_back(iTraces[iTraces.size()-1].c_str()); sl@0: } sl@0: sl@0: GetPrivateProfileStringA(COMMON_SECT, "Mode", "profile", buf, sizeof buf, aCfgFileName); sl@0: switch(buf[0]) sl@0: { sl@0: case 'l': case 'L': sl@0: sAction = ETrace; sl@0: break; sl@0: case 'p': case 'P': sl@0: sAction = EProfile; sl@0: break; sl@0: case 'a': case 'A': sl@0: sAction = EActivity; sl@0: break; sl@0: default: sl@0: return EErrorCfgFile; sl@0: } sl@0: sl@0: rc = GetPrivateProfileStringA(COMMON_SECT, "SymbolFile", "", buf, sizeof buf, aCfgFileName); sl@0: if (rc) sl@0: { sl@0: iRomFile = buf; sl@0: sRomFile = iRomFile.c_str(); sl@0: } sl@0: sl@0: rc = GetPrivateProfileStringA(COMMON_SECT, "Range", "", buf, sizeof buf, aCfgFileName); sl@0: if (rc) sl@0: { sl@0: sOptions |= ERange; sl@0: bool plus = false; sl@0: char * p = strrchr(buf, '+'); sl@0: if (p) sl@0: plus = true; sl@0: else sl@0: p = strrchr(buf, '-'); sl@0: if (!p) return EErrorCfgFile; sl@0: *p = '\0'; sl@0: sBeginSample = atoi(buf); sl@0: sEndSample = atoi(++p); sl@0: if (plus) sl@0: sEndSample = sEndSample += sBeginSample; sl@0: } sl@0: sl@0: rc = GetPrivateProfileIntA(COMMON_SECT, "IncludeNullThread", 0, aCfgFileName); sl@0: if (rc) sl@0: sOptions|=ENull; sl@0: sl@0: rc = GetPrivateProfileStringA(COMMON_SECT, "Cutoff", "", buf, sizeof buf, aCfgFileName); sl@0: if (rc) sl@0: sCutOff = atof(buf); sl@0: sl@0: sl@0: rc = GetPrivateProfileStringA(PROFILE_SECT, "Thread", "", buf, sizeof buf, aCfgFileName); sl@0: if (rc) sl@0: { sl@0: iThread = buf; sl@0: sThread = iThread.c_str(); sl@0: } sl@0: sl@0: rc = GetPrivateProfileStringA(PROFILE_SECT, "Dll", "", buf, sizeof buf, aCfgFileName); sl@0: if (rc) sl@0: { sl@0: iDll = buf; sl@0: sDll = iDll.c_str(); sl@0: } sl@0: sl@0: rc = GetPrivateProfileStringA(PROFILE_SECT, "Function", "", buf, sizeof buf, aCfgFileName); sl@0: if (rc) sl@0: { sl@0: iFunction = buf; sl@0: sFunction = iFunction.c_str(); sl@0: } sl@0: sl@0: rc = GetPrivateProfileStringA(PROFILE_SECT, "Range", "", buf, sizeof buf, aCfgFileName); sl@0: if (rc) sl@0: { sl@0: sOptions |= EAddress; sl@0: bool plus = false; sl@0: char * p = strrchr(buf, '+'); sl@0: if (p) sl@0: plus = true; sl@0: else sl@0: p = strrchr(buf, '-'); sl@0: if (!p) return EErrorCfgFile; sl@0: *p = '\0'; sl@0: sBase = strtoul(buf,0,16); sl@0: sLim = strtoul(++p,0,16); sl@0: if (plus) sl@0: sLim = sLim += sBase; sl@0: } sl@0: sl@0: sl@0: rc = GetPrivateProfileStringA(PARTITION_SECT, "Mode", "", buf, sizeof buf, aCfgFileName); sl@0: if (rc) sl@0: { sl@0: switch(buf[0]) sl@0: { sl@0: case 'd': case 'D': sl@0: sPartition = EDll; sl@0: break; sl@0: case 'f': case 'F': sl@0: sPartition = EFunction; sl@0: break; sl@0: default: sl@0: return EErrorCfgFile; sl@0: } sl@0: } sl@0: sl@0: rc = GetPrivateProfileIntA(PARTITION_SECT, "BucketSize", 0, aCfgFileName); sl@0: if (rc) sl@0: { sl@0: sPartition = ESize; sl@0: sBucketSize = rc; sl@0: } sl@0: sl@0: rc = GetPrivateProfileIntA(PARTITION_SECT, "NumberOfBuckets", 0, aCfgFileName); sl@0: if (rc) sl@0: { sl@0: sPartition = EBuckets; sl@0: sBuckets = rc; sl@0: } sl@0: sl@0: sl@0: sl@0: rc = GetPrivateProfileStringA(FORMAT_SECT, "Mode", "", buf, sizeof buf, aCfgFileName); sl@0: if (rc) sl@0: { sl@0: switch(buf[0]) sl@0: { sl@0: case 'p': case 'P': sl@0: sFormat = EPercent; sl@0: break; sl@0: case 's': case 'S': sl@0: sFormat = ESamples; sl@0: break; sl@0: case 'e': case 'E': sl@0: sFormat = EExcel; sl@0: break; sl@0: default: sl@0: return EErrorCfgFile; sl@0: } sl@0: } sl@0: sl@0: rc = GetPrivateProfileIntA(FORMAT_SECT, "ZeroValues", 0, aCfgFileName); sl@0: if (rc) sl@0: sOptions |= EZeros; sl@0: sl@0: rc = GetPrivateProfileIntA(FORMAT_SECT, "NoOthers", 0, aCfgFileName); sl@0: if (rc) sl@0: sOptions |= ENoOther; sl@0: sl@0: rc = GetPrivateProfileIntA(FORMAT_SECT, "TotalOnly", 0, aCfgFileName); sl@0: if (rc) sl@0: sOptions |= ETotalOnly; sl@0: sl@0: sl@0: char key[256]; sl@0: for(int i=1;sprintf(key,"ObyFile%d",i), sl@0: GetPrivateProfileStringA(NON_XIP_SECT, key, "", buf, sizeof buf, aCfgFileName);i++) sl@0: gNonXIP.AddObyFile(buf); sl@0: sl@0: for(i=1;sprintf(key,"RofsSymbolFile%d",i), sl@0: GetPrivateProfileStringA(NON_XIP_SECT, key, "", buf, sizeof buf, aCfgFileName);i++) sl@0: gNonXIP.AddSymbolFile(buf); sl@0: sl@0: return EOk; sl@0: } sl@0: