282 continue; |
282 continue; |
283 |
283 |
284 // get time string from timestamp |
284 // get time string from timestamp |
285 sTime = GetTimeFromTimeStamp( iTimeStamp, vProcessList[iProcessIDinList].iTimeSpan ); |
285 sTime = GetTimeFromTimeStamp( iTimeStamp, vProcessList[iProcessIDinList].iTimeSpan ); |
286 |
286 |
287 // TODO version with reallocation |
287 if( bCreateCleanedTraces ) |
288 //cleanedTraces << sTime << " "; //add time |
288 { |
289 //cleanedTraces << sLineToCleanedFile << "\n"; //add the rest of the line |
289 cleanedTraces << sTime << " "; //add time |
290 |
290 cleanedTraces << sLineToCleanedFile << "\n"; //add the rest of the line |
291 // "Old style" allocation (< v.1.6) |
291 } |
292 if( ! _stricmp( pCommand, ALLOC_ID ) ) |
292 |
|
293 // Allocation header |
|
294 if ( ! _stricmp( pCommand, ALLOCH_ID ) ) |
293 { |
295 { |
294 // Add alloc |
296 // Add alloc |
295 vProcessList[iProcessIDinList].Alloc( sRestOfLine ); |
297 vProcessList[iProcessIDinList].AllocH( sRestOfLine, sTime ); |
296 |
298 |
297 // Subtests running? |
299 // Subtests running? |
298 vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin(); |
300 vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin(); |
299 while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() ) |
301 while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() ) |
300 { |
302 { |
301 if( viSubTestIter->bRunning ) |
303 if( viSubTestIter->bRunning ) |
302 { |
304 { |
303 // Save alloc also to sub test |
305 // Save alloc also to sub test |
304 viSubTestIter->Alloc( sRestOfLine ); |
|
305 } |
|
306 viSubTestIter++; |
|
307 } |
|
308 } |
|
309 else if ( ! _stricmp( pCommand, ALLOCH_ID ) ) |
|
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 |
|
320 // Add alloc |
|
321 vProcessList[iProcessIDinList].AllocH( sRestOfLine, sTime ); |
|
322 |
|
323 // Subtests running? |
|
324 vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin(); |
|
325 while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() ) |
|
326 { |
|
327 if( viSubTestIter->bRunning ) |
|
328 { |
|
329 // Save alloc also to sub test |
|
330 viSubTestIter->AllocH( sRestOfLine, sTime ); |
306 viSubTestIter->AllocH( sRestOfLine, sTime ); |
331 } |
307 } |
332 viSubTestIter++; |
308 viSubTestIter++; |
333 } |
309 } |
334 } |
310 } |
335 // Allocation fragment (call stack). |
311 // Allocation fragment (call stack). |
336 else if ( ! _stricmp( pCommand, ALLOCF_ID ) ) |
312 else if ( ! _stricmp( pCommand, ALLOCF_ID ) ) |
337 { |
313 { |
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 |
314 // Add alloc fragment |
348 vProcessList[iProcessIDinList].AllocF( sRestOfLine, sTime ); |
315 vProcessList[iProcessIDinList].AllocF( sRestOfLine, sTime ); |
349 |
316 |
350 // Subtests running? |
317 // Subtests running? |
351 vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin(); |
318 vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin(); |
357 viSubTestIter->AllocF( sRestOfLine, sTime ); |
324 viSubTestIter->AllocF( sRestOfLine, sTime ); |
358 } |
325 } |
359 viSubTestIter++; |
326 viSubTestIter++; |
360 } |
327 } |
361 } |
328 } |
|
329 //Reallocation header |
362 else if ( ! _stricmp( pCommand, REALLOCH_ID ) ) |
330 else if ( ! _stricmp( pCommand, REALLOCH_ID ) ) |
363 { |
331 { |
|
332 // todo add reallocation flag? |
|
333 |
|
334 string sFreeLine = ""; |
|
335 string sAllocLine = ""; |
|
336 |
364 // Add free |
337 // Add free |
365 |
338 |
366 // get 'free' line from realloc line |
339 // get 'free' line from realloc line |
367 string sFreeRestOfLine = sRestOfLine; |
340 string sFreeRestOfLine = sRestOfLine; |
368 string sFreeLine = ""; |
341 |
369 sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address |
342 sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address |
370 sFreeLine.append( " " ); |
343 sFreeLine.append( " " ); |
371 // next two strings are for 'alloc' (address and size) - lets remove them |
344 // next two strings are for 'alloc' (address and size) - lets remove them |
372 GetStringUntilNextSpace( sFreeRestOfLine, true ); |
345 GetStringUntilNextSpace( sFreeRestOfLine, true ); |
373 GetStringUntilNextSpace( sFreeRestOfLine, true ); |
346 GetStringUntilNextSpace( sFreeRestOfLine, true ); |
374 // add rest of line to 'free' line |
347 // add rest of line to 'free' line |
375 sFreeLine.append( sFreeRestOfLine ); |
348 sFreeLine.append( sFreeRestOfLine ); |
376 //add 'free' line |
349 //add 'free' line |
377 vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime ); |
350 vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime ); |
378 |
351 |
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 |
352 // Add alloc |
391 |
353 |
392 //get 'alloc' line from realloc line |
354 //get 'alloc' line from realloc line |
393 // only first string is unnecessary, lets remove it |
355 // first string is for 'free' (address), lets remove it first |
394 GetStringUntilNextSpace( sRestOfLine ); |
356 GetStringUntilNextSpace( sRestOfLine ); |
|
357 sAllocLine = sRestOfLine; |
395 // add 'alloc' line |
358 // add 'alloc' line |
396 vProcessList[iProcessIDinList].AllocH( sRestOfLine, sTime ); |
359 vProcessList[iProcessIDinList].AllocH( sAllocLine, 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 |
360 |
409 // Subtests running? |
361 // Subtests running? |
410 vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin(); |
362 vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin(); |
411 while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() ) |
363 while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() ) |
412 { |
364 { |
413 if( viSubTestIter->bRunning ) |
365 if( viSubTestIter->bRunning ) |
414 { |
366 { |
415 // Save realloc also to sub test |
367 // Save realloc also to sub test |
416 // Add free |
368 |
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 |
369 //add 'free' line |
429 vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime ); |
370 vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime ); |
430 |
371 |
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 |
372 // add 'alloc' line |
437 vProcessList[iProcessIDinList].AllocH( sRestOfLine, sTime ); |
373 vProcessList[iProcessIDinList].AllocH( sAllocLine, sTime ); |
438 } |
374 } |
439 viSubTestIter++; |
375 viSubTestIter++; |
440 } |
376 } |
441 } |
377 } |
442 // rellocation fragment (call stack). |
378 // rellocation fragment (call stack) |
443 else if ( ! _stricmp( pCommand, REALLOCF_ID ) ) |
379 else if ( ! _stricmp( pCommand, REALLOCF_ID ) ) |
444 { |
380 { |
|
381 string sFreeLine = ""; |
|
382 string sAllocLine = ""; |
|
383 |
|
384 // Not used currently. |
|
385 /* |
445 // Add free fragment |
386 // Add free fragment |
446 |
387 |
447 // get 'free' line from realloc line |
388 // get 'free' line from realloc line |
448 string sFreeRestOfLine = sRestOfLine; |
389 string sFreeRestOfLine = sRestOfLine; |
449 string sFreeLine = ""; |
|
450 sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address |
390 sFreeLine.append( GetStringUntilNextSpace( sFreeRestOfLine, true ) ); //append freed memory address |
451 sFreeLine.append( " " ); |
391 sFreeLine.append( " " ); |
452 // next string is for 'alloc' (address) - lets remove it |
392 // next string is for 'alloc' (address) - lets remove it |
453 GetStringUntilNextSpace( sFreeRestOfLine, true ); |
393 GetStringUntilNextSpace( sFreeRestOfLine, true ); |
454 // add rest of line to 'free' line |
394 // add rest of line to 'free' line |
455 sFreeLine.append( sFreeRestOfLine ); |
395 sFreeLine.append( sFreeRestOfLine ); |
|
396 |
456 //add 'free' line |
397 //add 'free' line |
457 vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime ); |
398 vProcessList[iProcessIDinList].FreeF( sFreeLine, sTime ); |
458 |
399 */ |
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 |
400 |
470 // Add alloc fragment |
401 // Add alloc fragment |
471 |
402 |
472 // first string is for 'free' (address), lets remove it first |
403 // first string is for 'free' (address), lets remove it first |
473 GetStringUntilNextSpace( sRestOfLine, true ); |
404 GetStringUntilNextSpace( sRestOfLine, true ); |
|
405 sAllocLine = sRestOfLine; |
474 //add 'alloc' line |
406 //add 'alloc' line |
475 vProcessList[iProcessIDinList].AllocF( sRestOfLine, sTime ); |
407 vProcessList[iProcessIDinList].AllocF( sAllocLine, 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 |
408 |
488 // Subtests running? |
409 // Subtests running? |
489 vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin(); |
410 vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin(); |
490 while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() ) |
411 while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() ) |
491 { |
412 { |
492 if( viSubTestIter->bRunning ) |
413 if( viSubTestIter->bRunning ) |
493 { |
414 { |
494 // Save alloc fragment also to sub test |
415 // Save realloc fragment also to sub test |
495 // Add free fragment |
416 |
496 |
417 // Not used currently. |
497 // get 'free' line from realloc line |
418 /* |
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 |
419 //add 'free' line |
507 vProcessList[iProcessIDinList].FreeH( sFreeLine, sTime ); |
420 vProcessList[iProcessIDinList].FreeF( sFreeLine, sTime ); |
508 |
421 */ |
509 // Add alloc fragment |
422 |
510 |
|
511 // first string is for 'free' (address), lets remove it first |
|
512 GetStringUntilNextSpace( sRestOfLine, true ); |
|
513 //add 'alloc' line |
423 //add 'alloc' line |
514 vProcessList[iProcessIDinList].AllocF( sRestOfLine, sTime ); |
424 vProcessList[iProcessIDinList].AllocF( sAllocLine, sTime ); |
515 } |
425 } |
516 viSubTestIter++; |
426 viSubTestIter++; |
517 } |
427 } |
518 } |
428 } |
519 // Command free |
429 // Free header |
520 else if( ! _stricmp( pCommand, FREE_ID ) ) |
430 else if( ! _stricmp( pCommand, FREEH_ID ) ) |
521 { |
431 { |
522 // Send free |
432 // Send free |
523 vProcessList[iProcessIDinList].Free( sRestOfLine ); |
433 vProcessList[iProcessIDinList].FreeH( sRestOfLine, sTime ); |
524 |
434 |
525 // Subtests running? |
435 // Subtests running? |
526 vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin(); |
436 vector<CSubTestData>::iterator viSubTestIter = vProcessList[iProcessIDinList].vSubTests.begin(); |
527 while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() ) |
437 while( viSubTestIter != vProcessList[iProcessIDinList].vSubTests.end() ) |
528 { |
438 { |
529 if( viSubTestIter->bRunning ) |
439 if( viSubTestIter->bRunning ) |
530 { |
440 { |
531 // Send free to subtest |
441 // Send free to subtest |
532 viSubTestIter->Free( sRestOfLine ); |
442 viSubTestIter->FreeH( sRestOfLine, sTime ); |
533 } |
443 } |
534 viSubTestIter++; |
444 viSubTestIter++; |
535 } |
445 } |
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 } |
|
563 |
446 |
564 } |
447 } |
|
448 // Free fragment |
565 else if( ! _stricmp( pCommand, FREEF_ID ) ) |
449 else if( ! _stricmp( pCommand, FREEF_ID ) ) |
566 { |
450 { |
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. |
451 // Not used currently. |
576 } |
452 } |
577 // Command process end |
453 // Command process end |
578 else if( ! _stricmp( pCommand, LABEL_PROCESS_END ) ) |
454 else if( ! _stricmp( pCommand, LABEL_PROCESS_END ) ) |
579 { |
455 { |
580 // append processID and time |
456 // add processID and time |
581 sWholeTempLine.append(" "); |
457 sWholeTempLine.append(" "); |
582 sWholeTempLine.append( sProcessID ); |
458 sWholeTempLine.append( sProcessID ); |
583 sWholeTempLine.append(" "); |
459 sWholeTempLine.append(" "); |
584 sWholeTempLine.append( sTime ); |
460 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 |
461 |
595 // Set process has ended. |
462 // Set process has ended. |
596 vProcessList[iProcessIDinList].bProcessOnGoing = false; |
463 vProcessList[iProcessIDinList].bProcessOnGoing = false; |
597 |
464 |
598 // Save leaks |
465 // Save leaks |