analyzetool/commandlineengine/src/CATParseTraceFile.cpp
branchRCL_3
changeset 59 8ad140f3dd41
parent 49 7fdc9a71d314
equal deleted inserted replaced
49:7fdc9a71d314 59:8ad140f3dd41
    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"
       
    24 
    23 
    25 #include <time.h>
    24 #include <time.h>
    26 
    25 
    27 
    26 #define MAIN_ID "PCSS"
       
    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 };
    28 
    45 
    29 // -----------------------------------------------------------------------------
    46 // -----------------------------------------------------------------------------
    30 // CATParseTraceFile::CATParseTraceFile
    47 // CATParseTraceFile::CATParseTraceFile
    31 // Constructor.
    48 // Constructor.
    32 // -----------------------------------------------------------------------------
    49 // -----------------------------------------------------------------------------
    38 
    55 
    39 // -----------------------------------------------------------------------------
    56 // -----------------------------------------------------------------------------
    40 // CATParseTraceFile::StartParse
    57 // CATParseTraceFile::StartParse
    41 // Main function to start trace parsing.
    58 // Main function to start trace parsing.
    42 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    43 bool CATParseTraceFile::StartParse( const char* pFileName, const char* pOutputFileName, const char* pCleanedTraceFile )
    60 bool CATParseTraceFile::StartParse( const char* pFileName, const char* pOutputFileName )
    44 {
    61 {
    45 	LOG_FUNC_ENTRY("CATParseTraceFile::StartParse");
    62 	LOG_FUNC_ENTRY("CATParseTraceFile::StartParse");
    46 
    63 
    47 	// Return value, will be changed to true if process start found.
    64 	// Return value, will be changed to true if process start found.
    48 	bool bRet = false;
    65 	bool bRet = false;
    49 	bool bCreateCleanedTraces = false;
       
    50 
    66 
    51 	// Check pointers
    67 	// Check pointers
    52 	if ( pFileName == NULL  )
    68 	if ( pFileName == NULL  )
    53 		return bRet;
    69 		return bRet;
    54 
    70 
    59 	{
    75 	{
    60 		cout << AT_MSG << "Error, input file \""
    76 		cout << AT_MSG << "Error, input file \""
    61 			<< pFileName
    77 			<< pFileName
    62 			<< "\" does not exist." << endl;
    78 			<< "\" does not exist." << endl;
    63 		return bRet;
    79 		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 		}
       
    82 	}
    80 	}
    83 
    81 
    84 	// Open data file
    82 	// Open data file
    85 	ifstream in( pFileName );
    83 	ifstream in( pFileName );
    86 
    84 
   140 
   138 
   141 		// Is there main ID?
   139 		// Is there main ID?
   142 		if( strstr( cLineFromFile, MAIN_ID ) != NULL )
   140 		if( strstr( cLineFromFile, MAIN_ID ) != NULL )
   143 		{
   141 		{
   144 			string sRestOfLine( cLineFromFile );
   142 			string sRestOfLine( cLineFromFile );
   145 			string sTemp("");
   143 			string sTemp;
   146 			unsigned __int64 iTimeStamp(0);
   144 
   147 			string sTime("");
   145 			// Delete all characters before main ID
   148 			string sLineStart("");
   146 			sRestOfLine.erase( 0, sRestOfLine.find( MAIN_ID ) );
   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 );
       
   156 
   147 
   157 			// Get main ID
   148 			// Get main ID
   158 			sTemp = GetStringUntilNextSpace( sRestOfLine );
   149 			sTemp = GetStringUntilNextSpace( sRestOfLine );
   159 
   150 
   160 			// Is there more data in line?
   151 			// Is there more data in line?
   163 				continue;
   154 				continue;
   164 			}
   155 			}
   165 
   156 
   166 			// Get next argument
   157 			// Get next argument
   167 			sTemp = GetStringUntilNextSpace( sRestOfLine );
   158 			sTemp = GetStringUntilNextSpace( sRestOfLine );
   168 			// This might be process id, device info message or error message
   159 			// This might be process id or error message
   169 			if ( sTemp.compare( ERROR_OCCURED ) == 0 )
   160 			if ( sTemp.compare( ERROR_OCCURED ) == 0 )
   170 			{
   161 			{
   171 				// Api mismatch between s60 side and atool.exe
   162 				// Api mismatch between s60 side and atool.exe
   172 				if ( sRestOfLine.find( INCORRECT_ATOOL_VERSION ) != string::npos )
   163 				if ( sRestOfLine.find( INCORRECT_ATOOL_VERSION ) != string::npos )
   173 				{
   164 				{
   186 				}
   177 				}
   187 				else
   178 				else
   188 					cout << sRestOfLine << endl;
   179 					cout << sRestOfLine << endl;
   189 				continue;
   180 				continue;
   190 			}
   181 			}
   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 
       
   213 			unsigned long iProcessID = _httoi( sTemp.c_str() );
   182 			unsigned long iProcessID = _httoi( sTemp.c_str() );
   214 			// todo to be removed when reallocations are implemented
       
   215 			string sProcessID = sTemp;
       
   216 
   183 
   217 			iProcessIDinList = -1;
   184 			iProcessIDinList = -1;
   218 			// Find process from list
   185 			// Find process from list
   219 			for( unsigned int i = 0 ; i < vProcessList.size() ; i++ )
   186 			for( unsigned int i = 0 ; i < vProcessList.size() ; i++ )
   220 			{
   187 			{
   252 			if( ! _stricmp( pCommand, LABEL_PROCESS_START ) )
   219 			if( ! _stricmp( pCommand, LABEL_PROCESS_START ) )
   253 			{
   220 			{
   254 				bRet = true; // Set return value true we found start.
   221 				bRet = true; // Set return value true we found start.
   255 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   222 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   256 				vProcessList[iProcessIDinList].bProcessOnGoing = true;
   223 				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 
       
   277 				continue;
   224 				continue;
   278 			}
   225 			}
   279 
   226 
   280 			// Check is process ongoing if not skip other tags.
   227 			// Check is process ongoing if not skip other tags.
   281 			if( vProcessList[iProcessIDinList].bProcessOnGoing == false )
   228 			if( vProcessList[iProcessIDinList].bProcessOnGoing == false )
   282 				continue;
   229 				continue;
   283 
   230 
   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 
       
   291 			// "Old style" allocation (< v.1.6)
   231 			// "Old style" allocation (< v.1.6)
   292 			if( ! _stricmp( pCommand, ALLOC_ID ) )
   232 			if( ! _stricmp( pCommand, ALLOC_ID ) )
   293 			{
   233 			{
   294 				// Add alloc
   234 				// Add alloc
   295 				vProcessList[iProcessIDinList].Alloc( sRestOfLine );
   235 				vProcessList[iProcessIDinList].Alloc( sRestOfLine );
   306 					viSubTestIter++;
   246 					viSubTestIter++;
   307 				}
   247 				}
   308 			}
   248 			}
   309 			else if ( ! _stricmp( pCommand, ALLOCH_ID ) )
   249 			else if ( ! _stricmp( pCommand, ALLOCH_ID ) )
   310 			{
   250 			{
   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 
       
   320 				// Add alloc
   251 				// Add alloc
   321 				vProcessList[iProcessIDinList].AllocH( sRestOfLine, sTime );
   252 				vProcessList[iProcessIDinList].AllocH( sRestOfLine );
   322 
   253 
   323 				// Subtests running?
   254 				// Subtests running?
   324 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   255 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   325 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   256 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   326 				{
   257 				{
   327 					if( viSubTestIter->bRunning )
   258 					if( viSubTestIter->bRunning )
   328 					{
   259 					{
   329 						// Save alloc also to sub test
   260 						// Save alloc also to sub test
   330 						viSubTestIter->AllocH( sRestOfLine, sTime );
   261 						viSubTestIter->AllocH( sRestOfLine );
   331 					}
   262 					}
   332 					viSubTestIter++;
   263 					viSubTestIter++;
   333 				}
   264 				}
   334 			}
   265 			}
   335 			// Allocation fragment (call stack).
   266 			// Allocation fragment (call stack).
   336 			else if ( ! _stricmp( pCommand, ALLOCF_ID ) )
   267 			else if ( ! _stricmp( pCommand, ALLOCF_ID ) )
   337 			{
   268 			{
   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 
       
   347 				// Add alloc fragment
   269 				// Add alloc fragment
   348 				vProcessList[iProcessIDinList].AllocF( sRestOfLine, sTime );
   270 				vProcessList[iProcessIDinList].AllocF( sRestOfLine );
   349 				
   271 				
   350 				// Subtests running?
   272 				// Subtests running?
   351 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   273 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   352 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   274 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   353 				{
   275 				{
   354 					if( viSubTestIter->bRunning )
   276 					if( viSubTestIter->bRunning )
   355 					{
   277 					{
   356 						// Save alloc fragment also to sub test
   278 						// Save alloc fragment also to sub test
   357 						viSubTestIter->AllocF( sRestOfLine, sTime );
   279 						viSubTestIter->AllocF( sRestOfLine );
   358 					}
       
   359 					viSubTestIter++;
       
   360 				}
       
   361 			}
       
   362 			else if ( ! _stricmp( pCommand, REALLOCH_ID ) )
       
   363 			{
       
   364 				// Add free
       
   365 
       
   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 				}
       
   408 
       
   409 				// Subtests running?
       
   410 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
       
   411 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
       
   412 				{
       
   413 					if( viSubTestIter->bRunning )
       
   414 					{
       
   415 						// Save realloc also to sub test
       
   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 );
       
   438 					}
       
   439 					viSubTestIter++;
       
   440 				}
       
   441 			}
       
   442 			// rellocation fragment (call stack).
       
   443 			else if ( ! _stricmp( pCommand, REALLOCF_ID ) )
       
   444 			{
       
   445 				// Add free fragment 
       
   446 
       
   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 				
       
   488 				// Subtests running?
       
   489 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
       
   490 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
       
   491 				{
       
   492 					if( viSubTestIter->bRunning )
       
   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 					}
   280 					}
   516 					viSubTestIter++;
   281 					viSubTestIter++;
   517 				}
   282 				}
   518 			}
   283 			}
   519 			// Command free
   284 			// Command free
   535 				}
   300 				}
   536 			}
   301 			}
   537 			// Header free.
   302 			// Header free.
   538 			else if( ! _stricmp( pCommand, FREEH_ID ) )
   303 			else if( ! _stricmp( pCommand, FREEH_ID ) )
   539 			{
   304 			{
   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
   305 				// Send free
   550 				vProcessList[iProcessIDinList].FreeH( sRestOfLine, sTime );
   306 				vProcessList[iProcessIDinList].FreeH( sRestOfLine );
   551 
   307 
   552 				// Subtests running?
   308 				// Subtests running?
   553 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   309 				vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin();
   554 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   310 				while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() )
   555 				{
   311 				{
   556 					if( viSubTestIter->bRunning )
   312 					if( viSubTestIter->bRunning )
   557 					{
   313 					{
   558 						// Send free to subtest
   314 						// Send free to subtest
   559 						viSubTestIter->FreeH( sRestOfLine, sTime );
   315 						viSubTestIter->FreeH( sRestOfLine );
   560 					}
   316 					}
   561 					viSubTestIter++;
   317 					viSubTestIter++;
   562 				}
   318 				}
   563 			
   319 			
   564 			}
   320 			}
   565 			else if( ! _stricmp( pCommand, FREEF_ID ) )
   321 			else if( ! _stricmp( pCommand, FREEF_ID ) )
   566 			{
   322 			{
   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 				}
       
   575 				// Not used currently.
   323 				// Not used currently.
   576 			}
   324 			}
   577 			// Command process end
   325 			// Command process end
   578 			else if( ! _stricmp( pCommand, LABEL_PROCESS_END ) )
   326 			else if( ! _stricmp( pCommand, LABEL_PROCESS_END ) )
   579 			{
   327 			{
   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 
       
   595 				// Set process has ended.
   328 				// Set process has ended.
   596 				vProcessList[iProcessIDinList].bProcessOnGoing = false;
   329 				vProcessList[iProcessIDinList].bProcessOnGoing = false;
   597 
   330 
   598 				// Save leaks
   331 				// Save leaks
   599 				vector<string> vLeaks;
   332 				vector<string> vLeaks;
   670 				vProcessList[iProcessIDinList].vSubTests.clear();
   403 				vProcessList[iProcessIDinList].vSubTests.clear();
   671 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   404 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   672 			}
   405 			}
   673 			else if( ! _stricmp( pCommand, LABEL_HANDLE_LEAK ) )
   406 			else if( ! _stricmp( pCommand, LABEL_HANDLE_LEAK ) )
   674 			{
   407 			{
   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 
       
   684 				// Make whole line
   408 				// Make whole line
   685 				sTemp.append( " " );
   409 				sTemp.append( " " );
   686 				sTemp.append( sRestOfLine );
   410 				sTemp.append( sRestOfLine );
   687 				vProcessList[iProcessIDinList].vHandleLeaks.push_back( sTemp );
   411 				vProcessList[iProcessIDinList].vHandleLeaks.push_back( sTemp );
   688 			}
   412 			}
   689 			else if( ! _stricmp( pCommand, LABEL_DLL_LOAD ) )
   413 			else if( ! _stricmp( pCommand, LABEL_DLL_LOAD ) )
   690 			{
   414 			{
   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 
       
   704 				// Add module load to process data.
   415 				// Add module load to process data.
   705 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   416 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   706 				// Add module load to subtest data if test running.
   417 				// Add module load to subtest data if test running.
   707 				for( vector<CSubTestData>::iterator it = vProcessList[iProcessIDinList].vSubTests.begin();
   418 				for( vector<CSubTestData>::iterator it = vProcessList[iProcessIDinList].vSubTests.begin();
   708 					it != vProcessList[iProcessIDinList].vSubTests.end(); it++ )
   419 					it != vProcessList[iProcessIDinList].vSubTests.end(); it++ )
   712 				}
   423 				}
   713 
   424 
   714 			}
   425 			}
   715 			else if( ! _stricmp( pCommand, LABEL_DLL_UNLOAD ) )
   426 			else if( ! _stricmp( pCommand, LABEL_DLL_UNLOAD ) )
   716 			{
   427 			{
   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 
       
   730 				// Add module load to process data.
   428 				// Add module load to process data.
   731 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   429 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   732 				// Add module unload to subtest data if test running.
   430 				// Add module unload to subtest data if test running.
   733 				for( vector<CSubTestData>::iterator it = vProcessList[iProcessIDinList].vSubTests.begin();
   431 				for( vector<CSubTestData>::iterator it = vProcessList[iProcessIDinList].vSubTests.begin();
   734 					it != vProcessList[iProcessIDinList].vSubTests.end(); it++ )
   432 					it != vProcessList[iProcessIDinList].vSubTests.end(); it++ )
   739 			}
   437 			}
   740 			else if( sTemp.find( LABEL_LOGGING_CANCELLED ) != string::npos ||
   438 			else if( sTemp.find( LABEL_LOGGING_CANCELLED ) != string::npos ||
   741 				     sTemp.find( LABEL_PROCESS_END ) != string::npos || sTemp.find( LABEL_ERROR_OCCURED ) != string::npos ||
   439 				     sTemp.find( LABEL_PROCESS_END ) != string::npos || sTemp.find( LABEL_ERROR_OCCURED ) != string::npos ||
   742 					 sTemp.find( LABEL_HANDLE_LEAK ) != string::npos )
   440 					 sTemp.find( LABEL_HANDLE_LEAK ) != string::npos )
   743 			{
   441 			{
   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 
       
   753 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   442 				vProcessList[iProcessIDinList].vData.push_back( sWholeTempLine );
   754 			}
   443 			}
   755 			else if( ! _stricmp( pCommand, LABEL_TEST_START ) )
   444 			else if( ! _stricmp( pCommand, LABEL_TEST_START ) )
   756 			{
   445 			{
   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 
       
   766 				bRet = true; // Set return value true we found start.
   446 				bRet = true; // Set return value true we found start.
   767 				// Get sub test time
   447 				// Get sub test time
   768 				string sSubTestTime = GetStringUntilNextSpace( sRestOfLine );
   448 				string sSubTestTime = GetStringUntilNextSpace( sRestOfLine );
   769 				// Get sub test name
   449 				// Get sub test name
   770 				string sSubTestName = GetStringUntilNextSpace( sRestOfLine );
   450 				string sSubTestName = GetStringUntilNextSpace( sRestOfLine );
   779 
   459 
   780 				vProcessList[iProcessIDinList].vSubTests.push_back( SubTestData );
   460 				vProcessList[iProcessIDinList].vSubTests.push_back( SubTestData );
   781 			}
   461 			}
   782 			else if( ! _stricmp( pCommand, LABEL_TEST_END ) )
   462 			else if( ! _stricmp( pCommand, LABEL_TEST_END ) )
   783 			{
   463 			{
   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 
       
   793 				// Get sub test time
   464 				// Get sub test time
   794 				string sSubTestEnd = GetStringUntilNextSpace( sRestOfLine );
   465 				string sSubTestEnd = GetStringUntilNextSpace( sRestOfLine );
   795 				// Get sub test name
   466 				// Get sub test name
   796 				string sSubTestName = GetStringUntilNextSpace( sRestOfLine );
   467 				string sSubTestName = GetStringUntilNextSpace( sRestOfLine );
   797 				// Get sub test end handle count
   468 				// Get sub test end handle count
   808 						viSubTestIter->sSubTestEndHandleCount = sSubTestEndHandleCount.c_str();
   479 						viSubTestIter->sSubTestEndHandleCount = sSubTestEndHandleCount.c_str();
   809 					}
   480 					}
   810 					viSubTestIter++;
   481 					viSubTestIter++;
   811 				}
   482 				}
   812 			}
   483 			}
   813 			else if( ! _stricmp( pCommand, LABEL_THREAD_START ) )
   484 		}
   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 			}
       
   851 		}
       
   852 	}
       
   853 
       
   854 	if( bCreateCleanedTraces )
       
   855 	{
       
   856 	// close stream
       
   857 	cleanedTraces.close();
       
   858 	}
   485 	}
   859 
   486 
   860 	// Print all saved data from processes
   487 	// Print all saved data from processes
   861 	for( unsigned int i = 0 ; i < vProcessList.size() ; i++ )
   488 	for( unsigned int i = 0 ; i < vProcessList.size() ; i++ )
   862 	{
   489 	{
   953 CATDataSaver* CATParseTraceFile::GetDataSaver(void)	
   580 CATDataSaver* CATParseTraceFile::GetDataSaver(void)	
   954 {
   581 {
   955 	LOG_LOW_FUNC_ENTRY("CATParseTraceFile::GetDataSaver");
   582 	LOG_LOW_FUNC_ENTRY("CATParseTraceFile::GetDataSaver");
   956 	return &m_DataSaver;
   583 	return &m_DataSaver;
   957 }
   584 }
   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 
       
   973 //EOF
   585 //EOF