imgtools/imglib/symbolutil/logparser.cpp
author lorewang
Wed, 01 Dec 2010 16:05:36 +0800
changeset 715 e0739b8406dd
parent 714 e5a58c351011
permissions -rw-r--r--
Specify extenal tool with path
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
			}
714
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
    99
			else if(linebuf.compare(0,15,"Executable File") == 0)
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
   100
			{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
   101
				if(linebuf.find("size:", 26) != string::npos)
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
   102
				{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
   103
					size_t startpos = linebuf.find('\'') ;
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
   104
					size_t endpos   = linebuf.rfind('\'');
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
   105
					if((startpos!=string::npos) && (endpos!=string::npos))
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
   106
					{
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
   107
						symgen->AddFile(linebuf.substr(startpos+1,endpos-startpos-1), true);
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
   108
					}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
   109
				}
e5a58c351011 feature bsym format symbol rombuild support
marvin shi <marvin.shi@nokia.com>
parents: 712
diff changeset
   110
			}
695
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   111
			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
   112
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   113
				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
   114
				{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   115
					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
   116
					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
   117
					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
   118
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   119
						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
   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
			}
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
		symgen->SetFinished();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   125
		symgen->Release();
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
	else
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
		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
   130
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   131
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   132
	return;
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
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   135
RomLogParser::RomLogParser()
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
	iImageType = ERomImage;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   138
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   139
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   140
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
   141
{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   142
	string linebuf;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   143
	SymbolGenerator* symgen = SymbolGenerator::GetInstance();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   144
	symgen->SetImageType(iImageType);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   145
	symgen->SetSymbolFileName(string(LogFilename));
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   146
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   147
	ifstream logfd(LogFilename);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   148
	if(logfd.is_open())
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   149
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   150
		//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
   151
		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
   152
		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
   153
		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
   154
		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
   155
		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
   156
		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
   157
		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
   158
		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
   159
		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
   160
		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
   161
		string tmpline, tmpaddr;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   162
		boost::cmatch what;
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   163
		while(getline(logfd, tmpline))
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   164
		{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   165
			TPlacedEntry tmpEntry;
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   166
			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
   167
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   168
				break;
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, sourceFile))
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
				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
   173
				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
   174
				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
   175
				symgen->AddEntry(tmpEntry);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   176
			}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   177
			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
   178
			{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   179
				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
   180
				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
   181
				{
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   182
					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
   183
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   184
						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
   185
						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
   186
					} 
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   187
					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
   188
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   189
						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
   190
						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
   191
					}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   192
					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
   193
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   194
						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
   195
						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
   196
					}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   197
					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
   198
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   199
						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
   200
						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
   201
					}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   202
					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
   203
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   204
						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
   205
						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
   206
					}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   207
					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
   208
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   209
						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
   210
						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
   211
					}
712
df89378e9223 Fix these errors:
Ross Qin <ross.qin@nokia.com>
parents: 695
diff changeset
   212
					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
   213
					{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   214
						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
   215
						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
   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
				symgen->AddEntry(tmpEntry);
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   219
			}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   220
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   221
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   222
		}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   223
		symgen->SetFinished();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   224
		symgen->Release();
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   225
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   226
	else
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   227
	{
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   228
		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
   229
	}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   230
}
46ca13b54f56 features: bsym for rofsbuild and log input support for rombuild
marvin shi <marvin.shi@nokia.com>
parents:
diff changeset
   231