os/kernelhwsrv/kerneltest/e32utils/analyse/ProcessCfg.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32utils/analyse/ProcessCfg.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,222 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +#include <windows.h>
    1.21 +#include "analyse.h"
    1.22 +#include "nonxip.h"
    1.23 +
    1.24 +
    1.25 +extern NonXIP gNonXIP;
    1.26 +
    1.27 +const char* COMMON_SECT="Common";
    1.28 +const char* PROFILE_SECT="Profile";
    1.29 +const char* PARTITION_SECT="Partition";
    1.30 +const char* FORMAT_SECT="Format";
    1.31 +const char* NON_XIP_SECT="NonXIP";
    1.32 +
    1.33 +std::string Analyse::iRomFile;
    1.34 +std::string Analyse::iThread;
    1.35 +std::string Analyse::iDll;
    1.36 +std::string Analyse::iFunction;
    1.37 +std::vector<std::string> Analyse::iTraces;
    1.38 +
    1.39 +int Analyse::ProcessCfgFile(const char* aCfgFileName)
    1.40 +	{
    1.41 +	char buf[1024];
    1.42 +	char path[MAX_PATH];
    1.43 +	if (aCfgFileName[0] != '\\' || aCfgFileName[1] != ':')
    1.44 +		{
    1.45 +		char ** file_name = 0;
    1.46 +		if (!GetFullPathNameA(aCfgFileName, sizeof path, path, file_name))
    1.47 +			return ENoCfgFile;
    1.48 +		aCfgFileName = path;
    1.49 +		}
    1.50 +
    1.51 +	if (GetFileAttributesA(aCfgFileName) == 0xffffffff) // no ini file
    1.52 +		return ENoCfgFile;
    1.53 +	int rc = GetPrivateProfileStringA(COMMON_SECT, "TraceFile", "", buf, sizeof buf, aCfgFileName);
    1.54 +	if (rc)
    1.55 +		{
    1.56 +		iTraces.push_back(buf);
    1.57 +		sTraces.push_back(iTraces[iTraces.size()-1].c_str());
    1.58 +		}
    1.59 +
    1.60 +	GetPrivateProfileStringA(COMMON_SECT, "Mode", "profile", buf, sizeof buf, aCfgFileName);
    1.61 +	switch(buf[0])
    1.62 +		{
    1.63 +	case 'l': case 'L':
    1.64 +		sAction = ETrace;
    1.65 +		break;
    1.66 +	case 'p': case 'P':
    1.67 +		sAction = EProfile;
    1.68 +		break;
    1.69 +	case 'a': case 'A':
    1.70 +		sAction = EActivity;
    1.71 +		break;
    1.72 +	default:
    1.73 +		return EErrorCfgFile;
    1.74 +		}
    1.75 +
    1.76 +	rc = GetPrivateProfileStringA(COMMON_SECT, "SymbolFile", "", buf, sizeof buf, aCfgFileName);
    1.77 +	if (rc) 
    1.78 +		{
    1.79 +		iRomFile = buf;
    1.80 +		sRomFile = iRomFile.c_str();
    1.81 +		}
    1.82 +
    1.83 +	rc = GetPrivateProfileStringA(COMMON_SECT, "Range", "", buf, sizeof buf, aCfgFileName);
    1.84 +	if (rc) 
    1.85 +		{
    1.86 +		sOptions |= ERange;
    1.87 +		bool plus = false;
    1.88 +		char * p = strrchr(buf, '+');
    1.89 +		if (p)
    1.90 +			plus = true;
    1.91 +		else
    1.92 +			p = strrchr(buf, '-');
    1.93 +		if (!p) return EErrorCfgFile;
    1.94 +		*p = '\0';
    1.95 +		sBeginSample = atoi(buf);
    1.96 +		sEndSample = atoi(++p);
    1.97 +		if (plus) 
    1.98 +			sEndSample = sEndSample += sBeginSample;
    1.99 +		}
   1.100 +
   1.101 +	rc = GetPrivateProfileIntA(COMMON_SECT, "IncludeNullThread", 0, aCfgFileName);
   1.102 +	if (rc) 
   1.103 +		sOptions|=ENull;
   1.104 +	
   1.105 +	rc = GetPrivateProfileStringA(COMMON_SECT, "Cutoff", "", buf, sizeof buf, aCfgFileName);
   1.106 +	if (rc) 
   1.107 +		sCutOff = atof(buf);
   1.108 +
   1.109 +
   1.110 +	rc = GetPrivateProfileStringA(PROFILE_SECT, "Thread", "", buf, sizeof buf, aCfgFileName);
   1.111 +	if (rc) 
   1.112 +		{
   1.113 +		iThread = buf;
   1.114 +		sThread = iThread.c_str();
   1.115 +		}
   1.116 +
   1.117 +	rc = GetPrivateProfileStringA(PROFILE_SECT, "Dll", "", buf, sizeof buf, aCfgFileName);
   1.118 +	if (rc) 
   1.119 +		{
   1.120 +		iDll = buf;
   1.121 +		sDll = iDll.c_str();
   1.122 +		}
   1.123 +
   1.124 +	rc = GetPrivateProfileStringA(PROFILE_SECT, "Function", "", buf, sizeof buf, aCfgFileName);
   1.125 +	if (rc) 
   1.126 +		{
   1.127 +		iFunction = buf;
   1.128 +		sFunction = iFunction.c_str();
   1.129 +		}
   1.130 +
   1.131 +	rc = GetPrivateProfileStringA(PROFILE_SECT, "Range", "", buf, sizeof buf, aCfgFileName);
   1.132 +	if (rc) 
   1.133 +		{
   1.134 +		sOptions |= EAddress;
   1.135 +		bool plus = false;
   1.136 +		char * p = strrchr(buf, '+');
   1.137 +		if (p)
   1.138 +			plus = true;
   1.139 +		else
   1.140 +			p = strrchr(buf, '-');
   1.141 +		if (!p) return EErrorCfgFile;
   1.142 +		*p = '\0';
   1.143 +		sBase = strtoul(buf,0,16);
   1.144 +		sLim = strtoul(++p,0,16);
   1.145 +		if (plus) 
   1.146 +			sLim = sLim += sBase;
   1.147 +		}
   1.148 +	
   1.149 +
   1.150 +	rc = GetPrivateProfileStringA(PARTITION_SECT, "Mode", "", buf, sizeof buf, aCfgFileName);
   1.151 +	if (rc)
   1.152 +		{
   1.153 +		switch(buf[0])
   1.154 +			{
   1.155 +		case 'd': case 'D':
   1.156 +			sPartition = EDll;
   1.157 +			break;
   1.158 +		case 'f': case 'F':
   1.159 +			sPartition = EFunction;
   1.160 +			break;
   1.161 +		default:
   1.162 +			return EErrorCfgFile;
   1.163 +			}
   1.164 +		}
   1.165 +
   1.166 +	rc = GetPrivateProfileIntA(PARTITION_SECT, "BucketSize", 0, aCfgFileName);
   1.167 +	if (rc)
   1.168 +		{
   1.169 +		sPartition = ESize;
   1.170 +		sBucketSize = rc;
   1.171 +		}
   1.172 +
   1.173 +	rc = GetPrivateProfileIntA(PARTITION_SECT, "NumberOfBuckets", 0, aCfgFileName);
   1.174 +	if (rc)
   1.175 +		{
   1.176 +		sPartition = EBuckets;
   1.177 +		sBuckets = rc;
   1.178 +		}
   1.179 +
   1.180 +
   1.181 +
   1.182 +	rc = GetPrivateProfileStringA(FORMAT_SECT, "Mode", "", buf, sizeof buf, aCfgFileName);
   1.183 +	if (rc)
   1.184 +		{
   1.185 +		switch(buf[0])
   1.186 +			{
   1.187 +		case 'p': case 'P':
   1.188 +			sFormat = EPercent;
   1.189 +			break;
   1.190 +		case 's': case 'S':
   1.191 +			sFormat = ESamples;
   1.192 +			break;
   1.193 +		case 'e': case 'E':
   1.194 +			sFormat = EExcel;
   1.195 +			break;
   1.196 +		default:
   1.197 +			return EErrorCfgFile;
   1.198 +			}
   1.199 +		}
   1.200 +
   1.201 +	rc = GetPrivateProfileIntA(FORMAT_SECT, "ZeroValues", 0, aCfgFileName);
   1.202 +	if (rc)
   1.203 +		sOptions |= EZeros;
   1.204 +
   1.205 +	rc = GetPrivateProfileIntA(FORMAT_SECT, "NoOthers", 0, aCfgFileName);
   1.206 +	if (rc)
   1.207 +		sOptions |= ENoOther;
   1.208 +
   1.209 +	rc = GetPrivateProfileIntA(FORMAT_SECT, "TotalOnly", 0, aCfgFileName);
   1.210 +	if (rc)
   1.211 +		sOptions |= ETotalOnly;
   1.212 +
   1.213 +
   1.214 +	char key[256];
   1.215 +	for(int i=1;sprintf(key,"ObyFile%d",i),
   1.216 +		GetPrivateProfileStringA(NON_XIP_SECT, key, "", buf, sizeof buf, aCfgFileName);i++)
   1.217 +		gNonXIP.AddObyFile(buf);
   1.218 +
   1.219 +	for(i=1;sprintf(key,"RofsSymbolFile%d",i),
   1.220 +		GetPrivateProfileStringA(NON_XIP_SECT, key, "", buf, sizeof buf, aCfgFileName);i++)
   1.221 +		gNonXIP.AddSymbolFile(buf);
   1.222 +
   1.223 +	return EOk;
   1.224 +	}
   1.225 +