Changeset 99c90b3 in rtems-tools for tester/covoar/ObjdumpProcessor.cc


Ignore:
Timestamp:
Aug 5, 2018, 11:41:08 PM (16 months ago)
Author:
Chris Johns <chrisj@…>
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)
Message:

tester/covoar: Integrate DWARF function data.

Use DAWRF function data to create the executable coverage
maps. Integrate the existing objdump processing with this
data.

  • Refactor CoverageMapBase? to have the address ranges and address info as separate objects. Move the to address info into a vector. Add support for multiple address ranges.
  • DesiredSymbols? is only interested in function symbols.
  • ExecutableInfo? creates coverage maps from DWARF function data.
  • Add warning flags to the covoar build.
  • Varous C++11 refactoring.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tester/covoar/ObjdumpProcessor.cc

    rf450227 r99c90b3  
    3030    ExecutableInfo* const            executableInfo,
    3131    std::string&                     symbolName,
    32     uint32_t                         lowAddress,
    33     uint32_t                         highAddress,
    3432    ObjdumpProcessor::objdumpLines_t instructions
    3533  ) {
    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;
    8640
    8741    // If there are NOT already saved instructions, save them.
    88     symbolInfo = SymbolsToAnalyze->find( symbolName );
     42    SymbolInformation* symbolInfo = SymbolsToAnalyze->find( symbolName );
    8943    if (symbolInfo->instructions.empty()) {
    9044      symbolInfo->sourceFile = executableInfo;
     
    9448
    9549    // Add the symbol to this executable's symbol table.
    96     theSymbolTable = executableInfo->getSymbolTable();
     50    SymbolTable* theSymbolTable = executableInfo->getSymbolTable();
    9751    theSymbolTable->addSymbol(
    98       symbolName, lowAddress, endAddress - lowAddress + 1
     52      symbolName, lowAddress, highAddress - lowAddress + 1
    9953    );
    10054
    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
    10463    );
    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 + 1
    120       );
    121     }
    12264  }
    12365
     
    354296
    355297    while ( true ) {
    356 
    357298      // Get the line.
    358299      objdumpFile.read_line( line );
    359300      if ( line.empty() ) {
    360 
    361301        // If we are currently processing a symbol, finalize it.
    362302        if (processSymbol) {
     
    364304            executableInformation,
    365305            currentSymbol,
    366             startAddress,
    367             executableInformation->getLoadAddress() + offset,
    368306            theInstructions
    369307          );
     
    389327      lineInfo.isBranch      = false;
    390328
     329      instruction[0] = '\0';
     330      ID[0] = '\0';
     331
    391332      // Look for the start of a symbol's objdump and extract
    392333      // offset and symbol (i.e. offset <symbolname>:).
     
    408349      // If all items found, we are at the beginning of a symbol's objdump.
    409350      if ((items == 3) && (terminator1 == ':')) {
    410 
    411351        endAddress = executableInformation->getLoadAddress() + offset - 1;
    412352
     
    416356            executableInformation,
    417357            currentSymbol,
    418             startAddress,
    419             endAddress,
    420358            theInstructions
    421359          );
     
    442380               && processSymbol )
    443381      {
    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
    455390            );
    456           }
    457           processSymbol = false;
     391        }
     392        processSymbol = false;
    458393      }
    459394      else if (processSymbol) {
     
    468403        // If it looks like an instruction ...
    469404        if ((items == 3) && (terminator1 == ':') && (terminator2 == '\t')) {
    470 
    471405          // update the line's information, save it and ...
    472406          lineInfo.address =
Note: See TracChangeset for help on using the changeset viewer.