imgtools/imglib/symbolutil/logparser.cpp
changeset 712 df89378e9223
parent 695 46ca13b54f56
child 714 e5a58c351011
equal deleted inserted replaced
697:818fe0ed324b 712:df89378e9223
    28 
    28 
    29 
    29 
    30 LogParser* LogParser::Only = (LogParser*)0;
    30 LogParser* LogParser::Only = (LogParser*)0;
    31 
    31 
    32 
    32 
    33 LogParser* LogParser::GetInstance(TImageType aImageType) throw (LoggingException)
    33  
       
    34 LogParser* LogParser::GetInstance(TImageType aImageType) throw (LOGGINGEXCEPTION) 
    34 {
    35 {
    35 	if(! LogParser::Only)
    36 	if(! LogParser::Only)
    36 	{
    37 	{
    37 		if(aImageType == ERomImage)
    38 		if(aImageType == ERomImage)
    38 		{
    39 		{
    67 
    68 
    68 RofsLogParser::RofsLogParser()
    69 RofsLogParser::RofsLogParser()
    69 {
    70 {
    70 	iImageType = ERofsImage;
    71 	iImageType = ERofsImage;
    71 }
    72 }
    72 
    73  
    73 void RofsLogParser::ParseSymbol(const char* LogFilename) throw (LoggingException)
    74 void RofsLogParser::ParseSymbol(const char* LogFilename) throw (LOGGINGEXCEPTION) 
    74 {
    75 {
    75 	string linebuf;
    76 	string linebuf;
    76 	SymbolGenerator* symgen = SymbolGenerator::GetInstance();
    77 	SymbolGenerator* symgen = SymbolGenerator::GetInstance();
    77 	symgen->SetImageType(iImageType);
    78 	symgen->SetImageType(iImageType);
    78 	symgen->SetSymbolFileName(string(LogFilename));
    79 	symgen->SetSymbolFileName(string(LogFilename));
   122 RomLogParser::RomLogParser()
   123 RomLogParser::RomLogParser()
   123 {
   124 {
   124 	iImageType = ERomImage;
   125 	iImageType = ERomImage;
   125 }
   126 }
   126 
   127 
   127 void RomLogParser::ParseSymbol(const char* LogFilename) throw (LoggingException)
   128 void RomLogParser::ParseSymbol(const char* LogFilename) throw (LOGGINGEXCEPTION)
   128 {
   129 {
   129 	string linebuf;
   130 	string linebuf;
   130 	SymbolGenerator* symgen = SymbolGenerator::GetInstance();
   131 	SymbolGenerator* symgen = SymbolGenerator::GetInstance();
   131 	symgen->SetImageType(iImageType);
   132 	symgen->SetImageType(iImageType);
   132 	symgen->SetSymbolFileName(string(LogFilename));
   133 	symgen->SetSymbolFileName(string(LogFilename));
   148 		string tmpline, tmpaddr;
   149 		string tmpline, tmpaddr;
   149 		boost::cmatch what;
   150 		boost::cmatch what;
   150 		while(getline(logfd, tmpline))
   151 		while(getline(logfd, tmpline))
   151 		{
   152 		{
   152 			TPlacedEntry tmpEntry;
   153 			TPlacedEntry tmpEntry;
   153 			if(regex_search(tmpline, what, endFlag))
   154 			if(regex_search(tmpline.c_str(), what, endFlag))
   154 			{
   155 			{
   155 				break;
   156 				break;
   156 			}
   157 			}
   157 			if(regex_search(tmpline, what, sourceFile))
   158 			if(regex_search(tmpline.c_str(), what, sourceFile))
   158 			{
   159 			{
   159 				tmpEntry.iFileName.assign(what[1].first, what[1].second-what[1].first);
   160 				tmpEntry.iFileName.assign(what[1].first, what[1].second-what[1].first);
   160 				tmpaddr.assign(what[2].first, what[2].second-what[2].first);
   161 				tmpaddr.assign(what[2].first, what[2].second-what[2].first);
   161 				tmpEntry.iDataAddress = strtol(tmpaddr.c_str(), NULL, 16);
   162 				tmpEntry.iDataAddress = strtol(tmpaddr.c_str(), NULL, 16);
   162 				symgen->AddEntry(tmpEntry);
   163 				symgen->AddEntry(tmpEntry);
   163 			}
   164 			}
   164 			else if(regex_search(tmpline, what, executableFile))
   165 			else if(regex_search(tmpline.c_str(), what, executableFile))
   165 			{
   166 			{
   166 				tmpEntry.iFileName.assign(what[1].first, what[1].second-what[1].first);
   167 				tmpEntry.iFileName.assign(what[1].first, what[1].second-what[1].first);
   167 				while(getline(logfd, tmpline) && tmpline != "")
   168 				while(getline(logfd, tmpline) && tmpline != "")
   168 				{
   169 				{
   169 					if(regex_search(tmpline, what, codeStart))
   170 					if(regex_search(tmpline.c_str(), what, codeStart))
   170 					{
   171 					{
   171 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   172 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   172 						tmpEntry.iCodeAddress = strtol(tmpaddr.c_str(), NULL, 16);
   173 						tmpEntry.iCodeAddress = strtol(tmpaddr.c_str(), NULL, 16);
   173 					} 
   174 					} 
   174 					else if(regex_search(tmpline, what, dataStart))
   175 					else if(regex_search(tmpline.c_str(), what, dataStart))
   175 					{
   176 					{
   176 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   177 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   177 						tmpEntry.iDataAddress = strtol(tmpaddr.c_str(), NULL, 16);
   178 						tmpEntry.iDataAddress = strtol(tmpaddr.c_str(), NULL, 16);
   178 					}
   179 					}
   179 					else if(regex_search(tmpline, what, dataBssStart))
   180 					else if(regex_search(tmpline.c_str(), what, dataBssStart))
   180 					{
   181 					{
   181 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   182 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   182 						tmpEntry.iDataBssLinearBase = strtol(tmpaddr.c_str(), NULL, 16);
   183 						tmpEntry.iDataBssLinearBase = strtol(tmpaddr.c_str(), NULL, 16);
   183 					}
   184 					}
   184 					else if(regex_search(tmpline, what, textSize))
   185 					else if(regex_search(tmpline.c_str(), what, textSize))
   185 					{
   186 					{
   186 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   187 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   187 						tmpEntry.iTextSize = strtol(tmpaddr.c_str(), NULL, 16);
   188 						tmpEntry.iTextSize = strtol(tmpaddr.c_str(), NULL, 16);
   188 					}
   189 					}
   189 					else if(regex_search(tmpline, what, dataSize))
   190 					else if(regex_search(tmpline.c_str(), what, dataSize))
   190 					{
   191 					{
   191 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   192 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   192 						tmpEntry.iDataSize = strtol(tmpaddr.c_str(), NULL, 16);
   193 						tmpEntry.iDataSize = strtol(tmpaddr.c_str(), NULL, 16);
   193 					}
   194 					}
   194 					else if(regex_search(tmpline, what, bssSize))
   195 					else if(regex_search(tmpline.c_str(), what, bssSize))
   195 					{
   196 					{
   196 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   197 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   197 						tmpEntry.iBssSize = strtol(tmpaddr.c_str(), NULL, 16);
   198 						tmpEntry.iBssSize = strtol(tmpaddr.c_str(), NULL, 16);
   198 					}
   199 					}
   199 					else if(regex_search(tmpline, what, totalDataSize))
   200 					else if(regex_search(tmpline.c_str(), what, totalDataSize))
   200 					{
   201 					{
   201 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   202 						tmpaddr.assign(what[1].first, what[1].second-what[1].first);
   202 						tmpEntry.iTotalDataSize = strtol(tmpaddr.c_str(), NULL, 16);
   203 						tmpEntry.iTotalDataSize = strtol(tmpaddr.c_str(), NULL, 16);
   203 					}
   204 					}
   204 				}
   205 				}