analyzetool/commandlineengine/src/CATParseTraceFile.cpp
branchRCL_3
changeset 49 7fdc9a71d314
parent 19 da2cedce4920
child 59 8ad140f3dd41
equal deleted inserted replaced
46:e26895079d7c 49:7fdc9a71d314
    18 
    18 
    19 #include "../inc/ATCommonDefines.h"
    19 #include "../inc/ATCommonDefines.h"
    20 #include "../inc/CATParseTraceFile.h"
    20 #include "../inc/CATParseTraceFile.h"
    21 #include "../inc/catdatasaver.h"
    21 #include "../inc/catdatasaver.h"
    22 #include "../inc/CATDatParser.h"
    22 #include "../inc/CATDatParser.h"
       
    23 #include "../inc/CATProcessData.h"
    23 
    24 
    24 #include <time.h>
    25 #include <time.h>
    25 
    26 
    26 #define MAIN_ID "PCSS"
    27 
    27 #define ALLOC_ID "ALLOC" // < V.1.6 allocation.
       
    28 #define ALLOCH_ID "ALLOCH" // Header of multi message allocation.
       
    29 #define ALLOCF_ID "ALLOCF" // Fragment of multi message allocation.
       
    30 #define FREE_ID "FREE"
       
    31 #define FREEH_ID "FREEH" // Header of multi message free.
       
    32 #define FREEF_ID "FREEF" // Fragment of multi message free.
       
    33 #define HANDLE_LEAK_ID "HANDLE_LEAK"
       
    34 
       
    35 const string ERROR_OCCURED = "ERROR_OCCURED"; // Error messages.
       
    36 const string INCORRECT_ATOOL_VERSION = "INCORRECT_ATOOL_VERSION";
       
    37 /**
       
    38 * Invalid characters in trace file line content.
       
    39 * These will be filtered out before actuall parsing of line.
       
    40 10 = LF
       
    41 13 = CR
       
    42 124 = |
       
    43 */
       
    44 const char cINVALID_TRACE_FILE_CHARS[] = { 10, 13, 124 };
       
    45 
    28 
    46 // -----------------------------------------------------------------------------
    29 // -----------------------------------------------------------------------------
    47 // CATParseTraceFile::CATParseTraceFile
    30 // CATParseTraceFile::CATParseTraceFile
    48 // Constructor.
    31 // Constructor.
    49 // -----------------------------------------------------------------------------
    32 // -----------------------------------------------------------------------------
    55 
    38 
    56 // -----------------------------------------------------------------------------
    39 // -----------------------------------------------------------------------------
    57 // CATParseTraceFile::StartParse
    40 // CATParseTraceFile::StartParse
    58 // Main function to start trace parsing.
    41 // Main function to start trace parsing.
    59 // -----------------------------------------------------------------------------
    42 // -----------------------------------------------------------------------------
    60 bool CATParseTraceFile::StartParse( const char* pFileName, const char* pOutputFileName )
    43 bool CATParseTraceFile::StartParse( const char* pFileName, const char* pOutputFileName, const char* pCleanedTraceFile )
    61 {
    44 {
    62 	LOG_FUNC_ENTRY("CATParseTraceFile::StartParse");
    45 	LOG_FUNC_ENTRY("CATParseTraceFile::StartParse");
    63 
    46 
    64 	// Return value, will be changed to true if process start found.
    47 	// Return value, will be changed to true if process start found.
    65 	bool bRet = false;
    48 	bool bRet = false;
       
    49 	bool bCreateCleanedTraces = false;
    66 
    50 
    67 	// Check pointers
    51 	// Check pointers
    68 	if ( pFileName == NULL  )
    52 	if ( pFileName == NULL  )
    69 		return bRet;
    53 		return bRet;
    70 
    54 
    75 	{
    59 	{
    76 		cout << AT_MSG << "Error, input file \""
    60 		cout << AT_MSG << "Error, input file \""
    77 			<< pFileName
    61 			<< pFileName
    78 			<< "\" does not exist." << endl;
    62 			<< "\" does not exist." << endl;
    79 		return bRet;
    63 		return bRet;
       
    64 	}
       
    65 
       
    66 	ofstream cleanedTraces;
       
    67 
       
    68 	// check is creation of file needed
       
    69 	if( pCleanedTraceFile != NULL )
       
    70 	{
       
    71 		// if yes open file for cleaned traces
       
    72 	    // (<AT> messages with cleaned timestamps)
       
    73 		bCreateCleanedTraces = true;
       
    74 
       
    75 		cleanedTraces.open(pCleanedTraceFile);
       
    76 
       
    77 		if( !cleanedTraces.good() )
       
    78 		{
       
    79 			printf( "Can not open file: %s\n", pCleanedTraceFile );
       
    80 			return bRet;
       
    81 		}
    80 	}
    82 	}
    81 
    83 
    82 	// Open data file
    84 	// Open data file
    83 	ifstream in( pFileName );
    85 	ifstream in( pFileName );
    84 
    86 
   138 
   140 
   139 		// Is there main ID?
   141 		// Is there main ID?
   140 		if( strstr( cLineFromFile, MAIN_ID ) != NULL )
   142 		if( strstr( cLineFromFile, MAIN_ID ) != NULL )
   141 		{
   143 		{
   142 			string sRestOfLine( cLineFromFile );
   144 			string sRestOfLine( cLineFromFile );
   143 			string sTemp;
   145 			string sTemp("");
   144 
   146 			unsigned __int64 iTimeStamp(0);
   145 			// Delete all characters before main ID
   147 			string sTime("");
   146 			sRestOfLine.erase( 0, sRestOfLine.find( MAIN_ID ) );
   148 			string sLineStart("");
       
   149 
       
   150 			// Get part of line before main id. This should contain time info
       
   151 			sLineStart = GetStringUntilMainId( sRestOfLine );
       
   152 			// Get message's time stamp in microseconds
       
   153 			iTimeStamp = ParseTimeStamp( sLineStart );
       
   154 			// store whole line from MAIN_ID - to be logged to cleaned traces file
       
   155 		    string sLineToCleanedFile( sRestOfLine );
   147 
   156 
   148 			// Get main ID
   157 			// Get main ID
   149 			sTemp = GetStringUntilNextSpace( sRestOfLine );
   158 			sTemp = GetStringUntilNextSpace( sRestOfLine );
   150 
   159 
   151 			// Is there more data in line?
   160 			// Is there more data in line?
   154 				continue;
   163 				continue;
   155 			}
   164 			}
   156 
   165 
   157 			// Get next argument
   166 			// Get next argument
   158 			sTemp = GetStringUntilNextSpace( sRestOfLine );
   167 			sTemp = GetStringUntilNextSpace( sRestOfLine );
   159 			// This might be process id or error message
   168 			// This might be process id, device info message or error message
   160 			if ( sTemp.compare( ERROR_OCCURED ) == 0 )
   169 			if ( sTemp.compare( ERROR_OCCURED ) == 0 )
   161 			{
   170 			{
   162 				// Api mismatch between s60 side and atool.exe
   171 				// Api mismatch between s60 side and atool.exe
   163 				if ( sRestOfLine.find( INCORRECT_ATOOL_VERSION ) != string::npos )
   172 				if ( sRestOfLine.find( INCORRECT_ATOOL_VERSION ) != string::npos )
   164 				{
   173 				{
   177 				}
   186 				}
   178 				else
   187 				else
   179 					cout << sRestOfLine << endl;
   188 					cout << sRestOfLine << endl;
   180 				continue;
   189 				continue;
   181 			}
   190 			}
       
   191 
       
   192 			if ( sTemp.compare( LABEL_DEVICE_INFO ) == 0 ) 
       
   193 			{
       
   194 
       
   195 				if( vProcessList[iProcessIDinList].bProcessOnGoing == false )
       
   196 				continue;
       
   197 
       
   198 				// get time string from timestamp
       
   199 			    sTime = GetTimeFromTimeStamp( iTimeStamp, vProcessList[iProcessIDinList].iTimeSpan );
       
   200 
       
   201 				// device info line, log it to cleaned file for carbide
       
   202 				if( bCreateCleanedTraces )
       
   203 				{
       
   204 				// add message to cleaned traces file
       
   205 				cleanedTraces << sTime << " "; //add time
       
   206 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   207 				cleanedTraces << LABEL_DEVICE_INFO << " "; //add Message type
       
   208 				cleanedTraces << sRestOfLine << "\n"; //add the rest of the line
       
   209 				}
       
   210 				continue;
       
   211 			}
       
   212 
   182 			unsigned long iProcessID = _httoi( sTemp.c_str() );
   213 			unsigned long iProcessID = _httoi( sTemp.c_str() );
       
   214 			// todo to be removed when reallocations are implemented
       
   215 			string sProcessID = sTemp;
   183 
   216 
   184 			iProcessIDinList = -1;
   217 			iProcessIDinList = -1;
   185 			// Find process from list
   218 			// Find process from list
   186 			for( unsigned int i = 0 ; i < vProcessList.size() ; i++ )
   219 			for( unsigned int i = 0 ; i < vProcessList.size() ; i++ )
   187 			{
   220 			{
   219 			if( ! _stricmp( pCommand, LABEL_PROCESS_START ) )
   252 			if( ! _stricmp( pCommand, LABEL_PROCESS_START ) )
   220 			{
   253 			{
   221 				bRet = true; // Set return value true we found start.
   254 				bRet = true; // Set return value true we found start.
   222 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   255 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   223 				vProcessList[iProcessIDinList].bProcessOnGoing = true;
   256 				vProcessList[iProcessIDinList].bProcessOnGoing = true;
       
   257 
       
   258 				// remove <processName> <processID> part
       
   259 				GetStringUntilNextSpace( sRestOfLine );
       
   260 				GetStringUntilNextSpace( sRestOfLine );
       
   261 				// get time
       
   262 				sTemp = GetStringUntilNextSpace( sRestOfLine );
       
   263 				unsigned __int64 iTemp(0);
       
   264 				sscanf_s( sTemp.c_str(), "%016I64x", &iTemp);
       
   265 				//calculate span between PCS time and PCS timestamp
       
   266 				vProcessList[iProcessIDinList].iTimeSpan = iTemp - iTimeStamp;
       
   267 
       
   268 				if( bCreateCleanedTraces )
       
   269 				{
       
   270 				// add message to cleaned traces file
       
   271 				cleanedTraces << sTemp << " "; //add time
       
   272 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   273 				cleanedTraces << sProcessID << " "; //add process ID
       
   274 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   275 				}
       
   276 
   224 				continue;
   277 				continue;
   225 			}
   278 			}
   226 
   279 
   227 			// Check is process ongoing if not skip other tags.
   280 			// Check is process ongoing if not skip other tags.
   228 			if( vProcessList[iProcessIDinList].bProcessOnGoing == false )
   281 			if( vProcessList[iProcessIDinList].bProcessOnGoing == false )
   229 				continue;
   282 				continue;
   230 
   283 
       
   284 			// get time string from timestamp
       
   285 			sTime = GetTimeFromTimeStamp( iTimeStamp, vProcessList[iProcessIDinList].iTimeSpan );
       
   286 
       
   287 			// TODO version with reallocation
       
   288 			//cleanedTraces << sTime << " "; //add time
       
   289 			//cleanedTraces << sLineToCleanedFile << "\n"; //add the rest of the line
       
   290 
   231 			// "Old style" allocation (< v.1.6)
   291 			// "Old style" allocation (< v.1.6)
   232 			if( ! _stricmp( pCommand, ALLOC_ID ) )
   292 			if( ! _stricmp( pCommand, ALLOC_ID ) )
   233 			{
   293 			{
   234 				// Add alloc
   294 				// Add alloc
   235 				vProcessList[iProcessIDinList].Alloc( sRestOfLine );
   295 				vProcessList[iProcessIDinList].Alloc( sRestOfLine );
   246 					viSubTestIter++;
   306 					viSubTestIter++;
   247 				}
   307 				}
   248 			}
   308 			}
   249 			else if ( ! _stricmp( pCommand, ALLOCH_ID ) )
   309 			else if ( ! _stricmp( pCommand, ALLOCH_ID ) )
   250 			{
   310 			{
       
   311 				if( bCreateCleanedTraces )
       
   312 				{
       
   313 				// add message to cleaned traces file
       
   314 				cleanedTraces << sTime << " "; //add time
       
   315 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   316 				cleanedTraces << sProcessID << " "; //add process ID
       
   317 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   318 				}
       
   319 
   251 				// Add alloc
   320 				// Add alloc
   252 				vProcessList[iProcessIDinList].AllocH( sRestOfLine );
   321 				vProcessList[iProcessIDinList].AllocH( sRestOfLine, sTime );
   253 
   322 
   254 				// Subtests running?
   323 				// Subtests running?
   255 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   324 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   256 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   325 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   257 				{
   326 				{
   258 					if( viSubTestIter->bRunning )
   327 					if( viSubTestIter->bRunning )
   259 					{
   328 					{
   260 						// Save alloc also to sub test
   329 						// Save alloc also to sub test
   261 						viSubTestIter->AllocH( sRestOfLine );
   330 						viSubTestIter->AllocH( sRestOfLine, sTime );
   262 					}
   331 					}
   263 					viSubTestIter++;
   332 					viSubTestIter++;
   264 				}
   333 				}
   265 			}
   334 			}
   266 			// Allocation fragment (call stack).
   335 			// Allocation fragment (call stack).
   267 			else if ( ! _stricmp( pCommand, ALLOCF_ID ) )
   336 			else if ( ! _stricmp( pCommand, ALLOCF_ID ) )
   268 			{
   337 			{
       
   338 				if( bCreateCleanedTraces )
       
   339 				{
       
   340 				// add message to cleaned traces file
       
   341 				cleanedTraces << sTime << " "; //add time
       
   342 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   343 				cleanedTraces << sProcessID << " "; //add process ID
       
   344 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   345 				}
       
   346 
   269 				// Add alloc fragment
   347 				// Add alloc fragment
   270 				vProcessList[iProcessIDinList].AllocF( sRestOfLine );
   348 				vProcessList[iProcessIDinList].AllocF( sRestOfLine, sTime );
   271 				
   349 				
   272 				// Subtests running?
   350 				// Subtests running?
   273 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   351 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   274 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   352 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   275 				{
   353 				{
   276 					if( viSubTestIter->bRunning )
   354 					if( viSubTestIter->bRunning )
   277 					{
   355 					{
   278 						// Save alloc fragment also to sub test
   356 						// Save alloc fragment also to sub test
   279 						viSubTestIter->AllocF( sRestOfLine );
   357 						viSubTestIter->AllocF( sRestOfLine, sTime );
   280 					}
   358 					}
   281 					viSubTestIter++;
   359 					viSubTestIter++;
   282 				}
   360 				}
   283 			}
   361 			}
   284 			// Command free
   362 			else if ( ! _stricmp( pCommand, REALLOCH_ID ) )
   285 			else if( ! _stricmp( pCommand, FREE_ID ) )
   363 			{
   286 			{
   364 				// Add free
   287 				// Send free
   365 
   288 				vProcessList[iProcessIDinList].Free( sRestOfLine );
   366 				// get 'free' line from realloc line
       
   367 				string sFreeRestOfLine = sRestOfLine;
       
   368 				string sFreeLine = "";
       
   369 				sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address
       
   370 				sFreeLine.append( " " );
       
   371 				// next two strings are for 'alloc' (address and size) - lets remove them
       
   372 				GetStringUntilNextSpace( sFreeRestOfLine, true );
       
   373 				GetStringUntilNextSpace( sFreeRestOfLine, true );
       
   374 				// add rest of line to 'free' line
       
   375 				sFreeLine.append( sFreeRestOfLine );
       
   376 				//add 'free' line
       
   377 				vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime );
       
   378 
       
   379 				if( bCreateCleanedTraces )
       
   380 				{
       
   381 				// add message to cleaned traces file
       
   382 				// construct 'free' header trace
       
   383 				cleanedTraces << sTime << " "; //add time
       
   384 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   385 				cleanedTraces << sProcessID << " "; //add process ID
       
   386 				cleanedTraces << FREEH_ID << " "; //add FRH
       
   387 				cleanedTraces << sFreeLine << "\n"; //add the rest of the line
       
   388 				}
       
   389 
       
   390 				// Add alloc
       
   391 
       
   392 				//get 'alloc' line from realloc line
       
   393 				// only first string is unnecessary, lets remove it
       
   394 				GetStringUntilNextSpace( sRestOfLine );
       
   395      			// add 'alloc' line
       
   396 				vProcessList[iProcessIDinList].AllocH( sRestOfLine, sTime );
       
   397 
       
   398 				if( bCreateCleanedTraces )
       
   399 				{
       
   400 				// add message to cleaned traces file
       
   401 				// construct 'alloc' header trace
       
   402 				cleanedTraces << sTime << " "; //add time
       
   403 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   404 				cleanedTraces << sProcessID << " "; //add process ID
       
   405 				cleanedTraces << ALLOCH_ID << " "; //add FRH
       
   406 				cleanedTraces << sRestOfLine << "\n"; //add the rest of the line
       
   407 				}
   289 
   408 
   290 				// Subtests running?
   409 				// Subtests running?
   291 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   410 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   292 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   411 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   293 				{
   412 				{
   294 					if( viSubTestIter->bRunning )
   413 					if( viSubTestIter->bRunning )
   295 					{
   414 					{
   296 						// Send free to subtest
   415 						// Save realloc also to sub test
   297 						viSubTestIter->Free( sRestOfLine );
   416 						// Add free
       
   417 
       
   418 						// get 'free' line from realloc line
       
   419 						string sFreeRestOfLine = sRestOfLine;
       
   420 						string sFreeLine = "";
       
   421 						sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address
       
   422 						sFreeLine.append( " " );
       
   423 						// next two strings are for 'alloc' (address and size) - lets remove them
       
   424 						GetStringUntilNextSpace( sFreeRestOfLine, true );
       
   425 						GetStringUntilNextSpace( sFreeRestOfLine, true );
       
   426 						// add rest of line to 'free' line
       
   427 						sFreeLine.append( sFreeRestOfLine );
       
   428 						//add 'free' line
       
   429 						vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime );
       
   430 
       
   431 						// Add alloc
       
   432 
       
   433 						//get 'alloc' line from realloc line
       
   434 						// only first string is unnecessary, lets remove it
       
   435 						GetStringUntilNextSpace( sRestOfLine );
       
   436      					// add 'alloc' line
       
   437 						vProcessList[iProcessIDinList].AllocH( sRestOfLine, sTime );
   298 					}
   438 					}
   299 					viSubTestIter++;
   439 					viSubTestIter++;
   300 				}
   440 				}
   301 			}
   441 			}
   302 			// Header free.
   442 			// rellocation fragment (call stack).
   303 			else if( ! _stricmp( pCommand, FREEH_ID ) )
   443 			else if ( ! _stricmp( pCommand, REALLOCF_ID ) )
   304 			{
   444 			{
   305 				// Send free
   445 				// Add free fragment 
   306 				vProcessList[iProcessIDinList].FreeH( sRestOfLine );
   446 
   307 
   447 				// get 'free' line from realloc line
       
   448 				string sFreeRestOfLine = sRestOfLine;
       
   449 				string sFreeLine = "";
       
   450 				sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address
       
   451 				sFreeLine.append( " " );
       
   452 				// next string is for 'alloc' (address) - lets remove it
       
   453 				GetStringUntilNextSpace( sFreeRestOfLine, true );
       
   454 				// add rest of line to 'free' line
       
   455 				sFreeLine.append( sFreeRestOfLine );
       
   456 				//add 'free' line
       
   457 				vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime );
       
   458 
       
   459 				if( bCreateCleanedTraces )
       
   460 				{
       
   461 				// add message to cleaned traces file
       
   462 				// construct 'free' fragment trace
       
   463 				cleanedTraces << sTime << " "; //add time
       
   464 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   465 				cleanedTraces << sProcessID << " "; //add process ID
       
   466 				cleanedTraces << FREEF_ID << " "; //add FRF
       
   467 				cleanedTraces << sFreeLine << "\n"; //add the rest of the line
       
   468 				}
       
   469 
       
   470 				// Add alloc fragment
       
   471 
       
   472 				// first string is for 'free' (address), lets remove it first
       
   473 				GetStringUntilNextSpace( sRestOfLine, true );
       
   474 				//add 'alloc' line
       
   475 				vProcessList[iProcessIDinList].AllocF( sRestOfLine, sTime );
       
   476 
       
   477 				if( bCreateCleanedTraces )
       
   478 				{
       
   479 				// add message to cleaned traces file
       
   480 				// construct 'alloc' fragment trace
       
   481 				cleanedTraces << sTime << " "; //add time
       
   482 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   483 				cleanedTraces << sProcessID << " "; //add process ID
       
   484 				cleanedTraces << ALLOCF_ID << " "; //add FRF
       
   485 				cleanedTraces << sRestOfLine << "\n"; //add the rest of the line
       
   486 				}
       
   487 				
   308 				// Subtests running?
   488 				// Subtests running?
   309 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   489 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   310 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   490 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   311 				{
   491 				{
   312 					if( viSubTestIter->bRunning )
   492 					if( viSubTestIter->bRunning )
   313 					{
   493 					{
       
   494 						// Save alloc fragment also to sub test
       
   495 						// Add free fragment 
       
   496 
       
   497 						// get 'free' line from realloc line
       
   498 						string sFreeRestOfLine = sRestOfLine;
       
   499 						string sFreeLine = "";
       
   500 						sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address
       
   501 						sFreeLine.append( " " );
       
   502 						// next string is for 'alloc' (address) - lets remove it
       
   503 						GetStringUntilNextSpace( sFreeRestOfLine, true );
       
   504 						// add rest of line to 'free' line
       
   505 						sFreeLine.append( sFreeRestOfLine );
       
   506 						//add 'free' line
       
   507 						vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime );
       
   508 
       
   509 						// Add alloc fragment
       
   510 
       
   511 						// first string is for 'free' (address), lets remove it first
       
   512 						GetStringUntilNextSpace( sRestOfLine, true );
       
   513 						//add 'alloc' line
       
   514 						vProcessList[iProcessIDinList].AllocF( sRestOfLine, sTime );
       
   515 					}
       
   516 					viSubTestIter++;
       
   517 				}
       
   518 			}
       
   519 			// Command free
       
   520 			else if( ! _stricmp( pCommand, FREE_ID ) )
       
   521 			{
       
   522 				// Send free
       
   523 				vProcessList[iProcessIDinList].Free( sRestOfLine );
       
   524 
       
   525 				// Subtests running?
       
   526 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
       
   527 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
       
   528 				{
       
   529 					if( viSubTestIter->bRunning )
       
   530 					{
   314 						// Send free to subtest
   531 						// Send free to subtest
   315 						viSubTestIter->FreeH( sRestOfLine );
   532 						viSubTestIter->Free( sRestOfLine );
   316 					}
   533 					}
   317 					viSubTestIter++;
   534 					viSubTestIter++;
   318 				}
   535 				}
       
   536 			}
       
   537 			// Header free.
       
   538 			else if( ! _stricmp( pCommand, FREEH_ID ) )
       
   539 			{
       
   540 				if( bCreateCleanedTraces )
       
   541 				{
       
   542 				// add message to cleaned traces file
       
   543 				cleanedTraces << sTime << " "; //add time
       
   544 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   545 				cleanedTraces << sProcessID << " "; //add process ID
       
   546 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   547 				}
       
   548 
       
   549 				// Send free
       
   550 				vProcessList[iProcessIDinList].FreeH( sRestOfLine, sTime );
       
   551 
       
   552 				// Subtests running?
       
   553 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
       
   554 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
       
   555 				{
       
   556 					if( viSubTestIter->bRunning )
       
   557 					{
       
   558 						// Send free to subtest
       
   559 						viSubTestIter->FreeH( sRestOfLine, sTime );
       
   560 					}
       
   561 					viSubTestIter++;
       
   562 				}
   319 			
   563 			
   320 			}
   564 			}
   321 			else if( ! _stricmp( pCommand, FREEF_ID ) )
   565 			else if( ! _stricmp( pCommand, FREEF_ID ) )
   322 			{
   566 			{
       
   567 				if( bCreateCleanedTraces )
       
   568 				{
       
   569 				// add message to cleaned traces file
       
   570 				cleanedTraces << sTime << " "; //add time
       
   571 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   572 				cleanedTraces << sProcessID << " "; //add process ID
       
   573 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   574 				}
   323 				// Not used currently.
   575 				// Not used currently.
   324 			}
   576 			}
   325 			// Command process end
   577 			// Command process end
   326 			else if( ! _stricmp( pCommand, LABEL_PROCESS_END ) )
   578 			else if( ! _stricmp( pCommand, LABEL_PROCESS_END ) )
   327 			{
   579 			{
       
   580 				// append processID and time
       
   581 				sWholeTempLine.append(" ");
       
   582 				sWholeTempLine.append( sProcessID );
       
   583 				sWholeTempLine.append(" ");
       
   584 				sWholeTempLine.append( sTime );
       
   585 
       
   586 				if( bCreateCleanedTraces )
       
   587 				{
       
   588 				// add message to cleaned traces file
       
   589 				cleanedTraces << sTime << " "; //add time
       
   590 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   591 				cleanedTraces << sProcessID << " "; //add process ID
       
   592 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   593 				}
       
   594 
   328 				// Set process has ended.
   595 				// Set process has ended.
   329 				vProcessList[iProcessIDinList].bProcessOnGoing = false;
   596 				vProcessList[iProcessIDinList].bProcessOnGoing = false;
   330 
   597 
   331 				// Save leaks
   598 				// Save leaks
   332 				vector<string> vLeaks;
   599 				vector<string> vLeaks;
   403 				vProcessList[iProcessIDinList].vSubTests.clear();
   670 				vProcessList[iProcessIDinList].vSubTests.clear();
   404 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   671 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   405 			}
   672 			}
   406 			else if( ! _stricmp( pCommand, LABEL_HANDLE_LEAK ) )
   673 			else if( ! _stricmp( pCommand, LABEL_HANDLE_LEAK ) )
   407 			{
   674 			{
       
   675 				if( bCreateCleanedTraces )
       
   676 				{
       
   677 				// add message to cleaned traces file
       
   678 				cleanedTraces << sTime << " "; //add time
       
   679 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   680 				cleanedTraces << sProcessID << " "; //add process ID
       
   681 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   682 				}
       
   683 
   408 				// Make whole line
   684 				// Make whole line
   409 				sTemp.append( " " );
   685 				sTemp.append( " " );
   410 				sTemp.append( sRestOfLine );
   686 				sTemp.append( sRestOfLine );
   411 				vProcessList[iProcessIDinList].vHandleLeaks.push_back( sTemp );
   687 				vProcessList[iProcessIDinList].vHandleLeaks.push_back( sTemp );
   412 			}
   688 			}
   413 			else if( ! _stricmp( pCommand, LABEL_DLL_LOAD ) )
   689 			else if( ! _stricmp( pCommand, LABEL_DLL_LOAD ) )
   414 			{
   690 			{
       
   691 				if( bCreateCleanedTraces )
       
   692 				{
       
   693 				// add message to cleaned traces file
       
   694 				cleanedTraces << sTime << " "; //add time
       
   695 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   696 				cleanedTraces << sProcessID << " "; //add process ID
       
   697 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   698 				}
       
   699 
       
   700 				// append time to the end of the line
       
   701 				sWholeTempLine.append( " " );
       
   702 				sWholeTempLine.append( sTime );
       
   703 
   415 				// Add module load to process data.
   704 				// Add module load to process data.
   416 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   705 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   417 				// Add module load to subtest data if test running.
   706 				// Add module load to subtest data if test running.
   418 				for( vector<CSubTestData>::iterator it = vProcessList[iProcessIDinList].vSubTests.begin();
   707 				for( vector<CSubTestData>::iterator it = vProcessList[iProcessIDinList].vSubTests.begin();
   419 					it != vProcessList[iProcessIDinList].vSubTests.end(); it++ )
   708 					it != vProcessList[iProcessIDinList].vSubTests.end(); it++ )
   423 				}
   712 				}
   424 
   713 
   425 			}
   714 			}
   426 			else if( ! _stricmp( pCommand, LABEL_DLL_UNLOAD ) )
   715 			else if( ! _stricmp( pCommand, LABEL_DLL_UNLOAD ) )
   427 			{
   716 			{
       
   717 				if( bCreateCleanedTraces )
       
   718 				{
       
   719 				// add message to cleaned traces file
       
   720 				cleanedTraces << sTime << " "; //add time
       
   721 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   722 				cleanedTraces << sProcessID << " "; //add process ID
       
   723 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   724 				}
       
   725 
       
   726 				// append time to the end of the line
       
   727 				sWholeTempLine.append( " " );
       
   728 				sWholeTempLine.append( sTime );
       
   729 
   428 				// Add module load to process data.
   730 				// Add module load to process data.
   429 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   731 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   430 				// Add module unload to subtest data if test running.
   732 				// Add module unload to subtest data if test running.
   431 				for( vector<CSubTestData>::iterator it = vProcessList[iProcessIDinList].vSubTests.begin();
   733 				for( vector<CSubTestData>::iterator it = vProcessList[iProcessIDinList].vSubTests.begin();
   432 					it != vProcessList[iProcessIDinList].vSubTests.end(); it++ )
   734 					it != vProcessList[iProcessIDinList].vSubTests.end(); it++ )
   437 			}
   739 			}
   438 			else if( sTemp.find( LABEL_LOGGING_CANCELLED ) != string::npos ||
   740 			else if( sTemp.find( LABEL_LOGGING_CANCELLED ) != string::npos ||
   439 				     sTemp.find( LABEL_PROCESS_END ) != string::npos || sTemp.find( LABEL_ERROR_OCCURED ) != string::npos ||
   741 				     sTemp.find( LABEL_PROCESS_END ) != string::npos || sTemp.find( LABEL_ERROR_OCCURED ) != string::npos ||
   440 					 sTemp.find( LABEL_HANDLE_LEAK ) != string::npos )
   742 					 sTemp.find( LABEL_HANDLE_LEAK ) != string::npos )
   441 			{
   743 			{
       
   744 				if( bCreateCleanedTraces )
       
   745 				{
       
   746 				// add message to cleaned traces file
       
   747 				cleanedTraces << sTime << " "; //add time
       
   748 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   749 				cleanedTraces << sProcessID << " "; //add process ID
       
   750 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   751 				}
       
   752 
   442 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   753 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   443 			}
   754 			}
   444 			else if( ! _stricmp( pCommand, LABEL_TEST_START ) )
   755 			else if( ! _stricmp( pCommand, LABEL_TEST_START ) )
   445 			{
   756 			{
       
   757 				if( bCreateCleanedTraces )
       
   758 				{
       
   759 				// add message to cleaned traces file
       
   760 				cleanedTraces << sTime << " "; //add time
       
   761 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   762 				cleanedTraces << sProcessID << " "; //add process ID
       
   763 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   764 				}
       
   765 
   446 				bRet = true; // Set return value true we found start.
   766 				bRet = true; // Set return value true we found start.
   447 				// Get sub test time
   767 				// Get sub test time
   448 				string sSubTestTime = GetStringUntilNextSpace( sRestOfLine );
   768 				string sSubTestTime = GetStringUntilNextSpace( sRestOfLine );
   449 				// Get sub test name
   769 				// Get sub test name
   450 				string sSubTestName = GetStringUntilNextSpace( sRestOfLine );
   770 				string sSubTestName = GetStringUntilNextSpace( sRestOfLine );
   459 
   779 
   460 				vProcessList[iProcessIDinList].vSubTests.push_back( SubTestData );
   780 				vProcessList[iProcessIDinList].vSubTests.push_back( SubTestData );
   461 			}
   781 			}
   462 			else if( ! _stricmp( pCommand, LABEL_TEST_END ) )
   782 			else if( ! _stricmp( pCommand, LABEL_TEST_END ) )
   463 			{
   783 			{
       
   784 				if( bCreateCleanedTraces )
       
   785 				{
       
   786 				// add message to cleaned traces file
       
   787 				cleanedTraces << sTime << " "; //add time
       
   788 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   789 				cleanedTraces << sProcessID << " "; //add process ID
       
   790 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   791 				}
       
   792 
   464 				// Get sub test time
   793 				// Get sub test time
   465 				string sSubTestEnd = GetStringUntilNextSpace( sRestOfLine );
   794 				string sSubTestEnd = GetStringUntilNextSpace( sRestOfLine );
   466 				// Get sub test name
   795 				// Get sub test name
   467 				string sSubTestName = GetStringUntilNextSpace( sRestOfLine );
   796 				string sSubTestName = GetStringUntilNextSpace( sRestOfLine );
   468 				// Get sub test end handle count
   797 				// Get sub test end handle count
   479 						viSubTestIter->sSubTestEndHandleCount = sSubTestEndHandleCount.c_str();
   808 						viSubTestIter->sSubTestEndHandleCount = sSubTestEndHandleCount.c_str();
   480 					}
   809 					}
   481 					viSubTestIter++;
   810 					viSubTestIter++;
   482 				}
   811 				}
   483 			}
   812 			}
       
   813 			else if( ! _stricmp( pCommand, LABEL_THREAD_START ) )
       
   814 			{
       
   815 				if( bCreateCleanedTraces )
       
   816 				{
       
   817 				// add message to cleaned traces file
       
   818 				cleanedTraces << sTime << " "; //add time
       
   819 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   820 				cleanedTraces << sProcessID << " "; //add process ID
       
   821 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   822 				}
       
   823 
       
   824 				//currently not used
       
   825 			}
       
   826 			else if( ! _stricmp( pCommand, LABEL_THREAD_END ) )
       
   827 			{
       
   828 				if( bCreateCleanedTraces )
       
   829 				{
       
   830 				// add message to cleaned traces file
       
   831 				cleanedTraces << sTime << " "; //add time
       
   832 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   833 				cleanedTraces << sProcessID << " "; //add process ID
       
   834 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   835 				}
       
   836 
       
   837 				//currently not used
       
   838 			}
       
   839 			else
       
   840 			{
       
   841 				// unknown tag, log it to cleaned file for carbide
       
   842 				if( bCreateCleanedTraces )
       
   843 				{
       
   844 				// add message to cleaned traces file
       
   845 				cleanedTraces << sTime << " "; //add time
       
   846 				cleanedTraces << MAIN_ID << " "; //add MAIN_ID
       
   847 				cleanedTraces << sProcessID << " "; //add process ID
       
   848 				cleanedTraces << sWholeTempLine << "\n"; //add the rest of the line
       
   849 				}
       
   850 			}
   484 		}
   851 		}
       
   852 	}
       
   853 
       
   854 	if( bCreateCleanedTraces )
       
   855 	{
       
   856 	// close stream
       
   857 	cleanedTraces.close();
   485 	}
   858 	}
   486 
   859 
   487 	// Print all saved data from processes
   860 	// Print all saved data from processes
   488 	for( unsigned int i = 0 ; i < vProcessList.size() ; i++ )
   861 	for( unsigned int i = 0 ; i < vProcessList.size() ; i++ )
   489 	{
   862 	{
   580 CATDataSaver* CATParseTraceFile::GetDataSaver(void)	
   953 CATDataSaver* CATParseTraceFile::GetDataSaver(void)	
   581 {
   954 {
   582 	LOG_LOW_FUNC_ENTRY("CATParseTraceFile::GetDataSaver");
   955 	LOG_LOW_FUNC_ENTRY("CATParseTraceFile::GetDataSaver");
   583 	return &m_DataSaver;
   956 	return &m_DataSaver;
   584 }
   957 }
       
   958 
       
   959 
       
   960 // -----------------------------------------------------------------------------
       
   961 // CATBase::GetTimeFromTimeStamp
       
   962 // Gets time from timestamp in microseconds as string
       
   963 // -----------------------------------------------------------------------------
       
   964 string CATParseTraceFile::GetTimeFromTimeStamp( unsigned __int64 iTimeStamp, unsigned __int64 iTimeSpan )
       
   965 {
       
   966 	unsigned __int64 iTime = iTimeStamp + iTimeSpan;
       
   967 	stringstream ss;
       
   968 	ss <<  std::hex << iTime;
       
   969 
       
   970     return ss.str();
       
   971 }
       
   972 
   585 //EOF
   973 //EOF