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++ ) |