imgtools/imglib/symbolutil/logparser.cpp
author Ross Qin <ross.qin@nokia.com>
Tue, 30 Nov 2010 13:59:58 +0800
changeset 712 df89378e9223
parent 695 46ca13b54f56
child 714 e5a58c351011
permissions -rw-r--r--
Fix these errors: Some cases of PREQ1230 fail because of buildrom issue rombuild crashs when create ext-romimage readimage crashes on reading wk42 vasco_ui core image vc2008 compiling issues
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
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
    33
 
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
    34
LogParser* LogParser::GetInstance(TImageType aImageType) throw (LOGGINGEXCEPTION) 
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    35
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    36
	if(! LogParser::Only)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    37
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    38
		if(aImageType == ERomImage)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    39
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    40
			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
    41
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    42
		else if(aImageType == ERofsImage)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    43
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    44
			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
    45
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    46
		else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    47
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    48
			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
    49
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    50
		if(! LogParser::Only)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    51
			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
    52
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    53
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    54
	return LogParser::Only;
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
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    57
void LogParser::Cleanup(void)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    58
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    59
	return;
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
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    63
LogParser::LogParser(void)
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    64
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    65
	iImageType = EUnknownType;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    66
	return;
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
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    69
RofsLogParser::RofsLogParser()
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    70
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    71
	iImageType = ERofsImage;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    72
}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
    73
 
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
    74
void RofsLogParser::ParseSymbol(const char* LogFilename) throw (LOGGINGEXCEPTION) 
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    75
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    76
	string linebuf;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    77
	SymbolGenerator* symgen = SymbolGenerator::GetInstance();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    78
	symgen->SetImageType(iImageType);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    79
	symgen->SetSymbolFileName(string(LogFilename));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    80
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    81
	ifstream logfd(LogFilename);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    82
	if(logfd.is_open())
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    83
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    84
		while(! logfd.eof())
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    85
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    86
			getline(logfd, linebuf);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    87
			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
    88
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    89
				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
    90
				{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    91
					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
    92
					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
    93
					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
    94
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    95
						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
    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
			}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
    99
			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
   100
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   101
				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
   102
				{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   103
					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
   104
					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
   105
					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
   106
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   107
						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
   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
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   112
		symgen->SetFinished();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   113
		symgen->Release();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   114
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   115
	else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   116
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   117
		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
   118
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   119
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   120
	return;
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
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   123
RomLogParser::RomLogParser()
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   124
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   125
	iImageType = ERomImage;
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
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   128
void RomLogParser::ParseSymbol(const char* LogFilename) throw (LOGGINGEXCEPTION)
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   129
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   130
	string linebuf;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   131
	SymbolGenerator* symgen = SymbolGenerator::GetInstance();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   132
	symgen->SetImageType(iImageType);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   133
	symgen->SetSymbolFileName(string(LogFilename));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   134
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   135
	ifstream logfd(LogFilename);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   136
	if(logfd.is_open())
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   137
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   138
		//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
   139
		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
   140
		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
   141
		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
   142
		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
   143
		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
   144
		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
   145
		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
   146
		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
   147
		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
   148
		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
   149
		string tmpline, tmpaddr;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   150
		boost::cmatch what;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   151
		while(getline(logfd, tmpline))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   152
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   153
			TPlacedEntry tmpEntry;
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   154
			if(regex_search(tmpline.c_str(), what, endFlag))
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   155
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   156
				break;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   157
			}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   158
			if(regex_search(tmpline.c_str(), what, sourceFile))
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   159
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   160
				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
   161
				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
   162
				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
   163
				symgen->AddEntry(tmpEntry);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   164
			}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   165
			else if(regex_search(tmpline.c_str(), what, executableFile))
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   166
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   167
				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
   168
				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
   169
				{
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   170
					if(regex_search(tmpline.c_str(), what, codeStart))
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   171
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   172
						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
   173
						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
   174
					} 
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   175
					else if(regex_search(tmpline.c_str(), what, dataStart))
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   176
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   177
						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
   178
						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
   179
					}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   180
					else if(regex_search(tmpline.c_str(), what, dataBssStart))
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   181
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   182
						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
   183
						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
   184
					}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   185
					else if(regex_search(tmpline.c_str(), what, textSize))
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   186
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   187
						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
   188
						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
   189
					}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   190
					else if(regex_search(tmpline.c_str(), what, dataSize))
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   191
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   192
						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
   193
						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
   194
					}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   195
					else if(regex_search(tmpline.c_str(), what, bssSize))
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   196
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   197
						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
   198
						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
   199
					}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   200
					else if(regex_search(tmpline.c_str(), what, totalDataSize))
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   201
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   202
						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
   203
						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
   204
					}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   205
				}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   206
				symgen->AddEntry(tmpEntry);
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
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   211
		symgen->SetFinished();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   212
		symgen->Release();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   213
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   214
	else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   215
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   216
		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
   217
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   218
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   219