imgtools/romtools/rofsbuild/src/logging/logparser.cpp
changeset 700 c22eff170fac
parent 699 9ca650050cf0
parent 698 e3ee96a3961c
child 701 170c8b305768
equal deleted inserted replaced
699:9ca650050cf0 700:c22eff170fac
     1 /*
       
     2 * Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <new>
       
    20 #include <iostream>
       
    21 #include <fstream>
       
    22 #include <string>
       
    23 using namespace std;
       
    24 
       
    25 #include "logging/loggingexception.hpp"
       
    26 #include "logging/logparser.hpp"
       
    27 #include "symbolgenerator.h"
       
    28 
       
    29 
       
    30 LogParser* LogParser::Only = (LogParser*)0;
       
    31 
       
    32 
       
    33 LogParser* LogParser::GetInstance(void) throw (LoggingException)
       
    34 {
       
    35 	if(! LogParser::Only)
       
    36 	{
       
    37 		LogParser::Only = new (std::nothrow) LogParser();
       
    38 		if(! LogParser::Only)
       
    39 			throw LoggingException(LoggingException::RESOURCE_ALLOCATION_FAILURE);
       
    40 	}
       
    41 
       
    42 	return LogParser::Only;
       
    43 }
       
    44 
       
    45 
       
    46 void LogParser::ParseSymbol(const char* LogFilename) throw (LoggingException)
       
    47 {
       
    48 	string linebuf;
       
    49 	SymbolGenerator* symgen = SymbolGenerator::GetInstance();
       
    50 	symgen->SetSymbolFileName(string(LogFilename));
       
    51 
       
    52 	ifstream logfd(LogFilename);
       
    53 	if(logfd.is_open())
       
    54 	{
       
    55 		while(! logfd.eof())
       
    56 		{
       
    57 			getline(logfd, linebuf);
       
    58 			if(linebuf.compare(0,4,"File") == 0)
       
    59 			{
       
    60 				if(linebuf.find("size:", 4) != string::npos)
       
    61 				{
       
    62 					size_t startpos = linebuf.find('\'') ;
       
    63 					size_t endpos   = linebuf.rfind('\'');
       
    64 					if((startpos!=string::npos) && (endpos!=string::npos))
       
    65 					{
       
    66 						symgen->AddFile(linebuf.substr(startpos+1,endpos-startpos-1), false);
       
    67 					}
       
    68 				}
       
    69 			}
       
    70 			else if(linebuf.compare(0,15,"Executable File") == 0)
       
    71 			{
       
    72 				if(linebuf.find("size:", 26) != string::npos)
       
    73 				{
       
    74 					size_t startpos = linebuf.find('\'') ;
       
    75 					size_t endpos   = linebuf.rfind('\'');
       
    76 					if((startpos!=string::npos) && (endpos!=string::npos))
       
    77 					{
       
    78 						symgen->AddFile(linebuf.substr(startpos+1,endpos-startpos-1), true);
       
    79 					}
       
    80 				}
       
    81 			}
       
    82 			else if(linebuf.compare(0,26,"Compressed executable File") == 0)
       
    83 			{
       
    84 				if(linebuf.find("size:", 26) != string::npos)
       
    85 				{
       
    86 					size_t startpos = linebuf.find('\'') ;
       
    87 					size_t endpos   = linebuf.rfind('\'');
       
    88 					if((startpos!=string::npos) && (endpos!=string::npos))
       
    89 					{
       
    90 						symgen->AddFile(linebuf.substr(startpos+1,endpos-startpos-1), true);
       
    91 					}
       
    92 				}
       
    93 			}
       
    94 		}
       
    95 		symgen->SetFinished();
       
    96 		symgen->Release();
       
    97 	}
       
    98 	else
       
    99 	{
       
   100 		throw LoggingException(LoggingException::INVALID_LOG_FILENAME);
       
   101 	}
       
   102 
       
   103 	return;
       
   104 }
       
   105 
       
   106 
       
   107 void LogParser::Cleanup(void)
       
   108 {
       
   109 	return;
       
   110 }
       
   111 
       
   112 
       
   113 LogParser::LogParser(void)
       
   114 {
       
   115 	return;
       
   116 }