Merge
authorkelvzhu
Wed, 27 Oct 2010 16:03:51 +0800
changeset 662 60be34e1b006
parent 654 7c11c3d8d025 (diff)
parent 661 199bb033aacf (current diff)
child 663 8e27d440923e
Merge
bintools/evalid/EvalidCompare.pm
imgtools/romtools/group/release.txt
imgtools/romtools/rofsbuild/rofsbuild.cpp
imgtools/romtools/rofsbuild/symbolgenerator.cpp
imgtools/romtools/rofsbuild/symbolgenerator.h
--- a/bintools/evalid/EvalidCompare.pm	Tue Oct 26 11:04:46 2010 +0100
+++ b/bintools/evalid/EvalidCompare.pm	Wed Oct 27 16:03:51 2010 +0800
@@ -231,7 +231,7 @@
     }
   }
 
-  if ($typeBuf =~ /^!<arch>\x0A(.{48}([0-9 ]{9})\x60\x0A(......))/s) {
+  if ($typeBuf =~ /^!<arch>\x0A(.{48}([0-9 ]{9}).\x60\x0A(......))/s) {
     # library - could be MARM or WINS
 
     $typeBuf = $1;
--- a/imgtools/buildrom/group/release.txt	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/buildrom/group/release.txt	Wed Oct 27 16:03:51 2010 +0800
@@ -1,3 +1,8 @@
+Version 3.31.0 (BUILDROM)
+===============
+Released by Lorence Wang, 20/10/2010
+	1) Volume Serial NO. for FAT image.
+
 Version 3.30.0 (BUILDROM)
 ===============
 Released by Lorence Wang, 12/10/2010
--- a/imgtools/buildrom/tools/buildrom.pm	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/buildrom/tools/buildrom.pm	Wed Oct 27 16:03:51 2010 +0800
@@ -67,7 +67,7 @@
 my $enforceFeatureManager = 0; # Flag to make Feature Manager mandatory if SYMBIAN_FEATURE_MANAGER macro is defined. 
 
 my $BuildromMajorVersion = 3 ;
-my $BuildromMinorVersion = 30;
+my $BuildromMinorVersion = 31;
 my $BuildromPatchVersion = 0;
 
 
@@ -3666,7 +3666,7 @@
 	{
 		return $line;
 	}
-  	elsif($line =~ /^\s*volume\s*=.*/i)
+  	elsif($line =~ /^\s*(volume|volumeid)\s*=.*/i)
   	{
   		return $line;		
   	}
--- a/imgtools/imglib/inc/fatdefines.h	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/imglib/inc/fatdefines.h	Wed Oct 27 16:03:51 2010 +0800
@@ -16,6 +16,7 @@
 */
 #ifndef __FAT_DEFINES_HEADER__
 #define __FAT_DEFINES_HEADER__
+#include <time.h>
 #include <e32std.h>
 struct TFATBootSector {
 	TUint8 BS_jmpBoot[3];
@@ -130,8 +131,12 @@
     TUint16 iDriveSectorSize;
     TUint32 iDriveClusterSize;
     TUint8 iDriveNoOfFATs;    
+    TUint32 iVolumeId;
     ConfigurableFatAttributes():iImageSize(0),iDriveSectorSize(512),iDriveClusterSize(0),iDriveNoOfFATs(2){
         memcpy(iDriveVolumeLabel,"NO NAME    \0",12);
+				time_t rawtime;
+				time(&rawtime);
+				iVolumeId = (TUint32)rawtime;
     }
 };
 #endif
--- a/imgtools/romtools/group/release.txt	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/romtools/group/release.txt	Wed Oct 27 16:03:51 2010 +0800
@@ -1,3 +1,19 @@
+Version 2.16.1 (ROFSBUILD)
+===============
+Released by Marvin Shi, 25/10/2010
+	1) ou1cimx1#627682  Rofsbuild hangs with "-loginput" option on linux
+	
+=======
+Version 2.16.0 (ROFSBUILD)
+===============
+Released by Marvin Shi and Jason Cui, 21/10/2010
+	1) Concurrent symbol generation.
+	
+Version 2.15.0 (ROFSBUILD)
+===============
+Released by Lorence Wang, 20/10/2010
+	1) Volume Serial NO. for FAT image.
+
 Version 2.18.4 (ROMBUILD)
 Version 2.14.2 (ROFSBUILD)
 ===============
--- a/imgtools/romtools/maksym/maksymrofs.pl	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/romtools/maksym/maksymrofs.pl	Wed Oct 27 16:03:51 2010 +0800
@@ -15,371 +15,8 @@
 # Produces symbolic information given a ROFS log file and .map files for relevant binary files
 #
 
-require 5.003_07;
-no strict 'vars';
-use English;
-use FindBin;		# for FindBin::Bin
-
-# Version
-my $MajorVersion = 1;
-my $MinorVersion = 1;
-my $PatchVersion = 0;
-
-# Globals
-my $maksym = "";
-my $rofsbuild;
-my $debug = 0;
-
-&args;
-&main;
+shift @ARGV;
+my $logfile = shift @ARGV;
+my $command = "rofsbuild -loginput=$logfile";
+system ($command);
 exit 0;
