Changeset c1a3cbc in rtems-testing


Ignore:
Timestamp:
Apr 29, 2010, 7:12:31 PM (9 years ago)
Author:
Jennifer Averett <Jennifer.Averett@…>
Branches:
4.11, 8895273c193787f84c4585a10f6d6aceb3b25dc4
Children:
d69d629
Parents:
ef2241b
Message:

2010-04-29 Jennifer Averett <Jennifer.Averett@…>

Location:
rtems-coverage
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • rtems-coverage/ChangeLog

    ref2241b rc1a3cbc  
     12010-04-29      Jennifer Averett <Jennifer.Averett@OARcorp.com>
     2
     3        * CoverageMapBase.cc, CoverageReaderQEMU.cc, DesiredSymbols.cc,
     4        DesiredSymbols.h, Makefile, ObjdumpProcessor.cc, ObjdumpProcessor.h,
     5        TargetBase.cc, TargetBase.h, Target_i386.cc, Target_i386.h,
     6        Target_lm32.cc, Target_lm32.h, Target_sparc.cc,
     7        TraceReaderLogQEMU.cc, covoar.cc: Modified such that branch
     8        information is gathered from the objdump file and cleaned up comments
     9
    1102010-04-26      Jennifer Averett <Jennifer.Averett@OARcorp.com>
    211
  • rtems-coverage/CoverageMapBase.cc

    ref2241b rc1a3cbc  
    187187    if ((address < lowAddress) || (address > highAddress))
    188188      return false;
    189     return (!Info[ address - lowAddress ].wasTaken);
     189    return (!Info[ address - lowAddress ].wasTaken &&
     190            Info[ address - lowAddress ].wasNotTaken);
    190191  }
    191192
  • rtems-coverage/CoverageReaderQEMU.cc

    ref2241b rc1a3cbc  
    102102
    103103    //
    104     // Read and process each line of the coverage file.
     104    // Read ENTRIES number of trace entries.
    105105    //
    106106#define ENTRIES 1024
     
    111111      int                 num_entries;
    112112
     113
     114      // Read and process each line of the coverage file.
    113115      num_entries = fread(
    114116        entries,
     
    120122        break;
    121123
     124      // Get the coverage map for each entry.  Note that the map is
     125      // the same for each entry in the coverage map
    122126      for (int count=0; count<num_entries; count++) {
     127
    123128        entry = &entries[count];
    124129     
     
    131136          continue;
    132137
    133         #if 0
    134           fprintf( stderr, "0x%08x %d 0x%2x \n", entry->pc, entry->size, entry->op );
    135         #endif
     138        // Set was executed for each TRACE_OP_BLOCK
    136139        if (entry->op & TRACE_OP_BLOCK) {
    137140         for (i=0; i<entry->size; i++) {
     
    140143        }
    141144
    142         // Determine if additional branch information is available. */
    143         if ( (entry->op & (TRACE_OP_TAKEN|TRACE_OP_NOT_TAKEN)) != 0 ) {
     145        // Determine if additional branch information is available.
     146       if ( (entry->op & (TRACE_OP_TAKEN|TRACE_OP_NOT_TAKEN)) != 0 ) {
    144147          unsigned int a = entry->pc + entry->size - 1;
    145148          while (!aCoverageMap->isStartOfInstruction(a))
    146149            a--;
    147           aCoverageMap->setIsBranch( a );
    148           if (entry->op & TRACE_OP_TAKEN) {
    149             aCoverageMap->setWasTaken( a );
    150           } else if (entry->op & TRACE_OP_NOT_TAKEN) {
     150          if (entry->op & TRACE_OP_TAKEN) {
     151            aCoverageMap->setWasTaken( a );
     152          } else if (entry->op & TRACE_OP_NOT_TAKEN) {
    151153            aCoverageMap->setWasNotTaken( a );
    152           }
    153         }
     154          }
     155        }
    154156      }
    155157    }
  • rtems-coverage/DesiredSymbols.cc

    ref2241b rc1a3cbc  
    107107  }
    108108
    109   void DesiredSymbols::computeUncovered( void )
    110   {
    111     uint32_t                                             a, la, ha;
    112     uint32_t                                             endAddress;
     109  void DesiredSymbols::Preprocess( void )
     110  {
     111    CoverageMapBase*                                             theCoverageMap;
    113112    std::list<ObjdumpProcessor::objdumpLine_t>::reverse_iterator itr;
    114     DesiredSymbols::symbolSet_t::iterator                sitr;
    115     CoverageRanges*                                      theBranches;
    116     CoverageMapBase*                                     theCoverageMap;
    117     CoverageRanges*                                      theRanges;
     113    std::list<ObjdumpProcessor::objdumpLine_t>::iterator         fitr;
     114    DesiredSymbols::symbolSet_t::iterator                        sitr;
    118115
    119116    // Look at each symbol.
     
    128125        continue;
    129126
    130       // Create containers for the symbol's uncovered ranges and branches.
    131       theRanges = new CoverageRanges();
    132       sitr->second.uncoveredRanges = theRanges;
    133       theBranches = new CoverageRanges();
    134       sitr->second.uncoveredBranches = theBranches;
    135 
    136127      // Mark any trailing nops as executed.  Some targets use nops to
    137128      // force alignment of the next method but still include the nops
    138129      // in the symbol size.
     130      //
     131      // Mark all branches as isBranch.
    139132      //
    140133      // NOTE: If nop's are used for alignment inside a method, this
     
    149142            );
    150143          }
     144        } else
     145          break;
     146      }
     147
     148      for (fitr = sitr->second.instructions.begin(), fitr++;
     149           fitr != sitr->second.instructions.end();
     150           fitr++) {
     151        if (fitr->isBranch) {
     152           theCoverageMap->setIsBranch( fitr->address -  sitr->second.baseAddress );
    151153        }
    152         else
    153           break;
    154       }
     154      }
     155
     156    }
     157  }
     158
     159  void DesiredSymbols::computeUncovered( void )
     160  {
     161    uint32_t                                             a, la, ha;
     162    uint32_t                                             endAddress;
     163    std::list<ObjdumpProcessor::objdumpLine_t>::reverse_iterator itr;
     164    DesiredSymbols::symbolSet_t::iterator                sitr;
     165    CoverageRanges*                                      theBranches;
     166    CoverageMapBase*                                     theCoverageMap;
     167    CoverageRanges*                                      theRanges;
     168
     169    // Look at each symbol.
     170    for (sitr = SymbolsToAnalyze->set.begin();
     171         sitr != SymbolsToAnalyze->set.end();
     172         sitr++) {
     173
     174      // If the unified coverage map does not exist, the symbol was
     175      // never referenced by any executable.  Just skip it.
     176      theCoverageMap = sitr->second.unifiedCoverageMap;
     177      if (!theCoverageMap)
     178        continue;
     179
     180      // Create containers for the symbol's uncovered ranges and branches.
     181      theRanges = new CoverageRanges();
     182      sitr->second.uncoveredRanges = theRanges;
     183      theBranches = new CoverageRanges();
     184      sitr->second.uncoveredBranches = theBranches;
    155185
    156186      // Now scan through the coverage map of this symbol.
     
    556586
    557587      // Merge the execution data.
    558       if (sourceCoverageMap->wasExecuted( sAddress))
     588      if (sourceCoverageMap->wasExecuted( sAddress ))
    559589        destinationCoverageMap->setWasExecuted( dAddress );
    560590
    561591      // Merge the branch data.
    562       if (sourceCoverageMap->isBranch( sAddress )) {
    563 
    564         destinationCoverageMap->setIsBranch( dAddress );
    565 
    566         if (sourceCoverageMap->wasTaken( sAddress))
    567           destinationCoverageMap->setWasTaken( dAddress );
    568 
    569         if (sourceCoverageMap->wasNotTaken( sAddress))
    570           destinationCoverageMap->setWasNotTaken( dAddress );
    571       }
     592      if (sourceCoverageMap->wasTaken( sAddress ))
     593        destinationCoverageMap->setWasTaken( dAddress );
     594
     595      if (sourceCoverageMap->wasNotTaken( sAddress ))
     596        destinationCoverageMap->setWasNotTaken( dAddress );
    572597    }
    573598  }
  • rtems-coverage/DesiredSymbols.h

    ref2241b rc1a3cbc  
    210210    );
    211211
     212    /*!
     213     *  This method preprocess each symbols coverage map to marking nop
     214     *  and branch information.
     215     */
     216    void Preprocess( void );
     217
    212218  private:
    213219
  • rtems-coverage/Makefile

    ref2241b rc1a3cbc  
    44
    55INSTALL_DIR=../bin
    6 CXXFLAGS=-g -Wall -O2 -march=native -mtune=native
     6CXXFLAGS=-g -Wall -O0 -march=native -mtune=native
    77PROGRAMS=covoar qemu-dump-trace trace-converter
    88
  • rtems-coverage/ObjdumpProcessor.cc

    ref2241b rc1a3cbc  
    3838  )
    3939  {
    40     if (target_m)
    41       return target_m->isBranch( instruction );
    42  
    43     fprintf( stderr, "ERROR!!! unknown architecture!!!\n");
    44     assert(0);
    45     return false;
     40    if (!target_m) {
     41      fprintf( stderr, "ERROR!!! unknown architecture!!!\n");
     42      assert(0);
     43      return false;
     44    }
     45
     46    return target_m->isBranch( instruction );
     47  }
     48
     49  bool ObjdumpProcessor::isBranchLine(
     50    const char* const line
     51  )
     52  {
     53    if (!target_m) {
     54      fprintf( stderr, "ERROR!!! unknown architecture!!!\n");
     55      assert(0);
     56      return false;
     57    }
     58
     59    return  target_m->isBranchLine( line );
    4660  }
    4761
     
    5266  {
    5367
    54     if (target_m)
    55       return target_m->isNopLine( line, size );
    56 
    57     fprintf( stderr, "ERROR!!! unknown architecture!!!\n");
    58     fprintf( stderr, "HOW LARGE IS NOP ON THIS ARCHITECTURE? -- fix me\n" );
    59     assert(0);
    60 
    61     // ASSUME: ARM dump uses nop instruction. Really "mov r0,r0"
    62     return false;
     68    if (!target_m){
     69      fprintf( stderr, "ERROR!!! unknown architecture!!!\n");
     70      fprintf( stderr, "HOW LARGE IS NOP ON THIS ARCHITECTURE? -- fix me\n" );
     71      assert(0);
     72      return false;
     73    }
     74
     75    return target_m->isNopLine( line, size );
    6376  }
    6477
     
    200213      lineInfo.isNop         = false;
    201214      lineInfo.nopSize       = 0;
     215      lineInfo.isBranch      = false;
    202216
    203217      // Look for the start of a symbol's objdump and extract
     
    258272            lineInfo.isInstruction = true;
    259273            lineInfo.isNop         = isNop( buffer, lineInfo.nopSize );
     274            lineInfo.isBranch      = isBranchLine( buffer );
    260275
    261276            // mark the address as the beginning of an instruction.
  • rtems-coverage/ObjdumpProcessor.h

    ref2241b rc1a3cbc  
    6565      int nopSize;
    6666
     67      /*!
     68       *  This member variable contains an indication of whether the line
     69       *  is a branch instruction.
     70       */
     71      bool isBranch;
     72
    6773    } objdumpLine_t;
    6874
     
    115121    bool IsBranch( const char *instruction );
    116122
     123    /*!
     124     *  This method returns true if the instruction from
     125     *  the given line in the objdmp file is a branch instruction,
     126     *  otherwise it returns false.
     127     */
     128    bool isBranchLine(
     129      const char* const line
     130    );
    117131
    118132  private:
  • rtems-coverage/TargetBase.cc

    ref2241b rc1a3cbc  
    1010 */
    1111#include "TargetBase.h"
     12#include <algorithm>
     13#include <stdio.h>
    1214
    1315namespace Target {
    1416
    15   TargetBase::TargetBase( std::string targetName ):
     17  TargetBase::TargetBase(
     18    std::string targetName
     19  ):
    1620    targetName_m( targetName )
    1721  {
     
    2226  }
    2327
     28
     29  bool TargetBase::isBranch(
     30      const char* const instruction
     31  )
     32  {
     33    if (branchInstructions.empty()) {
     34      fprintf(
     35        stderr,
     36        "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n"
     37       );
     38       exit( -1 );   
     39    }
     40   
     41    if ( find(
     42           branchInstructions.begin(),
     43           branchInstructions.end(),
     44           instruction
     45        ) == branchInstructions.end()
     46    )
     47      return false;
     48    return true;
     49  }
     50
     51  bool TargetBase::isBranchLine(
     52    const char* const line
     53  )
     54  {
     55    const char *ch;
     56    char instruction[120];
     57    int  result;
     58
     59   
     60    ch = &(line[0]);
     61
     62    // Increment to the first tab in the line
     63    while ((*ch != '\t') && (*ch != '\0')) {
     64      ch++;
     65    }
     66    if (*ch != '\t') {
     67      fprintf(
     68        stderr,
     69        "ERROR: TargetBase::isBranchLine - Unable to find instruction\n"
     70      );
     71      exit( -1 );   
     72    }
     73    ch++;
     74
     75    // Increment to the second tab in the line
     76    while ((*ch != '\t') && (*ch != '\0'))
     77      ch++;
     78    if (*ch != '\t') {
     79      fprintf(
     80        stderr,
     81        "ERROR: TargetBase::isBranchLine - Unable to find instruction\n"
     82      );
     83      exit( -1 );   
     84    }
     85    ch++;
     86
     87    // Grab the instruction which is the next word in the buffer after the second tab.
     88    result = sscanf( ch, "%s", instruction );
     89    if (result != 1) {
     90        fprintf(
     91          stderr,
     92          "ERROR: TargetBase::isBranchLine - Unable to find instruction\n"
     93        );
     94        exit( -1 );
     95    }
     96
     97    return isBranch( instruction );
     98  }
    2499}
  • rtems-coverage/TargetBase.h

    ref2241b rc1a3cbc  
    5252    ) = 0;
    5353
     54
     55    /*!
     56     *  This method determins if the objdump line contains a
     57     *  branch instruction.
     58     *
     59     *  @param[in] line contains the object dump line to check
     60     *  @param[out] size is set to the size in bytes of the nop
     61     *
     62     *  @return Returns TRUE if the instruction is a branch, FALSE otherwise.
     63     */
     64    bool isBranchLine(
     65      const char* const line
     66    );
     67
     68   
    5469    /*!
    5570     *  This method determines if the specified line from an
    5671     *  objdump file is a branch instruction.
    5772     */
    58     virtual bool isBranch(
     73    bool isBranch(
    5974      const char* const instruction
    60     ) = 0;
     75    );
    6176
    62   private:
     77  protected:
    6378
    6479    /*!
     
    6782    std::string    targetName_m;
    6883
     84    /*!
     85     * This member variable indicates either the column that the instruction
     86     * starts in the object dump file, when the objdump has no tabs; or the
     87     * number of tabs to find the instruction.
     88     */
     89    int objdumpInstructionLocation;
     90
     91    /*!
     92     *  This member variable indicates whether or not the objdump has
     93     *  tabs as delemeters.
     94     */
     95    bool objdumpHasTabs;
     96
     97    /*!
     98     * This member variable is an array of all branch instructions
     99     * for this target.
     100     */
     101    std::list <std::string> branchInstructions;
    69102  };
    70103}
  • rtems-coverage/Target_i386.cc

    ref2241b rc1a3cbc  
    1111
    1212#include "Target_i386.h"
    13 #include <stdio.h>
    1413#include <stdlib.h>
    1514#include <string.h>
    1615#include <unistd.h>
    17 #include <algorithm>
    1816
    1917namespace Target {
     
    9795  }
    9896
    99   bool Target_i386::isBranch(
    100       const char* const instruction
    101   )
    102   {
    103     if ( find(
    104            branchInstructions.begin(),
    105            branchInstructions.end(),
    106            instruction
    107         ) == branchInstructions.end()
    108     )
    109       return false;
    110     return true;
    111   }
    11297
    11398  TargetBase *Target_i386_Constructor(
  • rtems-coverage/Target_i386.h

    ref2241b rc1a3cbc  
    5252    );
    5353
    54     /*!
    55      *  This method determines if the specified line from an
    56      *  objdump file is a branch instruction.
    57      */
    58     bool isBranch(
    59       const char* const instruction
    60     );
    61 
    6254  private:
    63     std::list <std::string> branchInstructions;
    6455  };
    6556
  • rtems-coverage/Target_lm32.cc

    ref2241b rc1a3cbc  
    4747  }
    4848
    49   bool Target_lm32::isBranch(
    50       const char* const instruction
    51   )
    52   {
    53     if ( find(
    54            branchInstructions.begin(),
    55            branchInstructions.end(),
    56            instruction
    57         ) == branchInstructions.end()
    58     )
    59       return false;
    60     return true;
    61   }
    62 
    6349  TargetBase *Target_lm32_Constructor(
    6450    std::string          targetName
  • rtems-coverage/Target_lm32.h

    ref2241b rc1a3cbc  
    5252    );
    5353
    54     /*!
    55      *  This method determines if the specified instruction from an
    56      *  objdump file is a branch instruction.
    57      */
    58     bool isBranch(
    59       const char* const instruction
    60     );
    61 
    6254  private:
    63     std::list <std::string> branchInstructions;
    6455
    6556  };
  • rtems-coverage/Target_sparc.cc

    ref2241b rc1a3cbc  
    4848  }
    4949
    50   bool Target_sparc::isBranch(
    51       const char* const instruction
    52   )
    53   {
    54     fprintf( stderr, "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n" );
    55     exit( -1 );   
    56   }
    5750
    5851  TargetBase *Target_sparc_Constructor(
  • rtems-coverage/TraceReaderLogQEMU.cc

    ref2241b rc1a3cbc  
    5252  {
    5353    bool                done          = false;
    54     bool                isBranch      = false;
    5554    QEMU_LOG_IN_Block_t first         = { 0, "", "" };
    5655    QEMU_LOG_IN_Block_t last          = { 0, "", "" };
     
    160159      // the block; otherwise add the block to the trace list.
    161160      if (nextlogical != 0) {
    162         isBranch = objdumpProcessor->IsBranch( last.instruction );
     161        TraceList::exitReason_t reason = TraceList::EXIT_REASON_OTHER;
    163162
    164         if (  isBranch &&
    165           ( nextExecuted.address == nextlogical )) {
    166           Trace.add(
    167             first.address,
    168             nextlogical,
    169             TraceList::EXIT_REASON_BRANCH_NOT_TAKEN
    170           );
    171         } else if (isBranch) {
    172           Trace.add(
    173             first.address,
    174             nextlogical,
    175             TraceList::EXIT_REASON_BRANCH_TAKEN
    176           );
    177         } else
    178           Trace.add(first.address, nextlogical, TraceList::EXIT_REASON_OTHER);
     163        if ( objdumpProcessor->IsBranch( last.instruction ) ) {
     164          if ( nextExecuted.address == nextlogical ) {
     165            reason = TraceList::EXIT_REASON_BRANCH_NOT_TAKEN;
     166          }  else {
     167            reason = TraceList::EXIT_REASON_BRANCH_TAKEN;
     168          }
     169        }
     170        Trace.add( first.address, nextlogical, reason );
    179171      }
    180172      first = nextExecuted;
  • rtems-coverage/covoar.cc

    ref2241b rc1a3cbc  
    286286  }
    287287
     288  // Do necessary preprocessing uncovered ranges and branches
     289  if (Verbose)
     290     fprintf( stderr, "Preprocess uncovered ranges and branches\n" );
     291  SymbolsToAnalyze->Preprocess();
     292
    288293  // Determine the uncovered ranges and branches.
    289294  if (Verbose)
Note: See TracChangeset for help on using the changeset viewer.