Changeset 99c90b3 in rtems-tools for tester/covoar/ObjdumpProcessor.cc
- Timestamp:
- Aug 5, 2018, 11:41:08 PM (16 months ago)
- Branches:
- master
- Children:
- 317d85d
- Parents:
- f450227
- git-author:
- Chris Johns <chrisj@…> (08/05/18 23:41:08)
- git-committer:
- Chris Johns <chrisj@…> (08/06/18 23:11:29)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tester/covoar/ObjdumpProcessor.cc
rf450227 r99c90b3 30 30 ExecutableInfo* const executableInfo, 31 31 std::string& symbolName, 32 uint32_t lowAddress,33 uint32_t highAddress,34 32 ObjdumpProcessor::objdumpLines_t instructions 35 33 ) { 36 37 CoverageMapBase* aCoverageMap = NULL; 38 uint32_t endAddress = highAddress; 39 ObjdumpProcessor::objdumpLines_t::iterator itr, fnop, lnop; 40 ObjdumpProcessor::objdumpLines_t::reverse_iterator ritr; 41 SymbolInformation* symbolInfo = NULL; 42 SymbolTable* theSymbolTable; 43 44 // 45 // Remove trailing nop instructions. 46 // 47 48 // First find the last instruction. 49 for (ritr = instructions.rbegin(); 50 ritr != instructions.rend(); 51 ritr++) { 52 if (ritr->isInstruction) 53 break; 54 } 55 56 // If an instruction was found and it is a nop, ... 57 if ((ritr != instructions.rend()) && (ritr->isNop)) { 58 59 // save it as the last nop. Note that we must account for 60 // the difference between a forward and a reverse iterator. 61 lnop = ritr.base(); 62 lnop--; 63 endAddress -= lnop->nopSize; 64 65 // Now look for the first nop in the sequence of trailing nops. 66 fnop = lnop; 67 ritr++; 68 for (; ritr != instructions.rend(); ritr++) { 69 if (ritr->isNop) { 70 fnop = ritr.base(); 71 fnop--; 72 endAddress -= fnop->nopSize; 73 } 74 else 75 break; 76 } 77 78 // Erase trailing nops. The erase operation wants the first 79 // parameter to point to the first item to erase and the second 80 // parameter to point to the item beyond the last item to erase. 81 if ( fnop == lnop ) 82 instructions.erase( fnop ); 83 else 84 instructions.erase( fnop, ++lnop ); 85 } 34 // Find the symbol's coverage map. 35 CoverageMapBase& coverageMap = executableInfo->findCoverageMap( symbolName ); 36 37 uint32_t lowAddress = coverageMap.getFirstLowAddress(); 38 uint32_t size = coverageMap.getSize(); 39 uint32_t highAddress = lowAddress + size; 86 40 87 41 // If there are NOT already saved instructions, save them. 88 symbolInfo = SymbolsToAnalyze->find( symbolName );42 SymbolInformation* symbolInfo = SymbolsToAnalyze->find( symbolName ); 89 43 if (symbolInfo->instructions.empty()) { 90 44 symbolInfo->sourceFile = executableInfo; … … 94 48 95 49 // Add the symbol to this executable's symbol table. 96 theSymbolTable = executableInfo->getSymbolTable();50 SymbolTable* theSymbolTable = executableInfo->getSymbolTable(); 97 51 theSymbolTable->addSymbol( 98 symbolName, lowAddress, endAddress - lowAddress + 152 symbolName, lowAddress, highAddress - lowAddress + 1 99 53 ); 100 54 101 // Create a coverage map for the symbol. 102 aCoverageMap = executableInfo->createCoverageMap( 103 executableInfo->getFileName().c_str(), symbolName, lowAddress, endAddress 55 // Mark the start of each instruction in the coverage map. 56 for (auto& instruction : instructions) { 57 coverageMap.setIsStartOfInstruction( instruction.address ); 58 } 59 60 // Create a unified coverage map for the symbol. 61 SymbolsToAnalyze->createCoverageMap( 62 executableInfo->getFileName().c_str(), symbolName, size 104 63 ); 105 106 if (aCoverageMap) {107 108 // Mark the start of each instruction in the coverage map.109 for (itr = instructions.begin();110 itr != instructions.end();111 itr++ ) {112 113 aCoverageMap->setIsStartOfInstruction( itr->address );114 }115 116 // Create a unified coverage map for the symbol.117 SymbolsToAnalyze->createCoverageMap(118 executableInfo->getFileName().c_str(), symbolName,119 endAddress - lowAddress + 1120 );121 }122 64 } 123 65 … … 354 296 355 297 while ( true ) { 356 357 298 // Get the line. 358 299 objdumpFile.read_line( line ); 359 300 if ( line.empty() ) { 360 361 301 // If we are currently processing a symbol, finalize it. 362 302 if (processSymbol) { … … 364 304 executableInformation, 365 305 currentSymbol, 366 startAddress,367 executableInformation->getLoadAddress() + offset,368 306 theInstructions 369 307 ); … … 389 327 lineInfo.isBranch = false; 390 328 329 instruction[0] = '\0'; 330 ID[0] = '\0'; 331 391 332 // Look for the start of a symbol's objdump and extract 392 333 // offset and symbol (i.e. offset <symbolname>:). … … 408 349 // If all items found, we are at the beginning of a symbol's objdump. 409 350 if ((items == 3) && (terminator1 == ':')) { 410 411 351 endAddress = executableInformation->getLoadAddress() + offset - 1; 412 352 … … 416 356 executableInformation, 417 357 currentSymbol, 418 startAddress,419 endAddress,420 358 theInstructions 421 359 ); … … 442 380 && processSymbol ) 443 381 { 444 445 endAddress = executableInformation->getLoadAddress() + offset - 1; 446 447 // If we are currently processing a symbol, finalize it. 448 if ( processSymbol ) { 449 finalizeSymbol( 450 executableInformation, 451 currentSymbol, 452 startAddress, 453 endAddress, 454 theInstructions 382 endAddress = executableInformation->getLoadAddress() + offset - 1; 383 384 // If we are currently processing a symbol, finalize it. 385 if ( processSymbol ) { 386 finalizeSymbol( 387 executableInformation, 388 currentSymbol, 389 theInstructions 455 390 ); 456 457 391 } 392 processSymbol = false; 458 393 } 459 394 else if (processSymbol) { … … 468 403 // If it looks like an instruction ... 469 404 if ((items == 3) && (terminator1 == ':') && (terminator2 == '\t')) { 470 471 405 // update the line's information, save it and ... 472 406 lineInfo.address =
Note: See TracChangeset
for help on using the changeset viewer.