imgtools/imglib/symbolutil/logparser.cpp
author kelvzhu
Tue, 23 Nov 2010 10:47:23 +0800
changeset 702 341ab25bc4ef
parent 695 46ca13b54f56
child 712 df89378e9223
permissions -rw-r--r--
merge from SF
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     1
/*
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     8
*
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    11
*
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    12
* Contributors:
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    13
*
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    14
* Description:
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    15
*
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    16
*/
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    17
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    18
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    19
#include <new>
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    20
#include <iostream>
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    21
#include <fstream>
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    22
#include <string>
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    23
#include <boost/regex.hpp>
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    24
using namespace std;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    25
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    26
#include "loggingexception.h"
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    27
#include "logparser.h"
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    28
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    29
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    30
LogParser* LogParser::Only = (LogParser*)0;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    31
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    32
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    33
LogParser* LogParser::GetInstance(TImageType aImageType) throw (LoggingException)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    34
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    35
	if(! LogParser::Only)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    36
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    37
		if(aImageType == ERomImage)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    38
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    39
			LogParser::Only = new (std::nothrow) RomLogParser();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    40
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    41
		else if(aImageType == ERofsImage)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    42
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    43
			LogParser::Only = new (std::nothrow) RofsLogParser();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    44
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    45
		else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    46
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    47
			throw LoggingException(LoggingException::UNKNOWN_IMAGE_TYPE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    48
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    49
		if(! LogParser::Only)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    50
			throw LoggingException(LoggingException::RESOURCE_ALLOCATION_FAILURE);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    51
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    52
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    53
	return LogParser::Only;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    54
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    55
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    56
void LogParser::Cleanup(void)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    57
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    58
	return;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    59
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    60
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    61
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    62
LogParser::LogParser(void)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    63
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    64
	iImageType = EUnknownType;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    65
	return;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    66
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    67
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    68
RofsLogParser::RofsLogParser()
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    69
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    70
	iImageType = ERofsImage;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    71
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    72
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    73
void RofsLogParser::ParseSymbol(const char* LogFilename) throw (LoggingException)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    74
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    75
	string linebuf;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    76
	SymbolGenerator* symgen = SymbolGenerator::GetInstance();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    77
	symgen->SetImageType(iImageType);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    78
	symgen->SetSymbolFileName(string(LogFilename));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    79
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    80
	ifstream logfd(LogFilename);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    81
	if(logfd.is_open())
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    82
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    83
		while(! logfd.eof())
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    84
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    85
			getline(logfd, linebuf);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    86
			if(linebuf.compare(0,4,"File") == 0)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    87
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    88
				if(linebuf.find("size:", 4) != string::npos)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    89
				{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    90
					size_t startpos = linebuf.find('\'') ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    91
					size_t endpos   = linebuf.rfind('\'');
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    92
					if((startpos!=string::npos) && (endpos!=string::npos))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    93
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    94
						symgen->AddFile(linebuf.substr(startpos+1,endpos-startpos-1), false);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    95
					}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    96
				}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    97
			}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    98
			else if(linebuf.compare(0,26,"Compressed executable File") == 0)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    99
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   100
				if(linebuf.find("size:", 26) != string::npos)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   101
				{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   102
					size_t startpos = linebuf.find('\'') ;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   103
					size_t endpos   = linebuf.rfind('\'');
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   104
					if((startpos!=string::npos) && (endpos!=string::npos))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   105
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   106
						symgen->AddFile(linebuf.substr(startpos+1,endpos-startpos-1), true);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   107
					}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   108
				}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   109
			}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   110
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   111
		symgen->SetFinished();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   112
		symgen->Release();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   113
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   114
	else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   115
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   116
		throw LoggingException(LoggingException::INVALID_LOG_FILENAME);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   117
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   118
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   119
	return;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   120
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   121
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   122
RomLogParser::RomLogParser()
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   123
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   124
	iImageType = ERomImage;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   125
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   126
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   127
void RomLogParser::ParseSymbol(const char* LogFilename) throw (LoggingException)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   128
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   129
	string linebuf;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   130
	SymbolGenerator* symgen = SymbolGenerator::GetInstance();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   131
	symgen->SetImageType(iImageType);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   132
	symgen->SetSymbolFileName(string(LogFilename));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   133
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   134
	ifstream logfd(LogFilename);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   135
	if(logfd.is_open())
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   136
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   137
		//boost::regex beginFlag("^Creating Rom image (\\S*)");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   138
		boost::regex endFlag("^Writing Rom image");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   139
		boost::regex sourceFile("^Reading resource (.*) to rom linear address (.*)");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   140
		boost::regex executableFile("^Processing file (.*)");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   141
		boost::regex codeStart("^Code start addr:\\s*(\\w+)");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   142
		boost::regex dataStart("^Data start addr:\\s+(\\w+)");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   143
		boost::regex dataBssStart("^DataBssLinearBase:\\s+(\\w+)");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   144
		boost::regex textSize("^Text size:\\s+(\\w+)");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   145
		boost::regex dataSize("^Data size:\\s+(\\w+)");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   146
		boost::regex bssSize("Bsssize:\\s+(\\w+)");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   147
		boost::regex totalDataSize("^Total data size:\\s+(\\w+)");
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   148
		string tmpline, tmpaddr;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   149
		boost::cmatch what;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   150
		while(getline(logfd, tmpline))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   151
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   152
			TPlacedEntry tmpEntry;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   153
			if(regex_search(tmpline, what, endFlag))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   154
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   155
				break;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   156
			}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   157
			if(regex_search(tmpline, what, sourceFile))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   158
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   159
				tmpEntry.iFileName.assign(what[1].first, what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   160
				tmpaddr.assign(what[2].first, what[2].second-what[2].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   161
				tmpEntry.iDataAddress = strtol(tmpaddr.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   162
				symgen->AddEntry(tmpEntry);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   163
			}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   164
			else if(regex_search(tmpline, what, executableFile))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   165
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   166
				tmpEntry.iFileName.assign(what[1].first, what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   167
				while(getline(logfd, tmpline) && tmpline != "")
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   168
				{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   169
					if(regex_search(tmpline, what, codeStart))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   170
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   171
						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   172
						tmpEntry.iCodeAddress = strtol(tmpaddr.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   173
					} 
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   174
					else if(regex_search(tmpline, what, dataStart))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   175
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   176
						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   177
						tmpEntry.iDataAddress = strtol(tmpaddr.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   178
					}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   179
					else if(regex_search(tmpline, what, dataBssStart))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   180
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   181
						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   182
						tmpEntry.iDataBssLinearBase = strtol(tmpaddr.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   183
					}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   184
					else if(regex_search(tmpline, what, textSize))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   185
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   186
						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   187
						tmpEntry.iTextSize = strtol(tmpaddr.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   188
					}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   189
					else if(regex_search(tmpline, what, dataSize))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   190
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   191
						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   192
						tmpEntry.iDataSize = strtol(tmpaddr.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   193
					}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   194
					else if(regex_search(tmpline, what, bssSize))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   195
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   196
						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   197
						tmpEntry.iBssSize = strtol(tmpaddr.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   198
					}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   199
					else if(regex_search(tmpline, what, totalDataSize))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   200
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   201
						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   202
						tmpEntry.iTotalDataSize = strtol(tmpaddr.c_str(), NULL, 16);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   203
					}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   204
				}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   205
				symgen->AddEntry(tmpEntry);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   206
			}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   207
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   208
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   209
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   210
		symgen->SetFinished();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   211
		symgen->Release();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   212
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   213
	else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   214
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   215
		throw LoggingException(LoggingException::INVALID_LOG_FILENAME);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   216
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   217
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   218