Ticket #1900: covoar.patch

File covoar.patch, 7.8 KB (added by Pawel, on 08/18/11 at 16:59:03)

Covoar : adding backend calculating instruction execution counts for future gcov support

  • rtems-testing/covoar/CoverageMapBase.cc

    RCS file: /usr1/CVS/rtems-testing/covoar/CoverageMapBase.cc,v
    retrieving revision 1.4
    diff -u -8 -p -r1.4 CoverageMapBase.cc
    namespace Coverage { 
    3535
    3636    Info = new perAddressInfo_t[ Size ];
    3737
    3838    for (a=0; a<Size; a++) {
    3939
    4040      perAddressInfo_t *i = &Info[ a ];
    4141
    4242      i->isStartOfInstruction = false;
    43       i->wasExecuted          = false;
     43      i->wasExecuted          = 0;
    4444      i->isBranch             = false;
    4545      i->isNop                = false;
    4646      i->wasTaken             = false;
    4747      i->wasNotTaken          = false;
    4848    }
    4949  }
    5050
    5151  CoverageMapBase::~CoverageMapBase()
    namespace Coverage { 
    195195
    196196  void CoverageMapBase::setWasExecuted( uint32_t address )
    197197  {
    198198    uint32_t offset;
    199199 
    200200    if (determineOffset( address, &offset ) != true)
    201201      return;
    202202
    203     Info[ offset ].wasExecuted = true;
     203    Info[ offset ].wasExecuted += 1;
    204204  }
    205205
     206  void CoverageMapBase::sumWasExecuted( uint32_t address, uint32_t addition)
     207  {
     208    uint32_t offset;
     209 
     210    if (determineOffset( address, &offset ) != true)
     211      return;
     212
     213    Info[ offset ].wasExecuted += addition;
     214   }
     215
    206216  bool CoverageMapBase::wasExecuted( uint32_t address ) const
    207217  {
    208218    uint32_t offset;
     219    bool     result;
    209220 
     221    result = true;
     222
    210223    if (determineOffset( address, &offset ) != true)
    211       return false;
     224      result = false;
     225
     226    if (Info[ offset ].wasExecuted <= 0)
     227      result = false;
     228
     229    return result;
     230  }
     231
     232  uint32_t CoverageMapBase::getWasExecuted( uint32_t address ) const
     233  {
     234    uint32_t offset;
     235
     236    if (determineOffset( address, &offset ) != true)
     237      return 0;
    212238
    213    return Info[ offset ].wasExecuted;
     239    return Info[ offset ].wasExecuted; 
    214240  }
    215241
    216242  void CoverageMapBase::setIsBranch(
    217243    uint32_t    address
    218244  )
    219245  {
    220246    uint32_t offset;
    221247 
  • rtems-testing/covoar/CoverageMapBase.h

    RCS file: /usr1/CVS/rtems-testing/covoar/CoverageMapBase.h,v
    retrieving revision 1.3
    diff -u -8 -p -r1.3 CoverageMapBase.h
    namespace Coverage { 
    170170     *  @param[in] address specifies the address to check
    171171     *
    172172     *  @return Returns TRUE if the specified address is the start
    173173     *   of an instruction and FALSE otherwise.
    174174     */
    175175    bool isStartOfInstruction( uint32_t address ) const;
    176176
    177177    /*!
    178      *  This method sets the boolean which indicates that the instruction
    179      *  at the specified address was executed.
     178     *  This method iterates the counter which indicates how many times
     179     *  the instruction at the specified address was executed.
    180180     *
    181181     *  @param[in] address specifies the address which was executed
    182182     */
    183183    virtual void setWasExecuted( uint32_t address );
    184184
    185185    /*!
    186186     *  This method returns a boolean which indicates if the instruction
    187187     *  at the specified address was executed.
    namespace Coverage { 
    189189     *  @param[in] address specifies the address to check
    190190     * 
    191191     *  @return Returns TRUE if the instruction at the specified
    192192     *   address was executed and FALSE otherwise.
    193193     */
    194194    bool wasExecuted( uint32_t address ) const;
    195195
    196196    /*!
     197     *  This method increases the counter which indicates how many times
     198     *  the instruction at the specified address was executed. It is used
     199     *  for merging coverage maps.
     200     *
     201     *  @param[in] address specifies the address which was executed
     202     *  @param[in] address specifies the execution count that should be
     203     *             added
     204     */
     205    virtual void sumWasExecuted( uint32_t address, uint32_t addition);
     206
     207    /*!
     208     *  This method returns an unsigned integer which indicates how often
     209     *  the instruction at the specified address was executed.
     210     *
     211     *  @param[in] address specifies the address to check
     212     * 
     213     *  @return Returns number of executins
     214     */
     215    uint32_t getWasExecuted( uint32_t address ) const;
     216
     217    /*!
    197218     *  This method sets the boolean which indicates if the specified
    198219     *  address is the starting address of a branch instruction.
    199220     *
    200221     *  @param[in] address specifies the address of the branch instruction
    201222     */
    202223    void setIsBranch( uint32_t address );
    203224
    204225    /*!
    namespace Coverage { 
    299320     */
    300321    typedef struct {
    301322      /*!
    302323       *  This member indicates that the address is the start of
    303324       *  an instruction.
    304325       */
    305326      bool isStartOfInstruction;
    306327      /*!
    307        *  This member indicates that the address was executed.
     328       *  This member indicates how many times the address was executed.
    308329       */
    309       bool wasExecuted;
     330      uint32_t wasExecuted;
    310331      /*!
    311332       *  This member indicates that the address is a branch instruction.
    312333       */
    313334      bool isBranch;
    314335      /*!
    315336       *  This member indicates that the address is a NOP instruction.
    316337       */
    317338      bool isNop;
  • rtems-testing/covoar/DesiredSymbols.cc

    RCS file: /usr1/CVS/rtems-testing/covoar/DesiredSymbols.cc,v
    retrieving revision 1.7
    diff -u -8 -p -r1.7 DesiredSymbols.cc
    namespace Coverage { 
    624624  {
    625625    uint32_t              dAddress;
    626626    CoverageMapBase*      destinationCoverageMap;
    627627    uint32_t              dMapSize;
    628628    symbolSet_t::iterator itr;
    629629    uint32_t              sAddress;
    630630    uint32_t              sBaseAddress;
    631631    uint32_t              sMapSize;
     632    uint32_t              executionCount;
    632633   
    633634    // Ensure that the symbol is a desired symbol.
    634635    itr = set.find( symbolName );
    635636
    636637    if (itr == set.end()) {
    637638
    638639      fprintf(
    639640        stderr,
    namespace Coverage { 
    668669
    669670      sAddress = dAddress + sBaseAddress;
    670671
    671672      // Merge start of instruction indication.
    672673      if (sourceCoverageMap->isStartOfInstruction( sAddress ))
    673674        destinationCoverageMap->setIsStartOfInstruction( dAddress );
    674675
    675676      // Merge the execution data.
    676       if (sourceCoverageMap->wasExecuted( sAddress ))
    677         destinationCoverageMap->setWasExecuted( dAddress );
     677      executionCount = sourceCoverageMap->getWasExecuted( sAddress );
     678      destinationCoverageMap->sumWasExecuted( dAddress, executionCount );
    678679
    679680      // Merge the branch data.
    680681      if (sourceCoverageMap->wasTaken( sAddress ))
    681682        destinationCoverageMap->setWasTaken( dAddress );
    682683
    683684      if (sourceCoverageMap->wasNotTaken( sAddress ))
    684685        destinationCoverageMap->setWasNotTaken( dAddress );
    685686    }
  • rtems-testing/covoar/covoar.cc

    RCS file: /usr1/CVS/rtems-testing/covoar/covoar.cc,v
    retrieving revision 1.3
    diff -u -8 -p -r1.3 covoar.cc
    void usage() 
    7676#define PrintableString(_s) \
    7777       ((!(_s)) ? "NOT SET" : (_s))
    7878
    7979/*
    8080 *  Configuration File Support
    8181 */
    8282#include "ConfigFile.h"
    8383Configuration::FileReader *CoverageConfiguration;
    84 
    8584Configuration::Options_t Options[] = {
    8685  { "explanations",         NULL },
    8786  { "format",               NULL },
    8887  { "symbolsFile",          NULL },
    8988  { "outputDirectory",      NULL },
    9089  { "executableExtension",  NULL },
    9190  { "coverageExtension",    NULL },
    9291  { "target",               NULL },