-
-sub CompareAddrs()
-{
-    return -1 if ($a < $b);
-    return 1 if ($a > $b);
-    return 0;
-}
-
-#
-# main
-#
-sub main()
-{
-	open (ROFS, "<$rofsbuild") or die "ERROR: Can't open rofsbuild log file \"$rofsbuild\"\n";
-	if ($maksym ne "") 
-	{
-		open (SYM, ">$maksym") or die "ERROR: Can't open output file \"$maksym\"\n";
-   		print "Creating $maksym...\n"
-	}
-	
-	my $curretnLine;
-	while ($currentLine = <ROFS>) 	
-	{
-		# Check that the given log file is from a rofs image and set up the name for the symbol file
-		if ($currentLine =~ /^Creating Rofs image (\S*)/) 
-		{
-			if ($maksym eq "") 
-			{
-				# For backwards compatibility, replace trailing .img with .symbol
-				# if no trailing .img, just append .symbol anyway
-				$maksym = $1;
-				$maksym =~ s/(\.img)?$/.symbol/i;
-				close SYM;
-				open (SYM, ">$maksym") or die "ERROR: Can't open output file \"$maksym\"\n";
-				print "\nCreating $maksym...\n"
-			}
-			next;
-		}
-		
-		# found at end of file
-		if ($currentLine =~ /^Writing Rom image/) 
-		{
-			close SYM;
-			$maksym = "";
-			next;
-		}
-		
-		# Data file
-		if ($currentLine =~ /^File \'(.*)\' size: \S+\s*$/) 
-		{
-			my $file = $1;
-			$file =~ /([^\\]+)$/;
-			printf SYM "\nFrom    $file\n\n00000000    0000    $1\n";
-		}
-
-		# Executable file
-		elsif ($currentLine =~ /^Compressed executable File \'(.*)\' size: \S+\s*, mode:\S+\s*$/) 
-		{
-			ProcessCompressedLine($1);
-		}
-	}
-	close SYM;
-	close ROFS;
-}
-
-sub ProcessCompressedLine
-{
-	my ($file) = @_;
-
-	my $mapfile;
-	my $mapfile2;
-	print SYM "\nFrom    $file\n\n";
-
-	# Look in map file for symbols in .text and relocate them
-	$mapfile2 = $file.".map";			
-	$mapfile = $file;
-	$mapfile =~ s/\.\w+$/\.map/;			
-	if (!(open (MAP, "$mapfile2") || open (MAP, "$mapfile"))) 
-	{
-		print "$file\nWarning: Can't open \"$mapfile2\" or \"$mapfile\"\n";
-		# couldn't find map file so output in format that is used for non-binary files
-		my $BinSize = GetSizeFromBinFile($file);
-		$file =~ /([^\\]+)$/;
-		printf "00000000    %04x    $1\n", $BinSize;
-		printf SYM "00000000    %04x    $1\n", $BinSize;
-	} 
-	else 
-	{
-		my @maplines;
-		while ($_ = <MAP>) 
-		{
-			push @maplines, $_;
-		}
-		close MAP;
-		# See if we're dealing with the RVCT output
-		if ($file =~m/ARMV5/i) 
-		{
-			ProcessArmv5File($file, \@maplines);
-		} 
-		elsif( ($file =~ /GCCE/i) || ($file =~ /ARM4/i) )
-		{
-			ProcessGcceOrArm4File($file, \@maplines);
-		}
-		else
-		{
-			print "\nWarning: cannot determine linker type used to create $file\n";
-			$file =~ /([^\\]+)$/;
-			printf SYM "00000000    0000    $1\n";
-		}
-	}
-}
-
-sub ProcessArmv5File
-{
-	my ($file, $mapLines) = @_;
-	my @maplines = @$mapLines;
-	if ($maplines[0] !~ /^ARM Linker/) 
-	{
-		print "\nWarning: expecting $file to be generated by ARM linker\n";
-		# file not in format produced by ARMV5 linker so treat file as non-binary file
-		$file =~ /([^\\]+)$/;
-		printf SYM "00000000    0000    $1\n";
-	}
-	else
-	{
-		# scroll down to the global symbols
-		while ($_ = shift @maplines) 
-		{
-			if ($_ =~ /Global Symbols/) 
-			{
-				last;
-			}
-		}
-
-		my %syms;
-		my $baseOffset; # offset to subtract from each address so that the first entry has address 0x0
-
-		foreach (@maplines) 
-		{
-			# name address ignore size section
-			if (/^\s*(.+)\s*(0x\S+)\s+[^\d]*(\d+)\s+(.*)$/) 
-			{
-				my $sym = $1;
-				my $addr = hex($2);
-				my $size = sprintf("%04x",$3);
-				my $section = $4;
-				$size = sprintf("%04x", 8) if ($section =~ /\(StubCode\)/);
-				
-				# it is possible that there will be more than one entry in a log file for a
-				# particular address, this is because aliases are included.
-				# The following code checks that the correct function (i.e. the one with
-				# non-zero size) is being included in the symbol file.
-                                if($addr > 0) {
-                                    if( ! defined $baseOffset ) {
-                                        $baseOffset = $addr;
-                                    }
-                                    # no entry at this address so create one regardless of whether size is zero
-                                    # an entry at this address exists, replace if it is an alias
-                                    if( (! exists $syms{$addr-$baseOffset}) || !($size eq "0000")) {
-                                        $syms{$addr - $baseOffset} = "$size    $sym $section";
-                                    }
-                                }
-			}
-		}
-
-		# Write symbols in address order
-		my @addrs = sort CompareAddrs keys %syms;
-		for ($i = 0; $i < @addrs ; $i++) 
-		{
-			my $thisaddr = $addrs[$i];
-			printf SYM "%08x    %s\n",
-			$thisaddr, $syms{$thisaddr};
-		}
-	}
-}
-
-sub ProcessGcceOrArm4File
-{
-	my ($file, $mapLines) = @_;
-	my @maplines = @$mapLines;
-	my %syms;
-	my $stubhex=1;
-
-	# Find text section
-	while (($_ = shift @maplines) && !(/^\.text\s+/)) 
-	{
-	}
-
-	/^\.text\s+(\w+)\s+\w+/ or die "ERROR: Can't get .text section info for \"$file\"\n";
-
-	my $imgtext=hex($1);
-
-	# Slurp symbols 'til the end of the text section
-	foreach (@maplines) 
-	{
-
-		# blank line marks the end of the text section
-		last if (/^$/);
-
-		# .text <addr> <len>  <library(member)>
-		# .text$something
-		#       <addr> <len>  <library(member)>
-		#       <addr> <len>  LONG 0x0
-
-		if (/^\s(\.text)?\s+(0x\w+)\s+(0x\w+)\s+(.*)$/io) 
-		{
-			my $address = hex($2);
-			my $length = hex($3);
-			my $libraryfile = $4;
-			next if ($libraryfile =~ /^LONG 0x/);
-			
-			$syms{$address+$length} = ' ';	# impossible symbol as end marker
-
-			#set $stubhex value as $address if there is a match
-			if ($libraryfile =~ /.*lib\(.*d\d*s_?\d{5}.o\)$/io) 
-			{
-				$stubhex=$address;
-			}
-			next;
-		}
-
-		#  <addr>  <symbol name possibly including spaces>
-		if (/^\s+(\w+)\s\s+([a-zA-Z_].+)/o) 
-		{
-			my $addr = hex($1);
-			my $symbol = $2;
-			$symbol = "stub $symbol" if ($addr == $stubhex);
-			$syms{$addr} = $symbol;
-			next;
-		}
-	}				
-
-	# Write symbols in address order
-	@addrs = sort CompareAddrs keys %syms;
-	for ($i = 0; $i < @addrs - 1; $i++) 
-	{
-		my $symbol = $syms{$addrs[$i]};
-		next if ($symbol eq ' ');
-		printf SYM "%08x    %04x    %s\n",
-		$addrs[$i] - $imgtext, $addrs[$i+1]-$addrs[$i], $symbol;
-	}
-	# last address assumed to be imgtext+lentext
-
-	close MAP;
-}
-
-#
-# args - get command line args
-#
-sub args
-{
-	my $arg;
-	my @args;
-	my $flag;
-
-	&help if (!@ARGV);
-
-	while (@ARGV) 
-	{
-		$arg = shift @ARGV;
-
-		if ($arg=~/^[\-](\S*)$/) 
-		{
-			$flag=$1;
-
-			if ($flag=~/^[\?h]$/i) 
-			{
-				&help;
-			}
-			elsif ($flag=~/^d$/i) 
-			{
-				$debug = 1;
-			}
-		       	else 
-			{
-				print "\nERROR: Unknown flag \"-$flag\"\n";
-				&usage;
-				exit 1;
-			}
-		}
-		else 
-		{
-			push @args,$arg;
-		}
-	}
-
-	if (@args)
-	{
-		$rofsbuild = shift @args;
-		if (@args) 
-		{
-			$maksym = shift @args;
-			if (@args) 
-			{
-				print "\nERROR: Incorrect argument(s) \"@args\"\n";
-				&usage;
-				exit 1;
-			}
-		}
-	}
-}
-
-sub help ()
-{
-	my $build;
-
-	print "\nmaksymrofs - Produce symbolic information given a ROFS image V${MajorVersion}.${MinorVersion}.${PatchVersion}\n";
-	&usage;
-	exit 0;
-}
-
-sub usage ()
-{
-    print <<EOF
-
-Usage:
-  maksymrofs <logfile> [<outfile>]
-
-Where:
-  <logfile>   Log file from rofsbuild tool.
-  <outfile>   Output file. Defaults to imagename.symbol.
-EOF
-    ;
-    exit 0;
-}
-
-sub GetSizeFromBinFile ()
-{
-   my ($file) = @_;
-   my $tmpfile = "temp.info";
-   system("readimage $file -o $tmpfile");
-   return 0 if (!-e $tmpfile);
-   
-   open (TMP, "<$tmpfile");
-   my $line;
-   my $size = 0;
-   while ($line = <TMP>)
-   {
-      print $line;
-      if ($line =~ /^Code size\W+(\w+)$/)
-      {
-        $size = hex($1);
-        last;
-      }
-   }
-   close TMP;
-   unlink $tmpfile;
-   return $size;
-}
-
--- a/imgtools/romtools/rofsbuild/fatimagegenerator.cpp	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/romtools/rofsbuild/fatimagegenerator.cpp	Wed Oct 27 16:03:51 2010 +0800
@@ -76,9 +76,7 @@
 	iFatHeader.BS_DrvNum = 0x80 ;
 	iFatHeader.BS_BootSig = 0x29 ;
 
-	time_t rawtime;
-	time(&rawtime);
-	*((TUint32*)iFatHeader.BS_VolID) = (TUint32)rawtime;
+	*((TUint32*)iFatHeader.BS_VolID) = aAttr.iVolumeId;
 	memcpy(iFatHeader.BS_VolLab,aAttr.iDriveVolumeLabel,sizeof(iFatHeader.BS_VolLab));
 	if(aAttr.iImageSize == 0){
 		if(aType == EFat32)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/imgtools/romtools/rofsbuild/inc/logging/loggingexception.hpp	Wed Oct 27 16:03:51 2010 +0800
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef ROM_TOOLS_ROFSBUILD_LOGGING_LOGGINGEXCEPTION_H_
+#define ROM_TOOLS_ROFSBUILD_LOGGING_LOGGINGEXCEPTION_H_
+
+
+/*
+ * @class LoggingException
+ */
+class LoggingException
+{
+public:
+	LoggingException(int ErrorCode);
+
+	int GetErrorCode(void);
+
+	const char* GetErrorMessage(void);
+
+	static int RESOURCE_ALLOCATION_FAILURE;
+	static int INVALID_LOG_FILENAME       ;
+
+	virtual ~LoggingException(void);
+protected:
+	int errcode;
+private:
+	LoggingException(void);
+
+	LoggingException& operator = (const LoggingException&);
+};
+
+
+#endif  /* defined ROM_TOOLS_ROFSBUILD_LOGGING_LOGGINGEXCEPTION_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/imgtools/romtools/rofsbuild/inc/logging/logparser.hpp	Wed Oct 27 16:03:51 2010 +0800
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef ROM_TOOLS_ROFSBUILD_LOGGING_LOGPARSER_H_
+#define ROM_TOOLS_ROFSBUILD_LOGGING_LOGPARSER_H_
+
+
+/**
+ * @class LogParser
+ */
+class LogParser
+{
+public:
+	static LogParser* GetInstance(void) throw (LoggingException);
+
+	void ParseSymbol(const char* LogFilename) throw (LoggingException);
+
+	void Cleanup(void);
+protected:
+	static LogParser* Only;
+private:
+	LogParser(void);
+
+	LogParser(const LogParser&);
+
+	LogParser& operator = (const LogParser&);
+};
+
+
+
+#endif  /* defined ROM_TOOLS_ROFSBUILD_LOGGING_LOGPARSER_H_ */
--- a/imgtools/romtools/rofsbuild/r_obey.cpp	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/romtools/rofsbuild/r_obey.cpp	Wed Oct 27 16:03:51 2010 +0800
@@ -91,6 +91,7 @@
 	{_K("dataimagename"),1, 1,EKeywordDataImageName, "Data Drive image file name"},
 	{_K("dataimagefilesystem"),1, 1,EKeywordDataImageFileSystem, "Drive image file system format"},
 	{_K("dataimagesize"),1, 1,EKeywordDataImageSize, "Maximum size of Data Drive image"},
+	{_K("volumeid"),1, 1,EKeywordDataImageVolumeID, "Volume ID of Data Drive image"},
 	{_K("volume"),1, -1,EKeywordDataImageVolume, "Volume Label of Data Drive image"},
 	{_K("sectorsize"),1, 1,EKeywordDataImageSectorSize, "Sector size(in bytes) of Data Drive image"},
 	{_K("clustersize"),1, 1,EKeywordDataImageClusterSize, "Cluster size(in bytes) of Data Drive image"},
@@ -819,30 +820,33 @@
 
 			TUint position = volumeLabel.find(volumeLabelKeyword.c_str(),0,volumeLabelKeyword.size());
 			position += volumeLabelKeyword.size();
-			if (volumeLabel.find('=',position) != string::npos) {
-				position=volumeLabel.find('=',position);
-				++position;
+			while (iReader.IsGap(volumeLabel[position]))
+				position ++;
+			volumeLabel = volumeLabel.substr(position);
+				
+			if (volumeLabel.find('=',0) != string::npos) {
+				Print(EWarning,"Value for Volume Label includes illegel charactor. Default value is considered.\n");
+				break;
 			}								
 
-			position = volumeLabel.find_first_not_of(' ',position);
+			// Remove the new line character from the end
+			position = volumeLabel.find_first_of("\n");
 			if (position != string::npos) {
-				volumeLabel = volumeLabel.substr(position);
-
-				// Remove the new line character from the end
-				position = volumeLabel.find_first_of("\r\n");
-				if (position != string::npos)
-					volumeLabel = volumeLabel.substr(0,position);
-				size_t length = volumeLabel.length() ;
-				if(length > 11) 
-						length = 11 ;
-				memcpy(iConfigurableFatAttributes.iDriveVolumeLabel,volumeLabel.c_str(),length) ;
-				while(length != 11)
-					iConfigurableFatAttributes.iDriveVolumeLabel[length++] = ' ';
-				iConfigurableFatAttributes.iDriveVolumeLabel[length] = 0;
+				if (position != 0 && volumeLabel[position-1] == '\r')
+					position --;
+				volumeLabel = volumeLabel.substr(0,position);
 			}
-			else {
+			size_t length = volumeLabel.length();
+			if (length == 0) {
 				Print(EWarning,"Value for Volume Label is not provided. Default value is considered.\n");
+				break;
 			}
+			if(length > 11) 
+					length = 11 ;
+			memcpy(iConfigurableFatAttributes.iDriveVolumeLabel,volumeLabel.c_str(),length) ;
+			while(length != 11)
+				iConfigurableFatAttributes.iDriveVolumeLabel[length++] = ' ';
+			iConfigurableFatAttributes.iDriveVolumeLabel[length] = 0;
 			break;
 		}
 	case EKeywordDataImageSectorSize:
@@ -882,6 +886,21 @@
 				iConfigurableFatAttributes.iDriveNoOfFATs = noOfFats;			
 		}			
 		break;			
+	case EKeywordDataImageVolumeID:
+		{
+			static bool isSet = false;
+			if (isSet)
+				Print(EWarning,"Duplicate setting for volume ID will be ignored.\n");
+			const char* bigString = iReader.Word(1);
+			TUint32 volumeid = 0;
+			TInt res = Val(volumeid,bigString); 
+			if (res != KErrNone || volumeid == 0xFFFFFFFF)
+				Print(EWarning,"Invalid Volume ID specified. Default value is considered.\n");
+			else
+				iConfigurableFatAttributes.iVolumeId = volumeid;			
+			isSet = true;
+		}			
+		break;			
 	default:
 		// unexpected keyword iReader.Word(0), keep going.
 		break;
--- a/imgtools/romtools/rofsbuild/r_obey.h	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/romtools/rofsbuild/r_obey.h	Wed Oct 27 16:03:51 2010 +0800
@@ -75,6 +75,7 @@
 	EKeywordDataImageName,    
 	EKeywordDataImageFileSystem, 
 	EKeywordDataImageSize,
+	EKeywordDataImageVolumeID,
 	EKeywordDataImageVolume,
 	EKeywordDataImageSectorSize,
 	EKeywordDataImageClusterSize,
@@ -158,12 +159,12 @@
 
 	void ProcessTime(TInt64& aTime);
 	static void TimeNow(TInt64& aTime);
+	inline static TBool IsGap(char ch) {
+		return (ch==' ' || ch=='=' || ch=='\t');
+	}
 private:
 	TInt ReadAndParseLine(); 
 	TInt Parse();
-	inline static TBool IsGap(char ch) {
-		return (ch==' ' || ch=='=' || ch=='\t');
-	}
 
 	static const ObeyFileKeyword iKeywords[];
 	static const FileAttributeKeyword iAttributeKeywords[];
--- a/imgtools/romtools/rofsbuild/r_rofs.cpp	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/romtools/rofsbuild/r_rofs.cpp	Wed Oct 27 16:03:51 2010 +0800
@@ -356,7 +356,7 @@
             thrds.join_all();
             delete [] workers;
             if(iSymGen)
-                iSymGen->AddFile("",false);
+                iSymGen->SetFinished();
 
             TUint offset = aBaseOffset;
             TUint8* dest = aDestBase;
--- a/imgtools/romtools/rofsbuild/rofsbuild.cpp	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/romtools/rofsbuild/rofsbuild.cpp	Wed Oct 27 16:03:51 2010 +0800
@@ -34,6 +34,8 @@
 #include "cache/cachevalidator.hpp"
 #include "cache/cacheablelist.hpp"
 #include "cache/cachemanager.hpp"
+#include "logging/loggingexception.hpp"
+#include "logging/logparser.hpp"
 #include <malloc.h>
  
 #ifndef WIN32
@@ -46,8 +48,8 @@
 #endif
 
 static const TInt RofsbuildMajorVersion=2;
-static const TInt RofsbuildMinorVersion=14;
-static const TInt RofsbuildPatchVersion=2;
+static const TInt RofsbuildMinorVersion=16;
+static const TInt RofsbuildPatchVersion=1;
 static TBool SizeSummary=EFalse;
 static TPrintType SizeWhere=EAlways;
 
@@ -78,6 +80,7 @@
 TBool gSmrImage = EFalse;
 string gSmrFileName = "";
 static string cmdlogfile = "";
+static string loginput = "";
 
 //Cache global variables
 bool gCache = false;
@@ -115,7 +118,8 @@
 	"        -argfile=<FileName>   specify argument-file name containing list of command-line arguments\n"
 "        -lowmem     use memory-mapped file for image build to reduce physical memory consumption\n"
 "        -k     to enable keepgoing when duplicate files exist in oby\n"
-"        -logfile=<fileName>           specify log file\n";
+"        -logfile=<fileName>           specify log file\n"
+"        -loginput=<log filename>      specify as input a log file and produce as output symbol file.\n";
 
 char ReallyHelpText[] =
 "Log Level:\n"
@@ -325,6 +329,9 @@
 			else if (strnicmp(argv[i], "-logfile=",9) ==0) {
 				cmdlogfile = argv[i] + 9;
 			}
+			else if (strnicmp(argv[i], "-loginput=", 10) == 0) {
+				loginput = argv[i] + 10;
+			}
 			else {
 #ifdef WIN32
 				Print (EWarning, "Unrecognised option %s\n",argv[i]);
@@ -348,7 +355,7 @@
 		return;
 
 	if((gDriveImage == EFalse) && (gSmrImage ==  EFalse) && 
-		(filename.empty() || (gUseCoreImage && gImageFilename.length() == 0))){
+		(filename.empty() || (gUseCoreImage && gImageFilename.length() == 0)) && (loginput.length() == 0)){
 			Print (EAlways, HelpText);
 			if (reallyHelp) {
 				ObeyFileReader::KeywordHelp();
@@ -487,6 +494,29 @@
 		gCPUNum = MAXIMUM_THREADS;
 	PrintVersion();
 	processCommandLine(argc, argv);
+	if(gThreadNum == 0) {
+		if(gCPUNum > 0) {
+			printf("WARNING: The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum);
+			gThreadNum = gCPUNum;
+		}
+		else {
+			printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
+			gThreadNum = DEFAULT_THREADS;
+		}
+	}
+	if(loginput.length() >= 1)
+	{
+		try
+		{
+			LogParser::GetInstance()->ParseSymbol(loginput.c_str());
+		}
+		catch(LoggingException le)
+		{
+			printf("ERROR: %s\r\n", le.GetErrorMessage());
+			return 1;
+		}
+		return 0;
+	}
 	//if the user wants to clean up the cache, do it only.
 	if(gCleanCache){
 		try {
@@ -515,16 +545,6 @@
 	if ((!obeyFileName) && (!gDriveFilename.empty()) && (!gSmrFileName.empty())){
 		return KErrGeneral;
 	}
-	if(gThreadNum == 0) {
-		if(gCPUNum > 0) {
-			printf("WARNING: The number of processors (%d) is used as the number of concurrent jobs.\n", gCPUNum);
-			gThreadNum = gCPUNum;
-		}
-		else {
-			printf("WARNING: Can't automatically get the valid number of concurrent jobs and %d is used.\n", DEFAULT_THREADS);
-			gThreadNum = DEFAULT_THREADS;
-		}
-	}
 	// Process drive obey files.
 	if(gDriveImage) {  
 		char temp = 0;
@@ -582,11 +602,8 @@
 	}
 	// Process Rofs Obey files.
 	if(obeyFileName) {
-		if(cmdlogfile.empty())
-			cmdlogfile.assign("ROFSBUILD.LOG");
-		else if (cmdlogfile[cmdlogfile.length()-1] == '\\' || cmdlogfile[cmdlogfile.length()-1] == '/') {
+		if (cmdlogfile.empty() || cmdlogfile[cmdlogfile.size()-1] == '\\' || cmdlogfile[cmdlogfile.size()-1] == '/')
 			cmdlogfile += "ROFSBUILD.LOG" ;
-		}
 			
 	 	H.SetLogFile(cmdlogfile.c_str());
 		ObeyFileReader *reader = new ObeyFileReader(obeyFileName); 
--- a/imgtools/romtools/rofsbuild/rofsbuild.mmp	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/romtools/rofsbuild/rofsbuild.mmp	Wed Oct 27 16:03:51 2010 +0800
@@ -25,10 +25,13 @@
 SOURCE			 r_obey.cpp r_build.cpp r_rofs.cpp r_driveimage.cpp r_driveutl.cpp
 SOURCE			 rofsbuild.cpp r_coreimage.cpp r_smrimage.cpp symbolgenerator.cpp
 SOURCE			 fatcluster.cpp fsnode.cpp fatimagegenerator.cpp
+SOURCE			 symbolprocessunit.cpp
 SOURCEPATH	../../imglib/host
 SOURCE			h_utl.cpp h_file.cpp h_mem.cpp utf16string.cpp
 SOURCEPATH ../rofsbuild/src/cache
 SOURCE cachemanager.cpp cacheexception.cpp cache.cpp cacheablelist.cpp cachevalidator.cpp cachegenerator.cpp cacheentry.cpp
+SOURCEPATH ../rofsbuild/src/logging
+SOURCE loggingexception.cpp logparser.cpp
 
 // executable compression
 SOURCEPATH	../../imglib/e32uid
@@ -50,6 +53,7 @@
 USERINCLUDE   ../rofsbuild/inc
 USERINCLUDE   ../../imglib/boostlibrary/
 USERINCLUDE   ../../imglib/boostlibrary/boost
+USERINCLUDE   ../rofsbuild
 
 STATICLIBRARY 	patchdataprocessor parameterfileprocessor memmap
 STATICLIBRARY   boost_thread-1.39 boost_filesystem-1.39 boost_regex-1.39 boost_system-1.39 uniconv
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/imgtools/romtools/rofsbuild/src/logging/loggingexception.cpp	Wed Oct 27 16:03:51 2010 +0800
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#include "logging/loggingexception.hpp"
+
+
+int LoggingException::RESOURCE_ALLOCATION_FAILURE = 1;
+int LoggingException::INVALID_LOG_FILENAME        = 2;
+
+
+LoggingException::LoggingException(int ErrorCode)
+{
+	this->errcode = ErrorCode;
+
+	return;
+}
+
+
+int LoggingException::GetErrorCode(void)
+{
+	return this->errcode;
+}
+
+
+const char* LoggingException::GetErrorMessage(void)
+{
+	if(this->errcode == LoggingException::RESOURCE_ALLOCATION_FAILURE)
+		return "Not enough system resources to initialize logging module.";
+	else if(this->errcode == LoggingException::INVALID_LOG_FILENAME)
+		return "Invalid log filename as input.";
+//	else if(this->errcode == CacheException::CACHE_INVALID)
+//		return "Cache is invalid.";
+//	else if(this->errcode == CacheException::CACHE_IS_EMPTY)
+//		return "Cache is empty.";
+//	else if(this->errcode == CacheException::HARDDRIVE_FAILURE)
+//		return "A hard drive failure occurred in Cache operations.";
+
+	return "Undefined error type.";
+}
+
+
+LoggingException::~LoggingException(void)
+{
+	return;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/imgtools/romtools/rofsbuild/src/logging/logparser.cpp	Wed Oct 27 16:03:51 2010 +0800
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#include <new>
+#include <iostream>
+#include <fstream>
+#include <string>
+using namespace std;
+
+#include "logging/loggingexception.hpp"
+#include "logging/logparser.hpp"
+#include "symbolgenerator.h"
+
+
+LogParser* LogParser::Only = (LogParser*)0;
+
+
+LogParser* LogParser::GetInstance(void) throw (LoggingException)
+{
+	if(! LogParser::Only)
+	{
+		LogParser::Only = new (std::nothrow) LogParser();
+		if(! LogParser::Only)
+			throw LoggingException(LoggingException::RESOURCE_ALLOCATION_FAILURE);
+	}
+
+	return LogParser::Only;
+}
+
+
+void LogParser::ParseSymbol(const char* LogFilename) throw (LoggingException)
+{
+	string linebuf;
+	SymbolGenerator* symgen = SymbolGenerator::GetInstance();
+	symgen->SetSymbolFileName(string(LogFilename));
+
+	ifstream logfd(LogFilename);
+	if(logfd.is_open())
+	{
+		while(! logfd.eof())
+		{
+			getline(logfd, linebuf);
+			if(linebuf.compare(0,4,"File") == 0)
+			{
+				if(linebuf.find("size:", 4) != string::npos)
+				{
+					size_t startpos = linebuf.find('\'') ;
+					size_t endpos   = linebuf.rfind('\'');
+					if((startpos!=string::npos) && (endpos!=string::npos))
+					{
+						symgen->AddFile(linebuf.substr(startpos+1,endpos-startpos-1), false);
+					}
+				}
+			}
+			else if(linebuf.compare(0,26,"Compressed executable File") == 0)
+			{
+				if(linebuf.find("size:", 26) != string::npos)
+				{
+					size_t startpos = linebuf.find('\'') ;
+					size_t endpos   = linebuf.rfind('\'');
+					if((startpos!=string::npos) && (endpos!=string::npos))
+					{
+						symgen->AddFile(linebuf.substr(startpos+1,endpos-startpos-1), true);
+					}
+				}
+			}
+		}
+		symgen->SetFinished();
+		symgen->Release();
+	}
+	else
+	{
+		throw LoggingException(LoggingException::INVALID_LOG_FILENAME);
+	}
+
+	return;
+}
+
+
+void LogParser::Cleanup(void)
+{
+	return;
+}
+
+
+LogParser::LogParser(void)
+{
+	return;
+}
--- a/imgtools/romtools/rofsbuild/symbolgenerator.cpp	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/romtools/rofsbuild/symbolgenerator.cpp	Wed Oct 27 16:03:51 2010 +0800
@@ -15,6 +15,7 @@
 *
 */
 
+#include <vector>
 #include <boost/regex.hpp>
 #define MAX_LINE 65535
 #include "symbolgenerator.h"
@@ -25,6 +26,7 @@
 #else
 #define PATH_SEPARATOR '\\'
 #endif
+extern TInt gThreadNum;
 
 boost::mutex SymbolGenerator::iMutexSingleton;
 SymbolGenerator* SymbolGenerator::iInst = NULL;
@@ -37,6 +39,9 @@
     return iInst;
 }
 void SymbolGenerator::Release() {
+    if(iInst != NULL) {
+        iInst->join();
+    }
     iMutexSingleton.lock();
     if(iInst != NULL) {
         delete iInst;
@@ -57,216 +62,75 @@
     iMutex.unlock();
     iCond.notify_all();
 }
-void SymbolGenerator::ProcessExecutable( const string& fileName ){
-    char str[MAX_LINE];
-    string outString;
-    outString = "\nFrom    ";
-    outString += fileName + "\n\n";
-    iSymFile.write(outString.c_str(),outString.length());
-    string mapFile2 = fileName+".map";
-    size_t dot = fileName.rfind('.');
-    string mapFile = fileName.substr(0,dot)+".map";
-    ifstream fMap;
-    fMap.open(mapFile2.c_str());
-    if(!fMap.is_open()) {
-        fMap.open(mapFile.c_str());
-    }
+void SymbolGenerator::SetFinished() 
+{ 
 
-    if(!fMap.is_open()) {
-        printf("%s\nWarning: Can't open \"%s\" or \"%s\"\n",fileName.c_str(),mapFile2.c_str(),mapFile.c_str());
-        int binSize = GetSizeFromBinFile(fileName);
-        memset(str,0,sizeof(str));
-        sprintf(str,"%04x", binSize);
-        outString = "00000000    ";
-        outString += str;
-        outString += "    ";
-        outString += fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n";
-        iSymFile.write(outString.c_str(),outString.length());
+	iFinished = true; 
+	iCond.notify_all();
     }
-    else {
-		if(!fMap.good()) fMap.clear();
-        boost::regex regARMV5("ARMV5", boost::regex::icase);
-        boost::regex regGCCEoARMV4("(GCCE|ARMV4)", boost::regex::icase);
-        boost::cmatch what;
-        if(regex_search(fileName.c_str(), what, regARMV5)) {
-            ProcessArmv5File(fileName, fMap);
-        }
-        else if(regex_search(fileName.c_str(), what, regGCCEoARMV4)) {
-            ProcessGcceOrArm4File(fileName, fMap);
-        }
-        else {
-            printf("\nWarning: cannot determine linker type used to create %s\n",fileName.c_str());
-            outString = "00000000    0000    ";
-            outString += fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n";
-            iSymFile.write(outString.c_str(),outString.length());
+TPlacedEntry SymbolGenerator::GetNextPlacedEntry()
+{
+        if(regex_search(fileName, what, regARMV5)) {
+	TPlacedEntry pe("", false);
+	if(1)
+        else if(regex_search(fileName, what, regGCCEoARMV4)) {
+	{
+		boost::mutex::scoped_lock lock(iMutex);
+		while(!iFinished && iQueueFiles.empty())
+			iCond.wait(lock);
+		if(!iQueueFiles.empty())
+		{
+			pe = iQueueFiles.front();
+			iQueueFiles.pop();
         }
     }
-}
-void SymbolGenerator::ProcessDatafile( const string& fileName ){
-    string line = "\nFrom    "+fileName+"\n\n00000000    0000    "+fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n";
-    iSymFile.write(line.c_str(),line.length());
+	return pe;
 }
-void SymbolGenerator::ProcessArmv5File( const string& fileName, ifstream& aMap ){
-    aMap.seekg (0, ios::beg);
-    char str[MAX_LINE];
-    string outString;
-    aMap.getline(str,MAX_LINE);
-    boost::cmatch what;
-    boost::regex reg("^ARM Linker");
-    if(!regex_search(str, what, reg)) {
-        printf("\nWarning: expecting %s to be generated by ARM linker\n", fileName.c_str());
-        outString = "00000000    0000    "+fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n";
-        iSymFile.write(outString.c_str(),outString.length());
-    }
-    reg.assign("Global Symbols");
-    while(aMap.getline(str,MAX_LINE)) {
-        if(regex_search(str, what, reg)) {
-            break;
-        }
+void SymbolGenerator::thrd_func(){
+    	boost::thread_group threads;
+	SymbolWorker worker;
+    	for(int i=0; i < gThreadNum; i++)
+    	{
+    		threads.create_thread(worker);
     }
-
-    reg.assign("^\\s*(.+)\\s*0x(\\S+)\\s+[^\\d]*(\\d+)\\s+(.*)$");
-    string sSym,sTmp,sSection;
-    unsigned int addr,size,baseOffset = 0;
-    map<unsigned int,string> syms;
-    char symString[MAX_LINE];
-    while(aMap.getline(str,MAX_LINE)) {
-        if(regex_search(str, what, reg)) {
-            sSym.assign(what[1].first,what[1].second-what[1].first);
-            sTmp.assign(what[2].first,what[2].second-what[2].first);
-            addr = strtol(sTmp.c_str(), NULL, 16);
-            sTmp.assign(what[3].first,what[3].second-what[3].first);
-            size = strtol(sTmp.c_str(), NULL, 10);
-            sSection.assign(what[4].first,what[4].second-what[4].first);
-            if(sSection.find("(StubCode)") != string::npos)
-                size = 8;
-            if(addr > 0) {
-                memset(symString,0,sizeof(symString));
-                sprintf(symString,"%04x    ",size);
-                outString = symString;
-                outString += sSym+" ";
-                outString += sSection;
-                if(baseOffset == 0) 
-                    baseOffset = addr;
-                unsigned int k = addr - baseOffset;
-                if( (syms.find(k) == syms.end()) || size != 0) 
-                    syms[k] = outString;
+    	threads.join_all();
+        }
+SymbolGenerator::SymbolGenerator() : boost::thread(thrd_func),iFinished(false) {
+    }
+SymbolGenerator::~SymbolGenerator(){
+    if(joinable())
+        join();
+    iSymFile.flush();
+    iSymFile.close();
             }
-            // end of addr>0
-        }
+SymbolWorker::SymbolWorker()
+{
         // end of regex_search
     }
-
-    map<unsigned int,string>::iterator it;
-    for(it = syms.begin(); it != syms.end(); it++) {
-        memset(str,0,sizeof(str));
-        sprintf(str,"%08x",it->first);
-        outString = str;
-        outString += "    ";
-        outString += it->second+"\n";
-        iSymFile.write(outString.c_str(),outString.length());
-    }
-}
-void SymbolGenerator::ProcessGcceOrArm4File( const string& fileName, ifstream& aMap ){
-    aMap.seekg (0, ios_base::beg);
-    char str[MAX_LINE];
-    aMap.getline(str,MAX_LINE);
-    boost::cmatch what;
-    boost::regex reg("^\\.text\\s+");
-    while(aMap.getline(str,MAX_LINE)) {
-        if(regex_search(str, what, reg)) {
-            break;
-        }
-    }
-
-    reg.assign("^\\.text\\s+(\\w+)\\s+\\w+");
-    if(!regex_search(str, what, reg)) {
-        printf("ERROR: Can't get .text section info for \"%s\"\n",fileName.c_str());
+SymbolWorker::~SymbolWorker()
+{
     }
-    else {
-        string sTmp, sLibFile;
-        sTmp.assign(what[1].first,what[1].second-what[1].first);
-        unsigned int imgText = strtol(sTmp.c_str(), NULL, 16);
-
-        reg.assign("^LONG 0x.*", boost::regex::icase);
-        boost::cmatch what1;
-        boost::regex reg1("^\\s(\\.text)?\\s+(0x\\w+)\\s+(0x\\w+)\\s+(.*)$", boost::regex::icase);
-        boost::regex reg2("^\\s+(\\w+)\\s\\s+([a-zA-Z_].+)", boost::regex::icase);
-        boost::regex reg3(".*lib\\(.*d\\d*s_?\\d{5}.o\\)$", boost::regex::icase);
-
-        map<unsigned int,string> syms;
-        unsigned int addr, len, stubhex;
+void SymbolWorker::operator()()
+{
+	SymbolProcessUnit* aSymbolProcessUnit = new CommenSymbolProcessUnit();
+	SymbolGenerator* symbolgenerator = SymbolGenerator::GetInstance();
 
-        while(aMap.getline(str,MAX_LINE)) {
-            if(strlen(str) == 0)
+	while(1)
+	{
+		if(symbolgenerator->HasFinished() && symbolgenerator->IsEmpty())
+		{
+
                 break;
-            else if(regex_search(str, what, reg1)) {
-                sLibFile.assign(what[4].first,what[4].second-what[4].first);
-                if(!regex_search(sLibFile.c_str(), what1, reg)) {
-                    sTmp.assign(what[2].first,what[2].second-what[2].first);
-                    addr = strtol(sTmp.c_str(), NULL, 16);
-                    sTmp.assign(what[3].first,what[3].second-what[3].first);
-                    len = strtol(sTmp.c_str(), NULL, 16);
-                    syms[addr+len] = "";
-                    if(regex_search(sLibFile.c_str(), what, reg3)) {
-                        stubhex = addr;
+                if(!regex_search(sLibFile, what1, reg)) {
+                    if(regex_search(sLibFile, what, reg3)) {
                     }
-                }
-            }
-            else if(regex_search(str, what, reg2)) {
-                sTmp.assign(what[1].first,what[1].second-what[1].first);
-                addr = strtol(sTmp.c_str(), NULL, 16);
-                sTmp.assign(what[2].first,what[2].second-what[2].first);
-                syms[addr] = (addr == stubhex)? ("stub "+sTmp) : sTmp;
-            }
-        }
+
+
+
 
-        map<unsigned int,string>::iterator it = syms.begin();
-        map<unsigned int,string>::iterator itp = it++;
-        string outString;
-        for(; it != syms.end(); itp = it++) {
-            if(itp->second != "") {
-                memset(str,0,sizeof(str));
-                sprintf(str,"%08x    %04x    ",(itp->first-imgText), (it->first-itp->first));
-                outString = str;
-                outString += it->second+"\n";
-                iSymFile.write(outString.c_str(),outString.length());
-            }
-        }
-    }
-}
-int SymbolGenerator::GetSizeFromBinFile( const string& fileName ){
-    TInt ret = 0;
-    ifstream aIf(fileName.c_str(), ios_base::binary);
-    if( !aIf.is_open() ) {
-        printf("Warning: Cannot open file \n");
-    }
-    else {
-        E32ImageFile e32Image;
-        TUint32 aSz;
+		TPlacedEntry pe = symbolgenerator->GetNextPlacedEntry();
 
-        aIf.seekg(0,ios_base::end);
-        aSz = aIf.tellg();
-
-        e32Image.Adjust(aSz);
-        e32Image.iFileSize = aSz;
-
-        aIf.seekg(0,ios_base::beg);
-        aIf >> e32Image;
-        ret = e32Image.iOrigHdr->iCodeSize;
-    }
-    return ret;
-}
-void SymbolGenerator::thrd_func(){
-    SymbolGenerator* me = GetInstance();
-
-    TPlacedEntry pe("",false);
-    while(1) {
-        if(1) {
             //scope the code block with if(1) for lock
-            boost::mutex::scoped_lock lock(me->iMutex);
-            while(me->iQueueFiles.empty())
-                me->iCond.wait(lock);
             /*
             if(me->iQueueFiles.empty()) {
                 boost::this_thread::sleep(boost::posix_time::milliseconds(10));
@@ -274,23 +138,17 @@
             }
             */
 
-            pe = me->iQueueFiles.front();
-            me->iQueueFiles.pop();
-        }
 
         if(pe.iFileName == "")
-            break;
+			continue;
         else if(pe.iExecutable) 
-            me->ProcessExecutable(pe.iFileName);
+			aSymbolProcessUnit->ProcessExecutableFile(pe.iFileName);
         else
-            me->ProcessDatafile(pe.iFileName);
-    }
+			aSymbolProcessUnit->ProcessDataFile(pe.iFileName);
+		symbolgenerator->LockOutput();
+		aSymbolProcessUnit->FlushStdOut(cout);
+		aSymbolProcessUnit->FlushSymbolContent(symbolgenerator->GetOutputFileStream());
+		symbolgenerator->UnlockOutput();
 }
-SymbolGenerator::SymbolGenerator() : boost::thread(thrd_func) {
+	delete aSymbolProcessUnit;
 }
-SymbolGenerator::~SymbolGenerator(){
-    if(joinable())
-        join();
-    iSymFile.flush();
-    iSymFile.close();
-}
--- a/imgtools/romtools/rofsbuild/symbolgenerator.h	Tue Oct 26 11:04:46 2010 +0100
+++ b/imgtools/romtools/rofsbuild/symbolgenerator.h	Wed Oct 27 16:03:51 2010 +0800
@@ -23,6 +23,7 @@
 using namespace std;
 #include <boost/thread/thread.hpp>
 #include <boost/thread/condition.hpp>
+#include "symbolprocessunit.h"
 
 
 struct TPlacedEntry{
@@ -39,22 +40,33 @@
         static void Release();
         void SetSymbolFileName( const string& fileName );
         void AddFile( const string& fileName, bool isExecutable );
+        bool HasFinished()	{ return iFinished; }
+        void SetFinished();
+        bool IsEmpty() { return iQueueFiles.empty(); }
+        void LockOutput() { iOutputMutex.lock(); }
+        void UnlockOutput() { iOutputMutex.unlock(); }
+        TPlacedEntry GetNextPlacedEntry();
+        ofstream& GetOutputFileStream() { return iSymFile; };
     private:
         SymbolGenerator();
         ~SymbolGenerator();
-        void ProcessExecutable( const string& fileName );
-        void ProcessDatafile( const string& fileName );
-        void ProcessArmv5File( const string& fileName, ifstream& aMap );
-        void ProcessGcceOrArm4File( const string& fileName, ifstream& aMap );
-        int GetSizeFromBinFile( const string& fileName );
         static void thrd_func();
 
         queue<TPlacedEntry> iQueueFiles;
         boost::mutex iMutex;
+        boost::mutex iOutputMutex;
         static boost::mutex iMutexSingleton;
         static SymbolGenerator* iInst;
         boost::condition_variable iCond;
+        bool iFinished;
 
         ofstream iSymFile;
 };
+class SymbolWorker{
+public:
+	SymbolWorker();
+	~SymbolWorker();
+	void operator()();
+private:
+};
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/imgtools/romtools/rofsbuild/symbolprocessunit.cpp	Wed Oct 27 16:03:51 2010 +0800
@@ -0,0 +1,258 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#include <boost/regex.hpp>
+#include "symbolprocessunit.h"
+#include "e32image.h"
+#define MAX_LINE 65535
+
+#if defined(__LINUX__)
+#define PATH_SEPARATOR '/'
+#else
+#define PATH_SEPARATOR '\\'
+#endif
+
+void CommenSymbolProcessUnit::ProcessExecutableFile(const string& aFile)
+{
+	ResetContentLog();
+	char str[MAX_LINE];
+	string outString;
+	outString = "\nFrom    ";
+	outString += aFile + "\n\n";
+	iSymbolContentLog.push_back(outString);
+	string mapFile2 = aFile+".map";
+	size_t dot = aFile.rfind('.');
+	string mapFile = aFile.substr(0,dot)+".map";
+	ifstream fMap;
+	fMap.open(mapFile2.c_str());
+	if(!fMap.is_open()) {
+		fMap.open(mapFile.c_str());
+	}
+
+	if(!fMap.is_open()) {
+		sprintf(str, "%s\nWarning: Can't open \"%s\" or \"%s\"\n",aFile.c_str(),mapFile2.c_str(),mapFile.c_str());
+		iStdoutLog.push_back(str);
+	    int binSize = GetSizeFromBinFile(aFile);
+	    memset(str,0,sizeof(str));
+	    sprintf(str,"%04x", binSize);
+	    outString = "00000000    ";
+	    outString += str;
+	    outString += "    ";
+	    outString += aFile.substr(aFile.rfind(PATH_SEPARATOR)+1)+"\n";
+	    iSymbolContentLog.push_back(outString);
+	}
+	else {
+		if(!fMap.good()) fMap.clear();
+	    boost::regex regARMV5("ARMV5", boost::regex::icase);
+	    boost::regex regGCCEoARMV4("(GCCE|ARMV4)", boost::regex::icase);
+	    boost::cmatch what;
+	    if(regex_search(aFile, what, regARMV5)) {
+	        ProcessArmv5File(aFile, fMap);
+	    }
+	    else if(regex_search(aFile, what, regGCCEoARMV4)) {
+	        ProcessGcceOrArm4File(aFile, fMap);
+	    }
+	    else {
+	        sprintf(str, "\nWarning: cannot determine linker type used to create %s\n",aFile.c_str());
+	        iStdoutLog.push_back(str);
+	        outString = "00000000    0000    ";
+	        outString += aFile.substr(aFile.rfind(PATH_SEPARATOR)+1)+"\n";
+	        iSymbolContentLog.push_back(outString);
+	        }
+	    }
+}
+void CommenSymbolProcessUnit::ProcessDataFile(const string& aFile)
+{
+	ResetContentLog();
+	string line = "\nFrom    "+aFile+"\n\n00000000    0000    "+aFile.substr(aFile.rfind(PATH_SEPARATOR)+1)+"\n";
+	iSymbolContentLog.push_back(line);
+}
+void CommenSymbolProcessUnit::FlushStdOut(ostream& aOut)
+{
+	for(int i = 0; i < (int) iStdoutLog.size(); i++)
+	{
+		aOut << iStdoutLog[i];
+	}
+}
+void CommenSymbolProcessUnit::FlushSymbolContent(ostream &aOut)
+{
+	for(int i = 0; i < (int) iSymbolContentLog.size(); i++)
+	{
+		aOut << iSymbolContentLog[i];
+	}
+}
+void CommenSymbolProcessUnit::ResetContentLog()
+{
+	iStdoutLog.clear();
+	iSymbolContentLog.clear();
+}
+void CommenSymbolProcessUnit::ProcessArmv5File( const string& fileName, ifstream& aMap ){
+    aMap.seekg (0, ios::beg);
+    char str[MAX_LINE];
+    char outbuffer[MAX_LINE];
+    string outString;
+    aMap.getline(str,MAX_LINE);
+    boost::cmatch what;
+    boost::regex reg("^ARM Linker");
+    if(!regex_search(str, what, reg)) {
+        sprintf(outbuffer, "\nWarning: expecting %s to be generated by ARM linker\n", fileName.c_str());
+        iStdoutLog.push_back(outbuffer);
+        outString = "00000000    0000    "+fileName.substr(fileName.rfind(PATH_SEPARATOR)+1)+"\n";
+        iSymbolContentLog.push_back(outString);
+    }
+    reg.assign("Global Symbols");
+    while(aMap.getline(str,MAX_LINE)) {
+        if(regex_search(str, what, reg)) {
+            break;
+        }
+    }
+
+    reg.assign("^\\s*(.+)\\s*0x(\\S+)\\s+[^\\d]*(\\d+)\\s+(.*)$");
+    string sSym,sTmp,sSection;
+    unsigned int addr,size,baseOffset = 0;
+    map<unsigned int,string> syms;
+    char symString[MAX_LINE];
+    while(aMap.getline(str,MAX_LINE)) {
+        if(regex_search(str, what, reg)) {
+            sSym.assign(what[1].first,what[1].second-what[1].first);
+            sTmp.assign(what[2].first,what[2].second-what[2].first);
+            addr = strtol(sTmp.c_str(), NULL, 16);
+            sTmp.assign(what[3].first,what[3].second-what[3].first);
+            size = strtol(sTmp.c_str(), NULL, 10);
+            sSection.assign(what[4].first,what[4].second-what[4].first);
+            if(sSection.find("(StubCode)") != string::npos)
+                size = 8;
+            if(addr > 0) {
+                memset(symString,0,sizeof(symString));
+                sprintf(symString,"%04x    ",size);
+                outString = symString;
+                outString += sSym+" ";
+                outString += sSection;
+                if(baseOffset == 0)
+                    baseOffset = addr;
+                unsigned int k = addr - baseOffset;
+                if( (syms.find(k) == syms.end()) || size != 0)
+                    syms[k] = outString;
+            }
+            // end of addr>0
+        }
+        // end of regex_search
+    }
+
+    map<unsigned int,string>::iterator it;
+    for(it = syms.begin(); it != syms.end(); it++) {
+        memset(str,0,sizeof(str));
+        sprintf(str,"%08x",it->first);
+        outString = str;
+        outString += "    ";
+        outString += it->second+"\n";
+        iSymbolContentLog.push_back(outString);
+    }
+}
+void CommenSymbolProcessUnit::ProcessGcceOrArm4File( const string& fileName, ifstream& aMap ){
+    aMap.seekg (0, ios_base::beg);
+    char str[MAX_LINE];
+    char outbuffer[MAX_LINE];
+    aMap.getline(str,MAX_LINE);
+    boost::cmatch what;
+    boost::regex reg("^\\.text\\s+");
+    while(aMap.getline(str,MAX_LINE)) {
+        if(regex_search(str, what, reg)) {
+            break;
+        }
+    }
+
+    reg.assign("^\\.text\\s+(\\w+)\\s+\\w+");
+    if(!regex_search(str, what, reg)) {
+        sprintf(outbuffer, "ERROR: Can't get .text section info for \"%s\"\n",fileName.c_str());
+        iStdoutLog.push_back(outbuffer);
+    }
+    else {
+        string sTmp, sLibFile;
+        sTmp.assign(what[1].first,what[1].second-what[1].first);
+        unsigned int imgText = strtol(sTmp.c_str(), NULL, 16);
+
+        reg.assign("^LONG 0x.*", boost::regex::icase);
+        boost::cmatch what1;
+        boost::regex reg1("^\\s(\\.text)?\\s+(0x\\w+)\\s+(0x\\w+)\\s+(.*)$", boost::regex::icase);
+        boost::regex reg2("^\\s+(\\w+)\\s\\s+([a-zA-Z_].+)", boost::regex::icase);
+        boost::regex reg3(".*lib\\(.*d\\d*s_?\\d{5}.o\\)$", boost::regex::icase);
+
+        map<unsigned int,string> syms;
+        unsigned int addr, len, stubhex;
+
+        while(aMap.getline(str,MAX_LINE)) {
+            if(strlen(str) == 0)
+                break;
+            else if(regex_search(str, what, reg1)) {
+                sLibFile.assign(what[4].first,what[4].second-what[4].first);
+                if(!regex_search(sLibFile, what1, reg)) {
+                    sTmp.assign(what[2].first,what[2].second-what[2].first);
+                    addr = strtol(sTmp.c_str(), NULL, 16);
+                    sTmp.assign(what[3].first,what[3].second-what[3].first);
+                    len = strtol(sTmp.c_str(), NULL, 16);
+                    syms[addr+len] = "";
+                    if(regex_search(sLibFile, what, reg3)) {
+                        stubhex = addr;
+                    }
+                }
+            }
+            else if(regex_search(str, what, reg2)) {
+                sTmp.assign(what[1].first,what[1].second-what[1].first);
+                addr = strtol(sTmp.c_str(), NULL, 16);
+                sTmp.assign(what[2].first,what[2].second-what[2].first);
+                syms[addr] = (addr == stubhex)? ("stub "+sTmp) : sTmp;
+            }
+        }
+
+        map<unsigned int,string>::iterator it = syms.begin();
+        map<unsigned int,string>::iterator itp = it++;
+        string outString;
+        for(; it != syms.end(); itp = it++) {
+            if(itp->second != "") {
+                memset(str,0,sizeof(str));
+                sprintf(str,"%08x    %04x    ",(itp->first-imgText), (it->first-itp->first));
+                outString = str;
+                outString += it->second+"\n";
+                iSymbolContentLog.push_back(outString);
+            }
+        }
+    }
+}
+int CommenSymbolProcessUnit::GetSizeFromBinFile( const string& fileName ){
+    TInt ret = 0;
+    char outbuffer[MAX_LINE];
+    ifstream aIf(fileName.c_str(), ios_base::binary);
+    if( !aIf.is_open() ) {
+        printf(outbuffer, "Warning: Cannot open file \n");
+        iStdoutLog.push_back(outbuffer);
+    }
+    else {
+        E32ImageFile e32Image;
+        TUint32 aSz;
+
+        aIf.seekg(0,ios_base::end);
+        aSz = aIf.tellg();
+
+        e32Image.Adjust(aSz);
+        e32Image.iFileSize = aSz;
+
+        aIf.seekg(0,ios_base::beg);
+        aIf >> e32Image;
+        ret = e32Image.iOrigHdr->iCodeSize;
+    }
+    return ret;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/imgtools/romtools/rofsbuild/symbolprocessunit.h	Wed Oct 27 16:03:51 2010 +0800
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+#ifndef __SYMBOLPROCESSUNIT_H__
+#define __SYMBOLPROCESSUNIT_H__
+#include <vector>
+#include <string>
+#include <iostream>
+#include <fstream>
+using namespace std;
+
+
+typedef vector<string> stringlist;
+
+class SymbolProcessUnit
+{
+public:
+	virtual void ProcessExecutableFile(const string& aFile) = 0;
+	virtual void ProcessDataFile(const string& afile) = 0;
+	virtual void FlushStdOut(ostream& aOut) = 0;
+	virtual void FlushSymbolContent(ostream &aOut) = 0;
+	virtual void ResetContentLog() = 0;
+	virtual ~SymbolProcessUnit() {}
+};
+
+class CommenSymbolProcessUnit : public SymbolProcessUnit
+{
+public:
+	virtual void ProcessExecutableFile(const string& aFile);
+	virtual void ProcessDataFile(const string& afile);
+	virtual void FlushStdOut(ostream& aOut);
+	virtual void FlushSymbolContent(ostream &aOut);
+	virtual void ResetContentLog();
+private:
+	void ProcessArmv5File( const string& fileName, ifstream& aMap );
+	void ProcessGcceOrArm4File( const string& fileName, ifstream& aMap );
+	int GetSizeFromBinFile( const string& fileName );
+private:
+	stringlist iStdoutLog;
+	stringlist iSymbolContentLog;
+};
+#endif